Skip to content

Commit

Permalink
revert: do not use node: protocol for imports (aws#3651)
Browse files Browse the repository at this point in the history
It requires node 14.18.0 or greater, which is way more recent than
the earliest node engine we claim to support.



---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
  • Loading branch information
RomainMuller authored Jul 8, 2022
1 parent afada33 commit 8d84440
Show file tree
Hide file tree
Showing 109 changed files with 189 additions and 254 deletions.
4 changes: 0 additions & 4 deletions eslint-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ plugins:
- '@typescript-eslint'
- import
- prettier
- unicorn

parser: '@typescript-eslint/parser'
parserOptions:
Expand Down Expand Up @@ -44,9 +43,6 @@ rules:
'prettier/prettier':
- error

'unicorn/prefer-node-protocol':
- error

'@typescript-eslint/array-type':
- error
- default: array-simple
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"eslint-import-resolver-typescript": "^3.2.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-unicorn": "^43.0.0",
"jest": "^28.1.2",
"jest-circus": "^28.1.2",
"jest-config": "^28.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/@jsii/benchmarks/bin/benchmark.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from 'fs-extra';
import * as path from 'node:path';
import * as path from 'path';
import * as yargs from 'yargs';

import { benchmarks } from '../lib';
Expand Down
8 changes: 2 additions & 6 deletions packages/@jsii/benchmarks/lib/benchmark.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { Profiler, Session } from 'node:inspector';
import {
performance,
PerformanceObserver,
PerformanceEntry,
} from 'node:perf_hooks';
import { Profiler, Session } from 'inspector';
import { performance, PerformanceObserver, PerformanceEntry } from 'perf_hooks';

/**
* Result of a single run of the subject
Expand Down
2 changes: 1 addition & 1 deletion packages/@jsii/benchmarks/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from 'node:path';
import * as path from 'path';

export const fixturesDir = path.resolve(__dirname, '..', 'fixtures');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Compiler } from 'jsii/lib/compiler';
import { loadProjectInfo } from 'jsii/lib/project-info';
import * as path from 'node:path';
import * as process from 'node:process';
import * as path from 'path';
import * as process from 'process';
import * as ts from 'typescript';

import type { Context } from '.';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs-extra';
import * as path from 'node:path';
import * as process from 'node:process';
import * as path from 'path';
import * as process from 'process';
import * as ts from 'typescript';

import type { Context } from '.';
Expand Down
6 changes: 3 additions & 3 deletions packages/@jsii/benchmarks/lib/suite/aws-cdk-lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as cp from 'child_process';
import * as fs from 'fs-extra';
import * as cp from 'node:child_process';
import * as os from 'node:os';
import * as path from 'node:path';
import * as os from 'os';
import * as path from 'path';

import { cdkTag, cdk } from '../../constants';
import { inDirectory, streamUntar } from '../../util';
Expand Down
6 changes: 3 additions & 3 deletions packages/@jsii/benchmarks/scripts/snapshot-package.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as cp from 'child_process';
import * as fs from 'fs-extra';
import * as glob from 'glob';
import * as cp from 'node:child_process';
import * as os from 'node:os';
import * as path from 'node:path';
import * as os from 'os';
import * as path from 'path';
import * as tar from 'tar';
import * as ts from 'typescript';

Expand Down
2 changes: 1 addition & 1 deletion packages/@jsii/check-node/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as process from 'node:process';
import * as process from 'process';
import { Range, SemVer } from 'semver';

const ONE_DAY_IN_MILLISECONDS = 86_400_000;
Expand Down
4 changes: 2 additions & 2 deletions packages/@jsii/check-node/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Chalk, bgYellow, bgYellowBright, bgRed } from 'chalk';
import { error } from 'node:console';
import { version } from 'node:process';
import { error } from 'console';
import { version } from 'process';

import { NodeRelease } from './constants';

Expand Down
4 changes: 2 additions & 2 deletions packages/@jsii/integ-test/test/build-cdk.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Octokit } from '@octokit/rest';
import * as dotenv from 'dotenv';
import { mkdtemp, readdir, remove } from 'fs-extra';
import { tmpdir } from 'node:os';
import * as path from 'node:path';
import { tmpdir } from 'os';
import * as path from 'path';

import {
downloadReleaseAsset,
Expand Down
8 changes: 4 additions & 4 deletions packages/@jsii/integ-test/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as cp from 'node:child_process';
import { IncomingMessage } from 'node:http';
import * as https from 'node:https';
import { Readable } from 'node:stream';
import * as cp from 'child_process';
import { IncomingMessage } from 'http';
import * as https from 'https';
import { Readable } from 'stream';
import { extract } from 'tar';

/**
Expand Down
10 changes: 5 additions & 5 deletions packages/@jsii/kernel/src/kernel.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as childProcess from 'child_process';
import * as fs from 'fs-extra';
import * as childProcess from 'node:child_process';
import * as os from 'node:os';
import { join } from 'node:path';
import * as path from 'node:path';
import * as vm from 'node:vm';
import * as os from 'os';
import { join } from 'path';
import * as path from 'path';
import * as vm from 'vm';

import * as api from './api';
import {
Expand Down
10 changes: 5 additions & 5 deletions packages/@jsii/kernel/src/kernel.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as spec from '@jsii/spec';
import { loadAssemblyFromPath } from '@jsii/spec';
import * as cp from 'child_process';
import * as fs from 'fs-extra';
import * as cp from 'node:child_process';
import * as os from 'node:os';
import * as path from 'node:path';
import * as vm from 'node:vm';
import * as os from 'os';
import * as path from 'path';
import * as tar from 'tar';
import * as vm from 'vm';

import * as api from './api';
import { TOKEN_REF } from './api';
Expand Down Expand Up @@ -49,7 +49,7 @@ export class Kernel {
// I wonder if webpack has some pragma that allows opting-out at certain points
// in the code.
// eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires
const moduleLoad = require('node:module').Module._load;
const moduleLoad = require('module').Module._load;
const nodeRequire = (p: string) => moduleLoad(p, module, false);

this.sandbox = vm.createContext({
Expand Down
2 changes: 1 addition & 1 deletion packages/@jsii/kernel/src/on-exit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from 'fs-extra';
import * as process from 'node:process';
import * as process from 'process';

const removeSyncPaths = new Array<string>();

Expand Down
4 changes: 2 additions & 2 deletions packages/@jsii/kernel/src/serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
*/

import * as spec from '@jsii/spec';
import * as assert from 'node:assert';
import { inspect } from 'node:util';
import * as assert from 'assert';
import { inspect } from 'util';

import {
isObjRef,
Expand Down
10 changes: 5 additions & 5 deletions packages/@jsii/runtime/bin/jsii-runtime.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import '@jsii/check-node/run';

import { spawn } from 'node:child_process';
import { error } from 'node:console';
import { constants as os } from 'node:os';
import { resolve } from 'node:path';
import { Duplex } from 'node:stream';
import { spawn } from 'child_process';
import { error } from 'console';
import { constants as os } from 'os';
import { resolve } from 'path';
import { Duplex } from 'stream';

// Spawn another node process, with the following file descriptor setup:
// - No STDIN will be provided
Expand Down
2 changes: 1 addition & 1 deletion packages/@jsii/runtime/lib/host.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { api, Kernel } from '@jsii/kernel';
import { EventEmitter } from 'node:events';
import { EventEmitter } from 'events';

import { Input, IInputOutput } from './in-out';

Expand Down
2 changes: 1 addition & 1 deletion packages/@jsii/runtime/lib/sync-stdio.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as fs from 'node:fs';
import * as fs from 'fs';

const INPUT_BUFFER_SIZE = 1_048_576; // 1MiB (aka: 1024 * 1024), not related to max line length

Expand Down
6 changes: 3 additions & 3 deletions packages/@jsii/runtime/test/kernel-host.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { api } from '@jsii/kernel';
import * as spec from '@jsii/spec';
import { loadAssemblyFromPath } from '@jsii/spec';
import * as child from 'node:child_process';
import * as fs from 'node:fs';
import * as path from 'node:path';
import * as child from 'child_process';
import * as fs from 'fs';
import * as path from 'path';

import { KernelHost, IInputOutput, Input, Output } from '../lib';

Expand Down
8 changes: 4 additions & 4 deletions packages/@jsii/runtime/test/playback.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as child from 'node:child_process';
import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import * as child from 'child_process';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';

import { IInputOutput, Input, KernelHost, Output } from '../lib';

Expand Down
6 changes: 3 additions & 3 deletions packages/@jsii/spec/src/assembly-utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from 'fs-extra';
import * as os from 'node:os';
import * as path from 'node:path';
import * as zlib from 'node:zlib';
import * as os from 'os';
import * as path from 'path';
import * as zlib from 'zlib';

import {
SPEC_FILE_NAME,
Expand Down
6 changes: 3 additions & 3 deletions packages/@jsii/spec/src/assembly-utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import * as zlib from 'node:zlib';
import * as fs from 'fs';
import * as path from 'path';
import * as zlib from 'zlib';

import {
Assembly,
Expand Down
4 changes: 2 additions & 2 deletions packages/@jsii/spec/src/validate-assembly.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFileSync, readdirSync } from 'node:fs';
import { resolve } from 'node:path';
import { readFileSync, readdirSync } from 'fs';
import { resolve } from 'path';

import { validateAssembly } from './validate-assembly';

Expand Down
4 changes: 2 additions & 2 deletions packages/codemaker/src/codemaker.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs-extra';
import * as os from 'node:os';
import * as path from 'node:path';
import * as os from 'os';
import * as path from 'path';

import { CodeMaker } from './codemaker';

Expand Down
2 changes: 1 addition & 1 deletion packages/codemaker/src/codemaker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as util from 'node:util';
import * as util from 'util';

import * as caseutils from './case-utils';
import FileBuffer from './filebuff';
Expand Down
4 changes: 2 additions & 2 deletions packages/codemaker/src/filebuff.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs-extra';
import * as os from 'node:os';
import * as path from 'node:path';
import * as os from 'os';
import * as path from 'path';

import FileBuffer from './filebuff';

Expand Down
2 changes: 1 addition & 1 deletion packages/codemaker/src/filebuff.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from 'node:path';
import * as path from 'path';

/**
* Buffers the text of a file for later saving.
Expand Down
2 changes: 1 addition & 1 deletion packages/jsii-calc/lib/cdk16625/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from 'node:assert';
import * as assert from 'assert';

import { IRandomNumberGenerator } from '../calculator';
import { UnimportedSubmoduleType } from './donotimport';
Expand Down
10 changes: 5 additions & 5 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
StructWithOnlyOptionals,
NumericValue,
} from '@scope/jsii-calc-lib';
import * as crypto from 'node:crypto';
import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import { promisify } from 'node:util';
import * as crypto from 'crypto';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import { promisify } from 'util';

import {
IFriendlyRandomGenerator,
Expand Down
2 changes: 1 addition & 1 deletion packages/jsii-calc/test/test.calc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as calcLib from '@scope/jsii-calc-lib';
import * as assert from 'node:assert';
import * as assert from 'assert';

import {
Add,
Expand Down
6 changes: 3 additions & 3 deletions packages/jsii-calc/test/test.transitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// take a direct dependency on @scope/jsii-calc-base-of-base, which is intended
// to only be used as a transitive dependency through @scope/jsii-calc-base.

import * as assert from 'node:assert';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import * as assert from 'assert';
import { readFileSync } from 'fs';
import { join } from 'path';

const pkgjsonPath = join(__dirname, '..', 'package.json');
const pkgjson = JSON.parse(readFileSync(pkgjsonPath, 'utf-8'));
Expand Down
4 changes: 2 additions & 2 deletions packages/jsii-config/bin/jsii-config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '@jsii/check-node/run';

import { writeFile } from 'node:fs';
import { promisify } from 'node:util';
import { writeFile } from 'fs';
import { promisify } from 'util';
import * as yargs from 'yargs';

import jsiiConfig from '../lib';
Expand Down
2 changes: 1 addition & 1 deletion packages/jsii-config/lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFile } from 'node:fs';
import { readFile } from 'fs';

/*
* Look for existing nested values in config, return undefined if not found
Expand Down
2 changes: 1 addition & 1 deletion packages/jsii-config/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from 'fs';
import * as inquirer from 'inquirer';
import * as fs from 'node:fs';

import jsiiConfig from '../lib';
import { packageJsonObject, findQuestions, findQuestion } from './util';
Expand Down
8 changes: 4 additions & 4 deletions packages/jsii-diff/lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as childProcess from 'child_process';
import * as fs from 'fs-extra';
import * as log4js from 'log4js';
import * as childProcess from 'node:child_process';
import * as os from 'node:os';
import * as path from 'node:path';
import * as util from 'node:util';
import * as os from 'os';
import * as path from 'path';
import * as util from 'util';

const LOG = log4js.getLogger('jsii-diff');

Expand Down
2 changes: 1 addition & 1 deletion packages/jsii-pacmak/lib/builder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Rosetta } from 'jsii-rosetta';
import * as path from 'node:path';
import * as path from 'path';

import * as logging from './logging';
import { JsiiModule } from './packaging';
Expand Down
2 changes: 1 addition & 1 deletion packages/jsii-pacmak/lib/dependency-graph.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from 'fs-extra';
import { join } from 'node:path';
import { join } from 'path';

import * as util from './util';

Expand Down
Loading

0 comments on commit 8d84440

Please sign in to comment.