From 0d77db8dd49e7519d1a7ed7db368bb6cc6c2e039 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Dec 2021 22:31:45 +0000 Subject: [PATCH 01/14] chore(deps-dev): update wheel requirement from ~=0.37.0 to ~=0.37.1 in /packages/jsii-pacmak/lib/targets/python (#3287) --- .../jsii-pacmak/lib/targets/python/requirements-dev.txt | 2 +- .../generated-code/__snapshots__/examples.test.ts.snap | 4 ++-- .../__snapshots__/prerelease-identifiers.test.ts.snap | 8 ++++---- .../__snapshots__/target-python.test.ts.snap | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/jsii-pacmak/lib/targets/python/requirements-dev.txt b/packages/jsii-pacmak/lib/targets/python/requirements-dev.txt index 90ffd2fc28..028ff319b4 100644 --- a/packages/jsii-pacmak/lib/targets/python/requirements-dev.txt +++ b/packages/jsii-pacmak/lib/targets/python/requirements-dev.txt @@ -4,6 +4,6 @@ # package (wheel, sdist), but not declared as build-system dependencies. setuptools~=59.6.0 # build-system -wheel~=0.37.0 # build-system +wheel~=0.37.1 # build-system twine~=3.7.1 diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap index 624e3892b6..ebf8d2a3d9 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap @@ -1147,7 +1147,7 @@ testpkg.FooBar=example.test.demo.FooBar exports[`diamond-struct-parameter.ts: /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=59.6.0", "wheel~=0.37.0"] +requires = ["setuptools~=59.6.0", "wheel~=0.37.1"] build-backend = "setuptools.build_meta" `; @@ -2447,7 +2447,7 @@ testpkg.Namespace2.Foo.Final=example.test.demo.Namespace2$Foo.Final exports[`nested-types.ts: /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=59.6.0", "wheel~=0.37.0"] +requires = ["setuptools~=59.6.0", "wheel~=0.37.1"] build-backend = "setuptools.build_meta" `; diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.ts.snap index 0d9d45331c..721d8977b2 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.ts.snap @@ -416,7 +416,7 @@ foo exports[`foo@1.2.3 depends on bar@^2.0.0-rc.42: /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=59.6.0", "wheel~=0.37.0"] +requires = ["setuptools~=59.6.0", "wheel~=0.37.1"] build-backend = "setuptools.build_meta" `; @@ -925,7 +925,7 @@ foo exports[`foo@1.2.3 depends on bar@^4.5.6-pre.1337: /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=59.6.0", "wheel~=0.37.0"] +requires = ["setuptools~=59.6.0", "wheel~=0.37.1"] build-backend = "setuptools.build_meta" `; @@ -1414,7 +1414,7 @@ foo exports[`foo@2.0.0-rc.42: /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=59.6.0", "wheel~=0.37.0"] +requires = ["setuptools~=59.6.0", "wheel~=0.37.1"] build-backend = "setuptools.build_meta" `; @@ -1900,7 +1900,7 @@ foo exports[`foo@4.5.6-pre.1337: /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=59.6.0", "wheel~=0.37.0"] +requires = ["setuptools~=59.6.0", "wheel~=0.37.1"] build-backend = "setuptools.build_meta" `; diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap index 35b92b1edf..f618f261c7 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap @@ -243,7 +243,7 @@ scope.jsii-calc-base exports[`Generated code for "@scope/jsii-calc-base": /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=59.6.0", "wheel~=0.37.0"] +requires = ["setuptools~=59.6.0", "wheel~=0.37.1"] build-backend = "setuptools.build_meta" `; @@ -723,7 +723,7 @@ scope.jsii-calc-base-of-base exports[`Generated code for "@scope/jsii-calc-base-of-base": /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=59.6.0", "wheel~=0.37.0"] +requires = ["setuptools~=59.6.0", "wheel~=0.37.1"] build-backend = "setuptools.build_meta" `; @@ -1176,7 +1176,7 @@ scope.jsii-calc-lib exports[`Generated code for "@scope/jsii-calc-lib": /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=59.6.0", "wheel~=0.37.0"] +requires = ["setuptools~=59.6.0", "wheel~=0.37.1"] build-backend = "setuptools.build_meta" `; @@ -2408,7 +2408,7 @@ foo = "bar" exports[`Generated code for "jsii-calc": /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=59.6.0", "wheel~=0.37.0"] +requires = ["setuptools~=59.6.0", "wheel~=0.37.1"] build-backend = "setuptools.build_meta" `; From 086540a72e7062804cdb72c971775b0f9622ff41 Mon Sep 17 00:00:00 2001 From: Eli Polonsky Date: Sat, 25 Dec 2021 15:11:13 +0200 Subject: [PATCH 02/14] chore: deprecation warnings test are timing out (#3297) These tests have been sporadically yet consistently timing out in CI. https://github.com/aws/jsii/runs/4629721868?check_suite_focus=true Increasing timeouts. --- 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 --- packages/jsii/test/deprecation-warnings.test.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/jsii/test/deprecation-warnings.test.ts b/packages/jsii/test/deprecation-warnings.test.ts index c105eb37b4..668d9a9e04 100644 --- a/packages/jsii/test/deprecation-warnings.test.ts +++ b/packages/jsii/test/deprecation-warnings.test.ts @@ -200,11 +200,11 @@ function testpkg_Baz(p) { ` export interface Baz { /** @deprecated message from Baz */ - readonly x: string; + readonly x: string; } export interface Bar { /** @deprecated message from Bar */ - readonly x: string; + readonly x: string; } export interface Foo extends Bar, Baz { } @@ -248,11 +248,11 @@ function testpkg_Baz(p) { const result = await compileJsiiForTest( ` export interface Baz { - readonly x: string; + readonly x: string; } export interface Bar { /** @deprecated message from Bar */ - readonly x: string; + readonly x: string; } export interface Foo extends Bar, Baz { } @@ -345,7 +345,7 @@ function testpkg_Baz(p) { // Recompiling without deprecation warning to leave the packages in a clean state await compile(calcBaseRoot, false); await compile(calcLibRoot, false); - }, 50000); + }, 120000); }); describe('Call injections', () => { @@ -386,7 +386,7 @@ describe('Call injections', () => { expect(content).toContain( `const jsiiDeprecationWarnings = require("${expectedPath}")`, ); - }); + }, 60000); test('does not generate a require statement when no calls were injected', async () => { const result = await compileJsiiForTest( @@ -406,7 +406,7 @@ describe('Call injections', () => { expect(content).not.toContain( `const jsiiDeprecationWarnings = require("${expectedPath}")`, ); - }); + }, 60000); test('deprecated methods', async () => { const result = await compileJsiiForTest( @@ -440,7 +440,7 @@ describe('Call injections', () => { expect(jsFile(result)).toMatch( 'bar(a, b) { jsiiDeprecationWarnings.testpkg_A(a); return a.x + b; }', ); - }); + }, 60000); test('deprecated getters', async () => { const result = await compileJsiiForTest( From d2459fd7238f43bf7df05d897059e7acc738d1ea Mon Sep 17 00:00:00 2001 From: Eli Polonsky Date: Sun, 26 Dec 2021 11:22:36 +0200 Subject: [PATCH 03/14] chore: merge dependabot with mergify (#3298) --- .github/workflows/auto-approve.yml | 41 +++--------------------------- .github/workflows/pr-labeler.yml | 18 +++++++++++++ .mergify/config.yml | 6 ----- 3 files changed, 22 insertions(+), 43 deletions(-) create mode 100644 .github/workflows/pr-labeler.yml diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index c6751dee68..b4dc8c2b56 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -12,44 +12,11 @@ on: jobs: auto-approve: - if: contains(github.event.pull_request.labels.*.name, 'pr/auto-approve') || github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' - + if: contains(github.event.pull_request.labels.*.name, 'pr/auto-approve') permissions: pull-requests: write runs-on: ubuntu-latest - steps: - # Check whether the PR needs an automated approval or not. We will only add an automated - # approval if the PR currently has no reviews on it. Dismissed reviews are ignored in the - # context of this check. This way, the automated workflow will not do anything if a manual - # review has already been done for the PR (implicit opt-out). - - uses: actions/github-script@v5.0.0 - id: needs-approving - with: - script: |- - const { issue: { number: pull_number }, repo: { owner, repo } } = context; - const reviews = (await github.rest.pulls.listReviews({ owner, repo, pull_number })).data - .filter((review) => review.state !== 'DISMISSED'); - return reviews.length === 0; - - # If this is NOT a dependabot PR, just approve it. - - uses: actions/github-script@v5.0.0 - if: steps.needs-approving.outputs.result == 'true' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' - with: - script: |- - const { issue: { number: pull_number }, repo: { owner, repo } } = context; - github.rest.pulls.createReview({ - owner, repo, pull_number, - event: 'APPROVE', - }); - # If this IS a dependabot PR, approve it and ask dependabot to squash-and-merge it when CI passes. - - uses: actions/github-script@v5.0.0 - if: steps.needs-approving.outputs.result == 'true' && (github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]') - with: - script: |- - const { issue: { number: pull_number }, repo: { owner, repo } } = context; - github.rest.pulls.createReview({ - owner, repo, pull_number, - body: '@dependabot squash and merge', - event: 'APPROVE', - }); \ No newline at end of file + - uses: hmarr/auto-approve-action@v2.1.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml new file mode 100644 index 0000000000..9b597bde76 --- /dev/null +++ b/.github/workflows/pr-labeler.yml @@ -0,0 +1,18 @@ +# Apply various labels on PRs + +name: pr-labeler +on: + pull_request: + types: [ opened ] + +jobs: + auto-approve: + if: github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'dependabot-preview[bot]' + runs-on: ubuntu-latest + permissions: + pull-requests: write + issues: write + steps: + - run: gh pr edit ${{ github.event.pull_request.number }} --add-label "pr/auto-approve" -R ${{ github.repository }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.mergify/config.yml b/.mergify/config.yml index 0dba861be7..8c6c3f928b 100644 --- a/.mergify/config.yml +++ b/.mergify/config.yml @@ -39,8 +39,6 @@ pull_request_rules: label: add: [pr/ready-to-merge] conditions: - - author!=dependabot[bot] - - author!=dependabot-preview[bot] - -title~=(WIP|wip) - label!=pr/blocked - label!=pr/do-not-merge @@ -89,8 +87,6 @@ pull_request_rules: comment: message: Merging (with squash)... conditions: - - author!=dependabot[bot] - - author!=dependabot-preview[bot] - -title~=(WIP|wip) - label!=pr/blocked - label!=pr/do-not-merge @@ -140,8 +136,6 @@ pull_request_rules: comment: message: Merging (no-squash)... conditions: - - author!=dependabot[bot] - - author!=dependabot-preview[bot] - -title~=(WIP|wip) - label!=pr/blocked - label!=pr/do-not-merge From 3b7ac53d9f1e3d26b9ea3555443d75bcb49d682d Mon Sep 17 00:00:00 2001 From: Eli Polonsky Date: Sun, 26 Dec 2021 17:07:43 +0200 Subject: [PATCH 04/14] chore: rename label for auto approvals (#3300) See https://github.com/aws/aws-cdk/pull/18183 --- 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 --- .github/workflows/auto-approve.yml | 4 ++-- .github/workflows/pr-labeler.yml | 2 +- .github/workflows/yarn-upgrade.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index b4dc8c2b56..1206e3fe61 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -1,4 +1,4 @@ -# Approve PRs with "pr/auto-approve". mergify takes care of the actual merge. +# Approve PRs with "auto-approve". mergify takes care of the actual merge. name: auto-approve on: @@ -12,7 +12,7 @@ on: jobs: auto-approve: - if: contains(github.event.pull_request.labels.*.name, 'pr/auto-approve') + if: contains(github.event.pull_request.labels.*.name, 'auto-approve') permissions: pull-requests: write runs-on: ubuntu-latest diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml index 9b597bde76..1619f8bc4c 100644 --- a/.github/workflows/pr-labeler.yml +++ b/.github/workflows/pr-labeler.yml @@ -13,6 +13,6 @@ jobs: pull-requests: write issues: write steps: - - run: gh pr edit ${{ github.event.pull_request.number }} --add-label "pr/auto-approve" -R ${{ github.repository }} + - run: gh pr edit ${{ github.event.pull_request.number }} --add-label "auto-approve" -R ${{ github.repository }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/yarn-upgrade.yml b/.github/workflows/yarn-upgrade.yml index c94b43b0be..ab4f0b5d74 100644 --- a/.github/workflows/yarn-upgrade.yml +++ b/.github/workflows/yarn-upgrade.yml @@ -140,7 +140,7 @@ jobs: title: 'chore: npm-check-updates && yarn upgrade' body: |- Ran npm-check-updates and yarn upgrade to keep the `yarn.lock` file up-to-date. - labels: contribution/core,dependencies,pr/auto-approve + labels: contribution/core,dependencies,auto-approve team-reviewers: aws-cdk-team # Privileged token so automated PR validation happens token: ${{ secrets.AUTO_APPROVE_GITHUB_TOKEN }} From 63132cf30ad62ba59d2a8cdfaba60b92819352cd Mon Sep 17 00:00:00 2001 From: Aatman Date: Tue, 28 Dec 2021 00:46:56 +0530 Subject: [PATCH 05/14] feat(pacmak): go yaml struct tags (#3299) closes #3293 --- 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 --- .../lib/targets/go/types/type-member.ts | 6 +- .../__snapshots__/examples.test.ts.snap | 14 +- .../__snapshots__/target-go.test.ts.snap | 232 +++++++++--------- 3 files changed, 127 insertions(+), 125 deletions(-) diff --git a/packages/jsii-pacmak/lib/targets/go/types/type-member.ts b/packages/jsii-pacmak/lib/targets/go/types/type-member.ts index 843b73fd54..78c61dc69b 100644 --- a/packages/jsii-pacmak/lib/targets/go/types/type-member.ts +++ b/packages/jsii-pacmak/lib/targets/go/types/type-member.ts @@ -76,8 +76,10 @@ export class GoProperty implements GoTypeMember { ? `*${this.returnType}` : this.returnType; - // Adds json tags for easy deserialization - code.line(`${this.name} ${memberType} \`json:"${this.property.name}"\``); + // Adds json and yaml tags for easy deserialization + code.line( + `${this.name} ${memberType} \`json:"${this.property.name}" yaml:"${this.property.name}"\``, + ); // TODO add newline if not the last member } diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap index ebf8d2a3d9..24cd0361f9 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap @@ -421,9 +421,9 @@ import ( ) type Baz struct { - Foo *float64 \`json:"foo"\` - Bar *string \`json:"bar"\` - Baz *bool \`json:"baz"\` + Foo *float64 \`json:"foo" yaml:"foo"\` + Bar *string \`json:"bar" yaml:"bar"\` + Baz *bool \`json:"baz" yaml:"baz"\` } type Consumer interface { @@ -445,12 +445,12 @@ func Consumer_ConsumeBaz(baz *Baz) { } type Foo struct { - Foo *float64 \`json:"foo"\` + Foo *float64 \`json:"foo" yaml:"foo"\` } type FooBar struct { - Foo *float64 \`json:"foo"\` - Bar *string \`json:"bar"\` + Foo *float64 \`json:"foo" yaml:"foo"\` + Bar *string \`json:"bar" yaml:"bar"\` } @@ -1796,7 +1796,7 @@ func (n *jsiiProxy_Namespace1) Foo() { } type Namespace1_Foo struct { - Bar *string \`json:"bar"\` + Bar *string \`json:"bar" yaml:"bar"\` } type Namespace1_IBar interface { diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.ts.snap index 86f1d64f4e..8a5013518a 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.ts.snap @@ -296,8 +296,8 @@ func (b *jsiiProxy_Base) TypeName() interface{} { } type BaseProps struct { - Foo scopejsiicalcbaseofbase.Very \`json:"foo"\` - Bar *string \`json:"bar"\` + Foo scopejsiicalcbaseofbase.Very \`json:"foo" yaml:"foo"\` + Bar *string \`json:"bar" yaml:"bar"\` } type IBaseInterface interface { @@ -820,7 +820,7 @@ func (v *jsiiProxy_Very) Hey() *float64 { } type VeryBaseProps struct { - Foo Very \`json:"foo"\` + Foo Very \`json:"foo" yaml:"foo"\` } @@ -1201,15 +1201,15 @@ func NewNestingClass_NestedClass_Override(n NestingClass_NestedClass) { // Deprecated. type NestingClass_NestedStruct struct { // Deprecated. - Name *string \`json:"name"\` + Name *string \`json:"name" yaml:"name"\` } // Deprecated. type ReflectableEntry struct { // Deprecated. - Key *string \`json:"key"\` + Key *string \`json:"key" yaml:"key"\` // Deprecated. - Value interface{} \`json:"value"\` + Value interface{} \`json:"value" yaml:"value"\` } // Deprecated. @@ -1450,17 +1450,17 @@ func (b *jsiiProxy_BaseFor2647) Foo(obj jcb.IBaseInterface) { // Deprecated. type DiamondLeft struct { // Deprecated. - HoistedTop *string \`json:"hoistedTop"\` + HoistedTop *string \`json:"hoistedTop" yaml:"hoistedTop"\` // Deprecated. - Left *float64 \`json:"left"\` + Left *float64 \`json:"left" yaml:"left"\` } // Deprecated. type DiamondRight struct { // Deprecated. - HoistedTop *string \`json:"hoistedTop"\` + HoistedTop *string \`json:"hoistedTop" yaml:"hoistedTop"\` // Deprecated. - Right *bool \`json:"right"\` + Right *bool \`json:"right" yaml:"right"\` } // Check that enums from \\@scoped packages can be references. @@ -1554,12 +1554,12 @@ func (i *jsiiProxy_IThreeLevelsInterface) Baz() { type MyFirstStruct struct { // An awesome number value. // Deprecated. - Anumber *float64 \`json:"anumber"\` + Anumber *float64 \`json:"anumber" yaml:"anumber"\` // A string value. // Deprecated. - Astring *string \`json:"astring"\` + Astring *string \`json:"astring" yaml:"astring"\` // Deprecated. - FirstOptional *[]*string \`json:"firstOptional"\` + FirstOptional *[]*string \`json:"firstOptional" yaml:"firstOptional"\` } // Represents a concrete number. @@ -1795,11 +1795,11 @@ func (o *jsiiProxy_Operation) TypeName() interface{} { type StructWithOnlyOptionals struct { // The first optional! // Deprecated. - Optional1 *string \`json:"optional1"\` + Optional1 *string \`json:"optional1" yaml:"optional1"\` // Deprecated. - Optional2 *float64 \`json:"optional2"\` + Optional2 *float64 \`json:"optional2" yaml:"optional2"\` // Deprecated. - Optional3 *bool \`json:"optional3"\` + Optional3 *bool \`json:"optional3" yaml:"optional3"\` } @@ -2921,7 +2921,7 @@ func (j *jsiiProxy_Foo) SetBar(val *string) { } type Hello struct { - Foo *float64 \`json:"foo"\` + Foo *float64 \`json:"foo" yaml:"foo"\` } @@ -2960,7 +2960,7 @@ package interfaceinnamespaceonlyinterface type Hello struct { - Foo *float64 \`json:"foo"\` + Foo *float64 \`json:"foo" yaml:"foo"\` } @@ -4777,14 +4777,14 @@ type CalculatorProps struct { // The initial value of the calculator. // // NOTE: Any number works here, it's fine. - InitialValue *float64 \`json:"initialValue"\` + InitialValue *float64 \`json:"initialValue" yaml:"initialValue"\` // The maximum value the calculator can store. - MaximumValue *float64 \`json:"maximumValue"\` + MaximumValue *float64 \`json:"maximumValue" yaml:"maximumValue"\` } type ChildStruct982 struct { - Foo *string \`json:"foo"\` - Bar *float64 \`json:"bar"\` + Foo *string \`json:"foo" yaml:"foo"\` + Bar *float64 \`json:"bar" yaml:"bar"\` } type ClassThatImplementsTheInternalInterface interface { @@ -5506,7 +5506,7 @@ func ConfusingToJackson_MakeStructInstance() *ConfusingToJacksonStruct { } type ConfusingToJacksonStruct struct { - UnionProperty interface{} \`json:"unionProperty"\` + UnionProperty interface{} \`json:"unionProperty" yaml:"unionProperty"\` } type ConstructorPassesThisOut interface { @@ -5961,9 +5961,9 @@ func (c *jsiiProxy_ConsumersOfThisCrazyTypeSystem) ConsumeNonInternalInterface(o } type ContainerProps struct { - ArrayProp *[]*DummyObj \`json:"arrayProp"\` - ObjProp *map[string]*DummyObj \`json:"objProp"\` - RecordProp *map[string]*DummyObj \`json:"recordProp"\` + ArrayProp *[]*DummyObj \`json:"arrayProp" yaml:"arrayProp"\` + ObjProp *map[string]*DummyObj \`json:"objProp" yaml:"objProp"\` + RecordProp *map[string]*DummyObj \`json:"recordProp" yaml:"recordProp"\` } // Verifies proper type handling through dynamic overrides. @@ -6307,58 +6307,58 @@ const ( // Deprecated: it just wraps a string type DeprecatedStruct struct { // Deprecated: well, yeah - ReadonlyProperty *string \`json:"readonlyProperty"\` + ReadonlyProperty *string \`json:"readonlyProperty" yaml:"readonlyProperty"\` } // A struct which derives from another struct. type DerivedStruct struct { // An awesome number value. // Deprecated. - Anumber *float64 \`json:"anumber"\` + Anumber *float64 \`json:"anumber" yaml:"anumber"\` // A string value. // Deprecated. - Astring *string \`json:"astring"\` + Astring *string \`json:"astring" yaml:"astring"\` // Deprecated. - FirstOptional *[]*string \`json:"firstOptional"\` - AnotherRequired *time.Time \`json:"anotherRequired"\` - Bool *bool \`json:"bool"\` + FirstOptional *[]*string \`json:"firstOptional" yaml:"firstOptional"\` + AnotherRequired *time.Time \`json:"anotherRequired" yaml:"anotherRequired"\` + Bool *bool \`json:"bool" yaml:"bool"\` // An example of a non primitive property. - NonPrimitive DoubleTrouble \`json:"nonPrimitive"\` + NonPrimitive DoubleTrouble \`json:"nonPrimitive" yaml:"nonPrimitive"\` // This is optional. - AnotherOptional *map[string]scopejsiicalclib.NumericValue \`json:"anotherOptional"\` - OptionalAny interface{} \`json:"optionalAny"\` - OptionalArray *[]*string \`json:"optionalArray"\` + AnotherOptional *map[string]scopejsiicalclib.NumericValue \`json:"anotherOptional" yaml:"anotherOptional"\` + OptionalAny interface{} \`json:"optionalAny" yaml:"optionalAny"\` + OptionalArray *[]*string \`json:"optionalArray" yaml:"optionalArray"\` } type DiamondBottom struct { // Deprecated. - HoistedTop *string \`json:"hoistedTop"\` + HoistedTop *string \`json:"hoistedTop" yaml:"hoistedTop"\` // Deprecated. - Left *float64 \`json:"left"\` + Left *float64 \`json:"left" yaml:"left"\` // Deprecated. - Right *bool \`json:"right"\` - Bottom *time.Time \`json:"bottom"\` + Right *bool \`json:"right" yaml:"right"\` + Bottom *time.Time \`json:"bottom" yaml:"bottom"\` } type DiamondInheritanceBaseLevelStruct struct { - BaseLevelProperty *string \`json:"baseLevelProperty"\` + BaseLevelProperty *string \`json:"baseLevelProperty" yaml:"baseLevelProperty"\` } type DiamondInheritanceFirstMidLevelStruct struct { - BaseLevelProperty *string \`json:"baseLevelProperty"\` - FirstMidLevelProperty *string \`json:"firstMidLevelProperty"\` + BaseLevelProperty *string \`json:"baseLevelProperty" yaml:"baseLevelProperty"\` + FirstMidLevelProperty *string \`json:"firstMidLevelProperty" yaml:"firstMidLevelProperty"\` } type DiamondInheritanceSecondMidLevelStruct struct { - BaseLevelProperty *string \`json:"baseLevelProperty"\` - SecondMidLevelProperty *string \`json:"secondMidLevelProperty"\` + BaseLevelProperty *string \`json:"baseLevelProperty" yaml:"baseLevelProperty"\` + SecondMidLevelProperty *string \`json:"secondMidLevelProperty" yaml:"secondMidLevelProperty"\` } type DiamondInheritanceTopLevelStruct struct { - BaseLevelProperty *string \`json:"baseLevelProperty"\` - FirstMidLevelProperty *string \`json:"firstMidLevelProperty"\` - SecondMidLevelProperty *string \`json:"secondMidLevelProperty"\` - TopLevelProperty *string \`json:"topLevelProperty"\` + BaseLevelProperty *string \`json:"baseLevelProperty" yaml:"baseLevelProperty"\` + FirstMidLevelProperty *string \`json:"firstMidLevelProperty" yaml:"firstMidLevelProperty"\` + SecondMidLevelProperty *string \`json:"secondMidLevelProperty" yaml:"secondMidLevelProperty"\` + TopLevelProperty *string \`json:"topLevelProperty" yaml:"topLevelProperty"\` } // Verifies that null/undefined can be returned for optional collections. @@ -6692,7 +6692,7 @@ func (d *jsiiProxy_DoubleTrouble) Next() *float64 { } type DummyObj struct { - Example *string \`json:"example"\` + Example *string \`json:"example" yaml:"example"\` } // Ensures we can override a dynamic property that was inherited. @@ -7047,8 +7047,8 @@ func EraseUndefinedHashValues_Prop2IsUndefined() *map[string]interface{} { } type EraseUndefinedHashValuesOptions struct { - Option1 *string \`json:"option1"\` - Option2 *string \`json:"option2"\` + Option1 *string \`json:"option1" yaml:"option1"\` + Option2 *string \`json:"option2" yaml:"option2"\` } // Experimental. @@ -7139,7 +7139,7 @@ const ( // Experimental. type ExperimentalStruct struct { // Experimental. - ReadonlyProperty *string \`json:"readonlyProperty"\` + ReadonlyProperty *string \`json:"readonlyProperty" yaml:"readonlyProperty"\` } type ExportedBaseClass interface { @@ -7187,8 +7187,8 @@ func NewExportedBaseClass_Override(e ExportedBaseClass, success *bool) { } type ExtendsInternalInterface struct { - Boom *bool \`json:"boom"\` - Prop *string \`json:"prop"\` + Boom *bool \`json:"boom" yaml:"boom"\` + Prop *string \`json:"prop" yaml:"prop"\` } type ExternalClass interface { @@ -7272,7 +7272,7 @@ const ( ) type ExternalStruct struct { - ReadonlyProperty *string \`json:"readonlyProperty"\` + ReadonlyProperty *string \`json:"readonlyProperty" yaml:"readonlyProperty"\` } type GiveMeStructs interface { @@ -7367,7 +7367,7 @@ func (g *jsiiProxy_GiveMeStructs) ReadFirstNumber(first *scopejsiicalclib.MyFirs // These are some arguments you can pass to a method. type Greetee struct { // The name of the greetee. - Name *string \`json:"name"\` + Name *string \`json:"name" yaml:"name"\` } type GreetingAugmenter interface { @@ -8670,9 +8670,9 @@ func (j *jsiiProxy_ImplementsPrivateInterface) SetPrivate(val *string) { } type ImplictBaseOfBase struct { - Foo scopejsiicalcbaseofbase.Very \`json:"foo"\` - Bar *string \`json:"bar"\` - Goo *time.Time \`json:"goo"\` + Foo scopejsiicalcbaseofbase.Very \`json:"foo" yaml:"foo"\` + Bar *string \`json:"bar" yaml:"bar"\` + Goo *time.Time \`json:"goo" yaml:"goo"\` } type InbetweenClass interface { @@ -10182,15 +10182,15 @@ func NewLevelOne_Override(l LevelOne, props *LevelOneProps) { } type LevelOne_PropBooleanValue struct { - Value *bool \`json:"value"\` + Value *bool \`json:"value" yaml:"value"\` } type LevelOne_PropProperty struct { - Prop *LevelOne_PropBooleanValue \`json:"prop"\` + Prop *LevelOne_PropBooleanValue \`json:"prop" yaml:"prop"\` } type LevelOneProps struct { - Prop *LevelOne_PropProperty \`json:"prop"\` + Prop *LevelOne_PropProperty \`json:"prop" yaml:"prop"\` } // jsii#298: show default values in sphinx documentation, and respect newlines. @@ -10198,7 +10198,7 @@ type LoadBalancedFargateServiceProps struct { // The container port of the application load balancer attached to your Fargate service. // // Corresponds to container port mapping. - ContainerPort *float64 \`json:"containerPort"\` + ContainerPort *float64 \`json:"containerPort" yaml:"containerPort"\` // The number of cpu units used by the task. // // Valid values, which determines your range of valid values for the memory parameter: @@ -10209,7 +10209,7 @@ type LoadBalancedFargateServiceProps struct { // 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB increments // // This default is set in the underlying FargateTaskDefinition construct. - Cpu *string \`json:"cpu"\` + Cpu *string \`json:"cpu" yaml:"cpu"\` // The amount (in MiB) of memory used by the task. // // This field is required and you must use one of the following values, which determines your range of valid values @@ -10226,11 +10226,11 @@ type LoadBalancedFargateServiceProps struct { // Between 8GB and 30GB in 1GB increments - Available cpu values: 4096 (4 vCPU) // // This default is set in the underlying FargateTaskDefinition construct. - MemoryMiB *string \`json:"memoryMiB"\` + MemoryMiB *string \`json:"memoryMiB" yaml:"memoryMiB"\` // Determines whether the Application Load Balancer will be internet-facing. - PublicLoadBalancer *bool \`json:"publicLoadBalancer"\` + PublicLoadBalancer *bool \`json:"publicLoadBalancer" yaml:"publicLoadBalancer"\` // Determines whether your Fargate Service will be assigned a public IP address. - PublicTasks *bool \`json:"publicTasks"\` + PublicTasks *bool \`json:"publicTasks" yaml:"publicTasks"\` } type MethodNamedProperty interface { @@ -10614,7 +10614,7 @@ func NestedClassInstance_MakeInstance() customsubmodulename.NestingClass_NestedC type NestedStruct struct { // When provided, must be > 0. - NumberProp *float64 \`json:"numberProp"\` + NumberProp *float64 \`json:"numberProp" yaml:"numberProp"\` } // Test fixture to verify that jsii modules can use the node standard library. @@ -10795,8 +10795,8 @@ func (n *jsiiProxy_NullShouldBeTreatedAsUndefined) VerifyPropertyIsUndefined() { } type NullShouldBeTreatedAsUndefinedData struct { - ArrayWithThreeElementsAndUndefinedAsSecondArgument *[]interface{} \`json:"arrayWithThreeElementsAndUndefinedAsSecondArgument"\` - ThisShouldBeUndefined interface{} \`json:"thisShouldBeUndefined"\` + ArrayWithThreeElementsAndUndefinedAsSecondArgument *[]interface{} \`json:"arrayWithThreeElementsAndUndefinedAsSecondArgument" yaml:"arrayWithThreeElementsAndUndefinedAsSecondArgument"\` + ThisShouldBeUndefined interface{} \`json:"thisShouldBeUndefined" yaml:"thisShouldBeUndefined"\` } // This allows us to test that a reference can be stored for objects that implement interfaces. @@ -11135,7 +11135,7 @@ func NewOptionalConstructorArgument_Override(o OptionalConstructorArgument, arg1 } type OptionalStruct struct { - Field *string \`json:"field"\` + Field *string \`json:"field" yaml:"field"\` } type OptionalStructConsumer interface { @@ -11344,7 +11344,7 @@ func (o *jsiiProxy_OverrideReturnsObject) Test(obj IReturnsNumber) *float64 { // https://github.com/aws/jsii/issues/982. type ParentStruct982 struct { - Foo *string \`json:"foo"\` + Foo *string \`json:"foo" yaml:"foo"\` } type PartiallyInitializedThisConsumer interface { @@ -12145,8 +12145,8 @@ func NewReturnsPrivateImplementationOfInterface_Override(r ReturnsPrivateImpleme // idiomatic" way for Pythonists. type RootStruct struct { // May not be empty. - StringProp *string \`json:"stringProp"\` - NestedStruct *NestedStruct \`json:"nestedStruct"\` + StringProp *string \`json:"stringProp" yaml:"stringProp"\` + NestedStruct *NestedStruct \`json:"nestedStruct" yaml:"nestedStruct"\` } type RootStructValidator interface { @@ -12229,9 +12229,9 @@ func (r *jsiiProxy_RuntimeTypeChecking) MethodWithOptionalArguments(arg1 *float6 type SecondLevelStruct struct { // It's long and required. - DeeperRequiredProp *string \`json:"deeperRequiredProp"\` + DeeperRequiredProp *string \`json:"deeperRequiredProp" yaml:"deeperRequiredProp"\` // It's long, but you'll almost never pass it. - DeeperOptionalProp *string \`json:"deeperOptionalProp"\` + DeeperOptionalProp *string \`json:"deeperOptionalProp" yaml:"deeperOptionalProp"\` } // Test that a single instance can be returned under two different FQNs. @@ -12364,8 +12364,8 @@ const ( ) type SmellyStruct struct { - Property *string \`json:"property"\` - YetAnoterOne *bool \`json:"yetAnoterOne"\` + Property *string \`json:"property" yaml:"property"\` + YetAnoterOne *bool \`json:"yetAnoterOne" yaml:"yetAnoterOne"\` } type SomeTypeJsii976 interface { @@ -12511,7 +12511,7 @@ const ( ) type StableStruct struct { - ReadonlyProperty *string \`json:"readonlyProperty"\` + ReadonlyProperty *string \`json:"readonlyProperty" yaml:"readonlyProperty"\` } // This is used to validate the ability to use \`this\` from within a static context. @@ -12869,24 +12869,24 @@ func (j *jsiiProxy_StripInternal) SetYouSeeMe(val *string) { // We can serialize and deserialize structs without silently ignoring optional fields. type StructA struct { - RequiredString *string \`json:"requiredString"\` - OptionalNumber *float64 \`json:"optionalNumber"\` - OptionalString *string \`json:"optionalString"\` + RequiredString *string \`json:"requiredString" yaml:"requiredString"\` + OptionalNumber *float64 \`json:"optionalNumber" yaml:"optionalNumber"\` + OptionalString *string \`json:"optionalString" yaml:"optionalString"\` } // This intentionally overlaps with StructA (where only requiredString is provided) to test htat the kernel properly disambiguates those. type StructB struct { - RequiredString *string \`json:"requiredString"\` - OptionalBoolean *bool \`json:"optionalBoolean"\` - OptionalStructA *StructA \`json:"optionalStructA"\` + RequiredString *string \`json:"requiredString" yaml:"requiredString"\` + OptionalBoolean *bool \`json:"optionalBoolean" yaml:"optionalBoolean"\` + OptionalStructA *StructA \`json:"optionalStructA" yaml:"optionalStructA"\` } // Verifies that, in languages that do keyword lifting (e.g: Python), having a struct member with the same name as a positional parameter results in the correct code being emitted. // // See: https://github.com/aws/aws-cdk/issues/4302 type StructParameterType struct { - Scope *string \`json:"scope"\` - Props *bool \`json:"props"\` + Scope *string \`json:"scope" yaml:"scope"\` + Props *bool \`json:"props" yaml:"props"\` } // Just because we can. @@ -12997,16 +12997,16 @@ func StructUnionConsumer_IsStructB(struct_ interface{}) *bool { type StructWithEnum struct { // An enum value. - Foo StringEnum \`json:"foo"\` + Foo StringEnum \`json:"foo" yaml:"foo"\` // Optional enum value (of type integer). - Bar AllTypesEnum \`json:"bar"\` + Bar AllTypesEnum \`json:"bar" yaml:"bar"\` } type StructWithJavaReservedWords struct { - Default *string \`json:"default"\` - Assert *string \`json:"assert"\` - Result *string \`json:"result"\` - That *string \`json:"that"\` + Default *string \`json:"default" yaml:"default"\` + Assert *string \`json:"assert" yaml:"assert"\` + Result *string \`json:"result" yaml:"result"\` + That *string \`json:"that" yaml:"that"\` } // An operation that sums multiple values. @@ -13266,11 +13266,11 @@ func NewSupportsNiceJavaBuilder_Override(s SupportsNiceJavaBuilder, id *float64, type SupportsNiceJavaBuilderProps struct { // Some number, like 42. - Bar *float64 \`json:"bar"\` + Bar *float64 \`json:"bar" yaml:"bar"\` // An \`id\` field here is terrible API design, because the constructor of \`SupportsNiceJavaBuilder\` already has a parameter named \`id\`. // // But here we are, doing it like we didn't care. - Id *string \`json:"id"\` + Id *string \`json:"id" yaml:"id"\` } // We can generate fancy builders in Java for classes which take a mix of positional & struct parameters. @@ -13737,11 +13737,11 @@ func (t *jsiiProxy_Thrower) ThrowError() { type TopLevelStruct struct { // This is a required field. - Required *string \`json:"required"\` + Required *string \`json:"required" yaml:"required"\` // A union to really stress test our serialization. - SecondLevel interface{} \`json:"secondLevel"\` + SecondLevel interface{} \`json:"secondLevel" yaml:"secondLevel"\` // You don't have to pass this. - Optional *string \`json:"optional"\` + Optional *string \`json:"optional" yaml:"optional"\` } // In TypeScript it is possible to have two methods with the same name but different capitalization. @@ -13948,8 +13948,8 @@ func (u *jsiiProxy_UnaryOperation) TypeName() interface{} { } type UnionProperties struct { - Bar interface{} \`json:"bar"\` - Foo interface{} \`json:"foo"\` + Bar interface{} \`json:"bar" yaml:"bar"\` + Foo interface{} \`json:"foo" yaml:"foo"\` } // Ensures submodule-imported types from dependencies can be used correctly. @@ -17293,8 +17293,8 @@ import ( ) type MyStruct struct { - BaseMap *map[string]*jcb.BaseProps \`json:"baseMap"\` - Numbers *[]scopejsiicalclib.Number \`json:"numbers"\` + BaseMap *map[string]*jcb.BaseProps \`json:"baseMap" yaml:"baseMap"\` + Numbers *[]scopejsiicalclib.Number \`json:"numbers" yaml:"numbers"\` } @@ -17330,7 +17330,7 @@ package submodule1 type Bar struct { - Bar1 *string \`json:"bar1"\` + Bar1 *string \`json:"bar1" yaml:"bar1"\` } @@ -17359,13 +17359,13 @@ package submodule2 type Bar struct { - Bar2 *string \`json:"bar2"\` + Bar2 *string \`json:"bar2" yaml:"bar2"\` } type Foo struct { - Bar2 *string \`json:"bar2"\` - Bar1 *string \`json:"bar1"\` - Foo2 *string \`json:"foo2"\` + Bar2 *string \`json:"bar2" yaml:"bar2"\` + Bar1 *string \`json:"bar1" yaml:"bar1"\` + Foo2 *string \`json:"foo2" yaml:"foo2"\` } @@ -18665,7 +18665,7 @@ func (i *jsiiProxy_IInterfaceWithSelf) Method(self *float64) *string { } type StructWithSelf struct { - Self *string \`json:"self"\` + Self *string \`json:"self" yaml:"self"\` } @@ -18728,7 +18728,7 @@ import ( ) type MyClassReference struct { - Reference submodule.MyClass \`json:"reference"\` + Reference submodule.MyClass \`json:"reference" yaml:"reference"\` } @@ -18818,8 +18818,8 @@ func InnerClass_StaticProp() *SomeStruct { } type KwargsProps struct { - Prop SomeEnum \`json:"prop"\` - Extra *string \`json:"extra"\` + Prop SomeEnum \`json:"prop" yaml:"prop"\` + Extra *string \`json:"extra" yaml:"extra"\` } // Checks that classes can self-reference during initialization. @@ -18876,11 +18876,11 @@ const ( ) type SomeStruct struct { - Prop SomeEnum \`json:"prop"\` + Prop SomeEnum \`json:"prop" yaml:"prop"\` } type Structure struct { - Bool *bool \`json:"bool"\` + Bool *bool \`json:"bool" yaml:"bool"\` } @@ -19161,7 +19161,7 @@ package param type SpecialParameter struct { - Value *string \`json:"value"\` + Value *string \`json:"value" yaml:"value"\` } @@ -19286,7 +19286,7 @@ import ( // See: https://github.com/aws/jsii/issues/2637 // type Default struct { - Foo *float64 \`json:"foo"\` + Foo *float64 \`json:"foo" yaml:"foo"\` } type MyClass interface { From 04597fbd3975f62e0c96bd941fe08b4b38b0731e Mon Sep 17 00:00:00 2001 From: AWS CDK Automation <43080478+aws-cdk-automation@users.noreply.github.com> Date: Wed, 29 Dec 2021 20:49:28 +0100 Subject: [PATCH 06/14] chore: npm-check-updates && yarn upgrade (#3307) Ran npm-check-updates and yarn upgrade to keep the `yarn.lock` file up-to-date. --- package.json | 4 +- packages/@jsii/check-node/package.json | 2 +- .../@jsii/dotnet-runtime-test/package.json | 2 +- packages/@jsii/dotnet-runtime/package.json | 2 +- packages/@jsii/go-runtime/package.json | 2 +- packages/@jsii/integ-test/package.json | 2 +- packages/@jsii/java-runtime/package.json | 2 +- packages/@jsii/kernel/package.json | 2 +- packages/@jsii/runtime/package.json | 2 +- packages/@jsii/spec/package.json | 2 +- .../jsii-calc-base-of-base/package.json | 2 +- packages/@scope/jsii-calc-base/package.json | 2 +- packages/@scope/jsii-calc-lib/package.json | 2 +- packages/codemaker/package.json | 2 +- packages/jsii-calc/package.json | 2 +- packages/jsii-config/package.json | 4 +- packages/jsii-diff/package.json | 2 +- packages/jsii-pacmak/package.json | 2 +- packages/jsii-reflect/package.json | 2 +- packages/jsii-rosetta/package.json | 4 +- packages/jsii/package.json | 2 +- packages/oo-ascii-tree/package.json | 2 +- tools/jsii-compliance/package.json | 2 +- yarn.lock | 187 +++++++++--------- 24 files changed, 124 insertions(+), 115 deletions(-) diff --git a/package.json b/package.json index 92ca3b0758..de84acee6b 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ }, "devDependencies": { "@jest/types": "^27.4.2", - "@typescript-eslint/eslint-plugin": "^5.8.0", - "@typescript-eslint/parser": "^5.8.0", + "@typescript-eslint/eslint-plugin": "^5.8.1", + "@typescript-eslint/parser": "^5.8.1", "all-contributors-cli": "^6.20.0", "eslint": "^8.5.0", "eslint-config-prettier": "^8.3.0", diff --git a/packages/@jsii/check-node/package.json b/packages/@jsii/check-node/package.json index 41bd393271..465df1906e 100644 --- a/packages/@jsii/check-node/package.json +++ b/packages/@jsii/check-node/package.json @@ -42,7 +42,7 @@ "devDependencies": { "@types/chalk": "^2.2.0", "@types/jest": "^27.0.3", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "jest": "^27.4.5" } } diff --git a/packages/@jsii/dotnet-runtime-test/package.json b/packages/@jsii/dotnet-runtime-test/package.json index 830e5f32df..177351a629 100644 --- a/packages/@jsii/dotnet-runtime-test/package.json +++ b/packages/@jsii/dotnet-runtime-test/package.json @@ -31,7 +31,7 @@ }, "devDependencies": { "@jsii/dotnet-runtime": "^0.0.0", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "jsii-calc": "^3.20.120", "jsii-pacmak": "^0.0.0", "typescript": "~3.9.10" diff --git a/packages/@jsii/dotnet-runtime/package.json b/packages/@jsii/dotnet-runtime/package.json index 33f0664101..ee61ce23dd 100644 --- a/packages/@jsii/dotnet-runtime/package.json +++ b/packages/@jsii/dotnet-runtime/package.json @@ -39,7 +39,7 @@ }, "devDependencies": { "@jsii/runtime": "^0.0.0", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "@types/semver": "^7.3.9", "jsii-build-tools": "^0.0.0", "semver": "^7.3.5", diff --git a/packages/@jsii/go-runtime/package.json b/packages/@jsii/go-runtime/package.json index 07825e30fe..210c9cb84b 100644 --- a/packages/@jsii/go-runtime/package.json +++ b/packages/@jsii/go-runtime/package.json @@ -24,7 +24,7 @@ }, "devDependencies": { "@types/fs-extra": "^9.0.13", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "codemaker": "^0.0.0", "eslint": "^8.5.0", "fs-extra": "^9.1.0", diff --git a/packages/@jsii/integ-test/package.json b/packages/@jsii/integ-test/package.json index b1744ed7ca..c16d5a23cb 100644 --- a/packages/@jsii/integ-test/package.json +++ b/packages/@jsii/integ-test/package.json @@ -30,7 +30,7 @@ "@types/dotenv": "^8.2.0", "@types/fs-extra": "^9.0.13", "@types/jest": "^27.0.3", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "@types/tar": "^6.1.1", "eslint": "^8.5.0", "prettier": "^2.5.1", diff --git a/packages/@jsii/java-runtime/package.json b/packages/@jsii/java-runtime/package.json index 074ed63b08..c5d61198e4 100644 --- a/packages/@jsii/java-runtime/package.json +++ b/packages/@jsii/java-runtime/package.json @@ -33,7 +33,7 @@ }, "devDependencies": { "@jsii/runtime": "^0.0.0", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "jsii-build-tools": "^0.0.0", "typescript": "~3.9.10" } diff --git a/packages/@jsii/kernel/package.json b/packages/@jsii/kernel/package.json index fa8e45292e..45df2bb1f7 100644 --- a/packages/@jsii/kernel/package.json +++ b/packages/@jsii/kernel/package.json @@ -40,7 +40,7 @@ "@scope/jsii-calc-lib": "^0.0.0", "@types/fs-extra": "^9.0.13", "@types/jest": "^27.0.3", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "@types/tar": "^6.1.1", "eslint": "^8.5.0", "jest": "^27.4.5", diff --git a/packages/@jsii/runtime/package.json b/packages/@jsii/runtime/package.json index 9b112360a1..55095f6ca5 100644 --- a/packages/@jsii/runtime/package.json +++ b/packages/@jsii/runtime/package.json @@ -42,7 +42,7 @@ "@scope/jsii-calc-base": "^0.0.0", "@scope/jsii-calc-lib": "^0.0.0", "@types/jest": "^27.0.3", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "eslint": "^8.5.0", "jest": "^27.4.5", "jsii-build-tools": "^0.0.0", diff --git a/packages/@jsii/spec/package.json b/packages/@jsii/spec/package.json index 021b5f53e2..3347248ef9 100644 --- a/packages/@jsii/spec/package.json +++ b/packages/@jsii/spec/package.json @@ -35,7 +35,7 @@ }, "devDependencies": { "@types/jest": "^27.0.3", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "eslint": "^8.5.0", "jest": "^27.4.5", "jsii-build-tools": "^0.0.0", diff --git a/packages/@scope/jsii-calc-base-of-base/package.json b/packages/@scope/jsii-calc-base-of-base/package.json index a3db725d45..ac98f4d102 100644 --- a/packages/@scope/jsii-calc-base-of-base/package.json +++ b/packages/@scope/jsii-calc-base-of-base/package.json @@ -30,7 +30,7 @@ "test:update": "npm run build && UPDATE_DIFF=1 npm run test" }, "devDependencies": { - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "jsii": "^0.0.0", "jsii-build-tools": "^0.0.0", "jsii-rosetta": "^0.0.0", diff --git a/packages/@scope/jsii-calc-base/package.json b/packages/@scope/jsii-calc-base/package.json index 49ec85c588..ed0747078d 100644 --- a/packages/@scope/jsii-calc-base/package.json +++ b/packages/@scope/jsii-calc-base/package.json @@ -35,7 +35,7 @@ "@scope/jsii-calc-base-of-base": "^2.1.1" }, "devDependencies": { - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "jsii": "^0.0.0", "jsii-build-tools": "^0.0.0", "jsii-rosetta": "^0.0.0", diff --git a/packages/@scope/jsii-calc-lib/package.json b/packages/@scope/jsii-calc-lib/package.json index 77984b9744..0134988c7c 100644 --- a/packages/@scope/jsii-calc-lib/package.json +++ b/packages/@scope/jsii-calc-lib/package.json @@ -39,7 +39,7 @@ "@scope/jsii-calc-base-of-base": "^2.1.1" }, "devDependencies": { - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "jsii": "^0.0.0", "jsii-build-tools": "^0.0.0", "jsii-rosetta": "^0.0.0", diff --git a/packages/codemaker/package.json b/packages/codemaker/package.json index 8175bc49de..dd1865963a 100644 --- a/packages/codemaker/package.json +++ b/packages/codemaker/package.json @@ -38,7 +38,7 @@ "devDependencies": { "@types/fs-extra": "^9.0.13", "@types/jest": "^27.0.3", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "eslint": "^8.5.0", "jest": "^27.4.5", "prettier": "^2.5.1", diff --git a/packages/jsii-calc/package.json b/packages/jsii-calc/package.json index 84e2cf07cd..45c610370d 100644 --- a/packages/jsii-calc/package.json +++ b/packages/jsii-calc/package.json @@ -51,7 +51,7 @@ "@scope/jsii-calc-lib": "^0.0.0" }, "devDependencies": { - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "eslint": "^8.5.0", "jsii": "^0.0.0", "jsii-build-tools": "^0.0.0", diff --git a/packages/jsii-config/package.json b/packages/jsii-config/package.json index 47f24e2a2f..19e2fd15ef 100644 --- a/packages/jsii-config/package.json +++ b/packages/jsii-config/package.json @@ -21,8 +21,8 @@ "devDependencies": { "@types/inquirer": "^8.1.3", "@types/jest": "^27.0.3", - "@types/node": "^12.20.38", - "@types/yargs": "^17.0.7", + "@types/node": "^12.20.39", + "@types/yargs": "^17.0.8", "eslint": "^8.5.0", "jest": "^27.4.5", "jest-expect-message": "^1.0.2", diff --git a/packages/jsii-diff/package.json b/packages/jsii-diff/package.json index 502d8e0019..728bc74242 100644 --- a/packages/jsii-diff/package.json +++ b/packages/jsii-diff/package.json @@ -44,7 +44,7 @@ "devDependencies": { "@types/fs-extra": "^9.0.13", "@types/jest": "^27.0.3", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "@types/tar-fs": "^2.0.1", "eslint": "^8.5.0", "jest": "^27.4.5", diff --git a/packages/jsii-pacmak/package.json b/packages/jsii-pacmak/package.json index 91ef03460e..33332db349 100644 --- a/packages/jsii-pacmak/package.json +++ b/packages/jsii-pacmak/package.json @@ -60,7 +60,7 @@ "@types/commonmark": "^0.27.5", "@types/fs-extra": "^9.0.13", "@types/jest": "^27.0.3", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "@types/semver": "^7.3.9", "eslint": "^8.5.0", "jest": "^27.4.5", diff --git a/packages/jsii-reflect/package.json b/packages/jsii-reflect/package.json index 5ac36e4bfd..9065530314 100644 --- a/packages/jsii-reflect/package.json +++ b/packages/jsii-reflect/package.json @@ -45,7 +45,7 @@ "@scope/jsii-calc-lib": "^0.0.0", "@types/fs-extra": "^9.0.13", "@types/jest": "^27.0.3", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "eslint": "^8.5.0", "jest": "^27.4.5", "jsii": "^0.0.0", diff --git a/packages/jsii-rosetta/package.json b/packages/jsii-rosetta/package.json index eca6a9cd80..ebf15f9842 100644 --- a/packages/jsii-rosetta/package.json +++ b/packages/jsii-rosetta/package.json @@ -20,7 +20,7 @@ "@types/fs-extra": "^9.0.13", "@types/jest": "^27.0.3", "@types/mock-fs": "^4.13.1", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "@types/workerpool": "^6.1.0", "eslint": "^8.5.0", "jest": "^27.4.5", @@ -36,7 +36,7 @@ "fs-extra": "^9.1.0", "typescript": "~3.9.10", "sort-json": "^2.0.0", - "@xmldom/xmldom": "^0.7.5", + "@xmldom/xmldom": "^0.8.0", "workerpool": "^6.1.5", "yargs": "^16.2.0", "jsii": "0.0.0" diff --git a/packages/jsii/package.json b/packages/jsii/package.json index ca41de5e0a..239b9b333f 100644 --- a/packages/jsii/package.json +++ b/packages/jsii/package.json @@ -54,7 +54,7 @@ "@types/deep-equal": "^1.0.1", "@types/fs-extra": "^9.0.13", "@types/jest": "^27.0.3", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "@types/semver": "^7.3.9", "clone": "^2.1.2", "eslint": "^8.5.0", diff --git a/packages/oo-ascii-tree/package.json b/packages/oo-ascii-tree/package.json index 97aca21143..906a64df29 100644 --- a/packages/oo-ascii-tree/package.json +++ b/packages/oo-ascii-tree/package.json @@ -32,7 +32,7 @@ }, "devDependencies": { "@types/jest": "^27.0.3", - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "eslint": "^8.5.0", "jest": "^27.4.5", "jsii-build-tools": "^0.0.0", diff --git a/tools/jsii-compliance/package.json b/tools/jsii-compliance/package.json index e25e4922e2..edef95835a 100644 --- a/tools/jsii-compliance/package.json +++ b/tools/jsii-compliance/package.json @@ -16,7 +16,7 @@ "tablemark": "^2.0.0" }, "devDependencies": { - "@types/node": "^12.20.38", + "@types/node": "^12.20.39", "eslint": "^8.5.0", "prettier": "^2.5.1", "ts-node": "^10.4.0", diff --git a/yarn.lock b/yarn.lock index 14ebffdcd5..48450e8ee5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1451,9 +1451,9 @@ "@types/babel__traverse" "*" "@types/babel__generator@*": - version "7.6.3" - resolved "https://registry.yarnpkg.com/@types/babel__generator/-/babel__generator-7.6.3.tgz#f456b4b2ce79137f768aa130d2423d2f0ccfaba5" - integrity sha512-/GWCmzJWqV7diQW54smJZzWbSFf4QYtF71WCKhcx6Ru/tFyQIY2eiiITcCAeuPbNSvT9YCGkVMqqvSk2Z0mXiA== + version "7.6.4" + resolved "https://registry.yarnpkg.com/@types/babel__generator/-/babel__generator-7.6.4.tgz#1f20ce4c5b1990b37900b63f050182d28c2439b7" + integrity sha512-tFkciB9j2K755yrTALxD44McOrk+gfpIpvC3sxHjRawj6PfnQxrse4Clq5y/Rq+G3mrBurMax/lG8Qn2t9mSsg== dependencies: "@babel/types" "^7.0.0" @@ -1545,9 +1545,9 @@ rxjs "^7.2.0" "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1": - version "2.0.3" - resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz#4ba8ddb720221f432e443bd5f9117fd22cfd4762" - integrity sha512-sz7iLqvVUg1gIedBOvlkxPlc8/uVzyS5OwGz1cKjXzkl3FpL3al0crU8YGU1WoHkxn0Wxbw5tyi6hvzJKNzFsw== + version "2.0.4" + resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz#8467d4b3c087805d63580480890791277ce35c44" + integrity sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g== "@types/istanbul-lib-report@*": version "3.0.0" @@ -1606,19 +1606,19 @@ "@types/node" "*" "@types/node@*": - version "17.0.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.2.tgz#a4c07d47ff737e8ee7e586fe636ff0e1ddff070a" - integrity sha512-JepeIUPFDARgIs0zD/SKPgFsJEAF0X5/qO80llx59gOxFTboS9Amv3S+QfB7lqBId5sFXJ99BN0J6zFRvL9dDA== + version "17.0.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.5.tgz#57ca67ec4e57ad9e4ef5a6bab48a15387a1c83e0" + integrity sha512-w3mrvNXLeDYV1GKTZorGJQivK6XLCoGwpnyJFbJVK/aTBQUxOCaa/GlFAAN3OTDFcb7h5tiFG+YXCO2By+riZw== -"@types/node@^12.20.38": - version "12.20.38" - resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.38.tgz#74801983c0558a7a31a4ead18bce2edded2b0e2f" - integrity sha512-NxmtBRGipjx1B225OeMdI+CQmLbYqvvmYbukDTJGDgzIDgPQ1EcjGmYxGhOk5hTBqeB558S6RgHSpq2iiqifAQ== +"@types/node@^12.20.39": + version "12.20.39" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.39.tgz#ef3cb119eaba80e9f1012c78b9384a7489a18bf6" + integrity sha512-U7PMwkDmc3bnL0e4U8oA0POpi1vfsYDc+DEUS2+rPxm9NlLcW1dBa5JcRhO633PoPUcCSWMNXrMsqhmAVEo+IQ== "@types/node@^16.9.2": - version "16.11.15" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.15.tgz#724da13bc1ba99fe8190d0f5cd35cb53c67db942" - integrity sha512-LMGR7iUjwZRxoYnfc9+YELxwqkaLmkJlo4/HUvOMyGvw9DaHO0gtAbH2FUdoFE6PXBTYZIT7x610r7kdo8o1fQ== + version "16.11.17" + resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.17.tgz#ae146499772e33fc6382e1880bc567e41a528586" + integrity sha512-C1vTZME8cFo8uxY2ui41xcynEotVkczIVI5AjLmy5pkpBv/FtG+jhtOlfcPysI8VRVwoOMv6NJm44LGnoMSWkw== "@types/normalize-package-data@^2.4.0": version "2.4.1" @@ -1694,20 +1694,20 @@ dependencies: "@types/yargs-parser" "*" -"@types/yargs@^17.0.7": - version "17.0.7" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.7.tgz#44a484c634761da4391477515a98772b82b5060f" - integrity sha512-OvLKmpKdea1aWtqHv9bxVVcMoT6syAeK+198dfETIFkAevYRGwqh4H+KFxfjUETZuUuE5sQCAFwdOdoHUdo8eg== +"@types/yargs@^17.0.8": + version "17.0.8" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.8.tgz#d23a3476fd3da8a0ea44b5494ca7fa677b9dad4c" + integrity sha512-wDeUwiUmem9FzsyysEwRukaEdDNcwbROvQ9QGRKaLI6t+IltNzbn4/i4asmB10auvZGQCzSQ6t0GSczEThlUXw== dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.8.0.tgz#52cd9305ceef98a5333f9492d519e6c6c7fe7d43" - integrity sha512-spu1UW7QuBn0nJ6+psnfCc3iVoQAifjKORgBngKOmC8U/1tbe2YJMzYQqDGYB4JCss7L8+RM2kKLb1B1Aw9BNA== +"@typescript-eslint/eslint-plugin@^5.8.1": + version "5.8.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.8.1.tgz#97dfaa39f38e99f86801fdf34f9f1bed66704258" + integrity sha512-wTZ5oEKrKj/8/366qTM366zqhIKAp6NCMweoRONtfuC07OAU9nVI2GZZdqQ1qD30WAAtcPdkH+npDwtRFdp4Rw== dependencies: - "@typescript-eslint/experimental-utils" "5.8.0" - "@typescript-eslint/scope-manager" "5.8.0" + "@typescript-eslint/experimental-utils" "5.8.1" + "@typescript-eslint/scope-manager" "5.8.1" debug "^4.3.2" functional-red-black-tree "^1.0.1" ignore "^5.1.8" @@ -1715,60 +1715,60 @@ semver "^7.3.5" tsutils "^3.21.0" -"@typescript-eslint/experimental-utils@5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-5.8.0.tgz#0916ffe98d34b3c95e3652efa0cace61a7b25728" - integrity sha512-KN5FvNH71bhZ8fKtL+lhW7bjm7cxs1nt+hrDZWIqb6ViCffQcWyLunGrgvISgkRojIDcXIsH+xlFfI4RCDA0xA== +"@typescript-eslint/experimental-utils@5.8.1": + version "5.8.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-5.8.1.tgz#01861eb2f0749f07d02db342b794145a66ed346f" + integrity sha512-fbodVnjIDU4JpeXWRDsG5IfIjYBxEvs8EBO8W1+YVdtrc2B9ppfof5sZhVEDOtgTfFHnYQJDI8+qdqLYO4ceww== dependencies: "@types/json-schema" "^7.0.9" - "@typescript-eslint/scope-manager" "5.8.0" - "@typescript-eslint/types" "5.8.0" - "@typescript-eslint/typescript-estree" "5.8.0" + "@typescript-eslint/scope-manager" "5.8.1" + "@typescript-eslint/types" "5.8.1" + "@typescript-eslint/typescript-estree" "5.8.1" eslint-scope "^5.1.1" eslint-utils "^3.0.0" -"@typescript-eslint/parser@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.8.0.tgz#b39970b21c1d7bc4a6018507fb29b380328d2587" - integrity sha512-Gleacp/ZhRtJRYs5/T8KQR3pAQjQI89Dn/k+OzyCKOsLiZH2/Vh60cFBTnFsHNI6WAD+lNUo/xGZ4NeA5u0Ipw== +"@typescript-eslint/parser@^5.8.1": + version "5.8.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.8.1.tgz#380f5f1e596b540059998aa3fc80d78f0f9b0d0a" + integrity sha512-K1giKHAjHuyB421SoXMXFHHVI4NdNY603uKw92++D3qyxSeYvC10CBJ/GE5Thpo4WTUvu1mmJI2/FFkz38F2Gw== dependencies: - "@typescript-eslint/scope-manager" "5.8.0" - "@typescript-eslint/types" "5.8.0" - "@typescript-eslint/typescript-estree" "5.8.0" + "@typescript-eslint/scope-manager" "5.8.1" + "@typescript-eslint/types" "5.8.1" + "@typescript-eslint/typescript-estree" "5.8.1" debug "^4.3.2" -"@typescript-eslint/scope-manager@5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.8.0.tgz#2371095b4fa4c7be6a80b380f4e1b49c715e16f4" - integrity sha512-x82CYJsLOjPCDuFFEbS6e7K1QEWj7u5Wk1alw8A+gnJiYwNnDJk0ib6PCegbaPMjrfBvFKa7SxE3EOnnIQz2Gg== +"@typescript-eslint/scope-manager@5.8.1": + version "5.8.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.8.1.tgz#7fc0604f7ade8833e4d42cebaa1e2debf8b932e4" + integrity sha512-DGxJkNyYruFH3NIZc3PwrzwOQAg7vvgsHsHCILOLvUpupgkwDZdNq/cXU3BjF4LNrCsVg0qxEyWasys5AiJ85Q== dependencies: - "@typescript-eslint/types" "5.8.0" - "@typescript-eslint/visitor-keys" "5.8.0" + "@typescript-eslint/types" "5.8.1" + "@typescript-eslint/visitor-keys" "5.8.1" -"@typescript-eslint/types@5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.8.0.tgz#e7fa74ec35d9dbe3560d039d3d8734986c3971e0" - integrity sha512-LdCYOqeqZWqCMOmwFnum6YfW9F3nKuxJiR84CdIRN5nfHJ7gyvGpXWqL/AaW0k3Po0+wm93ARAsOdzlZDPCcXg== +"@typescript-eslint/types@5.8.1": + version "5.8.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.8.1.tgz#04c6b49ebc8c99238238a6b8b43f2fc613983b5a" + integrity sha512-L/FlWCCgnjKOLefdok90/pqInkomLnAcF9UAzNr+DSqMC3IffzumHTQTrINXhP1gVp9zlHiYYjvozVZDPleLcA== -"@typescript-eslint/typescript-estree@5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.8.0.tgz#900469ba9d5a37f4482b014ecce4a5dbb86cb4dd" - integrity sha512-srfeZ3URdEcUsSLbkOFqS7WoxOqn8JNil2NSLO9O+I2/Uyc85+UlfpEvQHIpj5dVts7KKOZnftoJD/Fdv0L7nQ== +"@typescript-eslint/typescript-estree@5.8.1": + version "5.8.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.8.1.tgz#a592855be688e7b729a1e9411d7d74ec992ed6ef" + integrity sha512-26lQ8l8tTbG7ri7xEcCFT9ijU5Fk+sx/KRRyyzCv7MQ+rZZlqiDPtMKWLC8P7o+dtCnby4c+OlxuX1tp8WfafQ== dependencies: - "@typescript-eslint/types" "5.8.0" - "@typescript-eslint/visitor-keys" "5.8.0" + "@typescript-eslint/types" "5.8.1" + "@typescript-eslint/visitor-keys" "5.8.1" debug "^4.3.2" globby "^11.0.4" is-glob "^4.0.3" semver "^7.3.5" tsutils "^3.21.0" -"@typescript-eslint/visitor-keys@5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.8.0.tgz#22d4ed96fe2451135299239feedb9fe1dcec780c" - integrity sha512-+HDIGOEMnqbxdAHegxvnOqESUH6RWFRR2b8qxP1W9CZnnYh4Usz6MBL+2KMAgPk/P0o9c1HqnYtwzVH6GTIqug== +"@typescript-eslint/visitor-keys@5.8.1": + version "5.8.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.8.1.tgz#58a2c566265d5511224bc316149890451c1bbab0" + integrity sha512-SWgiWIwocK6NralrJarPZlWdr0hZnj5GXHIgfdm8hNkyKvpeQuFyLP6YjSIe9kf3YBIfU6OHSZLYkQ+smZwtNg== dependencies: - "@typescript-eslint/types" "5.8.0" + "@typescript-eslint/types" "5.8.1" eslint-visitor-keys "^3.0.0" "@webassemblyjs/ast@1.11.1": @@ -1909,10 +1909,10 @@ resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.6.0.tgz#2c275aa05c895eccebbfc34cfb223c6e8bd591a2" integrity sha512-ZkVeqEmRpBV2GHvjjUZqEai2PpUbuq8Bqd//vEYsp63J8WyexI8ppCqVS3Zs0QADf6aWuPdU+0XsPI647PVlQA== -"@xmldom/xmldom@^0.7.5": - version "0.7.5" - resolved "https://registry.yarnpkg.com/@xmldom/xmldom/-/xmldom-0.7.5.tgz#09fa51e356d07d0be200642b0e4f91d8e6dd408d" - integrity sha512-V3BIhmY36fXZ1OtVcI9W+FxQqxVLsPKcNjWigIaa81dLC9IolJl5Mt4Cvhmr0flUnjSpTdrbMTSbXqYqV5dT6A== +"@xmldom/xmldom@^0.8.0": + version "0.8.0" + resolved "https://registry.yarnpkg.com/@xmldom/xmldom/-/xmldom-0.8.0.tgz#9f83fd9b3506c9603baad67e44eb6e6ee8eee0ce" + integrity sha512-7wVnF+rKrVDEo1xjzkkidTG0grclaVnX0vKa0z9JSXcEdtftUJjvU33jLGg6SHyvs3eeqEsI7jZ6NxYfRypEEg== "@xtuc/ieee754@^1.2.0": version "1.2.0" @@ -1976,9 +1976,9 @@ acorn@^7.1.1: integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== acorn@^8.2.4, acorn@^8.4.1, acorn@^8.6.0: - version "8.6.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.6.0.tgz#e3692ba0eb1a0c83eaa4f37f5fa7368dd7142895" - integrity sha512-U1riIR+lBSNi3IbxtaHOIKdH8sLFv3NYfNv8sg7ZsNhcfl4HF2++BfqqrNAxoCLQW1iiylOj76ecnaUxz+z9yw== + version "8.7.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.0.tgz#90951fde0f8f09df93549481e5fc141445b791cf" + integrity sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ== add-stream@^1.0.0: version "1.0.0" @@ -2416,9 +2416,9 @@ camelcase@^6.2.0, camelcase@^6.2.1: integrity sha512-tVI4q5jjFV5CavAU8DXfza/TJcZutVKo/5Foskmsqcm0MsL91moHvwiGNnqaa2o6PF/7yT5ikDRcVcl8Rj6LCA== caniuse-lite@^1.0.30001286: - version "1.0.30001292" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001292.tgz#4a55f61c06abc9595965cfd77897dc7bc1cdc456" - integrity sha512-jnT4Tq0Q4ma+6nncYQVe7d73kmDmE9C3OGTx3MvW7lBM/eY1S1DZTMBON7dqV481RhNiS5OxD7k9JQvmDOTirw== + version "1.0.30001294" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001294.tgz#4849f27b101fd59ddee3751598c663801032533d" + integrity sha512-LiMlrs1nSKZ8qkNhpUf5KD0Al1KCBE3zaT7OLOwEkagXMEDij98SiOovn9wxVGQpklk9vVC/pUSqgYmkmKOS8g== case@^1.6.3: version "1.6.3" @@ -2700,7 +2700,7 @@ conventional-changelog-config-spec@2.1.0: resolved "https://registry.yarnpkg.com/conventional-changelog-config-spec/-/conventional-changelog-config-spec-2.1.0.tgz#874a635287ef8b581fd8558532bf655d4fb59f2d" integrity sha512-IpVePh16EbbB02V+UA+HQnnPIohgXvJRxHcS5+Uwk4AT5LjzCZJm5sp/yqs5C6KZJ1jMsV4paEV13BN1pvDuxQ== -conventional-changelog-conventionalcommits@4.6.1, conventional-changelog-conventionalcommits@^4.5.0: +conventional-changelog-conventionalcommits@4.6.1: version "4.6.1" resolved "https://registry.yarnpkg.com/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.6.1.tgz#f4c0921937050674e578dc7875f908351ccf4014" integrity sha512-lzWJpPZhbM1R0PIzkwzGBCnAkH5RKJzJfFQZcl/D+2lsJxAwGnDKBqn/F4C1RD31GJNn8NuKWQzAZDAVXPp2Mw== @@ -2709,6 +2709,15 @@ conventional-changelog-conventionalcommits@4.6.1, conventional-changelog-convent lodash "^4.17.15" q "^1.5.1" +conventional-changelog-conventionalcommits@^4.5.0: + version "4.6.2" + resolved "https://registry.yarnpkg.com/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.6.2.tgz#6debf07a894f7c7e22b950e2f872de334d5d49ed" + integrity sha512-fo+VhM0VtD3wdHZtrPhgvTFjAhAMUjYeQV6B5+DB/cupG1O554pJdTwrvBInq8JLHl+GucKQpZycMPye/OpgSw== + dependencies: + compare-func "^2.0.0" + lodash "^4.17.15" + q "^1.5.1" + conventional-changelog-core@^4.2.1, conventional-changelog-core@^4.2.2: version "4.2.4" resolved "https://registry.yarnpkg.com/conventional-changelog-core/-/conventional-changelog-core-4.2.4.tgz#e50d047e8ebacf63fac3dc67bf918177001e1e9f" @@ -3177,9 +3186,9 @@ ecc-jsbn@~0.1.1: safer-buffer "^2.1.0" electron-to-chromium@^1.4.17: - version "1.4.26" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.26.tgz#d71b9da220543cf10614a576c3d5ebbe43d96efb" - integrity sha512-cA1YwlRzO6TGp7yd3+KAqh9Tt6Z4CuuKqsAJP6uF/H5MQryjAGDhMhnY5cEXo8MaRCczpzSBhMPdqRIodkbZYw== + version "1.4.29" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.29.tgz#a9b85ab888d0122124c9647c04d8dd246fae94b6" + integrity sha512-N2Jbwxo5Rum8G2YXeUxycs1sv4Qme/ry71HG73bv8BvZl+I/4JtRgK/En+ST/Wh/yF1fqvVCY4jZBgMxnhjtBA== emittery@^0.8.1: version "0.8.1" @@ -4541,9 +4550,9 @@ istanbul-lib-source-maps@^4.0.0: source-map "^0.6.1" istanbul-reports@^3.0.2: - version "3.1.1" - resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.1.tgz#7085857f17d2441053c6ce5c3b8fdf6882289397" - integrity sha512-q1kvhAXWSsXfMjCdNHNPKZZv94OlspKnoGv+R9RGbnqOOQ0VbNfLFgQDVgi7hHenKsndGq3/o0OBdzDXthWcNw== + version "3.1.2" + resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.2.tgz#b80e13cbab0120e1c367ebaa099862361aed5ead" + integrity sha512-0gHxuT1NNC0aEIL1zbJ+MTgPbbHhU77eJPuU35WKA7TgXiSNlCAx4PENoMrH0Or6M2H80TaZcWKhM0IK6V8gRw== dependencies: html-escaper "^2.0.0" istanbul-lib-report "^3.0.0" @@ -6684,11 +6693,11 @@ rxjs@^6.6.0: tslib "^1.9.0" rxjs@^7.2.0: - version "7.4.0" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.4.0.tgz#a12a44d7eebf016f5ff2441b87f28c9a51cebc68" - integrity sha512-7SQDi7xeTMCJpqViXh8gL/lebcwlp3d831F05+9B44A4B0WfsEwUQHR64gsH1kvJ+Ep/J9K2+n1hVl1CsGN23w== + version "7.5.1" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.5.1.tgz#af73df343cbcab37628197f43ea0c8256f54b157" + integrity sha512-KExVEeZWxMZnZhUZtsJcFwz8IvPvgu4G2Z2QyqjZQzUGr32KDYuSxrEYO4w3tFFNbfLozcrKUTvTPi+E9ywJkQ== dependencies: - tslib "~2.1.0" + tslib "^2.1.0" safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.2, safe-buffer@^5.2.1, safe-buffer@~5.2.0: version "5.2.1" @@ -7422,10 +7431,10 @@ tslib@^1.8.1, tslib@^1.9.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== -tslib@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a" - integrity sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A== +tslib@^2.1.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" + integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== tsutils@^3.21.0: version "3.21.0" @@ -8062,9 +8071,9 @@ yargs@^16.0.0, yargs@^16.2.0: yargs-parser "^20.2.2" yargs@^17.1.1: - version "17.3.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.3.0.tgz#295c4ffd0eef148ef3e48f7a2e0f58d0e4f26b1c" - integrity sha512-GQl1pWyDoGptFPJx9b9L6kmR33TGusZvXIZUT+BOz9f7X2L94oeAskFYLEg/FkhV06zZPBYLvLZRWeYId29lew== + version "17.3.1" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.3.1.tgz#da56b28f32e2fd45aefb402ed9c26f42be4c07b9" + integrity sha512-WUANQeVgjLbNsEmGk20f+nlHgOqzRFpiGWVaBrYGYIGANIIu3lWjoyi0fNlFmJkvfhCZ6BXINe7/W2O2bV4iaA== dependencies: cliui "^7.0.2" escalade "^3.1.1" From 652f6e5ede5957a8a1d73f74d3b24f1b0ee67a97 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Dec 2021 20:59:45 +0000 Subject: [PATCH 07/14] chore(deps): bump actions/setup-node from 2.5.0 to 2.5.1 (#3305) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/setup-node](https://github.com/actions/setup-node) from 2.5.0 to 2.5.1.
Release notes

Sourced from actions/setup-node's releases.

Fix logic of error handling for npm warning and uncaught exception

In scope of this release we fix logic of error handling related to caching (actions/setup-node#358) and (actions/setup-node#359).

In the previous behaviour we relied on stderr output to throw error. The warning messages from package managers can be written to the stderr's output. For now the action will throw an error only if exit code differs from zero. Besides, we add logic to сatch and log unhandled exceptions.

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/setup-node&package-manager=github_actions&previous-version=2.5.0&new-version=2.5.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- .github/workflows/main.yml | 6 +++--- .github/workflows/yarn-upgrade.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5e2a263a9f..fab3dfd957 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,7 +41,7 @@ jobs: java-version: '8' distribution: 'zulu' - name: Set up Node 12 - uses: actions/setup-node@v2.5.0 + uses: actions/setup-node@v2.5.1 with: cache: yarn node-version: '12' @@ -135,7 +135,7 @@ jobs: java-version: '8' distribution: 'zulu' - name: Set up Node 12 - uses: actions/setup-node@v2.5.0 + uses: actions/setup-node@v2.5.1 with: cache: yarn node-version: '12' @@ -303,7 +303,7 @@ jobs: java-version: ${{ matrix.java }} distribution: 'zulu' - name: Set up Node ${{ matrix.node }} - uses: actions/setup-node@v2.5.0 + uses: actions/setup-node@v2.5.1 with: cache: yarn node-version: ${{ matrix.node }} diff --git a/.github/workflows/yarn-upgrade.yml b/.github/workflows/yarn-upgrade.yml index ab4f0b5d74..728c3c4258 100644 --- a/.github/workflows/yarn-upgrade.yml +++ b/.github/workflows/yarn-upgrade.yml @@ -18,7 +18,7 @@ jobs: uses: actions/checkout@v2.4.0 - name: Set up Node - uses: actions/setup-node@v2.5.0 + uses: actions/setup-node@v2.5.1 with: cache: yarn node-version: 12 From 949d5f00df6a44c4fbacc06dc9f4f239c68c583e Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Thu, 30 Dec 2021 20:19:31 +0100 Subject: [PATCH 08/14] fix(jsii): cannot use submodule types from assemblies before 1.39.0 (#3306) When trying to use submodule types from assemblies compiled with a jsii version `< 1.39.0`, you will see the following error: ``` Unable to resolve type ".". It may be @internal or not exported from the module's entry point (as configured in "package.json" as "main"). ``` The type resolution introduced in #3233 was relying on either (a) the symbol identifier table; or (b) the type not being in a submodule. Unfortunately, there was a 3rd case which was not covered: the library had already been imported by its entry point, and the `this.submoduleMap` had been initialized will all exported submodules. Restore that code path, and improve the error message for undeclared dependencies. --- 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 --- packages/jsii/lib/assembler.ts | 52 ++++++++------- packages/jsii/lib/jsii-diagnostic.ts | 3 +- packages/jsii/test/submodules.test.ts | 94 ++++++++++++++++++++------- 3 files changed, 99 insertions(+), 50 deletions(-) diff --git a/packages/jsii/lib/assembler.ts b/packages/jsii/lib/assembler.ts index 6d4a94c88c..a33a98d509 100644 --- a/packages/jsii/lib/assembler.ts +++ b/packages/jsii/lib/assembler.ts @@ -525,17 +525,14 @@ export class Assembler implements Emitter { return `unknown.${typeName}`; } - // If the symbol comes from the current assembly or an assembly whose - // submodules we've already spidered, look up in the tables we are currently building - if (pkg.name === this.projectInfo.name) { - const submodule = this._submoduleMap.get(sym); - if (submodule != null) { - const submoduleNs = - this._submodules.get(submodule)!.fqnResolutionPrefix; - return `${submoduleNs}.${typeName}`; - } - - return `${this.projectInfo.name}.${typeName}`; + // If the symbol comes from an assembly whose submodules we've already + // spidered (or from the current assembly), look up there. This relies + // on an entry-point import of the library having been done first + // (`import * as x from 'module-root';`) + const submodule = this._submoduleMap.get(sym); + if (submodule != null) { + const submoduleNs = this._submodules.get(submodule)!.fqnResolutionPrefix; + return `${submoduleNs}.${typeName}`; } // This is the fallback: in case we can't find a symbolId for the given @@ -544,13 +541,24 @@ export class Assembler implements Emitter { // most likely won't be using submodules so this legacy guess will be correct. const fallbackFqn = `${pkg.name}.${typeName}`; + // If the type is coming from the current module, we won't find it in a dependency + if (pkg.name === this.projectInfo.name) { + return fallbackFqn; + } + // Otherwise look up the symbol identifier in the dependency assemblies + // This is now the preferred mechanism but we can't do this as the only mechanism, + // as we may still have compile against very old assemblies that don't have a + // symbol identifier table at all. const dep = this.projectInfo.dependencyClosure.find( (d) => d.name === pkg.name, ); if (!dep) { this._diagnostics.push( - JsiiDiagnostic.JSII_9000_UNKNOWN_MODULE.createDetached(pkg.name), + JsiiDiagnostic.JSII_9000_UNKNOWN_MODULE.create( + typeAnnotationNode, + pkg.name, + ), ); return fallbackFqn; } @@ -679,21 +687,17 @@ export class Assembler implements Emitter { return; } - // Normalize the path so the correct separator is in use (Looking at you, Windows) - resolution.resolvedModule.resolvedFileName = path.normalize( - resolution.resolvedModule.resolvedFileName, - ); if ( // We're not looking into a dependency's namespace exports, and the resolution says it's external (packageRoot === this.projectInfo.projectRoot && resolution.resolvedModule.isExternalLibraryImport) || // Or the module resolves outside of the current dependency's tree entirely - !resolution.resolvedModule.resolvedFileName.startsWith(packageRoot) || + !isUnder(resolution.resolvedModule.resolvedFileName, packageRoot) || // Or the module is under one the current dependency's node_modules subtree resolution.resolvedModule.resolvedFileName - .split(path.sep) + .split('/') // Separator is always '/', even on Windows .filter((entry) => entry === 'node_modules').length !== - packageRoot.split(path.sep).filter((entry) => entry === 'node_modules') + packageRoot.split('/').filter((entry) => entry === 'node_modules') .length ) { // External re-exports are "pure-javascript" sugar; they need not be @@ -2589,11 +2593,6 @@ export class Assembler implements Emitter { } // Not a primitive type! return undefined; - - function isUnder(file: string, dir: string): boolean { - const relative = path.relative(dir, file); - return !relative.startsWith(path.sep) && !relative.startsWith('..'); - } } async function _unionType(this: Assembler): Promise { @@ -3477,3 +3476,8 @@ function getSymbolFromDeclaration( const name = ts.getNameOfDeclaration(decl); return name ? typeChecker.getSymbolAtLocation(name) : undefined; } + +function isUnder(file: string, dir: string): boolean { + const relative = path.relative(dir, file); + return !relative.startsWith(path.sep) && !relative.startsWith('..'); +} diff --git a/packages/jsii/lib/jsii-diagnostic.ts b/packages/jsii/lib/jsii-diagnostic.ts index 5207ec30c5..c78b4ccfd2 100644 --- a/packages/jsii/lib/jsii-diagnostic.ts +++ b/packages/jsii/lib/jsii-diagnostic.ts @@ -741,7 +741,8 @@ export class JsiiDiagnostic implements ts.Diagnostic { public static readonly JSII_9000_UNKNOWN_MODULE = Code.error({ code: 9000, - formatter: (moduleName) => `Encountered unknown module: "${moduleName}"`, + formatter: (moduleName) => + `Encountered use of module that is not declared in "dependencies" or "peerDependencies": "${moduleName}"`, name: 'miscellaneous/unknown-module', }); diff --git a/packages/jsii/test/submodules.test.ts b/packages/jsii/test/submodules.test.ts index 99b3a0d61b..a924a24137 100644 --- a/packages/jsii/test/submodules.test.ts +++ b/packages/jsii/test/submodules.test.ts @@ -1,4 +1,6 @@ import * as spec from '@jsii/spec'; +import * as fs from 'fs-extra'; +import * as path from 'path'; import { sourceToAssemblyHelper, @@ -72,17 +74,7 @@ test.each(['directly', 'as namespace', 'with alias'] as ImportStyle[])( // We need to support both import styles. // Dependency that exports a submodule - await ws.addDependency( - await compileJsiiForTest({ - 'index.ts': 'export * as submodule from "./subdir"', - 'subdir/index.ts': [ - 'export class Foo { };', - 'export interface FooInterface { readonly value?: string }', - 'export interface IProtocol { readonly value?: string; }', - ].join('\n'), - 'subdir/README.md': 'This is the README', - }), - ); + await ws.addDependency(await makeDependencyWithSubmodule()); let importStatement; let prefix; @@ -167,20 +159,7 @@ test.each(['directly', 'as namespace', 'with alias'] as ImportStyle[])( // We need to support both import styles. // Dependency that exports a submodule - await ws.addDependency( - await compileJsiiForTest({ - 'index.ts': 'export * as submodule from "./subdir"', - 'subdir/index.ts': [ - 'export class Namespace {};', - 'export namespace Namespace {', - ' export class Foo { };', - ' export interface FooInterface { readonly value?: string }', - ' export interface IProtocol { readonly value?: string; }', - '}', - ].join('\n'), - 'subdir/README.md': 'This is the README', - }), - ); + await ws.addDependency(await makeDependencyWithSubmoduleAndNamespace()); let importStatement; let prefix; @@ -251,3 +230,68 @@ test.each(['directly', 'as namespace', 'with alias'] as ImportStyle[])( ]); }), ); + +// Backwards compatibility test, for versions of libraries compiled before jsii 1.39.0 +// which introduced the symbol identifier table +test('will detect types from submodules even if the symbol identifier table is missing', () => + TestWorkspace.withWorkspace(async (ws) => { + await ws.addDependency(await makeDependencyWithSubmodule()); + + // Strip the symbolidentifiers from the assembly + const asmFile = path.join(ws.dependencyDir('testpkg'), '.jsii'); + const asm: spec.Assembly = await fs.readJson(asmFile); + for (const mod of Object.values(asm.submodules ?? {})) { + delete mod.symbolId; + } + for (const type of Object.values(asm.types ?? {})) { + delete type.symbolId; + } + await fs.writeJson(asmFile, asm); + + // We can still use those types if we have a full-library import + await compileJsiiForTest( + { + 'index.ts': ` + import { submodule } from 'testpkg'; + export class Bar { + constructor(public readonly foo: submodule.Foo) {} + } + `, + }, + { + packageJson: { + // Must be a different name from the dependency + name: 'consumerpkg', + peerDependencies: { testpkg: '*' }, + }, + compilationDirectory: ws.rootDirectory, + }, + ); + })); + +async function makeDependencyWithSubmodule() { + return compileJsiiForTest({ + 'index.ts': 'export * as submodule from "./subdir"', + 'subdir/index.ts': [ + 'export class Foo { };', + 'export interface FooInterface { readonly value?: string }', + 'export interface IProtocol { readonly value?: string; }', + ].join('\n'), + 'subdir/README.md': 'This is the README', + }); +} + +async function makeDependencyWithSubmoduleAndNamespace() { + return compileJsiiForTest({ + 'index.ts': 'export * as submodule from "./subdir"', + 'subdir/index.ts': [ + 'export class Namespace {};', + 'export namespace Namespace {', + ' export class Foo { };', + ' export interface FooInterface { readonly value?: string }', + ' export interface IProtocol { readonly value?: string; }', + '}', + ].join('\n'), + 'subdir/README.md': 'This is the README', + }); +} From eed25ef511dbcd82245d611ac578470b47898604 Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <36202692+kaizen3031593@users.noreply.github.com> Date: Thu, 30 Dec 2021 15:28:19 -0500 Subject: [PATCH 09/14] chore: move disclaimer logic from pacmak to rosetta (#3308) We add disclaimers to the visible source when we are translating examples that do not compile. Previously this logic was in `pacmak`, and the main reason this was the case was because that was where we knew what language we were translating to (and could append the correct comment token). `pacmak` shouldn't really know/change snippets, so this PR refactors that logic into `rosetta` instead. --- 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 --- packages/jsii-pacmak/lib/index.ts | 5 +- .../lib/targets/dotnet/dotnetdocgenerator.ts | 16 +- packages/jsii-pacmak/lib/targets/java.ts | 16 +- packages/jsii-pacmak/lib/targets/python.ts | 16 +- .../lib/commands/transliterate.ts | 86 ++-------- packages/jsii-rosetta/lib/rosetta-reader.ts | 44 ++++- packages/jsii-rosetta/lib/util.ts | 14 ++ .../test/commands/transliterate.test.ts | 162 ++++-------------- packages/jsii-rosetta/test/rosetta.test.ts | 59 +++++++ 9 files changed, 164 insertions(+), 254 deletions(-) diff --git a/packages/jsii-pacmak/lib/index.ts b/packages/jsii-pacmak/lib/index.ts index 1e8d6d7e9f..8f7dea3b30 100644 --- a/packages/jsii-pacmak/lib/index.ts +++ b/packages/jsii-pacmak/lib/index.ts @@ -36,7 +36,10 @@ export async function pacmak({ updateNpmIgnoreFiles = false, validateAssemblies = false, }: PacmakOptions): Promise { - const rosetta = new Rosetta({ unknownSnippets: rosettaUnknownSnippets }); + const rosetta = new Rosetta({ + unknownSnippets: rosettaUnknownSnippets, + prefixDisclaimer: true, + }); if (rosettaTablet) { await rosetta.loadTabletFromFile(rosettaTablet); } diff --git a/packages/jsii-pacmak/lib/targets/dotnet/dotnetdocgenerator.ts b/packages/jsii-pacmak/lib/targets/dotnet/dotnetdocgenerator.ts index e10ba5b582..48337cdf20 100644 --- a/packages/jsii-pacmak/lib/targets/dotnet/dotnetdocgenerator.ts +++ b/packages/jsii-pacmak/lib/targets/dotnet/dotnetdocgenerator.ts @@ -3,14 +3,12 @@ import { CodeMaker } from 'codemaker'; import { Rosetta, TargetLanguage, - Translation, enforcesStrictMode, markDownToXmlDoc, ApiLocation, } from 'jsii-rosetta'; import * as xmlbuilder from 'xmlbuilder'; -import { INCOMPLETE_DISCLAIMER_NONCOMPILING } from '..'; import { renderSummary } from '../_utils'; import { DotNetNameUtils } from './nameutils'; @@ -168,7 +166,7 @@ export class DotNetDocGenerator { TargetLanguage.CSHARP, enforcesStrictMode(this.assembly), ); - return this.prefixDisclaimer(translated); + return translated.source; } private convertSamplesInMarkdown(markdown: string, api: ApiLocation): string { @@ -177,20 +175,8 @@ export class DotNetDocGenerator { markdown, TargetLanguage.CSHARP, enforcesStrictMode(this.assembly), - (trans) => ({ - language: trans.language, - source: this.prefixDisclaimer(trans), - }), ); } - - private prefixDisclaimer(translated: Translation) { - if (!translated.didCompile && INCOMPLETE_DISCLAIMER_NONCOMPILING) { - return `// ${INCOMPLETE_DISCLAIMER_NONCOMPILING}\n${translated.source}`; - } - return translated.source; - } - private emitXmlDoc( tag: string, content: string, diff --git a/packages/jsii-pacmak/lib/targets/java.ts b/packages/jsii-pacmak/lib/targets/java.ts index 6b6351900a..f7e6f737fd 100644 --- a/packages/jsii-pacmak/lib/targets/java.ts +++ b/packages/jsii-pacmak/lib/targets/java.ts @@ -6,7 +6,6 @@ import * as reflect from 'jsii-reflect'; import { Rosetta, TargetLanguage, - Translation, enforcesStrictMode, markDownToJavaDoc, ApiLocation, @@ -30,7 +29,7 @@ import { VERSION, VERSION_DESC } from '../version'; import { stabilityPrefixFor, renderSummary } from './_utils'; import { toMavenVersionRange, toReleaseVersion } from './version-utils'; -import { INCOMPLETE_DISCLAIMER_NONCOMPILING, TargetName } from '.'; +import { TargetName } from './index'; // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports const spdxLicenseList = require('spdx-license-list'); @@ -2987,7 +2986,7 @@ class JavaGenerator extends Generator { TargetLanguage.JAVA, enforcesStrictMode(this.assembly), ); - return this.prefixDisclaimer(translated); + return translated.source; } private convertSamplesInMarkdown(markdown: string, api: ApiLocation): string { @@ -2996,20 +2995,9 @@ class JavaGenerator extends Generator { markdown, TargetLanguage.JAVA, enforcesStrictMode(this.assembly), - (trans) => ({ - language: trans.language, - source: this.prefixDisclaimer(trans), - }), ); } - private prefixDisclaimer(translated: Translation) { - if (!translated.didCompile && INCOMPLETE_DISCLAIMER_NONCOMPILING) { - return `// ${INCOMPLETE_DISCLAIMER_NONCOMPILING}\n${translated.source}`; - } - return translated.source; - } - /** * Fins the Java FQN of the default implementation interfaces that should be implemented when a new * default interface or proxy class is being emitted. diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index dcd4807b91..6410ad8ed1 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -6,7 +6,6 @@ import * as fs from 'fs-extra'; import * as reflect from 'jsii-reflect'; import { TargetLanguage, - Translation, Rosetta, enforcesStrictMode, ApiLocation, @@ -30,7 +29,7 @@ import { import { die, toPythonIdentifier } from './python/util'; import { toPythonVersionRange, toReleaseVersion } from './version-utils'; -import { INCOMPLETE_DISCLAIMER_NONCOMPILING, TargetName } from '.'; +import { TargetName } from './index'; // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports const spdxLicenseList = require('spdx-license-list'); @@ -2399,7 +2398,7 @@ class PythonGenerator extends Generator { TargetLanguage.PYTHON, enforcesStrictMode(this.assembly), ); - return this.prefixDisclaimer(translated); + return translated.source; } public convertMarkdown(markdown: string, apiLoc: ApiLocation): string { @@ -2408,20 +2407,9 @@ class PythonGenerator extends Generator { markdown, TargetLanguage.PYTHON, enforcesStrictMode(this.assembly), - (trans) => ({ - language: trans.language, - source: this.prefixDisclaimer(trans), - }), ); } - private prefixDisclaimer(translated: Translation) { - if (!translated.didCompile && INCOMPLETE_DISCLAIMER_NONCOMPILING) { - return `# ${INCOMPLETE_DISCLAIMER_NONCOMPILING}\n${translated.source}`; - } - return translated.source; - } - public getPythonType(fqn: string): PythonType { const type = this.types.get(fqn); diff --git a/packages/jsii-rosetta/lib/commands/transliterate.ts b/packages/jsii-rosetta/lib/commands/transliterate.ts index 4a91681342..86c2f334af 100644 --- a/packages/jsii-rosetta/lib/commands/transliterate.ts +++ b/packages/jsii-rosetta/lib/commands/transliterate.ts @@ -2,14 +2,10 @@ import { Assembly, Docs, SPEC_FILE_NAME, Type, TypeKind } from '@jsii/spec'; import { readJson, writeJson } from 'fs-extra'; import { resolve } from 'path'; -import { fixturize } from '../fixtures'; -import { EXAMPLE_METADATA_JSDOCTAG } from '../jsii/assemblies'; import { TargetLanguage } from '../languages'; import { debug } from '../logging'; import { RosettaTabletReader, UnknownSnippetMode } from '../rosetta-reader'; -import { SnippetParameters, typeScriptSnippetFromVisibleSource, ApiLocation, parseMetadataLine } from '../snippet'; -import { Translation } from '../tablets/tablets'; -import { fmap } from '../util'; +import { typeScriptSnippetFromVisibleSource, ApiLocation } from '../snippet'; import { extractSnippets } from './extract'; export interface TransliterateAssemblyOptions { @@ -71,6 +67,7 @@ export async function transliterateAssembly( const rosetta = new RosettaTabletReader({ unknownSnippets: UnknownSnippetMode.FAIL, targetLanguages, + prefixDisclaimer: true, }); // Put in the same caching tablet here if (options.tablet) { @@ -92,15 +89,10 @@ export async function transliterateAssembly( result.readme.markdown, language, true /* strict */, - (translation) => ({ - language: translation.language, - source: prefixDisclaimer(translation), - }), - location, ); } for (const type of Object.values(result.types ?? {})) { - transliterateType(type, rosetta, language, location, options.loose); + transliterateType(type, rosetta, language); } // eslint-disable-next-line no-await-in-loop await writeJson(resolve(location, `${SPEC_FILE_NAME}.${language}`), result, { spaces: 2 }); @@ -146,70 +138,35 @@ async function loadAssemblies( type Mutable = { -readonly [K in keyof T]: Mutable }; type AssemblyLoader = () => Promise>; -function prefixDisclaimer(translation: Translation): string { - const comment = commentToken(); - const disclaimer = translation.didCompile - ? 'This example was automatically transliterated.' - : 'This example was automatically transliterated with incomplete type information. It may not work as-is.'; - - return [ - `${comment} ${disclaimer}`, - `${comment} See https://github.com/aws/jsii/issues/826 for more information.`, - '', - translation.source, - ].join('\n'); - - function commentToken() { - // This is future-proofed a bit, but don't read too much in this... - switch (translation.language) { - case 'python': - case 'ruby': - return '#'; - case 'csharp': - case 'java': - case 'go': - default: - return '//'; - } - } -} - -function transliterateType( - type: Type, - rosetta: RosettaTabletReader, - language: TargetLanguage, - workingDirectory: string, - loose = false, -): void { - transliterateDocs({ api: 'type', fqn: type.fqn }, type.docs, workingDirectory); +function transliterateType(type: Type, rosetta: RosettaTabletReader, language: TargetLanguage): void { + transliterateDocs({ api: 'type', fqn: type.fqn }, type.docs); switch (type.kind) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore 7029 case TypeKind.Class: if (type.initializer) { - transliterateDocs({ api: 'initializer', fqn: type.fqn }, type.initializer.docs, workingDirectory); + transliterateDocs({ api: 'initializer', fqn: type.fqn }, type.initializer.docs); } // fallthrough case TypeKind.Interface: for (const method of type.methods ?? []) { - transliterateDocs({ api: 'member', fqn: type.fqn, memberName: method.name }, method.docs, workingDirectory); + transliterateDocs({ api: 'member', fqn: type.fqn, memberName: method.name }, method.docs); for (const parameter of method.parameters ?? []) { transliterateDocs( { api: 'parameter', fqn: type.fqn, methodName: method.name, parameterName: parameter.name }, parameter.docs, - workingDirectory, ); } } for (const property of type.properties ?? []) { - transliterateDocs({ api: 'member', fqn: type.fqn, memberName: property.name }, property.docs, workingDirectory); + transliterateDocs({ api: 'member', fqn: type.fqn, memberName: property.name }, property.docs); } break; case TypeKind.Enum: for (const member of type.members) { - transliterateDocs({ api: 'member', fqn: type.fqn, memberName: member.name }, member.docs, workingDirectory); + transliterateDocs({ api: 'member', fqn: type.fqn, memberName: member.name }, member.docs); } break; @@ -217,34 +174,17 @@ function transliterateType( throw new Error(`Unsupported type kind: ${(type as any).kind}`); } - function transliterateDocs(api: ApiLocation, docs: Docs | undefined, workingDirectory: string) { + function transliterateDocs(api: ApiLocation, docs: Docs | undefined) { if (docs?.remarks) { - docs.remarks = rosetta.translateSnippetsInMarkdown( - api, - docs.remarks, - language, - true /* strict */, - (translation) => ({ - language: translation.language, - source: prefixDisclaimer(translation), - }), - workingDirectory, - ); + docs.remarks = rosetta.translateSnippetsInMarkdown(api, docs.remarks, language, true /* strict */); } if (docs?.example) { const location = { api, field: { field: 'example' } } as const; - const metadata = fmap(docs.custom?.[EXAMPLE_METADATA_JSDOCTAG], parseMetadataLine) ?? {}; - const snippet = fixturize( - typeScriptSnippetFromVisibleSource(docs.example, location, true /* strict */, { - [SnippetParameters.$PROJECT_DIRECTORY]: workingDirectory, - ...metadata, - }), - loose, - ); + const snippet = typeScriptSnippetFromVisibleSource(docs.example, location, true /* strict */); const translation = rosetta.translateSnippet(snippet, language); if (translation != null) { - docs.example = prefixDisclaimer(translation); + docs.example = translation.source; } } } diff --git a/packages/jsii-rosetta/lib/rosetta-reader.ts b/packages/jsii-rosetta/lib/rosetta-reader.ts index 49425be437..77f981c800 100644 --- a/packages/jsii-rosetta/lib/rosetta-reader.ts +++ b/packages/jsii-rosetta/lib/rosetta-reader.ts @@ -19,7 +19,7 @@ import { import { snippetKey } from './tablets/key'; import { DEFAULT_TABLET_NAME, LanguageTablet, Translation } from './tablets/tablets'; import { Translator } from './translate'; -import { printDiagnostics } from './util'; +import { commentToken, printDiagnostics } from './util'; export enum UnknownSnippetMode { /** @@ -65,6 +65,13 @@ export interface RosettaOptions { * @default false */ readonly loose?: boolean; + + /** + * Adds a disclaimer to start of snippet if it did not compile. + * + * @default false + */ + readonly prefixDisclaimer?: boolean; } /** @@ -93,11 +100,13 @@ export class RosettaTabletReader { private readonly translator: Translator; private readonly loose: boolean; private readonly unknownSnippets: UnknownSnippetMode; + private readonly _prefixDisclaimer: boolean; public constructor(private readonly options: RosettaOptions = {}) { this.loose = !!options.loose; this.unknownSnippets = options.unknownSnippets ?? UnknownSnippetMode.VERBATIM; this.translator = new Translator(options.includeCompilerDiagnostics ?? false); + this._prefixDisclaimer = options.prefixDisclaimer ?? false; } /** @@ -183,15 +192,18 @@ export class RosettaTabletReader { for (const tab of this.allTablets) { const ret = tab.lookup(source, targetLang); if (ret !== undefined) { - return ret; + return this.prefixDisclaimer(ret, this._prefixDisclaimer); } } if (this.unknownSnippets === UnknownSnippetMode.VERBATIM) { - return { - language: targetLang, - source: source.visibleSource, - }; + return this.prefixDisclaimer( + { + language: targetLang, + source: source.visibleSource, + }, + this._prefixDisclaimer, + ); } if (this.unknownSnippets === UnknownSnippetMode.FAIL) { @@ -218,13 +230,13 @@ export class RosettaTabletReader { if (extracted !== undefined) { const snippet = this.translator.translate(extracted, this.options.targetLanguages); this.liveTablet.addSnippet(snippet); - return snippet.get(targetLang); + return this.prefixDisclaimer(snippet.get(targetLang), this._prefixDisclaimer); } // Try to live-convert it as-is. const snippet = this.translator.translate(source, this.options.targetLanguages); this.liveTablet.addSnippet(snippet); - return snippet.get(targetLang); + return this.prefixDisclaimer(snippet.get(targetLang), this._prefixDisclaimer); } /** @@ -294,6 +306,22 @@ export class RosettaTabletReader { private get allTablets(): LanguageTablet[] { return [...this.loadedTablets, this.liveTablet]; } + + /** + * Adds a disclaimer to the front of the example if the prefixDisclaimer + * flag is set and we know it does not compile. + */ + private prefixDisclaimer(translation: Translation | undefined, prefixDisclaimer: boolean): Translation | undefined { + if (!prefixDisclaimer || translation?.didCompile !== false) { + return translation; + } + const comment = commentToken(translation.language); + const disclaimer = 'Example automatically generated from non-compiling source. May contain errors.'; + return { + ...translation, + source: `${comment} ${disclaimer}\n${translation.source}`, + }; + } } function id(x: Translation) { diff --git a/packages/jsii-rosetta/lib/util.ts b/packages/jsii-rosetta/lib/util.ts index 4f618b8b60..93ba9d7fd6 100644 --- a/packages/jsii-rosetta/lib/util.ts +++ b/packages/jsii-rosetta/lib/util.ts @@ -205,3 +205,17 @@ export function isDefined(x: A): x is NonNullable { export function indexBy(xs: A[], fn: (x: A) => string): Record { return mkDict(xs.map((x) => [fn(x), x] as const)); } + +export function commentToken(language: string) { + // This is future-proofed a bit, but don't read too much in this... + switch (language) { + case 'python': + case 'ruby': + return '#'; + case 'csharp': + case 'java': + case 'go': + default: + return '//'; + } +} diff --git a/packages/jsii-rosetta/test/commands/transliterate.test.ts b/packages/jsii-rosetta/test/commands/transliterate.test.ts index 83ff4926e9..9a8f36e663 100644 --- a/packages/jsii-rosetta/test/commands/transliterate.test.ts +++ b/packages/jsii-rosetta/test/commands/transliterate.test.ts @@ -139,9 +139,6 @@ export class ClassName implements IInterface { "markdown": "# README \`\`\`csharp - // This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - IInterface object = new ClassName(\\"this\\", 1337, new ClassNameProps { Foo = \\"bar\\" }); object.Property = EnumType.OPTION_A; object.MethodCall(); @@ -165,10 +162,7 @@ export class ClassName implements IInterface { "fqn": "testpkg.ClassName", "initializer": Object { "docs": Object { - "example": "// This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - - new ClassName(\\"this\\", 1337, new ClassNameProps { Property = EnumType.OPTION_B });", + "example": "new ClassName(\\"this\\", 1337, new ClassNameProps { Property = EnumType.OPTION_B });", "summary": "Create a new instance of ClassName.", }, "locationInModule": Object { @@ -207,10 +201,7 @@ export class ClassName implements IInterface { "methods": Array [ Object { "docs": Object { - "example": "// This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - - ClassName.StaticMethod();", + "example": "ClassName.StaticMethod();", "remarks": "It can be invoked easily.", "summary": "A static method.", }, @@ -304,10 +295,7 @@ export class ClassName implements IInterface { "testpkg.EnumType": Object { "assembly": "testpkg", "docs": Object { - "example": "// This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - - new ClassName(\\"this\\", 1337, new ClassNameProps { Property = EnumType.OPTION_B });", + "example": "new ClassName(\\"this\\", 1337, new ClassNameProps { Property = EnumType.OPTION_B });", }, "fqn": "testpkg.EnumType", "kind": "enum", @@ -318,19 +306,13 @@ export class ClassName implements IInterface { "members": Array [ Object { "docs": Object { - "example": "// This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - - new ClassName(\\"this\\", 1337, new ClassNameProps { Property = EnumType.OPTION_A });", + "example": "new ClassName(\\"this\\", 1337, new ClassNameProps { Property = EnumType.OPTION_A });", }, "name": "OPTION_A", }, Object { "docs": Object { - "example": "// This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - - new ClassName(\\"this\\", 1337, new ClassNameProps { Property = EnumType.OPTION_B });", + "example": "new ClassName(\\"this\\", 1337, new ClassNameProps { Property = EnumType.OPTION_B });", }, "name": "OPTION_B", }, @@ -350,10 +332,7 @@ export class ClassName implements IInterface { Object { "abstract": true, "docs": Object { - "example": "// This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - - iface.MethodCall();", + "example": "iface.MethodCall();", "summary": "An instance method call.", }, "locationInModule": Object { @@ -368,10 +347,7 @@ export class ClassName implements IInterface { Object { "abstract": true, "docs": Object { - "example": "// This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - - iface.Property = EnumType.OPTION_B;", + "example": "iface.Property = EnumType.OPTION_B;", "summary": "A property value.", }, "locationInModule": Object { @@ -421,9 +397,6 @@ export class ClassName implements IInterface { "markdown": "# README \`\`\`java - // This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - IInterface object = new ClassName(\\"this\\", 1337, new ClassNameProps().foo(\\"bar\\")); object.getProperty() = EnumType.OPTION_A; object.methodCall(); @@ -447,10 +420,7 @@ export class ClassName implements IInterface { "fqn": "testpkg.ClassName", "initializer": Object { "docs": Object { - "example": "// This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - - new ClassName(\\"this\\", 1337, new ClassNameProps().property(EnumType.OPTION_B));", + "example": "new ClassName(\\"this\\", 1337, new ClassNameProps().property(EnumType.OPTION_B));", "summary": "Create a new instance of ClassName.", }, "locationInModule": Object { @@ -489,10 +459,7 @@ export class ClassName implements IInterface { "methods": Array [ Object { "docs": Object { - "example": "// This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - - ClassName.staticMethod();", + "example": "ClassName.staticMethod();", "remarks": "It can be invoked easily.", "summary": "A static method.", }, @@ -586,10 +553,7 @@ export class ClassName implements IInterface { "testpkg.EnumType": Object { "assembly": "testpkg", "docs": Object { - "example": "// This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - - new ClassName(\\"this\\", 1337, new ClassNameProps().property(EnumType.OPTION_B));", + "example": "new ClassName(\\"this\\", 1337, new ClassNameProps().property(EnumType.OPTION_B));", }, "fqn": "testpkg.EnumType", "kind": "enum", @@ -600,19 +564,13 @@ export class ClassName implements IInterface { "members": Array [ Object { "docs": Object { - "example": "// This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - - new ClassName(\\"this\\", 1337, new ClassNameProps().property(EnumType.OPTION_A));", + "example": "new ClassName(\\"this\\", 1337, new ClassNameProps().property(EnumType.OPTION_A));", }, "name": "OPTION_A", }, Object { "docs": Object { - "example": "// This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - - new ClassName(\\"this\\", 1337, new ClassNameProps().property(EnumType.OPTION_B));", + "example": "new ClassName(\\"this\\", 1337, new ClassNameProps().property(EnumType.OPTION_B));", }, "name": "OPTION_B", }, @@ -632,10 +590,7 @@ export class ClassName implements IInterface { Object { "abstract": true, "docs": Object { - "example": "// This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - - iface.methodCall();", + "example": "iface.methodCall();", "summary": "An instance method call.", }, "locationInModule": Object { @@ -650,10 +605,7 @@ export class ClassName implements IInterface { Object { "abstract": true, "docs": Object { - "example": "// This example was automatically transliterated. - // See https://github.com/aws/jsii/issues/826 for more information. - - iface.getProperty() = EnumType.OPTION_B;", + "example": "iface.getProperty() = EnumType.OPTION_B;", "summary": "A property value.", }, "locationInModule": Object { @@ -703,9 +655,6 @@ export class ClassName implements IInterface { "markdown": "# README \`\`\`python - # This example was automatically transliterated. - # See https://github.com/aws/jsii/issues/826 for more information. - object = ClassName(\\"this\\", 1337, foo=\\"bar\\") object.property = EnumType.OPTION_A object.method_call() @@ -729,10 +678,7 @@ export class ClassName implements IInterface { "fqn": "testpkg.ClassName", "initializer": Object { "docs": Object { - "example": "# This example was automatically transliterated. - # See https://github.com/aws/jsii/issues/826 for more information. - - ClassName(\\"this\\", 1337, property=EnumType.OPTION_B)", + "example": "ClassName(\\"this\\", 1337, property=EnumType.OPTION_B)", "summary": "Create a new instance of ClassName.", }, "locationInModule": Object { @@ -771,10 +717,7 @@ export class ClassName implements IInterface { "methods": Array [ Object { "docs": Object { - "example": "# This example was automatically transliterated. - # See https://github.com/aws/jsii/issues/826 for more information. - - ClassName.static_method()", + "example": "ClassName.static_method()", "remarks": "It can be invoked easily.", "summary": "A static method.", }, @@ -868,10 +811,7 @@ export class ClassName implements IInterface { "testpkg.EnumType": Object { "assembly": "testpkg", "docs": Object { - "example": "# This example was automatically transliterated. - # See https://github.com/aws/jsii/issues/826 for more information. - - ClassName(\\"this\\", 1337, property=EnumType.OPTION_B)", + "example": "ClassName(\\"this\\", 1337, property=EnumType.OPTION_B)", }, "fqn": "testpkg.EnumType", "kind": "enum", @@ -882,19 +822,13 @@ export class ClassName implements IInterface { "members": Array [ Object { "docs": Object { - "example": "# This example was automatically transliterated. - # See https://github.com/aws/jsii/issues/826 for more information. - - ClassName(\\"this\\", 1337, property=EnumType.OPTION_A)", + "example": "ClassName(\\"this\\", 1337, property=EnumType.OPTION_A)", }, "name": "OPTION_A", }, Object { "docs": Object { - "example": "# This example was automatically transliterated. - # See https://github.com/aws/jsii/issues/826 for more information. - - ClassName(\\"this\\", 1337, property=EnumType.OPTION_B)", + "example": "ClassName(\\"this\\", 1337, property=EnumType.OPTION_B)", }, "name": "OPTION_B", }, @@ -914,10 +848,7 @@ export class ClassName implements IInterface { Object { "abstract": true, "docs": Object { - "example": "# This example was automatically transliterated. - # See https://github.com/aws/jsii/issues/826 for more information. - - iface.method_call()", + "example": "iface.method_call()", "summary": "An instance method call.", }, "locationInModule": Object { @@ -932,10 +863,7 @@ export class ClassName implements IInterface { Object { "abstract": true, "docs": Object { - "example": "# This example was automatically transliterated. - # See https://github.com/aws/jsii/issues/826 for more information. - - iface.property = EnumType.OPTION_B", + "example": "iface.property = EnumType.OPTION_B", "summary": "A property value.", }, "locationInModule": Object { @@ -1053,9 +981,7 @@ new SampleClass('omitted-literate'); ## This is a heading within the literate file! \`\`\`csharp - // This example was automatically transliterated with incomplete type information. It may not work as-is. - // See https://github.com/aws/jsii/issues/826 for more information. - + // Example automatically generated from non-compiling source. May contain errors. new SampleClass(\\"literate\\"); \`\`\` @@ -1064,18 +990,14 @@ new SampleClass('omitted-literate'); ## This is a heading within the omitted literate file! \`\`\`csharp - // This example was automatically transliterated with incomplete type information. It may not work as-is. - // See https://github.com/aws/jsii/issues/826 for more information. - + // Example automatically generated from non-compiling source. May contain errors. new SampleClass(\\"omitted-literate\\"); \`\`\` # Missing fixture \`\`\`csharp - // This example was automatically transliterated with incomplete type information. It may not work as-is. - // See https://github.com/aws/jsii/issues/826 for more information. - + // Example automatically generated from non-compiling source. May contain errors. new SampleClass(\\"README.md\\"); \`\`\`", }, @@ -1093,9 +1015,7 @@ new SampleClass('omitted-literate'); "testpkg.SampleClass": Object { "assembly": "testpkg", "docs": Object { - "example": "// This example was automatically transliterated with incomplete type information. It may not work as-is. - // See https://github.com/aws/jsii/issues/826 for more information. - + "example": "// Example automatically generated from non-compiling source. May contain errors. new DoesNotCompile(this, \\"That\\", new Struct { Foo = 1337 });", }, "fqn": "testpkg.SampleClass", @@ -1159,9 +1079,7 @@ new SampleClass('omitted-literate'); ## This is a heading within the literate file! \`\`\`java - // This example was automatically transliterated with incomplete type information. It may not work as-is. - // See https://github.com/aws/jsii/issues/826 for more information. - + // Example automatically generated from non-compiling source. May contain errors. new SampleClass(\\"literate\\"); \`\`\` @@ -1170,18 +1088,14 @@ new SampleClass('omitted-literate'); ## This is a heading within the omitted literate file! \`\`\`java - // This example was automatically transliterated with incomplete type information. It may not work as-is. - // See https://github.com/aws/jsii/issues/826 for more information. - + // Example automatically generated from non-compiling source. May contain errors. new SampleClass(\\"omitted-literate\\"); \`\`\` # Missing fixture \`\`\`java - // This example was automatically transliterated with incomplete type information. It may not work as-is. - // See https://github.com/aws/jsii/issues/826 for more information. - + // Example automatically generated from non-compiling source. May contain errors. new SampleClass(\\"README.md\\"); \`\`\`", }, @@ -1199,9 +1113,7 @@ new SampleClass('omitted-literate'); "testpkg.SampleClass": Object { "assembly": "testpkg", "docs": Object { - "example": "// This example was automatically transliterated with incomplete type information. It may not work as-is. - // See https://github.com/aws/jsii/issues/826 for more information. - + "example": "// Example automatically generated from non-compiling source. May contain errors. DoesNotCompile.Builder.create(this, \\"That\\").foo(1337).build();", }, "fqn": "testpkg.SampleClass", @@ -1265,9 +1177,7 @@ new SampleClass('omitted-literate'); ## This is a heading within the literate file! \`\`\`python - # This example was automatically transliterated with incomplete type information. It may not work as-is. - # See https://github.com/aws/jsii/issues/826 for more information. - + # Example automatically generated from non-compiling source. May contain errors. SampleClass(\\"literate\\") \`\`\` @@ -1276,18 +1186,14 @@ new SampleClass('omitted-literate'); ## This is a heading within the omitted literate file! \`\`\`python - # This example was automatically transliterated with incomplete type information. It may not work as-is. - # See https://github.com/aws/jsii/issues/826 for more information. - + # Example automatically generated from non-compiling source. May contain errors. SampleClass(\\"omitted-literate\\") \`\`\` # Missing fixture \`\`\`python - # This example was automatically transliterated with incomplete type information. It may not work as-is. - # See https://github.com/aws/jsii/issues/826 for more information. - + # Example automatically generated from non-compiling source. May contain errors. SampleClass(\\"README.md\\") \`\`\`", }, @@ -1305,9 +1211,7 @@ new SampleClass('omitted-literate'); "testpkg.SampleClass": Object { "assembly": "testpkg", "docs": Object { - "example": "# This example was automatically transliterated with incomplete type information. It may not work as-is. - # See https://github.com/aws/jsii/issues/826 for more information. - + "example": "# Example automatically generated from non-compiling source. May contain errors. DoesNotCompile(self, \\"That\\", foo=1337)", }, "fqn": "testpkg.SampleClass", diff --git a/packages/jsii-rosetta/test/rosetta.test.ts b/packages/jsii-rosetta/test/rosetta.test.ts index 596037eaa6..7d68c2eccd 100644 --- a/packages/jsii-rosetta/test/rosetta.test.ts +++ b/packages/jsii-rosetta/test/rosetta.test.ts @@ -18,6 +18,11 @@ const SAMPLE_CODE: TypeScriptSnippet = { location: testSnippetLocation('sample'), }; +const SAMPLE_CODE_COMPILING: TypeScriptSnippet = { + visibleSource: 'console.log("hello");', + location: testSnippetLocation('sample'), +}; + describe('Rosetta object can do live translation', () => { let rosetta: Rosetta; let translated: Translation | undefined; @@ -157,6 +162,60 @@ test('Rosetta object can do translation and annotation of snippets in MarkDown', ); }); +describe('Rosetta object with disclaimers', () => { + let rosetta: Rosetta; + beforeEach(() => { + // GIVEN + rosetta = new Rosetta({ + includeCompilerDiagnostics: true, + unknownSnippets: UnknownSnippetMode.TRANSLATE, + targetLanguages: [TargetLanguage.PYTHON], + prefixDisclaimer: true, + }); + }); + + test('compiling source code has no disclaimer', () => { + // WHEN + const translated = rosetta.translateSnippet(SAMPLE_CODE_COMPILING, TargetLanguage.PYTHON); + + // THEN + expect(translated).toMatchObject({ + source: 'print("hello")', + language: 'python', + }); + }); + + test('noncompiling source code has disclaimer', () => { + // WHEN + const translated = rosetta.translateSnippet(SAMPLE_CODE, TargetLanguage.PYTHON); + + // THEN + expect(translated).toMatchObject({ + source: '# Example automatically generated from non-compiling source. May contain errors.\ncall_this_function()', + language: 'python', + }); + }); + + test('source with no compilation information has no disclaimer', () => { + // GIVEN + const rosettaNoCompile = new Rosetta({ + includeCompilerDiagnostics: false, + unknownSnippets: UnknownSnippetMode.TRANSLATE, + targetLanguages: [TargetLanguage.PYTHON], + prefixDisclaimer: true, + }); + + // WHEN + const translated = rosettaNoCompile.translateSnippet(SAMPLE_CODE, TargetLanguage.PYTHON); + + // THEN + expect(translated).toMatchObject({ + source: 'call_this_function()', + language: 'python', + }); + }); +}); + describe('with mocked filesystem', () => { beforeEach(() => { mockfs(); From 9175d608c9a7af3e17359d07f1f1ea572c738862 Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <36202692+kaizen3031593@users.noreply.github.com> Date: Thu, 30 Dec 2021 16:23:47 -0500 Subject: [PATCH 10/14] chore(rosetta): loose option not exposed to command-line for extract (#3304) In `ExtractOptions`, we specify an option called `loose`. We should also have a command-line argument `--loose` to reflect that, which is what I'm adding here. The `loose` flag is already tested; so I don't think we need to add any tests here. --- 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 --- packages/jsii-rosetta/bin/jsii-rosetta.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/jsii-rosetta/bin/jsii-rosetta.ts b/packages/jsii-rosetta/bin/jsii-rosetta.ts index 20ef8c46c5..8f05aed94c 100644 --- a/packages/jsii-rosetta/bin/jsii-rosetta.ts +++ b/packages/jsii-rosetta/bin/jsii-rosetta.ts @@ -221,7 +221,14 @@ function main() { describe: 'Require all code samples compile, and fail if one does not. Strict mode always enables --compile and --fail', default: false, - }), + }) + .options('loose', { + alias: 'l', + describe: 'Ignore missing fixtures and literate markdown files instead of failing', + type: 'boolean', + }) + .conflicts('loose', 'strict') + .conflicts('loose', 'fail'), wrapHandler(async (args) => { // `--strict` is short for `--compile --fail`, and we'll override those even if they're set to `false`, such as // using `--no-(compile|fail)`, because yargs does not quite give us a better option that does not hurt CX. @@ -250,6 +257,7 @@ function main() { cacheFromFile: absCacheFrom, cacheToFile: absCacheTo, trimCache: args['trim-cache'], + loose: args.loose, }; const result = args.infuse From a833a1d2f1335e9447fd5702b9e4f9c6166abe67 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Fri, 31 Dec 2021 10:54:03 +0100 Subject: [PATCH 11/14] fix(rosetta): Python translation for `implements` is wrong (#3280) For Python, interface implementation needs to be written as `@jsii.implements(Iface)`. Also add a check that people don't put functions in object literals. Fixes aws/aws-cdk#17928 --- 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 --- packages/jsii-rosetta/lib/jsii/jsii-utils.ts | 75 +++++++++++++++++++ .../jsii-rosetta/lib/languages/default.ts | 39 +++++++++- packages/jsii-rosetta/lib/languages/python.ts | 22 ++++-- packages/jsii-rosetta/test/translate.test.ts | 38 ++++++++++ .../class_implementing_jsii_interface.cs | 7 ++ .../class_implementing_jsii_interface.java | 5 ++ .../class_implementing_jsii_interface.py | 4 + .../class_implementing_jsii_interface.ts | 12 +++ 8 files changed, 195 insertions(+), 7 deletions(-) create mode 100644 packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.cs create mode 100644 packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.java create mode 100644 packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.py create mode 100644 packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.ts diff --git a/packages/jsii-rosetta/lib/jsii/jsii-utils.ts b/packages/jsii-rosetta/lib/jsii/jsii-utils.ts index ec5e845093..45e94100a2 100644 --- a/packages/jsii-rosetta/lib/jsii/jsii-utils.ts +++ b/packages/jsii-rosetta/lib/jsii/jsii-utils.ts @@ -1,3 +1,4 @@ +import * as spec from '@jsii/spec'; import { symbolIdentifier } from 'jsii'; import * as ts from 'typescript'; @@ -29,6 +30,60 @@ export function analyzeStructType(typeChecker: ts.TypeChecker, type: ts.Type): O return { kind: 'local-struct', type }; } +/** + * Whether the given type is a protocol AND comes from jsii + * + * - Protocol: a TypeScript interface that is *not* a "struct" type. + * A.k.a. "behavioral interface". + * - From jsii: whether the interface type is defined in and exported + * via a jsii assembly. There can be literal interfaces defined + * in an example, and they will not be mangled in the same way + * as a jsii interface would be. + * + * + * Examples: + * + * ```ts + * // isJsiiProtocolType() -> false: not a protocol + * interface Banana { + * readonly arc: number; + * } + * + * // isJsiiProtocolType() -> might be true: depends on whether it was defined + * // in a jsii assembly. + * interface IHello { + * sayIt(): void; + * } + * + * // isJsiiProtocolType() -> false: declared to not be a protocol, even though + * // it has the naming scheme of one + * /** + * * @struct + * * / + * interface IPAddress { + * readonly octets: number[]; + * } + * ``` + */ +export function isJsiiProtocolType(typeChecker: ts.TypeChecker, type: ts.Type): boolean | undefined { + if (!type.isClassOrInterface() || !hasAllFlags(type.objectFlags, ts.ObjectFlags.Interface)) { + return false; + } + + const sym = lookupJsiiSymbol(typeChecker, type.symbol); + if (!sym) { + return false; + } + + if (!sym.sourceAssembly) { + // No source assembly, so this is a 'fake-from-jsii' type + return !isNamedLikeStruct(type.symbol.name); + } + + const jsiiType = resolveJsiiSymbolType(sym); + return spec.isInterfaceType(jsiiType) && !jsiiType.datatype; +} + export function hasAllFlags(flags: A, test: A) { // tslint:disable-next-line:no-bitwise return test !== 0 && (flags & test) === test; @@ -100,6 +155,26 @@ export function lookupJsiiSymbolFromNode(typeChecker: ts.TypeChecker, node: ts.N return fmap(typeChecker.getSymbolAtLocation(node), (s) => lookupJsiiSymbol(typeChecker, s)); } +export function resolveJsiiSymbolType(jsiiSymbol: JsiiSymbol): spec.Type { + if (jsiiSymbol.symbolType !== 'type') { + throw new Error( + `Expected symbol to refer to a 'type', got '${jsiiSymbol.fqn}' which is a '${jsiiSymbol.symbolType}'`, + ); + } + + if (!jsiiSymbol.sourceAssembly) { + throw new Error('`resolveJsiiSymbolType: requires an actual source assembly'); + } + + const type = jsiiSymbol.sourceAssembly?.assembly.types?.[jsiiSymbol.fqn]; + if (!type) { + throw new Error( + `resolveJsiiSymbolType: ${jsiiSymbol.fqn} not found in assembly ${jsiiSymbol.sourceAssembly.assembly.name}`, + ); + } + return type; +} + /** * Returns the jsii FQN for a TypeScript (class or type) symbol * diff --git a/packages/jsii-rosetta/lib/languages/default.ts b/packages/jsii-rosetta/lib/languages/default.ts index dc6a83fd2f..bc82fde164 100644 --- a/packages/jsii-rosetta/lib/languages/default.ts +++ b/packages/jsii-rosetta/lib/languages/default.ts @@ -1,7 +1,7 @@ import * as ts from 'typescript'; import { analyzeObjectLiteral, ObjectLiteralStruct } from '../jsii/jsii-types'; -import { isNamedLikeStruct } from '../jsii/jsii-utils'; +import { isNamedLikeStruct, isJsiiProtocolType } from '../jsii/jsii-utils'; import { OTree, NO_SYNTAX } from '../o-tree'; import { AstRenderer, AstHandler, nimpl, CommentSyntax } from '../renderer'; import { voidExpressionString } from '../typescript/ast-utils'; @@ -153,6 +153,22 @@ export abstract class DefaultVisitor implements AstHandler { context.report(unsup, `Use of ${ts.SyntaxKind[unsup.kind]} in an object literal is not supported.`); } + const anyMembersFunctions = node.properties.some((p) => + ts.isPropertyAssignment(p) + ? isExpressionOfFunctionType(context.typeChecker, p.initializer) + : ts.isShorthandPropertyAssignment(p) + ? isExpressionOfFunctionType(context.typeChecker, p.name) + : false, + ); + + const inferredType = context.inferredTypeOfExpression(node); + if ((inferredType && isJsiiProtocolType(context.typeChecker, inferredType)) || anyMembersFunctions) { + context.report( + node, + `You cannot use an object literal to make an instance of an interface. Define a class instead.`, + ); + } + const lit = analyzeObjectLiteral(context.typeChecker, node); switch (lit.kind) { @@ -342,3 +358,24 @@ const UNARY_OPS: { [op in ts.PrefixUnaryOperator]: string } = { [ts.SyntaxKind.TildeToken]: '~', [ts.SyntaxKind.ExclamationToken]: '!', }; + +/** + * Whether the given expression evaluates to a value that is of type "function" + * + * Examples of function types: + * + * ```ts + * // GIVEN + * function someFunction() { } + * + * // THEN + * const x = someFunction; // <- function type + * const y = () => 42; // <- function type + * const z = x; // <- function type + * Array.isArray; // <- function type + * ``` + */ +function isExpressionOfFunctionType(typeChecker: ts.TypeChecker, expr: ts.Expression) { + const type = typeChecker.getTypeAtLocation(expr).getNonNullableType(); + return type.getCallSignatures().length > 0; +} diff --git a/packages/jsii-rosetta/lib/languages/python.ts b/packages/jsii-rosetta/lib/languages/python.ts index 73b0c434dc..24d903469c 100644 --- a/packages/jsii-rosetta/lib/languages/python.ts +++ b/packages/jsii-rosetta/lib/languages/python.ts @@ -9,6 +9,7 @@ import { JsiiSymbol, simpleName, namespaceName, + isJsiiProtocolType, } from '../jsii/jsii-utils'; import { jsiiTargetParameter } from '../jsii/packages'; import { TargetLanguage } from '../languages/target-language'; @@ -23,7 +24,7 @@ import { } from '../typescript/ast-utils'; import { ImportStatement } from '../typescript/imports'; import { parameterAcceptsUndefined } from '../typescript/types'; -import { startsWithUppercase, flat, sortBy, groupBy, fmap } from '../util'; +import { startsWithUppercase, sortBy, groupBy, fmap } from '../util'; import { DefaultVisitor } from './default'; interface StructVar { @@ -102,7 +103,7 @@ export class PythonVisitor extends DefaultVisitor { * Bump this when you change something in the implementation to invalidate * existing cached translations. */ - public static readonly VERSION = '1'; + public static readonly VERSION = '2'; public readonly language = TargetLanguage.PYTHON; public readonly defaultContext = {}; @@ -532,10 +533,18 @@ export class PythonVisitor extends DefaultVisitor { } public classDeclaration(node: ts.ClassDeclaration, context: PythonVisitorContext): OTree { - const heritage = flat(Array.from(node.heritageClauses ?? []).map((h) => Array.from(h.types))).map((t) => - context.convert(t.expression), + const allHeritageClauses = Array.from(node.heritageClauses ?? []).flatMap((h) => Array.from(h.types)); + + // List of booleans matching `allHeritage` array + const isJsii = allHeritageClauses.map( + (e) => + fmap(context.typeOfExpression(e.expression), (type) => isJsiiProtocolType(context.typeChecker, type)) ?? false, ); - const hasHeritage = heritage.length > 0; + + const jsiiImplements = allHeritageClauses.filter((_, i) => isJsii[i]); + + const inlineHeritage = allHeritageClauses.filter((_, i) => !isJsii[i]); + const hasHeritage = inlineHeritage.length > 0; const members = context.updateContext({ inClass: true }).convertAll(node.members); if (members.length === 0) { @@ -544,10 +553,11 @@ export class PythonVisitor extends DefaultVisitor { const ret = new OTree( [ + ...jsiiImplements.flatMap((i) => ['@jsii.implements(', context.convert(i.expression), ')\n']), 'class ', node.name ? context.textOf(node.name) : '???', hasHeritage ? '(' : '', - ...heritage, + ...inlineHeritage.map((t) => context.convert(t.expression)), hasHeritage ? ')' : '', ': ', ], diff --git a/packages/jsii-rosetta/test/translate.test.ts b/packages/jsii-rosetta/test/translate.test.ts index 7643b9caab..a42b6b7bf7 100644 --- a/packages/jsii-rosetta/test/translate.test.ts +++ b/packages/jsii-rosetta/test/translate.test.ts @@ -144,3 +144,41 @@ test('didSuccessfullyCompile is undefined when compilation is not attempted', () expect(subject.didSuccessfullyCompile).toBeUndefined(); }); + +test('refuse to translate object literal with function member', () => { + const visibleSource = 'const x: any = { mem: () => 42 };'; + + const snippet: TypeScriptSnippet = { + visibleSource, + location: { api: { api: 'type', fqn: 'my.class' } }, + }; + + // WHEN + const subject = new SnippetTranslator(snippet); + subject.renderUsing(new PythonVisitor()); + + expect(subject.diagnostics).toContainEqual( + expect.objectContaining({ + messageText: expect.stringMatching(/You cannot use an object literal/), + }), + ); +}); + +test('refuse to translate object literal with function member in shorthand property', () => { + const visibleSource = 'const mem = () => 42; const x: any = { mem };'; + + const snippet: TypeScriptSnippet = { + visibleSource, + location: { api: { api: 'type', fqn: 'my.class' } }, + }; + + // WHEN + const subject = new SnippetTranslator(snippet); + subject.renderUsing(new PythonVisitor()); + + expect(subject.diagnostics).toContainEqual( + expect.objectContaining({ + messageText: expect.stringMatching(/You cannot use an object literal/), + }), + ); +}); diff --git a/packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.cs b/packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.cs new file mode 100644 index 0000000000..4b59e581bf --- /dev/null +++ b/packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.cs @@ -0,0 +1,7 @@ +class MyClass : IResolvable +{ + public object Resolve() + { + return 42; + } +} \ No newline at end of file diff --git a/packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.java b/packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.java new file mode 100644 index 0000000000..fd8db8e96b --- /dev/null +++ b/packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.java @@ -0,0 +1,5 @@ +public class MyClass implements IResolvable { + public Object resolve() { + return 42; + } +} \ No newline at end of file diff --git a/packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.py b/packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.py new file mode 100644 index 0000000000..a51997c53d --- /dev/null +++ b/packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.py @@ -0,0 +1,4 @@ +@jsii.implements(IResolvable) +class MyClass: + def resolve(self): + return 42 \ No newline at end of file diff --git a/packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.ts b/packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.ts new file mode 100644 index 0000000000..611ec90dd8 --- /dev/null +++ b/packages/jsii-rosetta/test/translations/classes/class_implementing_jsii_interface.ts @@ -0,0 +1,12 @@ +/// !hide +/// fake-from-jsii +interface IResolvable { + resolve(): any; +} +/// !show + +class MyClass implements IResolvable { + public resolve(): any { + return 42; + } +} \ No newline at end of file From 215f3c421c43bec45f6f1852d3524564720888c0 Mon Sep 17 00:00:00 2001 From: Otavio Macedo Date: Tue, 4 Jan 2022 14:16:33 +0000 Subject: [PATCH 12/14] chore: excluding setuptools from dependabot (#3314) `setuptools` version 60.2.0 and above require Python >= 3.7. If dependabot updates it, the build will fail, as we have jobs that run on Python 3.6. --- 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 --- .github/dependabot.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 33abf8c19a..5e59efe7c5 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -48,6 +48,8 @@ updates: labels: - dependencies - language/python + ignore: + - dependency-name: "setuptools" - package-ecosystem: gomod directory: '/packages/@jsii/go-runtime' From d34881c35a56302ef2a1c3e8a0d19995c3344720 Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <36202692+kaizen3031593@users.noreply.github.com> Date: Wed, 5 Jan 2022 11:16:42 -0500 Subject: [PATCH 13/14] chore(rosetta): change how python shows declared types and include module name (#3317) Currently, Python type declarations are rendered as such: ```python # get_book_handler is of type Function # get_book_integration is of type LambdaIntegration get_book_integration = apigateway.LambdaIntegration(get_book_handler, content_handling=apigateway.ContentHandling.CONVERT_TO_TEXT, # convert to base64 credentials_passthrough=True ) ``` This PR adds information on what module the type came from (if possible), and changes the way these type declarations are shown: ```python # get_book_handler: lambda.Function # get_book_integration: apigateway.LambdaIntegration get_book_integration = apigateway.LambdaIntegration(get_book_handler, content_handling=apigateway.ContentHandling.CONVERT_TO_TEXT, # convert to base64 credentials_passthrough=True ) ``` --- 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 --- packages/jsii-rosetta/lib/languages/python.ts | 15 ++++---- .../jsii-rosetta/test/jsii-imports.test.ts | 2 +- packages/jsii-rosetta/test/translate.test.ts | 38 ++++++++++++++++++- .../translations/expressions/array_index.py | 2 +- .../translations/statements/declare_var.py | 2 +- 5 files changed, 48 insertions(+), 11 deletions(-) diff --git a/packages/jsii-rosetta/lib/languages/python.ts b/packages/jsii-rosetta/lib/languages/python.ts index 24d903469c..a42207ee0d 100644 --- a/packages/jsii-rosetta/lib/languages/python.ts +++ b/packages/jsii-rosetta/lib/languages/python.ts @@ -501,7 +501,7 @@ export class PythonVisitor extends DefaultVisitor { (node.initializer && context.typeOfExpression(node.initializer)); const renderedType = type ? this.renderType(node, type, context, fallback) : fallback; - return new OTree(['# ', context.convert(node.name), ' is of type ', renderedType], []); + return new OTree(['# ', context.convert(node.name), ': ', renderedType], []); } return new OTree([context.convert(node.name), ' = ', context.convert(node.initializer)], [], { @@ -731,21 +731,22 @@ export class PythonVisitor extends DefaultVisitor { renderer.report(owningNode, jsiiType.message); return fallback; case 'map': - return `dictionary of string to ${doRender(jsiiType.elementType)}`; + return `Dict[str, ${doRender(jsiiType.elementType)}]`; case 'list': - return `list of ${doRender(jsiiType.elementType)}`; + return `List[${doRender(jsiiType.elementType)}]`; case 'namedType': - return jsiiType.name; + // in this case, the fallback will hold more information than jsiiType.name + return fallback; case 'builtIn': switch (jsiiType.builtIn) { case 'boolean': - return 'boolean'; + return 'bool'; case 'number': return 'number'; case 'string': - return 'string'; + return 'str'; case 'any': - return 'object'; + return 'Any'; default: return jsiiType.builtIn; } diff --git a/packages/jsii-rosetta/test/jsii-imports.test.ts b/packages/jsii-rosetta/test/jsii-imports.test.ts index 2d8b9863b3..2cd61f9d86 100644 --- a/packages/jsii-rosetta/test/jsii-imports.test.ts +++ b/packages/jsii-rosetta/test/jsii-imports.test.ts @@ -493,7 +493,7 @@ const DEFAULT_CSHARP_CODE = [ ]; /** - * Verify the Java output. All expected Java outputs look the same. + * Verify the output in the given language. All expected outputs look the same. */ function expectTranslation(trans: TranslatedSnippet, lang: TargetLanguage, expected: string[]) { expect(trans.get(lang)?.source.split('\n')).toEqual(expected); diff --git a/packages/jsii-rosetta/test/translate.test.ts b/packages/jsii-rosetta/test/translate.test.ts index a42b6b7bf7..766c8692ac 100644 --- a/packages/jsii-rosetta/test/translate.test.ts +++ b/packages/jsii-rosetta/test/translate.test.ts @@ -1,6 +1,7 @@ -import { SnippetTranslator, TypeScriptSnippet, PythonVisitor } from '../lib'; +import { SnippetTranslator, TypeScriptSnippet, PythonVisitor, TargetLanguage } from '../lib'; import { VisualizeAstVisitor } from '../lib/languages/visualize'; import { snippetKey } from '../lib/tablets/key'; +import { TestJsiiModule, DUMMY_JSII_CONFIG } from './testutil'; const location = { api: { api: 'moduleReadme', moduleFqn: '@aws-cdk/aws-apigateway' }, @@ -182,3 +183,38 @@ test('refuse to translate object literal with function member in shorthand prope }), ); }); + +test('declarations are translated correctly in all jsii languages', async () => { + // Create an assembly in a temp directory + const assembly = await TestJsiiModule.fromSource( + { + 'index.ts': ` + export class ClassA { + public someMethod() { + } + } + export class ClassB { + public anotherMethod() { + } + } + `, + }, + { + name: 'my_assembly', + jsii: DUMMY_JSII_CONFIG, + }, + ); + try { + const ts = assembly.translateHere( + ["import * as masm from 'my_assembly';", 'declare const classA: masm.ClassA;'].join('\n'), + ); + + expect(ts.get(TargetLanguage.PYTHON)?.source).toEqual( + ['import example_test_demo as masm', '# class_a: masm.ClassA'].join('\n'), + ); + expect(ts.get(TargetLanguage.JAVA)?.source).toEqual(['import example.test.demo.*;', 'ClassA classA;'].join('\n')); + expect(ts.get(TargetLanguage.CSHARP)?.source).toEqual(['using Example.Test.Demo;', 'ClassA classA;'].join('\n')); + } finally { + await assembly.cleanup(); + } +}); diff --git a/packages/jsii-rosetta/test/translations/expressions/array_index.py b/packages/jsii-rosetta/test/translations/expressions/array_index.py index 1ba41427e4..c43ece9149 100644 --- a/packages/jsii-rosetta/test/translations/expressions/array_index.py +++ b/packages/jsii-rosetta/test/translations/expressions/array_index.py @@ -1,3 +1,3 @@ -# array is of type list of string +# array: List[str] print(array[3]) \ No newline at end of file diff --git a/packages/jsii-rosetta/test/translations/statements/declare_var.py b/packages/jsii-rosetta/test/translations/statements/declare_var.py index c393f76c28..d811f974ae 100644 --- a/packages/jsii-rosetta/test/translations/statements/declare_var.py +++ b/packages/jsii-rosetta/test/translations/statements/declare_var.py @@ -1 +1 @@ -# variable is of type Type \ No newline at end of file +# variable: Type \ No newline at end of file From 4eb182f8a95a03f23e0d9f20d3e8175709e45b68 Mon Sep 17 00:00:00 2001 From: AWS CDK Team Date: Thu, 6 Jan 2022 10:28:14 +0000 Subject: [PATCH 14/14] chore(release): 1.51.0 --- CHANGELOG.md | 13 +++++++++++++ lerna.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a89374e2c0..9928613b39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.51.0](https://github.com/aws/jsii/compare/v1.50.0...v1.51.0) (2022-01-06) + + +### Features + +* **pacmak:** go yaml struct tags ([#3299](https://github.com/aws/jsii/issues/3299)) ([63132cf](https://github.com/aws/jsii/commit/63132cf30ad62ba59d2a8cdfaba60b92819352cd)), closes [#3293](https://github.com/aws/jsii/issues/3293) + + +### Bug Fixes + +* **jsii:** cannot use submodule types from assemblies before 1.39.0 ([#3306](https://github.com/aws/jsii/issues/3306)) ([949d5f0](https://github.com/aws/jsii/commit/949d5f00df6a44c4fbacc06dc9f4f239c68c583e)), closes [#3233](https://github.com/aws/jsii/issues/3233) +* **rosetta:** Python translation for `implements` is wrong ([#3280](https://github.com/aws/jsii/issues/3280)) ([a833a1d](https://github.com/aws/jsii/commit/a833a1d2f1335e9447fd5702b9e4f9c6166abe67)), closes [aws/aws-cdk#17928](https://github.com/aws/aws-cdk/issues/17928) + ## [1.50.0](https://github.com/aws/jsii/compare/v1.49.0...v1.50.0) (2021-12-24) diff --git a/lerna.json b/lerna.json index 50956726e7..599048707e 100644 --- a/lerna.json +++ b/lerna.json @@ -10,5 +10,5 @@ "rejectCycles": true } }, - "version": "1.50.0" + "version": "1.51.0" }