diff --git a/.all-contributorsrc b/.all-contributorsrc index ad598a8355..ae888416e5 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1339,6 +1339,33 @@ "contributions": [ "bug" ] + }, + { + "login": "wendysophie", + "name": "wendysophie", + "avatar_url": "https://avatars.githubusercontent.com/u/54415551?v=4", + "profile": "https://github.com/wendysophie", + "contributions": [ + "bug" + ] + }, + { + "login": "CommanderRoot", + "name": "CommanderRoot", + "avatar_url": "https://avatars.githubusercontent.com/u/4395417?v=4", + "profile": "https://github.com/CommanderRoot", + "contributions": [ + "code" + ] + }, + { + "login": "cgarvis", + "name": "Chris Garvis", + "avatar_url": "https://avatars.githubusercontent.com/u/213125?v=4", + "profile": "https://github.com/cgarvis", + "contributions": [ + "doc" + ] } ], "repoType": "github", diff --git a/.github/ISSUE_TEMPLATE/1-bug.md b/.github/ISSUE_TEMPLATE/1-bug.md deleted file mode 100644 index 0ee6e7806e..0000000000 --- a/.github/ISSUE_TEMPLATE/1-bug.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -name: "\U0001F41B Bug Report" -about: Report a bug -labels: bug, needs-triage ---- - -## :bug: Bug Report - -### Affected Languages - -- [ ] `TypeScript` or `Javascript` -- [ ] `Python` -- [ ] `Java` -- [ ] .NET (`C#`, `F#`, ...) -- [ ] `Go` - -### General Information -* **JSII Version:** -* **Platform:** - -### What is the problem? - - -### Verbose Log - diff --git a/.github/ISSUE_TEMPLATE/2-feature-request.md b/.github/ISSUE_TEMPLATE/2-feature-request.md deleted file mode 100644 index b1b1221ea7..0000000000 --- a/.github/ISSUE_TEMPLATE/2-feature-request.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -name: "\U0001F680 Feature Request" -about: Request a new feature -labels: feature-request, needs-triage ---- - -## :rocket: Feature Request - -### Affected Languages - -- [ ] `TypeScript` or `Javascript` -- [ ] `Python` -- [ ] `Java` -- [ ] .NET (`C#`, `F#`, ...) -- [ ] `Go` - -### General Information -* **JSII Version:** -* **Platform:** - -* [ ] I may be able to implement this feature request - -* [ ] This feature might incur a breaking change - -### Description - - -### Proposed Solution - diff --git a/.github/ISSUE_TEMPLATE/3-guidance.md b/.github/ISSUE_TEMPLATE/3-guidance.md deleted file mode 100644 index 263485b119..0000000000 --- a/.github/ISSUE_TEMPLATE/3-guidance.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -name: "\U00002753 Guidance" -about: Ask a general guidance -labels: guidance, needs-triage ---- - -## :question: Guidance - - - -### Affected Languages - -- [ ] `TypeScript` or `Javascript` -- [ ] `Python` -- [ ] `Java` -- [ ] .NET (`C#`, `F#`, ...) -- [ ] `Go` - -### General Information -* **JSII Version:** -* **Platform:** - -### The Question - diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 0000000000..7dbaee37a3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,73 @@ +--- +name: "πŸ› Bug Report" +description: Report a bug +title: "(short issue description)" +labels: [bug, needs-triage] +assignees: [] +body: + - type: textarea + id: description + attributes: + label: Describe the bug + description: What is the problem? A clear and concise description of the bug. + validations: + required: true + - type: textarea + id: expected + attributes: + label: Expected Behavior + description: | + What did you expect to happen? + validations: + required: true + - type: textarea + id: current + attributes: + label: Current Behavior + description: | + What actually happened? + + Please include full errors, uncaught exceptions, stack traces, and relevant logs. + If service responses are relevant, please include wire logs. + validations: + required: true + - type: textarea + id: reproduction + attributes: + label: Reproduction Steps + description: | + Provide a self-contained, concise snippet of code that can be used to reproduce the issue. + For more complex issues provide a repo with the smallest sample that reproduces the bug. + + Avoid including business logic or unrelated code, it makes diagnosis more difficult. + The code sample should be an SSCCE. See http://sscce.org/ for details. In short, please provide a code sample that we can copy/paste, run and reproduce. + validations: + required: true + - type: textarea + id: solution + attributes: + label: Possible Solution + description: | + Suggest a fix/reason for the bug + validations: + required: false + - type: textarea + id: context + attributes: + label: Additional Information/Context + description: | + Anything else that might be relevant for troubleshooting this bug. Providing context helps us come up with a solution that is most useful in the real world. + validations: + required: false + - type: input + id: sdk-version + attributes: + label: SDK version used + validations: + required: true + - type: input + id: environment + attributes: + label: Environment details (OS name and version, etc.) + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000000..3811bfb3f1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,6 @@ +--- +blank_issues_enabled: false +contact_links: + - name: πŸ’¬ General Question + url: https://github.com/aws/jsii/discussions/categories/q-a + about: Please ask and answer questions as a discussion thread \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/documentation.yml b/.github/ISSUE_TEMPLATE/documentation.yml new file mode 100644 index 0000000000..c068514d13 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation.yml @@ -0,0 +1,23 @@ +--- +name: "πŸ“• Documentation Issue" +description: Report an issue in the API Reference documentation or Developer Guide +title: "(short issue description)" +labels: [documentation, needs-triage] +assignees: [] +body: + - type: textarea + id: description + attributes: + label: Describe the issue + description: A clear and concise description of the issue. + validations: + required: true + + - type: textarea + id: links + attributes: + label: Links + description: | + Include links to affected documentation page(s). + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml new file mode 100644 index 0000000000..23c385d1ef --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -0,0 +1,59 @@ +--- +name: πŸš€ Feature Request +description: Suggest an idea for this project +title: "(short issue description)" +labels: [feature-request, needs-triage] +assignees: [] +body: + - type: textarea + id: description + attributes: + label: Describe the feature + description: A clear and concise description of the feature you are proposing. + validations: + required: true + - type: textarea + id: use-case + attributes: + label: Use Case + description: | + Why do you need this feature? For example: "I'm always frustrated when..." + validations: + required: true + - type: textarea + id: solution + attributes: + label: Proposed Solution + description: | + Suggest how to implement the addition or change. Please include prototype/workaround/sketch/reference implementation. + validations: + required: false + - type: textarea + id: other + attributes: + label: Other Information + description: | + Any alternative solutions or features you considered, a more detailed explanation, stack traces, related issues, links for context, etc. + validations: + required: false + - type: checkboxes + id: ack + attributes: + label: Acknowledgements + options: + - label: I may be able to implement this feature request + required: false + - label: This feature might incur a breaking change + required: false + - type: input + id: sdk-version + attributes: + label: CDK version used + validations: + required: true + - type: input + id: environment + attributes: + label: Environment details (OS name and version, etc.) + validations: + required: true diff --git a/.github/workflows/docker-images.yml b/.github/workflows/docker-images.yml index 8db02b4518..666c2fc284 100644 --- a/.github/workflows/docker-images.yml +++ b/.github/workflows/docker-images.yml @@ -74,7 +74,7 @@ jobs: # We only restore GH cache if we are not going to publish the result (i.e: PR validation) - name: Set up layer cache if: steps.should-run.outputs.result == 'true' && github.event_name != 'push' - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ hashFiles('superchain/*') }}-${{ github.sha }} diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 8c71957679..3f6766ea5a 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -27,7 +27,7 @@ jobs: run: |- echo "::set-output name=pip-cache::$(python3 -m pip cache dir)" - name: Cache - uses: actions/cache@v2.1.6 + uses: actions/cache@v3 with: path: ${{ steps.cache-locations.outputs.pip-cache }} key: ${{ runner.os }}-${{ hashFiles('**/requirements-dev.txt') }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 401712ee0d..7f2b2f0b8f 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.1 + uses: actions/setup-node@v3 with: cache: yarn node-version: '12' @@ -61,7 +61,7 @@ jobs: echo "::set-output name=pip-cache::$(python3 -m pip cache dir)" - name: Cache - uses: actions/cache@v2.1.6 + uses: actions/cache@v3 with: path: |- ${{ steps.cache-locations.outputs.pip-cache }} @@ -135,7 +135,7 @@ jobs: java-version: '8' distribution: 'zulu' - name: Set up Node 12 - uses: actions/setup-node@v2.5.1 + uses: actions/setup-node@v3 with: cache: yarn node-version: '12' @@ -155,7 +155,7 @@ jobs: echo "::set-output name=pip-cache::$(python3 -m pip cache dir)" - name: Cache - uses: actions/cache@v2.1.6 + uses: actions/cache@v3 with: path: |- ${{ steps.cache-locations.outputs.pip-cache }} @@ -303,7 +303,7 @@ jobs: java-version: ${{ matrix.java }} distribution: 'zulu' - name: Set up Node ${{ matrix.node }} - uses: actions/setup-node@v2.5.1 + uses: actions/setup-node@v3 with: cache: yarn node-version: ${{ matrix.node }} @@ -324,7 +324,7 @@ jobs: echo "::set-output name=pip-cache::$(python3 -m pip cache dir)" - name: Cache - uses: actions/cache@v2.1.6 + uses: actions/cache@v3 with: path: |- ${{ steps.cache-locations.outputs.pip-cache }} diff --git a/.github/workflows/yarn-upgrade.yml b/.github/workflows/yarn-upgrade.yml index a011507f43..cd433b58d0 100644 --- a/.github/workflows/yarn-upgrade.yml +++ b/.github/workflows/yarn-upgrade.yml @@ -18,7 +18,7 @@ jobs: uses: actions/checkout@v3 - name: Set up Node - uses: actions/setup-node@v2.5.1 + uses: actions/setup-node@v3 with: cache: yarn node-version: 12 @@ -127,7 +127,7 @@ jobs: run: '[ -s ${{ runner.temp }}/upgrade.patch ] && git apply ${{ runner.temp }}/upgrade.patch || echo "Empty patch. Skipping."' - name: Make Pull Request - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v4 with: # Git commit details author: 'AWS CDK Automation ' diff --git a/.gitignore b/.gitignore index ff4e271d69..85bbd6119b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ dist/ *.tabl.json *.swp *.snk +build/ +coverage/ +jsii-outdir/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a810d20e0..a04c2578b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,22 @@ 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.56.0](https://github.com/aws/jsii/compare/v1.55.1...v1.56.0) (2022-04-08) + + +### Features + +* drop internal functions from Deprecation Error stack trace ([#3426](https://github.com/aws/jsii/issues/3426)) ([5b4b852](https://github.com/aws/jsii/commit/5b4b852c4550782d4f9777cbca7a65264bea49fe)) +* expose unknownSnippets config ([#3475](https://github.com/aws/jsii/issues/3475)) ([e9d99a0](https://github.com/aws/jsii/commit/e9d99a06b7b06da2e87d1bf4e2101a0ff5cf3dc9)) +* specify output directory for assemblies ([#3437](https://github.com/aws/jsii/issues/3437)) ([5419876](https://github.com/aws/jsii/commit/541987673dd015e0264cf299b51998923556eb8d)) +* Standardize issue template for discussions ([b191f60](https://github.com/aws/jsii/commit/b191f60630d513449c6771de38d2d7fcbc8d7941)) + + +### Bug Fixes + +* **rosetta:** incorrect transliteration of map keys in python ([#3449](https://github.com/aws/jsii/issues/3449)) ([54cebaa](https://github.com/aws/jsii/commit/54cebaa188a132ab764e2167c9ec5f9042588b47)), closes [#3448](https://github.com/aws/jsii/issues/3448) [#3448](https://github.com/aws/jsii/issues/3448) +* typo "though" -> "through" ([#3419](https://github.com/aws/jsii/issues/3419)) ([3274b6c](https://github.com/aws/jsii/commit/3274b6cb8c5a025c8877343423c1f101029ea0a5)) + ## [1.55.1](https://github.com/aws/jsii/compare/v1.55.0...v1.55.1) (2022-03-16) ## [1.55.0](https://github.com/aws/jsii/compare/v1.54.0...v1.55.0) (2022-03-10) diff --git a/README.md b/README.md index 53df719a0c..f8dd3174f5 100644 --- a/README.md +++ b/README.md @@ -87,147 +87,150 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Camilo BermΓΊdez

πŸ›
Campion Fellin

πŸ’»
Carter Van Deuren

πŸ› +
Chris Garvis

πŸ“–
Christophe Vico

πŸ› -
Christopher Currie

πŸ’» πŸ€” +
Christopher Currie

πŸ’» πŸ€”
Christopher Rybicki

πŸ“– +
CommanderRoot

πŸ’»
Cory Hall

πŸ›
Cristian Măgherușan-Stanciu

πŸ›
CyrusNajmabadi

πŸ› πŸ€”
Damian Silbergleith

πŸ’» πŸ› -
Daniel Dinu

πŸ› πŸ’» -
Daniel Schroeder

πŸ› πŸ’» πŸ“– πŸ€” 🚧 +
Daniel Dinu

πŸ› πŸ’» +
Daniel Schroeder

πŸ› πŸ’» πŸ“– πŸ€” 🚧
Dave Slotnick

πŸ›
Donald Stufft

πŸ› πŸ’» πŸ€” πŸ‘€
Dongie Agnir

πŸ’» πŸ‘€
Eduardo Rabelo

πŸ“–
Eduardo Sena S. Rosa

πŸ› -
Elad Ben-Israel

πŸ› πŸ’» πŸ€” 🚧 πŸ‘€ πŸ“’ -
Eli Polonsky

πŸ› πŸ’» πŸ€” 🚧 πŸ‘€ +
Elad Ben-Israel

πŸ› πŸ’» πŸ€” 🚧 πŸ‘€ πŸ“’ +
Eli Polonsky

πŸ› πŸ’» πŸ€” 🚧 πŸ‘€
Eric Z. Beard

πŸ“†
Erik Karlsson

πŸ›
Eugene Kozlov

πŸ’»
Fabio Gentile

πŸ›
Florian Eitel

πŸ€” -
Graham Lea

πŸ€” πŸ‘€ -
Hamza Assyad

πŸ› πŸ’» πŸ€” πŸ‘€ +
Graham Lea

πŸ€” πŸ‘€ +
Hamza Assyad

πŸ› πŸ’» πŸ€” πŸ‘€
Hari Pachuveetil

πŸ“ πŸ“–
Hsing-Hui Hsu

πŸ’» πŸ“– πŸ€” πŸ‘€
Ikko Ashimine

πŸ“–
James

πŸ› πŸ’»
James Kelley

πŸ› -
James Mead

πŸ’» -
James Siri

πŸ’» 🚧 +
James Mead

πŸ’» +
James Siri

πŸ’» 🚧
Jason Del Ponte

πŸ€” πŸ‘€
Jason Fulghum

πŸ€” πŸ“† πŸ‘€
Jerry Kindall

πŸ“– πŸ€”
Jimmy Gaussen

πŸ€”
Johannes Weber

πŸ“– -
Jon Steinich

πŸ› πŸ€” πŸ’» -
Joseph Lawson

πŸ‘€ +
Jon Steinich

πŸ› πŸ€” πŸ’» +
Joseph Lawson

πŸ‘€
Joseph Martin

πŸ›
Junix

πŸ›
Justin Taylor

πŸ›
Kaizen Conroy

πŸ’» πŸ›
Kaushik Borra

πŸ› -
Kyle Thomson

πŸ’» πŸ‘€ -
Leandro Padua

πŸ› +
Kyle Thomson

πŸ’» πŸ‘€ +
Leandro Padua

πŸ›
Liang Zhou

πŸ› πŸ’»
Madeline Kusters

πŸ’» πŸ›
Maja S Bratseth

πŸ›
Marcos Diez

πŸ›
Mark Nielsen

πŸ’» -
Matthew Bonig

πŸ› πŸ“ -
Matthew Pirocchi

πŸ’» πŸ€” πŸ‘€ +
Matthew Bonig

πŸ› πŸ“ +
Matthew Pirocchi

πŸ’» πŸ€” πŸ‘€
Meng Xin Zhu

πŸ›
Michael Neil

🚧
Mike Lane

πŸ›
Mitch Garnaat

πŸ› πŸ’» πŸ€” πŸ‘€
Mitchell Valine

πŸ› πŸ’» πŸ€” 🚧 πŸ‘€ -
Mohamad Soufan

πŸ“– -
Mykola Mogylenko

πŸ› +
Mohamad Soufan

πŸ“– +
Mykola Mogylenko

πŸ›
Neta Nir

πŸ’» πŸ€” 🚧 πŸ‘€
Nick Lynch

πŸ› πŸ’» 🚧 πŸ‘€
Niranjan Jayakar

πŸ› πŸ’» πŸ€” 🚧 πŸ‘€
Noah Litov

πŸ’» 🚧 πŸ‘€
Otavio Macedo

πŸ’» πŸ› -
PIDZ - Bart

πŸ€” -
Peter Woodworth

🚧 +
PIDZ - Bart

πŸ€” +
Peter Woodworth

🚧
Petr Kacer

πŸ›
Petra Barus

πŸ’»
Philip Cali

πŸ€”
Quentin Loos

πŸ€”
Raphael

πŸ› -
Richard H Boyd

πŸ› -
Rico Huijbers

πŸ› πŸ’» πŸ€” 🚧 πŸ‘€ +
Richard H Boyd

πŸ› +
Rico Huijbers

πŸ› πŸ’» πŸ€” 🚧 πŸ‘€
Romain Marcadier

πŸ› πŸ’» 🎨 πŸ€” 🚧 πŸ‘€ πŸ“
SADIK KUZU

πŸ‘€
SK

πŸ€”
Sam Fink

πŸ’» πŸ‘€
Sam Goodwin

πŸ‘€ -
Sebastian Korfmann

πŸ› πŸ’» πŸ€” -
Shane Witbeck

πŸ€” +
Sebastian Korfmann

πŸ› πŸ’» πŸ€” +
Shane Witbeck

πŸ€”
Shiv Lakshminarayan

πŸ’» 🚧 πŸ‘€
Somaya

πŸ’» πŸ€” 🚧 πŸ‘€
The Gitter Badger

πŸ’» 🚧
Thomas Poignant

πŸ›
Thomas Steinbach

πŸ› -
Thorsten Hoeger

πŸ’» -
Tim Wagner

πŸ› πŸ€” +
Thorsten Hoeger

πŸ’» +
Tim Wagner

πŸ› πŸ€”
Tobias Lidskog

πŸ’»
Ty Coghlan

πŸ›
Tyler van Hensbergen

πŸ€”
Vlad Hrybok

πŸ›
Vladimir Shchur

πŸ› -
Yan Zhulanow

πŸ’» -
Yigong Liu

πŸ› πŸ€” +
Yan Zhulanow

πŸ’» +
Yigong Liu

πŸ› πŸ€”
Zach Bienenfeld

πŸ›
ajnarang

πŸ€”
aniljava

πŸ’»
arnogeurts-sqills

πŸ› πŸ’»
deccy-mcc

πŸ› -
dependabot-preview[bot]

πŸ› 🚧 -
dependabot[bot]

🚧 +
dependabot-preview[bot]

πŸ› 🚧 +
dependabot[bot]

🚧
dheffx

πŸ›
gregswdl

πŸ›
guyroberts21

πŸ“–
mattBrzezinski

πŸ“–
mergify

🚧 -
mergify[bot]

🚧 -
seiyashima42

πŸ› πŸ’» πŸ“– +
mergify[bot]

🚧 +
seiyashima42

πŸ› πŸ’» πŸ“–
sullis

πŸ’»
vaneek

πŸ› +
wendysophie

