From 6e00874c9a70890b9291a4fa534eb497e7a186f9 Mon Sep 17 00:00:00 2001 From: Momo Kornher Date: Mon, 20 May 2024 10:03:40 +0100 Subject: [PATCH] fix(jsii-config): update jsii-config and docs with latest settings (#4515) Updates jsii-config and the website with the latest settings for user-provided TypeScript configs. The update to jsii-config includes some other changes that have previously been missed, including support for go and fixing a the outdir configuration. --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0 --- .../lib-author/configuration/index.md | 123 +++++++++++++----- .../content/user-guides/lib-author/index.md | 20 +-- .../user-guides/lib-author/toolchain/jsii.md | 18 ++- gh-pages/partials/tsconfig-rulesets.md | 11 ++ packages/jsii-config/lib/prompt.ts | 6 +- packages/jsii-config/lib/questions.ts | 24 +++- packages/jsii-config/lib/schema.ts | 98 ++++++++++++-- packages/jsii-config/package.json | 1 + packages/jsii-config/test/index.test.ts | 120 ++++++++++++++--- 9 files changed, 346 insertions(+), 75 deletions(-) create mode 100644 gh-pages/partials/tsconfig-rulesets.md diff --git a/gh-pages/content/user-guides/lib-author/configuration/index.md b/gh-pages/content/user-guides/lib-author/configuration/index.md index 34515cc1b8..bc4333b8c3 100644 --- a/gh-pages/content/user-guides/lib-author/configuration/index.md +++ b/gh-pages/content/user-guides/lib-author/configuration/index.md @@ -17,8 +17,8 @@ optional in the standard [package.json schema] are required by `jsii`. For example, Maven Central requires packages to carry [sufficient metadata], such as _developer information_ and _license_, in order to be valid for publishing. -| Field | Required | Extensions | -| ------------ |:-------------------------------:| -------------------------------- | +| Field | Required | Extensions | +| ------------ | :-----------------------------: | -------------------------------- | | `author` | :octicons-check-circle-fill-24: | `author.organization` | | `license` | :octicons-check-circle-fill-24: | | | `main` | :octicons-check-circle-fill-24: | | @@ -135,32 +135,20 @@ package maintainer, the generic interpretation for those on packages is: In order to configure the behavior of `jsii`, the `package.json` file must include a `jsii` section that can contain the following entries: -| Field | Type | Required | Default | -| ------------------- | ----------------------- |:-------------------------------:| ------------------------------------ | -| `excludeTypescript` | `#!ts string[]` | | _none_ | -| `metadata` | `#!ts object` | | _none_ | -| `projectReferences` | `#!ts boolean` | | `#!ts true` | -| `targets` | `#!ts object` | :octicons-check-circle-fill-24: | | -| `tsc` | `#!ts object` | | `#!ts { outDir: '.', rootDir: '.' }` | -| `versionFormat` | `#!ts 'short' | 'full'` | | `#!ts 'full'` | +| Field | Type | Required | Default | Supported versions | +| ------------------- | ---------------------------------------------- | :-----------------------------: | ------------------------------------ | ------------------ | +| `excludeTypescript` | `#!ts string[]` | | _none_ | _all_ | +| `metadata` | `#!ts object` | | _none_ | _all_ | +| `projectReferences` | `#!ts boolean` | | `#!ts true` | _all_ | +| `targets` | `#!ts object` | :octicons-check-circle-fill-24: | | _all_ | +| `tsc` | `#!ts object` | | `#!ts { outDir: '.', rootDir: '.' }` | _all_ | +| `tsconfig` | `#!ts string` | | _none_ | `>= 5.2` | +| `validateTsconfig` | `#!ts 'strict'\|'generated'\|'minimal'\|'off'` | | _none_ | `>= 5.2` | +| `versionFormat` | `#!ts 'short'\|'full'` | | `#!ts 'full'` | _all_ | -### `excludeTypescript` +### Language targets -By default, `jsii` will include _all_ `*.ts` files (except `.d.ts` files) in the `TypeScript` compiler input. This can -be problematic for example when the package's build or test procedure generates `.ts` files that cannot be compiled with -`jsii`'s compiler settings. - -The `excludeTypescript` configuration accepts a list of glob patterns. Files matching any of those patterns will be -excluded from the `TypeScript` compiler input. - -### `metadata` - -The `metadata` section can be used to record additional metadata as key-value pairs that will be recorded as-is into the -`.jsii` assembly file. That metadata can later be inspected using [`jsii-reflect`][jsii-reflect] utilities, for example. - -[jsii-reflect]: https://github.com/aws/jsii/tree/main/packages/jsii-reflect - -### `targets` +#### `targets` The `targets` section is where `jsii` packages define which target languages they support. This provides the package generators with the additional information they require in order to name generated artifacts. Configuration is provided @@ -173,7 +161,31 @@ The specific configuration accepted for each supported language is presented in - [:octicons-book-24: Java Target](targets/java.md) - [:octicons-book-24: Python Target](targets/python.md) -### `tsc` +### Typescript configuration + +By default, `jsii` generates a `tsconfig.json` for you, using best practice settings that are optimized for +widespread support and backwards compatibility. Use the `excludeTypescript` and `tsc` settings to configure +some supported typescript compiler options. + +You may want to customize the typescript configuration even further. In this case, use the `tsconfig` setting +to instruct the jsii compiler to use user-owned typescript configuration file. Such a user-provider tsconfig must +follow certain rules to be a valid config for use with jsii. These rules are enforced via the `validateTsconfig` +setting. You may choose the level of validation to match your use case. + +!!! info + Using a user-provider tsconfig and configuration via `excludeTypescript` and `tsc` are mutually exclusive. + Specifically when using a user-provided tsconfig, any other configuration settings will be ignored. + +#### `excludeTypescript` + +By default, `jsii` will include _all_ `*.ts` files (except `.d.ts` files) in the `TypeScript` compiler input. This can +be problematic for example when the package's build or test procedure generates `.ts` files that cannot be compiled with +`jsii`'s compiler settings. + +The `excludeTypescript` configuration accepts a list of glob patterns. Files matching any of those patterns will be +excluded from the `TypeScript` compiler input. + +#### `tsc` In order to the generated `javascript` can be properly loaded by the `jsii` runtimes, `jsii` generates a [`tsconfig.json`] file with fixed settings at the beginning of the compilation pass. Certain configuration options can @@ -188,11 +200,11 @@ are set in the `jsii.tsc` section of the `package.json` file, but use the same n - `forceConsistentCasingInFileNames` - if `true`, will make the `TypeScript` compiler care about the casing of files specified in `import` statements. This is helpful if you're developing on a filesystem that is case-insensitive (Mac/Win), but building/deploying on a filesystem that is case-sensitive (Linux). -- `declarationMap`, `inlineSourceMap`, `inlineSources`, and `sourceMap` allow confifuring the source map generation. +- `declarationMap`, `inlineSourceMap`, `inlineSources`, and `sourceMap` allow configuring the source map generation. This option can be useful to finely control your local development experience (for example, by enabling `declarationMap`), or to optimize the emitted code size (by disabling source maps entirely). - + if any of these options is specified, the source map configuration will exactly match what is being provided here - + If none are specified, the default settings will be used: `#!ts { inlineSourceMap: true, inlineSources: true }` + - if any of these options is specified, the source map configuration will exactly match what is being provided here + - If none are specified, the default settings will be used: `#!ts { inlineSourceMap: true, inlineSources: true }` - `types` allows limiting which visible type libraries get loaded in the global scope by the typescript compiler. By default, all visible `@types/*` packages will be loaded, which can be undesirable (in particular in monorepos, where some type libraries are not compatible with the TypeScript compiler version that `jsii` uses). The value specified @@ -204,7 +216,55 @@ Refer to the [TypeScript compiler options reference][ts-options] for more inform [`tsconfig.json`]: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html [ts-options]: https://www.typescriptlang.org/docs/handbook/compiler-options.html -### `versionFormat` +#### `tsconfig` _(available from jsii >= 5.2)_ + +!!! warn + :test_tube: This features is experimental. Behavior may change as bugs are addressed, and requirements are clarified + through early adopters. Use at your own risk, and please any [report bugs]. + +Provide this setting, to use a user-provided typescript configuration with `jsii`. Set to the name of the tsconfig +file that should be used. Usually this will be `"tsconfig.json"`, but can be set to any filename. +The provided tsconfig is subject to validation rules, see below for more details. + +```json +{ + "jsii": { + "tsconfig": "tsconfig.json" + } +} +``` + +#### :test_tube: `validateTsconfig` _(available from jsii >= 5.2)_ + +!!! warn + :test_tube: This features is experimental. Behavior may change as bugs are addressed, and requirements are clarified + through early adopters. Use at your own risk, and please any [report bugs]. + +A user-provider typescript config must follow certain rules to be a valid config for use with jsii. +By default the tsconfig is validated against the `strict` rule set. +If needed, you can change the level of enforcement with the `validateTsconfig` setting. + +--8<-- "partials/tsconfig-rulesets.md" + +```json +{ + "jsii": { + "tsconfig": "tsconfig.json", + "validateTsconfig": "generated" // ensure user tsconfig is similar to jsii-generated tsconfig + } +} +``` + +### Metadata + +#### `metadata` + +The `metadata` section can be used to record additional metadata as key-value pairs that will be recorded as-is into the +`.jsii` assembly file. That metadata can later be inspected using [`jsii-reflect`][jsii-reflect] utilities, for example. + +[jsii-reflect]: https://github.com/aws/jsii/tree/main/packages/jsii-reflect + +#### `versionFormat` Determines the format of the `jsii` toolchain version string that will be included in the `.jsii` assembly file's `jsiiVersion` attribute. @@ -270,3 +330,4 @@ modules, **must** also be referenced in the [`bundledDependencies`][npm-bundled] within the NPM package. [npm-bundled]: https://docs.npmjs.com/files/package.json#bundleddependencies +[report bugs]: https://github.com/aws/jsii/issues/new/choose diff --git a/gh-pages/content/user-guides/lib-author/index.md b/gh-pages/content/user-guides/lib-author/index.md index fdf52ab1c0..517f620878 100644 --- a/gh-pages/content/user-guides/lib-author/index.md +++ b/gh-pages/content/user-guides/lib-author/index.md @@ -14,13 +14,12 @@ must be available. Current `node` runtime versions support status is as follows: When developing _jsii modules_, the SDK for each desired target language must be available for `jsii-pacmak` to be able to produce releasable artifacts. -| Language/Platform | SDK Requirement | -| ----------------- | ---------------------------- | -| .NET | .NET ≥ 6.0 | -| Go | Go ≥ 1.18 | -| Java | JDK ≥ 8 *and* Maven ≥ 3.6 | -| Python | Python ≥ 3.8 | - +| Language/Platform | SDK Requirement | +| ----------------- | ------------------------- | +| .NET | .NET ≥ 6.0 | +| Go | Go ≥ 1.18 | +| Java | JDK ≥ 8 _and_ Maven ≥ 3.6 | +| Python | Python ≥ 3.8 | ## :octicons-desktop-download-24: Download Locations @@ -28,13 +27,14 @@ This table provides typical download locations for the prerequisites mentioned i also be installed using traditional package managers (standard for the operating system and platform). | Tool | Description | Location | -| --------------- | ---------------------------------------- | ------------------------| +| --------------- | ---------------------------------------- | ----------------------- | | .NET | Official Microsoft .NET SDK distribution | [Download][dl-dotnet] | | Amazon Corretto | Amazon's free OpenJDK distribution | [Download][dl-corretto] | | Go | Official Go distribution | [Download][dl-go] | -| OpenJDK | Oracle OpenJDK distribution | [Download][dl-openjdk] | | Maven | Official Maven distribution | [Download][dl-mvn] | -| Node | Official NodeJS distribution | [Download][dl-node] | +| Node | Official Node.js distribution | [Download][dl-node] | +| OpenJDK | Oracle OpenJDK distribution | [Download][dl-openjdk] | +| Python | Official Python distribution | [Download][dl-python] | [dl-dotnet]: https://dotnet.microsoft.com/download [dl-go]: https://golang.org/dl/ diff --git a/gh-pages/content/user-guides/lib-author/toolchain/jsii.md b/gh-pages/content/user-guides/lib-author/toolchain/jsii.md index b27402d996..5f546290ef 100644 --- a/gh-pages/content/user-guides/lib-author/toolchain/jsii.md +++ b/gh-pages/content/user-guides/lib-author/toolchain/jsii.md @@ -59,6 +59,22 @@ reserved words in an identifier. [report bugs]: https://github.com/aws/jsii/issues/new/choose +#### `--tsconfig`, `--validate-tsconfig` _(available from jsii >= 5.2)_ + +By default, jsii will generate a `tsconfig.json` for you, using best practice +settings that are optimized for widespread support and backwards compatibility. +In some situations it can be useful to provide a custom typescript +configuration file to compile the jsii project. + +Use the `--tsconfig` option to provide a path the config file, usually this +will be `--tsconfig=tsconfig.json`. + +A user-provider typescript config must follow certain rules to be a valid +config for use with jsii. These rules are enforced by the `--validate-tsconfig` +option. You may choose the level of validation to suit your use case. + +--8<-- "partials/tsconfig-rulesets.md" + #### `--strip-deprecated` The `--strip-deprecated` option modifies the compilation flow such that all @@ -105,4 +121,4 @@ or `quiet` to either fail at runtime or silence these warnings, respectively. By default, this is set to `warn`. The `JSII_DEPRECATED` environment variable is respected only on modules compiled -with the `--add-deprecated-warnings` flag. \ No newline at end of file +with the `--add-deprecated-warnings` flag. diff --git a/gh-pages/partials/tsconfig-rulesets.md b/gh-pages/partials/tsconfig-rulesets.md new file mode 100644 index 0000000000..b184b5c6ae --- /dev/null +++ b/gh-pages/partials/tsconfig-rulesets.md @@ -0,0 +1,11 @@ +| Rule set | Description | +| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `strict` :star: | (Default) Validates the provided config against a strict rule set designed for widespread support and backwards-compatibility. | +| `generated` | Enforces a tsconfig as if it were generated by jsii. Use this to stay compatible with the generated config, but have full ownership over the file. | +| `minimal` :warn: | Only reject options that are known to be incompatible with jsii. This rule set is likely to be incomplete and new rules will be added without notice as incompatibilities are discovered. | +| `off` :warn: | Disables all config validation, including options that are known to be incompatible with jsii. Intended for experimentation only. Use at your own risk. | + +:star: Recommended setting +:warn: Resulting jsii assembly/package may be incompatible with wider ecosystem + +There is currently no easy way to inspect these rule sets, however detailed error messages are returned if a provided tsconfig fails validation. diff --git a/packages/jsii-config/lib/prompt.ts b/packages/jsii-config/lib/prompt.ts index ba8d3640b3..bd178345a3 100644 --- a/packages/jsii-config/lib/prompt.ts +++ b/packages/jsii-config/lib/prompt.ts @@ -29,7 +29,11 @@ export default async function getAnswers( const answers = (await inquirer.prompt( getQuestions(current), )) as PromptAnswers; - const { jsiiTargets: _, ...config } = removeEmptyValues(answers); + const { + jsiiTargets: _1, + tsconfig: _2, + ...config + } = removeEmptyValues(answers); const confirmInput = await inquirer.prompt({ type: 'confirm', message: `Confirm Jsii Config\n${JSON.stringify( diff --git a/packages/jsii-config/lib/questions.ts b/packages/jsii-config/lib/questions.ts index 744e1ef0b3..8f54cba8f4 100644 --- a/packages/jsii-config/lib/questions.ts +++ b/packages/jsii-config/lib/questions.ts @@ -1,4 +1,4 @@ -import { QuestionCollection } from 'inquirer'; +import { QuestionCollection, Separator } from 'inquirer'; import schema, { ConfigPromptsSchema, BasePackageJson } from './schema'; import { getNestedValue, flattenKeys } from './util'; @@ -55,8 +55,28 @@ function buildQuestions( choices: Object.keys(schema.jsii.targets), default: Object.keys(currentTargets), }; + const tsconfigPrompt: QuestionCollection = { + name: 'tsconfig', + message: + 'Typescript config - should jsii generate a compatible tsconfig or do you want to manage it yourself', + type: 'list', + choices: [ + 'jsii-managed', + new Separator('tsconfig will be managed and generated for you by jsii'), + new Separator(), + 'user-provided', + new Separator( + 'bring your own user-provided tsconfig for advanced setups', + ), + ], + default: 'jsii-managed', + }; - return [targetsPrompt, ...flattenNestedQuestions(schema, current)]; + return [ + targetsPrompt, + tsconfigPrompt, + ...flattenNestedQuestions(schema, current), + ]; } export default (current: BasePackageJson) => buildQuestions(schema, current); diff --git a/packages/jsii-config/lib/schema.ts b/packages/jsii-config/lib/schema.ts index 9b51491e67..86e39fa6ac 100644 --- a/packages/jsii-config/lib/schema.ts +++ b/packages/jsii-config/lib/schema.ts @@ -44,6 +44,20 @@ const targetEnabled = (target: string) => (answers: any) => { return Boolean(answers.jsiiTargets.includes(target)); }; +/* + * A condition to ask for specific values user-provided tsconfig values when enabled + */ +const userProvidedConfig = (answers: any) => { + return Boolean(answers.tsconfig === 'user-provided'); +}; + +/* + * A condition to ask for specific values jsii-managed tsconfig values when enabled + */ +const jsiiManagedConfig = (answers: any) => { + return Boolean(answers.tsconfig !== 'user-provided'); +}; + /* * Validates that user input has length */ @@ -70,17 +84,11 @@ const schema: ConfigPromptsSchema = { types: { type: 'input', message: - 'Jsii Type Definitions - compiled typescript definitions file for module (e.g. "index.d.ts")', + 'Jsii Type Definitions - compiled typescript definitions file for module', validate: hasLength, + default: 'index.d.ts', }, jsii: { - outdir: { - type: 'input', - message: - 'Output Directory - Location for typescript compiler output (e.g. "dist")', - default: 'dist', - validate: hasLength, - }, versionFormat: { type: 'list', message: @@ -89,13 +97,14 @@ const schema: ConfigPromptsSchema = { choices: [ 'full', new Separator( - 'version number including a commit hash (e.g. "0.14.3 will be used"', + 'version number including a commit hash (e.g. "0.14.3#2a19bf8") will be used"', ), new Separator(), 'short', new Separator( - 'only the version number of jsii will be used (e.g. "0.14.3"', + 'only the version number of jsii will be used (e.g. "0.14.3")', ), + new Separator(), ], }, targets: { @@ -180,6 +189,75 @@ const schema: ConfigPromptsSchema = { }, }, }, + go: { + packageName: { + type: 'input', + message: + 'Go Package Name - optional name of the go package. If not specified, package name will be derived from the JavaScript module name by removing non-alphanumeric characters (e.g. @aws-cdk/aws-s3 will be awscdkawss3).', + when: targetEnabled('go'), + validate: hasLength, + }, + moduleName: { + type: 'input', + message: + 'Go Module Name - the name of the target repository in which this module will be published (e.g. github.com/foo/bar). The module itself will always be published under a subdirectory named according to the Go package name of the module.', + when: targetEnabled('go'), + validate: hasLength, + }, + versionSuffix: { + type: 'input', + message: + 'go Version Suffix - optional suffix that will be appended at the end of the module version, must begin with a "-" (e.g. "-devpreview")', + when: targetEnabled('go'), + }, + }, + }, + tsc: { + outDir: { + type: 'input', + message: 'Output Directory - Location for typescript compiler output', + default: 'dist', + when: jsiiManagedConfig, + validate: hasLength, + }, + }, + + tsconfig: { + type: 'input', + message: + 'TS config file - use this typescript configuration file to compile the jsii project', + default: 'tsconfig.json', + when: userProvidedConfig, + validate: hasLength, + }, + validateTsconfig: { + type: 'list', + message: + 'TS config validation - validates the provided typescript configuration file against a set of rules', + when: userProvidedConfig, + default: 'strict', + choices: [ + 'strict', + new Separator( + 'Validates the provided config against a strict rule set designed for widespread support and backwards-compatibility.', + ), + new Separator(), + 'generated', + new Separator( + 'Enforces a tsconfig as if it were generated by jsii. Use this to stay compatible with the generated config, but have full ownership over the file.', + ), + new Separator(), + 'minimal', + new Separator( + 'Only enforce options that are known to be incompatible with jsii. This rule set is likely to be incomplete and new rules will be added without notice as incompatibilities emerge.', + ), + new Separator(), + 'off', + new Separator( + 'Disables all config validation, including options that are known to be incompatible with jsii. Intended for experimentation only. Use at your own risk.', + ), + new Separator(), + ], }, }, }; diff --git a/packages/jsii-config/package.json b/packages/jsii-config/package.json index 8db1c9e015..825632fc62 100644 --- a/packages/jsii-config/package.json +++ b/packages/jsii-config/package.json @@ -8,6 +8,7 @@ "license": "Apache-2.0", "scripts": { "build": "tsc --build && npm run lint", + "build+test": "tsc --build && yarn test", "watch": "tsc --build -w", "lint": "ESLINT_USE_FLAT_CONFIG=false eslint . --ext .js,.ts --ignore-path=.gitignore --ignore-pattern=test/negatives/*", "lint:fix": "yarn lint --fix", diff --git a/packages/jsii-config/test/index.test.ts b/packages/jsii-config/test/index.test.ts index 02561e2fe6..49122ae1e8 100644 --- a/packages/jsii-config/test/index.test.ts +++ b/packages/jsii-config/test/index.test.ts @@ -84,6 +84,69 @@ describe('jsii-config', () => { }); }); + describe('user-provided tsconfig', () => { + const configAnswers = { + tsconfig: 'user-provided', + stability: 'experimental', + types: 'index.d.ts', + jsii: { + versionFormat: 'short', + tsconfig: 'tsconfig.dev.json', + validateTsconfig: 'generated', + }, + }; + + beforeEach(() => { + promptMock + .mockResolvedValueOnce({ + jsiiTargets: [], + ...configAnswers, + }) + .mockResolvedValueOnce({ + confirm: true, + }); + + readJsonMock.mockImplementation((_path, cb) => { + cb(null, Buffer.from(JSON.stringify(packageJsonObject))); + }); + }); + + it('prompts for tsc.outDir only when jsii-managed tsconfig is enabled', async () => { + await jsiiConfig('./package.json'); + const enabled = { tsconfig: 'jsii-managed' }; + const disabled = { tsconfig: 'user-provided' }; + const questions = promptMock.mock.calls[0][0]; + const subject = findQuestions(['jsii.tsc.outDir'], questions); + + subject.forEach((question: any) => { + expect(question.when(enabled)).toBe(true); + }); + + subject.forEach((question: any) => { + expect(question.when(disabled)).toBe(false); + }); + }); + + it('prompts for user-provided tsconfig settings only when user-provided tsconfig is enabled', async () => { + await jsiiConfig('./package.json'); + const enabled = { tsconfig: 'user-provided' }; + const disabled = { tsconfig: 'jsii-managed' }; + const questions = promptMock.mock.calls[0][0]; + const subject = findQuestions( + ['jsii.tsconfig', 'jsii.validateTsconfig'], + questions, + ); + + subject.forEach((question: any) => { + expect(question.when(enabled)).toBe(true); + }); + + subject.forEach((question: any) => { + expect(question.when(disabled)).toBe(false); + }); + }); + }); + describe('no existing jsii configuration', () => { const configAnswers = { stability: 'experimental', @@ -128,16 +191,18 @@ describe('jsii-config', () => { it('prompts user for top level jsii config and language targets', async () => { await jsiiConfig('./package.json'); const questions = promptMock.mock.calls[0][0]; - const [stability, types, outdir, versionFormat, targets] = findQuestions( - [ - 'stability', - 'types', - 'jsii.outdir', - 'jsii.versionFormat', - 'jsiiTargets', - ], - questions, - ); + const [stability, types, tscOutDir, versionFormat, targets, tsconfig] = + findQuestions( + [ + 'stability', + 'types', + 'jsii.tsc.outDir', + 'jsii.versionFormat', + 'jsiiTargets', + 'tsconfig', + ], + questions, + ); expect(stability).toHaveProperty('type', 'list'); expect(stability).toHaveProperty('choices', [ 'deprecated', @@ -148,17 +213,26 @@ describe('jsii-config', () => { expect(stability).toHaveProperty('default', 'experimental'); expect(types).toHaveProperty('type', 'input'); - expect(types).not.toHaveProperty('default'); + expect(types).toHaveProperty('default', 'index.d.ts'); - expect(outdir).toHaveProperty('type', 'input'); - expect(outdir).toHaveProperty('default', 'dist'); + expect(tscOutDir).toHaveProperty('type', 'input'); + expect(tscOutDir).toHaveProperty('default', 'dist'); expect(versionFormat).toHaveProperty('type', 'list'); expect(versionFormat.choices).toContain('full'); expect(versionFormat.choices).toContain('short'); expect(targets).toHaveProperty('type', 'checkbox'); - expect(targets).toHaveProperty('choices', ['java', 'python', 'dotnet']); + expect(targets).toHaveProperty('choices', [ + 'java', + 'python', + 'dotnet', + 'go', + ]); + + expect(tsconfig).toHaveProperty('type', 'list'); + expect(tsconfig.choices).toContain('jsii-managed'); + expect(tsconfig.choices).toContain('user-provided'); }); it('prompts for java specific values when only target enabled', async () => { @@ -243,7 +317,7 @@ describe('jsii-config', () => { [ 'types', - 'jsii.outdir', + 'jsii.tsc.outDir', 'jsii.targets.java.package', 'jsii.targets.java.maven.groupId', 'jsii.targets.java.maven.artifactId', @@ -282,7 +356,9 @@ describe('jsii-config', () => { stability: 'experimental', types: 'TYPES', jsii: { - outdir: 'OUTDIR', + tsc: { + outDir: 'OUTDIR', + }, versionFormat: 'short', targets: { java: { @@ -313,7 +389,9 @@ describe('jsii-config', () => { stability: 'stable', types: 'new_types.d.ts', jsii: { - outdir: 'dist', + tsc: { + outDir: 'dist', + }, versionFormat: 'short', }, }; @@ -342,7 +420,7 @@ describe('jsii-config', () => { jsiiTargets: ['java', 'dotnet', 'python'], stability: 'experimental', types: 'TYPES', - ['jsii.outdir']: 'OUTDIR', + ['jsii.tsc.outDir']: 'OUTDIR', ['jsii.versionFormat']: 'short', ['jsii.targets.java.package']: 'JAVA_PACKAGE', ['jsii.targets.java.maven.groupId']: 'JAVA_MAVEN_GROUPID', @@ -383,7 +461,9 @@ describe('jsii-config', () => { const answers = { jsiiTargets: ['python'], jsii: { - outdir: 'OUTDIR', + tsc: { + outDir: 'OUTDIR', + }, versionFormat: 'short', targets: { python: { @@ -414,7 +494,7 @@ describe('jsii-config', () => { await jsiiConfig('./package.json'); const defaultMap: { [key: string]: any } = { jsiiTargets: ['python'], - ['jsii.outdir']: 'OUTDIR', + ['jsii.tsc.outDir']: 'OUTDIR', ['jsii.versionFormat']: 'short', ['jsii.targets.python.distName']: 'PYTHON_DISTNAME', ['jsii.targets.python.module']: 'PYTHON_MODULE',