From f614666158cafa49814b906a025cb5a19ae7612d Mon Sep 17 00:00:00 2001 From: AWS CDK Automation <43080478+aws-cdk-automation@users.noreply.github.com> Date: Tue, 19 Apr 2022 10:32:55 -0700 Subject: [PATCH] chore(release): 1.57.0 (#3492) See [CHANGELOG](https://github.com/aws/jsii/blob/bump/1.57.0/CHANGELOG.md) --- .github/workflows/close-stale-issues.yml | 2 +- .github/workflows/gh-pages.yml | 4 +- .github/workflows/main.yml | 18 ++++----- .github/workflows/yarn-upgrade.yml | 4 +- CHANGELOG.md | 9 +++++ gh-pages/requirements-dev.txt | 2 +- lerna.json | 2 +- .../internal/kernel/conversions.go | 7 +++- packages/jsii-pacmak/lib/targets/python.ts | 37 ++++++++++++++++++- .../__snapshots__/target-python.test.ts.snap | 17 +++++++++ packages/jsii/bin/jsii.ts | 9 +++-- packages/jsii/lib/compiler.ts | 12 +++--- packages/jsii/test/compiler.test.ts | 2 +- 13 files changed, 98 insertions(+), 27 deletions(-) diff --git a/.github/workflows/close-stale-issues.yml b/.github/workflows/close-stale-issues.yml index 5cdde46223..39a64b9f83 100644 --- a/.github/workflows/close-stale-issues.yml +++ b/.github/workflows/close-stale-issues.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest name: Stale issue job steps: - - uses: aws-actions/stale-issue-cleanup@v4 + - uses: aws-actions/stale-issue-cleanup@v5 with: # Setting messages to an empty string will cause the automation to skip # that category diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 3f6766ea5a..bb2a9b7e40 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -44,7 +44,7 @@ jobs: --site-dir ${{ runner.temp }}/site working-directory: gh-pages - name: Upload Artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: doc-site path: ${{ runner.temp }}/site/ @@ -63,7 +63,7 @@ jobs: ref: gh-pages token: ${{ secrets.PROJEN_GITHUB_TOKEN }} - name: Download Artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: doc-site path: ${{ runner.temp }}/site diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f2b2f0b8f..ff96c368e4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,11 +32,11 @@ jobs: with: dotnet-version: '5.0.x' - name: Set up Go 1.16 - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: '1.16' - name: Set up Java 8 - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: java-version: '8' distribution: 'zulu' @@ -93,7 +93,7 @@ jobs: . # Upload artifact (we'll tar it up to save time) - name: 'Upload Artifact: built-tree' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: built-tree path: ${{ runner.temp }}/built-tree.tgz @@ -126,11 +126,11 @@ jobs: with: dotnet-version: '5.0.x' - name: Set up Go 1.16 - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: '1.16' - name: Set up Java 8 - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: java-version: '8' distribution: 'zulu' @@ -198,7 +198,7 @@ jobs: yarn package # Upload artifacts - name: 'Upload Artifact: release-package' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: release-package path: ${{ github.workspace }}/dist/ @@ -277,7 +277,7 @@ jobs: steps: # Check out the code - name: Download Artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: built-tree - name: Extract Artifact @@ -294,11 +294,11 @@ jobs: dotnet-version: ${{ matrix.dotnet }} include-prerelease: ${{ matrix.dotnet-prerelease }} - name: Set up Go ${{ matrix.go }} - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: go-version: ${{ matrix.go }} - name: Set up Java ${{ matrix.java }} - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: java-version: ${{ matrix.java }} distribution: 'zulu' diff --git a/.github/workflows/yarn-upgrade.yml b/.github/workflows/yarn-upgrade.yml index cd433b58d0..b48d39225c 100644 --- a/.github/workflows/yarn-upgrade.yml +++ b/.github/workflows/yarn-upgrade.yml @@ -101,7 +101,7 @@ jobs: git add . git diff --patch --staged > ${{ runner.temp }}/upgrade.patch - name: Upload Patch - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: upgrade.patch path: ${{ runner.temp }}/upgrade.patch @@ -118,7 +118,7 @@ jobs: uses: actions/checkout@v3 - name: Download patch - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: upgrade.patch path: ${{ runner.temp }} diff --git a/CHANGELOG.md b/CHANGELOG.md index a04c2578b0..b6ffb5a852 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ 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.57.0](https://github.com/aws/jsii/compare/v1.56.0...v1.57.0) (2022-04-19) + + +### Bug Fixes + +* **go:** object type not recognized ([#3485](https://github.com/aws/jsii/issues/3485)) ([fe2fa94](https://github.com/aws/jsii/commit/fe2fa947891ab5d517efbec37998b9b57203aa8d)), closes [#2880](https://github.com/aws/jsii/issues/2880) +* **jsii:** some submodules are not exported from `aws-cdk-lib` ([#3491](https://github.com/aws/jsii/issues/3491)) ([47f70a2](https://github.com/aws/jsii/commit/47f70a26383f401a8b3df700787d6ce7934f66f9)) +* make jsii --watch work ([#3487](https://github.com/aws/jsii/issues/3487)) ([4a46f7d](https://github.com/aws/jsii/commit/4a46f7d7db3e6f9f1cf2730b02f4af0c1da9f237)), closes [#3467](https://github.com/aws/jsii/issues/3467) + ## [1.56.0](https://github.com/aws/jsii/compare/v1.55.1...v1.56.0) (2022-04-08) diff --git a/gh-pages/requirements-dev.txt b/gh-pages/requirements-dev.txt index 2ba97549c5..cb825a4a84 100644 --- a/gh-pages/requirements-dev.txt +++ b/gh-pages/requirements-dev.txt @@ -1,4 +1,4 @@ mkdocs~=1.3.0 mkdocs-awesome-pages-plugin~=2.7.0 -mkdocs-material~=8.2.8 +mkdocs-material~=8.2.9 mkdocs-git-revision-date-plugin~=0.3.2 diff --git a/lerna.json b/lerna.json index 4083613ea3..55fef948ea 100644 --- a/lerna.json +++ b/lerna.json @@ -10,5 +10,5 @@ "rejectCycles": true } }, - "version": "1.56.0" + "version": "1.57.0" } diff --git a/packages/@jsii/go-runtime/jsii-runtime-go/internal/kernel/conversions.go b/packages/@jsii/go-runtime/jsii-runtime-go/internal/kernel/conversions.go index 2897f89efa..aa3eae82e5 100644 --- a/packages/@jsii/go-runtime/jsii-runtime-go/internal/kernel/conversions.go +++ b/packages/@jsii/go-runtime/jsii-runtime-go/internal/kernel/conversions.go @@ -65,7 +65,7 @@ func (c *Client) castAndSetToPtr(ptr reflect.Value, data reflect.Value) { targetType := ptr.Type() if typ, ok := c.Types().FindType(ref.TypeFQN()); ok && typ.AssignableTo(ptr.Type()) { - // Specialize the return type to be the dynamic value type + // Specialize the return type to be the dynamic value type targetType = typ } @@ -191,6 +191,11 @@ func (c *Client) CastPtrToRef(dataVal reflect.Value) interface{} { }, } } + } else if dataVal.Elem().Kind() == reflect.Ptr { + // Typically happens when a struct pointer is passed into an interface{} + // typed API (such as a place where a union is accepted). + elemVal := dataVal.Elem() + return c.CastPtrToRef(elemVal) } if ref, err := c.ManageObject(dataVal); err != nil { diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index 6410ad8ed1..97413da2ee 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -1637,7 +1637,21 @@ class PythonModule implements PythonType { } // Whatever names we've exported, we'll write out our __all__ that lists them. - const exportedMembers = this.members.map((m) => `"${m.pythonName}"`); + // + // __all__ is normally used for when users write `from library import *`, but we also + // use it with the `publication` module to hide everything that's NOT in the list. + // + // Normally adding submodules to `__all__` has the (negative?) side-effect + // that all submodules get loaded when the user does `import *`, but we + // already load submodules anyway so it doesn't make a difference, and in combination + // with the `publication` module NOT having them in this list hides any submodules + // we import as part of typechecking. + const exportedMembers = [ + ...this.members.map((m) => `"${m.pythonName}"`), + ...this.modules + .filter((m) => this.isDirectChild(m)) + .map((m) => `"${lastComponent(m.pythonName)}"`), + ]; if (this.loadAssembly) { exportedMembers.push('"__jsii_assembly__"'); } @@ -1747,6 +1761,19 @@ class PythonModule implements PythonType { return scripts; } + private isDirectChild(pyMod: PythonModule) { + if ( + this.pythonName === pyMod.pythonName || + !pyMod.pythonName.startsWith(`${this.pythonName}.`) + ) { + return false; + } + // Must include only one more component + return !pyMod.pythonName + .substring(this.pythonName.length + 1) + .includes('.'); + } + /** * Emit the README as module docstring if this is the entry point module (it loads the assembly) */ @@ -3114,3 +3141,11 @@ function nestedContext( } const isDeprecated = (x: PythonBase) => x.docs?.deprecated !== undefined; + +/** + * Last component of a .-separated name + */ +function lastComponent(n: string) { + const parts = n.split('.'); + return parts[parts.length - 1]; +} 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 40cb873524..355489723e 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 @@ -1825,6 +1825,7 @@ __all__ = [ "NumericValue", "Operation", "StructWithOnlyOptionals", + "custom_submodule_name", ] publication.publish() @@ -10251,6 +10252,22 @@ __all__ = [ "VirtualMethodPlayground", "VoidCallback", "WithPrivatePropertyInConstructor", + "cdk16625", + "composition", + "derived_class_has_no_properties", + "interface_in_namespace_includes_classes", + "interface_in_namespace_only_interface", + "module2530", + "module2617", + "module2647", + "module2689", + "module2692", + "module2700", + "module2702", + "nodirect", + "onlystatic", + "python_self", + "submodule", ] publication.publish() diff --git a/packages/jsii/bin/jsii.ts b/packages/jsii/bin/jsii.ts index 9e2a2845e9..a202c4054c 100644 --- a/packages/jsii/bin/jsii.ts +++ b/packages/jsii/bin/jsii.ts @@ -14,7 +14,7 @@ import { enabledWarnings } from '../lib/warnings'; const warningTypes = Object.keys(enabledWarnings); -(() => { +(async () => { const argv = yargs .env('JSII') .command( @@ -117,7 +117,7 @@ const warningTypes = Object.keys(enabledWarnings); generateTypeScriptConfig: argv['generate-tsconfig'], }); - const emitResult = argv.watch ? compiler.watch() : compiler.emit(); + const emitResult = argv.watch ? await compiler.watch() : compiler.emit(); const allDiagnostics = [...projectInfoDiagnostics, ...emitResult.diagnostics]; @@ -127,7 +127,10 @@ const warningTypes = Object.keys(enabledWarnings); if (emitResult.emitSkipped) { process.exitCode = 1; } -})(); +})().catch((e) => { + console.error(`Error: ${e.stack}`); + process.exitCode = -1; +}); function _configureLog4js(verbosity: number) { const stderrColor = !!process.stderr.isTTY; diff --git a/packages/jsii/lib/compiler.ts b/packages/jsii/lib/compiler.ts index bbc43ea227..8cf437e041 100644 --- a/packages/jsii/lib/compiler.ts +++ b/packages/jsii/lib/compiler.ts @@ -118,15 +118,17 @@ export class Compiler implements Emitter { * * @internal */ - public watch(opts: NonBlockingWatchOptions): ts.Watch; + public async watch( + opts: NonBlockingWatchOptions, + ): Promise>; /** * Watches for file-system changes and dynamically recompiles the project as needed. In blocking mode, this results * in a never-resolving promise. */ - public watch(): never; - public watch( + public async watch(): Promise; + public async watch( opts?: NonBlockingWatchOptions, - ): ts.Watch | never { + ): Promise | never> { this._prepareForBuild(); const pi = this.options.projectInfo; @@ -184,7 +186,7 @@ export class Compiler implements Emitter { return watch; } // In blocking mode, returns a never-resolving promise. - return undefined as never; + return new Promise(() => null); } /** diff --git a/packages/jsii/test/compiler.test.ts b/packages/jsii/test/compiler.test.ts index 5335215da4..91bf44b98b 100644 --- a/packages/jsii/test/compiler.test.ts +++ b/packages/jsii/test/compiler.test.ts @@ -72,7 +72,7 @@ describe(Compiler, () => { onWatchClosed = ok; onWatchFailed = ko; }); - const watch = compiler.watch({ + const watch = await compiler.watch({ nonBlocking: true, // Ignore diagnostics reporting (not to pollute test console output) reportDiagnostics: () => null,