├── .eslintrc.json ├── .gitattributes ├── .github ├── pull_request_template.md └── workflows │ ├── auto-approve.yml │ ├── build.yml │ ├── pull-request-lint.yml │ ├── release.yml │ ├── upgrade-cdklabs-projen-project-types-main.yml │ ├── upgrade-dev-deps-main.yml │ └── upgrade-main.yml ├── .gitignore ├── .mergify.yml ├── .npmignore ├── .projen ├── deps.json ├── files.json └── tasks.json ├── .projenrc.ts ├── CHANGELOG.md ├── LICENSE ├── README.md ├── bin └── jsii-srcmak ├── example └── lib │ ├── main.d.ts │ ├── main.js │ └── main.ts ├── package.json ├── src ├── cli.ts ├── compile.ts ├── index.ts ├── options.ts ├── srcmak.ts └── util.ts ├── test ├── __snapshots__ │ ├── cli.test.ts.snap │ └── srcmak.test.ts.snap ├── cli.test.ts ├── srcmak.test.ts └── util.ts ├── tsconfig.dev.json ├── tsconfig.json ├── version.json └── yarn.lock /.eslintrc.json: -------------------------------------------------------------------------------- 1 | // ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | { 3 | "env": { 4 | "jest": true, 5 | "node": true 6 | }, 7 | "root": true, 8 | "plugins": [ 9 | "@typescript-eslint", 10 | "import" 11 | ], 12 | "parser": "@typescript-eslint/parser", 13 | "parserOptions": { 14 | "ecmaVersion": 2018, 15 | "sourceType": "module", 16 | "project": "./tsconfig.dev.json" 17 | }, 18 | "extends": [ 19 | "plugin:import/typescript" 20 | ], 21 | "settings": { 22 | "import/parsers": { 23 | "@typescript-eslint/parser": [ 24 | ".ts", 25 | ".tsx" 26 | ] 27 | }, 28 | "import/resolver": { 29 | "node": {}, 30 | "typescript": { 31 | "project": "./tsconfig.dev.json", 32 | "alwaysTryTypes": true 33 | } 34 | } 35 | }, 36 | "ignorePatterns": [ 37 | "*.js", 38 | "*.d.ts", 39 | "node_modules/", 40 | "*.generated.ts", 41 | "coverage", 42 | "!.projenrc.ts", 43 | "!projenrc/**/*.ts" 44 | ], 45 | "rules": { 46 | "indent": [ 47 | "off" 48 | ], 49 | "@typescript-eslint/indent": [ 50 | "error", 51 | 2 52 | ], 53 | "quotes": [ 54 | "error", 55 | "single", 56 | { 57 | "avoidEscape": true 58 | } 59 | ], 60 | "comma-dangle": [ 61 | "error", 62 | "always-multiline" 63 | ], 64 | "comma-spacing": [ 65 | "error", 66 | { 67 | "before": false, 68 | "after": true 69 | } 70 | ], 71 | "no-multi-spaces": [ 72 | "error", 73 | { 74 | "ignoreEOLComments": false 75 | } 76 | ], 77 | "array-bracket-spacing": [ 78 | "error", 79 | "never" 80 | ], 81 | "array-bracket-newline": [ 82 | "error", 83 | "consistent" 84 | ], 85 | "object-curly-spacing": [ 86 | "error", 87 | "always" 88 | ], 89 | "object-curly-newline": [ 90 | "error", 91 | { 92 | "multiline": true, 93 | "consistent": true 94 | } 95 | ], 96 | "object-property-newline": [ 97 | "error", 98 | { 99 | "allowAllPropertiesOnSameLine": true 100 | } 101 | ], 102 | "keyword-spacing": [ 103 | "error" 104 | ], 105 | "brace-style": [ 106 | "error", 107 | "1tbs", 108 | { 109 | "allowSingleLine": true 110 | } 111 | ], 112 | "space-before-blocks": [ 113 | "error" 114 | ], 115 | "curly": [ 116 | "error", 117 | "multi-line", 118 | "consistent" 119 | ], 120 | "@typescript-eslint/member-delimiter-style": [ 121 | "error" 122 | ], 123 | "semi": [ 124 | "error", 125 | "always" 126 | ], 127 | "max-len": [ 128 | "error", 129 | { 130 | "code": 150, 131 | "ignoreUrls": true, 132 | "ignoreStrings": true, 133 | "ignoreTemplateLiterals": true, 134 | "ignoreComments": true, 135 | "ignoreRegExpLiterals": true 136 | } 137 | ], 138 | "quote-props": [ 139 | "error", 140 | "consistent-as-needed" 141 | ], 142 | "@typescript-eslint/no-require-imports": [ 143 | "error" 144 | ], 145 | "import/no-extraneous-dependencies": [ 146 | "error", 147 | { 148 | "devDependencies": [ 149 | "**/test/**", 150 | "**/build-tools/**", 151 | ".projenrc.ts", 152 | "projenrc/**/*.ts" 153 | ], 154 | "optionalDependencies": false, 155 | "peerDependencies": true 156 | } 157 | ], 158 | "import/no-unresolved": [ 159 | "error" 160 | ], 161 | "import/order": [ 162 | "warn", 163 | { 164 | "groups": [ 165 | "builtin", 166 | "external" 167 | ], 168 | "alphabetize": { 169 | "order": "asc", 170 | "caseInsensitive": true 171 | } 172 | } 173 | ], 174 | "import/no-duplicates": [ 175 | "error" 176 | ], 177 | "no-shadow": [ 178 | "off" 179 | ], 180 | "@typescript-eslint/no-shadow": [ 181 | "error" 182 | ], 183 | "key-spacing": [ 184 | "error" 185 | ], 186 | "no-multiple-empty-lines": [ 187 | "error" 188 | ], 189 | "@typescript-eslint/no-floating-promises": [ 190 | "error" 191 | ], 192 | "no-return-await": [ 193 | "off" 194 | ], 195 | "@typescript-eslint/return-await": [ 196 | "error" 197 | ], 198 | "no-trailing-spaces": [ 199 | "error" 200 | ], 201 | "dot-notation": [ 202 | "error" 203 | ], 204 | "no-bitwise": [ 205 | "error" 206 | ], 207 | "@typescript-eslint/member-ordering": [ 208 | "error", 209 | { 210 | "default": [ 211 | "public-static-field", 212 | "public-static-method", 213 | "protected-static-field", 214 | "protected-static-method", 215 | "private-static-field", 216 | "private-static-method", 217 | "field", 218 | "constructor", 219 | "method" 220 | ] 221 | } 222 | ] 223 | }, 224 | "overrides": [ 225 | { 226 | "files": [ 227 | ".projenrc.ts" 228 | ], 229 | "rules": { 230 | "@typescript-eslint/no-require-imports": "off", 231 | "import/no-extraneous-dependencies": "off" 232 | } 233 | } 234 | ] 235 | } 236 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | * text=auto eol=lf 4 | *.snap linguist-generated 5 | /.eslintrc.json linguist-generated 6 | /.gitattributes linguist-generated 7 | /.github/pull_request_template.md linguist-generated 8 | /.github/workflows/auto-approve.yml linguist-generated 9 | /.github/workflows/build.yml linguist-generated 10 | /.github/workflows/pull-request-lint.yml linguist-generated 11 | /.github/workflows/release.yml linguist-generated 12 | /.github/workflows/upgrade-cdklabs-projen-project-types-main.yml linguist-generated 13 | /.github/workflows/upgrade-dev-deps-main.yml linguist-generated 14 | /.github/workflows/upgrade-main.yml linguist-generated 15 | /.gitignore linguist-generated 16 | /.mergify.yml linguist-generated 17 | /.npmignore linguist-generated 18 | /.projen/** linguist-generated 19 | /.projen/deps.json linguist-generated 20 | /.projen/files.json linguist-generated 21 | /.projen/tasks.json linguist-generated 22 | /LICENSE linguist-generated 23 | /package.json linguist-generated 24 | /tsconfig.dev.json linguist-generated 25 | /tsconfig.json linguist-generated 26 | /yarn.lock linguist-generated -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | Fixes # -------------------------------------------------------------------------------- /.github/workflows/auto-approve.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | name: auto-approve 4 | on: 5 | pull_request_target: 6 | types: 7 | - labeled 8 | - opened 9 | - synchronize 10 | - reopened 11 | - ready_for_review 12 | jobs: 13 | approve: 14 | runs-on: ubuntu-latest 15 | permissions: 16 | pull-requests: write 17 | if: contains(github.event.pull_request.labels.*.name, 'auto-approve') && (github.event.pull_request.user.login == 'cdklabs-automation' || github.event.pull_request.user.login == 'dependabot[bot]') 18 | steps: 19 | - uses: hmarr/auto-approve-action@v2.2.1 20 | with: 21 | github-token: ${{ secrets.GITHUB_TOKEN }} 22 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | name: build 4 | on: 5 | pull_request: {} 6 | workflow_dispatch: {} 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | permissions: 11 | contents: write 12 | outputs: 13 | self_mutation_happened: ${{ steps.self_mutation.outputs.self_mutation_happened }} 14 | env: 15 | CI: "true" 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v4 19 | with: 20 | ref: ${{ github.event.pull_request.head.ref }} 21 | repository: ${{ github.event.pull_request.head.repo.full_name }} 22 | - name: Setup Node.js 23 | uses: actions/setup-node@v4 24 | with: 25 | node-version: 18.x 26 | - name: Install dependencies 27 | run: yarn install --check-files 28 | - name: build 29 | run: npx projen build 30 | - name: Find mutations 31 | id: self_mutation 32 | run: |- 33 | git add . 34 | git diff --staged --patch --exit-code > repo.patch || echo "self_mutation_happened=true" >> $GITHUB_OUTPUT 35 | working-directory: ./ 36 | - name: Upload patch 37 | if: steps.self_mutation.outputs.self_mutation_happened 38 | uses: actions/upload-artifact@v4.4.0 39 | with: 40 | name: repo.patch 41 | path: repo.patch 42 | overwrite: true 43 | - name: Fail build on mutation 44 | if: steps.self_mutation.outputs.self_mutation_happened 45 | run: |- 46 | echo "::error::Files were changed during build (see build log). If this was triggered from a fork, you will need to update your branch." 47 | cat repo.patch 48 | exit 1 49 | container: 50 | image: jsii/superchain:1-buster-slim-node16 51 | self-mutation: 52 | needs: build 53 | runs-on: ubuntu-latest 54 | permissions: 55 | contents: write 56 | if: always() && needs.build.outputs.self_mutation_happened && !(github.event.pull_request.head.repo.full_name != github.repository) 57 | steps: 58 | - name: Checkout 59 | uses: actions/checkout@v4 60 | with: 61 | token: ${{ secrets.PROJEN_GITHUB_TOKEN }} 62 | ref: ${{ github.event.pull_request.head.ref }} 63 | repository: ${{ github.event.pull_request.head.repo.full_name }} 64 | - name: Download patch 65 | uses: actions/download-artifact@v4 66 | with: 67 | name: repo.patch 68 | path: ${{ runner.temp }} 69 | - name: Apply patch 70 | run: '[ -s ${{ runner.temp }}/repo.patch ] && git apply ${{ runner.temp }}/repo.patch || echo "Empty patch. Skipping."' 71 | - name: Set git identity 72 | run: |- 73 | git config user.name "github-actions" 74 | git config user.email "github-actions@github.com" 75 | - name: Push changes 76 | env: 77 | PULL_REQUEST_REF: ${{ github.event.pull_request.head.ref }} 78 | run: |- 79 | git add . 80 | git commit -s -m "chore: self mutation" 81 | git push origin HEAD:$PULL_REQUEST_REF 82 | -------------------------------------------------------------------------------- /.github/workflows/pull-request-lint.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | name: pull-request-lint 4 | on: 5 | pull_request_target: 6 | types: 7 | - labeled 8 | - opened 9 | - synchronize 10 | - reopened 11 | - ready_for_review 12 | - edited 13 | jobs: 14 | validate: 15 | name: Validate PR title 16 | runs-on: ubuntu-latest 17 | permissions: 18 | pull-requests: write 19 | steps: 20 | - uses: amannn/action-semantic-pull-request@v5.4.0 21 | env: 22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 23 | with: 24 | types: |- 25 | feat 26 | fix 27 | chore 28 | requireScope: false 29 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | name: release 4 | on: 5 | push: 6 | branches: 7 | - main 8 | workflow_dispatch: {} 9 | concurrency: 10 | group: ${{ github.workflow }} 11 | cancel-in-progress: false 12 | jobs: 13 | release: 14 | runs-on: ubuntu-latest 15 | permissions: 16 | contents: write 17 | outputs: 18 | latest_commit: ${{ steps.git_remote.outputs.latest_commit }} 19 | tag_exists: ${{ steps.check_tag_exists.outputs.exists }} 20 | env: 21 | CI: "true" 22 | steps: 23 | - name: Checkout 24 | uses: actions/checkout@v4 25 | with: 26 | fetch-depth: 0 27 | - name: Set git identity 28 | run: |- 29 | git config user.name "github-actions" 30 | git config user.email "github-actions@github.com" 31 | - name: Setup Node.js 32 | uses: actions/setup-node@v4 33 | with: 34 | node-version: 18.x 35 | - name: Install dependencies 36 | run: yarn install --check-files --frozen-lockfile 37 | - name: release 38 | run: npx projen release 39 | - name: Check if version has already been tagged 40 | id: check_tag_exists 41 | run: |- 42 | TAG=$(cat dist/releasetag.txt) 43 | ([ ! -z "$TAG" ] && git ls-remote -q --exit-code --tags origin $TAG && (echo "exists=true" >> $GITHUB_OUTPUT)) || (echo "exists=false" >> $GITHUB_OUTPUT) 44 | cat $GITHUB_OUTPUT 45 | - name: Check for new commits 46 | id: git_remote 47 | run: |- 48 | echo "latest_commit=$(git ls-remote origin -h ${{ github.ref }} | cut -f1)" >> $GITHUB_OUTPUT 49 | cat $GITHUB_OUTPUT 50 | - name: Backup artifact permissions 51 | if: ${{ steps.git_remote.outputs.latest_commit == github.sha }} 52 | run: cd dist && getfacl -R . > permissions-backup.acl 53 | continue-on-error: true 54 | - name: Upload artifact 55 | if: ${{ steps.git_remote.outputs.latest_commit == github.sha }} 56 | uses: actions/upload-artifact@v4.4.0 57 | with: 58 | name: build-artifact 59 | path: dist 60 | overwrite: true 61 | container: 62 | image: jsii/superchain:1-buster-slim-node16 63 | release_github: 64 | name: Publish to GitHub Releases 65 | needs: 66 | - release 67 | - release_npm 68 | runs-on: ubuntu-latest 69 | permissions: 70 | contents: write 71 | if: needs.release.outputs.tag_exists != 'true' && needs.release.outputs.latest_commit == github.sha 72 | steps: 73 | - uses: actions/setup-node@v4 74 | with: 75 | node-version: 18.x 76 | - name: Download build artifacts 77 | uses: actions/download-artifact@v4 78 | with: 79 | name: build-artifact 80 | path: dist 81 | - name: Restore build artifact permissions 82 | run: cd dist && setfacl --restore=permissions-backup.acl 83 | continue-on-error: true 84 | - name: Release 85 | env: 86 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 87 | GITHUB_REPOSITORY: ${{ github.repository }} 88 | GITHUB_REF: ${{ github.sha }} 89 | run: errout=$(mktemp); gh release create $(cat dist/releasetag.txt) -R $GITHUB_REPOSITORY -F dist/changelog.md -t $(cat dist/releasetag.txt) --target $GITHUB_REF 2> $errout && true; exitcode=$?; if [ $exitcode -ne 0 ] && ! grep -q "Release.tag_name already exists" $errout; then cat $errout; exit $exitcode; fi 90 | container: 91 | image: jsii/superchain:1-buster-slim-node16 92 | release_npm: 93 | name: Publish to npm 94 | needs: release 95 | runs-on: ubuntu-latest 96 | permissions: 97 | id-token: write 98 | contents: read 99 | if: needs.release.outputs.tag_exists != 'true' && needs.release.outputs.latest_commit == github.sha 100 | steps: 101 | - uses: actions/setup-node@v4 102 | with: 103 | node-version: 18.x 104 | - name: Download build artifacts 105 | uses: actions/download-artifact@v4 106 | with: 107 | name: build-artifact 108 | path: dist 109 | - name: Restore build artifact permissions 110 | run: cd dist && setfacl --restore=permissions-backup.acl 111 | continue-on-error: true 112 | - name: Release 113 | env: 114 | NPM_DIST_TAG: latest 115 | NPM_REGISTRY: registry.npmjs.org 116 | NPM_CONFIG_PROVENANCE: "true" 117 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 118 | run: npx -p publib@latest publib-npm 119 | container: 120 | image: jsii/superchain:1-buster-slim-node16 121 | -------------------------------------------------------------------------------- /.github/workflows/upgrade-cdklabs-projen-project-types-main.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | name: upgrade-cdklabs-projen-project-types-main 4 | on: 5 | workflow_dispatch: {} 6 | jobs: 7 | upgrade: 8 | name: Upgrade 9 | runs-on: ubuntu-latest 10 | permissions: 11 | contents: read 12 | outputs: 13 | patch_created: ${{ steps.create_patch.outputs.patch_created }} 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v4 17 | with: 18 | ref: main 19 | - name: Setup Node.js 20 | uses: actions/setup-node@v4 21 | - name: Install dependencies 22 | run: yarn install --check-files --frozen-lockfile 23 | - name: Upgrade dependencies 24 | run: npx projen upgrade-cdklabs-projen-project-types 25 | - name: Find mutations 26 | id: create_patch 27 | run: |- 28 | git add . 29 | git diff --staged --patch --exit-code > repo.patch || echo "patch_created=true" >> $GITHUB_OUTPUT 30 | working-directory: ./ 31 | - name: Upload patch 32 | if: steps.create_patch.outputs.patch_created 33 | uses: actions/upload-artifact@v4.4.0 34 | with: 35 | name: repo.patch 36 | path: repo.patch 37 | overwrite: true 38 | pr: 39 | name: Create Pull Request 40 | needs: upgrade 41 | runs-on: ubuntu-latest 42 | permissions: 43 | contents: read 44 | if: ${{ needs.upgrade.outputs.patch_created }} 45 | steps: 46 | - name: Checkout 47 | uses: actions/checkout@v4 48 | with: 49 | ref: main 50 | - name: Download patch 51 | uses: actions/download-artifact@v4 52 | with: 53 | name: repo.patch 54 | path: ${{ runner.temp }} 55 | - name: Apply patch 56 | run: '[ -s ${{ runner.temp }}/repo.patch ] && git apply ${{ runner.temp }}/repo.patch || echo "Empty patch. Skipping."' 57 | - name: Set git identity 58 | run: |- 59 | git config user.name "github-actions" 60 | git config user.email "github-actions@github.com" 61 | - name: Create Pull Request 62 | id: create-pr 63 | uses: peter-evans/create-pull-request@v6 64 | with: 65 | token: ${{ secrets.PROJEN_GITHUB_TOKEN }} 66 | commit-message: |- 67 | chore(deps): upgrade cdklabs-projen-project-types 68 | 69 | Upgrades project dependencies. See details in [workflow run]. 70 | 71 | [Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} 72 | 73 | ------ 74 | 75 | *Automatically created by projen via the "upgrade-cdklabs-projen-project-types-main" workflow* 76 | branch: github-actions/upgrade-cdklabs-projen-project-types-main 77 | title: "chore(deps): upgrade cdklabs-projen-project-types" 78 | labels: auto-approve 79 | body: |- 80 | Upgrades project dependencies. See details in [workflow run]. 81 | 82 | [Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} 83 | 84 | ------ 85 | 86 | *Automatically created by projen via the "upgrade-cdklabs-projen-project-types-main" workflow* 87 | author: github-actions 88 | committer: github-actions 89 | signoff: true 90 | -------------------------------------------------------------------------------- /.github/workflows/upgrade-dev-deps-main.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | name: upgrade-dev-deps-main 4 | on: 5 | workflow_dispatch: {} 6 | schedule: 7 | - cron: 0 0 * * * 8 | jobs: 9 | upgrade: 10 | name: Upgrade 11 | runs-on: ubuntu-latest 12 | permissions: 13 | contents: read 14 | outputs: 15 | patch_created: ${{ steps.create_patch.outputs.patch_created }} 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v4 19 | with: 20 | ref: main 21 | - name: Setup Node.js 22 | uses: actions/setup-node@v4 23 | with: 24 | node-version: 18.x 25 | - name: Install dependencies 26 | run: yarn install --check-files --frozen-lockfile 27 | - name: Upgrade dependencies 28 | run: npx projen upgrade-dev-deps 29 | - name: Find mutations 30 | id: create_patch 31 | run: |- 32 | git add . 33 | git diff --staged --patch --exit-code > repo.patch || echo "patch_created=true" >> $GITHUB_OUTPUT 34 | working-directory: ./ 35 | - name: Upload patch 36 | if: steps.create_patch.outputs.patch_created 37 | uses: actions/upload-artifact@v4.4.0 38 | with: 39 | name: repo.patch 40 | path: repo.patch 41 | overwrite: true 42 | pr: 43 | name: Create Pull Request 44 | needs: upgrade 45 | runs-on: ubuntu-latest 46 | permissions: 47 | contents: read 48 | if: ${{ needs.upgrade.outputs.patch_created }} 49 | steps: 50 | - name: Checkout 51 | uses: actions/checkout@v4 52 | with: 53 | ref: main 54 | - name: Download patch 55 | uses: actions/download-artifact@v4 56 | with: 57 | name: repo.patch 58 | path: ${{ runner.temp }} 59 | - name: Apply patch 60 | run: '[ -s ${{ runner.temp }}/repo.patch ] && git apply ${{ runner.temp }}/repo.patch || echo "Empty patch. Skipping."' 61 | - name: Set git identity 62 | run: |- 63 | git config user.name "github-actions" 64 | git config user.email "github-actions@github.com" 65 | - name: Create Pull Request 66 | id: create-pr 67 | uses: peter-evans/create-pull-request@v6 68 | with: 69 | token: ${{ secrets.PROJEN_GITHUB_TOKEN }} 70 | commit-message: |- 71 | chore(deps): upgrade dev dependencies 72 | 73 | Upgrades project dependencies. See details in [workflow run]. 74 | 75 | [Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} 76 | 77 | ------ 78 | 79 | *Automatically created by projen via the "upgrade-dev-deps-main" workflow* 80 | branch: github-actions/upgrade-dev-deps-main 81 | title: "chore(deps): upgrade dev dependencies" 82 | labels: auto-approve 83 | body: |- 84 | Upgrades project dependencies. See details in [workflow run]. 85 | 86 | [Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} 87 | 88 | ------ 89 | 90 | *Automatically created by projen via the "upgrade-dev-deps-main" workflow* 91 | author: github-actions 92 | committer: github-actions 93 | signoff: true 94 | -------------------------------------------------------------------------------- /.github/workflows/upgrade-main.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | name: upgrade-main 4 | on: 5 | workflow_dispatch: {} 6 | schedule: 7 | - cron: 0 18 * * * 8 | jobs: 9 | upgrade: 10 | name: Upgrade 11 | runs-on: ubuntu-latest 12 | permissions: 13 | contents: read 14 | outputs: 15 | patch_created: ${{ steps.create_patch.outputs.patch_created }} 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v4 19 | with: 20 | ref: main 21 | - name: Setup Node.js 22 | uses: actions/setup-node@v4 23 | with: 24 | node-version: 18.x 25 | - name: Install dependencies 26 | run: yarn install --check-files --frozen-lockfile 27 | - name: Upgrade dependencies 28 | run: npx projen upgrade 29 | - name: Find mutations 30 | id: create_patch 31 | run: |- 32 | git add . 33 | git diff --staged --patch --exit-code > repo.patch || echo "patch_created=true" >> $GITHUB_OUTPUT 34 | working-directory: ./ 35 | - name: Upload patch 36 | if: steps.create_patch.outputs.patch_created 37 | uses: actions/upload-artifact@v4.4.0 38 | with: 39 | name: repo.patch 40 | path: repo.patch 41 | overwrite: true 42 | pr: 43 | name: Create Pull Request 44 | needs: upgrade 45 | runs-on: ubuntu-latest 46 | permissions: 47 | contents: read 48 | if: ${{ needs.upgrade.outputs.patch_created }} 49 | steps: 50 | - name: Checkout 51 | uses: actions/checkout@v4 52 | with: 53 | ref: main 54 | - name: Download patch 55 | uses: actions/download-artifact@v4 56 | with: 57 | name: repo.patch 58 | path: ${{ runner.temp }} 59 | - name: Apply patch 60 | run: '[ -s ${{ runner.temp }}/repo.patch ] && git apply ${{ runner.temp }}/repo.patch || echo "Empty patch. Skipping."' 61 | - name: Set git identity 62 | run: |- 63 | git config user.name "github-actions" 64 | git config user.email "github-actions@github.com" 65 | - name: Create Pull Request 66 | id: create-pr 67 | uses: peter-evans/create-pull-request@v6 68 | with: 69 | token: ${{ secrets.PROJEN_GITHUB_TOKEN }} 70 | commit-message: |- 71 | fix(deps): upgrade dependencies 72 | 73 | Upgrades project dependencies. See details in [workflow run]. 74 | 75 | [Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} 76 | 77 | ------ 78 | 79 | *Automatically created by projen via the "upgrade-main" workflow* 80 | branch: github-actions/upgrade-main 81 | title: "fix(deps): upgrade dependencies" 82 | labels: auto-approve 83 | body: |- 84 | Upgrades project dependencies. See details in [workflow run]. 85 | 86 | [Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} 87 | 88 | ------ 89 | 90 | *Automatically created by projen via the "upgrade-main" workflow* 91 | author: github-actions 92 | committer: github-actions 93 | signoff: true 94 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | !/.gitattributes 3 | !/.projen/tasks.json 4 | !/.projen/deps.json 5 | !/.projen/files.json 6 | !/.github/workflows/pull-request-lint.yml 7 | !/.github/workflows/auto-approve.yml 8 | !/package.json 9 | !/LICENSE 10 | !/.npmignore 11 | logs 12 | *.log 13 | npm-debug.log* 14 | yarn-debug.log* 15 | yarn-error.log* 16 | lerna-debug.log* 17 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 18 | pids 19 | *.pid 20 | *.seed 21 | *.pid.lock 22 | lib-cov 23 | coverage 24 | *.lcov 25 | .nyc_output 26 | build/Release 27 | node_modules/ 28 | jspm_packages/ 29 | *.tsbuildinfo 30 | .eslintcache 31 | *.tgz 32 | .yarn-integrity 33 | .cache 34 | /test-reports/ 35 | junit.xml 36 | /coverage/ 37 | !/.github/workflows/build.yml 38 | /dist/changelog.md 39 | /dist/version.txt 40 | !/.github/workflows/release.yml 41 | !/.mergify.yml 42 | !/.github/pull_request_template.md 43 | !/test/ 44 | !/tsconfig.json 45 | !/tsconfig.dev.json 46 | !/src/ 47 | /lib 48 | /dist/ 49 | !/.eslintrc.json 50 | !/.github/workflows/upgrade-cdklabs-projen-project-types-main.yml 51 | !/.github/workflows/upgrade-main.yml 52 | !/.github/workflows/upgrade-dev-deps-main.yml 53 | !/.projenrc.ts 54 | -------------------------------------------------------------------------------- /.mergify.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | queue_rules: 4 | - name: default 5 | update_method: merge 6 | conditions: 7 | - "#approved-reviews-by>=1" 8 | - -label~=(do-not-merge) 9 | - status-success=build 10 | pull_request_rules: 11 | - name: Automatic merge on approval and successful build 12 | actions: 13 | delete_head_branch: {} 14 | queue: 15 | method: squash 16 | name: default 17 | commit_message_template: |- 18 | {{ title }} (#{{ number }}) 19 | 20 | {{ body }} 21 | conditions: 22 | - "#approved-reviews-by>=1" 23 | - -label~=(do-not-merge) 24 | - status-success=build 25 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | /.projen/ 3 | /test-reports/ 4 | junit.xml 5 | /coverage/ 6 | permissions-backup.acl 7 | /dist/changelog.md 8 | /dist/version.txt 9 | /.mergify.yml 10 | /test/ 11 | /tsconfig.dev.json 12 | /src/ 13 | !/lib/ 14 | !/lib/**/*.js 15 | !/lib/**/*.d.ts 16 | dist 17 | /tsconfig.json 18 | /.github/ 19 | /.vscode/ 20 | /.idea/ 21 | /.projenrc.js 22 | tsconfig.tsbuildinfo 23 | /.eslintrc.json 24 | /.gitattributes 25 | /.projenrc.ts 26 | /projenrc 27 | -------------------------------------------------------------------------------- /.projen/deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | { 4 | "name": "@types/fs-extra", 5 | "version": "^8", 6 | "type": "build" 7 | }, 8 | { 9 | "name": "@types/jest", 10 | "type": "build" 11 | }, 12 | { 13 | "name": "@types/ncp", 14 | "type": "build" 15 | }, 16 | { 17 | "name": "@types/node", 18 | "version": "^18", 19 | "type": "build" 20 | }, 21 | { 22 | "name": "@typescript-eslint/eslint-plugin", 23 | "version": "^7", 24 | "type": "build" 25 | }, 26 | { 27 | "name": "@typescript-eslint/parser", 28 | "version": "^7", 29 | "type": "build" 30 | }, 31 | { 32 | "name": "cdklabs-projen-project-types", 33 | "type": "build" 34 | }, 35 | { 36 | "name": "commit-and-tag-version", 37 | "version": "^12", 38 | "type": "build" 39 | }, 40 | { 41 | "name": "constructs", 42 | "version": "^10.0.0", 43 | "type": "build" 44 | }, 45 | { 46 | "name": "eslint-import-resolver-typescript", 47 | "type": "build" 48 | }, 49 | { 50 | "name": "eslint-plugin-import", 51 | "type": "build" 52 | }, 53 | { 54 | "name": "eslint", 55 | "version": "^8", 56 | "type": "build" 57 | }, 58 | { 59 | "name": "jest", 60 | "type": "build" 61 | }, 62 | { 63 | "name": "jest-junit", 64 | "version": "^15", 65 | "type": "build" 66 | }, 67 | { 68 | "name": "projen", 69 | "type": "build" 70 | }, 71 | { 72 | "name": "ts-jest", 73 | "type": "build" 74 | }, 75 | { 76 | "name": "ts-node", 77 | "type": "build" 78 | }, 79 | { 80 | "name": "typescript", 81 | "type": "build" 82 | }, 83 | { 84 | "name": "jackspeak", 85 | "version": "2.0.3", 86 | "type": "override" 87 | }, 88 | { 89 | "name": "fs-extra", 90 | "type": "runtime" 91 | }, 92 | { 93 | "name": "jsii", 94 | "type": "runtime" 95 | }, 96 | { 97 | "name": "jsii-pacmak", 98 | "type": "runtime" 99 | }, 100 | { 101 | "name": "jsii-rosetta", 102 | "type": "runtime" 103 | }, 104 | { 105 | "name": "ncp", 106 | "type": "runtime" 107 | }, 108 | { 109 | "name": "yargs", 110 | "type": "runtime" 111 | } 112 | ], 113 | "//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"npx projen\"." 114 | } 115 | -------------------------------------------------------------------------------- /.projen/files.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | ".eslintrc.json", 4 | ".gitattributes", 5 | ".github/pull_request_template.md", 6 | ".github/workflows/auto-approve.yml", 7 | ".github/workflows/build.yml", 8 | ".github/workflows/pull-request-lint.yml", 9 | ".github/workflows/release.yml", 10 | ".github/workflows/upgrade-cdklabs-projen-project-types-main.yml", 11 | ".github/workflows/upgrade-dev-deps-main.yml", 12 | ".github/workflows/upgrade-main.yml", 13 | ".gitignore", 14 | ".mergify.yml", 15 | ".npmignore", 16 | ".projen/deps.json", 17 | ".projen/files.json", 18 | ".projen/tasks.json", 19 | "LICENSE", 20 | "tsconfig.dev.json", 21 | "tsconfig.json" 22 | ], 23 | "//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"npx projen\"." 24 | } 25 | -------------------------------------------------------------------------------- /.projen/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": { 3 | "build": { 4 | "name": "build", 5 | "description": "Full release build", 6 | "steps": [ 7 | { 8 | "spawn": "default" 9 | }, 10 | { 11 | "spawn": "pre-compile" 12 | }, 13 | { 14 | "spawn": "compile" 15 | }, 16 | { 17 | "spawn": "post-compile" 18 | }, 19 | { 20 | "spawn": "test" 21 | }, 22 | { 23 | "spawn": "package" 24 | } 25 | ] 26 | }, 27 | "bump": { 28 | "name": "bump", 29 | "description": "Bumps version based on latest git tag and generates a changelog entry", 30 | "env": { 31 | "OUTFILE": "package.json", 32 | "CHANGELOG": "dist/changelog.md", 33 | "BUMPFILE": "dist/version.txt", 34 | "RELEASETAG": "dist/releasetag.txt", 35 | "RELEASE_TAG_PREFIX": "", 36 | "BUMP_PACKAGE": "commit-and-tag-version@^12", 37 | "RELEASABLE_COMMITS": "git log --no-merges --oneline $LATEST_TAG..HEAD -E --grep \"^(feat|fix){1}(\\([^()[:space:]]+\\))?(!)?:[[:blank:]]+.+\"" 38 | }, 39 | "steps": [ 40 | { 41 | "builtin": "release/bump-version" 42 | } 43 | ], 44 | "condition": "git log --oneline -1 | grep -qv \"chore(release):\"" 45 | }, 46 | "clobber": { 47 | "name": "clobber", 48 | "description": "hard resets to HEAD of origin and cleans the local repo", 49 | "env": { 50 | "BRANCH": "$(git branch --show-current)" 51 | }, 52 | "steps": [ 53 | { 54 | "exec": "git checkout -b scratch", 55 | "name": "save current HEAD in \"scratch\" branch" 56 | }, 57 | { 58 | "exec": "git checkout $BRANCH" 59 | }, 60 | { 61 | "exec": "git fetch origin", 62 | "name": "fetch latest changes from origin" 63 | }, 64 | { 65 | "exec": "git reset --hard origin/$BRANCH", 66 | "name": "hard reset to origin commit" 67 | }, 68 | { 69 | "exec": "git clean -fdx", 70 | "name": "clean all untracked files" 71 | }, 72 | { 73 | "say": "ready to rock! (unpushed commits are under the \"scratch\" branch)" 74 | } 75 | ], 76 | "condition": "git diff --exit-code > /dev/null" 77 | }, 78 | "compile": { 79 | "name": "compile", 80 | "description": "Only compile", 81 | "steps": [ 82 | { 83 | "exec": "tsc --build" 84 | } 85 | ] 86 | }, 87 | "default": { 88 | "name": "default", 89 | "description": "Synthesize project files", 90 | "steps": [ 91 | { 92 | "exec": "ts-node --project tsconfig.dev.json .projenrc.ts" 93 | } 94 | ] 95 | }, 96 | "eject": { 97 | "name": "eject", 98 | "description": "Remove projen from the project", 99 | "env": { 100 | "PROJEN_EJECTING": "true" 101 | }, 102 | "steps": [ 103 | { 104 | "spawn": "default" 105 | } 106 | ] 107 | }, 108 | "eslint": { 109 | "name": "eslint", 110 | "description": "Runs eslint against the codebase", 111 | "steps": [ 112 | { 113 | "exec": "eslint --ext .ts,.tsx --fix --no-error-on-unmatched-pattern $@ src test build-tools projenrc .projenrc.ts", 114 | "receiveArgs": true 115 | } 116 | ] 117 | }, 118 | "install": { 119 | "name": "install", 120 | "description": "Install project dependencies and update lockfile (non-frozen)", 121 | "steps": [ 122 | { 123 | "exec": "yarn install --check-files" 124 | } 125 | ] 126 | }, 127 | "install:ci": { 128 | "name": "install:ci", 129 | "description": "Install project dependencies using frozen lockfile", 130 | "steps": [ 131 | { 132 | "exec": "yarn install --check-files --frozen-lockfile" 133 | } 134 | ] 135 | }, 136 | "package": { 137 | "name": "package", 138 | "description": "Creates the distribution package", 139 | "steps": [ 140 | { 141 | "exec": "mkdir -p dist/js" 142 | }, 143 | { 144 | "exec": "npm pack --pack-destination dist/js" 145 | } 146 | ] 147 | }, 148 | "post-compile": { 149 | "name": "post-compile", 150 | "description": "Runs after successful compilation" 151 | }, 152 | "post-upgrade": { 153 | "name": "post-upgrade", 154 | "description": "Runs after upgrading dependencies" 155 | }, 156 | "pre-compile": { 157 | "name": "pre-compile", 158 | "description": "Prepare the project for compilation" 159 | }, 160 | "release": { 161 | "name": "release", 162 | "description": "Prepare a release from \"main\" branch", 163 | "env": { 164 | "RELEASE": "true" 165 | }, 166 | "steps": [ 167 | { 168 | "exec": "rm -fr dist" 169 | }, 170 | { 171 | "spawn": "bump" 172 | }, 173 | { 174 | "spawn": "build" 175 | }, 176 | { 177 | "spawn": "unbump" 178 | }, 179 | { 180 | "exec": "git diff --ignore-space-at-eol --exit-code" 181 | } 182 | ] 183 | }, 184 | "test": { 185 | "name": "test", 186 | "description": "Run tests", 187 | "steps": [ 188 | { 189 | "exec": "jest --passWithNoTests --updateSnapshot", 190 | "receiveArgs": true 191 | }, 192 | { 193 | "spawn": "eslint" 194 | } 195 | ] 196 | }, 197 | "test:watch": { 198 | "name": "test:watch", 199 | "description": "Run jest in watch mode", 200 | "steps": [ 201 | { 202 | "exec": "jest --watch" 203 | } 204 | ] 205 | }, 206 | "unbump": { 207 | "name": "unbump", 208 | "description": "Restores version to 0.0.0", 209 | "env": { 210 | "OUTFILE": "package.json", 211 | "CHANGELOG": "dist/changelog.md", 212 | "BUMPFILE": "dist/version.txt", 213 | "RELEASETAG": "dist/releasetag.txt", 214 | "RELEASE_TAG_PREFIX": "", 215 | "BUMP_PACKAGE": "commit-and-tag-version@^12", 216 | "RELEASABLE_COMMITS": "git log --no-merges --oneline $LATEST_TAG..HEAD -E --grep \"^(feat|fix){1}(\\([^()[:space:]]+\\))?(!)?:[[:blank:]]+.+\"" 217 | }, 218 | "steps": [ 219 | { 220 | "builtin": "release/reset-version" 221 | } 222 | ] 223 | }, 224 | "upgrade": { 225 | "name": "upgrade", 226 | "description": "upgrade dependencies", 227 | "env": { 228 | "CI": "0" 229 | }, 230 | "steps": [ 231 | { 232 | "exec": "npx npm-check-updates@16 --upgrade --target=minor --peer --dep=prod --filter=fs-extra,jsii,jsii-pacmak,jsii-rosetta,ncp,yargs" 233 | }, 234 | { 235 | "exec": "yarn install --check-files" 236 | }, 237 | { 238 | "exec": "yarn upgrade fs-extra jsii jsii-pacmak jsii-rosetta ncp yargs" 239 | }, 240 | { 241 | "exec": "npx projen" 242 | }, 243 | { 244 | "spawn": "post-upgrade" 245 | } 246 | ] 247 | }, 248 | "upgrade-cdklabs-projen-project-types": { 249 | "name": "upgrade-cdklabs-projen-project-types", 250 | "description": "upgrade cdklabs-projen-project-types", 251 | "env": { 252 | "CI": "0" 253 | }, 254 | "steps": [ 255 | { 256 | "exec": "npx npm-check-updates@16 --upgrade --target=latest --peer --dep=dev,peer,prod,optional --filter=cdklabs-projen-project-types,projen" 257 | }, 258 | { 259 | "exec": "yarn install --check-files" 260 | }, 261 | { 262 | "exec": "yarn upgrade cdklabs-projen-project-types projen" 263 | }, 264 | { 265 | "exec": "npx projen" 266 | }, 267 | { 268 | "spawn": "post-upgrade" 269 | } 270 | ] 271 | }, 272 | "upgrade-dev-deps": { 273 | "name": "upgrade-dev-deps", 274 | "description": "upgrade dev dependencies", 275 | "env": { 276 | "CI": "0" 277 | }, 278 | "steps": [ 279 | { 280 | "exec": "npx npm-check-updates@16 --upgrade --target=minor --peer --dep=dev --filter=@types/jest,@types/ncp,eslint-import-resolver-typescript,eslint-plugin-import,jest,ts-jest,ts-node,typescript" 281 | }, 282 | { 283 | "exec": "yarn install --check-files" 284 | }, 285 | { 286 | "exec": "yarn upgrade @types/fs-extra @types/jest @types/ncp @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser commit-and-tag-version constructs eslint-import-resolver-typescript eslint-plugin-import eslint jest jest-junit ts-jest ts-node typescript" 287 | }, 288 | { 289 | "exec": "npx projen" 290 | }, 291 | { 292 | "spawn": "post-upgrade" 293 | } 294 | ] 295 | }, 296 | "watch": { 297 | "name": "watch", 298 | "description": "Watch & compile in the background", 299 | "steps": [ 300 | { 301 | "exec": "tsc --build -w" 302 | } 303 | ] 304 | } 305 | }, 306 | "env": { 307 | "PATH": "$(npx -c \"node --print process.env.PATH\")" 308 | }, 309 | "//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"npx projen\"." 310 | } 311 | -------------------------------------------------------------------------------- /.projenrc.ts: -------------------------------------------------------------------------------- 1 | import { CdklabsTypeScriptProject } from 'cdklabs-projen-project-types'; 2 | 3 | const project = new CdklabsTypeScriptProject({ 4 | name: 'jsii-srcmak', 5 | projenrcTs: true, 6 | private: false, 7 | setNodeEngineVersion: false, 8 | workflowNodeVersion: '18.x', 9 | description: 'generate source code in multiple languages from typescript', 10 | repository: 'https://github.com/cdklabs/jsii-srcmak.git', 11 | stability: 'experimental', 12 | defaultReleaseBranch: 'main', 13 | 14 | bin: { 15 | 'jsii-srcmak': 'bin/jsii-srcmak', 16 | }, 17 | 18 | devDeps: [ 19 | '@types/ncp', 20 | '@types/fs-extra@^8', 21 | 'constructs', 22 | 'cdklabs-projen-project-types', 23 | ], 24 | 25 | deps: [ 26 | 'jsii', 27 | 'jsii-pacmak', 28 | 'jsii-rosetta', 29 | 'fs-extra', 30 | 'ncp', 31 | 'yargs', 32 | ], 33 | 34 | releaseToNpm: true, 35 | 36 | // superchain is needed to ensure jsii-pacmak has everything it needs 37 | workflowContainerImage: 'jsii/superchain:1-buster-slim-node16', 38 | autoApproveOptions: { 39 | allowedUsernames: ['cdklabs-automation'], 40 | secret: 'GITHUB_TOKEN', 41 | }, 42 | autoApproveUpgrades: true, 43 | }); 44 | 45 | project.package.addPackageResolutions('jackspeak@2.0.3'); 46 | 47 | project.synth(); 48 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | 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. 4 | 5 | ### [0.1.255](https://github.com/aws/jsii-srcmak/compare/v0.1.254...v0.1.255) (2021-03-18) 6 | 7 | ### [0.1.254](https://github.com/aws/jsii-srcmak/compare/v0.1.253...v0.1.254) (2021-03-18) 8 | 9 | ### [0.1.253](https://github.com/aws/jsii-srcmak/compare/v0.1.252...v0.1.253) (2021-03-18) 10 | 11 | ### [0.1.252](https://github.com/aws/jsii-srcmak/compare/v0.1.251...v0.1.252) (2021-03-08) 12 | 13 | ### [0.1.251](https://github.com/aws/jsii-srcmak/compare/v0.1.250...v0.1.251) (2021-03-08) 14 | 15 | ### [0.1.250](https://github.com/aws/jsii-srcmak/compare/v0.1.249...v0.1.250) (2021-03-06) 16 | 17 | ### [0.1.249](https://github.com/aws/jsii-srcmak/compare/v0.1.248...v0.1.249) (2021-03-05) 18 | 19 | ### [0.1.248](https://github.com/aws/jsii-srcmak/compare/v0.1.247...v0.1.248) (2021-03-05) 20 | 21 | ### [0.1.247](https://github.com/aws/jsii-srcmak/compare/v0.1.246...v0.1.247) (2021-03-05) 22 | 23 | ### [0.1.246](https://github.com/aws/jsii-srcmak/compare/v0.1.245...v0.1.246) (2021-03-04) 24 | 25 | ### [0.1.245](https://github.com/aws/jsii-srcmak/compare/v0.1.244...v0.1.245) (2021-03-04) 26 | 27 | ### [0.1.244](https://github.com/aws/jsii-srcmak/compare/v0.1.243...v0.1.244) (2021-03-03) 28 | 29 | ### [0.1.243](https://github.com/aws/jsii-srcmak/compare/v0.1.242...v0.1.243) (2021-03-03) 30 | 31 | ### [0.1.242](https://github.com/aws/jsii-srcmak/compare/v0.1.241...v0.1.242) (2021-03-02) 32 | 33 | ### [0.1.241](https://github.com/aws/jsii-srcmak/compare/v0.1.240...v0.1.241) (2021-03-02) 34 | 35 | ### [0.1.240](https://github.com/aws/jsii-srcmak/compare/v0.1.239...v0.1.240) (2021-03-02) 36 | 37 | ### [0.1.239](https://github.com/aws/jsii-srcmak/compare/v0.1.238...v0.1.239) (2021-03-02) 38 | 39 | ### [0.1.238](https://github.com/aws/jsii-srcmak/compare/v0.1.237...v0.1.238) (2021-02-27) 40 | 41 | ### [0.1.237](https://github.com/aws/jsii-srcmak/compare/v0.1.236...v0.1.237) (2021-02-26) 42 | 43 | ### [0.1.236](https://github.com/aws/jsii-srcmak/compare/v0.1.235...v0.1.236) (2021-02-26) 44 | 45 | ### [0.1.235](https://github.com/aws/jsii-srcmak/compare/v0.1.234...v0.1.235) (2021-02-25) 46 | 47 | ### [0.1.234](https://github.com/aws/jsii-srcmak/compare/v0.1.233...v0.1.234) (2021-02-25) 48 | 49 | ### [0.1.233](https://github.com/aws/jsii-srcmak/compare/v0.1.232...v0.1.233) (2021-02-24) 50 | 51 | ### [0.1.232](https://github.com/aws/jsii-srcmak/compare/v0.1.231...v0.1.232) (2021-02-24) 52 | 53 | ### [0.1.231](https://github.com/aws/jsii-srcmak/compare/v0.1.230...v0.1.231) (2021-02-24) 54 | 55 | ### [0.1.230](https://github.com/aws/jsii-srcmak/compare/v0.1.229...v0.1.230) (2021-02-24) 56 | 57 | ### [0.1.229](https://github.com/aws/jsii-srcmak/compare/v0.1.228...v0.1.229) (2021-02-23) 58 | 59 | ### [0.1.228](https://github.com/aws/jsii-srcmak/compare/v0.1.227...v0.1.228) (2021-02-23) 60 | 61 | ### [0.1.227](https://github.com/aws/jsii-srcmak/compare/v0.1.226...v0.1.227) (2021-02-23) 62 | 63 | ### [0.1.226](https://github.com/aws/jsii-srcmak/compare/v0.1.225...v0.1.226) (2021-02-23) 64 | 65 | ### [0.1.225](https://github.com/aws/jsii-srcmak/compare/v0.1.224...v0.1.225) (2021-02-23) 66 | 67 | ### [0.1.224](https://github.com/aws/jsii-srcmak/compare/v0.1.223...v0.1.224) (2021-02-23) 68 | 69 | ### [0.1.223](https://github.com/aws/jsii-srcmak/compare/v0.1.222...v0.1.223) (2021-02-22) 70 | 71 | 72 | ### Bug Fixes 73 | 74 | * symlinks don’t work on windows ([#307](https://github.com/aws/jsii-srcmak/issues/307)) ([96ce223](https://github.com/aws/jsii-srcmak/commit/96ce2238c4ddb9bf512f9d32218e2c4374e15d56)) 75 | 76 | ### [0.1.222](https://github.com/eladb/jsii-srcmak/compare/v0.1.221...v0.1.222) (2021-02-08) 77 | 78 | ### [0.1.221](https://github.com/eladb/jsii-srcmak/compare/v0.1.220...v0.1.221) (2021-02-08) 79 | 80 | ### [0.1.220](https://github.com/eladb/jsii-srcmak/compare/v0.1.219...v0.1.220) (2021-02-05) 81 | 82 | ### [0.1.219](https://github.com/eladb/jsii-srcmak/compare/v0.1.218...v0.1.219) (2021-02-05) 83 | 84 | ### [0.1.218](https://github.com/eladb/jsii-srcmak/compare/v0.1.216...v0.1.218) (2021-02-04) 85 | 86 | ### [0.1.217](https://github.com/eladb/jsii-srcmak/compare/v0.1.216...v0.1.217) (2021-02-04) 87 | 88 | ### [0.1.216](https://github.com/eladb/jsii-srcmak/compare/v0.1.215...v0.1.216) (2021-02-04) 89 | 90 | ### [0.1.215](https://github.com/eladb/jsii-srcmak/compare/v0.1.214...v0.1.215) (2021-02-03) 91 | 92 | ### [0.1.214](https://github.com/eladb/jsii-srcmak/compare/v0.1.212...v0.1.214) (2021-02-02) 93 | 94 | ### [0.1.213](https://github.com/eladb/jsii-srcmak/compare/v0.1.212...v0.1.213) (2021-02-02) 95 | 96 | ### [0.1.212](https://github.com/eladb/jsii-srcmak/compare/v0.1.211...v0.1.212) (2021-02-01) 97 | 98 | ### [0.1.211](https://github.com/eladb/jsii-srcmak/compare/v0.1.210...v0.1.211) (2021-02-01) 99 | 100 | ### [0.1.210](https://github.com/eladb/jsii-srcmak/compare/v0.1.209...v0.1.210) (2021-01-27) 101 | 102 | ### [0.1.209](https://github.com/eladb/jsii-srcmak/compare/v0.1.207...v0.1.209) (2021-01-26) 103 | 104 | ### [0.1.208](https://github.com/eladb/jsii-srcmak/compare/v0.1.207...v0.1.208) (2021-01-26) 105 | 106 | ### [0.1.207](https://github.com/eladb/jsii-srcmak/compare/v0.1.206...v0.1.207) (2021-01-25) 107 | 108 | ### [0.1.206](https://github.com/eladb/jsii-srcmak/compare/v0.1.205...v0.1.206) (2021-01-22) 109 | 110 | ### [0.1.205](https://github.com/eladb/jsii-srcmak/compare/v0.1.204...v0.1.205) (2021-01-22) 111 | 112 | ### [0.1.204](https://github.com/eladb/jsii-srcmak/compare/v0.1.203...v0.1.204) (2021-01-21) 113 | 114 | ### [0.1.203](https://github.com/eladb/jsii-srcmak/compare/v0.1.202...v0.1.203) (2021-01-21) 115 | 116 | ### [0.1.202](https://github.com/eladb/jsii-srcmak/compare/v0.1.201...v0.1.202) (2021-01-20) 117 | 118 | ### [0.1.201](https://github.com/eladb/jsii-srcmak/compare/v0.1.199...v0.1.201) (2021-01-20) 119 | 120 | ### [0.1.200](https://github.com/eladb/jsii-srcmak/compare/v0.1.199...v0.1.200) (2021-01-19) 121 | 122 | ### [0.1.199](https://github.com/eladb/jsii-srcmak/compare/v0.1.198...v0.1.199) (2021-01-18) 123 | 124 | ### [0.1.198](https://github.com/eladb/jsii-srcmak/compare/v0.1.197...v0.1.198) (2021-01-18) 125 | 126 | ### [0.1.197](https://github.com/eladb/jsii-srcmak/compare/v0.1.195...v0.1.197) (2021-01-15) 127 | 128 | ### [0.1.196](https://github.com/eladb/jsii-srcmak/compare/v0.1.195...v0.1.196) (2021-01-15) 129 | 130 | ### [0.1.195](https://github.com/eladb/jsii-srcmak/compare/v0.1.194...v0.1.195) (2021-01-14) 131 | 132 | ### [0.1.194](https://github.com/eladb/jsii-srcmak/compare/v0.1.193...v0.1.194) (2021-01-14) 133 | 134 | ### [0.1.193](https://github.com/eladb/jsii-srcmak/compare/v0.1.192...v0.1.193) (2021-01-14) 135 | 136 | ### [0.1.192](https://github.com/eladb/jsii-srcmak/compare/v0.1.191...v0.1.192) (2021-01-13) 137 | 138 | ### [0.1.191](https://github.com/eladb/jsii-srcmak/compare/v0.1.189...v0.1.191) (2021-01-12) 139 | 140 | ### [0.1.190](https://github.com/eladb/jsii-srcmak/compare/v0.1.189...v0.1.190) (2021-01-12) 141 | 142 | ### [0.1.189](https://github.com/eladb/jsii-srcmak/compare/v0.1.188...v0.1.189) (2021-01-11) 143 | 144 | ### [0.1.188](https://github.com/eladb/jsii-srcmak/compare/v0.1.187...v0.1.188) (2021-01-11) 145 | 146 | ### [0.1.187](https://github.com/eladb/jsii-srcmak/compare/v0.1.186...v0.1.187) (2021-01-09) 147 | 148 | ### [0.1.186](https://github.com/eladb/jsii-srcmak/compare/v0.1.184...v0.1.186) (2021-01-08) 149 | 150 | ### [0.1.185](https://github.com/eladb/jsii-srcmak/compare/v0.1.184...v0.1.185) (2021-01-08) 151 | 152 | ### [0.1.184](https://github.com/eladb/jsii-srcmak/compare/v0.1.183...v0.1.184) (2021-01-07) 153 | 154 | ### [0.1.183](https://github.com/eladb/jsii-srcmak/compare/v0.1.182...v0.1.183) (2021-01-07) 155 | 156 | ### [0.1.182](https://github.com/eladb/jsii-srcmak/compare/v0.1.181...v0.1.182) (2021-01-06) 157 | 158 | ### [0.1.181](https://github.com/eladb/jsii-srcmak/compare/v0.1.180...v0.1.181) (2021-01-06) 159 | 160 | ### [0.1.180](https://github.com/eladb/jsii-srcmak/compare/v0.1.179...v0.1.180) (2021-01-05) 161 | 162 | ### [0.1.179](https://github.com/eladb/jsii-srcmak/compare/v0.1.178...v0.1.179) (2021-01-05) 163 | 164 | ### [0.1.178](https://github.com/eladb/jsii-srcmak/compare/v0.1.177...v0.1.178) (2021-01-04) 165 | 166 | ### [0.1.177](https://github.com/eladb/jsii-srcmak/compare/v0.1.176...v0.1.177) (2021-01-04) 167 | 168 | ### [0.1.176](https://github.com/eladb/jsii-srcmak/compare/v0.1.175...v0.1.176) (2021-01-02) 169 | 170 | ### [0.1.175](https://github.com/eladb/jsii-srcmak/compare/v0.1.174...v0.1.175) (2021-01-01) 171 | 172 | ### [0.1.174](https://github.com/eladb/jsii-srcmak/compare/v0.1.173...v0.1.174) (2020-12-31) 173 | 174 | ### [0.1.173](https://github.com/eladb/jsii-srcmak/compare/v0.1.172...v0.1.173) (2020-12-31) 175 | 176 | ### [0.1.172](https://github.com/eladb/jsii-srcmak/compare/v0.1.171...v0.1.172) (2020-12-30) 177 | 178 | ### [0.1.171](https://github.com/eladb/jsii-srcmak/compare/v0.1.170...v0.1.171) (2020-12-30) 179 | 180 | ### [0.1.170](https://github.com/eladb/jsii-srcmak/compare/v0.1.168...v0.1.170) (2020-12-29) 181 | 182 | ### [0.1.169](https://github.com/eladb/jsii-srcmak/compare/v0.1.168...v0.1.169) (2020-12-29) 183 | 184 | ### [0.1.168](https://github.com/eladb/jsii-srcmak/compare/v0.1.167...v0.1.168) (2020-12-28) 185 | 186 | ### [0.1.167](https://github.com/eladb/jsii-srcmak/compare/v0.1.166...v0.1.167) (2020-12-28) 187 | 188 | ### [0.1.166](https://github.com/eladb/jsii-srcmak/compare/v0.1.165...v0.1.166) (2020-12-25) 189 | 190 | ### 0.1.165 (2020-12-25) 191 | 192 | 193 | ### Features 194 | 195 | * .NET Support ([#73](https://github.com/eladb/jsii-srcmak/issues/73)) ([a0dc5ea](https://github.com/eladb/jsii-srcmak/commit/a0dc5ea0d53daf62df62601372771a2be15d74ec)) 196 | * export "Options" ([18cb8f3](https://github.com/eladb/jsii-srcmak/commit/18cb8f354640fd39077ccf362a5112a3bcd1befa)) 197 | * initial version ([158e2dd](https://github.com/eladb/jsii-srcmak/commit/158e2dd356d54fd180fdb6ebe54a2dd06f9a2469)) 198 | * Java support ([#2](https://github.com/eladb/jsii-srcmak/issues/2)) ([9e84d6e](https://github.com/eladb/jsii-srcmak/commit/9e84d6ee37662ba699d4a72f1656ca03d5fd949f)) 199 | * make "compile" private ([38fd95f](https://github.com/eladb/jsii-srcmak/commit/38fd95f9e176121103f2986ccae6890e81e487ed)) 200 | * make this a real thang ([b6c7c7e](https://github.com/eladb/jsii-srcmak/commit/b6c7c7efacd054dc64f72b342194436650e1bf2f)) 201 | * outputJsii ([1fd47b1](https://github.com/eladb/jsii-srcmak/commit/1fd47b13af3f18cab55ec0b26be408c1a78a16bc)) 202 | 203 | 204 | ### Bug Fixes 205 | 206 | * fails if java output directory does not exist ([6af49fe](https://github.com/eladb/jsii-srcmak/commit/6af49fefac3c4dadc0ca19ec3c56a44601548390)) 207 | * java output location moved to src/main ([#3](https://github.com/eladb/jsii-srcmak/issues/3)) ([96c76e4](https://github.com/eladb/jsii-srcmak/commit/96c76e4e23568b55d13721bb302b36b156bdf20f)), closes [/github.com/awslabs/cdk8s/pull/233#discussion_r439811482](https://github.com/eladb//github.com/awslabs/cdk8s/pull/233/issues/discussion_r439811482) 208 | * Package name collisions ([#22](https://github.com/eladb/jsii-srcmak/issues/22)) ([766de96](https://github.com/eladb/jsii-srcmak/commit/766de96d655463dadf5a9578ba38d47121be447b)) 209 | 210 | ### 0.1.164 (2020-12-24) 211 | 212 | 213 | ### Features 214 | 215 | * .NET Support ([#73](https://github.com/eladb/jsii-srcmak/issues/73)) ([a0dc5ea](https://github.com/eladb/jsii-srcmak/commit/a0dc5ea0d53daf62df62601372771a2be15d74ec)) 216 | * export "Options" ([18cb8f3](https://github.com/eladb/jsii-srcmak/commit/18cb8f354640fd39077ccf362a5112a3bcd1befa)) 217 | * initial version ([158e2dd](https://github.com/eladb/jsii-srcmak/commit/158e2dd356d54fd180fdb6ebe54a2dd06f9a2469)) 218 | * Java support ([#2](https://github.com/eladb/jsii-srcmak/issues/2)) ([9e84d6e](https://github.com/eladb/jsii-srcmak/commit/9e84d6ee37662ba699d4a72f1656ca03d5fd949f)) 219 | * make "compile" private ([38fd95f](https://github.com/eladb/jsii-srcmak/commit/38fd95f9e176121103f2986ccae6890e81e487ed)) 220 | * make this a real thang ([b6c7c7e](https://github.com/eladb/jsii-srcmak/commit/b6c7c7efacd054dc64f72b342194436650e1bf2f)) 221 | * outputJsii ([1fd47b1](https://github.com/eladb/jsii-srcmak/commit/1fd47b13af3f18cab55ec0b26be408c1a78a16bc)) 222 | 223 | 224 | ### Bug Fixes 225 | 226 | * fails if java output directory does not exist ([6af49fe](https://github.com/eladb/jsii-srcmak/commit/6af49fefac3c4dadc0ca19ec3c56a44601548390)) 227 | * java output location moved to src/main ([#3](https://github.com/eladb/jsii-srcmak/issues/3)) ([96c76e4](https://github.com/eladb/jsii-srcmak/commit/96c76e4e23568b55d13721bb302b36b156bdf20f)), closes [/github.com/awslabs/cdk8s/pull/233#discussion_r439811482](https://github.com/eladb//github.com/awslabs/cdk8s/pull/233/issues/discussion_r439811482) 228 | * Package name collisions ([#22](https://github.com/eladb/jsii-srcmak/issues/22)) ([766de96](https://github.com/eladb/jsii-srcmak/commit/766de96d655463dadf5a9578ba38d47121be447b)) 229 | 230 | ### 0.1.163 (2020-12-24) 231 | 232 | 233 | ### Features 234 | 235 | * .NET Support ([#73](https://github.com/eladb/jsii-srcmak/issues/73)) ([a0dc5ea](https://github.com/eladb/jsii-srcmak/commit/a0dc5ea0d53daf62df62601372771a2be15d74ec)) 236 | * export "Options" ([18cb8f3](https://github.com/eladb/jsii-srcmak/commit/18cb8f354640fd39077ccf362a5112a3bcd1befa)) 237 | * initial version ([158e2dd](https://github.com/eladb/jsii-srcmak/commit/158e2dd356d54fd180fdb6ebe54a2dd06f9a2469)) 238 | * Java support ([#2](https://github.com/eladb/jsii-srcmak/issues/2)) ([9e84d6e](https://github.com/eladb/jsii-srcmak/commit/9e84d6ee37662ba699d4a72f1656ca03d5fd949f)) 239 | * make "compile" private ([38fd95f](https://github.com/eladb/jsii-srcmak/commit/38fd95f9e176121103f2986ccae6890e81e487ed)) 240 | * make this a real thang ([b6c7c7e](https://github.com/eladb/jsii-srcmak/commit/b6c7c7efacd054dc64f72b342194436650e1bf2f)) 241 | * outputJsii ([1fd47b1](https://github.com/eladb/jsii-srcmak/commit/1fd47b13af3f18cab55ec0b26be408c1a78a16bc)) 242 | 243 | 244 | ### Bug Fixes 245 | 246 | * fails if java output directory does not exist ([6af49fe](https://github.com/eladb/jsii-srcmak/commit/6af49fefac3c4dadc0ca19ec3c56a44601548390)) 247 | * java output location moved to src/main ([#3](https://github.com/eladb/jsii-srcmak/issues/3)) ([96c76e4](https://github.com/eladb/jsii-srcmak/commit/96c76e4e23568b55d13721bb302b36b156bdf20f)), closes [/github.com/awslabs/cdk8s/pull/233#discussion_r439811482](https://github.com/eladb//github.com/awslabs/cdk8s/pull/233/issues/discussion_r439811482) 248 | * Package name collisions ([#22](https://github.com/eladb/jsii-srcmak/issues/22)) ([766de96](https://github.com/eladb/jsii-srcmak/commit/766de96d655463dadf5a9578ba38d47121be447b)) 249 | 250 | ### 0.1.162 (2020-12-23) 251 | 252 | 253 | ### Features 254 | 255 | * .NET Support ([#73](https://github.com/eladb/jsii-srcmak/issues/73)) ([a0dc5ea](https://github.com/eladb/jsii-srcmak/commit/a0dc5ea0d53daf62df62601372771a2be15d74ec)) 256 | * export "Options" ([18cb8f3](https://github.com/eladb/jsii-srcmak/commit/18cb8f354640fd39077ccf362a5112a3bcd1befa)) 257 | * initial version ([158e2dd](https://github.com/eladb/jsii-srcmak/commit/158e2dd356d54fd180fdb6ebe54a2dd06f9a2469)) 258 | * Java support ([#2](https://github.com/eladb/jsii-srcmak/issues/2)) ([9e84d6e](https://github.com/eladb/jsii-srcmak/commit/9e84d6ee37662ba699d4a72f1656ca03d5fd949f)) 259 | * make "compile" private ([38fd95f](https://github.com/eladb/jsii-srcmak/commit/38fd95f9e176121103f2986ccae6890e81e487ed)) 260 | * make this a real thang ([b6c7c7e](https://github.com/eladb/jsii-srcmak/commit/b6c7c7efacd054dc64f72b342194436650e1bf2f)) 261 | * outputJsii ([1fd47b1](https://github.com/eladb/jsii-srcmak/commit/1fd47b13af3f18cab55ec0b26be408c1a78a16bc)) 262 | 263 | 264 | ### Bug Fixes 265 | 266 | * fails if java output directory does not exist ([6af49fe](https://github.com/eladb/jsii-srcmak/commit/6af49fefac3c4dadc0ca19ec3c56a44601548390)) 267 | * java output location moved to src/main ([#3](https://github.com/eladb/jsii-srcmak/issues/3)) ([96c76e4](https://github.com/eladb/jsii-srcmak/commit/96c76e4e23568b55d13721bb302b36b156bdf20f)), closes [/github.com/awslabs/cdk8s/pull/233#discussion_r439811482](https://github.com/eladb//github.com/awslabs/cdk8s/pull/233/issues/discussion_r439811482) 268 | * Package name collisions ([#22](https://github.com/eladb/jsii-srcmak/issues/22)) ([766de96](https://github.com/eladb/jsii-srcmak/commit/766de96d655463dadf5a9578ba38d47121be447b)) 269 | 270 | ### 0.1.161 (2020-12-22) 271 | 272 | 273 | ### Features 274 | 275 | * .NET Support ([#73](https://github.com/eladb/jsii-srcmak/issues/73)) ([a0dc5ea](https://github.com/eladb/jsii-srcmak/commit/a0dc5ea0d53daf62df62601372771a2be15d74ec)) 276 | * export "Options" ([18cb8f3](https://github.com/eladb/jsii-srcmak/commit/18cb8f354640fd39077ccf362a5112a3bcd1befa)) 277 | * initial version ([158e2dd](https://github.com/eladb/jsii-srcmak/commit/158e2dd356d54fd180fdb6ebe54a2dd06f9a2469)) 278 | * Java support ([#2](https://github.com/eladb/jsii-srcmak/issues/2)) ([9e84d6e](https://github.com/eladb/jsii-srcmak/commit/9e84d6ee37662ba699d4a72f1656ca03d5fd949f)) 279 | * make "compile" private ([38fd95f](https://github.com/eladb/jsii-srcmak/commit/38fd95f9e176121103f2986ccae6890e81e487ed)) 280 | * make this a real thang ([b6c7c7e](https://github.com/eladb/jsii-srcmak/commit/b6c7c7efacd054dc64f72b342194436650e1bf2f)) 281 | * outputJsii ([1fd47b1](https://github.com/eladb/jsii-srcmak/commit/1fd47b13af3f18cab55ec0b26be408c1a78a16bc)) 282 | 283 | 284 | ### Bug Fixes 285 | 286 | * fails if java output directory does not exist ([6af49fe](https://github.com/eladb/jsii-srcmak/commit/6af49fefac3c4dadc0ca19ec3c56a44601548390)) 287 | * java output location moved to src/main ([#3](https://github.com/eladb/jsii-srcmak/issues/3)) ([96c76e4](https://github.com/eladb/jsii-srcmak/commit/96c76e4e23568b55d13721bb302b36b156bdf20f)), closes [/github.com/awslabs/cdk8s/pull/233#discussion_r439811482](https://github.com/eladb//github.com/awslabs/cdk8s/pull/233/issues/discussion_r439811482) 288 | * Package name collisions ([#22](https://github.com/eladb/jsii-srcmak/issues/22)) ([766de96](https://github.com/eladb/jsii-srcmak/commit/766de96d655463dadf5a9578ba38d47121be447b)) 289 | 290 | ### 0.1.160 (2020-12-22) 291 | 292 | ### 0.1.159 (2020-12-22) 293 | 294 | ### 0.1.158 (2020-12-21) 295 | 296 | ### 0.1.157 (2020-12-20) 297 | 298 | ### 0.1.156 (2020-12-18) 299 | 300 | ### 0.1.155 (2020-12-18) 301 | 302 | ### 0.1.154 (2020-12-17) 303 | 304 | ### 0.1.153 (2020-12-16) 305 | 306 | ### 0.1.152 (2020-12-15) 307 | 308 | ### 0.1.151 (2020-12-15) 309 | 310 | ### 0.1.150 (2020-12-14) 311 | 312 | ### 0.1.149 (2020-12-12) 313 | 314 | ### 0.1.148 (2020-12-11) 315 | 316 | ### 0.1.147 (2020-12-11) 317 | 318 | ### 0.1.146 (2020-12-10) 319 | 320 | ### 0.1.145 (2020-12-09) 321 | 322 | ### 0.1.144 (2020-12-08) 323 | 324 | ### 0.1.143 (2020-12-08) 325 | 326 | ### 0.1.142 (2020-12-07) 327 | 328 | ### 0.1.141 (2020-12-07) 329 | 330 | ### 0.1.140 (2020-12-06) 331 | 332 | ### 0.1.139 (2020-12-04) 333 | 334 | ### 0.1.138 (2020-12-04) 335 | 336 | ### 0.1.137 (2020-12-03) 337 | 338 | ### 0.1.136 (2020-12-03) 339 | 340 | ### 0.1.135 (2020-12-02) 341 | 342 | ### 0.1.134 (2020-12-02) 343 | 344 | ### 0.1.133 (2020-12-02) 345 | 346 | ### 0.1.132 (2020-12-02) 347 | 348 | ### 0.1.131 (2020-12-02) 349 | 350 | ### 0.1.130 (2020-12-02) 351 | 352 | ### 0.1.129 (2020-12-02) 353 | 354 | ### 0.1.128 (2020-12-02) 355 | 356 | ### 0.1.127 (2020-12-02) 357 | 358 | ### 0.1.126 (2020-12-01) 359 | 360 | ### 0.1.125 (2020-12-01) 361 | 362 | ### 0.1.124 (2020-11-30) 363 | 364 | ### 0.1.123 (2020-11-30) 365 | 366 | ### 0.1.122 (2020-11-28) 367 | 368 | ### 0.1.121 (2020-11-27) 369 | 370 | ### 0.1.120 (2020-11-27) 371 | 372 | ### 0.1.119 (2020-11-26) 373 | 374 | ### 0.1.118 (2020-11-26) 375 | 376 | ### 0.1.117 (2020-11-25) 377 | 378 | ### 0.1.116 (2020-11-25) 379 | 380 | ### 0.1.115 (2020-11-24) 381 | 382 | ### 0.1.114 (2020-11-24) 383 | 384 | ### 0.1.113 (2020-11-23) 385 | 386 | ### 0.1.112 (2020-11-20) 387 | 388 | ### 0.1.111 (2020-11-19) 389 | 390 | ### 0.1.110 (2020-11-19) 391 | 392 | ### 0.1.109 (2020-11-18) 393 | 394 | ### 0.1.108 (2020-11-18) 395 | 396 | ### 0.1.107 (2020-11-17) 397 | 398 | ### 0.1.106 (2020-11-17) 399 | 400 | ### 0.1.105 (2020-11-16) 401 | 402 | ### 0.1.104 (2020-11-16) 403 | 404 | ### 0.1.103 (2020-11-13) 405 | 406 | ### 0.1.102 (2020-11-13) 407 | 408 | ### 0.1.101 (2020-11-12) 409 | 410 | ### 0.1.100 (2020-11-12) 411 | 412 | ### 0.1.99 (2020-11-11) 413 | 414 | ### 0.1.98 (2020-11-11) 415 | 416 | ### 0.1.97 (2020-11-10) 417 | 418 | ### 0.1.96 (2020-11-10) 419 | 420 | ### 0.1.95 (2020-11-09) 421 | 422 | ### 0.1.94 (2020-11-09) 423 | 424 | ### 0.1.93 (2020-11-08) 425 | 426 | ### 0.1.92 (2020-11-07) 427 | 428 | ### 0.1.91 (2020-11-06) 429 | 430 | ### 0.1.90 (2020-11-06) 431 | 432 | ### 0.1.89 (2020-11-05) 433 | 434 | ### 0.1.88 (2020-11-04) 435 | 436 | ### 0.1.87 (2020-11-04) 437 | 438 | ### 0.1.86 (2020-11-03) 439 | 440 | ### 0.1.85 (2020-11-03) 441 | 442 | ### 0.1.84 (2020-11-02) 443 | 444 | ### 0.1.83 (2020-11-02) 445 | 446 | ### 0.1.82 (2020-10-30) 447 | 448 | ### 0.1.81 (2020-10-30) 449 | 450 | ### 0.1.80 (2020-10-29) 451 | 452 | ### 0.1.79 (2020-10-29) 453 | 454 | ### 0.1.78 (2020-10-28) 455 | 456 | ### 0.1.77 (2020-10-28) 457 | 458 | ### 0.1.76 (2020-10-27) 459 | 460 | ### 0.1.75 (2020-10-27) 461 | 462 | ### 0.1.74 (2020-10-26) 463 | 464 | ### 0.1.73 (2020-10-26) 465 | 466 | ### 0.1.72 (2020-10-26) 467 | 468 | ### 0.1.71 (2020-10-24) 469 | 470 | ### 0.1.70 (2020-10-23) 471 | 472 | ### 0.1.69 (2020-10-23) 473 | 474 | ### 0.1.68 (2020-10-22) 475 | 476 | ### 0.1.67 (2020-10-22) 477 | 478 | ### 0.1.66 (2020-10-21) 479 | 480 | ### 0.1.65 (2020-10-21) 481 | 482 | ### 0.1.64 (2020-10-20) 483 | 484 | ### 0.1.63 (2020-10-20) 485 | 486 | ### 0.1.62 (2020-10-19) 487 | 488 | ### 0.1.61 (2020-10-18) 489 | 490 | ### 0.1.60 (2020-10-16) 491 | 492 | ### 0.1.59 (2020-10-16) 493 | 494 | ### 0.1.58 (2020-10-15) 495 | 496 | ### 0.1.57 (2020-10-15) 497 | 498 | ### 0.1.56 (2020-10-14) 499 | 500 | ### 0.1.55 (2020-10-14) 501 | 502 | ### 0.1.54 (2020-10-13) 503 | 504 | ### 0.1.53 (2020-10-13) 505 | 506 | ### 0.1.52 (2020-10-12) 507 | 508 | ### 0.1.51 (2020-10-12) 509 | 510 | ### 0.1.50 (2020-10-09) 511 | 512 | ### 0.1.49 (2020-10-09) 513 | 514 | ### 0.1.48 (2020-10-08) 515 | 516 | ### 0.1.47 (2020-10-08) 517 | 518 | ### 0.1.46 (2020-10-07) 519 | 520 | ### 0.1.45 (2020-10-06) 521 | 522 | ### 0.1.44 (2020-10-06) 523 | 524 | ### 0.1.43 (2020-10-05) 525 | 526 | ### 0.1.42 (2020-10-01) 527 | 528 | ### 0.1.41 (2020-09-30) 529 | 530 | ### 0.1.40 (2020-09-28) 531 | 532 | ### 0.1.39 (2020-09-22) 533 | 534 | ### 0.1.38 (2020-09-22) 535 | 536 | 537 | ### Features 538 | 539 | * .NET Support ([#73](https://github.com/eladb/jsii-srcmak/issues/73)) ([a0dc5ea](https://github.com/eladb/jsii-srcmak/commit/a0dc5ea0d53daf62df62601372771a2be15d74ec)) 540 | 541 | ### 0.1.37 (2020-09-21) 542 | 543 | ### 0.1.36 (2020-09-17) 544 | 545 | ### 0.1.35 (2020-09-16) 546 | 547 | ### 0.1.34 (2020-09-14) 548 | 549 | ### 0.1.33 (2020-09-14) 550 | 551 | ### 0.1.32 (2020-09-11) 552 | 553 | ### 0.1.31 (2020-09-09) 554 | 555 | ### 0.1.30 (2020-09-07) 556 | 557 | ### 0.1.29 (2020-09-03) 558 | 559 | ### 0.1.28 (2020-09-03) 560 | 561 | ### 0.1.27 (2020-09-02) 562 | 563 | ### 0.1.26 (2020-08-27) 564 | 565 | ### 0.1.25 (2020-08-26) 566 | 567 | ### 0.1.24 (2020-08-24) 568 | 569 | ### 0.1.23 (2020-08-21) 570 | 571 | ### 0.1.22 (2020-08-19) 572 | 573 | ### 0.1.21 (2020-08-19) 574 | 575 | ### 0.1.20 (2020-08-19) 576 | 577 | ### 0.1.19 (2020-08-17) 578 | 579 | ### 0.1.18 (2020-08-13) 580 | 581 | ### 0.1.17 (2020-08-12) 582 | 583 | ### 0.1.16 (2020-08-12) 584 | 585 | ### 0.1.15 (2020-08-12) 586 | 587 | ### 0.1.14 (2020-08-11) 588 | 589 | ### 0.1.13 (2020-08-06) 590 | 591 | ### 0.1.12 (2020-08-05) 592 | 593 | ### 0.1.11 (2020-08-04) 594 | 595 | ### 0.1.10 (2020-08-03) 596 | 597 | ### 0.1.9 (2020-07-29) 598 | 599 | ### 0.1.8 (2020-07-29) 600 | 601 | ### 0.1.7 (2020-07-29) 602 | 603 | ### 0.1.6 (2020-07-29) 604 | 605 | ### [0.1.5](https://github.com/eladb/jsii-srcmak/compare/v0.1.4...v0.1.5) (2020-07-15) 606 | 607 | ### [0.1.4](https://github.com/eladb/jsii-srcmak/compare/v0.1.3...v0.1.4) (2020-06-17) 608 | 609 | ### [0.1.3](https://github.com/eladb/jsii-srcmak/compare/v0.1.2...v0.1.3) (2020-06-16) 610 | 611 | 612 | ### Bug Fixes 613 | 614 | * fails if java output directory does not exist ([6af49fe](https://github.com/eladb/jsii-srcmak/commit/6af49fefac3c4dadc0ca19ec3c56a44601548390)) 615 | 616 | ### [0.1.2](https://github.com/eladb/jsii-srcmak/compare/v0.1.1...v0.1.2) (2020-06-16) 617 | 618 | ### [0.1.1](https://github.com/eladb/jsii-srcmak/compare/v0.0.5...v0.1.1) (2020-06-16) 619 | 620 | ### [0.0.5](https://github.com/eladb/jsii-srcmak/compare/v0.0.4...v0.0.5) (2020-06-16) 621 | 622 | 623 | ### Bug Fixes 624 | 625 | * java output location moved to src/main ([#3](https://github.com/eladb/jsii-srcmak/issues/3)) ([96c76e4](https://github.com/eladb/jsii-srcmak/commit/96c76e4e23568b55d13721bb302b36b156bdf20f)), closes [/github.com/awslabs/cdk8s/pull/233#discussion_r439811482](https://github.com/eladb//github.com/awslabs/cdk8s/pull/233/issues/discussion_r439811482) 626 | 627 | ### [0.0.4](https://github.com/eladb/jsii-srcmak/compare/v0.0.3...v0.0.4) (2020-06-02) 628 | 629 | 630 | ### Features 631 | 632 | * Java support ([#2](https://github.com/eladb/jsii-srcmak/issues/2)) ([9e84d6e](https://github.com/eladb/jsii-srcmak/commit/9e84d6ee37662ba699d4a72f1656ca03d5fd949f)) 633 | 634 | ### [0.0.3](https://github.com/eladb/jsii-srcmak/compare/v0.0.2...v0.0.3) (2020-05-26) 635 | 636 | 637 | ### Features 638 | 639 | * make this a real thang ([b6c7c7e](https://github.com/eladb/jsii-srcmak/commit/b6c7c7efacd054dc64f72b342194436650e1bf2f)) 640 | 641 | ### [0.0.2](https://github.com/eladb/jsii-srcmak/compare/v0.0.1...v0.0.2) (2020-05-25) 642 | 643 | 644 | ### Features 645 | 646 | * make "compile" private ([38fd95f](https://github.com/eladb/jsii-srcmak/commit/38fd95f9e176121103f2986ccae6890e81e487ed)) 647 | * outputJsii ([1fd47b1](https://github.com/eladb/jsii-srcmak/commit/1fd47b13af3f18cab55ec0b26be408c1a78a16bc)) 648 | 649 | ### 0.0.1 (2020-05-25) 650 | 651 | 652 | ### Features 653 | 654 | * export "Options" ([18cb8f3](https://github.com/eladb/jsii-srcmak/commit/18cb8f354640fd39077ccf362a5112a3bcd1befa)) 655 | * initial version ([158e2dd](https://github.com/eladb/jsii-srcmak/commit/158e2dd356d54fd180fdb6ebe54a2dd06f9a2469)) 656 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # jsii-srcmak 2 | 3 | > Generates [jsii] source files for multiple languages from TypeScript. 4 | 5 | [jsii]: https://github.com/aws/jsii 6 | 7 | ## Usage 8 | 9 | This package can be either used as a library or through a CLI. 10 | 11 | The library entry point is the `srcmak` function: 12 | 13 | ```ts 14 | import { srcmak } from 'jsii-srcmak'; 15 | await srcmak(srcdir[, options]); 16 | ``` 17 | 18 | The CLI is `jsii-srcmak`: 19 | 20 | ```bash 21 | $ jsii-srcmak srcdir [OPTIONS] 22 | ``` 23 | 24 | The `srcdir` argument points to a directory tree that includes TypeScript files 25 | which will be translated through jsii to one of the supported languages. 26 | 27 | ### Compile only 28 | 29 | If called with no additional arguments, `srcmak` will only jsii-compile the source. If compilation fails, it will throw an error. This is a nice way to check if generated typescript code is jsii-compatible: 30 | 31 | ```ts 32 | const srcdir = generateSomeTypeScriptCode(); 33 | 34 | // verify it is jsii-compatible (throws otherwise) 35 | await srcmak(srcdir); 36 | ``` 37 | 38 | CLI: 39 | 40 | ```bash 41 | $ jsii-srcmak /source/directory 42 | ``` 43 | 44 | ### Python Output 45 | 46 | To produce a Python module from your source, use the `python` option: 47 | 48 | ```ts 49 | await srcmak('srcdir', { 50 | python: { 51 | outdir: '/path/to/project/root', 52 | moduleName: 'name.of.python.module' 53 | } 54 | }); 55 | ``` 56 | 57 | Or the `--python-*` switches in the CLI: 58 | 59 | ```bash 60 | $ jsii-srcmak /src/dir --python-outdir=dir --python-module-name=module.name 61 | ``` 62 | 63 | * The `outdir`/`--python-outdir` option points to the root directory of your Python project. 64 | * The `moduleName`/`--python-module-name` option is the python module name. Dots (`.`) delimit submodules. 65 | 66 | The output directory will include a python module that corresponds to the 67 | original module. This code depends on the following python modules: 68 | 69 | - [jsii](https://pypi.org/project/jsii/) 70 | 71 | ### Java Output 72 | 73 | To produce a Java module from your source, use the `java` option: 74 | 75 | ```ts 76 | await srcmak('srcdir', { 77 | java: { 78 | outdir: '/path/to/project/root', 79 | package: 'hello.world' 80 | } 81 | }); 82 | ``` 83 | 84 | Or the `--java-*` switches in the CLI: 85 | 86 | ```bash 87 | $ jsii-srcmak /src/dir --java-outdir=dir --java-package=hello.world 88 | ``` 89 | 90 | * The `outdir`/`--java-outdir` option points to the root directory of your Java project. 91 | * The `package`/`--java-package` option is the java package name. 92 | 93 | The output directory will include a java module that corresponds to the 94 | original module. This code depends on the following maven package (should be defined directly or indirectly in the project's `pom.xml` file): 95 | 96 | - [jsii](https://mvnrepository.com/artifact/software.amazon.jsii) 97 | 98 | The output directory will also include a tarball `generated@0.0.0.jsii.tgz` that must be bundled in your project. 99 | 100 | ### C# Output 101 | 102 | To produce a C# module from your source, use the `csharp` option: 103 | 104 | ```ts 105 | await srcmak('srcdir', { 106 | csharp: { 107 | outdir: '/path/to/project/root', 108 | namespace: 'HelloWorld' 109 | } 110 | }); 111 | ``` 112 | 113 | Or the `--csharp-*` switches in the CLI: 114 | 115 | ```bash 116 | $ jsii-srcmak /src/dir --csharp-outdir=dir --csharp-namespace=HelloWorld 117 | ``` 118 | 119 | * The `outdir`/`--csharp-outdir` option points to the root directory of your C# project. 120 | * The `package`/`--csharp-namespace` option is the C# root namespace. 121 | 122 | The output directory will include a C# project that corresponds to the 123 | original module. This code depends on the following NuGet package (It is already defined as a dependency in the generated project): 124 | 125 | - [jsii](https://www.nuget.org/packages/Amazon.JSII.Runtime/) 126 | 127 | The output directory will also include a tarball `generated@0.0.0.jsii.tgz` that must be bundled in your project (It is already included as an embedded resource in the generated project). 128 | 129 | ### Go Output 130 | 131 | To produce a Go module from your source, use the `golang` option: 132 | 133 | ```ts 134 | await srcmak('srcdir', { 135 | golang: { 136 | outdir: '/path/to/project/root', 137 | moduleName: 'github.com/yourorg/your-root-project', 138 | packageName: 'helloworld' 139 | } 140 | }); 141 | ``` 142 | 143 | Or the `--golang-*` switches in the CLI: 144 | 145 | ```bash 146 | $ jsii-srcmak /src/dir --golang-outdir=dir --golang-module="github.com/yourorg/your-root-project" --golang-package="helloworld" 147 | ``` 148 | 149 | * The `outdir`/`--golang-outdir` option points to the root directory of your base Go project (where your `go.mod` is in, if you have one). 150 | * The `moduleName`/`--golang-module` option must match the Go module name of the project that includes the generated source code e.g. `github.com/yourorg/your-root-project`. This is currently required, because the generated code needs to reference a submodule which is generated in a nested directory (see also upstream issue https://github.com/aws/jsii/issues/2847 for more information). 151 | * The `packageName`/`--golang-package` is the package in which the generated Go code will be in. It will be placed in the submodule. So the import path becomes e.g. `github.com/yourorg/your-root-project/yourpackage`. 152 | 153 | The output directory will include a directory named with the `packageName`/`--golang-package` containing the generated Go code. 154 | This code depends on the following Go module: 155 | 156 | - [jsii-runtime-go](github.com/aws/jsii-runtime-go) 157 | 158 | which you need to include in your `go.mod`: 159 | ``` 160 | require github.com/aws/jsii-runtime-go v1.29.0 # update the version to match the jsii version used in your version of jsii-srcmak 161 | ``` 162 | 163 | 164 | #### Nested output directories 165 | It is also possible to set the `outdir`/`--golang-outdir` option to a nested directory inside your Go project. For example, if you want to nest the generated code in a directory called `generated`. 166 | In that case you need to append the subdirectory to the module name (e.g. `github.com/yourorg/your-root-project/generated`): 167 | 168 | ```bash 169 | $ jsii-srcmak /src/dir --golang-outdir=~/projects/your-root-project/generated --golang-module="github.com/yourorg/your-root-project/generated" --golang-package="helloworld" 170 | ``` 171 | Your import path will then become e.g. `github.com/yourorg/your-root-project/generated/yourpackage`. 172 | 173 | ### Entrypoint 174 | 175 | The `entrypoint` option can be used to customize the name of the typescript entrypoint (default is `index.ts`). 176 | 177 | For example, if the code's entry point is under `/srcdir/foobar/lib/index.ts` then I can specify: 178 | 179 | ```ts 180 | await srcmak('/srcdir', { 181 | entrypoint: 'foobar/lib/index.ts' 182 | }); 183 | ``` 184 | 185 | Or through the CLI: 186 | 187 | ```bash 188 | $ jsii-srcmak /srcdir --entrypoint lib/main.ts 189 | ``` 190 | 191 | ### Dependencies 192 | 193 | The `deps` option can be used to specify a list of node module **directories** (must have a `package.json` file) which will be symlinked into the workspace when compiling your code. 194 | 195 | This is required if your code references types from other modules. 196 | 197 | Use this idiom to resolve a set of modules directories from the calling process: 198 | 199 | ```ts 200 | const modules = [ 201 | '@types/node', // commonly needed 202 | 'foobar' // a node module in *my* closure 203 | ]; 204 | 205 | const getModuleDir = m => 206 | path.dirname(require.resolve(`${m}/package.json`)); 207 | 208 | await srcmak('srcdir', { 209 | deps: modules.map(getModuleDir) 210 | }); 211 | ``` 212 | 213 | Or through the CLI: 214 | 215 | ```bash 216 | $ jsii-srcmak /src/dir --dep node_modules/@types/node --dep node_modules/constructs 217 | ``` 218 | 219 | ## Contributing 220 | 221 | To build this project, you must first generate the `package.json`: 222 | 223 | ``` 224 | npx projen 225 | ``` 226 | 227 | Then you can install your dependencies and build: 228 | 229 | ``` 230 | yarn install 231 | yarn build 232 | ``` 233 | 234 | ## What's with this name? 235 | 236 | It's a silly little pun that stems from another pun: jsii has `jsii-pacmak` 237 | which stands for "package maker". That's the tool that takes in a .jsii manifest 238 | and produces language-idiomatic *packages* from it. This tool produces *sources* 239 | from a .jsii manifest. Hence, "source maker". Yeah, it's lame. 240 | 241 | ## License 242 | 243 | Distributed under the [Apache 2.0](./LICENSE) license. 244 | -------------------------------------------------------------------------------- /bin/jsii-srcmak: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // eslint-disable-next-line @typescript-eslint/no-require-imports 3 | require('../lib/cli.js'); -------------------------------------------------------------------------------- /example/lib/main.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Math operands 3 | */ 4 | export interface Operands { 5 | /** 6 | * Left-hand side operand 7 | */ 8 | readonly lhs: number; 9 | /** 10 | * Right-hand side operand 11 | */ 12 | readonly rhs: number; 13 | } 14 | /** 15 | * A sophisticaed multi-language calculator 16 | */ 17 | export declare class Calculator { 18 | /** 19 | * Adds the two operands 20 | * @param ops operands 21 | */ 22 | add(ops: Operands): number; 23 | /** 24 | * Subtracts the two operands 25 | * @param ops operands 26 | */ 27 | sub(ops: Operands): number; 28 | /** 29 | * Multiplies the two operands 30 | * @param ops operands 31 | */ 32 | mul(ops: Operands): number; 33 | } 34 | -------------------------------------------------------------------------------- /example/lib/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.Calculator = void 0; 4 | /** 5 | * A sophisticaed multi-language calculator 6 | */ 7 | class Calculator { 8 | /** 9 | * Adds the two operands 10 | * @param ops operands 11 | */ 12 | add(ops) { 13 | return ops.lhs + ops.rhs; 14 | } 15 | /** 16 | * Subtracts the two operands 17 | * @param ops operands 18 | */ 19 | sub(ops) { 20 | return ops.lhs - ops.rhs; 21 | } 22 | /** 23 | * Multiplies the two operands 24 | * @param ops operands 25 | */ 26 | mul(ops) { 27 | return ops.lhs * ops.rhs; 28 | } 29 | } 30 | exports.Calculator = Calculator; 31 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIm1haW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBZUE7O0dBRUc7QUFDSCxNQUFhLFVBQVU7SUFDckI7OztPQUdHO0lBQ0ksR0FBRyxDQUFDLEdBQWE7UUFDdEIsT0FBTyxHQUFHLENBQUMsR0FBRyxHQUFHLEdBQUcsQ0FBQyxHQUFHLENBQUM7SUFDM0IsQ0FBQztJQUVEOzs7T0FHRztJQUNJLEdBQUcsQ0FBQyxHQUFhO1FBQ3RCLE9BQU8sR0FBRyxDQUFDLEdBQUcsR0FBRyxHQUFHLENBQUMsR0FBRyxDQUFDO0lBQzNCLENBQUM7SUFFRDs7O09BR0c7SUFDSSxHQUFHLENBQUMsR0FBYTtRQUN0QixPQUFPLEdBQUcsQ0FBQyxHQUFHLEdBQUcsR0FBRyxDQUFDLEdBQUcsQ0FBQTtJQUMxQixDQUFDO0NBQ0Y7QUF4QkQsZ0NBd0JDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBNYXRoIG9wZXJhbmRzXG4gKi9cbmV4cG9ydCBpbnRlcmZhY2UgT3BlcmFuZHMge1xuICAvKipcbiAgICogTGVmdC1oYW5kIHNpZGUgb3BlcmFuZFxuICAgKi9cbiAgcmVhZG9ubHkgbGhzOiBudW1iZXI7XG5cbiAgLyoqXG4gICAqIFJpZ2h0LWhhbmQgc2lkZSBvcGVyYW5kXG4gICAqL1xuICByZWFkb25seSByaHM6IG51bWJlcjtcbn1cblxuLyoqXG4gKiBBIHNvcGhpc3RpY2FlZCBtdWx0aS1sYW5ndWFnZSBjYWxjdWxhdG9yXG4gKi9cbmV4cG9ydCBjbGFzcyBDYWxjdWxhdG9yIHtcbiAgLyoqXG4gICAqIEFkZHMgdGhlIHR3byBvcGVyYW5kc1xuICAgKiBAcGFyYW0gb3BzIG9wZXJhbmRzXG4gICAqL1xuICBwdWJsaWMgYWRkKG9wczogT3BlcmFuZHMpIHtcbiAgICByZXR1cm4gb3BzLmxocyArIG9wcy5yaHM7XG4gIH1cblxuICAvKipcbiAgICogU3VidHJhY3RzIHRoZSB0d28gb3BlcmFuZHNcbiAgICogQHBhcmFtIG9wcyBvcGVyYW5kc1xuICAgKi9cbiAgcHVibGljIHN1YihvcHM6IE9wZXJhbmRzKSB7XG4gICAgcmV0dXJuIG9wcy5saHMgLSBvcHMucmhzO1xuICB9XG4gIFxuICAvKipcbiAgICogTXVsdGlwbGllcyB0aGUgdHdvIG9wZXJhbmRzXG4gICAqIEBwYXJhbSBvcHMgb3BlcmFuZHNcbiAgICovXG4gIHB1YmxpYyBtdWwob3BzOiBPcGVyYW5kcykge1xuICAgIHJldHVybiBvcHMubGhzICogb3BzLnJoc1xuICB9XG59XG4iXX0= -------------------------------------------------------------------------------- /example/lib/main.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Math operands 3 | */ 4 | export interface Operands { 5 | /** 6 | * Left-hand side operand 7 | */ 8 | readonly lhs: number; 9 | 10 | /** 11 | * Right-hand side operand 12 | */ 13 | readonly rhs: number; 14 | } 15 | 16 | /** 17 | * A sophisticaed multi-language calculator 18 | */ 19 | export class Calculator { 20 | /** 21 | * Adds the two operands 22 | * @param ops operands 23 | */ 24 | public add(ops: Operands) { 25 | return ops.lhs + ops.rhs; 26 | } 27 | 28 | /** 29 | * Subtracts the two operands 30 | * @param ops operands 31 | */ 32 | public sub(ops: Operands) { 33 | return ops.lhs - ops.rhs; 34 | } 35 | 36 | /** 37 | * Multiplies the two operands 38 | * @param ops operands 39 | */ 40 | public mul(ops: Operands) { 41 | return ops.lhs * ops.rhs 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jsii-srcmak", 3 | "description": "generate source code in multiple languages from typescript", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/cdklabs/jsii-srcmak.git" 7 | }, 8 | "bin": { 9 | "jsii-srcmak": "bin/jsii-srcmak" 10 | }, 11 | "scripts": { 12 | "build": "npx projen build", 13 | "bump": "npx projen bump", 14 | "clobber": "npx projen clobber", 15 | "compile": "npx projen compile", 16 | "default": "npx projen default", 17 | "eject": "npx projen eject", 18 | "eslint": "npx projen eslint", 19 | "package": "npx projen package", 20 | "post-compile": "npx projen post-compile", 21 | "post-upgrade": "npx projen post-upgrade", 22 | "pre-compile": "npx projen pre-compile", 23 | "release": "npx projen release", 24 | "test": "npx projen test", 25 | "test:watch": "npx projen test:watch", 26 | "unbump": "npx projen unbump", 27 | "upgrade": "npx projen upgrade", 28 | "upgrade-cdklabs-projen-project-types": "npx projen upgrade-cdklabs-projen-project-types", 29 | "upgrade-dev-deps": "npx projen upgrade-dev-deps", 30 | "watch": "npx projen watch", 31 | "projen": "npx projen" 32 | }, 33 | "author": { 34 | "name": "Amazon Web Services", 35 | "email": "aws-cdk-dev@amazon.com", 36 | "organization": true 37 | }, 38 | "devDependencies": { 39 | "@types/fs-extra": "^8", 40 | "@types/jest": "^27.5.2", 41 | "@types/ncp": "^2.0.8", 42 | "@types/node": "^18", 43 | "@typescript-eslint/eslint-plugin": "^7", 44 | "@typescript-eslint/parser": "^7", 45 | "cdklabs-projen-project-types": "^0.1.204", 46 | "commit-and-tag-version": "^12", 47 | "constructs": "^10.0.0", 48 | "eslint": "^8", 49 | "eslint-import-resolver-typescript": "^2.7.1", 50 | "eslint-plugin-import": "^2.31.0", 51 | "jest": "^29", 52 | "jest-junit": "^15", 53 | "projen": "^0.87.4", 54 | "ts-jest": "^29", 55 | "ts-node": "^10.9.2", 56 | "typescript": "^5.8.3" 57 | }, 58 | "dependencies": { 59 | "fs-extra": "^9.1.0", 60 | "jsii": "~5.8.11", 61 | "jsii-pacmak": "^1.112.0", 62 | "jsii-rosetta": "^5.8.9", 63 | "ncp": "^2.0.0", 64 | "yargs": "^17.7.2" 65 | }, 66 | "resolutions": { 67 | "jackspeak": "2.0.3" 68 | }, 69 | "main": "lib/index.js", 70 | "license": "Apache-2.0", 71 | "publishConfig": { 72 | "access": "public" 73 | }, 74 | "version": "0.0.0", 75 | "jest": { 76 | "coverageProvider": "v8", 77 | "testMatch": [ 78 | "/@(src|test)/**/*(*.)@(spec|test).ts?(x)", 79 | "/@(src|test)/**/__tests__/**/*.ts?(x)", 80 | "/@(projenrc)/**/*(*.)@(spec|test).ts?(x)", 81 | "/@(projenrc)/**/__tests__/**/*.ts?(x)" 82 | ], 83 | "clearMocks": true, 84 | "collectCoverage": true, 85 | "coverageReporters": [ 86 | "json", 87 | "lcov", 88 | "clover", 89 | "cobertura", 90 | "text" 91 | ], 92 | "coverageDirectory": "coverage", 93 | "coveragePathIgnorePatterns": [ 94 | "/node_modules/" 95 | ], 96 | "testPathIgnorePatterns": [ 97 | "/node_modules/" 98 | ], 99 | "watchPathIgnorePatterns": [ 100 | "/node_modules/" 101 | ], 102 | "reporters": [ 103 | "default", 104 | [ 105 | "jest-junit", 106 | { 107 | "outputDirectory": "test-reports" 108 | } 109 | ] 110 | ], 111 | "transform": { 112 | "^.+\\.[t]sx?$": [ 113 | "ts-jest", 114 | { 115 | "tsconfig": "tsconfig.dev.json" 116 | } 117 | ] 118 | } 119 | }, 120 | "types": "lib/index.d.ts", 121 | "//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"npx projen\"." 122 | } 123 | -------------------------------------------------------------------------------- /src/cli.ts: -------------------------------------------------------------------------------- 1 | import * as yargs from 'yargs'; 2 | import { srcmak } from './srcmak'; 3 | 4 | async function main() { 5 | const args = yargs 6 | .usage('$0 SRCDIR [OPTIONS]') 7 | .option('entrypoint', { desc: 'typescript entrypoint (relative to SRCDIR)', default: 'index.ts' }) 8 | .option('dep', { desc: 'node module directories to include in compilation', type: 'array', string: true }) 9 | .option('jsii-path', { desc: 'write .jsii output to this path', type: 'string' }) 10 | .option('python-outdir', { desc: 'python output directory (requires --python-module-name)', type: 'string' }) 11 | .option('python-module-name', { desc: 'python module name', type: 'string' }) 12 | .option('java-outdir', { desc: 'java output directory (requires --java-package)', type: 'string' }) 13 | .option('java-package', { desc: 'the java package (namespace) to use for all generated types', type: 'string' }) 14 | .option('csharp-outdir', { desc: 'C# output directory (requires --csharp-namespace)', type: 'string' }) 15 | .option('csharp-namespace', { desc: 'the C# namespace to use for all generated types', type: 'string' }) 16 | .option('golang-outdir', { desc: 'golang output directory (requires --golang-module)', type: 'string' }) 17 | .option('golang-module', { desc: 'the golang module to use for all generated types', type: 'string' }) 18 | .option('golang-package', { desc: 'the golang package name to use for all generated types', type: 'string' }) 19 | .showHelpOnFail(true) 20 | .help(); 21 | 22 | const argv = args.parseSync(); 23 | 24 | if (argv._.length !== 1) { 25 | args.showHelp(); 26 | console.error(); 27 | console.error('Invalid number of arguments. expecting a single positional argument.'); 28 | process.exit(1); 29 | } 30 | 31 | const srcdir = argv._[0] as string; 32 | await srcmak(srcdir, { 33 | entrypoint: argv.entrypoint, 34 | ...parseDepOption(), 35 | ...parseJsiiOptions(), 36 | ...parsePythonOptions(), 37 | ...parseJavaOptions(), 38 | ...parseCSharpOptions(), 39 | ...parseGoLangOptions(), 40 | }); 41 | 42 | function parseJsiiOptions() { 43 | const jsiiPath = argv['jsii-path']; 44 | if (!jsiiPath) { return undefined; } 45 | return { 46 | jsii: { 47 | path: jsiiPath, 48 | }, 49 | }; 50 | } 51 | 52 | function parsePythonOptions() { 53 | const outdir = argv['python-outdir']; 54 | const moduleName = argv['python-module-name']; 55 | if (!outdir && !moduleName) { return undefined; } 56 | if (!outdir) { throw new Error('--python-outdir is required if --python-module-name is specified'); } 57 | if (!moduleName) { throw new Error('--python-module-name is required if --python-outdir is specified'); } 58 | return { 59 | python: { 60 | outdir: outdir, 61 | moduleName: moduleName, 62 | }, 63 | }; 64 | } 65 | 66 | function parseJavaOptions() { 67 | const outdir = argv['java-outdir']; 68 | const packageName = argv['java-package']; 69 | if (!outdir && !packageName) { return undefined; } 70 | if (!outdir) { throw new Error('--java-outdir is required'); } 71 | if (!packageName) { throw new Error('--java-package is required'); } 72 | return { 73 | java: { 74 | outdir: outdir, 75 | package: packageName, 76 | }, 77 | }; 78 | } 79 | 80 | function parseCSharpOptions() { 81 | const outdir = argv['csharp-outdir']; 82 | const namespace = argv['csharp-namespace']; 83 | if (!outdir && !namespace) { return undefined; } 84 | if (!outdir) { throw new Error('--csharp-outdir is required'); } 85 | if (!namespace) { throw new Error('--csharp-namespace is required'); } 86 | return { 87 | csharp: { 88 | outdir: outdir, 89 | namespace: namespace, 90 | }, 91 | }; 92 | } 93 | 94 | function parseGoLangOptions() { 95 | const outdir = argv['golang-outdir']; 96 | const module = argv['golang-module']; 97 | const packageName = argv['golang-package']; 98 | if (!outdir && !module) { return undefined; } 99 | if (!outdir) { throw new Error('--golang-outdir is required'); } 100 | if (!module) { throw new Error('--golang-module is required'); } 101 | if (!packageName) { throw new Error('--golang-package is required'); } 102 | return { 103 | golang: { 104 | outdir: outdir, 105 | moduleName: module, 106 | packageName: packageName, 107 | }, 108 | }; 109 | } 110 | 111 | function parseDepOption() { 112 | if (argv.dep?.length === 0) { return undefined; } 113 | return { 114 | deps: argv.dep, 115 | }; 116 | } 117 | } 118 | 119 | main().catch((e: Error) => { 120 | console.error(e.stack); 121 | process.exit(1); 122 | }); 123 | 124 | -------------------------------------------------------------------------------- /src/compile.ts: -------------------------------------------------------------------------------- 1 | import * as crypto from 'crypto'; 2 | import * as path from 'path'; 3 | import * as fs from 'fs-extra'; 4 | import { Options } from './options'; 5 | import { exec, validateOptions } from './util'; 6 | 7 | const compilerModule = require.resolve('jsii/bin/jsii'); 8 | 9 | /** 10 | * Compiles the source files in `workdir` with jsii. 11 | */ 12 | export async function compile(workdir: string, options: Options) { 13 | validateOptions(options); 14 | 15 | const args = ['--silence-warnings', 'reserved-word']; 16 | const entrypoint = options.entrypoint ?? 'index.ts'; 17 | 18 | if (path.extname(entrypoint) !== '.ts') { 19 | throw new Error(`jsii entrypoint must be a .ts file: ${entrypoint}`); 20 | } 21 | 22 | if (!(await fs.pathExists(path.join(workdir, entrypoint)))) { 23 | throw new Error(`unable to find typescript entrypoint: ${path.join(workdir, entrypoint)}`); 24 | } 25 | 26 | // path to entrypoint without extension 27 | const basepath = path.join(path.dirname(entrypoint), path.basename(entrypoint, '.ts')); 28 | 29 | const moduleKey = options.moduleKey?.replace(/\./g, '').replace(/\//g, '') ?? crypto.createHash('sha256').update(basepath, 'utf8').digest('hex'); 30 | 31 | // jsii modules to include 32 | const moduleDirs = options.deps ?? []; 33 | 34 | const targets: Record = { }; 35 | 36 | const deps: Record = { }; 37 | 38 | for (const dir of moduleDirs) { 39 | // read module metadata 40 | const metadata = await fs.readJson(path.join(dir, 'package.json')); 41 | const moduleName: string = metadata.name; 42 | const moduleVersion: string = metadata.version; 43 | 44 | const targetdir = path.join(path.join(workdir, 'node_modules'), moduleName); 45 | await fs.mkdirp(path.dirname(targetdir)); 46 | await fs.copy(dir, targetdir); 47 | 48 | // add to "deps" and "peer deps" 49 | if (!moduleName.startsWith('@types/')) { 50 | deps[moduleName] = moduleVersion; 51 | } 52 | } 53 | 54 | const pkg = { 55 | name: moduleKey, 56 | version: '0.0.0', 57 | author: 'generated@generated.com', 58 | main: `${basepath}.js`, 59 | types: `${basepath}.d.ts`, 60 | license: 'UNLICENSED', 61 | repository: { url: 'http://generated', type: 'git' }, 62 | jsii: { 63 | outdir: 'dist', 64 | targets: targets, 65 | }, 66 | dependencies: deps, 67 | peerDependencies: deps, 68 | }; 69 | 70 | if (options.exports) { 71 | (pkg as Record).exports = options.exports; 72 | } 73 | 74 | if (options.python) { 75 | targets.python = { 76 | distName: 'generated', 77 | module: options.python.moduleName, 78 | }; 79 | } 80 | 81 | if (options.java) { 82 | targets.java = { 83 | package: options.java.package, 84 | maven: { 85 | groupId: 'generated', 86 | artifactId: 'generated', 87 | }, 88 | }; 89 | } 90 | 91 | if (options.csharp) { 92 | targets.dotnet = { 93 | namespace: options.csharp.namespace, 94 | packageId: options.csharp.namespace, 95 | }; 96 | } 97 | 98 | if (options.golang) { 99 | targets.go = { 100 | moduleName: options.golang.moduleName, 101 | packageName: options.golang.packageName, 102 | }; 103 | } 104 | 105 | await fs.writeFile(path.join(workdir, 'package.json'), JSON.stringify(pkg, undefined, 2)); 106 | 107 | await exec(compilerModule, args, { 108 | cwd: workdir, 109 | }); 110 | } 111 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './srcmak'; 2 | export * from './options'; -------------------------------------------------------------------------------- /src/options.ts: -------------------------------------------------------------------------------- 1 | export interface Options { 2 | /** 3 | * The relative path of the .ts entrypoint within the source directory. 4 | * @default "index.ts" 5 | */ 6 | entrypoint?: string; 7 | 8 | /** 9 | * List of directories that include node modules to symlink into the compiled 10 | * package. For example, if your generated code references some library, you 11 | * should include it's module directory in here. 12 | */ 13 | deps?: string[]; 14 | 15 | /** 16 | * Save .jsii file to an output location. 17 | * @default - jsii manifest is omitted. 18 | */ 19 | jsii?: JsiiOutputOptions; 20 | 21 | /** 22 | * Key for the module to prevent JSII collisions. 23 | * 24 | * Use your own if it's project-unique, otherwise use default. 25 | * 26 | * @default - hash of the basepath to the module 27 | */ 28 | moduleKey?: string; 29 | 30 | /** 31 | * Specify export overrides in the package.json file. 32 | * The key is the name of the export, the value is the file to be imported. 33 | * 34 | * See https://nodejs.org/api/packages.html#exports for more information 35 | */ 36 | exports?: Record; 37 | 38 | /** 39 | * Produce python code. 40 | * @default - python is not generated 41 | */ 42 | python?: PythonOutputOptions; 43 | 44 | /** 45 | * Produces java code under src/main/ 46 | * 47 | * @default - java is not generated 48 | */ 49 | java?: JavaOutputOptions; 50 | 51 | /** 52 | * Produces C# code. 53 | * 54 | * @default - C# is not generated 55 | */ 56 | csharp?: CSharpOutputOptions; 57 | 58 | /** 59 | * Produces Golang code. 60 | * 61 | * @default - go is not generated 62 | */ 63 | golang?: GoLangOutputOptions; 64 | } 65 | 66 | export interface JsiiOutputOptions { 67 | /** 68 | * Path to save the .jsii output to. 69 | */ 70 | path: string; 71 | } 72 | 73 | export interface PythonOutputOptions { 74 | /** 75 | * Base root directory. 76 | */ 77 | outdir: string; 78 | 79 | /** 80 | * The name of the the python module to generate. 81 | * 82 | * This must follow the standard Python module name conventions. 83 | * For example, it cannot include a hyphen ('-') 84 | */ 85 | moduleName: string; 86 | } 87 | 88 | export interface JavaOutputOptions { 89 | /** 90 | * Base root directory. 91 | */ 92 | outdir: string; 93 | 94 | /** 95 | * The name of the java package to generate 96 | * 97 | * This must follow standard Java package conventions. 98 | * For example, it cannot include a hyphen ('-') 99 | */ 100 | package: string; 101 | } 102 | 103 | export interface CSharpOutputOptions { 104 | /** 105 | * Base root directory. 106 | */ 107 | outdir: string; 108 | 109 | /** 110 | * The root namespace to generate types in 111 | * 112 | * This must follow standard C# namespace conventions. 113 | * For example, it cannot include a hyphen ('-') 114 | */ 115 | namespace: string; 116 | } 117 | 118 | export interface GoLangOutputOptions { 119 | /** 120 | * The output directory for the generated Go code. 121 | * Usually the root directory of your Go project, but may also be a subdirectory. 122 | * 123 | * The generated Go code will be placed inside a nested directory with the name 124 | * given via `packageName` inside of this directory. 125 | */ 126 | outdir: string; 127 | 128 | /** 129 | * The go module name 130 | * 131 | * This must match the name of the parent go module the source code is generated in (e.g. github.com/yourorg/yourproject). 132 | * See https://github.com/aws/jsii/issues/2847#issue-896419111 for the background on why this is required. 133 | * 134 | * This must follow standard Go module name conventions. 135 | * For example, it cannot include an underscore ('_') or be camelCased 136 | */ 137 | moduleName: string; 138 | 139 | /** 140 | * The name of the Go package. 141 | * 142 | * E.g. "tools" would result in something like github.com/yourorg/yourproject/tools 143 | * depeding on the supplied moduleName 144 | */ 145 | packageName: string; 146 | } 147 | 148 | /** 149 | * See https://nodejs.org/api/packages.html#conditional-exports for more information 150 | */ 151 | export interface ExportDefinition { 152 | node?: string; 153 | import?: string; 154 | require?: string; 155 | default?: string; 156 | } 157 | -------------------------------------------------------------------------------- /src/srcmak.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | import { promisify } from 'util'; 3 | import * as fs from 'fs-extra'; 4 | import { ncp as _ncp } from 'ncp'; 5 | import { compile } from './compile'; 6 | import { Options } from './options'; 7 | import { exec, mkdtemp } from './util'; 8 | 9 | const ncp = promisify(_ncp); 10 | 11 | const pacmakModule = require.resolve('jsii-pacmak/bin/jsii-pacmak'); 12 | 13 | export async function srcmak(srcdir: string, options: Options = { }) { 14 | if (!(await fs.pathExists(srcdir))) { 15 | throw new Error(`unable to find source directory ${srcdir}`); 16 | } 17 | 18 | await mkdtemp(async workdir => { 19 | // copy sources to temp directory 20 | await fs.copy(srcdir, workdir); 21 | 22 | // perform jsii compilation 23 | await compile(workdir, options); 24 | 25 | // extract .jsii if requested 26 | if (options.jsii) { 27 | await fs.copy(path.join(workdir, '.jsii'), options.jsii.path); 28 | } 29 | 30 | // run pacmak to generate code 31 | await exec(pacmakModule, ['--code-only'], { cwd: workdir }); 32 | 33 | // extract code based on selected languages 34 | if (options.python) { 35 | const reldir = options.python.moduleName.replace(/\./g, '/'); // jsii replaces "." with "/" 36 | const source = path.resolve(path.join(workdir, 'dist/python/src', reldir)); 37 | const target = path.join(options.python.outdir, reldir); 38 | await fs.move(source, target, { overwrite: true }); 39 | } 40 | 41 | if (options.java) { 42 | const source = path.resolve(path.join(workdir, 'dist/java/src/')); 43 | const target = path.join(options.java.outdir, 'src/'); 44 | await fs.mkdirp(target); // make sure target directory exists 45 | await ncp(source, target, { clobber: false }); 46 | } 47 | 48 | if (options.csharp) { 49 | const reldir = options.csharp.namespace; 50 | const source = path.resolve(path.join(workdir, 'dist/dotnet/', reldir)); 51 | const target = path.join(options.csharp.outdir, reldir); 52 | await fs.move(source, target, { overwrite: true }); 53 | } 54 | 55 | if (options.golang) { 56 | const reldir = options.golang.packageName; 57 | const source = path.resolve(path.join(workdir, 'dist/go/', reldir)); 58 | const target = path.join(options.golang.outdir, reldir); 59 | await fs.move(source, target, { overwrite: true }); 60 | // remove go.mod as this would make it a submodule 61 | await fs.remove(path.join(target, 'go.mod')); 62 | } 63 | }); 64 | } 65 | -------------------------------------------------------------------------------- /src/util.ts: -------------------------------------------------------------------------------- 1 | import { spawn, SpawnOptions } from 'child_process'; 2 | import * as os from 'os'; 3 | import * as path from 'path'; 4 | import * as fs from 'fs-extra'; 5 | import { Options } from './options'; 6 | 7 | export async function mkdtemp(closure: (dir: string) => Promise) { 8 | const workdir = await fs.mkdtemp(path.join(os.tmpdir(), 'temp-')); 9 | try { 10 | await closure(workdir); 11 | 12 | if (!process.env.RETAIN_TMP) { 13 | await fs.remove(workdir); 14 | } else { 15 | console.error(`NOTE: Temp directory retained (RETAIN_TMP=1): ${workdir}`); 16 | } 17 | } catch (e) { 18 | console.error(`NOTE: Temp directory retained due to an error: ${workdir}`); 19 | throw e; 20 | } 21 | } 22 | 23 | export async function exec(moduleName: string, args: string[] = [], options: SpawnOptions = { }) { 24 | return new Promise((ok, fail) => { 25 | 26 | const opts: SpawnOptions = { 27 | ...options, 28 | stdio: ['inherit', 'pipe', 'pipe'], 29 | shell: true, 30 | }; 31 | const child = spawn(`"${process.execPath}"`, [moduleName, ...args], opts); 32 | 33 | const data = new Array(); 34 | child.stdout?.on('data', chunk => data.push(chunk)); 35 | child.stderr?.on('data', chunk => data.push(chunk)); 36 | 37 | const newError = (message: string) => new Error([ 38 | message, 39 | ' | ' + Buffer.concat(data).toString('utf-8').split('\n').filter(x => x).join('\n | '), 40 | ' +----------------------------------------------------------------------------------', 41 | ` | Command: ${moduleName} ${args.join(' ')}`, 42 | ` | Workdir: ${path.resolve(options.cwd?.toString() ?? '.')}`, 43 | ' +----------------------------------------------------------------------------------', 44 | ].join('\n')); 45 | 46 | child.once('error', err => { 47 | throw newError(`jsii compilation failed. error: ${err.message}`); 48 | }); 49 | 50 | child.once('exit', code => { 51 | if (code === 0) { 52 | return ok(); 53 | } else { 54 | return fail(newError(`jsii compilation failed with non-zero exit code: ${code}`)); 55 | } 56 | }); 57 | }); 58 | } 59 | 60 | /** 61 | * This validates that the Python module name, Java package name, and C# namespace 62 | * conform to language-specific constraints. 63 | * 64 | * @param options Options set by the consumer 65 | * @throws error if options do not conform 66 | */ 67 | export function validateOptions(options: Options) { 68 | if (options.python?.moduleName.includes('-')) { 69 | throw new Error(`Python moduleName [${options.python.moduleName}] may not contain "-"`); 70 | } 71 | 72 | if (options.java?.package.includes('-')) { 73 | throw new Error(`Java package [${options.java.package}] may not contain "-"`); 74 | } 75 | 76 | if (options.csharp?.namespace.includes('-')) { 77 | throw new Error(`C# namespace [${options.csharp.namespace}] may not contain "-"`); 78 | } 79 | 80 | if (options.golang?.moduleName.includes('_')) { 81 | throw new Error(`Go module name [${options.golang.moduleName}] may not contain "_"`); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /test/__snapshots__/cli.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`csharp output 1`] = ` 4 | { 5 | "MyPackage/AssemblyInfo.cs": "using Amazon.JSII.Runtime.Deputy; 6 | 7 | [assembly: JsiiAssembly("4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060", "0.0.0", "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060-0.0.0.tgz")] 8 | ", 9 | "MyPackage/MyPackage.csproj": " 10 | 11 | 12 | 4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060 13 | MyPackage 14 | UNLICENSED 15 | 0.0.0 16 | 17 | generated@generated.com 18 | en-US 19 | http://generated 20 | http://generated 21 | git 22 | 23 | true 24 | true 25 | true 26 | true 27 | enable 28 | snupkg 29 | netcoreapp3.1 30 | Major 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 0612,0618 41 | 42 | 0108,0109 43 | 44 | 45 | 46 | ", 47 | "MyPackage/MyPackage/Calculator.cs": "using Amazon.JSII.Runtime.Deputy; 48 | 49 | #pragma warning disable CS0672,CS0809,CS1591 50 | 51 | namespace MyPackage 52 | { 53 | /// A sophisticaed multi-language calculator. 54 | [JsiiClass(nativeType: typeof(MyPackage.Calculator), fullyQualifiedName: "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Calculator")] 55 | public class Calculator : DeputyBase 56 | { 57 | public Calculator(): base(_MakeDeputyProps()) 58 | { 59 | } 60 | 61 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] 62 | private static DeputyProps _MakeDeputyProps() 63 | { 64 | return new DeputyProps(System.Array.Empty()); 65 | } 66 | 67 | /// Used by jsii to construct an instance of this class from a Javascript-owned object reference 68 | /// The Javascript-owned object reference 69 | [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] 70 | protected Calculator(ByRefValue reference): base(reference) 71 | { 72 | } 73 | 74 | /// Used by jsii to construct an instance of this class from DeputyProps 75 | /// The deputy props 76 | [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] 77 | protected Calculator(DeputyProps props): base(props) 78 | { 79 | } 80 | 81 | /// Adds the two operands. 82 | /// operands. 83 | [JsiiMethod(name: "add", returnsJson: "{\\"type\\":{\\"primitive\\":\\"number\\"}}", parametersJson: "[{\\"docs\\":{\\"summary\\":\\"operands.\\"},\\"name\\":\\"ops\\",\\"type\\":{\\"fqn\\":\\"4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands\\"}}]")] 84 | public virtual double Add(MyPackage.IOperands ops) 85 | { 86 | return InvokeInstanceMethod(new System.Type[]{typeof(MyPackage.IOperands)}, new object[]{ops})!; 87 | } 88 | 89 | /// Multiplies the two operands. 90 | /// operands. 91 | [JsiiMethod(name: "mul", returnsJson: "{\\"type\\":{\\"primitive\\":\\"number\\"}}", parametersJson: "[{\\"docs\\":{\\"summary\\":\\"operands.\\"},\\"name\\":\\"ops\\",\\"type\\":{\\"fqn\\":\\"4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands\\"}}]")] 92 | public virtual double Mul(MyPackage.IOperands ops) 93 | { 94 | return InvokeInstanceMethod(new System.Type[]{typeof(MyPackage.IOperands)}, new object[]{ops})!; 95 | } 96 | 97 | /// Subtracts the two operands. 98 | /// operands. 99 | [JsiiMethod(name: "sub", returnsJson: "{\\"type\\":{\\"primitive\\":\\"number\\"}}", parametersJson: "[{\\"docs\\":{\\"summary\\":\\"operands.\\"},\\"name\\":\\"ops\\",\\"type\\":{\\"fqn\\":\\"4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands\\"}}]")] 100 | public virtual double Sub(MyPackage.IOperands ops) 101 | { 102 | return InvokeInstanceMethod(new System.Type[]{typeof(MyPackage.IOperands)}, new object[]{ops})!; 103 | } 104 | } 105 | } 106 | ", 107 | "MyPackage/MyPackage/IOperands.cs": "using Amazon.JSII.Runtime.Deputy; 108 | 109 | #pragma warning disable CS0672,CS0809,CS1591 110 | 111 | namespace MyPackage 112 | { 113 | /// Math operands. 114 | [JsiiInterface(nativeType: typeof(IOperands), fullyQualifiedName: "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands")] 115 | public interface IOperands 116 | { 117 | /// Left-hand side operand. 118 | [JsiiProperty(name: "lhs", typeJson: "{\\"primitive\\":\\"number\\"}")] 119 | double Lhs 120 | { 121 | get; 122 | } 123 | 124 | /// Right-hand side operand. 125 | [JsiiProperty(name: "rhs", typeJson: "{\\"primitive\\":\\"number\\"}")] 126 | double Rhs 127 | { 128 | get; 129 | } 130 | 131 | /// Math operands. 132 | [JsiiTypeProxy(nativeType: typeof(IOperands), fullyQualifiedName: "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands")] 133 | internal sealed class _Proxy : DeputyBase, MyPackage.IOperands 134 | { 135 | private _Proxy(ByRefValue reference): base(reference) 136 | { 137 | } 138 | 139 | /// Left-hand side operand. 140 | [JsiiProperty(name: "lhs", typeJson: "{\\"primitive\\":\\"number\\"}")] 141 | public double Lhs 142 | { 143 | get => GetInstanceProperty()!; 144 | } 145 | 146 | /// Right-hand side operand. 147 | [JsiiProperty(name: "rhs", typeJson: "{\\"primitive\\":\\"number\\"}")] 148 | public double Rhs 149 | { 150 | get => GetInstanceProperty()!; 151 | } 152 | } 153 | } 154 | } 155 | ", 156 | "MyPackage/MyPackage/Internal/DependencyResolution/Anchor.cs": "#pragma warning disable CS0672,CS0809,CS1591 157 | 158 | namespace MyPackage.Internal.DependencyResolution 159 | { 160 | public sealed class Anchor 161 | { 162 | public Anchor() 163 | { 164 | } 165 | } 166 | } 167 | ", 168 | "MyPackage/MyPackage/Operands.cs": "using Amazon.JSII.Runtime.Deputy; 169 | 170 | #pragma warning disable CS0672,CS0809,CS1591 171 | 172 | namespace MyPackage 173 | { 174 | #pragma warning disable CS8618 175 | 176 | /// Math operands. 177 | [JsiiByValue(fqn: "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands")] 178 | public class Operands : MyPackage.IOperands 179 | { 180 | /// Left-hand side operand. 181 | [JsiiProperty(name: "lhs", typeJson: "{\\"primitive\\":\\"number\\"}")] 182 | public double Lhs 183 | { 184 | get; 185 | set; 186 | } 187 | 188 | /// Right-hand side operand. 189 | [JsiiProperty(name: "rhs", typeJson: "{\\"primitive\\":\\"number\\"}")] 190 | public double Rhs 191 | { 192 | get; 193 | set; 194 | } 195 | } 196 | } 197 | ", 198 | } 199 | `; 200 | 201 | exports[`golang output 1`] = ` 202 | { 203 | "package/Calculator.go": "package package 204 | 205 | import ( 206 | _jsii_ "github.com/aws/jsii-runtime-go/runtime" 207 | _init_ "github.com/hello/world/package/jsii" 208 | ) 209 | 210 | // A sophisticaed multi-language calculator. 211 | type Calculator interface { 212 | // Adds the two operands. 213 | Add(ops *Operands) *float64 214 | // Multiplies the two operands. 215 | Mul(ops *Operands) *float64 216 | // Subtracts the two operands. 217 | Sub(ops *Operands) *float64 218 | } 219 | 220 | // The jsii proxy struct for Calculator 221 | type jsiiProxy_Calculator struct { 222 | _ byte // padding 223 | } 224 | 225 | func NewCalculator() Calculator { 226 | _init_.Initialize() 227 | 228 | j := jsiiProxy_Calculator{} 229 | 230 | _jsii_.Create( 231 | "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Calculator", 232 | nil, // no parameters 233 | &j, 234 | ) 235 | 236 | return &j 237 | } 238 | 239 | func NewCalculator_Override(c Calculator) { 240 | _init_.Initialize() 241 | 242 | _jsii_.Create( 243 | "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Calculator", 244 | nil, // no parameters 245 | c, 246 | ) 247 | } 248 | 249 | func (c *jsiiProxy_Calculator) Add(ops *Operands) *float64 { 250 | if err := c.validateAddParameters(ops); err != nil { 251 | panic(err) 252 | } 253 | var returns *float64 254 | 255 | _jsii_.Invoke( 256 | c, 257 | "add", 258 | []interface{}{ops}, 259 | &returns, 260 | ) 261 | 262 | return returns 263 | } 264 | 265 | func (c *jsiiProxy_Calculator) Mul(ops *Operands) *float64 { 266 | if err := c.validateMulParameters(ops); err != nil { 267 | panic(err) 268 | } 269 | var returns *float64 270 | 271 | _jsii_.Invoke( 272 | c, 273 | "mul", 274 | []interface{}{ops}, 275 | &returns, 276 | ) 277 | 278 | return returns 279 | } 280 | 281 | func (c *jsiiProxy_Calculator) Sub(ops *Operands) *float64 { 282 | if err := c.validateSubParameters(ops); err != nil { 283 | panic(err) 284 | } 285 | var returns *float64 286 | 287 | _jsii_.Invoke( 288 | c, 289 | "sub", 290 | []interface{}{ops}, 291 | &returns, 292 | ) 293 | 294 | return returns 295 | } 296 | 297 | ", 298 | "package/Calculator__checks.go": "//go:build !no_runtime_type_checking 299 | 300 | package package 301 | 302 | import ( 303 | "fmt" 304 | 305 | _jsii_ "github.com/aws/jsii-runtime-go/runtime" 306 | ) 307 | 308 | func (c *jsiiProxy_Calculator) validateAddParameters(ops *Operands) error { 309 | if ops == nil { 310 | return fmt.Errorf("parameter ops is required, but nil was provided") 311 | } 312 | if err := _jsii_.ValidateStruct(ops, func() string { return "parameter ops" }); err != nil { 313 | return err 314 | } 315 | 316 | return nil 317 | } 318 | 319 | func (c *jsiiProxy_Calculator) validateMulParameters(ops *Operands) error { 320 | if ops == nil { 321 | return fmt.Errorf("parameter ops is required, but nil was provided") 322 | } 323 | if err := _jsii_.ValidateStruct(ops, func() string { return "parameter ops" }); err != nil { 324 | return err 325 | } 326 | 327 | return nil 328 | } 329 | 330 | func (c *jsiiProxy_Calculator) validateSubParameters(ops *Operands) error { 331 | if ops == nil { 332 | return fmt.Errorf("parameter ops is required, but nil was provided") 333 | } 334 | if err := _jsii_.ValidateStruct(ops, func() string { return "parameter ops" }); err != nil { 335 | return err 336 | } 337 | 338 | return nil 339 | } 340 | 341 | ", 342 | "package/Calculator__no_checks.go": "//go:build no_runtime_type_checking 343 | 344 | package package 345 | 346 | // Building without runtime type checking enabled, so all the below just return nil 347 | 348 | func (c *jsiiProxy_Calculator) validateAddParameters(ops *Operands) error { 349 | return nil 350 | } 351 | 352 | func (c *jsiiProxy_Calculator) validateMulParameters(ops *Operands) error { 353 | return nil 354 | } 355 | 356 | func (c *jsiiProxy_Calculator) validateSubParameters(ops *Operands) error { 357 | return nil 358 | } 359 | 360 | ", 361 | "package/Operands.go": "package package 362 | 363 | 364 | // Math operands. 365 | type Operands struct { 366 | // Left-hand side operand. 367 | Lhs *float64 \`field:"required" json:"lhs" yaml:"lhs"\` 368 | // Right-hand side operand. 369 | Rhs *float64 \`field:"required" json:"rhs" yaml:"rhs"\` 370 | } 371 | 372 | ", 373 | "package/jsii/jsii.go": "// Package jsii contains the functionaility needed for jsii packages to 374 | // initialize their dependencies and themselves. Users should never need to use this package 375 | // directly. If you find you need to - please report a bug at 376 | // https://github.com/aws/jsii/issues/new/choose 377 | package jsii 378 | 379 | import ( 380 | _ "embed" 381 | 382 | _jsii_ "github.com/aws/jsii-runtime-go/runtime" 383 | ) 384 | 385 | //go:embed 4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060-0.0.0.tgz 386 | var tarball []byte 387 | 388 | // Initialize loads the necessary packages in the @jsii/kernel to support the enclosing module. 389 | // The implementation is idempotent (and hence safe to be called over and over). 390 | func Initialize() { 391 | // Load this library into the kernel 392 | _jsii_.Load("4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060", "0.0.0", tarball) 393 | } 394 | ", 395 | "package/main.go": "// 4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060 396 | package package 397 | 398 | import ( 399 | "reflect" 400 | 401 | _jsii_ "github.com/aws/jsii-runtime-go/runtime" 402 | ) 403 | 404 | func init() { 405 | _jsii_.RegisterClass( 406 | "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Calculator", 407 | reflect.TypeOf((*Calculator)(nil)).Elem(), 408 | []_jsii_.Member{ 409 | _jsii_.MemberMethod{JsiiMethod: "add", GoMethod: "Add"}, 410 | _jsii_.MemberMethod{JsiiMethod: "mul", GoMethod: "Mul"}, 411 | _jsii_.MemberMethod{JsiiMethod: "sub", GoMethod: "Sub"}, 412 | }, 413 | func() interface{} { 414 | return &jsiiProxy_Calculator{} 415 | }, 416 | ) 417 | _jsii_.RegisterStruct( 418 | "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands", 419 | reflect.TypeOf((*Operands)(nil)).Elem(), 420 | ) 421 | } 422 | ", 423 | "package/version": "0.0.0 424 | ", 425 | } 426 | `; 427 | 428 | exports[`java output 1`] = ` 429 | { 430 | "src/main/java/mypackage/$Module.java": "package mypackage; 431 | 432 | import java.io.BufferedReader; 433 | import java.io.InputStream; 434 | import java.io.InputStreamReader; 435 | import java.io.IOException; 436 | import java.io.Reader; 437 | import java.io.UncheckedIOException; 438 | 439 | import java.nio.charset.StandardCharsets; 440 | 441 | import java.util.HashMap; 442 | import java.util.Map; 443 | 444 | import software.amazon.jsii.JsiiModule; 445 | 446 | @software.amazon.jsii.Internal 447 | public final class $Module extends JsiiModule { 448 | private static final Map MODULE_TYPES = load(); 449 | 450 | private static Map load() { 451 | final Map result = new HashMap<>(); 452 | final ClassLoader cl = $Module.class.getClassLoader(); 453 | try (final InputStream is = cl.getResourceAsStream("mypackage/$Module.txt"); 454 | final Reader rd = new InputStreamReader(is, StandardCharsets.UTF_8); 455 | final BufferedReader br = new BufferedReader(rd)) { 456 | br.lines() 457 | .filter(line -> !line.trim().isEmpty()) 458 | .forEach(line -> { 459 | final String[] parts = line.split("=", 2); 460 | final String fqn = parts[0]; 461 | final String className = parts[1]; 462 | result.put(fqn, className); 463 | }); 464 | } 465 | catch (final IOException exception) { 466 | throw new UncheckedIOException(exception); 467 | } 468 | return result; 469 | } 470 | 471 | private final Map> cache = new HashMap<>(); 472 | 473 | public $Module() { 474 | super("4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060", "0.0.0", $Module.class, "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060@0.0.0.jsii.tgz"); 475 | } 476 | 477 | @Override 478 | protected Class resolveClass(final String fqn) throws ClassNotFoundException { 479 | if (!MODULE_TYPES.containsKey(fqn)) { 480 | throw new ClassNotFoundException("Unknown JSII type: " + fqn); 481 | } 482 | String className = MODULE_TYPES.get(fqn); 483 | if (!this.cache.containsKey(className)) { 484 | this.cache.put(className, this.findClass(className)); 485 | } 486 | return this.cache.get(className); 487 | } 488 | 489 | private Class findClass(final String binaryName) { 490 | try { 491 | return Class.forName(binaryName); 492 | } 493 | catch (final ClassNotFoundException exception) { 494 | throw new RuntimeException(exception); 495 | } 496 | } 497 | } 498 | ", 499 | "src/main/java/mypackage/Calculator.java": "package mypackage; 500 | 501 | /** 502 | * A sophisticaed multi-language calculator. 503 | */ 504 | 505 | @software.amazon.jsii.Jsii(module = mypackage.$Module.class, fqn = "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Calculator") 506 | public class Calculator extends software.amazon.jsii.JsiiObject { 507 | 508 | protected Calculator(final software.amazon.jsii.JsiiObjectRef objRef) { 509 | super(objRef); 510 | } 511 | 512 | protected Calculator(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { 513 | super(initializationMode); 514 | } 515 | 516 | public Calculator() { 517 | super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); 518 | software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); 519 | } 520 | 521 | /** 522 | * Adds the two operands. 523 | *

