Skip to content

Commit 4f3a0d1

Browse files
authored
feat(@jsii/spec): add loadAssemblyFromBuffer function (#3634)
Usage is demonstrated here: cdklabs/construct-hub#920 Two implementations were considered to fit the use case in construct hub, `loadAssemblyFromBuffer` and `loadAssemblyFromTarball`. I went with loading from a buffer because it allows us to utilize prior art in construct hub for parsing tarballs, does not need an added dependency on `tar`, and causes minimal impact when refactoring the ingestion lambda to use this function. Also includes a small refactoring of the test suite. --- 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
1 parent e13ef56 commit 4f3a0d1

File tree

113 files changed

+559
-288
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+559
-288
lines changed

eslint-config.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ plugins:
88
- '@typescript-eslint'
99
- import
1010
- prettier
11+
- unicorn
1112

1213
parser: '@typescript-eslint/parser'
1314
parserOptions:
@@ -43,6 +44,9 @@ rules:
4344
'prettier/prettier':
4445
- error
4546

47+
'unicorn/prefer-node-protocol':
48+
- error
49+
4650
'@typescript-eslint/array-type':
4751
- error
4852
- default: array-simple
@@ -152,7 +156,9 @@ rules:
152156

153157
'import/no-extraneous-dependencies':
154158
- error
155-
- devDependencies: ['**/test/**'] # Only allow importing devDependencies from tests
159+
- devDependencies: # Only allow importing devDependencies from tests
160+
- '**/test/**'
161+
- '**/*.test.ts'
156162
optionalDependencies: false # Disallow importing optional dependencies (those shouldn't be used here)
157163
peerDependencies: false # Disallow importing peer dependencies (those shouldn't be used here)
158164

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"eslint-import-resolver-typescript": "^2.7.1",
2828
"eslint-plugin-import": "^2.26.0",
2929
"eslint-plugin-prettier": "^4.0.0",
30+
"eslint-plugin-unicorn": "^43.0.0",
3031
"jest": "^28.1.1",
3132
"jest-circus": "^28.1.1",
3233
"jest-config": "^28.1.1",

packages/@jsii/benchmarks/bin/benchmark.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as fs from 'fs-extra';
2-
import * as path from 'path';
2+
import * as path from 'node:path';
33
import * as yargs from 'yargs';
44

55
import { benchmarks } from '../lib';

packages/@jsii/benchmarks/lib/benchmark.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
import { Profiler, Session } from 'inspector';
2-
import { performance, PerformanceObserver, PerformanceEntry } from 'perf_hooks';
1+
import { Profiler, Session } from 'node:inspector';
2+
import {
3+
performance,
4+
PerformanceObserver,
5+
PerformanceEntry,
6+
} from 'node:perf_hooks';
37

48
/**
59
* Result of a single run of the subject

packages/@jsii/benchmarks/lib/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as path from 'path';
1+
import * as path from 'node:path';
22

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

packages/@jsii/benchmarks/scripts/snapshot-package.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import * as cp from 'child_process';
21
import * as fs from 'fs-extra';
32
import * as glob from 'glob';
4-
import * as os from 'os';
5-
import * as path from 'path';
3+
import * as cp from 'node:child_process';
4+
import * as os from 'node:os';
5+
import * as path from 'node:path';
66
import * as tar from 'tar';
77
import * as ts from 'typescript';
88

packages/@jsii/check-node/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as process from 'process';
1+
import * as process from 'node:process';
22
import { Range, SemVer } from 'semver';
33

44
const ONE_DAY_IN_MILLISECONDS = 86_400_000;

packages/@jsii/check-node/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Chalk, bgYellow, bgYellowBright, bgRed } from 'chalk';
2-
import { error } from 'console';
3-
import { version } from 'process';
2+
import { error } from 'node:console';
3+
import { version } from 'node:process';
44

55
import { NodeRelease } from './constants';
66

packages/@jsii/integ-test/test/build-cdk.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Octokit } from '@octokit/rest';
22
import * as dotenv from 'dotenv';
33
import { mkdtemp, readdir, remove } from 'fs-extra';
4-
import { tmpdir } from 'os';
5-
import * as path from 'path';
4+
import { tmpdir } from 'node:os';
5+
import * as path from 'node:path';
66

77
import {
88
downloadReleaseAsset,

packages/@jsii/integ-test/utils/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as cp from 'child_process';
2-
import { IncomingMessage } from 'http';
3-
import * as https from 'https';
4-
import { Readable } from 'stream';
1+
import * as cp from 'node:child_process';
2+
import { IncomingMessage } from 'node:http';
3+
import * as https from 'node:https';
4+
import { Readable } from 'node:stream';
55
import { extract } from 'tar';
66

77
/**

0 commit comments

Comments
 (0)