Jack Hsu d39624cbb1
feat(js): @nx/js:init generator does not generate prettier and tsconfig.base.json files by default (#27406)
In order to use `nx release` you must run `nx add @nx/js`. However, the
init generator will add Prettier and `tsconfig.base.json` files by
default, which is not what the user wants.

This PR adds two options:
- `addTsConfigBase` - generates `tsconfig.base.json` when `true`.
Default to`false`
- `setUpPrettier` - adds `prettier` and generates `.prettierrc` and
`.prettierignore` files when `true`. Defaults to `false`.

The programmatic `initGenerator` API defaults both options to `true` to
usages remain unaffected.

The one behavior change is if users run `nx g @nx/js:init` then the two
options default to `false`. However, since this is an internal API, the
actual usages should be through `nx add` or the programmatic API.



<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-08-14 09:08:56 -04:00

61 lines
1.8 KiB
JSON

{
"name": "init",
"factory": "./src/generators/init/init#initGenerator",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxTypescriptInit",
"cli": "nx",
"title": "Init nx/js",
"description": "Init generator placeholder for nx/js.",
"properties": {
"js": {
"type": "boolean",
"default": false,
"description": "Use JavaScript instead of TypeScript"
},
"skipFormat": {
"type": "boolean",
"aliases": ["skip-format"],
"description": "Skip formatting files.",
"x-priority": "internal"
},
"skipPackageJson": {
"type": "boolean",
"description": "Skip adding package.json dependencies",
"x-priority": "internal"
},
"keepExistingVersions": {
"type": "boolean",
"x-priority": "internal",
"description": "Keep existing dependencies versions",
"default": false
},
"addTsConfigBase": {
"type": "boolean",
"description": "Add a base tsconfig file to the workspace.",
"x-priority": "internal",
"default": false
},
"tsConfigName": {
"type": "string",
"description": "Customize the generated base tsconfig file name.",
"x-priority": "internal"
},
"setUpPrettier": {
"type": "boolean",
"description": "Add Prettier and corresponding configuration files.",
"x-priority": "internal",
"default": false
}
},
"presets": []
},
"aliases": ["lib"],
"x-type": "init",
"description": "Initialize a TS/JS workspace.",
"hidden": true,
"implementation": "/packages/js/src/generators/init/init#initGenerator.ts",
"path": "/packages/js/src/generators/init/schema.json",
"type": "generator"
}