πŸ› diff --git a/eslint-config.yaml b/eslint-config.yaml index 8c6c72d389..da28a00ad4 100644 --- a/eslint-config.yaml +++ b/eslint-config.yaml @@ -205,6 +205,7 @@ rules: 'no-restricted-properties': - error + - { property: "substr", message: "Use .slice instead of .substr." } 'no-return-await': - error diff --git a/gh-pages/content/index.md b/gh-pages/content/index.md index fddae9b4f7..1820862bba 100644 --- a/gh-pages/content/index.md +++ b/gh-pages/content/index.md @@ -93,8 +93,8 @@ header bar: - The [Language Implementation](user-guides/language-support) is intended for developers who are looking to add support for a new *target language* in *jsii*. -- The [Specification](specification) provides detailed information on the internal components of *jsii*. -- The [Architecture Decision Records](adrs) contains the log of all architectural decisions made while developing the +- The [Specification](specification/1-introduction) provides detailed information on the internal components of *jsii*. +- The [Architecture Decision Records](decisions/introduction) contains the log of all architectural decisions made while developing the *jsii* project. ## How to contribute diff --git a/gh-pages/content/overview/runtime-architecture.md b/gh-pages/content/overview/runtime-architecture.md index 291eeffdab..b625de6dc2 100644 --- a/gh-pages/content/overview/runtime-architecture.md +++ b/gh-pages/content/overview/runtime-architecture.md @@ -101,7 +101,7 @@ describing the process arrangement that achieves this: !!! bug "Missing Feature" As shown on the diagram above, there is nothing connected to the *Core* process' `FD#0` (`STDIN`). This feature will be added in the future, but - currently this means *jsii* libraries have no way of accepting input though + currently this means *jsii* libraries have no way of accepting input through `STDIN`. The *Wrapper* process manages the *Core* process such that: diff --git a/gh-pages/requirements-dev.txt b/gh-pages/requirements-dev.txt index 94f4a72d40..2ba97549c5 100644 --- a/gh-pages/requirements-dev.txt +++ b/gh-pages/requirements-dev.txt @@ -1,4 +1,4 @@ -mkdocs~=1.2.3 +mkdocs~=1.3.0 mkdocs-awesome-pages-plugin~=2.7.0 -mkdocs-material~=8.2.5 -mkdocs-git-revision-date-plugin~=0.3.1 +mkdocs-material~=8.2.8 +mkdocs-git-revision-date-plugin~=0.3.2 diff --git a/lerna.json b/lerna.json index a31db48016..4083613ea3 100644 --- a/lerna.json +++ b/lerna.json @@ -10,5 +10,5 @@ "rejectCycles": true } }, - "version": "1.55.1" + "version": "1.56.0" } diff --git a/package.json b/package.json index 23f975d850..5ac28efed4 100644 --- a/package.json +++ b/package.json @@ -16,21 +16,21 @@ }, "devDependencies": { "@jest/types": "^27.5.1", - "@typescript-eslint/eslint-plugin": "^5.14.0", - "@typescript-eslint/parser": "^5.14.0", + "@typescript-eslint/eslint-plugin": "^5.18.0", + "@typescript-eslint/parser": "^5.18.0", "all-contributors-cli": "^6.20.0", - "eslint": "^8.10.0", + "eslint": "^8.12.0", "eslint-config-prettier": "^8.5.0", "eslint-import-resolver-node": "^0.3.6", - "eslint-import-resolver-typescript": "^2.5.0", - "eslint-plugin-import": "^2.25.4", + "eslint-import-resolver-typescript": "^2.7.1", + "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^4.0.0", "jest-circus": "^27.5.1", "jest-config": "^27.5.1", "lerna": "^4.0.0", - "prettier": "^2.5.1", + "prettier": "^2.6.2", "standard-version": "^9.3.2", - "ts-jest": "^27.1.3", + "ts-jest": "^27.1.4", "ts-node": "^10.7.0", "typescript": "~3.9.10" }, diff --git a/packages/@jsii/go-runtime-test/project/go.mod b/packages/@jsii/go-runtime-test/project/go.mod index 739b059c53..0164d9ba43 100644 --- a/packages/@jsii/go-runtime-test/project/go.mod +++ b/packages/@jsii/go-runtime-test/project/go.mod @@ -7,7 +7,7 @@ require ( github.com/aws/jsii/jsii-calc/go/jcb v0.0.0 github.com/aws/jsii/jsii-calc/go/jsiicalc/v3 v3.20.120 github.com/aws/jsii/jsii-calc/go/scopejsiicalclib v0.0.0 - github.com/stretchr/testify v1.7.0 + github.com/stretchr/testify v1.7.1 golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 golang.org/x/tools v0.1.0 ) diff --git a/packages/@jsii/go-runtime-test/project/go.sum b/packages/@jsii/go-runtime-test/project/go.sum index 57ec351287..485cdc2311 100644 --- a/packages/@jsii/go-runtime-test/project/go.sum +++ b/packages/@jsii/go-runtime-test/project/go.sum @@ -6,8 +6,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= diff --git a/packages/@jsii/go-runtime/go.mod b/packages/@jsii/go-runtime/go.mod index 5099e3a5fb..2280d4124c 100644 --- a/packages/@jsii/go-runtime/go.mod +++ b/packages/@jsii/go-runtime/go.mod @@ -4,5 +4,5 @@ go 1.16 require ( golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 - golang.org/x/tools v0.1.9 + golang.org/x/tools v0.1.10 ) diff --git a/packages/@jsii/go-runtime/go.sum b/packages/@jsii/go-runtime/go.sum index b50c26931b..a0121607d0 100644 --- a/packages/@jsii/go-runtime/go.sum +++ b/packages/@jsii/go-runtime/go.sum @@ -2,13 +2,15 @@ github.com/yuin/goldmark v1.4.1 h1:/vn0k+RBvwlxEmP5E7SZMqNxPhfMVFEJiykr15/0XKM= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 h1:2M3HP5CCK1Si9FQhwnzYhXdG6DXeebvUHFpre8QvbyI= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= -golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -17,17 +19,19 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.1.9 h1:j9KsMiaP1c3B0OTQGth0/k+miLGTgLsAFUCrF2vLcF8= -golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= diff --git a/packages/@jsii/go-runtime/jsii-runtime-go/go.mod b/packages/@jsii/go-runtime/jsii-runtime-go/go.mod index e406443fa2..58dac68c48 100644 --- a/packages/@jsii/go-runtime/jsii-runtime-go/go.mod +++ b/packages/@jsii/go-runtime/jsii-runtime-go/go.mod @@ -4,7 +4,7 @@ go 1.16 require ( github.com/Masterminds/semver/v3 v3.1.1 - github.com/stretchr/testify v1.7.0 + github.com/stretchr/testify v1.7.1 ) require ( diff --git a/packages/@jsii/go-runtime/jsii-runtime-go/go.sum b/packages/@jsii/go-runtime/jsii-runtime-go/go.sum index 34dd278f55..a4aa7af91a 100644 --- a/packages/@jsii/go-runtime/jsii-runtime-go/go.sum +++ b/packages/@jsii/go-runtime/jsii-runtime-go/go.sum @@ -6,8 +6,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/packages/@jsii/go-runtime/package.json b/packages/@jsii/go-runtime/package.json index 8a01051a58..37b13f0eaa 100644 --- a/packages/@jsii/go-runtime/package.json +++ b/packages/@jsii/go-runtime/package.json @@ -26,11 +26,11 @@ "@types/fs-extra": "^9.0.13", "@types/node": "^12.20.47", "codemaker": "^0.0.0", - "eslint": "^8.10.0", + "eslint": "^8.12.0", "fs-extra": "^9.1.0", "jsii-build-tools": "^0.0.0", "jsii-calc": "^3.20.120", - "prettier": "^2.5.1", + "prettier": "^2.6.2", "ts-node": "^10.7.0", "typescript": "~3.9.10" } diff --git a/packages/@jsii/integ-test/package.json b/packages/@jsii/integ-test/package.json index b555a431f0..14b307216d 100644 --- a/packages/@jsii/integ-test/package.json +++ b/packages/@jsii/integ-test/package.json @@ -32,8 +32,8 @@ "@types/jest": "^27.4.1", "@types/node": "^12.20.47", "@types/tar": "^6.1.1", - "eslint": "^8.10.0", - "prettier": "^2.5.1", + "eslint": "^8.12.0", + "prettier": "^2.6.2", "typescript": "~3.9.10" } } diff --git a/packages/@jsii/kernel/lib/serialization.ts b/packages/@jsii/kernel/lib/serialization.ts index caec15fdc0..3b87bf2bc1 100644 --- a/packages/@jsii/kernel/lib/serialization.ts +++ b/packages/@jsii/kernel/lib/serialization.ts @@ -731,8 +731,8 @@ function deserializeEnum(value: WireEnum, lookup: SymbolLookup) { throw new Error(`Malformed enum value: ${JSON.stringify(value)}`); } - const typeName = enumLocator.substr(0, sep); - const valueName = enumLocator.substr(sep + 1); + const typeName = enumLocator.slice(0, sep); + const valueName = enumLocator.slice(sep + 1); const enumValue = lookup(typeName)[valueName]; if (enumValue === undefined) { diff --git a/packages/@jsii/kernel/package.json b/packages/@jsii/kernel/package.json index 47bb365016..cafd88ab1f 100644 --- a/packages/@jsii/kernel/package.json +++ b/packages/@jsii/kernel/package.json @@ -42,13 +42,13 @@ "@types/jest": "^27.4.1", "@types/node": "^12.20.47", "@types/tar": "^6.1.1", - "eslint": "^8.10.0", + "eslint": "^8.12.0", "jest": "^27.5.1", "jest-expect-message": "^1.0.2", "jsii-build-tools": "^0.0.0", "jsii-calc": "^3.20.120", - "prettier": "^2.5.1", - "ts-jest": "^27.1.3", + "prettier": "^2.6.2", + "ts-jest": "^27.1.4", "typescript": "~3.9.10" } } diff --git a/packages/@jsii/python-runtime/.gitignore b/packages/@jsii/python-runtime/.gitignore index 1580fafb23..619524466b 100644 --- a/packages/@jsii/python-runtime/.gitignore +++ b/packages/@jsii/python-runtime/.gitignore @@ -12,6 +12,7 @@ __pycache__ .mypy_cache .pytest_cache -build +# Occasionally left behind by pip, transient (safe to delete) +build/ README.md diff --git a/packages/@jsii/python-runtime/build-tools/deps.ts b/packages/@jsii/python-runtime/build-tools/deps.ts index 299093e5ca..8646a311f3 100644 --- a/packages/@jsii/python-runtime/build-tools/deps.ts +++ b/packages/@jsii/python-runtime/build-tools/deps.ts @@ -1,5 +1,6 @@ #!/usr/bin/env npx ts-node +import { removeSync } from 'fs-extra'; import { join, resolve } from 'path'; import { venv, runCommand } from './_constants'; @@ -18,3 +19,8 @@ runCommand( ['-m', 'pip', 'install', '-r', resolve(__dirname, '..', 'requirements.txt')], { env }, ); + +// Sometimes, pip leaves a `build` directory behind, which can mess with mypy +// when run with `pytest --mypy`. This directory should be transient and so we +// simply clean it up here. +removeSync(resolve(__dirname, '..', 'build')); diff --git a/packages/@jsii/python-runtime/pyproject.toml b/packages/@jsii/python-runtime/pyproject.toml index 5ebecdc3bb..12bd6ac191 100644 --- a/packages/@jsii/python-runtime/pyproject.toml +++ b/packages/@jsii/python-runtime/pyproject.toml @@ -1,12 +1,11 @@ [build-system] -requires = [ - "pip~=20.2", - "setuptools~=50.3", - "wheel~=0.35", -] +requires = ["pip~=20.2", "setuptools~=50.3", "wheel~=0.35"] build-backend = 'setuptools.build_meta' [tool.black] target-version = ['py36', 'py37', 'py38'] include = '\.pyi?$' exclude = '\.(git|mypy_cache|env)' + +[tool.mypy] +ignore_missing_imports = true diff --git a/packages/@jsii/python-runtime/requirements.txt b/packages/@jsii/python-runtime/requirements.txt index 23f655542c..19a7bcad39 100644 --- a/packages/@jsii/python-runtime/requirements.txt +++ b/packages/@jsii/python-runtime/requirements.txt @@ -1,8 +1,9 @@ -black~=22.1 +black~=22.3 mypy==0.812 pip~=21.3 ; python_version < '3.7' pip~=22.0 ; python_version >= '3.7' -pytest~=7.0 +pytest~=7.0 ; python_version < '3.7' +pytest~=7.1 ; python_version >= '3.7' pytest-mypy~=0.9 setuptools~=59.6 wheel~=0.37 diff --git a/packages/@jsii/python-runtime/setup.py b/packages/@jsii/python-runtime/setup.py index 440c5e9305..e61844806e 100644 --- a/packages/@jsii/python-runtime/setup.py +++ b/packages/@jsii/python-runtime/setup.py @@ -32,7 +32,7 @@ install_requires=[ "attrs~=21.2", "cattrs~=1.0.0 ; python_version < '3.7'", - "cattrs>=1.8,<1.11 ; python_version >= '3.7'", + "cattrs>=1.8,<22.2 ; python_version >= '3.7'", "importlib_resources ; python_version < '3.7'", "python-dateutil", "typing_extensions>=3.7,<5.0", diff --git a/packages/@jsii/runtime/lib/in-out.ts b/packages/@jsii/runtime/lib/in-out.ts index 41b4a9234d..b7a7e95635 100644 --- a/packages/@jsii/runtime/lib/in-out.ts +++ b/packages/@jsii/runtime/lib/in-out.ts @@ -61,7 +61,7 @@ export class InputOutput implements IInputOutput { // stip "> " from recorded requests if (reqLine.startsWith('> ')) { - reqLine = reqLine.substr(2); + reqLine = reqLine.slice(2); } const input = JSON.parse(reqLine); diff --git a/packages/@jsii/runtime/package.json b/packages/@jsii/runtime/package.json index ae49cbce3c..d62c8c4ac2 100644 --- a/packages/@jsii/runtime/package.json +++ b/packages/@jsii/runtime/package.json @@ -43,15 +43,15 @@ "@scope/jsii-calc-lib": "^0.0.0", "@types/jest": "^27.4.1", "@types/node": "^12.20.47", - "eslint": "^8.10.0", + "eslint": "^8.12.0", "jest": "^27.5.1", "jsii-build-tools": "^0.0.0", "jsii-calc": "^3.20.120", - "prettier": "^2.5.1", + "prettier": "^2.6.2", "source-map-loader": "^3.0.1", - "ts-jest": "^27.1.3", + "ts-jest": "^27.1.4", "typescript": "~3.9.10", - "webpack": "^5.70.0", + "webpack": "^5.71.0", "webpack-cli": "^4.9.2" } } diff --git a/packages/@jsii/spec/package.json b/packages/@jsii/spec/package.json index c9f85fe4d8..eade316882 100644 --- a/packages/@jsii/spec/package.json +++ b/packages/@jsii/spec/package.json @@ -36,10 +36,10 @@ "devDependencies": { "@types/jest": "^27.4.1", "@types/node": "^12.20.47", - "eslint": "^8.10.0", + "eslint": "^8.12.0", "jest": "^27.5.1", "jsii-build-tools": "^0.0.0", - "prettier": "^2.5.1", + "prettier": "^2.6.2", "typescript": "~3.9.10", "typescript-json-schema": "^0.53.0" } diff --git a/packages/@scope/jsii-calc-base-of-base/package.json b/packages/@scope/jsii-calc-base-of-base/package.json index 834abf6770..55627d2f54 100644 --- a/packages/@scope/jsii-calc-base-of-base/package.json +++ b/packages/@scope/jsii-calc-base-of-base/package.json @@ -34,7 +34,7 @@ "jsii": "^0.0.0", "jsii-build-tools": "^0.0.0", "jsii-rosetta": "^0.0.0", - "prettier": "^2.5.1" + "prettier": "^2.6.2" }, "jsii": { "outdir": "dist", diff --git a/packages/@scope/jsii-calc-base/package.json b/packages/@scope/jsii-calc-base/package.json index 31879c1c8d..9352f4435c 100644 --- a/packages/@scope/jsii-calc-base/package.json +++ b/packages/@scope/jsii-calc-base/package.json @@ -39,7 +39,7 @@ "jsii": "^0.0.0", "jsii-build-tools": "^0.0.0", "jsii-rosetta": "^0.0.0", - "prettier": "^2.5.1" + "prettier": "^2.6.2" }, "jsii": { "metadata": { diff --git a/packages/@scope/jsii-calc-lib/package.json b/packages/@scope/jsii-calc-lib/package.json index 0d4a0cab78..eb0f3a1a53 100644 --- a/packages/@scope/jsii-calc-lib/package.json +++ b/packages/@scope/jsii-calc-lib/package.json @@ -43,7 +43,7 @@ "jsii": "^0.0.0", "jsii-build-tools": "^0.0.0", "jsii-rosetta": "^0.0.0", - "prettier": "^2.5.1" + "prettier": "^2.6.2" }, "jsii": { "outdir": "dist", diff --git a/packages/codemaker/lib/case-utils.ts b/packages/codemaker/lib/case-utils.ts index c382477c27..bd609e340a 100644 --- a/packages/codemaker/lib/case-utils.ts +++ b/packages/codemaker/lib/case-utils.ts @@ -26,7 +26,7 @@ export function toSnakeCase(s: string, separator = '_'): string { return decamelize(s, { separator }); function ucfirst(str: string) { - return str.substr(0, 1).toUpperCase() + str.substr(1).toLowerCase(); + return str.slice(0, 1).toUpperCase() + str.slice(1).toLowerCase(); } } diff --git a/packages/codemaker/package.json b/packages/codemaker/package.json index 5ef07c5976..49ba8c09f5 100644 --- a/packages/codemaker/package.json +++ b/packages/codemaker/package.json @@ -39,9 +39,9 @@ "@types/fs-extra": "^9.0.13", "@types/jest": "^27.4.1", "@types/node": "^12.20.47", - "eslint": "^8.10.0", + "eslint": "^8.12.0", "jest": "^27.5.1", - "prettier": "^2.5.1", + "prettier": "^2.6.2", "typescript": "~3.9.10" } } diff --git a/packages/jsii-calc/package.json b/packages/jsii-calc/package.json index ba0f6c6063..a3ddebb5d3 100644 --- a/packages/jsii-calc/package.json +++ b/packages/jsii-calc/package.json @@ -52,11 +52,11 @@ }, "devDependencies": { "@types/node": "^12.20.47", - "eslint": "^8.10.0", + "eslint": "^8.12.0", "jsii": "^0.0.0", "jsii-build-tools": "^0.0.0", "jsii-rosetta": "^0.0.0", - "prettier": "^2.5.1" + "prettier": "^2.6.2" }, "jsii": { "outdir": "dist", diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index fa9482fec6..dd1e6075af 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -1128,10 +1128,10 @@ "primitive": "number" }, { - "fqn": "jsii-calc.Multiply" + "fqn": "@scope/jsii-calc-lib.Number" }, { - "fqn": "@scope/jsii-calc-lib.Number" + "fqn": "jsii-calc.Multiply" } ] } @@ -16931,5 +16931,5 @@ } }, "version": "3.20.120", - "fingerprint": "sqJBfFAp4Hg5OgntWB3IRyRS7mpPF7G3qoh4NYSDeSw=" + "fingerprint": "x8U5PHtkMg1Me8BU5rwy98qvqY6p+AhernFr4narjHc=" } diff --git a/packages/jsii-config/package.json b/packages/jsii-config/package.json index 0a8cf06bff..520bd55728 100644 --- a/packages/jsii-config/package.json +++ b/packages/jsii-config/package.json @@ -19,14 +19,14 @@ "jsii-config": "bin/jsii-config" }, "devDependencies": { - "@types/inquirer": "^8.2.0", + "@types/inquirer": "^8.2.1", "@types/jest": "^27.4.1", "@types/node": "^12.20.47", - "@types/yargs": "^17.0.9", - "eslint": "^8.10.0", + "@types/yargs": "^17.0.10", + "eslint": "^8.12.0", "jest": "^27.5.1", "jest-expect-message": "^1.0.2", - "prettier": "^2.5.1", + "prettier": "^2.6.2", "typescript": "~3.9.10" }, "dependencies": { diff --git a/packages/jsii-diff/package.json b/packages/jsii-diff/package.json index d054d558b3..16c68444a6 100644 --- a/packages/jsii-diff/package.json +++ b/packages/jsii-diff/package.json @@ -37,7 +37,7 @@ "@jsii/spec": "^0.0.0", "fs-extra": "^9.1.0", "jsii-reflect": "^0.0.0", - "log4js": "^6.4.2", + "log4js": "^6.4.4", "typescript": "~3.9.10", "yargs": "^16.2.0" }, @@ -46,11 +46,11 @@ "@types/jest": "^27.4.1", "@types/node": "^12.20.47", "@types/tar-fs": "^2.0.1", - "eslint": "^8.10.0", + "eslint": "^8.12.0", "jest": "^27.5.1", "jest-expect-message": "^1.0.2", "jsii": "^0.0.0", "jsii-build-tools": "^0.0.0", - "prettier": "^2.5.1" + "prettier": "^2.6.2" } } diff --git a/packages/jsii-diff/test/diagnostics.test.ts b/packages/jsii-diff/test/diagnostics.test.ts index 54c5c63495..1f65b14f08 100644 --- a/packages/jsii-diff/test/diagnostics.test.ts +++ b/packages/jsii-diff/test/diagnostics.test.ts @@ -2,8 +2,8 @@ import { classifyDiagnostics, hasErrors } from '../lib/diagnostics'; import { compare } from './util'; // ---------------------------------------------------------------------- -test('experimental elements lead to warnings', async () => { - const mms = await compare( +test('experimental elements lead to warnings', () => { + const mms = compare( ` /** @experimental */ export class Foo1 { } @@ -21,8 +21,8 @@ test('experimental elements lead to warnings', async () => { }); // ---------------------------------------------------------------------- -test('external stability violations are reported as warnings', async () => { - const mms = await compare( +test('external stability violations are reported as warnings', () => { + const mms = compare( ` /** @stability external */ export class Foo1 { } @@ -40,8 +40,8 @@ test('external stability violations are reported as warnings', async () => { }); // ---------------------------------------------------------------------- -test('warnings can be turned into errors', async () => { - const mms = await compare( +test('warnings can be turned into errors', () => { + const mms = compare( ` /** @experimental */ export class Foo1 { } @@ -59,8 +59,8 @@ test('warnings can be turned into errors', async () => { }); // ---------------------------------------------------------------------- -test('external stability violations are never turned into errors', async () => { - const mms = await compare( +test('external stability violations are never turned into errors', () => { + const mms = compare( ` /** @stability external */ export class Foo1 { } @@ -78,8 +78,8 @@ test('external stability violations are never turned into errors', async () => { }); // ---------------------------------------------------------------------- -test('errors can be skipped', async () => { - const mms = await compare( +test('errors can be skipped', () => { + const mms = compare( ` export class Foo1 { } `, @@ -100,8 +100,8 @@ test('errors can be skipped', async () => { }); // ---------------------------------------------------------------------- -test('changing stable to experimental is breaking', async () => { - const mms = await compare( +test('changing stable to experimental is breaking', () => { + const mms = compare( ` /** @stable */ export class Foo1 { } @@ -128,8 +128,8 @@ test('changing stable to experimental is breaking', async () => { // ---------------------------------------------------------------------- -test('can make fields optional in output struct if it is marked @external', async () => { - const mms = await compare( +test('can make fields optional in output struct if it is marked @external', () => { + const mms = compare( ` /** @stability external */ export interface TheStruct { diff --git a/packages/jsii-diff/test/util.ts b/packages/jsii-diff/test/util.ts index e9442683d1..19708aba42 100644 --- a/packages/jsii-diff/test/util.ts +++ b/packages/jsii-diff/test/util.ts @@ -4,25 +4,25 @@ import * as reflect from 'jsii-reflect'; import { compareAssemblies } from '../lib'; import { Mismatches } from '../lib/types'; -export async function expectNoError(original: string, updated: string) { - const mms = await compare(original, updated); +export function expectNoError(original: string, updated: string) { + const mms = compare(original, updated); for (const msg of mms.messages()) { console.error(`- ${msg}`); } expect(mms.count).toBe(0); } -export async function expectError( +export function expectError( error: RegExp | undefined, original: string, updated: string, ) { if (error == null) { - await expectNoError(original, updated); + expectNoError(original, updated); return; } - const mms = await compare(original, updated); + const mms = compare(original, updated); expect(mms.count).not.toBe(0); const msgs = Array.from(mms.messages()); @@ -32,23 +32,14 @@ export async function expectError( } } -export async function compare( - original: string, - updated: string, -): Promise { +export function compare(original: string, updated: string): Mismatches { const ass1 = sourceToAssemblyHelper(original); - await expect(ass1).resolves.not.toThrowError(); const ts1 = new reflect.TypeSystem(); - const originalAssembly = ts1.addAssembly( - new reflect.Assembly(ts1, await ass1), - ); + const originalAssembly = ts1.addAssembly(new reflect.Assembly(ts1, ass1)); const ass2 = sourceToAssemblyHelper(updated); - await expect(ass2).resolves.not.toThrowError(); const ts2 = new reflect.TypeSystem(); - const updatedAssembly = ts2.addAssembly( - new reflect.Assembly(ts2, await ass2), - ); + const updatedAssembly = ts2.addAssembly(new reflect.Assembly(ts2, ass2)); return compareAssemblies(originalAssembly, updatedAssembly); } diff --git a/packages/jsii-pacmak/lib/targets/dotnet/dotnetdocgenerator.ts b/packages/jsii-pacmak/lib/targets/dotnet/dotnetdocgenerator.ts index 48337cdf20..d1cb2ea2f6 100644 --- a/packages/jsii-pacmak/lib/targets/dotnet/dotnetdocgenerator.ts +++ b/packages/jsii-pacmak/lib/targets/dotnet/dotnetdocgenerator.ts @@ -204,7 +204,7 @@ export class DotNetDocGenerator { * Uppercase the first letter */ function ucFirst(x: string) { - return x.substr(0, 1).toUpperCase() + x.substr(1); + return x.slice(0, 1).toUpperCase() + x.slice(1); } function shouldMentionStability(s: spec.Stability) { diff --git a/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts b/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts index b781fa6551..45af4500e2 100644 --- a/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts +++ b/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts @@ -161,7 +161,7 @@ export class DotNetGenerator extends Generator { this.assembly.name, // Strip the `${assmName}.` prefix here, as the "assembly-relative" NS // is expected by `this.typeResolver.resovleNamespace`. - jsiiNs.substr(this.assembly.name.length + 1), + jsiiNs.slice(this.assembly.name.length + 1), ); this.emitNamespaceDocs(dotnetNs, jsiiNs, submodule); } diff --git a/packages/jsii-pacmak/lib/targets/java.ts b/packages/jsii-pacmak/lib/targets/java.ts index f7e6f737fd..da935cd0c3 100644 --- a/packages/jsii-pacmak/lib/targets/java.ts +++ b/packages/jsii-pacmak/lib/targets/java.ts @@ -3257,5 +3257,5 @@ function splitNamespace(ns: string): [string, string] { if (dot === -1) { return ['', ns]; } - return [ns.substr(0, dot), ns.substr(dot + 1)]; + return [ns.slice(0, dot), ns.slice(dot + 1)]; } diff --git a/packages/jsii-pacmak/lib/targets/python/requirements-dev.txt b/packages/jsii-pacmak/lib/targets/python/requirements-dev.txt index 530b8a4098..23614b89c5 100644 --- a/packages/jsii-pacmak/lib/targets/python/requirements-dev.txt +++ b/packages/jsii-pacmak/lib/targets/python/requirements-dev.txt @@ -6,4 +6,5 @@ setuptools~=59.6.0 # build-system wheel~=0.37.1 # build-system -twine~=3.8.0 +twine~=3.8.0 ; python_version < '3.7' +twine~=4.0.0 ; python_version >= '3.7' diff --git a/packages/jsii-pacmak/package.json b/packages/jsii-pacmak/package.json index 6115bd74ff..353c1f469d 100644 --- a/packages/jsii-pacmak/package.json +++ b/packages/jsii-pacmak/package.json @@ -47,7 +47,7 @@ "jsii-reflect": "^0.0.0", "jsii-rosetta": "^0.0.0", "semver": "^7.3.5", - "spdx-license-list": "^6.4.0", + "spdx-license-list": "^6.5.0", "xmlbuilder": "^15.1.1", "yargs": "^16.2.0" }, @@ -62,13 +62,13 @@ "@types/jest": "^27.4.1", "@types/node": "^12.20.47", "@types/semver": "^7.3.9", - "eslint": "^8.10.0", + "eslint": "^8.12.0", "jest": "^27.5.1", "jsii": "^0.0.0", "jsii-build-tools": "^0.0.0", "jsii-calc": "^3.20.120", - "prettier": "^2.5.1", - "ts-jest": "^27.1.3", + "prettier": "^2.6.2", + "ts-jest": "^27.1.4", "typescript": "~3.9.10" }, "keywords": [ 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 ba54e825bd..07b399c846 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 @@ -500,7 +500,7 @@ exports[`diamond-struct-parameter.ts: /java/pom.xml 1`] = ` Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 repo An OSI-approved license @@ -1999,7 +1999,7 @@ exports[`nested-types.ts: /java/pom.xml 1`] = ` Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 repo An OSI-approved license diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap index 0706c2d65d..8e3462db3f 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap @@ -3580,7 +3580,7 @@ namespace Amazon.JSII.Tests.CalculatorNamespace set => SetInstanceProperty(value); } - [JsiiProperty(name: "unionProperty", typeJson: "{\\"union\\":{\\"types\\":[{\\"primitive\\":\\"string\\"},{\\"primitive\\":\\"number\\"},{\\"fqn\\":\\"jsii-calc.Multiply\\"},{\\"fqn\\":\\"@scope/jsii-calc-lib.Number\\"}]}}")] + [JsiiProperty(name: "unionProperty", typeJson: "{\\"union\\":{\\"types\\":[{\\"primitive\\":\\"string\\"},{\\"primitive\\":\\"number\\"},{\\"fqn\\":\\"@scope/jsii-calc-lib.Number\\"},{\\"fqn\\":\\"jsii-calc.Multiply\\"}]}}")] public virtual object UnionProperty { get => GetInstanceProperty()!; diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap index c53ae547ce..c15f524ba5 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap @@ -252,7 +252,7 @@ exports[`Generated code for "@scope/jsii-calc-base": /java/pom.xml 1`] = Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 repo An OSI-approved license @@ -975,7 +975,7 @@ exports[`Generated code for "@scope/jsii-calc-base-of-base": /java/pom.x Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 repo An OSI-approved license @@ -1668,7 +1668,7 @@ exports[`Generated code for "@scope/jsii-calc-lib": /java/pom.xml 1`] = Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 repo An OSI-approved license @@ -4113,7 +4113,7 @@ exports[`Generated code for "jsii-calc": /java/pom.xml 1`] = ` Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 repo An OSI-approved license @@ -4950,14 +4950,14 @@ public class AllTypes extends software.amazon.jsii.JsiiObject { /** */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) - public void setUnionProperty(final @org.jetbrains.annotations.NotNull software.amazon.jsii.tests.calculator.Multiply value) { + public void setUnionProperty(final @org.jetbrains.annotations.NotNull software.amazon.jsii.tests.calculator.lib.Number value) { software.amazon.jsii.Kernel.set(this, "unionProperty", java.util.Objects.requireNonNull(value, "unionProperty is required")); } /** */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) - public void setUnionProperty(final @org.jetbrains.annotations.NotNull software.amazon.jsii.tests.calculator.lib.Number value) { + public void setUnionProperty(final @org.jetbrains.annotations.NotNull software.amazon.jsii.tests.calculator.Multiply value) { software.amazon.jsii.Kernel.set(this, "unionProperty", java.util.Objects.requireNonNull(value, "unionProperty is required")); } 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 806b543cfa..40cb873524 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 @@ -2832,13 +2832,13 @@ class AllTypes(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AllTypes"): @jsii.member(jsii_name="unionProperty") def union_property( self, - ) -> typing.Union[builtins.str, jsii.Number, "Multiply", scope.jsii_calc_lib.Number]: - return typing.cast(typing.Union[builtins.str, jsii.Number, "Multiply", scope.jsii_calc_lib.Number], jsii.get(self, "unionProperty")) + ) -> typing.Union[builtins.str, jsii.Number, scope.jsii_calc_lib.Number, "Multiply"]: + return typing.cast(typing.Union[builtins.str, jsii.Number, scope.jsii_calc_lib.Number, "Multiply"], jsii.get(self, "unionProperty")) @union_property.setter def union_property( self, - value: typing.Union[builtins.str, jsii.Number, "Multiply", scope.jsii_calc_lib.Number], + value: typing.Union[builtins.str, jsii.Number, scope.jsii_calc_lib.Number, "Multiply"], ) -> None: jsii.set(self, "unionProperty", value) @@ -4544,8 +4544,7 @@ class DocumentedClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.DocumentedCl x = 12 + 44 s1 = "string" - s2 = """string - with new newlines""" # see https://github.com/aws/jsii/issues/2569 + s2 = "string \\nwith new newlines" # see https://github.com/aws/jsii/issues/2569 s3 = """string with new lines""" diff --git a/packages/jsii-pacmak/test/generated-code/examples.test.ts b/packages/jsii-pacmak/test/generated-code/examples.test.ts index 54f7451663..9d478942e2 100644 --- a/packages/jsii-pacmak/test/generated-code/examples.test.ts +++ b/packages/jsii-pacmak/test/generated-code/examples.test.ts @@ -13,7 +13,7 @@ for (const name of fs.readdirSync(EXAMPLES_ROOT)) { const file = path.join(EXAMPLES_ROOT, name); test(name, async () => { const source = await fs.readFile(file, 'utf8'); - const compiled = await jsii.compileJsiiForTest(source); + const compiled = jsii.compileJsiiForTest(source); const targets: AssemblyTargets = { dotnet: { diff --git a/packages/jsii-pacmak/test/generated-code/requirements-dev.txt b/packages/jsii-pacmak/test/generated-code/requirements-dev.txt index 78c3042d5d..2f3b421b72 100644 --- a/packages/jsii-pacmak/test/generated-code/requirements-dev.txt +++ b/packages/jsii-pacmak/test/generated-code/requirements-dev.txt @@ -1 +1 @@ -mypy==0.941 +mypy==0.942 diff --git a/packages/jsii-reflect/lib/source.ts b/packages/jsii-reflect/lib/source.ts index 1a93c4636c..b672aff99a 100644 --- a/packages/jsii-reflect/lib/source.ts +++ b/packages/jsii-reflect/lib/source.ts @@ -77,7 +77,7 @@ export function repositoryUrl( // Turn https://github.com/awslabs/aws-cdk.git -> https://github.com/awslabs/aws-cdk/blob/REF/filename#L - const prefix = repo.url.substr(0, repo.url.length - 4); + const prefix = repo.url.slice(0, -4); return `${prefix}/blob/${ref}/${loc.filename}#L${loc.line}`; } diff --git a/packages/jsii-reflect/package.json b/packages/jsii-reflect/package.json index a8f02a73ad..9f6c1f7593 100644 --- a/packages/jsii-reflect/package.json +++ b/packages/jsii-reflect/package.json @@ -46,12 +46,12 @@ "@types/fs-extra": "^9.0.13", "@types/jest": "^27.4.1", "@types/node": "^12.20.47", - "eslint": "^8.10.0", + "eslint": "^8.12.0", "jest": "^27.5.1", "jsii": "^0.0.0", "jsii-build-tools": "^0.0.0", "jsii-calc": "^3.20.120", - "prettier": "^2.5.1", + "prettier": "^2.6.2", "typescript": "~3.9.10" } } diff --git a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.ts.snap b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.ts.snap index 5aa58e66c2..a74e0b7e51 100644 --- a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.ts.snap +++ b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.ts.snap @@ -631,7 +631,7 @@ exports[`jsii-tree --all 1`] = ` β”‚ β”‚ β”œβ”€β”¬ unionMapProperty property (stable) β”‚ β”‚ β”‚ └── type: Map string | number | @scope/jsii-calc-lib.Number> β”‚ β”‚ β”œβ”€β”¬ unionProperty property (stable) - β”‚ β”‚ β”‚ └── type: string | number | jsii-calc.Multiply | @scope/jsii-calc-lib.Number + β”‚ β”‚ β”‚ └── type: string | number | @scope/jsii-calc-lib.Number | jsii-calc.Multiply β”‚ β”‚ β”œβ”€β”¬ unknownArrayProperty property (stable) β”‚ β”‚ β”‚ └── type: Array β”‚ β”‚ β”œβ”€β”¬ unknownMapProperty property (stable) diff --git a/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap b/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap index e69a0d7e27..bf8838a7ff 100644 --- a/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap +++ b/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap @@ -781,7 +781,7 @@ exports[`showAll 1`] = ` β”‚ β”‚ β”œβ”€β”¬ unionMapProperty property β”‚ β”‚ β”‚ └── type: Map string | number | @scope/jsii-calc-lib.Number> β”‚ β”‚ β”œβ”€β”¬ unionProperty property - β”‚ β”‚ β”‚ └── type: string | number | jsii-calc.Multiply | @scope/jsii-calc-lib.Number + β”‚ β”‚ β”‚ └── type: string | number | @scope/jsii-calc-lib.Number | jsii-calc.Multiply β”‚ β”‚ β”œβ”€β”¬ unknownArrayProperty property β”‚ β”‚ β”‚ └── type: Array β”‚ β”‚ β”œβ”€β”¬ unknownMapProperty property diff --git a/packages/jsii-reflect/test/independent.test.ts b/packages/jsii-reflect/test/independent.test.ts index b059ba88b5..fdbac01970 100644 --- a/packages/jsii-reflect/test/independent.test.ts +++ b/packages/jsii-reflect/test/independent.test.ts @@ -1,9 +1,9 @@ import * as reflect from '../lib'; import { assemblyFromSource } from './util'; -test('get full github source location for a class or method', async () => { +test('get full github source location for a class or method', () => { // WHEN - const assembly = await assemblyFromSource( + const assembly = assemblyFromSource( ` export class Foo { public bar() { diff --git a/packages/jsii-reflect/test/type-system.test.ts b/packages/jsii-reflect/test/type-system.test.ts index ef799095ab..0207c81b1f 100644 --- a/packages/jsii-reflect/test/type-system.test.ts +++ b/packages/jsii-reflect/test/type-system.test.ts @@ -203,8 +203,8 @@ test('Submodules can have a README', () => { ); }); -test('overridden member knows about both parent types', async () => { - const ts = await typeSystemFromSource(` +test('overridden member knows about both parent types', () => { + const ts = typeSystemFromSource(` export class Foo { public bar() { Array.isArray(3); @@ -256,8 +256,8 @@ describe('Stability', () => { // ---------------------------------------------------------------------- describe('lowest stability guarantee is advertised', () => { - test('when subclass is experimental', async () => { - const ts = await typeSystemFromSource(` + test('when subclass is experimental', () => { + const ts = typeSystemFromSource(` /** * @stable */ @@ -285,8 +285,8 @@ describe('Stability', () => { expect(method.docs.stability).toEqual(Stability.Experimental); }); - test('when method is experimental', async () => { - const ts = await typeSystemFromSource(` + test('when method is experimental', () => { + const ts = typeSystemFromSource(` /** * @stable */ @@ -321,8 +321,8 @@ describe('Stability', () => { expect(method.docs.stability).toEqual(Stability.Experimental); }); - test('when method is explicitly marked stable', async () => { - const ts = await typeSystemFromSource(` + test('when method is explicitly marked stable', () => { + const ts = typeSystemFromSource(` /** * @stable */ @@ -357,8 +357,8 @@ describe('Stability', () => { expect(method.docs.stability).toEqual(Stability.Experimental); }); - test('external stability', async () => { - const ts = await typeSystemFromSource(` + test('external stability', () => { + const ts = typeSystemFromSource(` /** * @stability external */ @@ -383,8 +383,8 @@ describe('Stability', () => { }); }); -test('TypeSystem.properties', async () => { - const ts = await typeSystemFromSource(` +test('TypeSystem.properties', () => { + const ts = typeSystemFromSource(` export namespace submodule { export class Foo { public readonly test = 'TEST'; @@ -397,8 +397,8 @@ test('TypeSystem.properties', async () => { expect(ts.properties).toHaveLength(2); }); -test('TypeSystem.methods', async () => { - const ts = await typeSystemFromSource(` +test('TypeSystem.methods', () => { + const ts = typeSystemFromSource(` export namespace submodule { export class Foo { public method(): void {} @@ -411,8 +411,8 @@ test('TypeSystem.methods', async () => { expect(ts.methods).toHaveLength(2); }); -test('Assembly allTypes includes submodule types', async () => { - const asm = await assemblyFromSource({ +test('Assembly allTypes includes submodule types', () => { + const asm = assemblyFromSource({ 'index.ts': 'export * as submod from "./submod";', 'submod.ts': `export class Foo {}`, }); diff --git a/packages/jsii-reflect/test/util.ts b/packages/jsii-reflect/test/util.ts index 575213a6a6..a1242a1c43 100644 --- a/packages/jsii-reflect/test/util.ts +++ b/packages/jsii-reflect/test/util.ts @@ -2,19 +2,19 @@ import { sourceToAssemblyHelper, MultipleSourceFiles, PackageInfo } from 'jsii'; import { Assembly, TypeSystem } from '../lib'; -export async function typeSystemFromSource( +export function typeSystemFromSource( source: string | MultipleSourceFiles, cb?: (obj: PackageInfo) => void, ) { - const asm = await assemblyFromSource(source, cb); + const asm = assemblyFromSource(source, cb); return asm.system; } -export async function assemblyFromSource( +export function assemblyFromSource( source: string | MultipleSourceFiles, cb?: (obj: PackageInfo) => void, -): Promise { - const ass = await sourceToAssemblyHelper(source, cb); +): Assembly { + const ass = sourceToAssemblyHelper(source, cb); const ts = new TypeSystem(); return ts.addAssembly(new Assembly(ts, ass)); } diff --git a/packages/jsii-rosetta/lib/commands/transliterate.ts b/packages/jsii-rosetta/lib/commands/transliterate.ts index 5878c1d9ad..5f7c6e87f9 100644 --- a/packages/jsii-rosetta/lib/commands/transliterate.ts +++ b/packages/jsii-rosetta/lib/commands/transliterate.ts @@ -32,6 +32,20 @@ export interface TransliterateAssemblyOptions { * @default - Only the default tablet (`.jsii.tabl.json`) files will be used. */ readonly tablet?: string; + + /** + * A directory to output translated assemblies to + * + * @default - assembly location + */ + readonly outdir?: string; + + /** + * Whether or not to live-convert samples + * + * @default UnknownSnippetMode.FAIL + */ + readonly unknownSnippets?: UnknownSnippetMode; } /** @@ -67,7 +81,7 @@ export async function transliterateAssembly( // Now do a regular "tablet reader" cycle, expecting everything to be translated already, // and therefore it doesn't matter that we do this all in a single-threaded loop. const rosetta = new RosettaTabletReader({ - unknownSnippets: UnknownSnippetMode.FAIL, + unknownSnippets: options?.unknownSnippets ?? UnknownSnippetMode.FAIL, targetLanguages, prefixDisclaimer: true, }); @@ -97,7 +111,7 @@ export async function transliterateAssembly( transliterateType(type, rosetta, language); } // eslint-disable-next-line no-await-in-loop - await writeJson(resolve(location, `${SPEC_FILE_NAME}.${language}`), result, { spaces: 2 }); + await writeJson(resolve(options?.outdir ?? location, `${SPEC_FILE_NAME}.${language}`), result, { spaces: 2 }); const then = new Date().getTime(); debug(`Done transliterating ${result.name}@${result.version} to ${language} after ${then - now} milliseconds`); } diff --git a/packages/jsii-rosetta/lib/languages/csharp.ts b/packages/jsii-rosetta/lib/languages/csharp.ts index 505843d97a..acca98b23b 100644 --- a/packages/jsii-rosetta/lib/languages/csharp.ts +++ b/packages/jsii-rosetta/lib/languages/csharp.ts @@ -689,7 +689,7 @@ export class CSharpVisitor extends DefaultVisitor { * Uppercase the first letter */ function ucFirst(x: string) { - return x.substr(0, 1).toUpperCase() + x.substr(1); + return x.slice(0, 1).toUpperCase() + x.slice(1); } /** diff --git a/packages/jsii-rosetta/lib/languages/java.ts b/packages/jsii-rosetta/lib/languages/java.ts index 97b4488980..778735731c 100644 --- a/packages/jsii-rosetta/lib/languages/java.ts +++ b/packages/jsii-rosetta/lib/languages/java.ts @@ -296,7 +296,7 @@ export class JavaVisitor extends DefaultVisitor { let renderedType = this.renderTypeNode(node.type, renderer); if (node.dotDotDotToken && renderedType.endsWith('[]')) { // Varargs. In Java, render this as `Element...` (instead of `Element[]` which is what we'll have gotten). - renderedType = `${renderedType.substr(0, renderedType.length - 2)}...`; + renderedType = `${renderedType.slice(0, -2)}...`; } return new OTree([renderedType, ' ', renderer.convert(node.name)]); diff --git a/packages/jsii-rosetta/lib/languages/python.ts b/packages/jsii-rosetta/lib/languages/python.ts index a42207ee0d..c4e1c02579 100644 --- a/packages/jsii-rosetta/lib/languages/python.ts +++ b/packages/jsii-rosetta/lib/languages/python.ts @@ -72,6 +72,13 @@ interface PythonLanguageContext { */ readonly inClass?: boolean; + /** + * Whether the current property assignment is in the context of a map value. + * In this case, the keys should be strings (quoted where needed), and should + * not get mangled or case-converted. + */ + readonly inMap?: boolean; + /** * If we're in a method, what is it's name * @@ -415,7 +422,7 @@ export class PythonVisitor extends DefaultVisitor { } public keyValueObjectLiteralExpression(node: ts.ObjectLiteralExpression, context: PythonVisitorContext): OTree { - return this.renderObjectLiteralExpression('{', '}', false, node, context); + return this.renderObjectLiteralExpression('{', '}', false, node, context.updateContext({ inMap: true })); } public translateUnaryOperator(operator: ts.PrefixUnaryOperator) { @@ -451,19 +458,26 @@ export class PythonVisitor extends DefaultVisitor { const mid = context.currentContext.renderObjectLiteralAsKeywords ? '=' : ': '; // node.name is either an identifier or a string literal. The string literal - // needs to be converted differently. - let name = context.convert(node.name); - matchAst(node.name, nodeOfType('stringLiteral', ts.SyntaxKind.StringLiteral), (captured) => { - name = new OTree([mangleIdentifier(captured.stringLiteral.text)]); - }); + // needs to be converted differently depending on whether it needs to be a + // string or a keyword argument. + let name = ts.isStringLiteral(node.name) + ? new OTree([ + context.currentContext.inMap // If in map, don't mangle the keys + ? node.name.text + : mangleIdentifier(node.name.text), + ]) + : context.convert(node.name); // If this isn't a computed property, we must quote the key (unless it's rendered as a keyword) - if (!context.currentContext.renderObjectLiteralAsKeywords && !ts.isComputedPropertyName(node.name)) { + if ( + context.currentContext.inMap || + (!context.currentContext.renderObjectLiteralAsKeywords && !ts.isComputedPropertyName(node.name)) + ) { name = new OTree(['"', name, '"']); } return new OTree( - [name, mid, context.updateContext({ tailPositionArgument: false }).convert(node.initializer)], + [name, mid, context.updateContext({ inMap: false, tailPositionArgument: false }).convert(node.initializer)], [], { canBreakLine: true }, ); @@ -608,11 +622,10 @@ export class PythonVisitor extends DefaultVisitor { node: ts.StringLiteral | ts.NoSubstitutionTemplateLiteral, _context: PythonVisitorContext, ): OTree { - const rawText = node.text; - if (rawText.includes('\n')) { + if (node.getText(node.getSourceFile()).includes('\n')) { return new OTree([ '"""', - rawText + node.text // Escape all occurrences of back-slash once more .replace(/\\/g, '\\\\') // Escape only the first one in triple-quotes @@ -620,7 +633,7 @@ export class PythonVisitor extends DefaultVisitor { '"""', ]); } - return new OTree([JSON.stringify(rawText)]); + return new OTree([JSON.stringify(node.text)]); } public templateExpression(node: ts.TemplateExpression, context: PythonVisitorContext): OTree { @@ -795,7 +808,7 @@ function mangleIdentifier(originalIdentifier: string) { return originalIdentifier; } // Turn into snake-case - const cased = originalIdentifier.replace(/[^A-Z][A-Z]/g, (m) => `${m[0].substr(0, 1)}_${m.substr(1).toLowerCase()}`); + const cased = originalIdentifier.replace(/[^A-Z][A-Z]/g, (m) => `${m[0].slice(0, 1)}_${m.slice(1).toLowerCase()}`); return IDENTIFIER_KEYWORDS.includes(cased) ? `${cased}_` : cased; } diff --git a/packages/jsii-rosetta/lib/markdown/markdown-renderer.ts b/packages/jsii-rosetta/lib/markdown/markdown-renderer.ts index f5a38db6fb..1610ad893c 100644 --- a/packages/jsii-rosetta/lib/markdown/markdown-renderer.ts +++ b/packages/jsii-rosetta/lib/markdown/markdown-renderer.ts @@ -74,7 +74,7 @@ export class MarkdownRenderer implements CommonMarkRenderer { const rendered = context.recurse(item); // Prefix the first line with a different text than subsequent lines - const prefixed = firstLinePrefix + prefixLines(hangingPrefix, rendered).substr(hangingPrefix.length); + const prefixed = firstLinePrefix + prefixLines(hangingPrefix, rendered).slice(hangingPrefix.length); items.push(prefixed); diff --git a/packages/jsii-rosetta/package.json b/packages/jsii-rosetta/package.json index b054c85ede..7ebfe9d65d 100644 --- a/packages/jsii-rosetta/package.json +++ b/packages/jsii-rosetta/package.json @@ -23,12 +23,12 @@ "@types/node": "^12.20.47", "@types/workerpool": "^6.1.0", "@types/semver": "^7.3.9", - "eslint": "^8.10.0", + "eslint": "^8.12.0", "jest": "^27.5.1", "jsii-build-tools": "0.0.0", "memory-streams": "^0.1.3", "mock-fs": "^5.1.2", - "prettier": "^2.5.1" + "prettier": "^2.6.2" }, "dependencies": { "@jsii/check-node": "0.0.0", @@ -37,7 +37,7 @@ "fs-extra": "^9.1.0", "typescript": "~3.9.10", "sort-json": "^2.0.1", - "@xmldom/xmldom": "^0.8.1", + "@xmldom/xmldom": "^0.8.2", "workerpool": "^6.2.0", "yargs": "^16.2.0", "semver": "^7.3.5", diff --git a/packages/jsii-rosetta/test/commands/extract.test.ts b/packages/jsii-rosetta/test/commands/extract.test.ts index 1fae776890..f85ce17322 100644 --- a/packages/jsii-rosetta/test/commands/extract.test.ts +++ b/packages/jsii-rosetta/test/commands/extract.test.ts @@ -34,9 +34,9 @@ const defaultExtractOptions = { }; let assembly: TestJsiiModule; -beforeEach(async () => { +beforeEach(() => { // Create an assembly in a temp directory - assembly = await TestJsiiModule.fromSource( + assembly = TestJsiiModule.fromSource( { 'index.ts': ` export class ClassA { @@ -57,7 +57,7 @@ beforeEach(async () => { ); }); -afterEach(async () => assembly.cleanup()); +afterEach(() => assembly.cleanup()); test('extract samples from test assembly', async () => { const cacheToFile = path.join(assembly.moduleDirectory, 'test.tabl.json'); @@ -267,7 +267,7 @@ describe('non-compiling cached examples', () => { let cacheToFile: string; beforeEach(async () => { // Create an assembly in a temp directory - otherAssembly = await TestJsiiModule.fromSource( + otherAssembly = TestJsiiModule.fromSource( { 'index.ts': ` export class ClassA { @@ -300,7 +300,7 @@ describe('non-compiling cached examples', () => { expect(tr?.snippet.didCompile).toBeFalsy(); }); - afterEach(async () => assembly.cleanup()); + afterEach(() => assembly.cleanup()); test('are ignored with strict mode', async () => { // second run of extract snippets should still evaluate the snippet @@ -333,7 +333,7 @@ describe('non-compiling cached examples', () => { test('do not ignore example strings', async () => { // Create an assembly in a temp directory - const otherAssembly = await TestJsiiModule.fromSource( + const otherAssembly = TestJsiiModule.fromSource( { 'index.ts': ` export class ClassA { @@ -363,14 +363,14 @@ test('do not ignore example strings', async () => { const tr = tablet.tryGetSnippet(tablet.snippetKeys[0]); expect(tr?.originalSource.source).toEqual('x'); } finally { - await otherAssembly.cleanup(); + otherAssembly.cleanup(); } }); describe('can find fqns via symbolId when ', () => { test('there is an outDir', async () => { const outDir = 'jsii-outDir'; - const otherAssembly = await createAssemblyWithDirectories(undefined, outDir); + const otherAssembly = createAssemblyWithDirectories(undefined, outDir); try { const outputFile = path.join(otherAssembly.moduleDirectory, 'test.tabl.json'); await extract.extractSnippets([otherAssembly.moduleDirectory], { @@ -382,14 +382,14 @@ describe('can find fqns via symbolId when ', () => { const tr = tablet.tryGetSnippet(tablet.snippetKeys[0]); expect(tr?.fqnsReferenced()).toEqual(['my_assembly.ClassA']); } finally { - await otherAssembly.cleanup(); + otherAssembly.cleanup(); } }); test('there is an outDir and rootDir', async () => { const outDir = 'jsii-outDir'; const rootDir = '.'; - const otherAssembly = await createAssemblyWithDirectories(rootDir, outDir); + const otherAssembly = createAssemblyWithDirectories(rootDir, outDir); try { const outputFile = path.join(otherAssembly.moduleDirectory, 'test.tabl.json'); await extract.extractSnippets([otherAssembly.moduleDirectory], { @@ -401,7 +401,7 @@ describe('can find fqns via symbolId when ', () => { const tr = tablet.tryGetSnippet(tablet.snippetKeys[0]); expect(tr?.fqnsReferenced()).toEqual(['my_assembly.ClassA']); } finally { - await otherAssembly.cleanup(); + otherAssembly.cleanup(); } }); }); @@ -438,8 +438,8 @@ test('extract and infuse in one command', async () => { describe('infused examples', () => { let infusedAssembly: TestJsiiModule; - beforeEach(async () => { - infusedAssembly = await TestJsiiModule.fromSource( + beforeEach(() => { + infusedAssembly = TestJsiiModule.fromSource( { 'index.ts': ` /** @@ -461,8 +461,8 @@ describe('infused examples', () => { ); }); - afterEach(async () => { - await infusedAssembly.cleanup(); + afterEach(() => { + infusedAssembly.cleanup(); }); test('always returned from cache', async () => { @@ -526,7 +526,7 @@ describe('infused examples', () => { test('can use additional dependencies from monorepo', async () => { logging.configure({ level: logging.Level.VERBOSE }); - const asm = await TestJsiiModule.fromSource( + const asm = TestJsiiModule.fromSource( { 'index.ts': ` /** @@ -555,8 +555,8 @@ test('can use additional dependencies from monorepo', async () => { ); try { // GIVEN - install some random other module - await asm.workspace.addDependency( - await compileJsiiForTest( + asm.workspace.addDependency( + compileJsiiForTest( { 'index.ts': 'export class SomeClass { }', }, @@ -576,12 +576,12 @@ test('can use additional dependencies from monorepo', async () => { await extract.extractSnippets([asm.moduleDirectory], defaultExtractOptions); // THEN -- did not throw an error } finally { - await asm.cleanup(); + asm.cleanup(); } }); test('can use additional dependencies from NPM', async () => { - const asm = await TestJsiiModule.fromSource( + const asm = TestJsiiModule.fromSource( { 'index.ts': ` /** @@ -613,12 +613,12 @@ test('can use additional dependencies from NPM', async () => { await extract.extractSnippets([asm.moduleDirectory], defaultExtractOptions); // THEN -- did not throw an error } finally { - await asm.cleanup(); + asm.cleanup(); } }); test('infused examples have no diagnostics', async () => { - const otherAssembly = await TestJsiiModule.fromSource( + const otherAssembly = TestJsiiModule.fromSource( { 'index.ts': ` /** @@ -651,7 +651,7 @@ test('infused examples have no diagnostics', async () => { expect(results.diagnostics).toEqual([]); } finally { - await otherAssembly.cleanup(); + otherAssembly.cleanup(); } }); @@ -662,7 +662,7 @@ class MockTranslator extends RosettaTranslator { } } -async function createAssemblyWithDirectories(rootDir?: string, outDir?: string) { +function createAssemblyWithDirectories(rootDir?: string, outDir?: string) { return TestJsiiModule.fromSource( { 'index.ts': ` diff --git a/packages/jsii-rosetta/test/commands/infuse.test.ts b/packages/jsii-rosetta/test/commands/infuse.test.ts index f8e8b7c316..d0a20ea54b 100644 --- a/packages/jsii-rosetta/test/commands/infuse.test.ts +++ b/packages/jsii-rosetta/test/commands/infuse.test.ts @@ -25,7 +25,7 @@ const TABLET_FILE = 'text.tabl.json'; let assembly: TestJsiiModule; beforeEach(async () => { // Create an assembly in a temp directory - assembly = await TestJsiiModule.fromSource( + assembly = TestJsiiModule.fromSource( { 'index.ts': ` export class ClassA { @@ -56,7 +56,7 @@ beforeEach(async () => { }); }); -afterEach(async () => assembly.cleanup()); +afterEach(() => assembly.cleanup()); test('examples are added in the assembly', async () => { await infuse([assembly.moduleDirectory]); diff --git a/packages/jsii-rosetta/test/commands/transliterate.test.ts b/packages/jsii-rosetta/test/commands/transliterate.test.ts index c5693523f5..c6797f4cbd 100644 --- a/packages/jsii-rosetta/test/commands/transliterate.test.ts +++ b/packages/jsii-rosetta/test/commands/transliterate.test.ts @@ -14,7 +14,7 @@ jest.setTimeout(60_000); test('single assembly, all languages', () => withTemporaryDirectory(async (tmpDir) => { // GIVEN - const compilationResult = await jsii.compileJsiiForTest({ + const compilationResult = jsii.compileJsiiForTest({ 'README.md': ` # README \`\`\`ts @@ -890,7 +890,7 @@ export class ClassName implements IInterface { test('single assembly, loose mode', () => withTemporaryDirectory(async (tmpDir) => { // GIVEN - const compilationResult = await jsii.compileJsiiForTest({ + const compilationResult = jsii.compileJsiiForTest({ 'README.md': ` # Missing literate source @@ -1249,7 +1249,7 @@ new SampleClass('omitted-literate'); test('single assembly with example metadata', () => withTemporaryDirectory(async (tmpDir) => { // GIVEN - const compilationResult = await jsii.compileJsiiForTest({ + const compilationResult = jsii.compileJsiiForTest({ 'index.ts': ` /** * @exampleMetadata fixture=custom @@ -1349,7 +1349,7 @@ export class ClassName implements IInterface { })); test('will read translations from cache even if they are dirty', async () => { - const infusedAssembly = await TestJsiiModule.fromSource( + const infusedAssembly = TestJsiiModule.fromSource( { 'index.ts': ` /** @@ -1388,6 +1388,115 @@ test('will read translations from cache even if they are dirty', async () => { const translated: Assembly = await fs.readJson(path.join(infusedAssembly.moduleDirectory, '.jsii.python')); expect(translated.types?.['my_assembly.ClassA'].docs?.example).toEqual('oops'); } finally { - await infusedAssembly.cleanup(); + infusedAssembly.cleanup(); } }); + +test('will output to specified directory', async () => + withTemporaryDirectory(async (tmpDir) => { + // GIVEN + const compilationResult = jsii.compileJsiiForTest({ + 'README.md': ` +# README +\`\`\`ts +const object: IInterface = new ClassName('this', 1337, { foo: 'bar' }); +object.property = EnumType.OPTION_A; +object.methodCall(); + +ClassName.staticMethod(EnumType.OPTION_B); +\`\`\` +`, + 'index.ts': ` +/** + * @example new ClassName('this', 1337, { property: EnumType.OPTION_B }); + */ +export enum EnumType { + /** + * @example new ClassName('this', 1337, { property: EnumType.OPTION_A }); + */ + OPTION_A = 1, + + /** + * @example new ClassName('this', 1337, { property: EnumType.OPTION_B }); + */ + OPTION_B = 2, +} + +export interface IInterface { + /** + * A property value. + * + * @example + * iface.property = EnumType.OPTION_B; + */ + property: EnumType; + + /** + * An instance method call. + * + * @example + * iface.methodCall(); + */ + methodCall(): void; +} + +export interface ClassNameProps { + readonly property?: EnumType; + readonly foo?: string; +} + +export class ClassName implements IInterface { + /** + * A static method. It can be invoked easily. + * + * @example ClassName.staticMethod(); + */ + public static staticMethod(_enm?: EnumType): void { + // ... + } + + public property: EnumType; + + /** + * Create a new instance of ClassName. + * + * @example new ClassName('this', 1337, { property: EnumType.OPTION_B }); + */ + public constructor(_this: string, _elite: number, props: ClassNameProps) { + this.property = props.property ?? EnumType.OPTION_A; + } + + public methodCall(): void { + // ... + } +}`, + }); + fs.writeJsonSync(path.join(tmpDir, SPEC_FILE_NAME), compilationResult.assembly, { + spaces: 2, + }); + for (const [file, content] of Object.entries(compilationResult.files)) { + fs.writeFileSync(path.resolve(tmpDir, file), content, 'utf-8'); + } + fs.mkdirSync(path.resolve(tmpDir, 'rosetta')); + fs.writeFileSync( + path.resolve(tmpDir, 'rosetta', 'default.ts-fixture'), + `import { EnumType, IInterface, ClassName } from '.';\ndeclare const iface: IInterface\n/// here`, + 'utf-8', + ); + + // WHEN + // create outdir + const outdir = path.resolve(tmpDir, 'out'); + fs.mkdirSync(outdir); + + await expect( + transliterateAssembly([tmpDir], Object.values(TargetLanguage), { + strict: true, + outdir, + }), + ).resolves.not.toThrow(); + + Object.values(TargetLanguage).forEach((lang) => { + expect(fs.statSync(path.join(outdir, `${SPEC_FILE_NAME}.${lang}`)).isFile()).toBe(true); + }); + })); diff --git a/packages/jsii-rosetta/test/commands/trim-cache.test.ts b/packages/jsii-rosetta/test/commands/trim-cache.test.ts index d5649356d6..27046cc301 100644 --- a/packages/jsii-rosetta/test/commands/trim-cache.test.ts +++ b/packages/jsii-rosetta/test/commands/trim-cache.test.ts @@ -16,9 +16,9 @@ const DUMMY_README = ` `; let assembly: TestJsiiModule; -beforeEach(async () => { +beforeEach(() => { // Create an assembly in a temp directory - assembly = await TestJsiiModule.fromSource( + assembly = TestJsiiModule.fromSource( { 'index.ts': ` export class ClassA { @@ -39,7 +39,7 @@ beforeEach(async () => { ); }); -afterEach(async () => assembly.cleanup()); +afterEach(() => assembly.cleanup()); test('trim-cache removes unused snippets', async () => { const cacheFile = path.join(assembly.moduleDirectory, 'dummy.tabl.json'); diff --git a/packages/jsii-rosetta/test/jsii-imports.test.ts b/packages/jsii-rosetta/test/jsii-imports.test.ts index 2cd61f9d86..d388b79e70 100644 --- a/packages/jsii-rosetta/test/jsii-imports.test.ts +++ b/packages/jsii-rosetta/test/jsii-imports.test.ts @@ -10,8 +10,8 @@ import { MultipleSources, TestJsiiModule, DUMMY_JSII_CONFIG } from './testutil'; describe('no submodule', () => { describe('top-level struct', () => { let module: TestJsiiModule; - beforeAll(async () => { - module = await makeJsiiModule({ withModule: false, nestedStruct: false }); + beforeAll(() => { + module = makeJsiiModule({ withModule: false, nestedStruct: false }); }); afterAll(() => module.cleanup()); @@ -103,8 +103,8 @@ describe('no submodule', () => { describe('nested struct', () => { let module: TestJsiiModule; - beforeAll(async () => { - module = await makeJsiiModule({ withModule: false, nestedStruct: true }); + beforeAll(() => { + module = makeJsiiModule({ withModule: false, nestedStruct: true }); }); afterAll(() => module.cleanup()); @@ -193,8 +193,8 @@ describe('no submodule', () => { describe('enum', () => { let module: TestJsiiModule; - beforeAll(async () => { - module = await TestJsiiModule.fromSource( + beforeAll(() => { + module = TestJsiiModule.fromSource( { 'index.ts': `export enum MyEnum { OPTION_A = 'a', OPTION_B = 'b' } @@ -320,8 +320,8 @@ describe('no submodule', () => { describe('with submodule', () => { describe('top-level struct', () => { let module: TestJsiiModule; - beforeAll(async () => { - module = await makeJsiiModule({ withModule: true, nestedStruct: false }); + beforeAll(() => { + module = makeJsiiModule({ withModule: true, nestedStruct: false }); }); afterAll(() => module.cleanup()); @@ -370,8 +370,8 @@ describe('with submodule', () => { describe('nested struct', () => { let module: TestJsiiModule; - beforeAll(async () => { - module = await makeJsiiModule({ withModule: true, nestedStruct: true }); + beforeAll(() => { + module = makeJsiiModule({ withModule: true, nestedStruct: true }); }); afterAll(() => module.cleanup()); @@ -419,10 +419,7 @@ describe('with submodule', () => { }); }); -async function makeJsiiModule(options: { - readonly withModule: boolean; - readonly nestedStruct: boolean; -}): Promise { +function makeJsiiModule(options: { readonly withModule: boolean; readonly nestedStruct: boolean }): TestJsiiModule { const nsRef = options.nestedStruct ? 'MyClass.' : ''; const nsDeclBegin = options.nestedStruct ? 'export namespace MyClass {\n' : ''; const nsDeclEnd = options.nestedStruct ? '}' : ''; diff --git a/packages/jsii-rosetta/test/jsii/assemblies.test.ts b/packages/jsii-rosetta/test/jsii/assemblies.test.ts index a5cf9d0d7a..0cc73b8597 100644 --- a/packages/jsii-rosetta/test/jsii/assemblies.test.ts +++ b/packages/jsii-rosetta/test/jsii/assemblies.test.ts @@ -234,7 +234,7 @@ test('Backwards compatibility with literate integ tests', async () => { }); test('rosetta fixture from submodule is preferred if it exists', async () => { - const jsiiModule = await TestJsiiModule.fromSource( + const jsiiModule = TestJsiiModule.fromSource( { 'index.ts': 'export * as submodule from "./submodule"', 'submodule.ts': ` @@ -268,6 +268,6 @@ test('rosetta fixture from submodule is preferred if it exists', async () => { expect(snippets[0].completeSource).toMatch(/^pick me/); } finally { - await jsiiModule.cleanup(); + jsiiModule.cleanup(); } }); diff --git a/packages/jsii-rosetta/test/record-references.test.ts b/packages/jsii-rosetta/test/record-references.test.ts index 72fd3d6bcc..db8e18f975 100644 --- a/packages/jsii-rosetta/test/record-references.test.ts +++ b/packages/jsii-rosetta/test/record-references.test.ts @@ -1,8 +1,8 @@ import { TestJsiiModule, DUMMY_JSII_CONFIG } from './testutil'; let assembly: TestJsiiModule; -beforeAll(async () => { - assembly = await TestJsiiModule.fromSource( +beforeAll(() => { + assembly = TestJsiiModule.fromSource( { 'index.ts': ` export class ClassA { diff --git a/packages/jsii-rosetta/test/syntax-counter.test.ts b/packages/jsii-rosetta/test/syntax-counter.test.ts index 2f3a424c26..003ba7bc7e 100644 --- a/packages/jsii-rosetta/test/syntax-counter.test.ts +++ b/packages/jsii-rosetta/test/syntax-counter.test.ts @@ -1,8 +1,8 @@ import { TestJsiiModule, DUMMY_JSII_CONFIG } from './testutil'; let assembly: TestJsiiModule; -beforeAll(async () => { - assembly = await TestJsiiModule.fromSource( +beforeAll(() => { + assembly = TestJsiiModule.fromSource( ` export class ClassA { public someMethod() { @@ -22,7 +22,7 @@ beforeAll(async () => { }, ); }); -afterAll(async () => assembly.cleanup()); +afterAll(() => assembly.cleanup()); test('generate syntax counter', () => { const translator = assembly.successfullyCompile(` diff --git a/packages/jsii-rosetta/test/testutil.ts b/packages/jsii-rosetta/test/testutil.ts index 1c3011da63..93a90c7606 100644 --- a/packages/jsii-rosetta/test/testutil.ts +++ b/packages/jsii-rosetta/test/testutil.ts @@ -19,16 +19,16 @@ export type MultipleSources = { [key: string]: string; 'index.ts': string }; * Compile a jsii module from source, and produce an environment in which it is available as a module */ export class TestJsiiModule { - public static async fromSource( + public static fromSource( source: string | MultipleSources, packageInfo: Partial & { name: string; main?: string; types?: string }, - ) { - const asm = await compileJsiiForTest(source, (pi) => { + ): TestJsiiModule { + const asm = compileJsiiForTest(source, (pi) => { Object.assign(pi, packageInfo); }); - const ws = await TestWorkspace.create(); - await ws.addDependency(asm); + const ws = TestWorkspace.create(); + ws.addDependency(asm); return new TestJsiiModule(asm.assembly, ws); } @@ -84,8 +84,8 @@ export class TestJsiiModule { await fs.writeJSON(path.join(this.moduleDirectory, '.jsii'), this.assembly); } - public async cleanup() { - await this.workspace.cleanup(); + public cleanup() { + this.workspace.cleanup(); } } diff --git a/packages/jsii-rosetta/test/translate.test.ts b/packages/jsii-rosetta/test/translate.test.ts index 766c8692ac..2eaf1b762f 100644 --- a/packages/jsii-rosetta/test/translate.test.ts +++ b/packages/jsii-rosetta/test/translate.test.ts @@ -184,9 +184,9 @@ test('refuse to translate object literal with function member in shorthand prope ); }); -test('declarations are translated correctly in all jsii languages', async () => { +test('declarations are translated correctly in all jsii languages', () => { // Create an assembly in a temp directory - const assembly = await TestJsiiModule.fromSource( + const assembly = TestJsiiModule.fromSource( { 'index.ts': ` export class ClassA { @@ -215,6 +215,6 @@ test('declarations are translated correctly in all jsii languages', async () => 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(); + assembly.cleanup(); } }); diff --git a/packages/jsii-rosetta/test/translations.test.ts b/packages/jsii-rosetta/test/translations.test.ts index e5f82bfacf..29ff2ba1c8 100644 --- a/packages/jsii-rosetta/test/translations.test.ts +++ b/packages/jsii-rosetta/test/translations.test.ts @@ -133,7 +133,7 @@ function stripCommonWhitespace(x: string) { /* eslint-disable-next-line @typescript-eslint/prefer-regexp-exec */ .map((l) => l.match(/(\s*)/)![1].length); const minWS = Math.min(...whitespaces); - return lines.map((l) => l.substr(minWS)).join('\n'); + return lines.map((l) => l.slice(minWS)).join('\n'); } function stripEmptyLines(x: string) { diff --git a/packages/jsii-rosetta/test/translations/expressions/map-literal.cs b/packages/jsii-rosetta/test/translations/expressions/map-literal.cs new file mode 100644 index 0000000000..f2774c2ebd --- /dev/null +++ b/packages/jsii-rosetta/test/translations/expressions/map-literal.cs @@ -0,0 +1,3 @@ +IDictionary map = new Dictionary { + { "Access-Control-Allow-Origin", "\"*\"" } +}; diff --git a/packages/jsii-rosetta/test/translations/expressions/map-literal.go b/packages/jsii-rosetta/test/translations/expressions/map-literal.go new file mode 100644 index 0000000000..8fb89ba172 --- /dev/null +++ b/packages/jsii-rosetta/test/translations/expressions/map-literal.go @@ -0,0 +1,3 @@ +map := map[string]interface{}{ + "Access-Control-Allow-Origin": jsii.String("\"*\""), +} diff --git a/packages/jsii-rosetta/test/translations/expressions/map-literal.java b/packages/jsii-rosetta/test/translations/expressions/map-literal.java new file mode 100644 index 0000000000..15f79962ca --- /dev/null +++ b/packages/jsii-rosetta/test/translations/expressions/map-literal.java @@ -0,0 +1,2 @@ +Map map = Map.of( + "Access-Control-Allow-Origin", "\"*\""); diff --git a/packages/jsii-rosetta/test/translations/expressions/map-literal.py b/packages/jsii-rosetta/test/translations/expressions/map-literal.py new file mode 100644 index 0000000000..9564689d87 --- /dev/null +++ b/packages/jsii-rosetta/test/translations/expressions/map-literal.py @@ -0,0 +1,3 @@ +map = { + "Access-Control-Allow-Origin": "\"*\"" +} diff --git a/packages/jsii-rosetta/test/translations/expressions/map-literal.ts b/packages/jsii-rosetta/test/translations/expressions/map-literal.ts new file mode 100644 index 0000000000..658638b03c --- /dev/null +++ b/packages/jsii-rosetta/test/translations/expressions/map-literal.ts @@ -0,0 +1,3 @@ +const map: { [key: string]: unknown; } = { + 'Access-Control-Allow-Origin': '"*"', +}; diff --git a/packages/jsii/bin/jsii.ts b/packages/jsii/bin/jsii.ts index a3bc2f301e..9e2a2845e9 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( @@ -90,7 +90,7 @@ const warningTypes = Object.keys(enabledWarnings); ); const { projectInfo, diagnostics: projectInfoDiagnostics } = - await loadProjectInfo(projectRoot); + loadProjectInfo(projectRoot); // disable all silenced warnings for (const key of argv['silence-warnings']) { @@ -117,7 +117,7 @@ const warningTypes = Object.keys(enabledWarnings); generateTypeScriptConfig: argv['generate-tsconfig'], }); - const emitResult = await (argv.watch ? compiler.watch() : compiler.emit()); + const emitResult = argv.watch ? compiler.watch() : compiler.emit(); const allDiagnostics = [...projectInfoDiagnostics, ...emitResult.diagnostics]; @@ -127,17 +127,14 @@ 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; const stdoutColor = !!process.stdout.isTTY; log4js.addLayout('passThroughNoColor', () => { - return (loggingEvent) => stripAnsi(util.format(...loggingEvent.data)); + return (loggingEvent) => utils.stripAnsi(util.format(...loggingEvent.data)); }); log4js.configure({ @@ -180,11 +177,3 @@ function _configureLog4js(verbosity: number) { } } } - -const ANSI_REGEX = - // eslint-disable-next-line no-control-regex - /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g; - -function stripAnsi(x: string): string { - return x.replace(ANSI_REGEX, ''); -} diff --git a/packages/jsii/lib/assembler.ts b/packages/jsii/lib/assembler.ts index 2ad44b60da..df760f05bc 100644 --- a/packages/jsii/lib/assembler.ts +++ b/packages/jsii/lib/assembler.ts @@ -48,7 +48,11 @@ export class Assembler implements Emitter { private _diagnostics = new Array(); private _deferred = new Array(); - private _types: { [fqn: string]: spec.Type } = {}; + private readonly _types = new Map(); + private readonly _packageInfoCache = new Map< + string, + PackageJson | undefined + >(); /** Map of Symbol to namespace export Symbol */ private readonly _submoduleMap = new Map(); @@ -142,8 +146,7 @@ export class Assembler implements Emitter { * * @return the result of the assembly emission. */ - public async emit(): Promise { - this._diagnostics = []; + public emit(): ts.EmitResult { if (!this.projectInfo.description) { this._diagnostics.push( JsiiDiagnostic.JSII_0001_PKG_MISSING_DESCRIPTION.createDetached(), @@ -154,7 +157,7 @@ export class Assembler implements Emitter { JsiiDiagnostic.JSII_0002_PKG_MISSING_HOMEPAGE.createDetached(), ); } - const readme = await _loadReadme.call(this); + const readme = _loadReadme.call(this); if (readme == null) { this._diagnostics.push( JsiiDiagnostic.JSII_0003_MISSING_README.createDetached(), @@ -162,10 +165,6 @@ export class Assembler implements Emitter { } const docs = _loadDocs.call(this); - this._types = {}; - this._deferred = []; - const visitPromises = new Array>(); - const sourceFile = this.program.getSourceFile(this.mainFile); if (sourceFile == null) { @@ -175,7 +174,7 @@ export class Assembler implements Emitter { ), ); } else { - await this._registerDependenciesNamespaces(sourceFile); + this._registerDependenciesNamespaces(sourceFile); if (LOG.isTraceEnabled()) { LOG.trace( @@ -187,24 +186,18 @@ export class Assembler implements Emitter { const symbol = this._typeChecker.getSymbolAtLocation(sourceFile); if (symbol) { const moduleExports = this._typeChecker.getExportsOfModule(symbol); - await Promise.all( - moduleExports.map((item) => - this._registerNamespaces(item, this.projectInfo.projectRoot), - ), + moduleExports.map((item) => + this._registerNamespaces(item, this.projectInfo.projectRoot), ); for (const node of moduleExports) { - visitPromises.push( - this._visitNode( - node.declarations[0], - new EmitContext([], this.projectInfo.stability), - ), + this._visitNode( + node.declarations[0], + new EmitContext([], this.projectInfo.stability), ); } } } - await Promise.all(visitPromises); - this.callDeferredsInOrder(); // Skip emitting if any diagnostic message is an error @@ -214,13 +207,11 @@ export class Assembler implements Emitter { ) != null ) { LOG.debug('Skipping emit due to errors.'); - // Clearing ``this._types`` to allow contents to be garbage-collected. - delete this._types; try { return { diagnostics: this._diagnostics, emitSkipped: true }; } finally { // Clearing ``this._diagnostics`` to allow contents to be garbage-collected. - delete this._diagnostics; + this._afterEmit(); } } @@ -248,7 +239,7 @@ export class Assembler implements Emitter { toDependencyClosure(this.projectInfo.dependencyClosure), ), bundled: this.projectInfo.bundleDependencies, - types: this._types, + types: Object.fromEntries(this._types), submodules: noEmptyDict(toSubmoduleDeclarations(this.mySubmodules())), targets: this.projectInfo.targets, metadata: { @@ -284,11 +275,11 @@ export class Assembler implements Emitter { } const validator = new Validator(this.projectInfo, assembly); - const validationResult = await validator.emit(); + const validationResult = validator.emit(); if (!validationResult.emitSkipped) { const assemblyPath = path.join(this.projectInfo.projectRoot, '.jsii'); LOG.trace(`Emitting assembly: ${chalk.blue(assemblyPath)}`); - await fs.writeJson(assemblyPath, _fingerprint(assembly), { + fs.writeJsonSync(assemblyPath, _fingerprint(assembly), { encoding: 'utf8', spaces: 2, }); @@ -300,18 +291,14 @@ export class Assembler implements Emitter { emitSkipped: validationResult.emitSkipped, }; } finally { - // Clearing ``this._types`` to allow contents to be garbage-collected. - delete this._types; - - // Clearing ``this._diagnostics`` to allow contents to be garbage-collected. - delete this._diagnostics; + this._afterEmit(); } - async function _loadReadme(this: Assembler) { + function _loadReadme(this: Assembler) { // Search for `README.md` in a case-insensitive way - const fileName = (await fs.readdir(this.projectInfo.projectRoot)).find( - (file) => file.toLocaleLowerCase() === 'readme.md', - ); + const fileName = fs + .readdirSync(this.projectInfo.projectRoot) + .find((file) => file.toLocaleLowerCase() === 'readme.md'); if (fileName == null) { return undefined; } @@ -329,6 +316,15 @@ export class Assembler implements Emitter { } } + private _afterEmit() { + this._diagnostics = []; + this._deferred = []; + this._types.clear(); + this._submoduleMap.clear(); + this._submodules.clear(); + this._packageInfoCache.clear(); + } + /** * Defer a callback until a (set of) types are available * @@ -402,7 +398,7 @@ export class Assembler implements Emitter { const [assm] = ref.split('.'); let type; if (assm === this.projectInfo.name) { - type = this._types[ref]; + type = this._types.get(ref); } else { const assembly = this.projectInfo.dependencyClosure.find( (dep) => dep.name === assm, @@ -450,12 +446,12 @@ export class Assembler implements Emitter { * * @returns the FQN of the type, or some "unknown" marker. */ - private async _getFQN( + private _getFQN( type: ts.Type, typeAnnotationNode: ts.Node, typeUse: TypeUseKind, isThisType: boolean, - ): Promise { + ): string { const sym = symbolFromType(type, this._typeChecker); const typeDeclaration = sym.valueDeclaration ?? sym.declarations?.[0]; @@ -500,7 +496,7 @@ export class Assembler implements Emitter { return tsName; } const [, modulePath, typeName] = groups; - const pkg = await findPackageInfo(modulePath); + const pkg = this.findPackageInfo(modulePath); if (!pkg) { if (!hasError) { this._diagnostics.push( @@ -587,7 +583,7 @@ export class Assembler implements Emitter { * * @param entryPoint the main source file for the currently compiled module. */ - private async _registerDependenciesNamespaces(entryPoint: ts.SourceFile) { + private _registerDependenciesNamespaces(entryPoint: ts.SourceFile) { for (const assm of this.projectInfo.dependencyClosure) { const resolved = ts.resolveModuleName( assm.name, @@ -611,8 +607,7 @@ export class Assembler implements Emitter { const depRoot = packageRoot(resolved.resolvedModule.resolvedFileName); for (const symbol of this._typeChecker.getExportsOfModule(depMod)) { - // eslint-disable-next-line no-await-in-loop - await this._registerNamespaces(symbol, depRoot); + this._registerNamespaces(symbol, depRoot); } } @@ -625,10 +620,7 @@ export class Assembler implements Emitter { } } - private async _registerNamespaces( - symbol: ts.Symbol, - packageRoot: string, - ): Promise { + private _registerNamespaces(symbol: ts.Symbol, packageRoot: string): void { const declaration = symbol.valueDeclaration ?? symbol.declarations[0]; if (declaration == null) { // Nothing to do here... @@ -643,7 +635,7 @@ export class Assembler implements Emitter { // // No way to configure targets - const { fqn, fqnResolutionPrefix } = await qualifiedNameOf.call( + const { fqn, fqnResolutionPrefix } = qualifiedNameOf.call( this, symbol, true, @@ -655,7 +647,7 @@ export class Assembler implements Emitter { symbolId: symbolIdentifier(this._typeChecker, symbol), locationInModule: this.declarationLocation(declaration), }); - await this._addToSubmodule(symbol, symbol, packageRoot); + this._addToSubmodule(symbol, symbol, packageRoot); return; } if (!ts.isNamespaceExport(declaration)) { @@ -716,18 +708,15 @@ export class Assembler implements Emitter { ); } - const { fqn, fqnResolutionPrefix } = await qualifiedNameOf.call( - this, - symbol, - ); - const targets = await loadSubmoduleTargetConfig(sourceFile.fileName); + const { fqn, fqnResolutionPrefix } = qualifiedNameOf.call(this, symbol); + const targets = loadSubmoduleTargetConfig(sourceFile.fileName); // There is no need to process the README file for submodules that are // external (i.e: from a dependency), as these will not be emitted in the // assembly. That'd be wasted effort, and could fail if the README file // refers to literate examples that are not packaged in the dependency. const readme = packageRoot === this.projectInfo.projectRoot - ? await loadSubmoduleReadMe( + ? loadSubmoduleReadMe( sourceFile.fileName, this.projectInfo.projectRoot, ) @@ -741,14 +730,14 @@ export class Assembler implements Emitter { symbolId: symbolIdentifier(this._typeChecker, symbol), locationInModule: this.declarationLocation(declaration), }); - await this._addToSubmodule(symbol, sourceModule, packageRoot); + this._addToSubmodule(symbol, sourceModule, packageRoot); } - async function qualifiedNameOf( + function qualifiedNameOf( this: Assembler, sym: ts.Symbol, inlineNamespace = false, - ): Promise<{ fqn: string; fqnResolutionPrefix: string }> { + ): { fqn: string; fqnResolutionPrefix: string } { if (this._submoduleMap.has(sym)) { const parent = this._submodules.get(this._submoduleMap.get(sym)!)!; const fqn = `${parent.fqn}.${sym.name}`; @@ -763,7 +752,7 @@ export class Assembler implements Emitter { .getDeclarations()?.[0] ?.getSourceFile()?.fileName; const pkgInfo = symbolLocation - ? await findPackageInfo(symbolLocation) + ? this.findPackageInfo(symbolLocation) : undefined; const assemblyName: string = pkgInfo?.name ?? this.projectInfo.name; const fqn = `${assemblyName}.${sym.name}`; @@ -773,14 +762,14 @@ export class Assembler implements Emitter { }; } - async function loadSubmoduleTargetConfig( + function loadSubmoduleTargetConfig( submoduleMain: string, - ): Promise { + ): SubmoduleSpec['targets'] { const jsiirc = path.resolve(submoduleMain, '..', '.jsiirc.json'); - if (!(await fs.pathExists(jsiirc))) { + if (!fs.pathExistsSync(jsiirc)) { return undefined; } - const data = await fs.readJson(jsiirc); + const data = fs.readJsonSync(jsiirc); return data.targets; } @@ -793,10 +782,10 @@ export class Assembler implements Emitter { * If the submodule is loaded from a file, like `mymodule.[d.]ts`, we will load * `mymodule.README.md`. */ - async function loadSubmoduleReadMe( + function loadSubmoduleReadMe( submoduleMain: string, projectRoot: string, - ): Promise { + ): SubmoduleSpec['readme'] { const fileBase = path.basename(submoduleMain).replace(/(\.d)?\.ts$/, ''); const readMeName = fileBase === 'index' ? `README.md` : `${fileBase}.README.md`; @@ -814,7 +803,7 @@ export class Assembler implements Emitter { * @param moduleLike the module-like symbol bound to the submodule. * @param packageRoot the root of the package being traversed. */ - private async _addToSubmodule( + private _addToSubmodule( ns: ts.Symbol, moduleLike: ts.Symbol, packageRoot: string, @@ -879,14 +868,14 @@ export class Assembler implements Emitter { } if (type.symbol.exports) { // eslint-disable-next-line no-await-in-loop - await this._addToSubmodule(ns, symbol, packageRoot); + this._addToSubmodule(ns, symbol, packageRoot); } } else if (ts.isModuleDeclaration(decl)) { // eslint-disable-next-line no-await-in-loop - await this._registerNamespaces(symbol, packageRoot); + this._registerNamespaces(symbol, packageRoot); } else if (ts.isNamespaceExport(decl)) { // eslint-disable-next-line no-await-in-loop - await this._registerNamespaces(symbol, packageRoot); + this._registerNamespaces(symbol, packageRoot); } } } @@ -899,10 +888,7 @@ export class Assembler implements Emitter { * @param namePrefix the prefix for the types' namespaces */ // eslint-disable-next-line complexity - private async _visitNode( - node: ts.Declaration, - context: EmitContext, - ): Promise { + private _visitNode(node: ts.Declaration, context: EmitContext): spec.Type[] { if (ts.isNamespaceExport(node)) { // export * as ns from 'module'; // Note: the "ts.NamespaceExport" refers to the "export * as ns" part of @@ -921,11 +907,9 @@ export class Assembler implements Emitter { } const nsContext = context.appendNamespace(node.name.text); - const promises = new Array>(); - for (const child of this._typeChecker.getExportsOfModule(symbol)) { - promises.push(this._visitNode(child.declarations[0], nsContext)); - } - const allTypes = flattenPromises(promises); + const allTypes = this._typeChecker + .getExportsOfModule(symbol) + .flatMap((child) => this._visitNode(child.declarations[0], nsContext)); if (LOG.isTraceEnabled()) { LOG.trace( @@ -964,7 +948,7 @@ export class Assembler implements Emitter { // export class Name { ... } this._validateHeritageClauses(node.heritageClauses); - jsiiType = await this._visitClass( + jsiiType = this._visitClass( this._typeChecker.getTypeAtLocation(node), context, ); @@ -974,13 +958,13 @@ export class Assembler implements Emitter { } else if (ts.isInterfaceDeclaration(node) && _isExported(node)) { // export interface Name { ... } this._validateHeritageClauses(node.heritageClauses); - jsiiType = await this._visitInterface( + jsiiType = this._visitInterface( this._typeChecker.getTypeAtLocation(node), context, ); } else if (ts.isEnumDeclaration(node) && _isExported(node)) { // export enum Name { ... } - jsiiType = await this._visitEnum( + jsiiType = this._visitEnum( this._typeChecker.getTypeAtLocation(node), context, ); @@ -997,16 +981,14 @@ export class Assembler implements Emitter { ); } - const allTypesPromises = new Array>(); - for (const prop of this._typeChecker.getExportsOfModule(symbol)) { - allTypesPromises.push( + const allTypes = this._typeChecker + .getExportsOfModule(symbol) + .flatMap((prop) => this._visitNode( prop.declarations[0], context.appendNamespace(node.name.getText()), ), ); - } - const allTypes = await flattenPromises(allTypesPromises); if (LOG.isTraceEnabled()) { LOG.trace( @@ -1071,7 +1053,7 @@ export class Assembler implements Emitter { )}`, ); } - this._types[jsiiType.fqn] = jsiiType; + this._types.set(jsiiType.fqn, jsiiType); jsiiType.locationInModule = this.declarationLocation(node); const type = this._typeChecker.getTypeAtLocation(node); @@ -1083,7 +1065,7 @@ export class Assembler implements Emitter { .map((exportedNode) => this._visitNode(exportedNode.declarations[0], nestedContext), ); - for (const nestedTypes of await Promise.all(visitedNodes)) { + for (const nestedTypes of visitedNodes) { for (const nestedType of nestedTypes) { if (nestedType.namespace !== nestedContext.namespace.join('.')) { this._diagnostics.push( @@ -1157,7 +1139,7 @@ export class Assembler implements Emitter { }; } - private async _processBaseInterfaces(fqn: string, baseTypes?: ts.Type[]) { + private _processBaseInterfaces(fqn: string, baseTypes?: ts.Type[]) { const erasedBases = new Array(); if (!baseTypes) { return { erasedBases }; @@ -1184,12 +1166,12 @@ export class Assembler implements Emitter { processBaseTypes(baseTypes); - const typeRefs = Array.from(baseInterfaces).map(async (iface) => { + const typeRefs = Array.from(baseInterfaces).map((iface) => { const decl = iface.symbol.valueDeclaration; - const typeRef = await this._typeReference(iface, decl, 'base interface'); + const typeRef = this._typeReference(iface, decl, 'base interface'); return { decl, typeRef }; }); - for (const { decl, typeRef } of await Promise.all(typeRefs)) { + for (const { decl, typeRef } of typeRefs) { if (!spec.isNamedTypeReference(typeRef)) { this._diagnostics.push( JsiiDiagnostic.JSII_3005_TYPE_USED_AS_INTERFACE.create(decl, typeRef), @@ -1218,10 +1200,10 @@ export class Assembler implements Emitter { } // eslint-disable-next-line complexity - private async _visitClass( + private _visitClass( type: ts.Type, ctx: EmitContext, - ): Promise { + ): spec.ClassType | undefined { if (LOG.isTraceEnabled()) { LOG.trace( `Processing class: ${chalk.gray(ctx.namespace.join('.'))}.${chalk.cyan( @@ -1284,7 +1266,7 @@ export class Assembler implements Emitter { } // eslint-disable-next-line no-await-in-loop - const ref = await this._typeReference( + const ref = this._typeReference( base, type.symbol.valueDeclaration, 'base class', @@ -1354,7 +1336,7 @@ export class Assembler implements Emitter { clause.types.map((t) => this._getTypeFromTypeNode(t)), ), ); - for (const { interfaces } of await Promise.all(baseInterfaces)) { + for (const { interfaces } of baseInterfaces) { for (const ifc of interfaces ?? []) { allInterfaces.add(ifc.fqn); } @@ -1443,7 +1425,7 @@ export class Assembler implements Emitter { ts.isMethodSignature(memberDecl) ) { // eslint-disable-next-line no-await-in-loop - await this._visitMethod( + this._visitMethod( member, jsiiType, ctx.replaceStability(jsiiType.docs?.stability), @@ -1455,7 +1437,7 @@ export class Assembler implements Emitter { ts.isAccessor(memberDecl) ) { // eslint-disable-next-line no-await-in-loop - await this._visitProperty( + this._visitProperty( member, jsiiType, ctx.replaceStability(jsiiType.docs?.stability), @@ -1501,7 +1483,7 @@ export class Assembler implements Emitter { jsiiType.initializer.parameters ?? []; jsiiType.initializer.parameters.push( // eslint-disable-next-line no-await-in-loop - await this._toParameter( + this._toParameter( param, ctx.replaceStability(jsiiType.docs?.stability), ), @@ -1536,7 +1518,7 @@ export class Assembler implements Emitter { !this._isPrivateOrInternal(param) ) { // eslint-disable-next-line no-await-in-loop - await this._visitProperty( + this._visitProperty( param, jsiiType, memberEmitContext, @@ -1713,10 +1695,10 @@ export class Assembler implements Emitter { return true; } - private async _visitEnum( + private _visitEnum( type: ts.Type, ctx: EmitContext, - ): Promise { + ): spec.EnumType | undefined { if (LOG.isTraceEnabled()) { LOG.trace( `Processing enum: ${chalk.gray(ctx.namespace.join('.'))}.${chalk.cyan( @@ -1741,7 +1723,7 @@ export class Assembler implements Emitter { } if (_hasInternalJsDocTag(symbol)) { - return Promise.resolve(undefined); + return undefined; } this._warnAboutReservedWords(symbol); @@ -1785,7 +1767,7 @@ export class Assembler implements Emitter { decl, ); - return Promise.resolve(jsiiType); + return jsiiType; } /** @@ -1859,10 +1841,10 @@ export class Assembler implements Emitter { } } - private async _visitInterface( + private _visitInterface( type: ts.Type, ctx: EmitContext, - ): Promise { + ): spec.InterfaceType | undefined { if (LOG.isTraceEnabled()) { LOG.trace( `Processing interface: ${chalk.gray( @@ -1895,7 +1877,7 @@ export class Assembler implements Emitter { type.symbol.declarations[0] as ts.InterfaceDeclaration, ); - const { interfaces, erasedBases } = await this._processBaseInterfaces( + const { interfaces, erasedBases } = this._processBaseInterfaces( fqn, type.getBaseTypes(), ); @@ -1925,7 +1907,7 @@ export class Assembler implements Emitter { ts.isMethodSignature(member.valueDeclaration) ) { // eslint-disable-next-line no-await-in-loop - await this._visitMethod( + this._visitMethod( member, jsiiType, ctx.replaceStability(jsiiType.docs?.stability), @@ -1938,7 +1920,7 @@ export class Assembler implements Emitter { ts.isAccessor(member.valueDeclaration) ) { // eslint-disable-next-line no-await-in-loop - await this._visitProperty( + this._visitProperty( member, jsiiType, ctx.replaceStability(jsiiType.docs?.stability), @@ -2083,7 +2065,7 @@ export class Assembler implements Emitter { return _sortMembers(jsiiType); } - private async _visitMethod( + private _visitMethod( symbol: ts.Symbol, type: spec.ClassType | spec.InterfaceType, ctx: EmitContext, @@ -2138,10 +2120,9 @@ export class Assembler implements Emitter { } this._warnAboutReservedWords(symbol); - const parameters = await Promise.all( - signature.getParameters().map((p) => this._toParameter(p, ctx)), - ); - + const parameters = signature + .getParameters() + .map((p) => this._toParameter(p, ctx)); const returnType = signature.getReturnType(); const method: spec.Method = bindings.setMethodRelatedNode( { @@ -2151,11 +2132,7 @@ export class Assembler implements Emitter { protected: _isProtected(symbol) || undefined, returns: _isVoid(returnType) ? undefined - : await this._optionalValue( - returnType, - declaration.name, - 'return type', - ), + : this._optionalValue(returnType, declaration.name, 'return type'), async: _isPromise(returnType) || undefined, static: _isStatic(symbol) || undefined, locationInModule: this.declarationLocation(declaration), @@ -2238,7 +2215,7 @@ export class Assembler implements Emitter { } } - private async _visitProperty( + private _visitProperty( symbol: ts.Symbol, type: spec.ClassType | spec.InterfaceType, ctx: EmitContext, @@ -2296,11 +2273,11 @@ export class Assembler implements Emitter { const property: spec.Property = bindings.setPropertyRelatedNode( { - ...(await this._optionalValue( + ...this._optionalValue( this._typeChecker.getTypeOfSymbolAtLocation(symbol, signature), signature.name, 'property type', - )), + ), abstract: _isAbstract(symbol, type) || undefined, name: symbol.name, protected: _isProtected(symbol) || undefined, @@ -2352,10 +2329,10 @@ export class Assembler implements Emitter { type.properties.push(property); } - private async _toParameter( + private _toParameter( paramSymbol: ts.Symbol, ctx: EmitContext, - ): Promise { + ): spec.Parameter { if (LOG.isTraceEnabled()) { LOG.trace(`Processing parameter: ${chalk.cyan(paramSymbol.name)}`); } @@ -2366,11 +2343,11 @@ export class Assembler implements Emitter { const parameter: spec.Parameter = bindings.setParameterRelatedNode( { - ...(await this._optionalValue( + ...this._optionalValue( this._typeChecker.getTypeAtLocation(paramDeclaration), paramDeclaration.name, 'parameter type', - )), + ), name: paramSymbol.name, variadic: paramDeclaration.dotDotDotToken && true, }, @@ -2396,12 +2373,12 @@ export class Assembler implements Emitter { return parameter; } - private async _typeReference( + private _typeReference( type: ts.Type, declaration: ts.Node, purpose: TypeUseKind, - ): Promise { - const optionalValue = await this._optionalValue(type, declaration, purpose); + ): spec.TypeReference { + const optionalValue = this._optionalValue(type, declaration, purpose); if (optionalValue.optional) { this._diagnostics.push( JsiiDiagnostic.JSII_3999_INCOHERENT_TYPE_MODEL.create( @@ -2413,11 +2390,11 @@ export class Assembler implements Emitter { return optionalValue.type; } - private async _optionalValue( + private _optionalValue( type: ts.Type, declaration: ts.Node, purpose: TypeUseKind, - ): Promise { + ): spec.OptionalValue { const isThisType = _isThisType(type, this._typeChecker); if (type.isLiteral() && _isEnumLike(type)) { @@ -2443,11 +2420,11 @@ export class Assembler implements Emitter { } if (type.symbol.name === 'Array') { - return { type: await _arrayType.call(this) }; + return { type: _arrayType.call(this) }; } if (type.symbol.name === '__type' && type.symbol.members) { - return { type: await _mapType.call(this) }; + return { type: _mapType.call(this) }; } if (type.symbol.escapedName === 'Promise') { @@ -2459,7 +2436,7 @@ export class Assembler implements Emitter { return { type: spec.CANONICAL_ANY }; } return { - type: await this._typeReference( + type: this._typeReference( typeRef.typeArguments[0], declaration, purpose, @@ -2468,17 +2445,15 @@ export class Assembler implements Emitter { } return { - type: { fqn: await this._getFQN(type, declaration, purpose, isThisType) }, + type: { fqn: this._getFQN(type, declaration, purpose, isThisType) }, }; - async function _arrayType( - this: Assembler, - ): Promise { + function _arrayType(this: Assembler): spec.CollectionTypeReference { const typeRef = type as ts.TypeReference; let elementtype: spec.TypeReference; if (typeRef.typeArguments?.length === 1) { - elementtype = await this._typeReference( + elementtype = this._typeReference( typeRef.typeArguments[0], declaration, 'list element type', @@ -2504,13 +2479,11 @@ export class Assembler implements Emitter { }; } - async function _mapType( - this: Assembler, - ): Promise { + function _mapType(this: Assembler): spec.CollectionTypeReference { let elementtype: spec.TypeReference; const objectType = type.getStringIndexType(); if (objectType) { - elementtype = await this._typeReference( + elementtype = this._typeReference( objectType, declaration, 'map element type', @@ -2564,7 +2537,7 @@ export class Assembler implements Emitter { return undefined; } - async function _unionType(this: Assembler): Promise { + function _unionType(this: Assembler): spec.OptionalValue { const types = new Array(); let optional: boolean | undefined; @@ -2574,11 +2547,7 @@ export class Assembler implements Emitter { continue; } // eslint-disable-next-line no-await-in-loop - const resolvedType = await this._typeReference( - subType, - declaration, - purpose, - ); + const resolvedType = this._typeReference(subType, declaration, purpose); if (types.find((ref) => deepEqual(ref, resolvedType)) != null) { continue; } @@ -2708,6 +2677,31 @@ export class Assembler implements Emitter { m.fqn.startsWith(`${this.projectInfo.name}.`), ); } + + private findPackageInfo(fromDir: string): PackageJson | undefined { + if (this._packageInfoCache.has(fromDir)) { + return this._packageInfoCache.get(fromDir); + } + + const packageInfo = _findPackageInfo.call(this, fromDir); + this._packageInfoCache.set(fromDir, packageInfo); + return packageInfo; + + function _findPackageInfo( + this: Assembler, + fromDir: string, + ): PackageJson | undefined { + const filePath = path.join(fromDir, 'package.json'); + if (fs.pathExistsSync(filePath)) { + return fs.readJsonSync(filePath); + } + const parent = path.dirname(fromDir); + if (parent === fromDir) { + return undefined; + } + return this.findPackageInfo(parent); + } + } } export interface AssemblerOptions { @@ -3164,14 +3158,6 @@ class EmitContext { } } -async function flattenPromises(promises: Array>): Promise { - const result = new Array(); - for (const subset of await Promise.all(promises)) { - result.push(...subset); - } - return result; -} - function inferRootDir(program: ts.Program): string | undefined { const directories = program .getRootFileNames() @@ -3240,20 +3226,6 @@ function isSingleValuedEnum( return false; } -async function findPackageInfo( - fromDir: string, -): Promise { - const filePath = path.join(fromDir, 'package.json'); - if (await fs.pathExists(filePath)) { - return fs.readJson(filePath); - } - const parent = path.dirname(fromDir); - if (parent === fromDir) { - return undefined; - } - return findPackageInfo(parent); -} - /** * Checks is the provided type is "this" (as a type annotation). * @@ -3374,18 +3346,18 @@ function isUnder(file: string, dir: string): boolean { return !relative.startsWith(path.sep) && !relative.startsWith('..'); } -async function loadAndRenderReadme(readmePath: string, projectRoot: string) { - if (!(await fs.pathExists(readmePath))) { +function loadAndRenderReadme(readmePath: string, projectRoot: string) { + if (!fs.pathExistsSync(readmePath)) { return undefined; } return { - markdown: ( - await literate.includeAndRenderExamples( - await literate.loadFromFile(readmePath), + markdown: literate + .includeAndRenderExamples( + literate.loadFromFile(readmePath), literate.fileSystemLoader(path.dirname(readmePath)), projectRoot, ) - ).join('\n'), + .join('\n'), }; } diff --git a/packages/jsii/lib/compiler.ts b/packages/jsii/lib/compiler.ts index 9b2447312b..bbc43ea227 100644 --- a/packages/jsii/lib/compiler.ts +++ b/packages/jsii/lib/compiler.ts @@ -107,8 +107,8 @@ export class Compiler implements Emitter { * * @param files can be specified to override the standard source code location logic. Useful for example when testing "negatives". */ - public async emit(...files: string[]): Promise { - await this._prepareForBuild(...files); + public emit(...files: string[]): ts.EmitResult { + this._prepareForBuild(...files); return this._buildOnce(); } @@ -118,18 +118,16 @@ export class Compiler implements Emitter { * * @internal */ - public async watch( - opts: NonBlockingWatchOptions, - ): Promise>; + public watch(opts: NonBlockingWatchOptions): ts.Watch; /** * Watches for file-system changes and dynamically recompiles the project as needed. In blocking mode, this results * in a never-resolving promise. */ - public async watch(): Promise; - public async watch( + public watch(): never; + public watch( opts?: NonBlockingWatchOptions, - ): Promise | never> { - await this._prepareForBuild(); + ): ts.Watch | never { + this._prepareForBuild(); const pi = this.options.projectInfo; const projectRoot = pi.projectRoot; @@ -160,8 +158,8 @@ export class Compiler implements Emitter { // cause an unhandled promise rejection warning, but that's not a big deal. // // eslint-disable-next-line @typescript-eslint/no-misused-promises - host.afterProgramCreate = async (builderProgram) => { - const emitResult = await this._consumeProgram( + host.afterProgramCreate = (builderProgram) => { + const emitResult = this._consumeProgram( builderProgram.getProgram(), host.getDefaultLibLocation!(), ); @@ -176,7 +174,7 @@ export class Compiler implements Emitter { orig.call(host, builderProgram); } if (opts?.compilationComplete) { - await opts.compilationComplete(emitResult); + opts.compilationComplete(emitResult); } }; const watch = ts.createWatchProgram(host); @@ -186,7 +184,7 @@ export class Compiler implements Emitter { return watch; } // In blocking mode, returns a never-resolving promise. - return new Promise(() => null); + return undefined as never; } /** @@ -195,16 +193,16 @@ export class Compiler implements Emitter { * * @param files the files that were specified as input in the CLI invocation. */ - private async _prepareForBuild(...files: string[]) { - await this.buildTypeScriptConfig(); - await this.writeTypeScriptConfig(); + private _prepareForBuild(...files: string[]) { + this.buildTypeScriptConfig(); + this.writeTypeScriptConfig(); this.rootFiles = this.determineSources(files); } /** * Do a single build */ - private async _buildOnce(): Promise { + private _buildOnce(): ts.EmitResult { if (!this.compilerHost.getDefaultLibLocation) { throw new Error( 'No default library location was found on the TypeScript compiler host!', @@ -233,10 +231,7 @@ export class Compiler implements Emitter { ); } - private async _consumeProgram( - program: ts.Program, - stdlib: string, - ): Promise { + private _consumeProgram(program: ts.Program, stdlib: string): ts.EmitResult { const diagnostics = [...ts.getPreEmitDiagnostics(program)]; let hasErrors = false; @@ -256,7 +251,7 @@ export class Compiler implements Emitter { }); try { - const assmEmit = await assembler.emit(); + const assmEmit = assembler.emit(); if ( !hasErrors && (assmEmit.emitSkipped || @@ -329,10 +324,10 @@ export class Compiler implements Emitter { * * This is the object that will be written to disk. */ - private async buildTypeScriptConfig() { + private buildTypeScriptConfig() { let references: string[] | undefined; if (this.projectReferences) { - references = await this.findProjectReferences(); + references = this.findProjectReferences(); } const pi = this.options.projectInfo; @@ -378,15 +373,15 @@ export class Compiler implements Emitter { * * @return the fully qualified path to the `tsconfig.json` file */ - private async writeTypeScriptConfig(): Promise { + private writeTypeScriptConfig(): void { const commentKey = '_generated_by_jsii_'; const commentValue = 'Generated by jsii - safe to delete, and ideally should be in .gitignore'; (this.typescriptConfig as any)[commentKey] = commentValue; - if (await fs.pathExists(this.configPath)) { - const currentConfig = await fs.readJson(this.configPath); + if (fs.pathExistsSync(this.configPath)) { + const currentConfig = fs.readJsonSync(this.configPath); if (!(commentKey in currentConfig)) { throw new Error( `A '${this.configPath}' file that was not generated by jsii is in ${this.options.projectInfo.projectRoot}. Aborting instead of overwriting.`, @@ -418,7 +413,7 @@ export class Compiler implements Emitter { }; LOG.debug(`Creating or updating ${chalk.blue(this.configPath)}`); - await fs.writeJson(this.configPath, outputConfig, { + fs.writeJsonSync(this.configPath, outputConfig, { encoding: 'utf8', spaces: 2, }); @@ -454,7 +449,7 @@ export class Compiler implements Emitter { * if there's an "index" tsconfig.json of all projects somewhere up the directory * tree) */ - private async findProjectReferences(): Promise { + private findProjectReferences(): string[] { const pkg = this.options.projectInfo.packageJson; const ret = new Array(); @@ -473,10 +468,8 @@ export class Compiler implements Emitter { ); } - for (const tsconfigFile of await Promise.all( - Array.from(dependencyNames).map((depName) => - this.findMonorepoPeerTsconfig(depName), - ), + for (const tsconfigFile of Array.from(dependencyNames).map((depName) => + this.findMonorepoPeerTsconfig(depName), )) { if (!tsconfigFile) { continue; @@ -552,9 +545,7 @@ export class Compiler implements Emitter { * * Returns undefined if no such tsconfig could be found. */ - private async findMonorepoPeerTsconfig( - depName: string, - ): Promise { + private findMonorepoPeerTsconfig(depName: string): string | undefined { // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires const { builtinModules } = require('module'); if ((builtinModules ?? []).includes(depName)) { @@ -563,18 +554,18 @@ export class Compiler implements Emitter { } try { - const depDir = await utils.findDependencyDirectory( + const depDir = utils.findDependencyDirectory( depName, this.options.projectInfo.projectRoot, ); const dep = path.join(depDir, 'tsconfig.json'); - if (!(await fs.pathExists(dep))) { + if (!fs.pathExistsSync(dep)) { return undefined; } // Resolve symlinks, to check if this is a monorepo peer - const dependencyRealPath = await fs.realpath(dep); + const dependencyRealPath = fs.realpathSync(dep); if (dependencyRealPath.split(path.sep).includes('node_modules')) { return undefined; } @@ -625,9 +616,7 @@ export interface NonBlockingWatchOptions { /** * This hook gets invoked when a compilation cycle (complete with Assembler execution) completes. */ - readonly compilationComplete: ( - emitResult: ts.EmitResult, - ) => void | Promise; + readonly compilationComplete: (emitResult: ts.EmitResult) => void; } function _pathOfLibraries( diff --git a/packages/jsii/lib/docs.ts b/packages/jsii/lib/docs.ts index dde213cdc2..9af1421c00 100644 --- a/packages/jsii/lib/docs.ts +++ b/packages/jsii/lib/docs.ts @@ -207,7 +207,7 @@ export function splitSummary( return [undefined, undefined]; } const summary = summaryLine(docBlock); - const remarks = uberTrim(docBlock.substr(summary.length)); + const remarks = uberTrim(docBlock.slice(summary.length)); return [endWithPeriod(noNewlines(summary.trim())), remarks]; } diff --git a/packages/jsii/lib/emitter.ts b/packages/jsii/lib/emitter.ts index e917178aaa..cb030d5d60 100644 --- a/packages/jsii/lib/emitter.ts +++ b/packages/jsii/lib/emitter.ts @@ -9,5 +9,5 @@ export interface Emitter { * * @return the result of attempting to emit stuff. */ - emit(): Promise; + emit(): ts.EmitResult; } diff --git a/packages/jsii/lib/helpers.ts b/packages/jsii/lib/helpers.ts index 5f5bd579cc..4e3300310f 100644 --- a/packages/jsii/lib/helpers.ts +++ b/packages/jsii/lib/helpers.ts @@ -35,11 +35,11 @@ export type MultipleSourceFiles = { * @param options accepts a callback for historical reasons but really expects to * take an options object. */ -export async function sourceToAssemblyHelper( +export function sourceToAssemblyHelper( source: string | MultipleSourceFiles, options?: TestCompilationOptions | ((obj: PackageJson) => void), -): Promise { - return (await compileJsiiForTest(source, options)).assembly; +): spec.Assembly { + return compileJsiiForTest(source, options).assembly; } export interface HelperCompilationResult { @@ -68,11 +68,11 @@ export interface HelperCompilationResult { * @param options accepts a callback for historical reasons but really expects to * take an options object. */ -export async function compileJsiiForTest( +export function compileJsiiForTest( source: string | { 'index.ts': string; [name: string]: string }, options?: TestCompilationOptions | ((obj: PackageJson) => void), compilerOptions?: Omit, -): Promise { +): HelperCompilationResult { if (typeof source === 'string') { source = { 'index.ts': source }; } @@ -84,14 +84,12 @@ export async function compileJsiiForTest( // Easiest way to get the source into the compiler is to write it to disk somewhere. // I guess we could make an in-memory compiler host but that seems like work... - return inSomeLocation(async () => { - await Promise.all( - Object.entries(source).map(async ([fileName, content]) => { - await fs.mkdirp(path.dirname(fileName)); - return fs.writeFile(fileName, content, { encoding: 'utf-8' }); - }), - ); - const { projectInfo, packageJson } = await makeProjectInfo( + return inSomeLocation(() => { + Object.entries(source).forEach(([fileName, content]) => { + fs.mkdirpSync(path.dirname(fileName)); + fs.writeFileSync(fileName, content, { encoding: 'utf-8' }); + }); + const { projectInfo, packageJson } = makeProjectInfo( 'index.ts', typeof options === 'function' ? options @@ -106,7 +104,7 @@ export async function compileJsiiForTest( projectInfo, ...compilerOptions, }); - const emitResult = await compiler.emit(); + const emitResult = compiler.emit(); const errors = emitResult.diagnostics.filter( (d) => d.category === DiagnosticCategory.Error, @@ -118,7 +116,7 @@ export async function compileJsiiForTest( if (errors.length > 0 || emitResult.emitSkipped) { throw new Error('There were compiler errors'); } - const assembly = await fs.readJSON('.jsii', { encoding: 'utf-8' }); + const assembly = fs.readJsonSync('.jsii', { encoding: 'utf-8' }); const files: Record = {}; for (const filename of Object.keys(source)) { @@ -130,14 +128,14 @@ export async function compileJsiiForTest( } // eslint-disable-next-line no-await-in-loop - files[jsFile] = await fs.readFile(jsFile, { encoding: 'utf-8' }); + files[jsFile] = fs.readFileSync(jsFile, { encoding: 'utf-8' }); // eslint-disable-next-line no-await-in-loop - files[dtsFile] = await fs.readFile(dtsFile, { encoding: 'utf-8' }); + files[dtsFile] = fs.readFileSync(dtsFile, { encoding: 'utf-8' }); const warningsFileName = '.warnings.jsii.js'; if (fs.existsSync(warningsFileName)) { // eslint-disable-next-line no-await-in-loop - files[warningsFileName] = await fs.readFile(warningsFileName, { + files[warningsFileName] = fs.readFileSync(warningsFileName, { encoding: 'utf-8', }); } @@ -147,23 +145,23 @@ export async function compileJsiiForTest( }); } -async function inTempDir(block: () => Promise): Promise { +function inTempDir(block: () => T): T { const origDir = process.cwd(); - const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), 'jsii')); + const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jsii')); process.chdir(tmpDir); - const ret = await block(); + const ret = block(); process.chdir(origDir); - await fs.remove(tmpDir); + fs.removeSync(tmpDir); return ret; } function inOtherDir(dir: string) { // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint - return async (block: () => Promise): Promise => { + return (block: () => T): T => { const origDir = process.cwd(); process.chdir(dir); try { - return await block(); + return block(); } finally { process.chdir(origDir); } @@ -179,10 +177,10 @@ function inOtherDir(dir: string) { * Most consistent behavior seems to be to write a package.json to disk and * then calling the same functions as the CLI would. */ -async function makeProjectInfo( +function makeProjectInfo( types: string, - cb?: (obj: PackageJson) => Promise | void, -): Promise<{ projectInfo: ProjectInfo; packageJson: PackageJson }> { + cb?: (obj: PackageJson) => void, +): { projectInfo: ProjectInfo; packageJson: PackageJson } { const packageJson: PackageJson = { types, main: types.replace(/(?:\.d)?\.ts(x?)/, '.js$1'), @@ -195,18 +193,16 @@ async function makeProjectInfo( }; if (cb) { - await cb(packageJson); + cb(packageJson); } - await fs.writeJson('package.json', packageJson, { + fs.writeJsonSync('package.json', packageJson, { encoding: 'utf-8', replacer: (_: string, v: any) => v, spaces: 2, }); - const { projectInfo } = await loadProjectInfo( - path.resolve(process.cwd(), '.'), - ); + const { projectInfo } = loadProjectInfo(path.resolve(process.cwd(), '.')); return { projectInfo, packageJson }; } export interface TestCompilationOptions { @@ -245,25 +241,21 @@ export class TestWorkspace { * * Creates a temporary directory, don't forget to call cleanUp */ - public static async create(): Promise { - const tmpDir = await fs.mkdtemp( - path.join(os.tmpdir(), 'jsii-testworkspace'), - ); - await fs.ensureDir(tmpDir); + public static create(): TestWorkspace { + const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jsii-testworkspace')); + fs.ensureDirSync(tmpDir); return new TestWorkspace(tmpDir); } /** * Execute a block with a temporary workspace */ - public static async withWorkspace( - block: (ws: TestWorkspace) => A | Promise, - ): Promise { - const ws = await TestWorkspace.create(); + public static withWorkspace(block: (ws: TestWorkspace) => A): A { + const ws = TestWorkspace.create(); try { - return await block(ws); + return block(ws); } finally { - await ws.cleanup(); + ws.cleanup(); } } @@ -274,7 +266,7 @@ export class TestWorkspace { /** * Add a test-compiled jsii assembly as a dependency */ - public async addDependency(dependencyAssembly: HelperCompilationResult) { + public addDependency(dependencyAssembly: HelperCompilationResult) { if (this.installed.has(dependencyAssembly.assembly.name)) { throw new Error( `A dependency with name '${dependencyAssembly.assembly.name}' was already installed. Give one a different name.`, @@ -293,10 +285,10 @@ export class TestWorkspace { 'node_modules', dependencyAssembly.assembly.name, ); - await fs.ensureDir(modDir); + fs.ensureDirSync(modDir); - await fs.writeJSON(path.join(modDir, '.jsii'), dependencyAssembly.assembly); - await fs.writeJSON( + fs.writeJsonSync(path.join(modDir, '.jsii'), dependencyAssembly.assembly); + fs.writeJsonSync( path.join(modDir, 'package.json'), dependencyAssembly.packageJson, ); @@ -305,9 +297,9 @@ export class TestWorkspace { dependencyAssembly.files, )) { // eslint-disable-next-line no-await-in-loop - await fs.ensureDir(path.dirname(path.join(modDir, fileName))); + fs.ensureDirSync(path.dirname(path.join(modDir, fileName))); // eslint-disable-next-line no-await-in-loop - await fs.writeFile(path.join(modDir, fileName), fileContents); + fs.writeFileSync(path.join(modDir, fileName), fileContents); } } @@ -318,8 +310,8 @@ export class TestWorkspace { return path.join(this.rootDirectory, 'node_modules', name); } - public async cleanup() { - await fs.remove(this.rootDirectory); + public cleanup() { + fs.removeSync(this.rootDirectory); } } diff --git a/packages/jsii/lib/literate.ts b/packages/jsii/lib/literate.ts index 5d6b812989..c4edde4717 100644 --- a/packages/jsii/lib/literate.ts +++ b/packages/jsii/lib/literate.ts @@ -76,9 +76,7 @@ export interface LoadedFile { readonly lines: string[]; } -export type FileLoader = ( - relativePath: string, -) => LoadedFile | Promise; +export type FileLoader = (relativePath: string) => LoadedFile; /** * Given MarkDown source, find source files to include and render @@ -88,11 +86,11 @@ export type FileLoader = ( * * [example](test/integ.bucket.ts) */ -export async function includeAndRenderExamples( +export function includeAndRenderExamples( lines: string[], loader: FileLoader, projectRoot: string, -): Promise { +): string[] { const ret: string[] = []; const regex = /^\[([^\]]*)\]\(([^)]+\.lit\.ts)\)/i; @@ -102,7 +100,7 @@ export async function includeAndRenderExamples( // Found an include const filename = m[2]; // eslint-disable-next-line no-await-in-loop - const { lines: source, fullPath } = await loader(filename); + const { lines: source, fullPath } = loader(filename); // 'lit' source attribute will make snippet compiler know to extract the same source // Needs to be relative to the project root. const imported = typescriptSourceToMarkdown(source, [ @@ -120,8 +118,8 @@ export async function includeAndRenderExamples( /** * Load a file into a string array */ -export async function loadFromFile(fileName: string): Promise { - const content = await fs.readFile(fileName, { encoding: 'utf-8' }); +export function loadFromFile(fileName: string): string[] { + const content = fs.readFileSync(fileName, { encoding: 'utf-8' }); return contentToLines(content); } @@ -136,9 +134,9 @@ export function contentToLines(content: string): string[] { * Return a file system loader given a base directory */ export function fileSystemLoader(directory: string): FileLoader { - return async (fileName) => { + return (fileName) => { const fullPath = path.resolve(directory, fileName); - return { fullPath, lines: await loadFromFile(fullPath) }; + return { fullPath, lines: loadFromFile(fullPath) }; }; } @@ -182,7 +180,7 @@ function stripCommonIndent(lines: string[]): string[] { const leadingWhitespace = /^(\s*)/; const indents = lines.map((l) => leadingWhitespace.exec(l)![1].length); const commonIndent = Math.min(...indents); - return lines.map((l) => l.substr(commonIndent)); + return lines.map((l) => l.slice(commonIndent)); } /** diff --git a/packages/jsii/lib/project-info.ts b/packages/jsii/lib/project-info.ts index 8f0e6611f7..9c0af8a8ef 100644 --- a/packages/jsii/lib/project-info.ts +++ b/packages/jsii/lib/project-info.ts @@ -64,12 +64,10 @@ export interface ProjectInfoResult { readonly diagnostics: readonly ts.Diagnostic[]; } -export async function loadProjectInfo( - projectRoot: string, -): Promise { +export function loadProjectInfo(projectRoot: string): ProjectInfoResult { const packageJsonPath = path.join(projectRoot, 'package.json'); // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports - const pkg = await fs.readJson(packageJsonPath); + const pkg = fs.readJsonSync(packageJsonPath); const diagnostics: ts.Diagnostic[] = []; @@ -127,7 +125,7 @@ export async function loadProjectInfo( const peerDependencies: Record = pkg.peerDependencies ?? {}; const resolver = new DependencyResolver(); - const resolved = await resolver.discoverDependencyTree(projectRoot, { + const resolved = resolver.discoverDependencyTree(projectRoot, { ...dependencies, ...peerDependencies, }); @@ -245,14 +243,14 @@ class DependencyResolver { * * Return the resolved jsii dependency paths */ - public async discoverDependencyTree( + public discoverDependencyTree( root: string, dependencies: Record, - ): Promise> { + ): Record { const ret: Record = {}; for (const [name, declaration] of Object.entries(dependencies)) { // eslint-disable-next-line no-await-in-loop - const resolved = await this.resolveDependency(root, name, declaration); + const resolved = this.resolveDependency(root, name, declaration); const actualVersion = resolved.dependencyInfo.assembly.version; if (!semver.satisfies(actualVersion, declaration)) { @@ -288,11 +286,7 @@ class DependencyResolver { return Array.from(closure.values()); } - private async resolveDependency( - root: string, - name: string, - declaration: string, - ) { + private resolveDependency(root: string, name: string, declaration: string) { const { version: versionString, localPackage } = _resolveVersion( declaration, root, @@ -303,27 +297,27 @@ class DependencyResolver { `Invalid semver expression for ${name}: ${versionString}`, ); } - const jsiiFile = await _tryResolveAssembly(name, localPackage, root); + const jsiiFile = _tryResolveAssembly(name, localPackage, root); LOG.debug(`Resolved dependency ${name} to ${jsiiFile}`); return { resolvedVersion: versionString, resolvedFile: jsiiFile, - dependencyInfo: await this.loadAssemblyAndRecurse(jsiiFile), + dependencyInfo: this.loadAssemblyAndRecurse(jsiiFile), }; } - private async loadAssemblyAndRecurse(jsiiFile: string) { + private loadAssemblyAndRecurse(jsiiFile: string) { // Only recurse if we haven't seen this assembly yet if (this.cache.has(jsiiFile)) { return this.cache.get(jsiiFile)!; } // eslint-disable-next-line no-await-in-loop - const assembly = await this.loadAssembly(jsiiFile); + const assembly = this.loadAssembly(jsiiFile); // Continue loading any dependencies declared in the asm const resolvedDependencies = assembly.dependencies - ? await this.discoverDependencyTree( + ? this.discoverDependencyTree( path.dirname(jsiiFile), assembly.dependencies, ) @@ -340,9 +334,9 @@ class DependencyResolver { /** * Load a JSII filename and validate it; cached to avoid redundant loads of the same JSII assembly */ - private async loadAssembly(jsiiFileName: string): Promise { + private loadAssembly(jsiiFileName: string): spec.Assembly { try { - return await fs.readJson(jsiiFileName); + return fs.readJsonSync(jsiiFileName); } catch (e) { throw new Error(`Error loading ${jsiiFileName}: ${e}`); } @@ -394,11 +388,11 @@ function _toRepository(value: any): { }; } -async function _tryResolveAssembly( +function _tryResolveAssembly( mod: string, localPackage: string | undefined, searchPath: string, -): Promise { +): string { if (localPackage) { const result = path.join(localPackage, '.jsii'); if (!fs.existsSync(result)) { @@ -407,7 +401,7 @@ async function _tryResolveAssembly( return result; } try { - const dependencyDir = await findDependencyDirectory(mod, searchPath); + const dependencyDir = findDependencyDirectory(mod, searchPath); return path.join(dependencyDir, '.jsii'); } catch (e) { throw new Error( diff --git a/packages/jsii/lib/transforms/deprecation-warnings.ts b/packages/jsii/lib/transforms/deprecation-warnings.ts index 6b19e65391..04775ddf91 100644 --- a/packages/jsii/lib/transforms/deprecation-warnings.ts +++ b/packages/jsii/lib/transforms/deprecation-warnings.ts @@ -13,6 +13,8 @@ const PARAMETER_NAME = 'p'; const NAMESPACE = 'jsiiDeprecationWarnings'; const LOCAL_ENUM_NAMESPACE = 'ns'; const VISITED_OBJECTS_SET_NAME = 'visitedObjects'; +const DEPRECATION_ERROR = 'DeprecationError'; +const GET_PROPERTY_DESCRIPTOR = 'getPropertyDescriptor'; export class DeprecationWarningsInjector { private transformers: ts.CustomTransformers = { @@ -34,35 +36,46 @@ export class DeprecationWarningsInjector { statements.push( ts.createExpressionStatement( ts.createCall( - ts.createIdentifier(`${VISITED_OBJECTS_SET_NAME}.add`), - [], + ts.createPropertyAccess( + ts.createIdentifier(VISITED_OBJECTS_SET_NAME), + 'add', + ), + undefined, [ts.createIdentifier(PARAMETER_NAME)], ), ), ); + const tryStatements = []; if (spec.isDeprecated(type) && spec.isEnumType(type)) { // The type is deprecated - statements.push( + tryStatements.push( createWarningFunctionCall(type.fqn, type.docs?.deprecated), ); isEmpty = false; } if (spec.isEnumType(type) && type.locationInModule?.filename) { - statements.push( + tryStatements.push( createEnumRequireStatement(type.locationInModule?.filename), ); - statements.push(createDuplicateEnumValuesCheck(type)); + tryStatements.push(createDuplicateEnumValuesCheck(type)); for (const member of Object.values(type.members ?? [])) { if (spec.isDeprecated(member)) { // The enum member is deprecated - const condition = ts.createIdentifier( - `${PARAMETER_NAME} === ${LOCAL_ENUM_NAMESPACE}.${type.name}.${member.name}`, + const condition = ts.createBinary( + ts.createIdentifier(PARAMETER_NAME), + ts.SyntaxKind.EqualsEqualsEqualsToken, + ts.createPropertyAccess( + ts.createPropertyAccess( + ts.createIdentifier(LOCAL_ENUM_NAMESPACE), + type.name, + ), + member.name, + ), ); - - statements.push( + tryStatements.push( createWarningFunctionCall( `${type.fqn}#${member.name}`, member.docs?.deprecated, @@ -78,26 +91,38 @@ export class DeprecationWarningsInjector { types, assembly, projectInfo, + undefined, + undefined, ); for (const [name, statement] of statementsByProp.entries()) { if (!excludedProps.has(name)) { - statements.push(statement); + tryStatements.push(statement); isEmpty = false; } } } + statements.push( - ts.createExpressionStatement( - ts.createCall( - ts.createIdentifier(`${VISITED_OBJECTS_SET_NAME}.delete`), - [], - [ts.createIdentifier(PARAMETER_NAME)], - ), + ts.createTry( + ts.createBlock(tryStatements), + undefined, + ts.createBlock([ + ts.createExpressionStatement( + ts.createCall( + ts.createPropertyAccess( + ts.createIdentifier(VISITED_OBJECTS_SET_NAME), + 'delete', + ), + undefined, + [ts.createIdentifier(PARAMETER_NAME)], + ), + ), + ]), ), ); - const parameter = ts.createParameter( + const paramValue = ts.createParameter( undefined, undefined, undefined, @@ -110,7 +135,7 @@ export class DeprecationWarningsInjector { undefined, functionName, undefined, - [parameter], + [paramValue], undefined, createFunctionBlock(isEmpty ? [] : statements), ); @@ -167,7 +192,12 @@ function processInterfaceType( const statement = createWarningFunctionCall( fqn, deprecatedDocs, - ts.createIdentifier(`"${prop.name}" in ${PARAMETER_NAME}`), + ts.createBinary( + ts.createStringLiteral(prop.name), + ts.SyntaxKind.InKeyword, + ts.createIdentifier(PARAMETER_NAME), + ), + undefined, ); statementsByProp.set(prop.name, statement); } else { @@ -254,7 +284,11 @@ function fnName(fqn: string): string { function createFunctionBlock(statements: ts.Statement[]): ts.Block { if (statements.length > 0) { const validation = ts.createIf( - ts.createIdentifier(`${PARAMETER_NAME} == null`), + ts.createBinary( + ts.createIdentifier(PARAMETER_NAME), + ts.SyntaxKind.EqualsEqualsToken, + ts.createNull(), + ), ts.createReturn(), ); return ts.createBlock([validation, ...statements], true); @@ -265,7 +299,7 @@ function createFunctionBlock(statements: ts.Statement[]): ts.Block { function createWarningFunctionCall( fqn: string, message = '', - condition?: ts.Identifier, + condition?: ts.Expression, includeNamespace = false, ): ts.Statement { const functionName = includeNamespace @@ -273,11 +307,10 @@ function createWarningFunctionCall( : WARNING_FUNCTION_NAME; const mainStatement = ts.createExpressionStatement( - ts.createCall( - ts.createIdentifier(functionName), - [], - [ts.createLiteral(fqn), ts.createLiteral(message)], - ), + ts.createCall(ts.createIdentifier(functionName), undefined, [ + ts.createLiteral(fqn), + ts.createLiteral(message), + ]), ); return condition ? ts.createIf(condition, mainStatement) : mainStatement; @@ -290,27 +323,54 @@ function generateWarningsFile( const names = [...functionDeclarations] .map((d) => d.name?.text) .filter(Boolean); - const exportedSymbols = [WARNING_FUNCTION_NAME, ...names].join(','); + const exportedSymbols = [ + WARNING_FUNCTION_NAME, + GET_PROPERTY_DESCRIPTOR, + DEPRECATION_ERROR, + ...names, + ].join(','); const functionText = `function ${WARNING_FUNCTION_NAME}(name, deprecationMessage) { const deprecated = process.env.JSII_DEPRECATED; const deprecationMode = ['warn', 'fail', 'quiet'].includes(deprecated) ? deprecated : 'warn'; - const message = \`\${name} is deprecated.\\n \${deprecationMessage}\\n This API will be removed in the next major release.\`; + const message = \`\${name} is deprecated.\\n \${deprecationMessage.trim()}\\n This API will be removed in the next major release.\`; switch (deprecationMode) { case "fail": - throw new DeprecationError(message); + throw new ${DEPRECATION_ERROR}(message); case "warn": console.warn("[WARNING]", message); break; } } +function ${GET_PROPERTY_DESCRIPTOR}(obj, prop) { + const descriptor = Object.getOwnPropertyDescriptor(obj, prop); + if (descriptor) { + return descriptor; + } + const proto = Object.getPrototypeOf(obj); + const prototypeDescriptor = proto && getPropertyDescriptor(proto, prop); + if (prototypeDescriptor) { + return prototypeDescriptor; + } + return {}; +} + const ${VISITED_OBJECTS_SET_NAME} = new Set(); -class DeprecationError extends Error {} +class ${DEPRECATION_ERROR} extends Error { + constructor(...args) { + super(...args); + Object.defineProperty(this, 'name', { + configurable: false, + enumerable: true, + value: '${DEPRECATION_ERROR}', + writable: false, + }); + } +} module.exports = {${exportedSymbols}} -module.exports.DeprecationError = DeprecationError; `; const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); @@ -383,10 +443,16 @@ class Transformer { node.typeParameters, node.parameters, node.type, - ts.updateBlock( - node.body, - ts.createNodeArray([...statements, ...node.body.statements]), - ), + ts.updateBlock(node.body, [ + ...wrapWithRethrow( + statements, + ts.createPropertyAccess( + ts.createThis(), + node.name.getText(node.getSourceFile()), + ), + ), + ...node.body.statements, + ]), ) as any; } else if (ts.isGetAccessorDeclaration(node) && node.body != null) { const statements = this.getStatementsForDeclaration(node); @@ -399,10 +465,26 @@ class Transformer { node.name, node.parameters, node.type, - ts.updateBlock( - node.body, - ts.createNodeArray([...statements, ...node.body.statements]), - ), + ts.updateBlock(node.body, [ + ...wrapWithRethrow( + statements, + ts.createPropertyAccess( + ts.createCall( + ts.createPropertyAccess( + ts.createIdentifier(NAMESPACE), + GET_PROPERTY_DESCRIPTOR, + ), + undefined, + [ + ts.createThis(), + ts.createLiteral(node.name.getText(node.getSourceFile())), + ], + ), + 'get', + ), + ), + ...node.body.statements, + ]), ) as any; } else if (ts.isSetAccessorDeclaration(node) && node.body != null) { const statements = this.getStatementsForDeclaration(node); @@ -414,10 +496,26 @@ class Transformer { node.modifiers, node.name, node.parameters, - ts.updateBlock( - node.body, - ts.createNodeArray([...statements, ...node.body.statements]), - ), + ts.updateBlock(node.body, [ + ...wrapWithRethrow( + statements, + ts.createPropertyAccess( + ts.createCall( + ts.createPropertyAccess( + ts.createIdentifier(NAMESPACE), + GET_PROPERTY_DESCRIPTOR, + ), + undefined, + [ + ts.createThis(), + ts.createLiteral(node.name.getText(node.getSourceFile())), + ], + ), + 'set', + ), + ), + ...node.body.statements, + ]), ) as any; } else if (ts.isConstructorDeclaration(node) && node.body != null) { const statements = this.getStatementsForDeclaration(node); @@ -428,13 +526,26 @@ class Transformer { node.decorators, node.modifiers, node.parameters, - ts.updateBlock(node.body, insertStatements(node.body, statements)), + ts.updateBlock( + node.body, + insertStatements( + node.body, + wrapWithRethrow( + statements, + ts.createPropertyAccess(ts.createThis(), 'constructor'), + ), + ), + ), ) as any; } return this.visitEachChild(node); } + /** + * @param getOrSet for property accessors, determines which of the getter or + * setter should be used to get the caller function value. + */ private getStatementsForDeclaration( node: | ts.MethodDeclaration @@ -481,7 +592,6 @@ class Transformer { method: spec.Method | spec.Initializer, ) { const statements = createWarningStatementForElement(method, classType); - for (const parameter of Object.values(method.parameters ?? {})) { const parameterType = this.assembly.types && spec.isNamedTypeReference(parameter.type) @@ -492,11 +602,9 @@ class Transformer { const functionName = `${NAMESPACE}.${fnName(parameterType.fqn)}`; statements.push( ts.createExpressionStatement( - ts.createCall( - ts.createIdentifier(functionName), - [], - [ts.createIdentifier(parameter.name)], - ), + ts.createCall(ts.createIdentifier(functionName), undefined, [ + ts.createIdentifier(parameter.name), + ]), ), ); } @@ -615,14 +723,22 @@ function createTypeHandlerCall( parameter: string, ): ts.Statement { return ts.createIf( - ts.createIdentifier(`!${VISITED_OBJECTS_SET_NAME}.has(${parameter})`), - ts.createExpressionStatement( + ts.createPrefix( + ts.SyntaxKind.ExclamationToken, ts.createCall( - ts.createIdentifier(functionName), - [], + ts.createPropertyAccess( + ts.createIdentifier(VISITED_OBJECTS_SET_NAME), + ts.createIdentifier('has'), + ), + undefined, [ts.createIdentifier(parameter)], ), ), + ts.createExpressionStatement( + ts.createCall(ts.createIdentifier(functionName), undefined, [ + ts.createIdentifier(parameter), + ]), + ), ); } @@ -646,9 +762,16 @@ function createDuplicateEnumValuesCheck( ts.createPropertyAccess( ts.createCall( ts.createPropertyAccess( - ts.createCall(ts.createIdentifier('Object.values'), undefined, [ - ts.createIdentifier(`${LOCAL_ENUM_NAMESPACE}.${type.name}`), - ]), + ts.createCall( + ts.createPropertyAccess(ts.createIdentifier('Object'), 'values'), + undefined, + [ + ts.createPropertyAccess( + ts.createIdentifier(LOCAL_ENUM_NAMESPACE), + type.name, + ), + ], + ), ts.createIdentifier('filter'), ), undefined, @@ -676,6 +799,66 @@ function createDuplicateEnumValuesCheck( ); } +// We try-then-rethrow exceptions to avoid runtimes displaying an uncanny wall of text if the place +// where the error was thrown is webpacked. For example, jest somehow manages to capture the throw +// location and renders the source line (which may be the whole file) when bundled. +function wrapWithRethrow( + statements: ts.Statement[], + caller: ts.Expression, +): ts.Statement[] { + if (statements.length === 0) { + return statements; + } + return [ + ts.createTry( + ts.createBlock(statements), + ts.createCatchClause( + ts.createVariableDeclaration('error'), + ts.createBlock([ + // If this is a DeprecationError, trim its stack trace to surface level before re-throwing, + // so we don't carry out possibly confusing frames from injected code. That can be toggled + // off by setting JSII_DEBUG=1, so we can also diagnose in-injected code faults. + ts.createIf( + ts.createBinary( + ts.createBinary( + ts.createPropertyAccess( + ts.createPropertyAccess( + ts.createIdentifier('process'), + 'env', + ), + 'JSII_DEBUG', + ), + ts.SyntaxKind.ExclamationEqualsEqualsToken, + ts.createLiteral('1'), + ), + ts.SyntaxKind.AmpersandAmpersandToken, + ts.createBinary( + ts.createPropertyAccess(ts.createIdentifier('error'), 'name'), + ts.SyntaxKind.EqualsEqualsEqualsToken, + ts.createLiteral(DEPRECATION_ERROR), + ), + ), + ts.createBlock([ + ts.createExpressionStatement( + ts.createCall( + ts.createPropertyAccess( + ts.createIdentifier('Error'), + 'captureStackTrace', + ), + undefined, + [ts.createIdentifier('error'), caller], + ), + ), + ]), + ), + ts.createThrow(ts.createIdentifier('error')), + ]), + ), + undefined, + ), + ]; +} + /** * Force a path to be UNIXy (use `/` as a separator) * diff --git a/packages/jsii/lib/utils.ts b/packages/jsii/lib/utils.ts index 947ec86237..af3303172c 100644 --- a/packages/jsii/lib/utils.ts +++ b/packages/jsii/lib/utils.ts @@ -172,7 +172,7 @@ export function parseRepository(value: string): { url: string } { * (This code is duplicated among jsii/jsii-pacmak/jsii-reflect. Changes should be done in all * 3 locations, and we should unify these at some point: https://github.com/aws/jsii/issues/3236) */ -export async function findDependencyDirectory( +export function findDependencyDirectory( dependencyName: string, searchStart: string, ) { @@ -184,7 +184,7 @@ export async function findDependencyDirectory( // Search up from the given directory, looking for a package.json that matches // the dependency name (so we don't accidentally find stray 'package.jsons'). - const depPkgJsonPath = await findPackageJsonUp( + const depPkgJsonPath = findPackageJsonUp( dependencyName, path.dirname(entryPoint), ); @@ -204,15 +204,11 @@ export async function findDependencyDirectory( * (This code is duplicated among jsii/jsii-pacmak/jsii-reflect. Changes should be done in all * 3 locations, and we should unify these at some point: https://github.com/aws/jsii/issues/3236) */ -export async function findPackageJsonUp( - packageName: string, - directory: string, -) { - return findUp(directory, async (dir) => { +export function findPackageJsonUp(packageName: string, directory: string) { + return findUp(directory, (dir) => { const pjFile = path.join(dir, 'package.json'); return ( - (await fs.pathExists(pjFile)) && - (await fs.readJson(pjFile)).name === packageName + fs.pathExistsSync(pjFile) && fs.readJsonSync(pjFile).name === packageName ); }); } @@ -225,25 +221,11 @@ export async function findPackageJsonUp( * (This code is duplicated among jsii/jsii-pacmak/jsii-reflect. Changes should be done in all * 3 locations, and we should unify these at some point: https://github.com/aws/jsii/issues/3236) */ -export function findUp( - directory: string, - pred: (dir: string) => Promise, -): Promise; export function findUp( directory: string, pred: (dir: string) => boolean, -): string | undefined; -// eslint-disable-next-line @typescript-eslint/promise-function-async -export function findUp( - directory: string, - pred: ((dir: string) => boolean) | ((dir: string) => Promise), -): Promise | string | undefined { +): string | undefined { const result = pred(directory); - if (isPromise(result)) { - return result.then((thisDirectory) => - thisDirectory ? directory : recurse(), - ); - } return result ? directory : recurse(); @@ -256,6 +238,10 @@ export function findUp( } } -function isPromise(x: A | Promise): x is Promise { - return typeof x === 'object' && (x as any).then; +const ANSI_REGEX = + // eslint-disable-next-line no-control-regex + /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g; + +export function stripAnsi(x: string): string { + return x.replace(ANSI_REGEX, ''); } diff --git a/packages/jsii/lib/validator.ts b/packages/jsii/lib/validator.ts index 878703c8a7..cf26248270 100644 --- a/packages/jsii/lib/validator.ts +++ b/packages/jsii/lib/validator.ts @@ -21,7 +21,7 @@ export class Validator implements Emitter { public readonly assembly: spec.Assembly, ) {} - public async emit(): Promise { + public emit(): ts.EmitResult { this._diagnostics = []; for (const validation of Validator.VALIDATIONS) { @@ -29,12 +29,12 @@ export class Validator implements Emitter { } try { - return await Promise.resolve({ + return { diagnostics: this._diagnostics, emitSkipped: this._diagnostics.some( (diag) => diag.category === ts.DiagnosticCategory.Error, ), - }); + }; } finally { // Clearing ``this._diagnostics`` to allow contents to be garbage-collected. delete this._diagnostics; diff --git a/packages/jsii/package.json b/packages/jsii/package.json index d5984b75e3..f36a13a236 100644 --- a/packages/jsii/package.json +++ b/packages/jsii/package.json @@ -41,11 +41,11 @@ "chalk": "^4", "deep-equal": "^2.0.5", "fs-extra": "^9.1.0", - "log4js": "^6.4.2", + "log4js": "^6.4.4", "semver": "^7.3.5", "semver-intersect": "^1.4.0", "sort-json": "^2.0.1", - "spdx-license-list": "^6.4.0", + "spdx-license-list": "^6.5.0", "typescript": "~3.9.10", "yargs": "^16.2.0" }, @@ -57,11 +57,11 @@ "@types/node": "^12.20.47", "@types/semver": "^7.3.9", "clone": "^2.1.2", - "eslint": "^8.10.0", + "eslint": "^8.12.0", "jest": "^27.5.1", "jest-expect-message": "^1.0.2", "jsii-build-tools": "^0.0.0", - "prettier": "^2.5.1", - "ts-jest": "^27.1.3" + "prettier": "^2.6.2", + "ts-jest": "^27.1.4" } } diff --git a/packages/jsii/test/compiler.test.ts b/packages/jsii/test/compiler.test.ts index 6e56673839..5335215da4 100644 --- a/packages/jsii/test/compiler.test.ts +++ b/packages/jsii/test/compiler.test.ts @@ -1,10 +1,10 @@ import { - ensureDir, - mkdtemp, - remove, - writeFile, - readFile, - readJson, + ensureDirSync, + mkdtempSync, + removeSync, + writeFileSync, + readFileSync, + readJsonSync, } from 'fs-extra'; import { tmpdir } from 'os'; import { join } from 'path'; @@ -14,8 +14,8 @@ import { ProjectInfo } from '../lib/project-info'; describe(Compiler, () => { describe('generated tsconfig', () => { - test('default is tsconfig.json', async () => { - const sourceDir = await mkdtemp( + test('default is tsconfig.json', () => { + const sourceDir = mkdtempSync( join(tmpdir(), 'jsii-compiler-watch-mode-'), ); @@ -23,15 +23,15 @@ describe(Compiler, () => { projectInfo: _makeProjectInfo(sourceDir, 'index.d.ts'), }); - await compiler.emit(); + compiler.emit(); - expect(await readJson(join(sourceDir, 'tsconfig.json'), 'utf-8')).toEqual( + expect(readJsonSync(join(sourceDir, 'tsconfig.json'), 'utf-8')).toEqual( expectedTypeScriptConfig(), ); }); - test('file name can be customized', async () => { - const sourceDir = await mkdtemp( + test('file name can be customized', () => { + const sourceDir = mkdtempSync( join(tmpdir(), 'jsii-compiler-watch-mode-'), ); @@ -40,10 +40,10 @@ describe(Compiler, () => { generateTypeScriptConfig: 'tsconfig.jsii.json', }); - await compiler.emit(); + compiler.emit(); expect( - await readJson(join(sourceDir, 'tsconfig.jsii.json'), 'utf-8'), + readJsonSync(join(sourceDir, 'tsconfig.jsii.json'), 'utf-8'), ).toEqual(expectedTypeScriptConfig()); }); }); @@ -52,14 +52,12 @@ describe(Compiler, () => { // This can be a little slow, allowing 15 seconds maximum here (default is 5 seconds) jest.setTimeout(15_000); - const sourceDir = await mkdtemp( - join(tmpdir(), 'jsii-compiler-watch-mode-'), - ); + const sourceDir = mkdtempSync(join(tmpdir(), 'jsii-compiler-watch-mode-')); try { - await writeFile(join(sourceDir, 'index.ts'), 'export class MarkerA {}'); + writeFileSync(join(sourceDir, 'index.ts'), 'export class MarkerA {}'); // Intentionally using lower case name - it should be case-insensitive - await writeFile(join(sourceDir, 'readme.md'), '# Test Package'); + writeFileSync(join(sourceDir, 'readme.md'), '# Test Package'); const compiler = new Compiler({ projectInfo: _makeProjectInfo(sourceDir, 'index.d.ts'), @@ -74,23 +72,23 @@ describe(Compiler, () => { onWatchClosed = ok; onWatchFailed = ko; }); - const watch = await compiler.watch({ + const watch = compiler.watch({ nonBlocking: true, // Ignore diagnostics reporting (not to pollute test console output) reportDiagnostics: () => null, // Ignore watch status reporting (not to pollute test console output) reportWatchStatus: () => null, // Verify everything goes according to plan - compilationComplete: async (emitResult) => { + compilationComplete: (emitResult) => { try { expect(emitResult.emitSkipped).toBeFalsy(); - const output = await readFile(join(sourceDir, '.jsii'), { + const output = readFileSync(join(sourceDir, '.jsii'), { encoding: 'utf-8', }); if (firstCompilation) { firstCompilation = false; expect(output).toContain('"MarkerA"'); - await writeFile( + writeFileSync( join(sourceDir, 'index.ts'), 'export class MarkerB {}', ); @@ -108,23 +106,23 @@ describe(Compiler, () => { }); await watchClosed; } finally { - await remove(sourceDir); + removeSync(sourceDir); } }); - test('rootDir is added to assembly', async () => { + test('rootDir is added to assembly', () => { const outDir = 'jsii-outdir'; const rootDir = 'jsii-rootdir'; - const sourceDir = await mkdtemp(join(tmpdir(), 'jsii-tmpdir')); - await ensureDir(join(sourceDir, rootDir)); + const sourceDir = mkdtempSync(join(tmpdir(), 'jsii-tmpdir')); + ensureDirSync(join(sourceDir, rootDir)); try { - await writeFile( + writeFileSync( join(sourceDir, rootDir, 'index.ts'), 'export class MarkerA {}', ); // Intentionally using lower case name - it should be case-insensitive - await writeFile(join(sourceDir, rootDir, 'readme.md'), '# Test Package'); + writeFileSync(join(sourceDir, rootDir, 'readme.md'), '# Test Package'); const compiler = new Compiler({ projectInfo: { @@ -138,16 +136,16 @@ describe(Compiler, () => { projectReferences: false, }); - await compiler.emit(); + compiler.emit(); - const assembly = await readJson(join(sourceDir, '.jsii'), 'utf-8'); + const assembly = readJsonSync(join(sourceDir, '.jsii'), 'utf-8'); expect(assembly.metadata).toEqual( expect.objectContaining({ tscRootDir: rootDir, }), ); } finally { - await remove(sourceDir); + removeSync(sourceDir); } }); }); diff --git a/packages/jsii/test/deprecated-remover.test.ts b/packages/jsii/test/deprecated-remover.test.ts index 63964fbe9b..920d228384 100644 --- a/packages/jsii/test/deprecated-remover.test.ts +++ b/packages/jsii/test/deprecated-remover.test.ts @@ -6,8 +6,8 @@ import { compileJsiiForTest, HelperCompilationResult } from '../lib'; const DEPRECATED = '/** @deprecated stripped */'; -test('produces correct output', async () => { - const result = await compileJsiiForTest( +test('produces correct output', () => { + const result = compileJsiiForTest( MULTI_FILE_EXAMPLE, undefined /* callback */, { stripDeprecated: true }, @@ -153,8 +153,8 @@ test('produces correct output', async () => { `); }); -test('cross-file deprecated heritage', async () => { - const result = await compileJsiiForTest( +test('cross-file deprecated heritage', () => { + const result = compileJsiiForTest( { 'index.ts': ` import { IDeprecated } from './deprecated'; @@ -188,12 +188,12 @@ test('cross-file deprecated heritage', async () => { }); describe('stripDeprecatedAllowList', () => { - test('strips all if all FQNs are present in the allowList', async () => { - const tmpDir = await fs.mkdtemp( + test('strips all if all FQNs are present in the allowList', () => { + const tmpDir = fs.mkdtempSync( path.join(os.tmpdir(), 'jsiideprecatedremover'), ); const stripDeprecatedAllowListFile = path.join(tmpDir, 'allowList'); - await fs.writeFile( + fs.writeFileSync( stripDeprecatedAllowListFile, [ 'testpkg.IDeprecatedInterface', @@ -207,12 +207,12 @@ describe('stripDeprecatedAllowList', () => { 'utf8', ); - const resultWithoutAllowList = await compileJsiiForTest( + const resultWithoutAllowList = compileJsiiForTest( MULTI_FILE_EXAMPLE, undefined /* callback */, { stripDeprecated: true }, ); - const resultWithAllowList = await compileJsiiForTest( + const resultWithAllowList = compileJsiiForTest( MULTI_FILE_EXAMPLE, undefined /* callback */, { stripDeprecated: true, stripDeprecatedAllowListFile }, @@ -226,20 +226,20 @@ describe('stripDeprecatedAllowList', () => { ); }); - test('strips none if the allowList is empty', async () => { - const tmpDir = await fs.mkdtemp( + test('strips none if the allowList is empty', () => { + const tmpDir = fs.mkdtempSync( path.join(os.tmpdir(), 'jsiideprecatedremover'), ); const stripDeprecatedAllowListFile = path.join(tmpDir, 'allowList'); // Valid but empty file - await fs.writeFile(stripDeprecatedAllowListFile, '', 'utf8'); + fs.writeFileSync(stripDeprecatedAllowListFile, '', 'utf8'); - const resultNoStrip = await compileJsiiForTest( + const resultNoStrip = compileJsiiForTest( MULTI_FILE_EXAMPLE, undefined /* callback */, { stripDeprecated: false }, ); - const resultStripEmpty = await compileJsiiForTest( + const resultStripEmpty = compileJsiiForTest( MULTI_FILE_EXAMPLE, undefined /* callback */, { stripDeprecated: true, stripDeprecatedAllowListFile }, @@ -253,12 +253,12 @@ describe('stripDeprecatedAllowList', () => { ); }); - test('strips only allowlisted items if subset is present', async () => { - const tmpDir = await fs.mkdtemp( + test('strips only allowlisted items if subset is present', () => { + const tmpDir = fs.mkdtempSync( path.join(os.tmpdir(), 'jsiideprecatedremover'), ); const stripDeprecatedAllowListFile = path.join(tmpDir, 'allowList'); - await fs.writeFile( + fs.writeFileSync( stripDeprecatedAllowListFile, [ 'testpkg.IDeprecatedInterface', @@ -268,7 +268,7 @@ describe('stripDeprecatedAllowList', () => { 'utf8', ); - const result = await compileJsiiForTest( + const result = compileJsiiForTest( MULTI_FILE_EXAMPLE, undefined /* callback */, { stripDeprecated: true, stripDeprecatedAllowListFile }, diff --git a/packages/jsii/test/deprecation-warnings.test.ts b/packages/jsii/test/deprecation-warnings.test.ts index 668d9a9e04..cd62370f31 100644 --- a/packages/jsii/test/deprecation-warnings.test.ts +++ b/packages/jsii/test/deprecation-warnings.test.ts @@ -1,6 +1,7 @@ // eslint-disable-next-line import/no-extraneous-dependencies import * as fs from 'fs'; import * as path from 'path'; +import * as vm from 'vm'; import { compileJsiiForTest, HelperCompilationResult } from '../lib'; import { Compiler } from '../lib/compiler'; @@ -9,16 +10,16 @@ import { loadProjectInfo } from '../lib/project-info'; const DEPRECATED = '/** @deprecated Use something else */'; describe('Function generation', () => { - test('generates the print function', async () => { - const result = await compileJsiiForTest(``, undefined /* callback */, { + test('generates the print function', () => { + const result = compileJsiiForTest(``, undefined /* callback */, { addDeprecationWarnings: true, }); - expect(jsFile(result, '.warnings.jsii')).toMatch( + expect(jsFile(result, '.warnings.jsii')).toBe( `function print(name, deprecationMessage) { const deprecated = process.env.JSII_DEPRECATED; const deprecationMode = ["warn", "fail", "quiet"].includes(deprecated) ? deprecated : "warn"; - const message = \`\${name} is deprecated.\\n \${deprecationMessage}\\n This API will be removed in the next major release.\`; + const message = \`\${name} is deprecated.\\n \${deprecationMessage.trim()}\\n This API will be removed in the next major release.\`; switch (deprecationMode) { case "fail": throw new DeprecationError(message); @@ -27,17 +28,37 @@ describe('Function generation', () => { break; } } +function getPropertyDescriptor(obj, prop) { + const descriptor = Object.getOwnPropertyDescriptor(obj, prop); + if (descriptor) { + return descriptor; + } + const proto = Object.getPrototypeOf(obj); + const prototypeDescriptor = proto && getPropertyDescriptor(proto, prop); + if (prototypeDescriptor) { + return prototypeDescriptor; + } + return {}; +} const visitedObjects = new Set(); class DeprecationError extends Error { + constructor(...args) { + super(...args); + Object.defineProperty(this, "name", { + configurable: false, + enumerable: true, + value: "DeprecationError", + writable: false, + }); + } } -module.exports = { print }; -module.exports.DeprecationError = DeprecationError; +module.exports = { print, getPropertyDescriptor, DeprecationError }; `, ); }); - test('generates a function for each type', async () => { - const result = await compileJsiiForTest( + test('generates a function for each type', () => { + const result = compileJsiiForTest( ` export interface Foo {} export interface Bar {} @@ -57,8 +78,8 @@ function testpkg_Baz(p) { ); }); - test('generates metadata', async () => { - const result = await compileJsiiForTest( + test('generates metadata', () => { + const result = compileJsiiForTest( ` export interface Foo {} export interface Bar {} @@ -72,8 +93,8 @@ function testpkg_Baz(p) { ).toBe(true); }); - test('for each non-primitive property, generates a call', async () => { - const result = await compileJsiiForTest( + test('for each non-primitive property, generates a call', () => { + const result = compileJsiiForTest( ` export interface Foo {} export interface Bar {} @@ -91,16 +112,20 @@ function testpkg_Baz(p) { if (p == null) return; visitedObjects.add(p); - if (!visitedObjects.has(p.bar)) - testpkg_Bar(p.bar); - if (!visitedObjects.has(p.foo)) - testpkg_Foo(p.foo); - visitedObjects.delete(p); + try { + if (!visitedObjects.has(p.bar)) + testpkg_Bar(p.bar); + if (!visitedObjects.has(p.foo)) + testpkg_Foo(p.foo); + } + finally { + visitedObjects.delete(p); + } }`); }); - test('generates empty functions for interfaces', async () => { - const result = await compileJsiiForTest( + test('generates empty functions for interfaces', () => { + const result = compileJsiiForTest( ` export interface IFoo { bar(): string; @@ -114,8 +139,8 @@ function testpkg_Baz(p) { }`); }); - test('generates empty functions for classes', async () => { - const result = await compileJsiiForTest( + test('generates empty functions for classes', () => { + const result = compileJsiiForTest( ` export class Foo { bar() {return 0}; @@ -129,8 +154,8 @@ function testpkg_Baz(p) { }`); }); - test('generates calls for recursive types', async () => { - const result = await compileJsiiForTest( + test('generates calls for recursive types', () => { + const result = compileJsiiForTest( ` export interface Bar {readonly bar?: Bar} `, @@ -143,15 +168,19 @@ function testpkg_Baz(p) { if (p == null) return; visitedObjects.add(p); - if (!visitedObjects.has(p.bar)) - testpkg_Bar(p.bar); - visitedObjects.delete(p); + try { + if (!visitedObjects.has(p.bar)) + testpkg_Bar(p.bar); + } + finally { + visitedObjects.delete(p); + } }`, ); }); - test('generates exports for all the functions', async () => { - const result = await compileJsiiForTest( + test('generates exports for all the functions', () => { + const result = compileJsiiForTest( ` export interface Foo {} export interface Bar {} @@ -162,12 +191,12 @@ function testpkg_Baz(p) { ); expect(jsFile(result, '.warnings.jsii')).toMatch( - `module.exports = { print, testpkg_Foo, testpkg_Bar, testpkg_Baz };`, + `module.exports = { print, getPropertyDescriptor, DeprecationError, testpkg_Foo, testpkg_Bar, testpkg_Baz };`, ); }); - test('generates functions for enums', async () => { - const result = await compileJsiiForTest( + test('generates functions for enums', () => { + const result = compileJsiiForTest( ` export enum State { ON, @@ -185,18 +214,22 @@ function testpkg_Baz(p) { if (p == null) return; visitedObjects.add(p); - const ns = require("./index.js"); - if (Object.values(ns.State).filter(x => x === p).length > 1) - return; - if (p === ns.State.OFF) - print("testpkg.State#OFF", "Use something else"); - visitedObjects.delete(p); + try { + const ns = require("./index.js"); + if (Object.values(ns.State).filter(x => x === p).length > 1) + return; + if (p === ns.State.OFF) + print("testpkg.State#OFF", "Use something else"); + } + finally { + visitedObjects.delete(p); + } } `); }); - test('generates calls for deprecated inherited properties', async () => { - const result = await compileJsiiForTest( + test('generates calls for deprecated inherited properties', () => { + const result = compileJsiiForTest( ` export interface Baz { /** @deprecated message from Baz */ @@ -220,17 +253,25 @@ function testpkg_Baz(p) { if (p == null) return; visitedObjects.add(p); - if ("x" in p) - print("testpkg.Baz#x", "message from Baz"); - visitedObjects.delete(p); + try { + if ("x" in p) + print("testpkg.Baz#x", "message from Baz"); + } + finally { + visitedObjects.delete(p); + } }`); expect(warningsFileContent).toMatch(`function testpkg_Bar(p) { if (p == null) return; visitedObjects.add(p); - if ("x" in p) - print("testpkg.Bar#x", "message from Bar"); - visitedObjects.delete(p); + try { + if ("x" in p) + print("testpkg.Bar#x", "message from Bar"); + } + finally { + visitedObjects.delete(p); + } }`); // But a call for one of the instances of the property should also be generated in the base function @@ -238,14 +279,18 @@ function testpkg_Baz(p) { if (p == null) return; visitedObjects.add(p); - if ("x" in p) - print("testpkg.Baz#x", "message from Baz"); - visitedObjects.delete(p); + try { + if ("x" in p) + print("testpkg.Baz#x", "message from Baz"); + } + finally { + visitedObjects.delete(p); + } }`); }); - test('skips properties that are deprecated in one supertype but not the other', async () => { - const result = await compileJsiiForTest( + test('skips properties that are deprecated in one supertype but not the other', () => { + const result = compileJsiiForTest( ` export interface Baz { readonly x: string; @@ -267,8 +312,8 @@ function testpkg_Baz(p) { }`); }); - test('generates calls for types with deprecated properties', async () => { - const result = await compileJsiiForTest( + test('generates calls for types with deprecated properties', () => { + const result = compileJsiiForTest( ` export interface Bar { readonly x: string; @@ -289,17 +334,21 @@ function testpkg_Baz(p) { if (p == null) return; visitedObjects.add(p); - if ("bar" in p) - print("testpkg.Foo#bar", "kkkkkkkk"); - if (!visitedObjects.has(p.bar)) - testpkg_Bar(p.bar); - visitedObjects.delete(p); + try { + if ("bar" in p) + print("testpkg.Foo#bar", "kkkkkkkk"); + if (!visitedObjects.has(p.bar)) + testpkg_Bar(p.bar); + } + finally { + visitedObjects.delete(p); + } } `); }); - test('generates calls for each property of a deprecated type', async () => { - const result = await compileJsiiForTest( + test('generates calls for each property of a deprecated type', () => { + const result = compileJsiiForTest( ` /** @deprecated use Bar instead */ export interface Foo { @@ -315,25 +364,29 @@ function testpkg_Baz(p) { if (p == null) return; visitedObjects.add(p); - if ("bar" in p) - print("testpkg.Foo#bar", "use Bar instead"); - if ("baz" in p) - print("testpkg.Foo#baz", "use Bar instead"); - visitedObjects.delete(p); + try { + if ("bar" in p) + print("testpkg.Foo#bar", "use Bar instead"); + if ("baz" in p) + print("testpkg.Foo#baz", "use Bar instead"); + } + finally { + visitedObjects.delete(p); + } } `); }); - test('generates calls for types in other assemblies', async () => { + test('generates calls for types in other assemblies', () => { const calcBaseOfBaseRoot = resolveModuleDir( '@scope/jsii-calc-base-of-base', ); const calcBaseRoot = resolveModuleDir('@scope/jsii-calc-base'); const calcLibRoot = resolveModuleDir('@scope/jsii-calc-lib'); - await compile(calcBaseOfBaseRoot, false); - await compile(calcBaseRoot, true); - await compile(calcLibRoot, true); + compile(calcBaseOfBaseRoot, false); + compile(calcBaseRoot, true); + compile(calcLibRoot, true); const warningsFile = loadWarningsFile(calcBaseRoot); // jsii-calc-base was compiled with warnings. So we expect to see handlers for its types in the warnings file @@ -343,14 +396,14 @@ function testpkg_Baz(p) { expect(warningsFile).not.toMatch('_scope_jsii_calc_base_of_base'); // Recompiling without deprecation warning to leave the packages in a clean state - await compile(calcBaseRoot, false); - await compile(calcLibRoot, false); + compile(calcBaseRoot, false); + compile(calcLibRoot, false); }, 120000); }); describe('Call injections', () => { - test('does not add warnings by default', async () => { - const result = await compileJsiiForTest( + test('does not add warnings by default', () => { + const result = compileJsiiForTest( ` export class Foo { ${DEPRECATED} @@ -365,8 +418,8 @@ describe('Call injections', () => { ).toBeFalsy(); }); - test('generates a require statement', async () => { - const result = await compileJsiiForTest( + test('generates a require statement', () => { + const result = compileJsiiForTest( { 'index.ts': `export * from './some/folder/source'`, 'some/folder/source.ts': ` @@ -388,8 +441,8 @@ describe('Call injections', () => { ); }, 60000); - test('does not generate a require statement when no calls were injected', async () => { - const result = await compileJsiiForTest( + test('does not generate a require statement when no calls were injected', () => { + const result = compileJsiiForTest( { 'index.ts': `export * from './some/folder/handler'`, 'some/folder/handler.ts': ` @@ -408,8 +461,8 @@ describe('Call injections', () => { ); }, 60000); - test('deprecated methods', async () => { - const result = await compileJsiiForTest( + test('deprecated methods', () => { + const result = compileJsiiForTest( ` export class Foo { ${DEPRECATED} @@ -420,30 +473,70 @@ describe('Call injections', () => { { addDeprecationWarnings: true }, ); - expect(jsFile(result)).toMatch( - 'bar() { jsiiDeprecationWarnings.print("testpkg.Foo#bar", "Use something else"); }', - ); + expect(jsFile(result)).toMatchInlineSnapshot(` + "\\"use strict\\"; + var _a; + Object.defineProperty(exports, \\"__esModule\\", { value: true }); + exports.Foo = void 0; + const jsiiDeprecationWarnings = require(\\"./.warnings.jsii.js\\"); + const JSII_RTTI_SYMBOL_1 = Symbol.for(\\"jsii.rtti\\"); + class Foo { + /** @deprecated Use something else */ + bar() { try { + jsiiDeprecationWarnings.print(\\"testpkg.Foo#bar\\", \\"Use something else\\"); + } + catch (error) { + if (process.env.JSII_DEBUG !== \\"1\\" && error.name === \\"DeprecationError\\") { + Error.captureStackTrace(error, this.bar); + } + throw error; + } } + } + exports.Foo = Foo; + _a = JSII_RTTI_SYMBOL_1; + Foo[_a] = { fqn: \\"testpkg.Foo\\", version: \\"0.0.1\\" }; + //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFDSSxNQUFhLEdBQUc7SUFDZCxxQ0FBcUM7SUFDOUIsR0FBRzs7Ozs7Ozs7T0FBSTs7QUFGaEIsa0JBR0MiLCJzb3VyY2VzQ29udGVudCI6WyJcbiAgICBleHBvcnQgY2xhc3MgRm9vIHtcbiAgICAgIC8qKiBAZGVwcmVjYXRlZCBVc2Ugc29tZXRoaW5nIGVsc2UgKi9cbiAgICAgIHB1YmxpYyBiYXIoKXt9XG4gICAgfVxuICAiXX0=" + `); }); - test('methods with parameters', async () => { - const result = await compileJsiiForTest( + test('methods with parameters', () => { + const result = compileJsiiForTest( ` - export interface A {readonly x: number;} - export class Foo { - public bar(a: A, b: number){return a.x + b;} - } - `, + export interface A {readonly x: number;} + export class Foo { + public bar(a: A, b: number){return a.x + b;} + }`, undefined /* callback */, { addDeprecationWarnings: true }, ); - expect(jsFile(result)).toMatch( - 'bar(a, b) { jsiiDeprecationWarnings.testpkg_A(a); return a.x + b; }', - ); + expect(jsFile(result)).toMatchInlineSnapshot(` + "\\"use strict\\"; + var _a; + Object.defineProperty(exports, \\"__esModule\\", { value: true }); + exports.Foo = void 0; + const jsiiDeprecationWarnings = require(\\"./.warnings.jsii.js\\"); + const JSII_RTTI_SYMBOL_1 = Symbol.for(\\"jsii.rtti\\"); + class Foo { + bar(a, b) { try { + jsiiDeprecationWarnings.testpkg_A(a); + } + catch (error) { + if (process.env.JSII_DEBUG !== \\"1\\" && error.name === \\"DeprecationError\\") { + Error.captureStackTrace(error, this.bar); + } + throw error; + } return a.x + b; } + } + exports.Foo = Foo; + _a = JSII_RTTI_SYMBOL_1; + Foo[_a] = { fqn: \\"testpkg.Foo\\", version: \\"0.0.1\\" }; + //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFFUyxNQUFhLEdBQUc7SUFDUixHQUFHLENBQUMsQ0FBSSxFQUFFLENBQVM7Ozs7Ozs7O01BQUUsT0FBTyxDQUFDLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxFQUFDOztBQUQ3QyxrQkFFQyIsInNvdXJjZXNDb250ZW50IjpbIlxuICAgICAgICBleHBvcnQgaW50ZXJmYWNlIEEge3JlYWRvbmx5IHg6IG51bWJlcjt9XG4gICAgICAgICBleHBvcnQgY2xhc3MgRm9vIHtcbiAgICAgICAgICBwdWJsaWMgYmFyKGE6IEEsIGI6IG51bWJlcil7cmV0dXJuIGEueCArIGI7fVxuICAgICAgICAgfSJdfQ==" + `); }, 60000); - test('deprecated getters', async () => { - const result = await compileJsiiForTest( + test('deprecated getters', () => { + const result = compileJsiiForTest( ` export class Foo { private _x = 0; @@ -455,13 +548,37 @@ describe('Call injections', () => { { addDeprecationWarnings: true }, ); - expect(jsFile(result)).toMatch( - 'get x() { jsiiDeprecationWarnings.print("testpkg.Foo#x", "Use something else"); return this._x; }', - ); + expect(jsFile(result)).toMatchInlineSnapshot(` + "\\"use strict\\"; + var _a; + Object.defineProperty(exports, \\"__esModule\\", { value: true }); + exports.Foo = void 0; + const jsiiDeprecationWarnings = require(\\"./.warnings.jsii.js\\"); + const JSII_RTTI_SYMBOL_1 = Symbol.for(\\"jsii.rtti\\"); + class Foo { + constructor() { + this._x = 0; + } + /** @deprecated Use something else */ + get x() { try { + jsiiDeprecationWarnings.print(\\"testpkg.Foo#x\\", \\"Use something else\\"); + } + catch (error) { + if (process.env.JSII_DEBUG !== \\"1\\" && error.name === \\"DeprecationError\\") { + Error.captureStackTrace(error, jsiiDeprecationWarnings.getPropertyDescriptor(this, \\"x\\").get); + } + throw error; + } return this._x; } + } + exports.Foo = Foo; + _a = JSII_RTTI_SYMBOL_1; + Foo[_a] = { fqn: \\"testpkg.Foo\\", version: \\"0.0.1\\" }; + //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFDSSxNQUFhLEdBQUc7SUFBaEI7UUFDVSxPQUFFLEdBQUcsQ0FBQyxDQUFDO0tBR2hCO0lBRkMscUNBQXFDO0lBQ3JDLElBQVcsQ0FBQzs7Ozs7Ozs7TUFBRyxPQUFPLElBQUksQ0FBQyxFQUFFLENBQUEsRUFBQzs7QUFIaEMsa0JBSUMiLCJzb3VyY2VzQ29udGVudCI6WyJcbiAgICBleHBvcnQgY2xhc3MgRm9vIHtcbiAgICAgIHByaXZhdGUgX3ggPSAwO1xuICAgICAgLyoqIEBkZXByZWNhdGVkIFVzZSBzb21ldGhpbmcgZWxzZSAqL1xuICAgICAgcHVibGljIGdldCB4KCl7cmV0dXJuIHRoaXMuX3h9XG4gICAgfVxuICAiXX0=" + `); }); - test('deprecated setters', async () => { - const result = await compileJsiiForTest( + test('deprecated setters', () => { + const result = compileJsiiForTest( ` export class Foo { private _x = 0; @@ -475,13 +592,46 @@ describe('Call injections', () => { { addDeprecationWarnings: true }, ); - expect(jsFile(result)).toMatch( - 'set x(_x) { jsiiDeprecationWarnings.print("testpkg.Foo#x", "Use something else"); this._x = _x; }', - ); + expect(jsFile(result)).toMatchInlineSnapshot(` + "\\"use strict\\"; + var _a; + Object.defineProperty(exports, \\"__esModule\\", { value: true }); + exports.Foo = void 0; + const jsiiDeprecationWarnings = require(\\"./.warnings.jsii.js\\"); + const JSII_RTTI_SYMBOL_1 = Symbol.for(\\"jsii.rtti\\"); + class Foo { + constructor() { + this._x = 0; + } + get x() { try { + jsiiDeprecationWarnings.print(\\"testpkg.Foo#x\\", \\"Use something else\\"); + } + catch (error) { + if (process.env.JSII_DEBUG !== \\"1\\" && error.name === \\"DeprecationError\\") { + Error.captureStackTrace(error, jsiiDeprecationWarnings.getPropertyDescriptor(this, \\"x\\").get); + } + throw error; + } return this._x; } + /** @deprecated Use something else */ + set x(_x) { try { + jsiiDeprecationWarnings.print(\\"testpkg.Foo#x\\", \\"Use something else\\"); + } + catch (error) { + if (process.env.JSII_DEBUG !== \\"1\\" && error.name === \\"DeprecationError\\") { + Error.captureStackTrace(error, jsiiDeprecationWarnings.getPropertyDescriptor(this, \\"x\\").set); + } + throw error; + } this._x = _x; } + } + exports.Foo = Foo; + _a = JSII_RTTI_SYMBOL_1; + Foo[_a] = { fqn: \\"testpkg.Foo\\", version: \\"0.0.1\\" }; + //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFDSSxNQUFhLEdBQUc7SUFBaEI7UUFDVSxPQUFFLEdBQUcsQ0FBQyxDQUFDO0tBS2hCO0lBSkMsSUFBVyxDQUFDOzs7Ozs7OztNQUFHLE9BQU8sSUFBSSxDQUFDLEVBQUUsQ0FBQSxFQUFDO0lBRTlCLHFDQUFxQztJQUNyQyxJQUFXLENBQUMsQ0FBQyxFQUFVOzs7Ozs7OztNQUFHLElBQUksQ0FBQyxFQUFFLEdBQUcsRUFBRSxDQUFDLEVBQUM7O0FBTDFDLGtCQU1DIiwic291cmNlc0NvbnRlbnQiOlsiXG4gICAgZXhwb3J0IGNsYXNzIEZvbyB7XG4gICAgICBwcml2YXRlIF94ID0gMDtcbiAgICAgIHB1YmxpYyBnZXQgeCgpe3JldHVybiB0aGlzLl94fVxuXG4gICAgICAvKiogQGRlcHJlY2F0ZWQgVXNlIHNvbWV0aGluZyBlbHNlICovXG4gICAgICBwdWJsaWMgc2V0IHgoX3g6IG51bWJlcikge3RoaXMuX3ggPSBfeDt9XG4gICAgfVxuICAiXX0=" + `); }); - test('deprecated classes', async () => { - const result = await compileJsiiForTest( + test('creates a new instance of error when test', () => { + const result = compileJsiiForTest( ` ${DEPRECATED} export class Foo { @@ -492,9 +642,207 @@ describe('Call injections', () => { { addDeprecationWarnings: true }, ); - expect(jsFile(result)).toMatch( - 'constructor() { jsiiDeprecationWarnings.print("testpkg.Foo", "Use something else"); }', + expect(jsFile(result)).toMatchInlineSnapshot(` + "\\"use strict\\"; + var _a; + Object.defineProperty(exports, \\"__esModule\\", { value: true }); + exports.Foo = void 0; + const jsiiDeprecationWarnings = require(\\"./.warnings.jsii.js\\"); + const JSII_RTTI_SYMBOL_1 = Symbol.for(\\"jsii.rtti\\"); + /** @deprecated Use something else */ + class Foo { + constructor() { try { + jsiiDeprecationWarnings.print(\\"testpkg.Foo\\", \\"Use something else\\"); + } + catch (error) { + if (process.env.JSII_DEBUG !== \\"1\\" && error.name === \\"DeprecationError\\") { + Error.captureStackTrace(error, this.constructor); + } + throw error; + } } + } + exports.Foo = Foo; + _a = JSII_RTTI_SYMBOL_1; + Foo[_a] = { fqn: \\"testpkg.Foo\\", version: \\"0.0.1\\" }; + //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFDSSxxQ0FBcUM7QUFDckMsTUFBYSxHQUFHO0lBQ2Q7Ozs7Ozs7O09BQWU7O0FBRGpCLGtCQUVDIiwic291cmNlc0NvbnRlbnQiOlsiXG4gICAgLyoqIEBkZXByZWNhdGVkIFVzZSBzb21ldGhpbmcgZWxzZSAqL1xuICAgIGV4cG9ydCBjbGFzcyBGb28ge1xuICAgICAgY29uc3RydWN0b3IoKXt9XG4gICAgfVxuICAiXX0=" + `); + }); +}); + +describe('thrown exceptions have the expected stack trace', () => { + test('constructor', () => { + const compilation = compileJsiiForTest( + ` + /** @deprecated for testing */ + export class DeprecatedConstructor { + public constructor() {} + } + + function test() { + new DeprecatedConstructor(); + } + + test(); + `, + undefined, + { addDeprecationWarnings: true }, + ); + const source = jsFile(compilation); + + const context = createVmContext(compilation); + try { + vm.runInContext(source, context, { filename: 'index.js' }); + // The above line should have resulted in a DeprecationError being thrown + expect(null).toBeInstanceOf(Error); + } catch (error) { + expect(error.stack.replace(process.cwd(), '')) + .toMatchInlineSnapshot(` + "index.js:16 + throw error; + ^ + + DeprecationError: testpkg.DeprecatedConstructor is deprecated. + for testing + This API will be removed in the next major release. + at test (index.js:23:5) + at index.js:25:1" + `); + } + }); + + test('getter', () => { + const compilation = compileJsiiForTest( + ` + export class DeprecatedConstructor { + /** @deprecated for testing */ + public get property() { + return 1337; + } + } + + function test() { + const subject = new DeprecatedConstructor(); + return subject.property; + } + + test(); + `, + undefined, + { addDeprecationWarnings: true }, + ); + const source = jsFile(compilation); + + const context = createVmContext(compilation); + try { + vm.runInContext(source, context, { filename: 'index.js' }); + // The above line should have resulted in a DeprecationError being thrown + expect(null).toBeInstanceOf(Error); + } catch (error) { + expect(error.stack.replace(process.cwd(), '')) + .toMatchInlineSnapshot(` + "index.js:17 + throw error; + ^ + + DeprecationError: testpkg.DeprecatedConstructor#property is deprecated. + for testing + This API will be removed in the next major release. + at test (index.js:27:20) + at index.js:29:1" + `); + } + }); + + test('setter', () => { + const compilation = compileJsiiForTest( + ` + export class DeprecatedConstructor { + private value = 1337; + + /** @deprecated for testing */ + public get property(): number { + return this.value; + } + + public set property(value: number) { + this.value = value; + } + } + + function test() { + const subject = new DeprecatedConstructor(); + subject.property = 42; + } + + test(); + `, + undefined, + { addDeprecationWarnings: true }, + ); + const source = jsFile(compilation); + + const context = createVmContext(compilation); + try { + vm.runInContext(source, context, { filename: 'index.js' }); + // The above line should have resulted in a DeprecationError being thrown + expect(null).toBeInstanceOf(Error); + } catch (error) { + expect(error.stack.replace(process.cwd(), '')) + .toMatchInlineSnapshot(` + "index.js:32 + throw error; + ^ + + DeprecationError: testpkg.DeprecatedConstructor#property is deprecated. + for testing + This API will be removed in the next major release. + at test (index.js:42:22) + at index.js:44:1" + `); + } + }); + + test('method', () => { + const compilation = compileJsiiForTest( + ` + export class DeprecatedConstructor { + /** @deprecated for testing */ + public deprecated(): void { + // Nothing to do + } + } + + function test() { + const subject = new DeprecatedConstructor(); + subject.deprecated(); + } + + test(); + `, + undefined, + { addDeprecationWarnings: true }, ); + const source = jsFile(compilation); + + const context = createVmContext(compilation); + try { + vm.runInContext(source, context, { filename: 'index.js' }); + // The above line should have resulted in a DeprecationError being thrown + expect(null).toBeInstanceOf(Error); + } catch (error) { + expect(error.stack.replace(process.cwd(), '')) + .toMatchInlineSnapshot(` + "index.js:17 + throw error; + ^ + + DeprecationError: testpkg.DeprecatedConstructor#deprecated is deprecated. + for testing + This API will be removed in the next major release. + at test (index.js:26:13) + at index.js:28:1" + `); + } }); }); @@ -503,22 +851,69 @@ function jsFile(result: HelperCompilationResult, baseName = 'index'): string { ([name]) => name === `${baseName}.js`, ); - return file![1]; + if (!file) { + throw new Error(`Could not find file with base name: ${baseName}`); + } + + return file[1]; +} + +function createVmContext(compilation: HelperCompilationResult) { + const context = vm.createContext({ + exports: {}, + process: { + env: { + JSII_DEPRECATED: 'fail', + }, + }, + // Bringing in a "fake" require(id) function that'll resolve relative paths + // to files within the compilation output, and module names using the + // regular require. When loading a file that was part of the compiler output, + // this emulates the situation that would be if the file had been through a + // bundler by turning all sequences of white spaces (new line included) into + // single spaces. + require: (id: string) => { + if (!id.startsWith('./')) { + // eslint-disable-next-line @typescript-eslint/no-require-imports + return require(id); + } + const code = jsFile(compilation, path.basename(id, '.js')) + // Pretend this has been webpack'd + .replace(/\s+/gm, ' '); + return vm.runInContext( + `(function(module){ + { + ${code} + } + return module.exports; + })({ exports: {} });`, + context, + { filename: id, lineOffset: -2, columnOffset: -4 }, + ); + }, + }); + + // Limit error stack traces to 2 frames... We don't need more for the sake of this test. This is + // important because past 2 levels, the stack frames will have entries that will be different on + // different versions of node, and that'll break our unit tests... + vm.runInContext('Error.stackTraceLimit = 2;', context); + + return context; } function resolveModuleDir(name: string) { return path.dirname(require.resolve(`${name}/package.json`)); } -async function compile(projectRoot: string, addDeprecationWarnings: boolean) { - const { projectInfo } = await loadProjectInfo(projectRoot); +function compile(projectRoot: string, addDeprecationWarnings: boolean) { + const { projectInfo } = loadProjectInfo(projectRoot); const compiler = new Compiler({ projectInfo, addDeprecationWarnings, }); - await compiler.emit(); + compiler.emit(); } function loadWarningsFile(projectRoot: string) { diff --git a/packages/jsii/test/docs.test.ts b/packages/jsii/test/docs.test.ts index b772d2c8ff..54b251d3ad 100644 --- a/packages/jsii/test/docs.test.ts +++ b/packages/jsii/test/docs.test.ts @@ -6,8 +6,8 @@ import { sourceToAssemblyHelper as compile } from '../lib'; jest.setTimeout(60_000); // ---------------------------------------------------------------------- -test('extract summary line from doc block, ends with a period', async () => { - const assembly = await compile(` +test('extract summary line from doc block, ends with a period', () => { + const assembly = compile(` /** * Hello this is the documentation for this class */ @@ -22,8 +22,8 @@ test('extract summary line from doc block, ends with a period', async () => { }); // ---------------------------------------------------------------------- -test('extract remarks from whitespace-separated doc block', async () => { - const assembly = await compile(` +test('extract remarks from whitespace-separated doc block', () => { + const assembly = compile(` /** * Hello this is the documentation for this class. * @@ -42,8 +42,8 @@ test('extract remarks from whitespace-separated doc block', async () => { }); // ---------------------------------------------------------------------- -test('separate long doc comment into summary and remarks', async () => { - const assembly = await compile(` +test('separate long doc comment into summary and remarks', () => { + const assembly = compile(` /** * Lots of people enjoy writing very long captions here. I think it's because they * copy/paste them out of CloudFormation, which has a tendency to just have one @@ -63,8 +63,8 @@ test('separate long doc comment into summary and remarks', async () => { }); // ---------------------------------------------------------------------- -test('separate non-space but newline terminated docs into summary&remarks', async () => { - const assembly = await compile(` +test('separate non-space but newline terminated docs into summary&remarks', () => { + const assembly = compile(` /** * Lots of people enjoy writing very long captions here. * I think it's because they copy/paste them out of CloudFormation, @@ -85,8 +85,8 @@ test('separate non-space but newline terminated docs into summary&remarks', asyn }); // ---------------------------------------------------------------------- -test('dont add period to summary that ends in exclamation mark', async () => { - const assembly = await compile(` +test('dont add period to summary that ends in exclamation mark', () => { + const assembly = compile(` /** * I'm happy about this class! */ @@ -101,8 +101,8 @@ test('dont add period to summary that ends in exclamation mark', async () => { }); // ---------------------------------------------------------------------- -test('parse method docs', async () => { - const assembly = await compile(` +test('parse method docs', () => { + const assembly = compile(` export class Foo { /** * Do the foo @@ -119,8 +119,8 @@ test('parse method docs', async () => { }); // ---------------------------------------------------------------------- -test('associate parameter comments with right parameter', async () => { - const assembly = await compile(` +test('associate parameter comments with right parameter', () => { + const assembly = compile(` export class Foo { /** * Do the foo @@ -139,8 +139,8 @@ test('associate parameter comments with right parameter', async () => { }); // ---------------------------------------------------------------------- -test('read example', async () => { - const assembly = await compile(` +test('read example', () => { + const assembly = compile(` export class Foo { /** * Do the foo @@ -162,8 +162,8 @@ test('read example', async () => { }); // ---------------------------------------------------------------------- -test('read default value', async () => { - const assembly = await compile(` +test('read default value', () => { + const assembly = compile(` export interface Foo { /** * The foo we're talking about @@ -180,8 +180,8 @@ test('read default value', async () => { }); // ---------------------------------------------------------------------- -test('read "see" annotation', async () => { - const assembly = await compile(` +test('read "see" annotation', () => { + const assembly = compile(` /** * @see http://lmgtfy.com/ */ @@ -193,8 +193,8 @@ test('read "see" annotation', async () => { }); // ---------------------------------------------------------------------- -test('read "returns" annotation', async () => { - const assembly = await compile(` +test('read "returns" annotation', () => { + const assembly = compile(` export class Foo { /** * Do the foo @@ -211,8 +211,8 @@ test('read "returns" annotation', async () => { }); // ---------------------------------------------------------------------- -test('can haz deprecated', async () => { - const assembly = await compile(` +test('can haz deprecated', () => { + const assembly = compile(` export class Foo { /** * Do the foo @@ -231,8 +231,8 @@ test('can haz deprecated', async () => { }); // ---------------------------------------------------------------------- -test('can mark stable', async () => { - const assembly = await compile(` +test('can mark stable', () => { + const assembly = compile(` /** * Rock solid Foo * @@ -248,8 +248,8 @@ test('can mark stable', async () => { }); // ---------------------------------------------------------------------- -test('can mark experimental', async () => { - const assembly = await compile(` +test('can mark experimental', () => { + const assembly = compile(` /** * Slightly less solid Foo * @@ -266,8 +266,8 @@ test('can mark experimental', async () => { // ---------------------------------------------------------------------- -test('can mark external', async () => { - const assembly = await compile(` +test('can mark external', () => { + const assembly = compile(` /** * @stability external */ @@ -286,8 +286,8 @@ test('can mark external', async () => { }); // ---------------------------------------------------------------------- -test('can mark subclassable', async () => { - const assembly = await compile(` +test('can mark subclassable', () => { + const assembly = compile(` /** * Become this Foo * @@ -303,8 +303,8 @@ test('can mark subclassable', async () => { }); // ---------------------------------------------------------------------- -test('can add arbitrary tags', async () => { - const assembly = await compile(` +test('can add arbitrary tags', () => { + const assembly = compile(` /** * @boop */ @@ -318,7 +318,7 @@ test('can add arbitrary tags', async () => { }); // ---------------------------------------------------------------------- -test('stability is inherited from parent type', async () => { +test('stability is inherited from parent type', () => { const stabilities = [ ['@deprecated Not good no more', Stability.Deprecated], ['@experimental', Stability.Experimental], @@ -327,7 +327,7 @@ test('stability is inherited from parent type', async () => { for (const [tag, stability] of stabilities) { // eslint-disable-next-line no-await-in-loop - const assembly = await compile(` + const assembly = compile(` /** * ${tag} */ @@ -354,8 +354,8 @@ test('stability is inherited from parent type', async () => { }); // ---------------------------------------------------------------------- -test('@example can contain @ sign', async () => { - const assembly = await compile(` +test('@example can contain @ sign', () => { + const assembly = compile(` /** * An IAM role to associate with the instance profile assigned to this Auto Scaling Group. * diff --git a/packages/jsii/test/enums.test.ts b/packages/jsii/test/enums.test.ts index 7cae6cb00e..0c4252603c 100644 --- a/packages/jsii/test/enums.test.ts +++ b/packages/jsii/test/enums.test.ts @@ -3,8 +3,8 @@ import { EnumType } from '@jsii/spec'; import { sourceToAssemblyHelper } from '../lib'; // ---------------------------------------------------------------------- -test('test parsing enum with two members and no values', async () => { - const assembly = await sourceToAssemblyHelper(` +test('test parsing enum with two members and no values', () => { + const assembly = sourceToAssemblyHelper(` export enum Foo { BAR, BAZ @@ -23,8 +23,8 @@ test('test parsing enum with two members and no values', async () => { }); // ---------------------------------------------------------------------- -test('test parsing enum with two members and assigned values', async () => { - const assembly = await sourceToAssemblyHelper(` +test('test parsing enum with two members and assigned values', () => { + const assembly = sourceToAssemblyHelper(` export enum Foo { BAR = 'Bar', BAZ = 'Baz' @@ -44,8 +44,8 @@ test('test parsing enum with two members and assigned values', async () => { // ---------------------------------------------------------------------- -test('enums can have a mix of letters and number', async () => { - const assembly = await sourceToAssemblyHelper(` +test('enums can have a mix of letters and number', () => { + const assembly = sourceToAssemblyHelper(` export enum Foo { Q5X, IB3M, diff --git a/packages/jsii/test/export-specifier.test.ts b/packages/jsii/test/export-specifier.test.ts index cc0391fcc0..db2129b62a 100644 --- a/packages/jsii/test/export-specifier.test.ts +++ b/packages/jsii/test/export-specifier.test.ts @@ -1,7 +1,7 @@ import { sourceToAssemblyHelper } from '../lib'; -test('export { Foo } from "./foo"', async () => { - const assembly = await sourceToAssemblyHelper({ +test('export { Foo } from "./foo"', () => { + const assembly = sourceToAssemblyHelper({ 'index.ts': 'export { Foo } from "./foo";', 'foo.ts': 'export class Foo { private constructor() {} }', }); diff --git a/packages/jsii/test/hints.test.ts b/packages/jsii/test/hints.test.ts index 0df21078ca..f9c9a5b4f7 100644 --- a/packages/jsii/test/hints.test.ts +++ b/packages/jsii/test/hints.test.ts @@ -3,8 +3,8 @@ import { InterfaceType, TypeKind } from '@jsii/spec'; import { sourceToAssemblyHelper } from '../lib'; describe('@struct', () => { - test('causes behavioral-named interfaces to be structs', async () => { - const assembly = await sourceToAssemblyHelper(` + test('causes behavioral-named interfaces to be structs', () => { + const assembly = sourceToAssemblyHelper(` /** @struct */ export interface IPSet { readonly cidr: string; @@ -17,8 +17,8 @@ describe('@struct', () => { ); }); - test('can be used on any struct', async () => { - const assembly = await sourceToAssemblyHelper(` + test('can be used on any struct', () => { + const assembly = sourceToAssemblyHelper(` /** @struct */ export interface Struct { readonly cidr: string; diff --git a/packages/jsii/test/literate.test.ts b/packages/jsii/test/literate.test.ts index d34bd549ef..d0d289c3e7 100644 --- a/packages/jsii/test/literate.test.ts +++ b/packages/jsii/test/literate.test.ts @@ -90,7 +90,7 @@ test('can add inline MarkDown', () => { ); }); -test('can do example inclusion', async () => { +test('can do example inclusion', () => { const inputMarkDown = [ 'This is a preamble', '[included here](test/something.lit.ts)', @@ -105,11 +105,7 @@ test('can do example inclusion', async () => { }; }; - const rendered = await includeAndRenderExamples( - inputMarkDown, - fakeLoader, - '.', - ); + const rendered = includeAndRenderExamples(inputMarkDown, fakeLoader, '.'); expect(rendered).toEqual([ 'This is a preamble', diff --git a/packages/jsii/test/negatives.test.ts b/packages/jsii/test/negatives.test.ts index a53d3b5f44..fb47463cdf 100644 --- a/packages/jsii/test/negatives.test.ts +++ b/packages/jsii/test/negatives.test.ts @@ -24,8 +24,8 @@ for (const source of fs.readdirSync(SOURCE_DIR)) { const filePath = path.join(SOURCE_DIR, source); test( source.replace(/neg\.(.+)\.ts/, '$1'), - async () => { - const { strict, stripDeprecated } = await _getPragmas(filePath); + () => { + const { strict, stripDeprecated } = _getPragmas(filePath); // Change in dir, so relative paths are processed correctly. process.chdir(SOURCE_DIR); @@ -35,7 +35,7 @@ for (const source of fs.readdirSync(SOURCE_DIR)) { failOnWarnings: strict, stripDeprecated, }); - const emitResult = await compiler.emit(path.join(SOURCE_DIR, source)); + const emitResult = compiler.emit(path.join(SOURCE_DIR, source)); expect(emitResult.emitSkipped).toBeTruthy(); @@ -57,23 +57,17 @@ for (const source of fs.readdirSync(SOURCE_DIR)) { ).toMatchSnapshot(); // Cleaning up... - return Promise.all( - (await fs.readdir(SOURCE_DIR)).map((file) => { - const promises = new Array>(); - if ( - file.startsWith('neg.') && - (file.endsWith('.d.ts') || file.endsWith('.js')) - ) { - promises.push(fs.remove(path.join(SOURCE_DIR, file))); - } - promises.push( - fs.remove(path.join(SOURCE_DIR, '.jsii')), - fs.remove(path.join(SOURCE_DIR, 'tsconfig.json')), - fs.remove(path.join(SOURCE_DIR, '.build')), - ); - return Promise.all(promises); - }), - ); + fs.readdirSync(SOURCE_DIR).forEach((file) => { + if ( + file.startsWith('neg.') && + (file.endsWith('.d.ts') || file.endsWith('.js')) + ) { + fs.removeSync(path.join(SOURCE_DIR, file)); + } + fs.removeSync(path.join(SOURCE_DIR, '.jsii')); + fs.removeSync(path.join(SOURCE_DIR, 'tsconfig.json')); + fs.removeSync(path.join(SOURCE_DIR, '.build')); + }); }, 50000, ); @@ -81,10 +75,11 @@ for (const source of fs.readdirSync(SOURCE_DIR)) { const STRICT_MARKER = '///!STRICT!'; const STRIP_DEPRECATED_MARKER = '///!STRIP_DEPRECATED!'; -async function _getPragmas( - file: string, -): Promise<{ strict: boolean; stripDeprecated: boolean }> { - const data = await fs.readFile(file, { encoding: 'utf8' }); +function _getPragmas(file: string): { + strict: boolean; + stripDeprecated: boolean; +} { + const data = fs.readFileSync(file, { encoding: 'utf8' }); const lines = data.split('\n'); const strict = lines.some((line) => line.startsWith(STRICT_MARKER)); const stripDeprecated = lines.some((line) => diff --git a/packages/jsii/test/project-info.test.ts b/packages/jsii/test/project-info.test.ts index bf106243f1..ad68d5d81f 100644 --- a/packages/jsii/test/project-info.test.ts +++ b/packages/jsii/test/project-info.test.ts @@ -30,8 +30,8 @@ const BASE_PROJECT = { describe('loadProjectInfo', () => { test('loads valid project', () => - _withTestProject(async (projectRoot) => { - const { projectInfo: info } = await loadProjectInfo(projectRoot); + _withTestProject((projectRoot) => { + const { projectInfo: info } = loadProjectInfo(projectRoot); expect(info.name).toBe(BASE_PROJECT.name); expect(info.version).toBe(BASE_PROJECT.version); expect(info.description).toBe(BASE_PROJECT.description); @@ -61,8 +61,8 @@ describe('loadProjectInfo', () => { test('loads valid project (UNLICENSED)', () => _withTestProject( - async (projectRoot) => { - const { projectInfo: info } = await loadProjectInfo(projectRoot); + (projectRoot) => { + const { projectInfo: info } = loadProjectInfo(projectRoot); expect(info?.license).toBe('UNLICENSED'); }, (info) => { @@ -72,8 +72,8 @@ describe('loadProjectInfo', () => { test('loads valid project (using bundleDependencies)', () => _withTestProject( - async (projectRoot) => { - const { projectInfo: info } = await loadProjectInfo(projectRoot); + (projectRoot) => { + const { projectInfo: info } = loadProjectInfo(projectRoot); expect(info.bundleDependencies).toEqual({ bundled: '^1.2.3' }); }, (info) => { @@ -84,8 +84,8 @@ describe('loadProjectInfo', () => { test('loads valid project (using bundledDependencies)', () => _withTestProject( - async (projectRoot) => { - const { projectInfo: info } = await loadProjectInfo(projectRoot); + (projectRoot) => { + const { projectInfo: info } = loadProjectInfo(projectRoot); expect(info.bundleDependencies).toEqual({ bundled: '^1.2.3' }); }, (info) => { @@ -97,8 +97,8 @@ describe('loadProjectInfo', () => { test('loads valid project (with contributors)', () => { const contributors = [{ name: 'foo', email: 'nobody@amazon.com' }]; return _withTestProject( - async (projectRoot) => { - const { projectInfo: info } = await loadProjectInfo(projectRoot); + (projectRoot) => { + const { projectInfo: info } = loadProjectInfo(projectRoot); expect(info?.contributors?.map(_stripUndefined)).toEqual( contributors.map((c) => ({ ...c, roles: ['contributor'] })), ); @@ -110,7 +110,7 @@ describe('loadProjectInfo', () => { test('rejects un-declared dependency in bundleDependencies', () => _withTestProject( (projectRoot) => - expect(loadProjectInfo(projectRoot)).rejects.toThrow( + expect(() => loadProjectInfo(projectRoot)).toThrow( /not declared in "dependencies"/i, ), (info) => { @@ -121,7 +121,7 @@ describe('loadProjectInfo', () => { test('rejects invalid license', () => _withTestProject( (projectRoot) => - expect(loadProjectInfo(projectRoot)).rejects.toThrow( + expect(() => loadProjectInfo(projectRoot)).toThrow( /invalid license identifier/i, ), (info) => { @@ -132,7 +132,7 @@ describe('loadProjectInfo', () => { test('rejects incompatible dependency version', () => _withTestProject( (projectRoot) => - expect(loadProjectInfo(projectRoot)).rejects.toThrow( + expect(() => loadProjectInfo(projectRoot)).toThrow( /declared dependency on version .+ but version .+ was found/i, ), (info) => { @@ -144,7 +144,7 @@ describe('loadProjectInfo', () => { test('missing peerDependencies are allowed', () => _withTestProject( (projectRoot) => - expect(loadProjectInfo(projectRoot)).resolves.toEqual( + expect(loadProjectInfo(projectRoot)).toEqual( expect.objectContaining({ diagnostics: [], }), @@ -157,7 +157,7 @@ describe('loadProjectInfo', () => { test('warns if peerDependency misses a matching devDependency', () => _withTestProject( (projectRoot) => - expect(loadProjectInfo(projectRoot)).resolves.toEqual( + expect(loadProjectInfo(projectRoot)).toEqual( expect.objectContaining({ diagnostics: [expect.objectContaining({ jsiiCode: 6 })], }), @@ -170,7 +170,7 @@ describe('loadProjectInfo', () => { test('warns if peerDependency has a devDependency on the wrong version', () => _withTestProject( (projectRoot) => - expect(loadProjectInfo(projectRoot)).resolves.toEqual( + expect(loadProjectInfo(projectRoot)).toEqual( expect.objectContaining({ diagnostics: [expect.objectContaining({ jsiiCode: 6 })], }), @@ -184,7 +184,7 @@ describe('loadProjectInfo', () => { test('no warnings if devDependency point version matches peerDependency range', () => _withTestProject( (projectRoot) => - expect(loadProjectInfo(projectRoot)).resolves.toEqual( + expect(loadProjectInfo(projectRoot)).toEqual( expect.objectContaining({ diagnostics: [], }), @@ -198,8 +198,8 @@ describe('loadProjectInfo', () => { describe('_loadDiagnostics', () => { test('diagnostic categories are correctly detected', () => { return _withTestProject( - async (projectRoot) => { - const { projectInfo: info } = await loadProjectInfo(projectRoot); + (projectRoot) => { + const { projectInfo: info } = loadProjectInfo(projectRoot); expect(info.diagnostics).toBeDefined(); const diagnostics = info.diagnostics!; expect(Object.keys(diagnostics).sort()).toEqual([ @@ -230,7 +230,7 @@ describe('loadProjectInfo', () => { test('invalid category is rejected', () => { return _withTestProject( (projectRoot) => - expect(loadProjectInfo(projectRoot)).rejects.toThrow( + expect(() => loadProjectInfo(projectRoot)).toThrow( /Invalid category/, ), (info) => { @@ -291,11 +291,11 @@ const TEST_DEP_DEP_ASSEMBLY: spec.Assembly = { * * @return the result of executing ``cb``. */ -async function _withTestProject( - cb: (projectRoot: string) => T | Promise, +function _withTestProject( + cb: (projectRoot: string) => T, gremlin?: (packageInfo: any) => void, -): Promise { - const tmpdir = await fs.mkdtemp( +): T { + const tmpdir = fs.mkdtempSync( path.join(os.tmpdir(), path.basename(__filename)), ); try { @@ -303,53 +303,50 @@ async function _withTestProject( if (gremlin) { gremlin(packageInfo); } - await fs.writeJson(path.join(tmpdir, 'package.json'), packageInfo, { + fs.writeJsonSync(path.join(tmpdir, 'package.json'), packageInfo, { spaces: 2, }); - await fs.writeFile( + fs.writeFileSync( path.join(tmpdir, 'index.js'), '// There ought to be some javascript', ); - await fs.writeFile( + fs.writeFileSync( path.join(tmpdir, 'index.ts'), '// There ought to be some typescript', ); - await fs.writeFile( + fs.writeFileSync( path.join(tmpdir, 'index.d.ts'), '// There ought to be some typescript definitions', ); const jsiiTestDep = path.join(tmpdir, 'node_modules', 'jsii-test-dep'); - await writeNpmPackageSkeleton(jsiiTestDep); + writeNpmPackageSkeleton(jsiiTestDep); - await fs.writeJson(path.join(jsiiTestDep, '.jsii'), TEST_DEP_ASSEMBLY); + fs.writeJsonSync(path.join(jsiiTestDep, '.jsii'), TEST_DEP_ASSEMBLY); const jsiiTestDepDep = path.join( jsiiTestDep, 'node_modules', 'jsii-test-dep-dep', ); - await writeNpmPackageSkeleton(jsiiTestDepDep); - await fs.writeJson( - path.join(jsiiTestDepDep, '.jsii'), - TEST_DEP_DEP_ASSEMBLY, - ); + writeNpmPackageSkeleton(jsiiTestDepDep); + fs.writeJsonSync(path.join(jsiiTestDepDep, '.jsii'), TEST_DEP_DEP_ASSEMBLY); - return await cb(tmpdir); + return cb(tmpdir); } finally { - await fs.remove(tmpdir); + fs.removeSync(tmpdir); } } /** * Write a package.json and an index.js so the package is mostly well-formed */ -async function writeNpmPackageSkeleton(directory: string) { - await fs.mkdirs(directory); - await fs.writeJson(path.join(directory, 'package.json'), { +function writeNpmPackageSkeleton(directory: string) { + fs.mkdirsSync(directory); + fs.writeJsonSync(path.join(directory, 'package.json'), { name: path.basename(directory), }); - await fs.writeFile( + fs.writeFileSync( path.join(directory, 'index.js'), '// There should be some JS', ); diff --git a/packages/jsii/test/quirks.test.ts b/packages/jsii/test/quirks.test.ts index 86f56085ff..4a43b49c0e 100644 --- a/packages/jsii/test/quirks.test.ts +++ b/packages/jsii/test/quirks.test.ts @@ -1,8 +1,8 @@ import { sourceToAssemblyHelper } from '../lib'; // ---------------------------------------------------------------------- -test('trailing semicolon after method is correctly ignored', async () => { - const assembly = await sourceToAssemblyHelper(` +test('trailing semicolon after method is correctly ignored', () => { + const assembly = sourceToAssemblyHelper(` export class Foo { private readonly initialized: boolean; diff --git a/packages/jsii/test/submodules.test.ts b/packages/jsii/test/submodules.test.ts index 244e5e8d58..beeedc4bc5 100644 --- a/packages/jsii/test/submodules.test.ts +++ b/packages/jsii/test/submodules.test.ts @@ -8,8 +8,8 @@ import { compileJsiiForTest, } from '../lib'; -test('submodules loaded from directories can have a README', async () => { - const assembly = await sourceToAssemblyHelper({ +test('submodules loaded from directories can have a README', () => { + const assembly = sourceToAssemblyHelper({ 'index.ts': 'export * as submodule from "./subdir"', 'subdir/index.ts': 'export class Foo { }', 'subdir/README.md': 'This is the README', @@ -24,8 +24,8 @@ test('submodules loaded from directories can have a README', async () => { ); }); -test('submodules loaded from files can have a README', async () => { - const assembly = await sourceToAssemblyHelper({ +test('submodules loaded from files can have a README', () => { + const assembly = sourceToAssemblyHelper({ 'index.ts': 'export * as submodule from "./submod"', 'submod.ts': 'export class Foo { }', 'submod.README.md': 'This is the README', @@ -40,8 +40,8 @@ test('submodules loaded from files can have a README', async () => { ); }); -test('submodules loaded from directories can have targets', async () => { - const assembly = await sourceToAssemblyHelper({ +test('submodules loaded from directories can have targets', () => { + const assembly = sourceToAssemblyHelper({ 'index.ts': 'export * as submodule from "./subdir"', 'subdir/index.ts': 'export class Foo { }', 'subdir/.jsiirc.json': JSON.stringify({ @@ -60,8 +60,8 @@ test('submodules loaded from directories can have targets', async () => { ); }); -test('submodule READMEs can have literate source references', async () => { - const assembly = await sourceToAssemblyHelper({ +test('submodule READMEs can have literate source references', () => { + const assembly = sourceToAssemblyHelper({ 'index.ts': 'export * as submodule from "./subdir"', 'subdir/index.ts': 'export class Foo { }', 'subdir/README.md': @@ -89,7 +89,7 @@ type ImportStyle = 'directly' | 'as namespace' | 'with alias'; test.each(['directly', 'as namespace', 'with alias'] as ImportStyle[])( 'can reference submodule types, importing %s', (importStyle) => - TestWorkspace.withWorkspace(async (ws) => { + TestWorkspace.withWorkspace((ws) => { // There are 2 import styles: // // import { submodule } from 'lib'; @@ -98,7 +98,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 makeDependencyWithSubmodule()); + ws.addDependency(makeDependencyWithSubmodule()); let importStatement; let prefix; @@ -120,7 +120,7 @@ test.each(['directly', 'as namespace', 'with alias'] as ImportStyle[])( // Main library that imports the submodule class directly // Use the type in all possible positions - const result = await compileJsiiForTest( + const result = compileJsiiForTest( { 'index.ts': ` ${importStatement}; @@ -174,7 +174,7 @@ test.each(['directly', 'as namespace', 'with alias'] as ImportStyle[])( test.each(['directly', 'as namespace', 'with alias'] as ImportStyle[])( 'can reference nested types in submodules, importing %s', (importStyle) => - TestWorkspace.withWorkspace(async (ws) => { + TestWorkspace.withWorkspace((ws) => { // There are 2 import styles: // // import { submodule } from 'lib'; @@ -183,7 +183,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 makeDependencyWithSubmoduleAndNamespace()); + ws.addDependency(makeDependencyWithSubmoduleAndNamespace()); let importStatement; let prefix; @@ -204,7 +204,7 @@ test.each(['directly', 'as namespace', 'with alias'] as ImportStyle[])( // Main library that imports the submodule class directly // Use the type in all possible positions - const result = await compileJsiiForTest( + const result = compileJsiiForTest( { 'index.ts': ` ${importStatement}; @@ -258,22 +258,22 @@ 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()); + TestWorkspace.withWorkspace((ws) => { + ws.addDependency(makeDependencyWithSubmodule()); // Strip the symbolidentifiers from the assembly const asmFile = path.join(ws.dependencyDir('testpkg'), '.jsii'); - const asm: spec.Assembly = await fs.readJson(asmFile); + const asm: spec.Assembly = fs.readJsonSync(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); + fs.writeJsonSync(asmFile, asm); // We can still use those types if we have a full-library import - await compileJsiiForTest( + compileJsiiForTest( { 'index.ts': ` import { submodule } from 'testpkg'; @@ -293,7 +293,7 @@ test('will detect types from submodules even if the symbol identifier table is m ); })); -async function makeDependencyWithSubmodule() { +function makeDependencyWithSubmodule() { return compileJsiiForTest({ 'index.ts': 'export * as submodule from "./subdir"', 'subdir/index.ts': [ @@ -305,7 +305,7 @@ async function makeDependencyWithSubmodule() { }); } -async function makeDependencyWithSubmoduleAndNamespace() { +function makeDependencyWithSubmoduleAndNamespace() { return compileJsiiForTest({ 'index.ts': 'export * as submodule from "./subdir"', 'subdir/index.ts': [ diff --git a/packages/jsii/test/symbol-identifiers.test.ts b/packages/jsii/test/symbol-identifiers.test.ts index 04a6a83c80..b1e90a55c4 100644 --- a/packages/jsii/test/symbol-identifiers.test.ts +++ b/packages/jsii/test/symbol-identifiers.test.ts @@ -1,7 +1,7 @@ import { compileJsiiForTest, normalizePath } from '../lib'; -test('Symbol map is generated', async () => { - const result = await compileJsiiForTest( +test('Symbol map is generated', () => { + const result = compileJsiiForTest( { 'index.ts': ` export * from './some/nested/file'; @@ -29,8 +29,8 @@ test('Symbol map is generated', async () => { expect(types['testpkg.Baz'].symbolId).toEqual('some/nested/file:Baz'); }); -test('Symbol id for single-value enum correctly identifies enum', async () => { - const result = await compileJsiiForTest( +test('Symbol id for single-value enum correctly identifies enum', () => { + const result = compileJsiiForTest( { 'index.ts': ` export enum SomeEnum { @@ -46,8 +46,8 @@ test('Symbol id for single-value enum correctly identifies enum', async () => { expect(types['testpkg.SomeEnum'].symbolId).toEqual('index:SomeEnum'); }); -test('Module declarations are included in symbolId', async () => { - const result = await compileJsiiForTest( +test('Module declarations are included in symbolId', () => { + const result = compileJsiiForTest( { 'index.ts': ` export class Foo { @@ -69,8 +69,8 @@ test('Module declarations are included in symbolId', async () => { expect(types['testpkg.Foo.Bar'].symbolId).toEqual('index:Foo.Bar'); }); -test('Submodules also have symbol identifiers', async () => { - const result = await compileJsiiForTest( +test('Submodules also have symbol identifiers', () => { + const result = compileJsiiForTest( { 'index.ts': `export * as submod from './submodule';`, 'submodule.ts': ` @@ -89,8 +89,8 @@ test('Submodules also have symbol identifiers', async () => { ); }); -test('Submodules also have symbol identifiers', async () => { - const result = await compileJsiiForTest( +test('Submodules also have symbol identifiers', () => { + const result = compileJsiiForTest( { 'index.ts': ` export namespace cookie { diff --git a/packages/oo-ascii-tree/package.json b/packages/oo-ascii-tree/package.json index 55ae5704df..da2c6a9512 100644 --- a/packages/oo-ascii-tree/package.json +++ b/packages/oo-ascii-tree/package.json @@ -33,10 +33,10 @@ "devDependencies": { "@types/jest": "^27.4.1", "@types/node": "^12.20.47", - "eslint": "^8.10.0", + "eslint": "^8.12.0", "jest": "^27.5.1", "jsii-build-tools": "^0.0.0", - "prettier": "^2.5.1", + "prettier": "^2.6.2", "typescript": "~3.9.10" } } diff --git a/tools/jsii-compliance/package.json b/tools/jsii-compliance/package.json index a6f5e60b1a..6b4e3caee2 100644 --- a/tools/jsii-compliance/package.json +++ b/tools/jsii-compliance/package.json @@ -17,8 +17,8 @@ }, "devDependencies": { "@types/node": "^12.20.47", - "eslint": "^8.10.0", - "prettier": "^2.5.1", + "eslint": "^8.12.0", + "prettier": "^2.6.2", "ts-node": "^10.7.0", "typescript": "~3.9.10" } diff --git a/yarn.lock b/yarn.lock index 8291086ae9..000674d993 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16,23 +16,23 @@ dependencies: "@babel/highlight" "^7.16.7" -"@babel/compat-data@^7.16.4": - version "7.17.0" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.17.0.tgz#86850b8597ea6962089770952075dcaabb8dba34" - integrity sha512-392byTlpGWXMv4FbyWw3sAZ/FrW/DrwqLGXpy0mbyNe9Taqv1mg9yON5/o0cnr8XYCkFTZbC1eV+c+LAROgrng== +"@babel/compat-data@^7.17.7": + version "7.17.7" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.17.7.tgz#078d8b833fbbcc95286613be8c716cef2b519fa2" + integrity sha512-p8pdE6j0a29TNGebNm7NzYZWB3xVZJBZ7XGs42uAKzQo8VQ3F0By/cQCtUEABwIqw5zo6WA4NbmxsfzADzMKnQ== "@babel/core@^7.1.0", "@babel/core@^7.12.3", "@babel/core@^7.7.2", "@babel/core@^7.8.0": - version "7.17.5" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.17.5.tgz#6cd2e836058c28f06a4ca8ee7ed955bbf37c8225" - integrity sha512-/BBMw4EvjmyquN5O+t5eh0+YqB3XXJkYD2cjKpYtWOfFy4lQ4UozNSmxAcWT8r2XtZs0ewG+zrfsqeR15i1ajA== + version "7.17.8" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.17.8.tgz#3dac27c190ebc3a4381110d46c80e77efe172e1a" + integrity sha512-OdQDV/7cRBtJHLSOBqqbYNkOcydOgnX59TZx4puf41fzcVtN3e/4yqY8lMQsK+5X2lJtAdmA+6OHqsj1hBJ4IQ== dependencies: "@ampproject/remapping" "^2.1.0" "@babel/code-frame" "^7.16.7" - "@babel/generator" "^7.17.3" - "@babel/helper-compilation-targets" "^7.16.7" - "@babel/helper-module-transforms" "^7.16.7" - "@babel/helpers" "^7.17.2" - "@babel/parser" "^7.17.3" + "@babel/generator" "^7.17.7" + "@babel/helper-compilation-targets" "^7.17.7" + "@babel/helper-module-transforms" "^7.17.7" + "@babel/helpers" "^7.17.8" + "@babel/parser" "^7.17.8" "@babel/template" "^7.16.7" "@babel/traverse" "^7.17.3" "@babel/types" "^7.17.0" @@ -42,21 +42,21 @@ json5 "^2.1.2" semver "^6.3.0" -"@babel/generator@^7.17.3", "@babel/generator@^7.7.2": - version "7.17.3" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.3.tgz#a2c30b0c4f89858cb87050c3ffdfd36bdf443200" - integrity sha512-+R6Dctil/MgUsZsZAkYgK+ADNSZzJRRy0TvY65T71z/CR854xHQ1EweBYXdfT+HNeN7w0cSJJEzgxZMv40pxsg== +"@babel/generator@^7.17.3", "@babel/generator@^7.17.7", "@babel/generator@^7.7.2": + version "7.17.7" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.7.tgz#8da2599beb4a86194a3b24df6c085931d9ee45ad" + integrity sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w== dependencies: "@babel/types" "^7.17.0" jsesc "^2.5.1" source-map "^0.5.0" -"@babel/helper-compilation-targets@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.16.7.tgz#06e66c5f299601e6c7da350049315e83209d551b" - integrity sha512-mGojBwIWcwGD6rfqgRXVlVYmPAv7eOpIemUG3dGnDdCY4Pae70ROij3XmfrH6Fa1h1aiDylpglbZyktfzyo/hA== +"@babel/helper-compilation-targets@^7.17.7": + version "7.17.7" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.17.7.tgz#a3c2924f5e5f0379b356d4cfb313d1414dc30e46" + integrity sha512-UFzlz2jjd8kroj0hmCFV5zr+tQPi1dpC2cRsDV/3IEW8bJfCPrPpmcSN6ZS8RqIq4LXcmpipCQFPddyFA5Yc7w== dependencies: - "@babel/compat-data" "^7.16.4" + "@babel/compat-data" "^7.17.7" "@babel/helper-validator-option" "^7.16.7" browserslist "^4.17.5" semver "^6.3.0" @@ -98,14 +98,14 @@ dependencies: "@babel/types" "^7.16.7" -"@babel/helper-module-transforms@^7.16.7": - version "7.17.6" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.17.6.tgz#3c3b03cc6617e33d68ef5a27a67419ac5199ccd0" - integrity sha512-2ULmRdqoOMpdvkbT8jONrZML/XALfzxlb052bldftkicAUy8AxSCkD5trDPQcwHNmolcl7wP6ehNqMlyUw6AaA== +"@babel/helper-module-transforms@^7.17.7": + version "7.17.7" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.17.7.tgz#3943c7f777139e7954a5355c815263741a9c1cbd" + integrity sha512-VmZD99F3gNTYB7fJRDTi+u6l/zxY0BE6OIxPSU7a50s6ZUQkHwSDmV92FfM+oCG0pZRVojGYhkR8I0OGeCVREw== dependencies: "@babel/helper-environment-visitor" "^7.16.7" "@babel/helper-module-imports" "^7.16.7" - "@babel/helper-simple-access" "^7.16.7" + "@babel/helper-simple-access" "^7.17.7" "@babel/helper-split-export-declaration" "^7.16.7" "@babel/helper-validator-identifier" "^7.16.7" "@babel/template" "^7.16.7" @@ -117,12 +117,12 @@ resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.16.7.tgz#aa3a8ab4c3cceff8e65eb9e73d87dc4ff320b2f5" integrity sha512-Qg3Nk7ZxpgMrsox6HreY1ZNKdBq7K72tDSliA6dCl5f007jR4ne8iD5UzuNnCJH2xBf2BEEVGr+/OL6Gdp7RxA== -"@babel/helper-simple-access@^7.16.7": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.16.7.tgz#d656654b9ea08dbb9659b69d61063ccd343ff0f7" - integrity sha512-ZIzHVyoeLMvXMN/vok/a4LWRy8G2v205mNP0XOuf9XRLyX5/u9CnVulUtDgUTama3lT+bf/UqucuZjqiGuTS1g== +"@babel/helper-simple-access@^7.17.7": + version "7.17.7" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.17.7.tgz#aaa473de92b7987c6dfa7ce9a7d9674724823367" + integrity sha512-txyMCGroZ96i+Pxr3Je3lzEJjqwaRC9buMUgtomcrLe5Nd0+fk1h0LLA+ixUF5OW7AhHuQ7Es1WcQJZmZsz2XA== dependencies: - "@babel/types" "^7.16.7" + "@babel/types" "^7.17.0" "@babel/helper-split-export-declaration@^7.16.7": version "7.16.7" @@ -141,13 +141,13 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz#b203ce62ce5fe153899b617c08957de860de4d23" integrity sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ== -"@babel/helpers@^7.17.2": - version "7.17.2" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.17.2.tgz#23f0a0746c8e287773ccd27c14be428891f63417" - integrity sha512-0Qu7RLR1dILozr/6M0xgj+DFPmi6Bnulgm9M8BVa9ZCWxDqlSnqt3cf8IDPB5m45sVXUZ0kuQAgUrdSFFH79fQ== +"@babel/helpers@^7.17.8": + version "7.17.8" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.17.8.tgz#288450be8c6ac7e4e44df37bcc53d345e07bc106" + integrity sha512-QcL86FGxpfSJwGtAvv4iG93UL6bmqBdmoVY0CMCU2g+oD2ezQse3PT5Pa+jiD6LJndBQi0EDlpzOWNlLuhz5gw== dependencies: "@babel/template" "^7.16.7" - "@babel/traverse" "^7.17.0" + "@babel/traverse" "^7.17.3" "@babel/types" "^7.17.0" "@babel/highlight@^7.16.7": @@ -159,10 +159,10 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.16.7", "@babel/parser@^7.17.3": - version "7.17.3" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.17.3.tgz#b07702b982990bf6fdc1da5049a23fece4c5c3d0" - integrity sha512-7yJPvPV+ESz2IUTPbOL+YkIGyCqOyNIzdguKQuJGnH7bg1WTIifuM21YqokFt/THWh1AkCRn9IgoykTRCBVpzA== +"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.16.7", "@babel/parser@^7.17.3", "@babel/parser@^7.17.8": + version "7.17.8" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.17.8.tgz#2817fb9d885dd8132ea0f8eb615a6388cca1c240" + integrity sha512-BoHhDJrJXqcg+ZL16Xv39H9n+AqJ4pcDrQBGZN+wHxIysrLZ3/ECwCBUch/1zUNhnsXULcONU3Ei5Hmkfk6kiQ== "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -256,9 +256,9 @@ "@babel/helper-plugin-utils" "^7.16.7" "@babel/runtime@^7.14.6", "@babel/runtime@^7.7.6": - version "7.17.2" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.2.tgz#66f68591605e59da47523c631416b18508779941" - integrity sha512-hzeyJyMA1YGdJTuWU0e/j4wKXrU4OMFvY2MSlaI9B7VQb0r5cxTE3EAIS2Q7Tn2RIcDkRvTA/v2JsAEhxe99uw== + version "7.17.8" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.8.tgz#3e56e4aff81befa55ac3ac6a0967349fd1c5bca2" + integrity sha512-dQpEpK0O9o6lj6oPu0gRDbbnk+4LeHlNcBpspf6Olzt3GIX4P1lWF1gS+pHLDFlaJvbR6q7jCfQ08zA4QJBnmA== dependencies: regenerator-runtime "^0.13.4" @@ -271,7 +271,7 @@ "@babel/parser" "^7.16.7" "@babel/types" "^7.16.7" -"@babel/traverse@^7.17.0", "@babel/traverse@^7.17.3", "@babel/traverse@^7.7.2": +"@babel/traverse@^7.17.3", "@babel/traverse@^7.7.2": version "7.17.3" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.3.tgz#0ae0f15b27d9a92ba1f2263358ea7c4e7db47b57" integrity sha512-5irClVky7TxRWIRtxlh2WPUUOLhcPN06AGgaQSB8AEwuyEBgJVuJ5imdHm5zxk8w0QS5T+tDfnDxAlhWjpb7cw== @@ -313,20 +313,20 @@ "@cspotcode/source-map-consumer" "0.8.0" "@discoveryjs/json-ext@^0.5.0": - version "0.5.6" - resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.6.tgz#d5e0706cf8c6acd8c6032f8d54070af261bbbb2f" - integrity sha512-ws57AidsDvREKrZKYffXddNkyaF14iHNHm8VQnZH6t99E8gczjNN0GpvcGny0imC80yQ0tHz1xVUKk/KFQSUyA== + version "0.5.7" + resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" + integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== -"@eslint/eslintrc@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.2.0.tgz#7ce1547a5c46dfe56e1e45c3c9ed18038c721c6a" - integrity sha512-igm9SjJHNEJRiUnecP/1R5T3wKLEJ7pL6e2P+GUSfCd0dGjPYYZve08uzw8L2J8foVHFz+NGu12JxRcU2gGo6w== +"@eslint/eslintrc@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.2.1.tgz#8b5e1c49f4077235516bc9ec7d41378c0f69b8c6" + integrity sha512-bxvbYnBPN1Gibwyp6NrpnFzA3YtRL3BBAyEAFVIpNTm2Rn4Vy87GA5M4aSn3InRrlsbX5N0GW7XIx+U4SAEKdQ== dependencies: ajv "^6.12.4" debug "^4.3.2" espree "^9.3.1" globals "^13.9.0" - ignore "^4.0.6" + ignore "^5.2.0" import-fresh "^3.2.1" js-yaml "^4.1.0" minimatch "^3.0.4" @@ -1327,13 +1327,13 @@ "@octokit/types" "^6.0.3" "@octokit/core@^3.5.1": - version "3.5.1" - resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.5.1.tgz#8601ceeb1ec0e1b1b8217b960a413ed8e947809b" - integrity sha512-omncwpLVxMP+GLpLPgeGJBF6IWJFjXDS5flY5VbppePYX9XehevbDykRH9PdCdvqt9TS5AOTiDide7h0qrkHjw== + version "3.6.0" + resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.6.0.tgz#3376cb9f3008d9b3d110370d90e0a1fcd5fe6085" + integrity sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q== dependencies: "@octokit/auth-token" "^2.4.4" "@octokit/graphql" "^4.5.8" - "@octokit/request" "^5.6.0" + "@octokit/request" "^5.6.3" "@octokit/request-error" "^2.0.5" "@octokit/types" "^6.0.3" before-after-hook "^2.2.0" @@ -1396,7 +1396,7 @@ deprecation "^2.0.0" once "^1.4.0" -"@octokit/request@^5.6.0": +"@octokit/request@^5.6.0", "@octokit/request@^5.6.3": version "5.6.3" resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.3.tgz#19a022515a5bba965ac06c9d1334514eb50c48b0" integrity sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A== @@ -1465,9 +1465,9 @@ integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA== "@types/babel__core@^7.0.0", "@types/babel__core@^7.1.14": - version "7.1.18" - resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.18.tgz#1a29abcc411a9c05e2094c98f9a1b7da6cdf49f8" - integrity sha512-S7unDjm/C7z2A2R9NzfKCK1I+BAALDtxEmsJBwlB3EzNfb929ykjL++1CK9LO++EIp2fQrC8O+BwjKvz6UeDyQ== + version "7.1.19" + resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.19.tgz#7b497495b7d1b4812bdb9d02804d0576f43ee460" + integrity sha512-WEOTgRsbYkvA/KCsDwVEGkd7WAr1e3g31VHQ8zy5gul/V1qKullU/BU5I68X5v7V3GnB9eotmom4v5a5gjxorw== dependencies: "@babel/parser" "^7.1.0" "@babel/types" "^7.0.0" @@ -1561,10 +1561,10 @@ dependencies: "@types/node" "*" -"@types/inquirer@^8.2.0": - version "8.2.0" - resolved "https://registry.yarnpkg.com/@types/inquirer/-/inquirer-8.2.0.tgz#b9566d048f5ff65159f2ed97aff45fe0f00b35ec" - integrity sha512-BNoMetRf3gmkpAlV5we+kxyZTle7YibdOntIZbU5pyIfMdcwy784KfeZDAcuyMznkh5OLa17RVXZOGA5LTlkgQ== +"@types/inquirer@^8.2.1": + version "8.2.1" + resolved "https://registry.yarnpkg.com/@types/inquirer/-/inquirer-8.2.1.tgz#28a139be3105a1175e205537e8ac10830e38dbf4" + integrity sha512-wKW3SKIUMmltbykg4I5JzCVzUhkuD9trD6efAmYgN2MrSntY0SMRQzEnD3mkyJ/rv9NLbTC7g3hKKE86YwEDLw== dependencies: "@types/through" "*" rxjs "^7.2.0" @@ -1597,9 +1597,9 @@ pretty-format "^27.0.0" "@types/json-schema@*", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": - version "7.0.9" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" - integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== + version "7.0.11" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" + integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== "@types/json5@^0.0.29": version "0.0.29" @@ -1631,9 +1631,9 @@ "@types/node" "*" "@types/node@*": - version "17.0.21" - resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.21.tgz#864b987c0c68d07b4345845c3e63b75edd143644" - integrity sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ== + version "17.0.23" + resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.23.tgz#3b41a6e643589ac6442bdbd7a4a3ded62f33f7da" + integrity sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw== "@types/node@^12.20.47": version "12.20.47" @@ -1719,21 +1719,21 @@ dependencies: "@types/yargs-parser" "*" -"@types/yargs@^17.0.9": - version "17.0.9" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.9.tgz#f1f931a4e5ae2c0134dea10f501088636a50b46a" - integrity sha512-Ci8+4/DOtkHRylcisKmVMtmVO5g7weUVCKcsu1sJvF1bn0wExTmbHmhFKj7AnEm0de800iovGhdSKzYnzbaHpg== +"@types/yargs@^17.0.10": + version "17.0.10" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.10.tgz#591522fce85d8739bca7b8bb90d048e4478d186a" + integrity sha512-gmEaFwpj/7f/ROdtIlci1R1VYU1J4j95m8T+Tj3iBgiBFKg1foE/PSl93bBd5T9LDXNPo8UlNN6W0qwD8O5OaA== dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@^5.14.0": - version "5.14.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.14.0.tgz#5119b67152356231a0e24b998035288a9cd21335" - integrity sha512-ir0wYI4FfFUDfLcuwKzIH7sMVA+db7WYen47iRSaCGl+HMAZI9fpBwfDo45ZALD3A45ZGyHWDNLhbg8tZrMX4w== +"@typescript-eslint/eslint-plugin@^5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.18.0.tgz#950df411cec65f90d75d6320a03b2c98f6c3af7d" + integrity sha512-tzrmdGMJI/uii9/V6lurMo4/o+dMTKDH82LkNjhJ3adCW22YQydoRs5MwTiqxGF9CSYxPxQ7EYb4jLNlIs+E+A== dependencies: - "@typescript-eslint/scope-manager" "5.14.0" - "@typescript-eslint/type-utils" "5.14.0" - "@typescript-eslint/utils" "5.14.0" + "@typescript-eslint/scope-manager" "5.18.0" + "@typescript-eslint/type-utils" "5.18.0" + "@typescript-eslint/utils" "5.18.0" debug "^4.3.2" functional-red-black-tree "^1.0.1" ignore "^5.1.8" @@ -1741,69 +1741,69 @@ semver "^7.3.5" tsutils "^3.21.0" -"@typescript-eslint/parser@^5.14.0": - version "5.14.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.14.0.tgz#7c79f898aa3cff0ceee6f1d34eeed0f034fb9ef3" - integrity sha512-aHJN8/FuIy1Zvqk4U/gcO/fxeMKyoSv/rS46UXMXOJKVsLQ+iYPuXNbpbH7cBLcpSbmyyFbwrniLx5+kutu1pw== +"@typescript-eslint/parser@^5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.18.0.tgz#2bcd4ff21df33621df33e942ccb21cb897f004c6" + integrity sha512-+08nYfurBzSSPndngnHvFw/fniWYJ5ymOrn/63oMIbgomVQOvIDhBoJmYZ9lwQOCnQV9xHGvf88ze3jFGUYooQ== dependencies: - "@typescript-eslint/scope-manager" "5.14.0" - "@typescript-eslint/types" "5.14.0" - "@typescript-eslint/typescript-estree" "5.14.0" + "@typescript-eslint/scope-manager" "5.18.0" + "@typescript-eslint/types" "5.18.0" + "@typescript-eslint/typescript-estree" "5.18.0" debug "^4.3.2" -"@typescript-eslint/scope-manager@5.14.0": - version "5.14.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.14.0.tgz#ea518962b42db8ed0a55152ea959c218cb53ca7b" - integrity sha512-LazdcMlGnv+xUc5R4qIlqH0OWARyl2kaP8pVCS39qSL3Pd1F7mI10DbdXeARcE62sVQE4fHNvEqMWsypWO+yEw== +"@typescript-eslint/scope-manager@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.18.0.tgz#a7d7b49b973ba8cebf2a3710eefd457ef2fb5505" + integrity sha512-C0CZML6NyRDj+ZbMqh9FnPscg2PrzSaVQg3IpTmpe0NURMVBXlghGZgMYqBw07YW73i0MCqSDqv2SbywnCS8jQ== dependencies: - "@typescript-eslint/types" "5.14.0" - "@typescript-eslint/visitor-keys" "5.14.0" + "@typescript-eslint/types" "5.18.0" + "@typescript-eslint/visitor-keys" "5.18.0" -"@typescript-eslint/type-utils@5.14.0": - version "5.14.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.14.0.tgz#711f08105860b12988454e91df433567205a8f0b" - integrity sha512-d4PTJxsqaUpv8iERTDSQBKUCV7Q5yyXjqXUl3XF7Sd9ogNLuKLkxz82qxokqQ4jXdTPZudWpmNtr/JjbbvUixw== +"@typescript-eslint/type-utils@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.18.0.tgz#62dbfc8478abf36ba94a90ddf10be3cc8e471c74" + integrity sha512-vcn9/6J5D6jtHxpEJrgK8FhaM8r6J1/ZiNu70ZUJN554Y3D9t3iovi6u7JF8l/e7FcBIxeuTEidZDR70UuCIfA== dependencies: - "@typescript-eslint/utils" "5.14.0" + "@typescript-eslint/utils" "5.18.0" debug "^4.3.2" tsutils "^3.21.0" -"@typescript-eslint/types@5.14.0": - version "5.14.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.14.0.tgz#96317cf116cea4befabc0defef371a1013f8ab11" - integrity sha512-BR6Y9eE9360LNnW3eEUqAg6HxS9Q35kSIs4rp4vNHRdfg0s+/PgHgskvu5DFTM7G5VKAVjuyaN476LCPrdA7Mw== +"@typescript-eslint/types@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.18.0.tgz#4f0425d85fdb863071680983853c59a62ce9566e" + integrity sha512-bhV1+XjM+9bHMTmXi46p1Led5NP6iqQcsOxgx7fvk6gGiV48c6IynY0apQb7693twJDsXiVzNXTflhplmaiJaw== -"@typescript-eslint/typescript-estree@5.14.0": - version "5.14.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.14.0.tgz#78b7f7385d5b6f2748aacea5c9b7f6ae62058314" - integrity sha512-QGnxvROrCVtLQ1724GLTHBTR0lZVu13izOp9njRvMkCBgWX26PKvmMP8k82nmXBRD3DQcFFq2oj3cKDwr0FaUA== +"@typescript-eslint/typescript-estree@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.18.0.tgz#6498e5ee69a32e82b6e18689e2f72e4060986474" + integrity sha512-wa+2VAhOPpZs1bVij9e5gyVu60ReMi/KuOx4LKjGx2Y3XTNUDJgQ+5f77D49pHtqef/klglf+mibuHs9TrPxdQ== dependencies: - "@typescript-eslint/types" "5.14.0" - "@typescript-eslint/visitor-keys" "5.14.0" + "@typescript-eslint/types" "5.18.0" + "@typescript-eslint/visitor-keys" "5.18.0" debug "^4.3.2" globby "^11.0.4" is-glob "^4.0.3" semver "^7.3.5" tsutils "^3.21.0" -"@typescript-eslint/utils@5.14.0": - version "5.14.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.14.0.tgz#6c8bc4f384298cbbb32b3629ba7415f9f80dc8c4" - integrity sha512-EHwlII5mvUA0UsKYnVzySb/5EE/t03duUTweVy8Zqt3UQXBrpEVY144OTceFKaOe4xQXZJrkptCf7PjEBeGK4w== +"@typescript-eslint/utils@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.18.0.tgz#27fc84cf95c1a96def0aae31684cb43a37e76855" + integrity sha512-+hFGWUMMri7OFY26TsOlGa+zgjEy1ssEipxpLjtl4wSll8zy85x0GrUSju/FHdKfVorZPYJLkF3I4XPtnCTewA== dependencies: "@types/json-schema" "^7.0.9" - "@typescript-eslint/scope-manager" "5.14.0" - "@typescript-eslint/types" "5.14.0" - "@typescript-eslint/typescript-estree" "5.14.0" + "@typescript-eslint/scope-manager" "5.18.0" + "@typescript-eslint/types" "5.18.0" + "@typescript-eslint/typescript-estree" "5.18.0" eslint-scope "^5.1.1" eslint-utils "^3.0.0" -"@typescript-eslint/visitor-keys@5.14.0": - version "5.14.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.14.0.tgz#1927005b3434ccd0d3ae1b2ecf60e65943c36986" - integrity sha512-yL0XxfzR94UEkjBqyymMLgCBdojzEuy/eim7N9/RIcTNxpJudAcqsU8eRyfzBbcEzGoPWfdM3AGak3cN08WOIw== +"@typescript-eslint/visitor-keys@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.18.0.tgz#c7c07709823804171d569017f3b031ced7253e60" + integrity sha512-Hf+t+dJsjAKpKSkg3EHvbtEpFFb/1CiOHnvI8bjHgOD4/wAw3gKrA0i94LrbekypiZVanJu3McWJg7rWDMzRTg== dependencies: - "@typescript-eslint/types" "5.14.0" + "@typescript-eslint/types" "5.18.0" eslint-visitor-keys "^3.0.0" "@webassemblyjs/ast@1.11.1": @@ -1944,10 +1944,10 @@ resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.6.1.tgz#0de2875ac31b46b6c5bb1ae0a7d7f0ba5678dffe" integrity sha512-gNGTiTrjEVQ0OcVnzsRSqTxaBSr+dmTfm+qJsCDluky8uhdLWep7Gcr62QsAKHTMxjCS/8nEITsmFAhfIx+QSw== -"@xmldom/xmldom@^0.8.1": - version "0.8.1" - resolved "https://registry.yarnpkg.com/@xmldom/xmldom/-/xmldom-0.8.1.tgz#70c239275fc6d6a84e41b9a8d623a93c0d59b6b4" - integrity sha512-4wOae+5N2RZ+CZXd9ZKwkaDi55IxrSTOjHpxTvQQ4fomtOJmqVxbmICA9jE1jvnqNhpfgz8cnfFagG86wV/xLQ== +"@xmldom/xmldom@^0.8.2": + version "0.8.2" + resolved "https://registry.yarnpkg.com/@xmldom/xmldom/-/xmldom-0.8.2.tgz#b695ff674e8216efa632a3d36ad51ae9843380c0" + integrity sha512-+R0juSseERyoPvnBQ/cZih6bpF7IpCXlWbHRoCRzYzqpz6gWHOgf8o4MOEf6KBVuOyqU+gCNLkCWVIJAro8XyQ== "@xtuc/ieee754@^1.2.0": version "1.2.0" @@ -2332,7 +2332,7 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" -braces@^3.0.1: +braces@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== @@ -2345,12 +2345,12 @@ browser-process-hrtime@^1.0.0: integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== browserslist@^4.14.5, browserslist@^4.17.5: - version "4.20.0" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.0.tgz#35951e3541078c125d36df76056e94738a52ebe9" - integrity sha512-bnpOoa+DownbciXj0jVGENf8VYQnE2LNWomhYuCsMmmx9Jd9lwq0WXODuwpSsp8AVdKM2/HorrzxAfbKvWTByQ== + version "4.20.2" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.2.tgz#567b41508757ecd904dab4d1c646c612cd3d4f88" + integrity sha512-CQOBCqp/9pDvDbx3xfMi+86pr4KXIf2FDkTTdeuYw8OxS9t898LA1Khq57gtufFILXpfgsSx5woNgsBgvGjpsA== dependencies: - caniuse-lite "^1.0.30001313" - electron-to-chromium "^1.4.76" + caniuse-lite "^1.0.30001317" + electron-to-chromium "^1.4.84" escalade "^3.1.1" node-releases "^2.0.2" picocolors "^1.0.0" @@ -2445,10 +2445,10 @@ camelcase@^6.2.0, camelcase@^6.3.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== -caniuse-lite@^1.0.30001313: - version "1.0.30001314" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001314.tgz#65c7f9fb7e4594fca0a333bec1d8939662377596" - integrity sha512-0zaSO+TnCHtHJIbpLroX7nsD+vYuOVjl3uzFbJO1wMVbuveJA0RK2WcQA9ZUIOiO0/ArMiMgHJLxfEZhQiC0kw== +caniuse-lite@^1.0.30001317: + version "1.0.30001325" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001325.tgz#2b4ad19b77aa36f61f2eaf72e636d7481d55e606" + integrity sha512-sB1bZHjseSjDtijV1Hb7PB2Zd58Kyx+n/9EotvZ4Qcz2K3d0lWB8dB4nb8wN/TsOGFq3UuAm0zQZNQ4SoR7TrQ== case@^1.6.3: version "1.6.3" @@ -2950,20 +2950,20 @@ data-urls@^2.0.0: whatwg-mimetype "^2.3.0" whatwg-url "^8.0.0" -date-format@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/date-format/-/date-format-4.0.4.tgz#b58036e29e74121fca3e1b3e0dc4a62c65faa233" - integrity sha512-/jyf4rhB17ge328HJuJjAcmRtCsGd+NDeAtahRBTaK6vSPR6MO5HlrAit3Nn7dVjaa6sowW0WXt8yQtLyZQFRg== +date-format@^4.0.6: + version "4.0.6" + resolved "https://registry.yarnpkg.com/date-format/-/date-format-4.0.6.tgz#f6138b8f17968df9815b3d101fc06b0523f066c5" + integrity sha512-B9vvg5rHuQ8cbUXE/RMWMyX2YA5TecT3jKF5fLtGNlzPlU7zblSPmAm2OImDbWL+LDOQ6pUm+4LOFz+ywS41Zw== dateformat@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q== -debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3: - version "4.3.3" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664" - integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q== +debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== dependencies: ms "2.1.2" @@ -3205,10 +3205,10 @@ ecc-jsbn@~0.1.1: jsbn "~0.1.0" safer-buffer "^2.1.0" -electron-to-chromium@^1.4.76: - version "1.4.78" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.78.tgz#7a1cf853efafde2c4cf6e86facf3e5792d3541a5" - integrity sha512-o61+D/Lx7j/E0LIin/efOqeHpXhwi1TaQco9vUcRmr91m25SfZY6L5hWJDv/r+6kNjboFKgBw1LbfM0lbhuK6Q== +electron-to-chromium@^1.4.84: + version "1.4.104" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.104.tgz#60973b0a7d398efa877196e8ccb0c93d48b918d8" + integrity sha512-2kjoAyiG7uMyGRM9mx25s3HAzmQG2ayuYXxsFmYugHSDcwxREgLtscZvbL1JcW9S/OemeQ3f/SG6JhDwpnCclQ== emittery@^0.8.1: version "0.8.1" @@ -3263,9 +3263,9 @@ error-ex@^1.3.1: is-arrayish "^0.2.1" es-abstract@^1.18.5, es-abstract@^1.19.0, es-abstract@^1.19.1: - version "1.19.1" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.19.1.tgz#d4885796876916959de78edaa0df456627115ec3" - integrity sha512-2vJ6tjA/UfqLm2MPs7jxVybLoB8i1t1Jd9R3kISld20sIxPcTbLuggQOUxeWeAvIUkduv/CfMjuh4WmiXr2v9w== + version "1.19.2" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.19.2.tgz#8f7b696d8f15b167ae3640b4060670f3d054143f" + integrity sha512-gfSBJoZdlL2xRiOCy0g8gLMryhoe1TlimjzU99L/31Z8QEGIhVQI+EWwt5lT+AuU9SnorVupXFqqOGqGfsyO6w== dependencies: call-bind "^1.0.2" es-to-primitive "^1.2.1" @@ -3273,15 +3273,15 @@ es-abstract@^1.18.5, es-abstract@^1.19.0, es-abstract@^1.19.1: get-intrinsic "^1.1.1" get-symbol-description "^1.0.0" has "^1.0.3" - has-symbols "^1.0.2" + has-symbols "^1.0.3" internal-slot "^1.0.3" is-callable "^1.2.4" - is-negative-zero "^2.0.1" + is-negative-zero "^2.0.2" is-regex "^1.1.4" is-shared-array-buffer "^1.0.1" is-string "^1.0.7" - is-weakref "^1.0.1" - object-inspect "^1.11.0" + is-weakref "^1.0.2" + object-inspect "^1.12.0" object-keys "^1.1.1" object.assign "^4.1.2" string.prototype.trimend "^1.0.4" @@ -3361,18 +3361,18 @@ eslint-import-resolver-node@^0.3.6: debug "^3.2.7" resolve "^1.20.0" -eslint-import-resolver-typescript@^2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-2.5.0.tgz#07661966b272d14ba97f597b51e1a588f9722f0a" - integrity sha512-qZ6e5CFr+I7K4VVhQu3M/9xGv9/YmwsEXrsm3nimw8vWaVHRDrQRp26BgCypTxBp3vUp4o5aVEJRiy0F2DFddQ== +eslint-import-resolver-typescript@^2.7.1: + version "2.7.1" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-2.7.1.tgz#a90a4a1c80da8d632df25994c4c5fdcdd02b8751" + integrity sha512-00UbgGwV8bSgUv34igBDbTOtKhqoRMy9bFjNehT40bXg6585PNIct8HhXZ0SybqB9rWtXj9crcku8ndDn/gIqQ== dependencies: - debug "^4.3.1" - glob "^7.1.7" - is-glob "^4.0.1" - resolve "^1.20.0" - tsconfig-paths "^3.9.0" + debug "^4.3.4" + glob "^7.2.0" + is-glob "^4.0.3" + resolve "^1.22.0" + tsconfig-paths "^3.14.1" -eslint-module-utils@^2.7.2: +eslint-module-utils@^2.7.3: version "2.7.3" resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.7.3.tgz#ad7e3a10552fdd0642e1e55292781bd6e34876ee" integrity sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ== @@ -3380,24 +3380,24 @@ eslint-module-utils@^2.7.2: debug "^3.2.7" find-up "^2.1.0" -eslint-plugin-import@^2.25.4: - version "2.25.4" - resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.25.4.tgz#322f3f916a4e9e991ac7af32032c25ce313209f1" - integrity sha512-/KJBASVFxpu0xg1kIBn9AUa8hQVnszpwgE7Ld0lKAlx7Ie87yzEzCgSkekt+le/YVhiaosO4Y14GDAOc41nfxA== +eslint-plugin-import@^2.26.0: + version "2.26.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz#f812dc47be4f2b72b478a021605a59fc6fe8b88b" + integrity sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA== dependencies: array-includes "^3.1.4" array.prototype.flat "^1.2.5" debug "^2.6.9" doctrine "^2.1.0" eslint-import-resolver-node "^0.3.6" - eslint-module-utils "^2.7.2" + eslint-module-utils "^2.7.3" has "^1.0.3" - is-core-module "^2.8.0" + is-core-module "^2.8.1" is-glob "^4.0.3" - minimatch "^3.0.4" + minimatch "^3.1.2" object.values "^1.1.5" - resolve "^1.20.0" - tsconfig-paths "^3.12.0" + resolve "^1.22.0" + tsconfig-paths "^3.14.1" eslint-plugin-prettier@^4.0.0: version "4.0.0" @@ -3439,12 +3439,12 @@ eslint-visitor-keys@^3.0.0, eslint-visitor-keys@^3.3.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== -eslint@^8.10.0: - version "8.10.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.10.0.tgz#931be395eb60f900c01658b278e05b6dae47199d" - integrity sha512-tcI1D9lfVec+R4LE1mNDnzoJ/f71Kl/9Cv4nG47jOueCMBrCCKYXr4AUVS7go6mWYGFD4+EoN6+eXSrEbRzXVw== +eslint@^8.12.0: + version "8.12.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.12.0.tgz#c7a5bd1cfa09079aae64c9076c07eada66a46e8e" + integrity sha512-it1oBL9alZg1S8UycLm5YDMAkIhtH6FtAzuZs6YvoGVldWjbS08BkAdb/ymP9LlAyq8koANu32U7Ib/w+UNh8Q== dependencies: - "@eslint/eslintrc" "^1.2.0" + "@eslint/eslintrc" "^1.2.1" "@humanwhocodes/config-array" "^0.9.2" ajv "^6.10.0" chalk "^4.0.0" @@ -3940,7 +3940,7 @@ glob-to-regexp@^0.4.1: resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== -glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@^7.1.7: +glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@^7.1.7, glob@^7.2.0: version "7.2.0" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== @@ -3958,9 +3958,9 @@ globals@^11.1.0: integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== globals@^13.6.0, globals@^13.9.0: - version "13.12.1" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.12.1.tgz#ec206be932e6c77236677127577aa8e50bf1c5cb" - integrity sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw== + version "13.13.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.13.0.tgz#ac32261060d8070e2719dd6998406e27d2b5727b" + integrity sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A== dependencies: type-fest "^0.20.2" @@ -3977,9 +3977,9 @@ globby@^11.0.2, globby@^11.0.4: slash "^3.0.0" graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.2, graceful-fs@^4.2.3, graceful-fs@^4.2.4, graceful-fs@^4.2.9: - version "4.2.9" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96" - integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== + version "4.2.10" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" + integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== handlebars@^4.7.7: version "4.7.7" @@ -4026,7 +4026,7 @@ has-flag@^4.0.0: resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== -has-symbols@^1.0.1, has-symbols@^1.0.2: +has-symbols@^1.0.1, has-symbols@^1.0.2, has-symbols@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== @@ -4138,11 +4138,6 @@ ignore-walk@^3.0.3: dependencies: minimatch "^3.0.4" -ignore@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" - integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== - ignore@^5.1.8, ignore@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" @@ -4288,7 +4283,7 @@ is-ci@^2.0.0: dependencies: ci-info "^2.0.0" -is-core-module@^2.5.0, is-core-module@^2.8.0, is-core-module@^2.8.1: +is-core-module@^2.5.0, is-core-module@^2.8.1: version "2.8.1" resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211" integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA== @@ -4341,15 +4336,15 @@ is-map@^2.0.1, is-map@^2.0.2: resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.2.tgz#00922db8c9bf73e81b7a335827bc2a43f2b91127" integrity sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg== -is-negative-zero@^2.0.1: +is-negative-zero@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.2.tgz#7bf6f03a28003b8b3965de3ac26f664d765f3150" integrity sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA== is-number-object@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.6.tgz#6a7aaf838c7f0686a50b4553f7e54a96494e89f0" - integrity sha512-bEVOqiRcvo3zO1+G2lVMy+gkkEm9Yh7cDMRusKKu5ZJKPUYSJwICTKZrNKHA2EbSP0Tu0+6B/emsYNHZyn6K8g== + version "1.0.7" + resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.7.tgz#59d50ada4c45251784e9904f5246c742f07a42fc" + integrity sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ== dependencies: has-tostringtag "^1.0.0" @@ -4404,9 +4399,11 @@ is-set@^2.0.1, is-set@^2.0.2: integrity sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g== is-shared-array-buffer@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.1.tgz#97b0c85fbdacb59c9c446fe653b82cf2b5b7cfe6" - integrity sha512-IU0NmyknYZN0rChcKhRO1X8LYz5Isj/Fsqh8NJOSf+N/hCOTwy29F32Ik7a+QszE63IdvmwdTPDd6cZ5pg4cwA== + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz#8f259c573b60b6a32d4058a1a07430c0a7344c79" + integrity sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA== + dependencies: + call-bind "^1.0.2" is-ssh@^1.3.0: version "1.3.3" @@ -4462,7 +4459,7 @@ is-weakmap@^2.0.1: resolved "https://registry.yarnpkg.com/is-weakmap/-/is-weakmap-2.0.1.tgz#5008b59bdc43b698201d18f62b37b2ca243e8cf2" integrity sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA== -is-weakref@^1.0.1: +is-weakref@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.0.2.tgz#9529f383a9338205e89765e0392efc2f100f06f2" integrity sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ== @@ -5062,11 +5059,9 @@ json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= json5@2.x, json5@^2.1.2: - version "2.2.0" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.0.tgz#2dfefe720c6ba525d9ebd909950f0515316c89a3" - integrity sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA== - dependencies: - minimist "^1.2.5" + version "2.2.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" + integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== json5@^1.0.1: version "1.0.1" @@ -5280,16 +5275,16 @@ lodash@^4.11.2, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.7.0: resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== -log4js@^6.4.2: - version "6.4.2" - resolved "https://registry.yarnpkg.com/log4js/-/log4js-6.4.2.tgz#45ec783835acc525b397f52cf086e26994fe3b70" - integrity sha512-k80cggS2sZQLBwllpT1p06GtfvzMmSdUCkW96f0Hj83rKGJDAu2vZjt9B9ag2vx8Zz1IXzxoLgqvRJCdMKybGg== +log4js@^6.4.4: + version "6.4.4" + resolved "https://registry.yarnpkg.com/log4js/-/log4js-6.4.4.tgz#c9bc75569f3f40bba22fe1bd0677afa7a6a13bac" + integrity sha512-ncaWPsuw9Vl1CKA406hVnJLGQKy1OHx6buk8J4rE2lVW+NW5Y82G5/DIloO7NkqLOUtNPEANaWC1kZYVjXssPw== dependencies: - date-format "^4.0.4" - debug "^4.3.3" + date-format "^4.0.6" + debug "^4.3.4" flatted "^3.2.5" rfdc "^1.3.0" - streamroller "^3.0.4" + streamroller "^3.0.6" lower-case@^1.1.1: version "1.1.4" @@ -5423,24 +5418,24 @@ merge2@^1.3.0, merge2@^1.4.1: integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== micromatch@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.4.tgz#896d519dfe9db25fce94ceb7a500919bf881ebf9" - integrity sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg== + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== dependencies: - braces "^3.0.1" - picomatch "^2.2.3" + braces "^3.0.2" + picomatch "^2.3.1" -mime-db@1.51.0: - version "1.51.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.51.0.tgz#d9ff62451859b18342d960850dc3cfb77e63fb0c" - integrity sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g== +mime-db@1.52.0: + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== mime-types@^2.1.12, mime-types@^2.1.27, mime-types@~2.1.19: - version "2.1.34" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.34.tgz#5a712f9ec1503511a945803640fafe09d3793c24" - integrity sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A== + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== dependencies: - mime-db "1.51.0" + mime-db "1.52.0" mimic-fn@^2.1.0: version "2.1.0" @@ -5452,7 +5447,7 @@ min-indent@^1.0.0: resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869" integrity sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg== -minimatch@^3.0.4: +minimatch@^3.0.4, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== @@ -5468,10 +5463,10 @@ minimist-options@4.1.0: is-plain-obj "^1.1.0" kind-of "^6.0.3" -minimist@>=1.2.2, minimist@^1.2.0, minimist@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== +minimist@>=1.2.2, minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6: + version "1.2.6" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" + integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== minipass-collect@^1.0.2: version "1.0.2" @@ -5560,11 +5555,11 @@ mkdirp-infer-owner@^2.0.0: mkdirp "^1.0.3" mkdirp@^0.5.1, mkdirp@^0.5.5: - version "0.5.5" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" - integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== + version "0.5.6" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" + integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== dependencies: - minimist "^1.2.5" + minimist "^1.2.6" mkdirp@^1.0.3, mkdirp@^1.0.4: version "1.0.4" @@ -5859,7 +5854,7 @@ object-assign@^4.1.0: resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= -object-inspect@^1.11.0, object-inspect@^1.9.0: +object-inspect@^1.12.0, object-inspect@^1.9.0: version "1.12.0" resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.0.tgz#6e2c120e868fd1fd18cb4f18c31741d0d6e776f0" integrity sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g== @@ -6196,7 +6191,7 @@ picocolors@^1.0.0: resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== -picomatch@^2.0.4, picomatch@^2.2.3: +picomatch@^2.0.4, picomatch@^2.2.3, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== @@ -6250,10 +6245,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@^2.5.1: - version "2.5.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a" - integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg== +prettier@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.2.tgz#e26d71a18a74c3d0f0597f55f01fb6c06c206032" + integrity sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew== pretty-format@^27.0.0, pretty-format@^27.5.1: version "27.5.1" @@ -6594,7 +6589,7 @@ resolve.exports@^1.1.0: resolved "https://registry.yarnpkg.com/resolve.exports/-/resolve.exports-1.1.0.tgz#5ce842b94b05146c0e03076985d1d0e7e48c90c9" integrity sha512-J1l+Zxxp4XK3LUDZ9m60LRJF/mAe4z6a4xyabPHk7pvK5t35dACV32iIjJDFeWZFfZlO29w6SZ67knR0tHzJtQ== -resolve@^1.10.0, resolve@^1.20.0, resolve@^1.9.0: +resolve@^1.10.0, resolve@^1.20.0, resolve@^1.22.0, resolve@^1.9.0: version "1.22.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198" integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== @@ -6911,10 +6906,10 @@ spdx-license-ids@^3.0.0: resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz#50c0d8c40a14ec1bf449bae69a0ea4685a9d9f95" integrity sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g== -spdx-license-list@^6.4.0: - version "6.4.0" - resolved "https://registry.yarnpkg.com/spdx-license-list/-/spdx-license-list-6.4.0.tgz#9850c3699c1d35745285607d064d2a5145049d12" - integrity sha512-4BxgJ1IZxTJuX1YxMGu2cRYK46Bk9zJNTK2/R0wNZR0cm+6SVl26/uG7FQmQtxoJQX1uZ0EpTi2L7zvMLboaBA== +spdx-license-list@^6.5.0: + version "6.5.0" + resolved "https://registry.yarnpkg.com/spdx-license-list/-/spdx-license-list-6.5.0.tgz#1624b9cd6c517ff8d697610e6c22d7f5b7c63d28" + integrity sha512-28O9GgFrMg2Wp8tVML0Zk+fnXaECy7UbB6pxo+93whHay/nqPyEdM07Cx6B4+j2pniUZTYr57OaIOyNTxsTwtw== split-on-first@^1.0.0: version "1.1.0" @@ -6998,13 +6993,13 @@ standard-version@^9.3.2: stringify-package "^1.0.1" yargs "^16.0.0" -streamroller@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-3.0.4.tgz#27ad87339d829483f89c5f33fd60ea6731e4183c" - integrity sha512-GI9NzeD+D88UFuIlJkKNDH/IsuR+qIN7Qh8EsmhoRZr9bQoehTraRgwtLUkZbpcAw+hLPfHOypmppz8YyGK68w== +streamroller@^3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-3.0.6.tgz#52823415800ded79a49aa3f7712f50a422b97493" + integrity sha512-Qz32plKq/MZywYyhEatxyYc8vs994Gz0Hu2MSYXXLD233UyPeIeRBZARIIGwFer4Mdb8r3Y2UqKkgyDghM6QCg== dependencies: - date-format "^4.0.4" - debug "^4.3.3" + date-format "^4.0.6" + debug "^4.3.4" fs-extra "^10.0.1" strict-uri-encode@^2.0.0: @@ -7246,9 +7241,9 @@ terser-webpack-plugin@^5.1.3: terser "^5.7.2" terser@^5.7.2: - version "5.12.0" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.12.0.tgz#728c6bff05f7d1dcb687d8eace0644802a9dae8a" - integrity sha512-R3AUhNBGWiFc77HXag+1fXpAxTAFRQTJemlJKjAgD9r8xXTpjNKqIXwHM/o7Rh+O0kUJtS3WQVdBeMKFk5sw9A== + version "5.12.1" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.12.1.tgz#4cf2ebed1f5bceef5c83b9f60104ac4a78b49e9c" + integrity sha512-NXbs+7nisos5E+yXwAD+y7zrcTkMqb0dEJxIGtSKPdCBzopf7ni4odPul2aechpV7EXNvOudYOX2bb5tln1jbQ== dependencies: acorn "^8.5.0" commander "^2.20.0" @@ -7357,10 +7352,10 @@ trim-newlines@^3.0.0: resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144" integrity sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw== -ts-jest@^27.1.3: - version "27.1.3" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.1.3.tgz#1f723e7e74027c4da92c0ffbd73287e8af2b2957" - integrity sha512-6Nlura7s6uM9BVUAoqLH7JHyMXjz8gluryjpPXxr3IxZdAXnU6FhjvVLHFtfd1vsE1p8zD1OJfskkc0jhTSnkA== +ts-jest@^27.1.4: + version "27.1.4" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.1.4.tgz#84d42cf0f4e7157a52e7c64b1492c46330943e00" + integrity sha512-qjkZlVPWVctAezwsOD1OPzbZ+k7zA5z3oxII4dGdZo5ggX/PL7kvwTM0pXTr10fAtbiVpJaL3bWd502zAhpgSQ== dependencies: bs-logger "0.x" fast-json-stable-stringify "2.x" @@ -7390,14 +7385,14 @@ ts-node@^10.2.1, ts-node@^10.7.0: v8-compile-cache-lib "^3.0.0" yn "3.1.1" -tsconfig-paths@^3.12.0, tsconfig-paths@^3.9.0: - version "3.13.0" - resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.13.0.tgz#f3e9b8f6876698581d94470c03c95b3a48c0e3d7" - integrity sha512-nWuffZppoaYK0vQ1SQmkSsQzJoHA4s6uzdb2waRpD806x9yfq153AdVsWz4je2qZcW+pENrMQXbGQ3sMCkXuhw== +tsconfig-paths@^3.14.1: + version "3.14.1" + resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz#ba0734599e8ea36c862798e920bcf163277b137a" + integrity sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ== dependencies: "@types/json5" "^0.0.29" json5 "^1.0.1" - minimist "^1.2.0" + minimist "^1.2.6" strip-bom "^3.0.0" tslib@^1.8.1, tslib@^1.9.0: @@ -7514,9 +7509,9 @@ typescript@~4.5.0: integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA== uglify-js@^3.1.4: - version "3.15.2" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.15.2.tgz#1ed2c976f448063b1f87adb68c741be79959f951" - integrity sha512-peeoTk3hSwYdoc9nrdiEJk+gx1ALCtTjdYuKSXMTDqq7n1W7dHPqWDdSi+BPL0ni2YMeHD7hKUSdbj3TZauY2A== + version "3.15.3" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.15.3.tgz#9aa82ca22419ba4c0137642ba0df800cb06e0471" + integrity sha512-6iCVm2omGJbsu3JWac+p6kUiOpg3wFO2f8lIXjfEb8RrmLjzog1wTPMmwKB7swfzzqxj9YM+sGUM++u1qN4qJg== uid-number@0.0.6: version "0.0.6" @@ -7733,10 +7728,10 @@ webpack-sources@^3.2.3: resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== -webpack@^5.70.0: - version "5.70.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.70.0.tgz#3461e6287a72b5e6e2f4872700bc8de0d7500e6d" - integrity sha512-ZMWWy8CeuTTjCxbeaQI21xSswseF2oNOwc70QSKNePvmxE7XW36i7vpBMYZFAUHPwQiEbNGCEYIOOlyRbdGmxw== +webpack@^5.71.0: + version "5.71.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.71.0.tgz#b01fcf379570b8c5ee06ca06c829ca168c951884" + integrity sha512-g4dFT7CFG8LY0iU5G8nBL6VlkT21Z7dcYDpJAEJV5Q1WLb9UwnFbrem1k7K52ILqEmomN7pnzWFxxE6SlDY56A== dependencies: "@types/eslint-scope" "^3.7.3" "@types/estree" "^0.0.51" @@ -8050,9 +8045,9 @@ yargs@^16.0.0, yargs@^16.2.0: yargs-parser "^20.2.2" yargs@^17.1.1: - version "17.3.1" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.3.1.tgz#da56b28f32e2fd45aefb402ed9c26f42be4c07b9" - integrity sha512-WUANQeVgjLbNsEmGk20f+nlHgOqzRFpiGWVaBrYGYIGANIIu3lWjoyi0fNlFmJkvfhCZ6BXINe7/W2O2bV4iaA== + version "17.4.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.4.0.tgz#9fc9efc96bd3aa2c1240446af28499f0e7593d00" + integrity sha512-WJudfrk81yWFSOkZYpAZx4Nt7V4xp7S/uJkX0CnxovMCt1wCE8LNftPpNuF9X/u9gN5nsD7ycYtRcDf2pL3UiA== dependencies: cliui "^7.0.2" escalade "^3.1.1"