524 | * @param ops operands. This parameter is required. 525 | */ 526 | public @org.jetbrains.annotations.NotNull java.lang.Number add(final @org.jetbrains.annotations.NotNull mypackage.Operands ops) { 527 | return software.amazon.jsii.Kernel.call(this, "add", software.amazon.jsii.NativeType.forClass(java.lang.Number.class), new Object[] { java.util.Objects.requireNonNull(ops, "ops is required") }); 528 | } 529 | 530 | /** 531 | * Multiplies the two operands. 532 | *

533 | * @param ops operands. This parameter is required. 534 | */ 535 | public @org.jetbrains.annotations.NotNull java.lang.Number mul(final @org.jetbrains.annotations.NotNull mypackage.Operands ops) { 536 | return software.amazon.jsii.Kernel.call(this, "mul", software.amazon.jsii.NativeType.forClass(java.lang.Number.class), new Object[] { java.util.Objects.requireNonNull(ops, "ops is required") }); 537 | } 538 | 539 | /** 540 | * Subtracts the two operands. 541 | *

542 | * @param ops operands. This parameter is required. 543 | */ 544 | public @org.jetbrains.annotations.NotNull java.lang.Number sub(final @org.jetbrains.annotations.NotNull mypackage.Operands ops) { 545 | return software.amazon.jsii.Kernel.call(this, "sub", software.amazon.jsii.NativeType.forClass(java.lang.Number.class), new Object[] { java.util.Objects.requireNonNull(ops, "ops is required") }); 546 | } 547 | } 548 | ", 549 | "src/main/java/mypackage/Operands.java": "package mypackage; 550 | 551 | /** 552 | * Math operands. 553 | */ 554 | 555 | @software.amazon.jsii.Jsii(module = mypackage.$Module.class, fqn = "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands") 556 | @software.amazon.jsii.Jsii.Proxy(Operands.Jsii$Proxy.class) 557 | public interface Operands extends software.amazon.jsii.JsiiSerializable { 558 | 559 | /** 560 | * Left-hand side operand. 561 | */ 562 | @org.jetbrains.annotations.NotNull java.lang.Number getLhs(); 563 | 564 | /** 565 | * Right-hand side operand. 566 | */ 567 | @org.jetbrains.annotations.NotNull java.lang.Number getRhs(); 568 | 569 | /** 570 | * @return a {@link Builder} of {@link Operands} 571 | */ 572 | static Builder builder() { 573 | return new Builder(); 574 | } 575 | /** 576 | * A builder for {@link Operands} 577 | */ 578 | public static final class Builder implements software.amazon.jsii.Builder { 579 | java.lang.Number lhs; 580 | java.lang.Number rhs; 581 | 582 | /** 583 | * Sets the value of {@link Operands#getLhs} 584 | * @param lhs Left-hand side operand. This parameter is required. 585 | * @return {@code this} 586 | */ 587 | public Builder lhs(java.lang.Number lhs) { 588 | this.lhs = lhs; 589 | return this; 590 | } 591 | 592 | /** 593 | * Sets the value of {@link Operands#getRhs} 594 | * @param rhs Right-hand side operand. This parameter is required. 595 | * @return {@code this} 596 | */ 597 | public Builder rhs(java.lang.Number rhs) { 598 | this.rhs = rhs; 599 | return this; 600 | } 601 | 602 | /** 603 | * Builds the configured instance. 604 | * @return a new instance of {@link Operands} 605 | * @throws NullPointerException if any required attribute was not provided 606 | */ 607 | @Override 608 | public Operands build() { 609 | return new Jsii$Proxy(this); 610 | } 611 | } 612 | 613 | /** 614 | * An implementation for {@link Operands} 615 | */ 616 | @software.amazon.jsii.Internal 617 | final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements Operands { 618 | private final java.lang.Number lhs; 619 | private final java.lang.Number rhs; 620 | 621 | /** 622 | * Constructor that initializes the object based on values retrieved from the JsiiObject. 623 | * @param objRef Reference to the JSII managed object. 624 | */ 625 | protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { 626 | super(objRef); 627 | this.lhs = software.amazon.jsii.Kernel.get(this, "lhs", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); 628 | this.rhs = software.amazon.jsii.Kernel.get(this, "rhs", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); 629 | } 630 | 631 | /** 632 | * Constructor that initializes the object based on literal property values passed by the {@link Builder}. 633 | */ 634 | protected Jsii$Proxy(final Builder builder) { 635 | super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); 636 | this.lhs = java.util.Objects.requireNonNull(builder.lhs, "lhs is required"); 637 | this.rhs = java.util.Objects.requireNonNull(builder.rhs, "rhs is required"); 638 | } 639 | 640 | @Override 641 | public final java.lang.Number getLhs() { 642 | return this.lhs; 643 | } 644 | 645 | @Override 646 | public final java.lang.Number getRhs() { 647 | return this.rhs; 648 | } 649 | 650 | @Override 651 | @software.amazon.jsii.Internal 652 | public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() { 653 | final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE; 654 | final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); 655 | 656 | data.set("lhs", om.valueToTree(this.getLhs())); 657 | data.set("rhs", om.valueToTree(this.getRhs())); 658 | 659 | final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); 660 | struct.set("fqn", om.valueToTree("4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands")); 661 | struct.set("data", data); 662 | 663 | final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); 664 | obj.set("$jsii.struct", struct); 665 | 666 | return obj; 667 | } 668 | 669 | @Override 670 | public final boolean equals(final Object o) { 671 | if (this == o) return true; 672 | if (o == null || getClass() != o.getClass()) return false; 673 | 674 | Operands.Jsii$Proxy that = (Operands.Jsii$Proxy) o; 675 | 676 | if (!lhs.equals(that.lhs)) return false; 677 | return this.rhs.equals(that.rhs); 678 | } 679 | 680 | @Override 681 | public final int hashCode() { 682 | int result = this.lhs.hashCode(); 683 | result = 31 * result + (this.rhs.hashCode()); 684 | return result; 685 | } 686 | } 687 | } 688 | ", 689 | "src/main/resources/mypackage/$Module.txt": "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Calculator=mypackage.Calculator 690 | 4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands=mypackage.Operands 691 | ", 692 | } 693 | `; 694 | 695 | exports[`jsii output 1`] = ` 696 | { 697 | "author": { 698 | "name": "generated@generated.com", 699 | "roles": [ 700 | "author", 701 | ], 702 | }, 703 | "description": "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060", 704 | "fingerprint": "UvZnbceh2Dy4kkZLuQlI6YzoRl7l0UdXexMjCcfg1s4=", 705 | "homepage": "http://generated", 706 | "jsiiVersion": "5.8.11 (build 55d251b)", 707 | "license": "UNLICENSED", 708 | "metadata": { 709 | "jsii": { 710 | "pacmak": { 711 | "hasDefaultInterfaces": true, 712 | }, 713 | }, 714 | }, 715 | "name": "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060", 716 | "repository": { 717 | "type": "git", 718 | "url": "http://generated", 719 | }, 720 | "schema": "jsii/0.10.0", 721 | "targets": { 722 | "js": { 723 | "npm": "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060", 724 | }, 725 | }, 726 | "types": { 727 | "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Calculator": { 728 | "assembly": "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060", 729 | "docs": { 730 | "summary": "A sophisticaed multi-language calculator.", 731 | }, 732 | "fqn": "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Calculator", 733 | "initializer": {}, 734 | "kind": "class", 735 | "locationInModule": { 736 | "filename": "lib/main.ts", 737 | "line": 19, 738 | }, 739 | "methods": [ 740 | { 741 | "docs": { 742 | "summary": "Adds the two operands.", 743 | }, 744 | "locationInModule": { 745 | "filename": "lib/main.ts", 746 | "line": 24, 747 | }, 748 | "name": "add", 749 | "parameters": [ 750 | { 751 | "docs": { 752 | "summary": "operands.", 753 | }, 754 | "name": "ops", 755 | "type": { 756 | "fqn": "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands", 757 | }, 758 | }, 759 | ], 760 | "returns": { 761 | "type": { 762 | "primitive": "number", 763 | }, 764 | }, 765 | }, 766 | { 767 | "docs": { 768 | "summary": "Multiplies the two operands.", 769 | }, 770 | "locationInModule": { 771 | "filename": "lib/main.ts", 772 | "line": 40, 773 | }, 774 | "name": "mul", 775 | "parameters": [ 776 | { 777 | "docs": { 778 | "summary": "operands.", 779 | }, 780 | "name": "ops", 781 | "type": { 782 | "fqn": "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands", 783 | }, 784 | }, 785 | ], 786 | "returns": { 787 | "type": { 788 | "primitive": "number", 789 | }, 790 | }, 791 | }, 792 | { 793 | "docs": { 794 | "summary": "Subtracts the two operands.", 795 | }, 796 | "locationInModule": { 797 | "filename": "lib/main.ts", 798 | "line": 32, 799 | }, 800 | "name": "sub", 801 | "parameters": [ 802 | { 803 | "docs": { 804 | "summary": "operands.", 805 | }, 806 | "name": "ops", 807 | "type": { 808 | "fqn": "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands", 809 | }, 810 | }, 811 | ], 812 | "returns": { 813 | "type": { 814 | "primitive": "number", 815 | }, 816 | }, 817 | }, 818 | ], 819 | "name": "Calculator", 820 | "symbolId": "lib/main:Calculator", 821 | }, 822 | "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands": { 823 | "assembly": "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060", 824 | "datatype": true, 825 | "docs": { 826 | "summary": "Math operands.", 827 | }, 828 | "fqn": "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands", 829 | "kind": "interface", 830 | "locationInModule": { 831 | "filename": "lib/main.ts", 832 | "line": 4, 833 | }, 834 | "name": "Operands", 835 | "properties": [ 836 | { 837 | "abstract": true, 838 | "docs": { 839 | "summary": "Left-hand side operand.", 840 | }, 841 | "immutable": true, 842 | "locationInModule": { 843 | "filename": "lib/main.ts", 844 | "line": 8, 845 | }, 846 | "name": "lhs", 847 | "type": { 848 | "primitive": "number", 849 | }, 850 | }, 851 | { 852 | "abstract": true, 853 | "docs": { 854 | "summary": "Right-hand side operand.", 855 | }, 856 | "immutable": true, 857 | "locationInModule": { 858 | "filename": "lib/main.ts", 859 | "line": 13, 860 | }, 861 | "name": "rhs", 862 | "type": { 863 | "primitive": "number", 864 | }, 865 | }, 866 | ], 867 | "symbolId": "lib/main:Operands", 868 | }, 869 | }, 870 | "version": "0.0.0", 871 | } 872 | `; 873 | 874 | exports[`python output 1`] = ` 875 | { 876 | "my/python/module/__init__.py": "from pkgutil import extend_path 877 | __path__ = extend_path(__path__, __name__) 878 | 879 | import abc 880 | import builtins 881 | import datetime 882 | import enum 883 | import typing 884 | 885 | import jsii 886 | import publication 887 | import typing_extensions 888 | 889 | import typeguard 890 | from importlib.metadata import version as _metadata_package_version 891 | TYPEGUARD_MAJOR_VERSION = int(_metadata_package_version('typeguard').split('.')[0]) 892 | 893 | def check_type(argname: str, value: object, expected_type: typing.Any) -> typing.Any: 894 | if TYPEGUARD_MAJOR_VERSION <= 2: 895 | return typeguard.check_type(argname=argname, value=value, expected_type=expected_type) # type:ignore 896 | else: 897 | if isinstance(value, jsii._reference_map.InterfaceDynamicProxy): # pyright: ignore [reportAttributeAccessIssue] 898 | pass 899 | else: 900 | if TYPEGUARD_MAJOR_VERSION == 3: 901 | typeguard.config.collection_check_strategy = typeguard.CollectionCheckStrategy.ALL_ITEMS # type:ignore 902 | typeguard.check_type(value=value, expected_type=expected_type) # type:ignore 903 | else: 904 | typeguard.check_type(value=value, expected_type=expected_type, collection_check_strategy=typeguard.CollectionCheckStrategy.ALL_ITEMS) # type:ignore 905 | 906 | from ._jsii import * 907 | 908 | 909 | class Calculator( 910 | metaclass=jsii.JSIIMeta, 911 | jsii_type="4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Calculator", 912 | ): 913 | '''A sophisticaed multi-language calculator.''' 914 | 915 | def __init__(self) -> None: 916 | jsii.create(self.__class__, self, []) 917 | 918 | @jsii.member(jsii_name="add") 919 | def add(self, *, lhs: jsii.Number, rhs: jsii.Number) -> jsii.Number: 920 | '''Adds the two operands. 921 | 922 | :param lhs: Left-hand side operand. 923 | :param rhs: Right-hand side operand. 924 | ''' 925 | ops = Operands(lhs=lhs, rhs=rhs) 926 | 927 | return typing.cast(jsii.Number, jsii.invoke(self, "add", [ops])) 928 | 929 | @jsii.member(jsii_name="mul") 930 | def mul(self, *, lhs: jsii.Number, rhs: jsii.Number) -> jsii.Number: 931 | '''Multiplies the two operands. 932 | 933 | :param lhs: Left-hand side operand. 934 | :param rhs: Right-hand side operand. 935 | ''' 936 | ops = Operands(lhs=lhs, rhs=rhs) 937 | 938 | return typing.cast(jsii.Number, jsii.invoke(self, "mul", [ops])) 939 | 940 | @jsii.member(jsii_name="sub") 941 | def sub(self, *, lhs: jsii.Number, rhs: jsii.Number) -> jsii.Number: 942 | '''Subtracts the two operands. 943 | 944 | :param lhs: Left-hand side operand. 945 | :param rhs: Right-hand side operand. 946 | ''' 947 | ops = Operands(lhs=lhs, rhs=rhs) 948 | 949 | return typing.cast(jsii.Number, jsii.invoke(self, "sub", [ops])) 950 | 951 | 952 | @jsii.data_type( 953 | jsii_type="4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060.Operands", 954 | jsii_struct_bases=[], 955 | name_mapping={"lhs": "lhs", "rhs": "rhs"}, 956 | ) 957 | class Operands: 958 | def __init__(self, *, lhs: jsii.Number, rhs: jsii.Number) -> None: 959 | '''Math operands. 960 | 961 | :param lhs: Left-hand side operand. 962 | :param rhs: Right-hand side operand. 963 | ''' 964 | if __debug__: 965 | type_hints = typing.get_type_hints(_typecheckingstub__62b72180950e738f3da9d30928f89aeb536b4a0ac6dbb349ce3eb7a1e3c2a293) 966 | check_type(argname="argument lhs", value=lhs, expected_type=type_hints["lhs"]) 967 | check_type(argname="argument rhs", value=rhs, expected_type=type_hints["rhs"]) 968 | self._values: typing.Dict[builtins.str, typing.Any] = { 969 | "lhs": lhs, 970 | "rhs": rhs, 971 | } 972 | 973 | @builtins.property 974 | def lhs(self) -> jsii.Number: 975 | '''Left-hand side operand.''' 976 | result = self._values.get("lhs") 977 | assert result is not None, "Required property 'lhs' is missing" 978 | return typing.cast(jsii.Number, result) 979 | 980 | @builtins.property 981 | def rhs(self) -> jsii.Number: 982 | '''Right-hand side operand.''' 983 | result = self._values.get("rhs") 984 | assert result is not None, "Required property 'rhs' is missing" 985 | return typing.cast(jsii.Number, result) 986 | 987 | def __eq__(self, rhs: typing.Any) -> builtins.bool: 988 | return isinstance(rhs, self.__class__) and rhs._values == self._values 989 | 990 | def __ne__(self, rhs: typing.Any) -> builtins.bool: 991 | return not (rhs == self) 992 | 993 | def __repr__(self) -> str: 994 | return "Operands(%s)" % ", ".join( 995 | k + "=" + repr(v) for k, v in self._values.items() 996 | ) 997 | 998 | 999 | __all__ = [ 1000 | "Calculator", 1001 | "Operands", 1002 | ] 1003 | 1004 | publication.publish() 1005 | 1006 | def _typecheckingstub__62b72180950e738f3da9d30928f89aeb536b4a0ac6dbb349ce3eb7a1e3c2a293( 1007 | *, 1008 | lhs: jsii.Number, 1009 | rhs: jsii.Number, 1010 | ) -> None: 1011 | """Type checking stubs""" 1012 | pass 1013 | ", 1014 | "my/python/module/_jsii/__init__.py": "from pkgutil import extend_path 1015 | __path__ = extend_path(__path__, __name__) 1016 | 1017 | import abc 1018 | import builtins 1019 | import datetime 1020 | import enum 1021 | import typing 1022 | 1023 | import jsii 1024 | import publication 1025 | import typing_extensions 1026 | 1027 | import typeguard 1028 | from importlib.metadata import version as _metadata_package_version 1029 | TYPEGUARD_MAJOR_VERSION = int(_metadata_package_version('typeguard').split('.')[0]) 1030 | 1031 | def check_type(argname: str, value: object, expected_type: typing.Any) -> typing.Any: 1032 | if TYPEGUARD_MAJOR_VERSION <= 2: 1033 | return typeguard.check_type(argname=argname, value=value, expected_type=expected_type) # type:ignore 1034 | else: 1035 | if isinstance(value, jsii._reference_map.InterfaceDynamicProxy): # pyright: ignore [reportAttributeAccessIssue] 1036 | pass 1037 | else: 1038 | if TYPEGUARD_MAJOR_VERSION == 3: 1039 | typeguard.config.collection_check_strategy = typeguard.CollectionCheckStrategy.ALL_ITEMS # type:ignore 1040 | typeguard.check_type(value=value, expected_type=expected_type) # type:ignore 1041 | else: 1042 | typeguard.check_type(value=value, expected_type=expected_type, collection_check_strategy=typeguard.CollectionCheckStrategy.ALL_ITEMS) # type:ignore 1043 | 1044 | __jsii_assembly__ = jsii.JSIIAssembly.load( 1045 | "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060", 1046 | "0.0.0", 1047 | __name__[0:-6], 1048 | "4c6b576fbe7e27053874813d9754cb2e46811d806c1e0aa9aae8add4c3763060@0.0.0.jsii.tgz", 1049 | ) 1050 | 1051 | __all__ = [ 1052 | "__jsii_assembly__", 1053 | ] 1054 | 1055 | publication.publish() 1056 | ", 1057 | "my/python/module/py.typed": " 1058 | ", 1059 | } 1060 | `; 1061 | -------------------------------------------------------------------------------- /test/__snapshots__/srcmak.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`csharp + different entrypoint 1`] = ` 4 | { 5 | "Hello.World/AssemblyInfo.cs": "using Amazon.JSII.Runtime.Deputy; 6 | 7 | [assembly: JsiiAssembly("csharppackage", "0.0.0", "csharppackage-0.0.0.tgz")] 8 | ", 9 | "Hello.World/Hello.World.csproj": " 10 | 11 | 12 | csharppackage 13 | Hello.World 14 | UNLICENSED 15 | 0.0.0 16 | 17 | generated@generated.com 18 | en-US 19 | http://generated 20 | http://generated 21 | git 22 | 23 | true 24 | true 25 | true 26 | true 27 | enable 28 | snupkg 29 | netcoreapp3.1 30 | Major 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 0612,0618 41 | 42 | 0108,0109 43 | 44 | 45 | 46 | ", 47 | "Hello.World/Hello/World/Hello.cs": "using Amazon.JSII.Runtime.Deputy; 48 | 49 | #pragma warning disable CS0672,CS0809,CS1591 50 | 51 | namespace Hello.World 52 | { 53 | [JsiiClass(nativeType: typeof(Hello.World.Hello), fullyQualifiedName: "csharppackage.Hello")] 54 | public class Hello : DeputyBase 55 | { 56 | public Hello(): base(_MakeDeputyProps()) 57 | { 58 | } 59 | 60 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] 61 | private static DeputyProps _MakeDeputyProps() 62 | { 63 | return new DeputyProps(System.Array.Empty()); 64 | } 65 | 66 | ///

Used by jsii to construct an instance of this class from a Javascript-owned object reference 67 | /// The Javascript-owned object reference 68 | [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] 69 | protected Hello(ByRefValue reference): base(reference) 70 | { 71 | } 72 | 73 | /// Used by jsii to construct an instance of this class from DeputyProps 74 | /// The deputy props 75 | [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] 76 | protected Hello(DeputyProps props): base(props) 77 | { 78 | } 79 | 80 | [JsiiMethod(name: "add", returnsJson: "{\\"type\\":{\\"primitive\\":\\"number\\"}}", parametersJson: "[{\\"name\\":\\"ops\\",\\"type\\":{\\"fqn\\":\\"csharppackage.Operands\\"}}]")] 81 | public virtual double Add(Hello.World.IOperands ops) 82 | { 83 | return InvokeInstanceMethod(new System.Type[]{typeof(Hello.World.IOperands)}, new object[]{ops})!; 84 | } 85 | } 86 | } 87 | ", 88 | "Hello.World/Hello/World/IOperands.cs": "using Amazon.JSII.Runtime.Deputy; 89 | 90 | #pragma warning disable CS0672,CS0809,CS1591 91 | 92 | namespace Hello.World 93 | { 94 | [JsiiInterface(nativeType: typeof(IOperands), fullyQualifiedName: "csharppackage.Operands")] 95 | public interface IOperands 96 | { 97 | [JsiiProperty(name: "lhs", typeJson: "{\\"primitive\\":\\"number\\"}")] 98 | double Lhs 99 | { 100 | get; 101 | } 102 | 103 | [JsiiProperty(name: "rhs", typeJson: "{\\"primitive\\":\\"number\\"}")] 104 | double Rhs 105 | { 106 | get; 107 | } 108 | 109 | [JsiiTypeProxy(nativeType: typeof(IOperands), fullyQualifiedName: "csharppackage.Operands")] 110 | internal sealed class _Proxy : DeputyBase, Hello.World.IOperands 111 | { 112 | private _Proxy(ByRefValue reference): base(reference) 113 | { 114 | } 115 | 116 | [JsiiProperty(name: "lhs", typeJson: "{\\"primitive\\":\\"number\\"}")] 117 | public double Lhs 118 | { 119 | get => GetInstanceProperty()!; 120 | } 121 | 122 | [JsiiProperty(name: "rhs", typeJson: "{\\"primitive\\":\\"number\\"}")] 123 | public double Rhs 124 | { 125 | get => GetInstanceProperty()!; 126 | } 127 | } 128 | } 129 | } 130 | ", 131 | "Hello.World/Hello/World/Internal/DependencyResolution/Anchor.cs": "#pragma warning disable CS0672,CS0809,CS1591 132 | 133 | namespace Hello.World.Internal.DependencyResolution 134 | { 135 | public sealed class Anchor 136 | { 137 | public Anchor() 138 | { 139 | } 140 | } 141 | } 142 | ", 143 | "Hello.World/Hello/World/Operands.cs": "using Amazon.JSII.Runtime.Deputy; 144 | 145 | #pragma warning disable CS0672,CS0809,CS1591 146 | 147 | namespace Hello.World 148 | { 149 | #pragma warning disable CS8618 150 | 151 | [JsiiByValue(fqn: "csharppackage.Operands")] 152 | public class Operands : Hello.World.IOperands 153 | { 154 | [JsiiProperty(name: "lhs", typeJson: "{\\"primitive\\":\\"number\\"}")] 155 | public double Lhs 156 | { 157 | get; 158 | set; 159 | } 160 | 161 | [JsiiProperty(name: "rhs", typeJson: "{\\"primitive\\":\\"number\\"}")] 162 | public double Rhs 163 | { 164 | get; 165 | set; 166 | } 167 | } 168 | } 169 | ", 170 | } 171 | `; 172 | 173 | exports[`golang + different entrypoint 1`] = ` 174 | { 175 | "hello/Hello.go": "package hello 176 | 177 | import ( 178 | _jsii_ "github.com/aws/jsii-runtime-go/runtime" 179 | _init_ "github.com/org/repo/hello/jsii" 180 | ) 181 | 182 | type Hello interface { 183 | Add(ops *Operands) *float64 184 | } 185 | 186 | // The jsii proxy struct for Hello 187 | type jsiiProxy_Hello struct { 188 | _ byte // padding 189 | } 190 | 191 | func NewHello() Hello { 192 | _init_.Initialize() 193 | 194 | j := jsiiProxy_Hello{} 195 | 196 | _jsii_.Create( 197 | "gopackage.Hello", 198 | nil, // no parameters 199 | &j, 200 | ) 201 | 202 | return &j 203 | } 204 | 205 | func NewHello_Override(h Hello) { 206 | _init_.Initialize() 207 | 208 | _jsii_.Create( 209 | "gopackage.Hello", 210 | nil, // no parameters 211 | h, 212 | ) 213 | } 214 | 215 | func (h *jsiiProxy_Hello) Add(ops *Operands) *float64 { 216 | if err := h.validateAddParameters(ops); err != nil { 217 | panic(err) 218 | } 219 | var returns *float64 220 | 221 | _jsii_.Invoke( 222 | h, 223 | "add", 224 | []interface{}{ops}, 225 | &returns, 226 | ) 227 | 228 | return returns 229 | } 230 | 231 | ", 232 | "hello/Hello__checks.go": "//go:build !no_runtime_type_checking 233 | 234 | package hello 235 | 236 | import ( 237 | "fmt" 238 | 239 | _jsii_ "github.com/aws/jsii-runtime-go/runtime" 240 | ) 241 | 242 | func (h *jsiiProxy_Hello) validateAddParameters(ops *Operands) error { 243 | if ops == nil { 244 | return fmt.Errorf("parameter ops is required, but nil was provided") 245 | } 246 | if err := _jsii_.ValidateStruct(ops, func() string { return "parameter ops" }); err != nil { 247 | return err 248 | } 249 | 250 | return nil 251 | } 252 | 253 | ", 254 | "hello/Hello__no_checks.go": "//go:build no_runtime_type_checking 255 | 256 | package hello 257 | 258 | // Building without runtime type checking enabled, so all the below just return nil 259 | 260 | func (h *jsiiProxy_Hello) validateAddParameters(ops *Operands) error { 261 | return nil 262 | } 263 | 264 | ", 265 | "hello/Operands.go": "package hello 266 | 267 | 268 | type Operands struct { 269 | Lhs *float64 \`field:"required" json:"lhs" yaml:"lhs"\` 270 | Rhs *float64 \`field:"required" json:"rhs" yaml:"rhs"\` 271 | } 272 | 273 | ", 274 | "hello/jsii/jsii.go": "// Package jsii contains the functionaility needed for jsii packages to 275 | // initialize their dependencies and themselves. Users should never need to use this package 276 | // directly. If you find you need to - please report a bug at 277 | // https://github.com/aws/jsii/issues/new/choose 278 | package jsii 279 | 280 | import ( 281 | _ "embed" 282 | 283 | _jsii_ "github.com/aws/jsii-runtime-go/runtime" 284 | ) 285 | 286 | //go:embed gopackage-0.0.0.tgz 287 | var tarball []byte 288 | 289 | // Initialize loads the necessary packages in the @jsii/kernel to support the enclosing module. 290 | // The implementation is idempotent (and hence safe to be called over and over). 291 | func Initialize() { 292 | // Load this library into the kernel 293 | _jsii_.Load("gopackage", "0.0.0", tarball) 294 | } 295 | ", 296 | "hello/main.go": "// gopackage 297 | package hello 298 | 299 | import ( 300 | "reflect" 301 | 302 | _jsii_ "github.com/aws/jsii-runtime-go/runtime" 303 | ) 304 | 305 | func init() { 306 | _jsii_.RegisterClass( 307 | "gopackage.Hello", 308 | reflect.TypeOf((*Hello)(nil)).Elem(), 309 | []_jsii_.Member{ 310 | _jsii_.MemberMethod{JsiiMethod: "add", GoMethod: "Add"}, 311 | }, 312 | func() interface{} { 313 | return &jsiiProxy_Hello{} 314 | }, 315 | ) 316 | _jsii_.RegisterStruct( 317 | "gopackage.Operands", 318 | reflect.TypeOf((*Operands)(nil)).Elem(), 319 | ) 320 | } 321 | ", 322 | "hello/version": "0.0.0 323 | ", 324 | } 325 | `; 326 | 327 | exports[`java + different entrypoint 1`] = ` 328 | { 329 | "src/main/java/hello/world/$Module.java": "package hello.world; 330 | 331 | import java.io.BufferedReader; 332 | import java.io.InputStream; 333 | import java.io.InputStreamReader; 334 | import java.io.IOException; 335 | import java.io.Reader; 336 | import java.io.UncheckedIOException; 337 | 338 | import java.nio.charset.StandardCharsets; 339 | 340 | import java.util.HashMap; 341 | import java.util.Map; 342 | 343 | import software.amazon.jsii.JsiiModule; 344 | 345 | @software.amazon.jsii.Internal 346 | public final class $Module extends JsiiModule { 347 | private static final Map MODULE_TYPES = load(); 348 | 349 | private static Map load() { 350 | final Map result = new HashMap<>(); 351 | final ClassLoader cl = $Module.class.getClassLoader(); 352 | try (final InputStream is = cl.getResourceAsStream("hello/world/$Module.txt"); 353 | final Reader rd = new InputStreamReader(is, StandardCharsets.UTF_8); 354 | final BufferedReader br = new BufferedReader(rd)) { 355 | br.lines() 356 | .filter(line -> !line.trim().isEmpty()) 357 | .forEach(line -> { 358 | final String[] parts = line.split("=", 2); 359 | final String fqn = parts[0]; 360 | final String className = parts[1]; 361 | result.put(fqn, className); 362 | }); 363 | } 364 | catch (final IOException exception) { 365 | throw new UncheckedIOException(exception); 366 | } 367 | return result; 368 | } 369 | 370 | private final Map> cache = new HashMap<>(); 371 | 372 | public $Module() { 373 | super("javapackage", "0.0.0", $Module.class, "javapackage@0.0.0.jsii.tgz"); 374 | } 375 | 376 | @Override 377 | protected Class resolveClass(final String fqn) throws ClassNotFoundException { 378 | if (!MODULE_TYPES.containsKey(fqn)) { 379 | throw new ClassNotFoundException("Unknown JSII type: " + fqn); 380 | } 381 | String className = MODULE_TYPES.get(fqn); 382 | if (!this.cache.containsKey(className)) { 383 | this.cache.put(className, this.findClass(className)); 384 | } 385 | return this.cache.get(className); 386 | } 387 | 388 | private Class findClass(final String binaryName) { 389 | try { 390 | return Class.forName(binaryName); 391 | } 392 | catch (final ClassNotFoundException exception) { 393 | throw new RuntimeException(exception); 394 | } 395 | } 396 | } 397 | ", 398 | "src/main/java/hello/world/Hello.java": "package hello.world; 399 | 400 | 401 | @software.amazon.jsii.Jsii(module = hello.world.$Module.class, fqn = "javapackage.Hello") 402 | public class Hello extends software.amazon.jsii.JsiiObject { 403 | 404 | protected Hello(final software.amazon.jsii.JsiiObjectRef objRef) { 405 | super(objRef); 406 | } 407 | 408 | protected Hello(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { 409 | super(initializationMode); 410 | } 411 | 412 | public Hello() { 413 | super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); 414 | software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); 415 | } 416 | 417 | public @org.jetbrains.annotations.NotNull java.lang.Number add(final @org.jetbrains.annotations.NotNull hello.world.Operands ops) { 418 | return software.amazon.jsii.Kernel.call(this, "add", software.amazon.jsii.NativeType.forClass(java.lang.Number.class), new Object[] { java.util.Objects.requireNonNull(ops, "ops is required") }); 419 | } 420 | } 421 | ", 422 | "src/main/java/hello/world/Operands.java": "package hello.world; 423 | 424 | 425 | @software.amazon.jsii.Jsii(module = hello.world.$Module.class, fqn = "javapackage.Operands") 426 | @software.amazon.jsii.Jsii.Proxy(Operands.Jsii$Proxy.class) 427 | public interface Operands extends software.amazon.jsii.JsiiSerializable { 428 | 429 | @org.jetbrains.annotations.NotNull java.lang.Number getLhs(); 430 | 431 | @org.jetbrains.annotations.NotNull java.lang.Number getRhs(); 432 | 433 | /** 434 | * @return a {@link Builder} of {@link Operands} 435 | */ 436 | static Builder builder() { 437 | return new Builder(); 438 | } 439 | /** 440 | * A builder for {@link Operands} 441 | */ 442 | public static final class Builder implements software.amazon.jsii.Builder { 443 | java.lang.Number lhs; 444 | java.lang.Number rhs; 445 | 446 | /** 447 | * Sets the value of {@link Operands#getLhs} 448 | * @param lhs the value to be set. This parameter is required. 449 | * @return {@code this} 450 | */ 451 | public Builder lhs(java.lang.Number lhs) { 452 | this.lhs = lhs; 453 | return this; 454 | } 455 | 456 | /** 457 | * Sets the value of {@link Operands#getRhs} 458 | * @param rhs the value to be set. This parameter is required. 459 | * @return {@code this} 460 | */ 461 | public Builder rhs(java.lang.Number rhs) { 462 | this.rhs = rhs; 463 | return this; 464 | } 465 | 466 | /** 467 | * Builds the configured instance. 468 | * @return a new instance of {@link Operands} 469 | * @throws NullPointerException if any required attribute was not provided 470 | */ 471 | @Override 472 | public Operands build() { 473 | return new Jsii$Proxy(this); 474 | } 475 | } 476 | 477 | /** 478 | * An implementation for {@link Operands} 479 | */ 480 | @software.amazon.jsii.Internal 481 | final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements Operands { 482 | private final java.lang.Number lhs; 483 | private final java.lang.Number rhs; 484 | 485 | /** 486 | * Constructor that initializes the object based on values retrieved from the JsiiObject. 487 | * @param objRef Reference to the JSII managed object. 488 | */ 489 | protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { 490 | super(objRef); 491 | this.lhs = software.amazon.jsii.Kernel.get(this, "lhs", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); 492 | this.rhs = software.amazon.jsii.Kernel.get(this, "rhs", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); 493 | } 494 | 495 | /** 496 | * Constructor that initializes the object based on literal property values passed by the {@link Builder}. 497 | */ 498 | protected Jsii$Proxy(final Builder builder) { 499 | super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); 500 | this.lhs = java.util.Objects.requireNonNull(builder.lhs, "lhs is required"); 501 | this.rhs = java.util.Objects.requireNonNull(builder.rhs, "rhs is required"); 502 | } 503 | 504 | @Override 505 | public final java.lang.Number getLhs() { 506 | return this.lhs; 507 | } 508 | 509 | @Override 510 | public final java.lang.Number getRhs() { 511 | return this.rhs; 512 | } 513 | 514 | @Override 515 | @software.amazon.jsii.Internal 516 | public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() { 517 | final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE; 518 | final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); 519 | 520 | data.set("lhs", om.valueToTree(this.getLhs())); 521 | data.set("rhs", om.valueToTree(this.getRhs())); 522 | 523 | final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); 524 | struct.set("fqn", om.valueToTree("javapackage.Operands")); 525 | struct.set("data", data); 526 | 527 | final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); 528 | obj.set("$jsii.struct", struct); 529 | 530 | return obj; 531 | } 532 | 533 | @Override 534 | public final boolean equals(final Object o) { 535 | if (this == o) return true; 536 | if (o == null || getClass() != o.getClass()) return false; 537 | 538 | Operands.Jsii$Proxy that = (Operands.Jsii$Proxy) o; 539 | 540 | if (!lhs.equals(that.lhs)) return false; 541 | return this.rhs.equals(that.rhs); 542 | } 543 | 544 | @Override 545 | public final int hashCode() { 546 | int result = this.lhs.hashCode(); 547 | result = 31 * result + (this.rhs.hashCode()); 548 | return result; 549 | } 550 | } 551 | } 552 | ", 553 | "src/main/resources/hello/world/$Module.txt": "javapackage.Hello=hello.world.Hello 554 | javapackage.Operands=hello.world.Operands 555 | ", 556 | } 557 | `; 558 | 559 | exports[`outputJsii can be used to look at the jsii file 1`] = ` 560 | { 561 | "author": { 562 | "name": "generated@generated.com", 563 | "roles": [ 564 | "author", 565 | ], 566 | }, 567 | "description": "1bc04b5291c26a46d918139138b992d2de976d6851d0893b0476b85bfbdfc6e6", 568 | "fingerprint": "fk6ODITUVY05viP1gfNCsP7v6a3tZfKNiEhZyMY1ddg=", 569 | "homepage": "http://generated", 570 | "jsiiVersion": "5.8.11 (build 55d251b)", 571 | "license": "UNLICENSED", 572 | "metadata": { 573 | "jsii": { 574 | "pacmak": { 575 | "hasDefaultInterfaces": true, 576 | }, 577 | }, 578 | }, 579 | "name": "1bc04b5291c26a46d918139138b992d2de976d6851d0893b0476b85bfbdfc6e6", 580 | "repository": { 581 | "type": "git", 582 | "url": "http://generated", 583 | }, 584 | "schema": "jsii/0.10.0", 585 | "targets": { 586 | "js": { 587 | "npm": "1bc04b5291c26a46d918139138b992d2de976d6851d0893b0476b85bfbdfc6e6", 588 | }, 589 | }, 590 | "types": { 591 | "1bc04b5291c26a46d918139138b992d2de976d6851d0893b0476b85bfbdfc6e6.Foo": { 592 | "assembly": "1bc04b5291c26a46d918139138b992d2de976d6851d0893b0476b85bfbdfc6e6", 593 | "fqn": "1bc04b5291c26a46d918139138b992d2de976d6851d0893b0476b85bfbdfc6e6.Foo", 594 | "initializer": {}, 595 | "kind": "class", 596 | "locationInModule": { 597 | "filename": "index.ts", 598 | "line": 2, 599 | }, 600 | "methods": [ 601 | { 602 | "locationInModule": { 603 | "filename": "index.ts", 604 | "line": 3, 605 | }, 606 | "name": "hello", 607 | "returns": { 608 | "type": { 609 | "primitive": "string", 610 | }, 611 | }, 612 | "static": true, 613 | }, 614 | ], 615 | "name": "Foo", 616 | "symbolId": "index:Foo", 617 | }, 618 | }, 619 | "version": "0.0.0", 620 | } 621 | `; 622 | 623 | exports[`python + different entrypoint + submodule 1`] = ` 624 | { 625 | "my_python_module/submodule/__init__.py": "from pkgutil import extend_path 626 | __path__ = extend_path(__path__, __name__) 627 | 628 | import abc 629 | import builtins 630 | import datetime 631 | import enum 632 | import typing 633 | 634 | import jsii 635 | import publication 636 | import typing_extensions 637 | 638 | import typeguard 639 | from importlib.metadata import version as _metadata_package_version 640 | TYPEGUARD_MAJOR_VERSION = int(_metadata_package_version('typeguard').split('.')[0]) 641 | 642 | def check_type(argname: str, value: object, expected_type: typing.Any) -> typing.Any: 643 | if TYPEGUARD_MAJOR_VERSION <= 2: 644 | return typeguard.check_type(argname=argname, value=value, expected_type=expected_type) # type:ignore 645 | else: 646 | if isinstance(value, jsii._reference_map.InterfaceDynamicProxy): # pyright: ignore [reportAttributeAccessIssue] 647 | pass 648 | else: 649 | if TYPEGUARD_MAJOR_VERSION == 3: 650 | typeguard.config.collection_check_strategy = typeguard.CollectionCheckStrategy.ALL_ITEMS # type:ignore 651 | typeguard.check_type(value=value, expected_type=expected_type) # type:ignore 652 | else: 653 | typeguard.check_type(value=value, expected_type=expected_type, collection_check_strategy=typeguard.CollectionCheckStrategy.ALL_ITEMS) # type:ignore 654 | 655 | from ._jsii import * 656 | 657 | 658 | class Hello(metaclass=jsii.JSIIMeta, jsii_type="pythonpackage.Hello"): 659 | def __init__(self) -> None: 660 | jsii.create(self.__class__, self, []) 661 | 662 | @jsii.member(jsii_name="add") 663 | def add(self, *, lhs: jsii.Number, rhs: jsii.Number) -> jsii.Number: 664 | ''' 665 | :param lhs: - 666 | :param rhs: - 667 | ''' 668 | ops = Operands(lhs=lhs, rhs=rhs) 669 | 670 | return typing.cast(jsii.Number, jsii.invoke(self, "add", [ops])) 671 | 672 | 673 | @jsii.data_type( 674 | jsii_type="pythonpackage.Operands", 675 | jsii_struct_bases=[], 676 | name_mapping={"lhs": "lhs", "rhs": "rhs"}, 677 | ) 678 | class Operands: 679 | def __init__(self, *, lhs: jsii.Number, rhs: jsii.Number) -> None: 680 | ''' 681 | :param lhs: - 682 | :param rhs: - 683 | ''' 684 | if __debug__: 685 | type_hints = typing.get_type_hints(_typecheckingstub__be3a9403b95ce7f8a86be94c66555dc360ad3231bf31a6ad0030c4198da87142) 686 | check_type(argname="argument lhs", value=lhs, expected_type=type_hints["lhs"]) 687 | check_type(argname="argument rhs", value=rhs, expected_type=type_hints["rhs"]) 688 | self._values: typing.Dict[builtins.str, typing.Any] = { 689 | "lhs": lhs, 690 | "rhs": rhs, 691 | } 692 | 693 | @builtins.property 694 | def lhs(self) -> jsii.Number: 695 | result = self._values.get("lhs") 696 | assert result is not None, "Required property 'lhs' is missing" 697 | return typing.cast(jsii.Number, result) 698 | 699 | @builtins.property 700 | def rhs(self) -> jsii.Number: 701 | result = self._values.get("rhs") 702 | assert result is not None, "Required property 'rhs' is missing" 703 | return typing.cast(jsii.Number, result) 704 | 705 | def __eq__(self, rhs: typing.Any) -> builtins.bool: 706 | return isinstance(rhs, self.__class__) and rhs._values == self._values 707 | 708 | def __ne__(self, rhs: typing.Any) -> builtins.bool: 709 | return not (rhs == self) 710 | 711 | def __repr__(self) -> str: 712 | return "Operands(%s)" % ", ".join( 713 | k + "=" + repr(v) for k, v in self._values.items() 714 | ) 715 | 716 | 717 | __all__ = [ 718 | "Hello", 719 | "Operands", 720 | ] 721 | 722 | publication.publish() 723 | 724 | def _typecheckingstub__be3a9403b95ce7f8a86be94c66555dc360ad3231bf31a6ad0030c4198da87142( 725 | *, 726 | lhs: jsii.Number, 727 | rhs: jsii.Number, 728 | ) -> None: 729 | """Type checking stubs""" 730 | pass 731 | ", 732 | "my_python_module/submodule/_jsii/__init__.py": "from pkgutil import extend_path 733 | __path__ = extend_path(__path__, __name__) 734 | 735 | import abc 736 | import builtins 737 | import datetime 738 | import enum 739 | import typing 740 | 741 | import jsii 742 | import publication 743 | import typing_extensions 744 | 745 | import typeguard 746 | from importlib.metadata import version as _metadata_package_version 747 | TYPEGUARD_MAJOR_VERSION = int(_metadata_package_version('typeguard').split('.')[0]) 748 | 749 | def check_type(argname: str, value: object, expected_type: typing.Any) -> typing.Any: 750 | if TYPEGUARD_MAJOR_VERSION <= 2: 751 | return typeguard.check_type(argname=argname, value=value, expected_type=expected_type) # type:ignore 752 | else: 753 | if isinstance(value, jsii._reference_map.InterfaceDynamicProxy): # pyright: ignore [reportAttributeAccessIssue] 754 | pass 755 | else: 756 | if TYPEGUARD_MAJOR_VERSION == 3: 757 | typeguard.config.collection_check_strategy = typeguard.CollectionCheckStrategy.ALL_ITEMS # type:ignore 758 | typeguard.check_type(value=value, expected_type=expected_type) # type:ignore 759 | else: 760 | typeguard.check_type(value=value, expected_type=expected_type, collection_check_strategy=typeguard.CollectionCheckStrategy.ALL_ITEMS) # type:ignore 761 | 762 | __jsii_assembly__ = jsii.JSIIAssembly.load( 763 | "pythonpackage", "0.0.0", __name__[0:-6], "pythonpackage@0.0.0.jsii.tgz" 764 | ) 765 | 766 | __all__ = [ 767 | "__jsii_assembly__", 768 | ] 769 | 770 | publication.publish() 771 | ", 772 | "my_python_module/submodule/py.typed": " 773 | ", 774 | } 775 | `; 776 | -------------------------------------------------------------------------------- /test/cli.test.ts: -------------------------------------------------------------------------------- 1 | import { execFileSync } from 'child_process'; 2 | import * as path from 'path'; 3 | import * as fs from 'fs-extra'; 4 | import { snapshotDirectory } from './util'; 5 | import { mkdtemp } from '../src/util'; 6 | 7 | const program = require.resolve('../bin/jsii-srcmak'); 8 | const srcdir = path.join(__dirname, '..', 'example'); 9 | 10 | jest.setTimeout(60_000); // 1min 11 | 12 | test('no arguments - fails with help', () => { 13 | expect(() => srcmakcli()).toThrow(/Invalid number of arguments. expecting a single positional argument./); 14 | }); 15 | 16 | test('invalid entrypoint', () => { 17 | expect(() => srcmakcli(srcdir)).toThrow(/unable to find typescript entrypoint/); 18 | }); 19 | 20 | test('compile only', () => { 21 | srcmakcli( 22 | srcdir, 23 | '--entrypoint lib/main.ts', 24 | ); 25 | }); 26 | 27 | test('jsii output', async () => { 28 | await mkdtemp(async dir => { 29 | const jsiiPath = path.join(dir, 'my.jsii'); 30 | 31 | srcmakcli(srcdir, 32 | '--entrypoint lib/main.ts', 33 | `--jsii-path ${jsiiPath}`, 34 | ); 35 | 36 | expect(JSON.parse(fs.readFileSync(jsiiPath, 'utf-8'))).toMatchSnapshot(); 37 | }); 38 | }); 39 | 40 | test('fails if only one python option is given', () => { 41 | expect(() => srcmakcli(srcdir, 42 | '--entrypoint lib/main.ts', 43 | '--python-module-name module', 44 | )).toThrow(/--python-outdir is required if --python-module-name is specified/); 45 | 46 | expect(() => srcmakcli(srcdir, 47 | '--entrypoint lib/main.ts', 48 | '--python-outdir dir', 49 | )).toThrow(/--python-module-name is required if --python-outdir is specified/); 50 | }); 51 | 52 | test('fails if only one java option is given', () => { 53 | expect(() => srcmakcli(srcdir, 54 | '--entrypoint lib/main.ts', 55 | '--java-package mypackage', 56 | )).toThrow(/--java-outdir is required/); 57 | 58 | expect(() => srcmakcli(srcdir, 59 | '--entrypoint lib/main.ts', 60 | '--java-outdir dir', 61 | )).toThrow(/--java-package is required/); 62 | }); 63 | 64 | test('fails if only one csharp option is given', () => { 65 | expect(() => srcmakcli(srcdir, 66 | '--entrypoint lib/main.ts', 67 | '--csharp-namespace mypackage', 68 | )).toThrow(/--csharp-outdir is required/); 69 | 70 | expect(() => srcmakcli(srcdir, 71 | '--entrypoint lib/main.ts', 72 | '--csharp-outdir dir', 73 | )).toThrow(/--csharp-namespace is required/); 74 | }); 75 | 76 | test('fails if required golang options are missing', () => { 77 | expect(() => srcmakcli(srcdir, 78 | '--entrypoint lib/main.ts', 79 | '--golang-module github.com/a/b', 80 | )).toThrow(/--golang-outdir is required/); 81 | 82 | expect(() => srcmakcli(srcdir, 83 | '--entrypoint lib/main.ts', 84 | '--golang-outdir dir', 85 | )).toThrow(/--golang-module is required/); 86 | 87 | expect(() => srcmakcli(srcdir, 88 | '--entrypoint lib/main.ts', 89 | '--golang-module github.com/a/b', 90 | '--golang-outdir dir', 91 | )).toThrow(/--golang-package is required/); 92 | }); 93 | 94 | test('python output', async () => { 95 | await mkdtemp(async tmpdir => { 96 | 97 | // put under a non-existent directory to verify it is created 98 | const outdir = path.join(tmpdir, 'python'); 99 | 100 | srcmakcli(srcdir, 101 | '--entrypoint lib/main.ts', 102 | `--python-outdir ${outdir}`, 103 | '--python-module-name my.python.module', 104 | ); 105 | 106 | expect(await snapshotDirectory(outdir, { 107 | excludeFiles: ['@0.0.0.jsii.tgz'], 108 | })).toMatchSnapshot(); 109 | }); 110 | }); 111 | 112 | test('java output', async () => { 113 | await mkdtemp(async tmpdir => { 114 | // put under a non-existent directory to verify it is created 115 | const outdir = path.join(tmpdir, 'java'); 116 | 117 | srcmakcli(srcdir, 118 | '--entrypoint lib/main.ts', 119 | `--java-outdir ${outdir}`, 120 | '--java-package mypackage', 121 | ); 122 | 123 | expect(await snapshotDirectory(outdir, { 124 | excludeLines: [/.*@javax.annotation.Generated.*/], 125 | excludeFiles: ['@0.0.0.jsii.tgz'], 126 | })).toMatchSnapshot(); 127 | }); 128 | }); 129 | 130 | test('csharp output', async () => { 131 | await mkdtemp(async tmpdir => { 132 | // put under a non-existent directory to verify it is created 133 | const outdir = path.join(tmpdir, 'csharp'); 134 | 135 | srcmakcli(srcdir, 136 | '--entrypoint lib/main.ts', 137 | `--csharp-outdir ${outdir}`, 138 | '--csharp-namespace MyPackage', 139 | ); 140 | 141 | expect(await snapshotDirectory(outdir, { 142 | excludeFiles: ['0.0.0.tgz'], 143 | })).toMatchSnapshot(); 144 | }); 145 | }); 146 | 147 | test('golang output', async () => { 148 | await mkdtemp(async tmpdir => { 149 | // put under a non-existent directory to verify it is created 150 | const outdir = path.join(tmpdir, 'go'); 151 | 152 | srcmakcli(srcdir, 153 | '--entrypoint lib/main.ts', 154 | `--golang-outdir ${outdir}`, 155 | '--golang-module github.com/hello/world', 156 | '--golang-package package', 157 | ); 158 | 159 | expect(await snapshotDirectory(outdir, { 160 | excludeFiles: ['0.0.0.tgz'], 161 | })).toMatchSnapshot(); 162 | }); 163 | }); 164 | 165 | test('dependencies', async () => { 166 | await mkdtemp(async srcdir2 => { 167 | await fs.writeFile(path.join(srcdir2, 'index.ts'), ` 168 | import * as fs from 'fs'; 169 | fs.writeFileSync('foo.bar', 'hello'); 170 | `); 171 | 172 | // resolve against *this* executable 173 | const dep = path.dirname(require.resolve('@types/node/package.json')); 174 | srcmakcli(srcdir2, `--dep ${dep}`); 175 | }); 176 | }); 177 | 178 | function srcmakcli(...args: string[]) { 179 | const a = args.join(' '); 180 | execFileSync(program, a ? a.split(' ') : []); 181 | } -------------------------------------------------------------------------------- /test/srcmak.test.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as path from 'path'; 3 | import * as fs from 'fs-extra'; 4 | import { snapshotDirectory } from './util'; 5 | import { srcmak } from '../src'; 6 | import { mkdtemp } from '../src/util'; 7 | 8 | jest.setTimeout(60_000); // 1min 9 | 10 | test('just compile', async () => { 11 | await mkdtemp(async source => { 12 | await fs.writeFile(path.join(source, 'index.ts'), ` 13 | export interface Operands { 14 | readonly lhs: number; 15 | readonly rhs: number; 16 | } 17 | 18 | export class Hello { 19 | public add(ops: Operands): number { 20 | return ops.lhs + ops.rhs; 21 | } 22 | } 23 | `); 24 | 25 | await srcmak(source); 26 | }); 27 | }); 28 | 29 | test('compilation error fails and includes error message', async () => { 30 | await mkdtemp(async source => { 31 | await fs.writeFile(path.join(source, 'index.ts'), 'I DO NOT COMPUTE'); 32 | 33 | let error; 34 | try { await srcmak(source); } catch (e: any) { error = e; } 35 | 36 | expect(error).toBeDefined(); 37 | expect(error.message).toMatch(/Cannot find name 'COMPUTE'/); 38 | expect(error.message).toMatch(/Compilation errors prevented the JSII assembly/); 39 | }); 40 | }); 41 | 42 | test('python + different entrypoint + submodule', async () => { 43 | await mkdtemp(async source => { 44 | const entry = 'different/entry.ts'; 45 | const ep = path.join(source, entry); 46 | await fs.mkdirp(path.dirname(ep)); 47 | await fs.writeFile(ep, ` 48 | export interface Operands { 49 | readonly lhs: number; 50 | readonly rhs: number; 51 | } 52 | 53 | export class Hello { 54 | public add(ops: Operands): number { 55 | return ops.lhs + ops.rhs; 56 | } 57 | } 58 | `); 59 | 60 | await mkdtemp(async target => { 61 | await srcmak(source, { 62 | entrypoint: 'different/entry.ts', 63 | moduleKey: 'python.package', 64 | python: { 65 | outdir: target, 66 | moduleName: 'my_python_module.submodule', 67 | }, 68 | }); 69 | 70 | const dir = await snapshotDirectory(target, { 71 | excludeFiles: ['@0.0.0.jsii.tgz'], 72 | }); 73 | expect(dir).toMatchSnapshot(); 74 | }); 75 | }); 76 | }); 77 | 78 | test('java + different entrypoint', async () => { 79 | await mkdtemp(async source => { 80 | const entry = 'different/entry.ts'; 81 | const ep = path.join(source, entry); 82 | await fs.mkdirp(path.dirname(ep)); 83 | await fs.writeFile(ep, ` 84 | export interface Operands { 85 | readonly lhs: number; 86 | readonly rhs: number; 87 | } 88 | 89 | export class Hello { 90 | public add(ops: Operands): number { 91 | return ops.lhs + ops.rhs; 92 | } 93 | } 94 | `); 95 | 96 | await mkdtemp(async target => { 97 | await srcmak(source, { 98 | entrypoint: 'different/entry.ts', 99 | moduleKey: 'java.package', 100 | java: { 101 | outdir: target, 102 | package: 'hello.world', 103 | }, 104 | }); 105 | 106 | const dir = await snapshotDirectory(target, { 107 | excludeLines: [/.*@javax.annotation.Generated.*/], 108 | excludeFiles: ['@0.0.0.jsii.tgz'], 109 | }); 110 | expect(dir).toMatchSnapshot(); 111 | }); 112 | }); 113 | }); 114 | 115 | test('csharp + different entrypoint', async () => { 116 | await mkdtemp(async source => { 117 | const entry = 'different/entry.ts'; 118 | const ep = path.join(source, entry); 119 | await fs.mkdirp(path.dirname(ep)); 120 | await fs.writeFile(ep, ` 121 | export interface Operands { 122 | readonly lhs: number; 123 | readonly rhs: number; 124 | } 125 | 126 | export class Hello { 127 | public add(ops: Operands): number { 128 | return ops.lhs + ops.rhs; 129 | } 130 | } 131 | `); 132 | 133 | await mkdtemp(async target => { 134 | await srcmak(source, { 135 | entrypoint: 'different/entry.ts', 136 | moduleKey: 'csharp.package', 137 | csharp: { 138 | outdir: target, 139 | namespace: 'Hello.World', 140 | }, 141 | }); 142 | 143 | const dir = await snapshotDirectory(target, { 144 | excludeFiles: ['0.0.0.tgz'], 145 | }); 146 | expect(dir).toMatchSnapshot(); 147 | }); 148 | }); 149 | }); 150 | 151 | test('golang + different entrypoint', async () => { 152 | await mkdtemp(async source => { 153 | const entry = 'different/entry.ts'; 154 | const ep = path.join(source, entry); 155 | await fs.mkdirp(path.dirname(ep)); 156 | await fs.writeFile(ep, ` 157 | export interface Operands { 158 | readonly lhs: number; 159 | readonly rhs: number; 160 | } 161 | 162 | export class Hello { 163 | public add(ops: Operands): number { 164 | return ops.lhs + ops.rhs; 165 | } 166 | } 167 | `); 168 | 169 | await mkdtemp(async target => { 170 | await srcmak(source, { 171 | entrypoint: 'different/entry.ts', 172 | moduleKey: 'gopackage', 173 | golang: { 174 | outdir: target, 175 | moduleName: 'github.com/org/repo', 176 | packageName: 'hello', 177 | }, 178 | }); 179 | 180 | const dir = await snapshotDirectory(target, { 181 | excludeFiles: ['0.0.0.tgz'], 182 | }); 183 | expect(dir).toMatchSnapshot(); 184 | }); 185 | }); 186 | }); 187 | 188 | test('deps: compile against a local jsii dependency', async () => { 189 | await mkdtemp(async source => { 190 | await fs.writeFile(path.join(source, 'index.ts'), ` 191 | import { Construct } from 'constructs'; 192 | 193 | export class Hello extends Construct { 194 | public add(lhs: number, rhs: number): number { 195 | return lhs + rhs; 196 | } 197 | } 198 | `); 199 | 200 | await srcmak(source, { 201 | deps: [ 202 | path.dirname(require.resolve('constructs/package.json')), // <<---- this is the magic 203 | ], 204 | }); 205 | }); 206 | }); 207 | 208 | test('outputJsii can be used to look at the jsii file', async () => { 209 | await mkdtemp(async source => { 210 | await fs.writeFile(path.join(source, 'index.ts'), ` 211 | export class Foo { 212 | public static hello() { return "world"; } 213 | } 214 | `); 215 | 216 | await mkdtemp(async target => { 217 | const outputPath = path.join(target, '.jsii'); 218 | await srcmak(source, { jsii: { path: outputPath } }); 219 | expect(await fs.readJson(outputPath)).toMatchSnapshot(); 220 | }); 221 | }); 222 | }); 223 | 224 | test('java with invalid package', async () => { 225 | await expect(srcmak('.', { 226 | entrypoint: 'different/entry.ts', 227 | moduleKey: 'java.package', 228 | java: { 229 | outdir: '.', 230 | package: 'hello-world', 231 | }, 232 | })).rejects.toEqual(new Error('Java package [hello-world] may not contain "-"')); 233 | }); 234 | 235 | test('python with invalid module name', async () => { 236 | await expect(srcmak('.', { 237 | entrypoint: 'different/entry.ts', 238 | moduleKey: 'python.package', 239 | python: { 240 | outdir: '.', 241 | moduleName: 'my-python.submodule', 242 | }, 243 | })).rejects.toEqual(new Error('Python moduleName [my-python.submodule] may not contain "-"')); 244 | }); 245 | 246 | test('csharp with invalid namespace', async () => { 247 | await expect(srcmak('.', { 248 | entrypoint: 'different/entry.ts', 249 | moduleKey: 'csharp.package', 250 | csharp: { 251 | outdir: '.', 252 | namespace: 'hello-world', 253 | }, 254 | })).rejects.toEqual(new Error('C# namespace [hello-world] may not contain "-"')); 255 | }); -------------------------------------------------------------------------------- /test/util.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | import * as fs from 'fs-extra'; 3 | 4 | interface SnapshotOptions { 5 | excludeLines?: RegExp[]; 6 | excludeFiles?: string[]; 7 | } 8 | 9 | /** 10 | * Returns a dictionary where keys are relative file names and values are the 11 | * file contents. Useful to perform snapshot testing against full directories. 12 | */ 13 | export async function snapshotDirectory(basedir: string, excludeOptions: SnapshotOptions = {}, reldir = '.'): Promise> { 14 | const result: Record = { }; 15 | const absdir = path.join(basedir, reldir); 16 | const { excludeLines, excludeFiles } = excludeOptions; 17 | for (const file of await fs.readdir(absdir)) { 18 | let skip = false; 19 | excludeFiles?.forEach((excludeFile) => { 20 | if (file.includes(excludeFile)) { 21 | skip = true; 22 | } 23 | }); 24 | if (skip) { 25 | continue; 26 | } 27 | 28 | const abspath = path.join(absdir, file); 29 | const relpath = path.join(reldir, file); 30 | 31 | if ((await fs.stat(abspath)).isDirectory()) { 32 | const subdir = await snapshotDirectory(basedir, excludeOptions, relpath); 33 | for (const [k, v] of Object.entries(subdir)) { 34 | result[k] = v; 35 | } 36 | continue; 37 | } 38 | 39 | let data = await fs.readFile(abspath, 'utf-8'); 40 | for (const excludeLine of excludeLines || []) { 41 | data = data.replace(excludeLine, ''); 42 | } 43 | 44 | result[relpath] = data; 45 | } 46 | 47 | return result; 48 | } -------------------------------------------------------------------------------- /tsconfig.dev.json: -------------------------------------------------------------------------------- 1 | // ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | { 3 | "compilerOptions": { 4 | "alwaysStrict": true, 5 | "declaration": true, 6 | "esModuleInterop": true, 7 | "experimentalDecorators": true, 8 | "inlineSourceMap": true, 9 | "inlineSources": true, 10 | "lib": [ 11 | "es2019" 12 | ], 13 | "module": "CommonJS", 14 | "noEmitOnError": false, 15 | "noFallthroughCasesInSwitch": true, 16 | "noImplicitAny": true, 17 | "noImplicitReturns": true, 18 | "noImplicitThis": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "resolveJsonModule": true, 22 | "strict": true, 23 | "strictNullChecks": true, 24 | "strictPropertyInitialization": true, 25 | "stripInternal": true, 26 | "target": "ES2019" 27 | }, 28 | "include": [ 29 | "src/**/*.ts", 30 | "test/**/*.ts", 31 | ".projenrc.ts", 32 | "projenrc/**/*.ts" 33 | ], 34 | "exclude": [ 35 | "node_modules" 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | // ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | { 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "lib", 6 | "alwaysStrict": true, 7 | "declaration": true, 8 | "esModuleInterop": true, 9 | "experimentalDecorators": true, 10 | "inlineSourceMap": true, 11 | "inlineSources": true, 12 | "lib": [ 13 | "es2019" 14 | ], 15 | "module": "CommonJS", 16 | "noEmitOnError": false, 17 | "noFallthroughCasesInSwitch": true, 18 | "noImplicitAny": true, 19 | "noImplicitReturns": true, 20 | "noImplicitThis": true, 21 | "noUnusedLocals": true, 22 | "noUnusedParameters": true, 23 | "resolveJsonModule": true, 24 | "strict": true, 25 | "strictNullChecks": true, 26 | "strictPropertyInitialization": true, 27 | "stripInternal": true, 28 | "target": "ES2019" 29 | }, 30 | "include": [ 31 | "src/**/*.ts" 32 | ], 33 | "exclude": [] 34 | } 35 | -------------------------------------------------------------------------------- /version.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.255" 3 | } 4 | --------------------------------------------------------------------------------