@nx/workspace 16.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE +22 -0
- package/README.md +61 -0
- package/executors.json +11 -0
- package/generators.d.ts +5 -0
- package/generators.js +14 -0
- package/generators.js.map +1 -0
- package/generators.json +92 -0
- package/index.d.ts +21 -0
- package/index.js +52 -0
- package/index.js.map +1 -0
- package/migrations.json +165 -0
- package/package.json +90 -0
- package/presets/core.json +11 -0
- package/presets/npm.json +7 -0
- package/src/core/file-utils.d.ts +1 -0
- package/src/core/file-utils.js +5 -0
- package/src/core/file-utils.js.map +1 -0
- package/src/core/project-graph.d.ts +1 -0
- package/src/core/project-graph.js +5 -0
- package/src/core/project-graph.js.map +1 -0
- package/src/executors/counter/counter.impl.d.ts +12 -0
- package/src/executors/counter/counter.impl.js +48 -0
- package/src/executors/counter/counter.impl.js.map +1 -0
- package/src/executors/counter/schema.json +20 -0
- package/src/generators/ci-workflow/ci-workflow.d.ts +6 -0
- package/src/generators/ci-workflow/ci-workflow.js +46 -0
- package/src/generators/ci-workflow/ci-workflow.js.map +1 -0
- package/src/generators/ci-workflow/files/azure/azure-pipelines.yml__tmpl__ +58 -0
- package/src/generators/ci-workflow/files/bitbucket-pipelines/bitbucket-pipelines.yml__tmpl__ +36 -0
- package/src/generators/ci-workflow/files/circleci/.circleci/config.yml__tmpl__ +73 -0
- package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml__tmpl__ +29 -0
- package/src/generators/ci-workflow/files/gitlab/.gitlab-ci.yml__tmpl__ +47 -0
- package/src/generators/ci-workflow/schema.json +38 -0
- package/src/generators/convert-to-nx-project/convert-to-nx-project.d.ts +6 -0
- package/src/generators/convert-to-nx-project/convert-to-nx-project.js +86 -0
- package/src/generators/convert-to-nx-project/convert-to-nx-project.js.map +1 -0
- package/src/generators/convert-to-nx-project/schema.d.ts +7 -0
- package/src/generators/convert-to-nx-project/schema.json +38 -0
- package/src/generators/move/lib/check-destination.d.ts +11 -0
- package/src/generators/move/lib/check-destination.js +24 -0
- package/src/generators/move/lib/check-destination.js.map +1 -0
- package/src/generators/move/lib/create-project-configuration-in-new-destination.d.ts +3 -0
- package/src/generators/move/lib/create-project-configuration-in-new-destination.js +17 -0
- package/src/generators/move/lib/create-project-configuration-in-new-destination.js.map +1 -0
- package/src/generators/move/lib/move-project-files.d.ts +8 -0
- package/src/generators/move/lib/move-project-files.js +22 -0
- package/src/generators/move/lib/move-project-files.js.map +1 -0
- package/src/generators/move/lib/normalize-schema.d.ts +3 -0
- package/src/generators/move/lib/normalize-schema.js +17 -0
- package/src/generators/move/lib/normalize-schema.js.map +1 -0
- package/src/generators/move/lib/update-build-targets.d.ts +6 -0
- package/src/generators/move/lib/update-build-targets.js +54 -0
- package/src/generators/move/lib/update-build-targets.js.map +1 -0
- package/src/generators/move/lib/update-cypress-config.d.ts +10 -0
- package/src/generators/move/lib/update-cypress-config.js +39 -0
- package/src/generators/move/lib/update-cypress-config.js.map +1 -0
- package/src/generators/move/lib/update-default-project.d.ts +10 -0
- package/src/generators/move/lib/update-default-project.js +21 -0
- package/src/generators/move/lib/update-default-project.js.map +1 -0
- package/src/generators/move/lib/update-eslintrc-json.d.ts +8 -0
- package/src/generators/move/lib/update-eslintrc-json.js +44 -0
- package/src/generators/move/lib/update-eslintrc-json.js.map +1 -0
- package/src/generators/move/lib/update-implicit-dependencies.d.ts +6 -0
- package/src/generators/move/lib/update-implicit-dependencies.js +20 -0
- package/src/generators/move/lib/update-implicit-dependencies.js.map +1 -0
- package/src/generators/move/lib/update-imports.d.ts +8 -0
- package/src/generators/move/lib/update-imports.js +159 -0
- package/src/generators/move/lib/update-imports.js.map +1 -0
- package/src/generators/move/lib/update-jest-config.d.ts +10 -0
- package/src/generators/move/lib/update-jest-config.js +36 -0
- package/src/generators/move/lib/update-jest-config.js.map +1 -0
- package/src/generators/move/lib/update-package-json.d.ts +8 -0
- package/src/generators/move/lib/update-package-json.js +22 -0
- package/src/generators/move/lib/update-package-json.js.map +1 -0
- package/src/generators/move/lib/update-project-root-files.d.ts +10 -0
- package/src/generators/move/lib/update-project-root-files.js +44 -0
- package/src/generators/move/lib/update-project-root-files.js.map +1 -0
- package/src/generators/move/lib/update-readme.d.ts +8 -0
- package/src/generators/move/lib/update-readme.js +22 -0
- package/src/generators/move/lib/update-readme.js.map +1 -0
- package/src/generators/move/lib/update-storybook-config.d.ts +10 -0
- package/src/generators/move/lib/update-storybook-config.js +44 -0
- package/src/generators/move/lib/update-storybook-config.js.map +1 -0
- package/src/generators/move/lib/utils.d.ts +22 -0
- package/src/generators/move/lib/utils.js +43 -0
- package/src/generators/move/lib/utils.js.map +1 -0
- package/src/generators/move/move.d.ts +5 -0
- package/src/generators/move/move.js +48 -0
- package/src/generators/move/move.js.map +1 -0
- package/src/generators/move/schema.d.ts +13 -0
- package/src/generators/move/schema.json +47 -0
- package/src/generators/new/files-integrated-repo/__dot__editorconfig +13 -0
- package/src/generators/new/files-integrated-repo/__dot__gitignore +39 -0
- package/src/generators/new/files-integrated-repo/__dot__vscode/extensions.json__tmpl__ +9 -0
- package/src/generators/new/files-integrated-repo/package.json__tmpl__ +14 -0
- package/src/generators/new/files-integrated-repo/tools/generators/.gitkeep +0 -0
- package/src/generators/new/files-integrated-repo/tools/tsconfig.tools.json +12 -0
- package/src/generators/new/files-package-based-repo/__dot__gitignore +39 -0
- package/src/generators/new/files-package-based-repo/__dot__vscode/extensions.json__tmpl__ +8 -0
- package/src/generators/new/files-package-based-repo/package.json__tmpl__ +13 -0
- package/src/generators/new/files-readme/README.md.template +21 -0
- package/src/generators/new/files-root-app/__dot__gitignore +39 -0
- package/src/generators/new/files-root-app/__dot__vscode/extensions.json__tmpl__ +6 -0
- package/src/generators/new/files-root-app/package.json__tmpl__ +14 -0
- package/src/generators/new/generate-preset.d.ts +4 -0
- package/src/generators/new/generate-preset.js +129 -0
- package/src/generators/new/generate-preset.js.map +1 -0
- package/src/generators/new/generate-workspace-files.d.ts +3 -0
- package/src/generators/new/generate-workspace-files.js +169 -0
- package/src/generators/new/generate-workspace-files.js.map +1 -0
- package/src/generators/new/new.d.ts +26 -0
- package/src/generators/new/new.js +73 -0
- package/src/generators/new/new.js.map +1 -0
- package/src/generators/new/schema.json +77 -0
- package/src/generators/npm-package/files/index.js.template +1 -0
- package/src/generators/npm-package/npm-package.d.ts +6 -0
- package/src/generators/npm-package/npm-package.js +42 -0
- package/src/generators/npm-package/npm-package.js.map +1 -0
- package/src/generators/npm-package/schema.json +21 -0
- package/src/generators/preset/files/angular/app.module.d.ts +0 -0
- package/src/generators/preset/files/angular/app.module.js +1 -0
- package/src/generators/preset/files/angular/app.module.js.map +1 -0
- package/src/generators/preset/files/angular/app.module.ts +0 -0
- package/src/generators/preset/preset.d.ts +4 -0
- package/src/generators/preset/preset.js +152 -0
- package/src/generators/preset/preset.js.map +1 -0
- package/src/generators/preset/schema.d.ts +17 -0
- package/src/generators/preset/schema.json +88 -0
- package/src/generators/remove/lib/__fixtures__/jest-project.config.d.ts +14 -0
- package/src/generators/remove/lib/__fixtures__/jest-project.config.js +18 -0
- package/src/generators/remove/lib/__fixtures__/jest-project.config.js.map +1 -0
- package/src/generators/remove/lib/__fixtures__/jest.config.d.ts +0 -0
- package/src/generators/remove/lib/__fixtures__/jest.config.js +9 -0
- package/src/generators/remove/lib/__fixtures__/jest.config.js.map +1 -0
- package/src/generators/remove/lib/check-dependencies.d.ts +7 -0
- package/src/generators/remove/lib/check-dependencies.js +27 -0
- package/src/generators/remove/lib/check-dependencies.js.map +1 -0
- package/src/generators/remove/lib/check-project-is-safe-to-remove.d.ts +3 -0
- package/src/generators/remove/lib/check-project-is-safe-to-remove.js +26 -0
- package/src/generators/remove/lib/check-project-is-safe-to-remove.js.map +1 -0
- package/src/generators/remove/lib/check-targets.d.ts +10 -0
- package/src/generators/remove/lib/check-targets.js +72 -0
- package/src/generators/remove/lib/check-targets.js.map +1 -0
- package/src/generators/remove/lib/remove-project-references-in-config.d.ts +3 -0
- package/src/generators/remove/lib/remove-project-references-in-config.js +22 -0
- package/src/generators/remove/lib/remove-project-references-in-config.js.map +1 -0
- package/src/generators/remove/lib/remove-project.d.ts +5 -0
- package/src/generators/remove/lib/remove-project.js +15 -0
- package/src/generators/remove/lib/remove-project.js.map +1 -0
- package/src/generators/remove/lib/update-jest-config.d.ts +6 -0
- package/src/generators/remove/lib/update-jest-config.js +64 -0
- package/src/generators/remove/lib/update-jest-config.js.map +1 -0
- package/src/generators/remove/lib/update-tsconfig.d.ts +8 -0
- package/src/generators/remove/lib/update-tsconfig.js +35 -0
- package/src/generators/remove/lib/update-tsconfig.js.map +1 -0
- package/src/generators/remove/remove.d.ts +5 -0
- package/src/generators/remove/remove.js +31 -0
- package/src/generators/remove/remove.js.map +1 -0
- package/src/generators/remove/schema.d.ts +10 -0
- package/src/generators/remove/schema.json +47 -0
- package/src/generators/run-commands/run-commands.d.ts +5 -0
- package/src/generators/run-commands/run-commands.js +30 -0
- package/src/generators/run-commands/run-commands.js.map +1 -0
- package/src/generators/run-commands/schema.d.ts +8 -0
- package/src/generators/run-commands/schema.json +49 -0
- package/src/generators/utils/get-npm-package-version.d.ts +1 -0
- package/src/generators/utils/get-npm-package-version.js +18 -0
- package/src/generators/utils/get-npm-package-version.js.map +1 -0
- package/src/generators/utils/insert-import.d.ts +2 -0
- package/src/generators/utils/insert-import.js +48 -0
- package/src/generators/utils/insert-import.js.map +1 -0
- package/src/generators/utils/insert-statement.d.ts +5 -0
- package/src/generators/utils/insert-statement.js +34 -0
- package/src/generators/utils/insert-statement.js.map +1 -0
- package/src/generators/utils/presets.d.ts +18 -0
- package/src/generators/utils/presets.js +23 -0
- package/src/generators/utils/presets.js.map +1 -0
- package/src/generators/workspace-generator/files/index.ts__tmpl__ +10 -0
- package/src/generators/workspace-generator/files/schema.json__tmpl__ +17 -0
- package/src/generators/workspace-generator/schema.d.ts +4 -0
- package/src/generators/workspace-generator/schema.json +25 -0
- package/src/generators/workspace-generator/workspace-generator.d.ts +3 -0
- package/src/generators/workspace-generator/workspace-generator.js +27 -0
- package/src/generators/workspace-generator/workspace-generator.js.map +1 -0
- package/src/migrations/update-12-5-0/add-target-dependencies.d.ts +3 -0
- package/src/migrations/update-12-5-0/add-target-dependencies.js +39 -0
- package/src/migrations/update-12-5-0/add-target-dependencies.js.map +1 -0
- package/src/migrations/update-13-0-0/config-locations/config-locations.d.ts +2 -0
- package/src/migrations/update-13-0-0/config-locations/config-locations.js +34 -0
- package/src/migrations/update-13-0-0/config-locations/config-locations.js.map +1 -0
- package/src/migrations/update-13-0-0/set-default-base-if-not-set.d.ts +3 -0
- package/src/migrations/update-13-0-0/set-default-base-if-not-set.js +30 -0
- package/src/migrations/update-13-0-0/set-default-base-if-not-set.js.map +1 -0
- package/src/migrations/update-13-10-0/update-decorate-cli.d.ts +3 -0
- package/src/migrations/update-13-10-0/update-decorate-cli.js +14 -0
- package/src/migrations/update-13-10-0/update-decorate-cli.js.map +1 -0
- package/src/migrations/update-13-10-0/update-tasks-runner.d.ts +3 -0
- package/src/migrations/update-13-10-0/update-tasks-runner.js +17 -0
- package/src/migrations/update-13-10-0/update-tasks-runner.js.map +1 -0
- package/src/migrations/update-13-2-0/set-parallel-default.d.ts +3 -0
- package/src/migrations/update-13-2-0/set-parallel-default.js +27 -0
- package/src/migrations/update-13-2-0/set-parallel-default.js.map +1 -0
- package/src/migrations/update-13-3-0/update-tsc-executor-location.d.ts +3 -0
- package/src/migrations/update-13-3-0/update-tsc-executor-location.js +31 -0
- package/src/migrations/update-13-3-0/update-tsc-executor-location.js.map +1 -0
- package/src/migrations/update-13-6-0/remove-old-task-runner-options.d.ts +3 -0
- package/src/migrations/update-13-6-0/remove-old-task-runner-options.js +17 -0
- package/src/migrations/update-13-6-0/remove-old-task-runner-options.js.map +1 -0
- package/src/migrations/update-13-9-0/replace-tao-with-nx.d.ts +3 -0
- package/src/migrations/update-13-9-0/replace-tao-with-nx.js +28 -0
- package/src/migrations/update-13-9-0/replace-tao-with-nx.js.map +1 -0
- package/src/migrations/update-13-9-0/update-decorate-cli.d.ts +3 -0
- package/src/migrations/update-13-9-0/update-decorate-cli.js +13 -0
- package/src/migrations/update-13-9-0/update-decorate-cli.js.map +1 -0
- package/src/migrations/update-14-0-0/change-npm-script-executor.d.ts +3 -0
- package/src/migrations/update-14-0-0/change-npm-script-executor.js +20 -0
- package/src/migrations/update-14-0-0/change-npm-script-executor.js.map +1 -0
- package/src/migrations/update-14-0-0/change-nx-json-presets.d.ts +3 -0
- package/src/migrations/update-14-0-0/change-nx-json-presets.js +21 -0
- package/src/migrations/update-14-0-0/change-nx-json-presets.js.map +1 -0
- package/src/migrations/update-14-2-0/enable-source-analysis.d.ts +3 -0
- package/src/migrations/update-14-2-0/enable-source-analysis.js +28 -0
- package/src/migrations/update-14-2-0/enable-source-analysis.js.map +1 -0
- package/src/migrations/update-14-8-0/change-run-commands-executor.d.ts +3 -0
- package/src/migrations/update-14-8-0/change-run-commands-executor.js +20 -0
- package/src/migrations/update-14-8-0/change-run-commands-executor.js.map +1 -0
- package/src/migrations/update-15-7-0/split-configuration-into-project-json-files.d.ts +3 -0
- package/src/migrations/update-15-7-0/split-configuration-into-project-json-files.js +15 -0
- package/src/migrations/update-15-7-0/split-configuration-into-project-json-files.js.map +1 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
- package/src/tasks-runner/cache.d.ts +1 -0
- package/src/tasks-runner/cache.js +6 -0
- package/src/tasks-runner/cache.js.map +1 -0
- package/src/tasks-runner/default-tasks-runner.d.ts +1 -0
- package/src/tasks-runner/default-tasks-runner.js +5 -0
- package/src/tasks-runner/default-tasks-runner.js.map +1 -0
- package/src/tasks-runner/life-cycle.d.ts +1 -0
- package/src/tasks-runner/life-cycle.js +6 -0
- package/src/tasks-runner/life-cycle.js.map +1 -0
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.d.ts +1 -0
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +5 -0
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js.map +1 -0
- package/src/tasks-runner/tasks-runner-v2.d.ts +1 -0
- package/src/tasks-runner/tasks-runner-v2.js +7 -0
- package/src/tasks-runner/tasks-runner-v2.js.map +1 -0
- package/src/tasks-runner/tasks-runner.d.ts +2 -0
- package/src/tasks-runner/tasks-runner.js +5 -0
- package/src/tasks-runner/tasks-runner.js.map +1 -0
- package/src/tasks-runner/utils.d.ts +1 -0
- package/src/tasks-runner/utils.js +5 -0
- package/src/tasks-runner/utils.js.map +1 -0
- package/src/utilities/app-root.d.ts +1 -0
- package/src/utilities/app-root.js +5 -0
- package/src/utilities/app-root.js.map +1 -0
- package/src/utilities/buildable-libs-utils.d.ts +41 -0
- package/src/utilities/buildable-libs-utils.js +316 -0
- package/src/utilities/buildable-libs-utils.js.map +1 -0
- package/src/utilities/default-base.d.ts +1 -0
- package/src/utilities/default-base.js +16 -0
- package/src/utilities/default-base.js.map +1 -0
- package/src/utilities/fileutils.d.ts +13 -0
- package/src/utilities/fileutils.js +52 -0
- package/src/utilities/fileutils.js.map +1 -0
- package/src/utilities/output.d.ts +1 -0
- package/src/utilities/output.js +5 -0
- package/src/utilities/output.js.map +1 -0
- package/src/utilities/run-tasks-in-serial.d.ts +8 -0
- package/src/utilities/run-tasks-in-serial.js +19 -0
- package/src/utilities/run-tasks-in-serial.js.map +1 -0
- package/src/utilities/ts-config.d.ts +5 -0
- package/src/utilities/ts-config.js +40 -0
- package/src/utilities/ts-config.js.map +1 -0
- package/src/utilities/typescript/compilation.d.ts +22 -0
- package/src/utilities/typescript/compilation.js +120 -0
- package/src/utilities/typescript/compilation.js.map +1 -0
- package/src/utilities/typescript/get-source-nodes.d.ts +5 -0
- package/src/utilities/typescript/get-source-nodes.js +22 -0
- package/src/utilities/typescript/get-source-nodes.js.map +1 -0
- package/src/utilities/typescript.d.ts +22 -0
- package/src/utilities/typescript.js +71 -0
- package/src/utilities/typescript.js.map +1 -0
- package/src/utilities/version-utils.d.ts +4 -0
- package/src/utilities/version-utils.js +14 -0
- package/src/utilities/version-utils.js.map +1 -0
- package/src/utils/ast-utils.d.ts +1 -0
- package/src/utils/ast-utils.js +6 -0
- package/src/utils/ast-utils.js.map +1 -0
- package/src/utils/cli-config-utils.d.ts +16 -0
- package/src/utils/cli-config-utils.js +30 -0
- package/src/utils/cli-config-utils.js.map +1 -0
- package/src/utils/fileutils.d.ts +24 -0
- package/src/utils/fileutils.js +67 -0
- package/src/utils/fileutils.js.map +1 -0
- package/src/utils/lint.d.ts +4 -0
- package/src/utils/lint.js +3 -0
- package/src/utils/lint.js.map +1 -0
- package/src/utils/output.d.ts +52 -0
- package/src/utils/output.js +134 -0
- package/src/utils/output.js.map +1 -0
- package/src/utils/perf-logging.d.ts +1 -0
- package/src/utils/perf-logging.js +11 -0
- package/src/utils/perf-logging.js.map +1 -0
- package/src/utils/project-type.d.ts +5 -0
- package/src/utils/project-type.js +18 -0
- package/src/utils/project-type.js.map +1 -0
- package/src/utils/rules/add-install-task.d.ts +7 -0
- package/src/utils/rules/add-install-task.js +18 -0
- package/src/utils/rules/add-install-task.js.map +1 -0
- package/src/utils/rules/deleteFile.d.ts +6 -0
- package/src/utils/rules/deleteFile.js +12 -0
- package/src/utils/rules/deleteFile.js.map +1 -0
- package/src/utils/rules/format-files.d.ts +7 -0
- package/src/utils/rules/format-files.js +58 -0
- package/src/utils/rules/format-files.js.map +1 -0
- package/src/utils/rules/visit-not-ignored-files.d.ts +6 -0
- package/src/utils/rules/visit-not-ignored-files.js +39 -0
- package/src/utils/rules/visit-not-ignored-files.js.map +1 -0
- package/src/utils/strings.d.ts +107 -0
- package/src/utils/strings.js +160 -0
- package/src/utils/strings.js.map +1 -0
- package/src/utils/testing-utils.d.ts +54 -0
- package/src/utils/testing-utils.js +147 -0
- package/src/utils/testing-utils.js.map +1 -0
- package/src/utils/version-utils.d.ts +1 -0
- package/src/utils/version-utils.js +5 -0
- package/src/utils/version-utils.js.map +1 -0
- package/src/utils/versions.d.ts +7 -0
- package/src/utils/versions.js +13 -0
- package/src/utils/versions.js.map +1 -0
- package/src/utils/workspace.d.ts +20 -0
- package/src/utils/workspace.js +97 -0
- package/src/utils/workspace.js.map +1 -0
- package/tasks-runners/default.d.ts +1 -0
- package/tasks-runners/default.js +6 -0
- package/tasks-runners/default.js.map +1 -0
- package/testing.d.ts +1 -0
- package/testing.js +8 -0
- package/testing.js.map +1 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.presetGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const presets_1 = require("../utils/presets");
|
|
7
|
+
function presetGenerator(tree, options) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
options = normalizeOptions(options);
|
|
10
|
+
const presetTask = yield createPreset(tree, options);
|
|
11
|
+
return () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
13
|
+
if (presetTask)
|
|
14
|
+
yield presetTask();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
exports.presetGenerator = presetGenerator;
|
|
19
|
+
exports.default = presetGenerator;
|
|
20
|
+
function createPreset(tree, options) {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
if (options.preset === presets_1.Preset.Empty || options.preset === presets_1.Preset.Apps) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
else if (options.preset === presets_1.Preset.AngularMonorepo) {
|
|
27
|
+
const { applicationGenerator: angularApplicationGenerator, } = require('@nx' + '/angular/generators');
|
|
28
|
+
return angularApplicationGenerator(tree, {
|
|
29
|
+
name: options.name,
|
|
30
|
+
style: options.style,
|
|
31
|
+
linter: options.linter,
|
|
32
|
+
standalone: options.standaloneApi,
|
|
33
|
+
routing: options.routing,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
else if (options.preset === presets_1.Preset.AngularStandalone) {
|
|
37
|
+
const { applicationGenerator: angularApplicationGenerator, } = require('@nx' + '/angular/generators');
|
|
38
|
+
return angularApplicationGenerator(tree, {
|
|
39
|
+
name: options.name,
|
|
40
|
+
style: options.style,
|
|
41
|
+
linter: options.linter,
|
|
42
|
+
routing: options.routing,
|
|
43
|
+
rootProject: true,
|
|
44
|
+
standalone: options.standaloneApi,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
else if (options.preset === presets_1.Preset.ReactMonorepo) {
|
|
48
|
+
const { applicationGenerator: reactApplicationGenerator } = require('@nx' +
|
|
49
|
+
'/react');
|
|
50
|
+
return reactApplicationGenerator(tree, {
|
|
51
|
+
name: options.name,
|
|
52
|
+
style: options.style,
|
|
53
|
+
linter: options.linter,
|
|
54
|
+
bundler: (_a = options.bundler) !== null && _a !== void 0 ? _a : 'webpack',
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else if (options.preset === presets_1.Preset.ReactStandalone) {
|
|
58
|
+
const { applicationGenerator: reactApplicationGenerator } = require('@nx' +
|
|
59
|
+
'/react');
|
|
60
|
+
return reactApplicationGenerator(tree, {
|
|
61
|
+
name: options.name,
|
|
62
|
+
style: options.style,
|
|
63
|
+
linter: options.linter,
|
|
64
|
+
rootProject: true,
|
|
65
|
+
bundler: (_b = options.bundler) !== null && _b !== void 0 ? _b : 'vite',
|
|
66
|
+
e2eTestRunner: 'cypress',
|
|
67
|
+
unitTestRunner: options.bundler === 'vite' ? 'vitest' : 'jest',
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else if (options.preset === presets_1.Preset.NextJs) {
|
|
71
|
+
const { applicationGenerator: nextApplicationGenerator } = require('@nx' +
|
|
72
|
+
'/next');
|
|
73
|
+
return nextApplicationGenerator(tree, {
|
|
74
|
+
name: options.name,
|
|
75
|
+
style: options.style,
|
|
76
|
+
linter: options.linter,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else if (options.preset === presets_1.Preset.WebComponents) {
|
|
80
|
+
const { applicationGenerator: webApplicationGenerator } = require('@nx' +
|
|
81
|
+
'/web');
|
|
82
|
+
return webApplicationGenerator(tree, {
|
|
83
|
+
name: options.name,
|
|
84
|
+
style: options.style,
|
|
85
|
+
linter: options.linter,
|
|
86
|
+
bundler: 'vite',
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
else if (options.preset === presets_1.Preset.Nest) {
|
|
90
|
+
const { applicationGenerator: nestApplicationGenerator } = require('@nx' +
|
|
91
|
+
'/nest');
|
|
92
|
+
return nestApplicationGenerator(tree, {
|
|
93
|
+
name: options.name,
|
|
94
|
+
linter: options.linter,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else if (options.preset === presets_1.Preset.Express) {
|
|
98
|
+
const { applicationGenerator: expressApplicationGenerator, } = require('@nx' + '/express');
|
|
99
|
+
return expressApplicationGenerator(tree, {
|
|
100
|
+
name: options.name,
|
|
101
|
+
linter: options.linter,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
else if (options.preset === presets_1.Preset.ReactNative) {
|
|
105
|
+
const { reactNativeApplicationGenerator } = require('@nx' +
|
|
106
|
+
'/react-native');
|
|
107
|
+
return reactNativeApplicationGenerator(tree, {
|
|
108
|
+
name: options.name,
|
|
109
|
+
linter: options.linter,
|
|
110
|
+
e2eTestRunner: 'detox',
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
else if (options.preset === presets_1.Preset.Expo) {
|
|
114
|
+
const { expoApplicationGenerator } = require('@nx' + '/expo');
|
|
115
|
+
return expoApplicationGenerator(tree, {
|
|
116
|
+
name: options.name,
|
|
117
|
+
linter: options.linter,
|
|
118
|
+
e2eTestRunner: 'detox',
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else if (options.preset === presets_1.Preset.TS) {
|
|
122
|
+
const c = (0, devkit_1.readNxJson)(tree);
|
|
123
|
+
const { initGenerator } = require('@nx' + '/js');
|
|
124
|
+
c.workspaceLayout = {
|
|
125
|
+
appsDir: 'packages',
|
|
126
|
+
libsDir: 'packages',
|
|
127
|
+
};
|
|
128
|
+
(0, devkit_1.updateNxJson)(tree, c);
|
|
129
|
+
return initGenerator(tree, {});
|
|
130
|
+
}
|
|
131
|
+
else if (options.preset === presets_1.Preset.NodeStandalone) {
|
|
132
|
+
const { applicationGenerator: nodeApplicationGenerator } = require('@nx' +
|
|
133
|
+
'/node');
|
|
134
|
+
return nodeApplicationGenerator(tree, {
|
|
135
|
+
name: options.name,
|
|
136
|
+
linter: options.linter,
|
|
137
|
+
standaloneConfig: options.standaloneConfig,
|
|
138
|
+
framework: options.framework,
|
|
139
|
+
docker: options.docker,
|
|
140
|
+
rootProject: true,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
throw new Error(`Invalid preset ${options.preset}`);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function normalizeOptions(options) {
|
|
149
|
+
options.name = (0, devkit_1.names)(options.name).fileName;
|
|
150
|
+
return options;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=preset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset.js","sourceRoot":"","sources":["../../../../../../packages/workspace/src/generators/preset/preset.ts"],"names":[],"mappings":";;;;AAAA,uCAMoB;AAEpB,8CAA0C;AAE1C,SAAsB,eAAe,CAAC,IAAU,EAAE,OAAe;;QAC/D,OAAO,GAAG,gBAAgB,CA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MAAM;gBACtB,WAAW,EAAE,IAAI;aAClB,CAAC,CAAC;SACJ;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,kBAAkB,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;SACrD;;CACF;AAED,SAAS,gBAAgB,CAAC,OAAe;IACvC,OAAO,CAAC,IAAI,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC5C,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Preset } from '../utils/presets';
|
|
2
|
+
import { PackageManager } from '@nx/devkit';
|
|
3
|
+
|
|
4
|
+
export interface Schema {
|
|
5
|
+
name: string;
|
|
6
|
+
npmScope?: string;
|
|
7
|
+
style?: string;
|
|
8
|
+
linter?: string;
|
|
9
|
+
preset: Preset;
|
|
10
|
+
standaloneConfig?: boolean;
|
|
11
|
+
framework?: string;
|
|
12
|
+
packageManager?: PackageManager;
|
|
13
|
+
bundler?: 'vite' | 'webpack';
|
|
14
|
+
docker?: boolean;
|
|
15
|
+
routing?: boolean;
|
|
16
|
+
standaloneApi?: boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "NxWorkspacePreset",
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"title": "Creates applications in a new workspace",
|
|
6
|
+
"description": "Creates applications in a new workspace.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"preset": {
|
|
10
|
+
"description": "The name of the preset.",
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
"name": {
|
|
14
|
+
"description": "The name of the application.",
|
|
15
|
+
"type": "string"
|
|
16
|
+
},
|
|
17
|
+
"npmScope": {
|
|
18
|
+
"description": "Npm scope for importing libs.",
|
|
19
|
+
"type": "string"
|
|
20
|
+
},
|
|
21
|
+
"linter": {
|
|
22
|
+
"description": "The tool to use for running lint checks.",
|
|
23
|
+
"type": "string",
|
|
24
|
+
"enum": ["eslint"],
|
|
25
|
+
"default": "eslint"
|
|
26
|
+
},
|
|
27
|
+
"routing": {
|
|
28
|
+
"description": "Add routing to the generated application.",
|
|
29
|
+
"type": "boolean",
|
|
30
|
+
"default": true
|
|
31
|
+
},
|
|
32
|
+
"style": {
|
|
33
|
+
"description": "The file extension to be used for style files.",
|
|
34
|
+
"type": "string",
|
|
35
|
+
"default": "css",
|
|
36
|
+
"x-prompt": {
|
|
37
|
+
"message": "Which stylesheet format would you like to use?",
|
|
38
|
+
"type": "list",
|
|
39
|
+
"items": [
|
|
40
|
+
{
|
|
41
|
+
"value": "css",
|
|
42
|
+
"label": "CSS"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"value": "scss",
|
|
46
|
+
"label": "SASS(.scss) [ http://sass-lang.com ]"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"value": "less",
|
|
50
|
+
"label": "LESS [ http://lesscss.org ]"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"standaloneApi": {
|
|
56
|
+
"description": "Use Standalone Components if generating an Angular application.",
|
|
57
|
+
"type": "boolean",
|
|
58
|
+
"default": false
|
|
59
|
+
},
|
|
60
|
+
"standaloneConfig": {
|
|
61
|
+
"description": "Split the project configurations into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
|
|
62
|
+
"type": "boolean",
|
|
63
|
+
"default": true,
|
|
64
|
+
"x-deprecated": "Nx only supports standaloneConfig"
|
|
65
|
+
},
|
|
66
|
+
"packageManager": {
|
|
67
|
+
"description": "The package manager used to install dependencies.",
|
|
68
|
+
"type": "string",
|
|
69
|
+
"enum": ["npm", "yarn", "pnpm"]
|
|
70
|
+
},
|
|
71
|
+
"framework": {
|
|
72
|
+
"description": "The framework which the application is using",
|
|
73
|
+
"type": "string",
|
|
74
|
+
"enum": ["express", "koa", "fastify", "nest", "none"]
|
|
75
|
+
},
|
|
76
|
+
"bundler": {
|
|
77
|
+
"description": "The bundler to use for building the application.",
|
|
78
|
+
"type": "string",
|
|
79
|
+
"enum": ["webpack", "vite"],
|
|
80
|
+
"default": "vite"
|
|
81
|
+
},
|
|
82
|
+
"docker": {
|
|
83
|
+
"description": "Generate a Dockerfile",
|
|
84
|
+
"type": "boolean",
|
|
85
|
+
"default": false
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
displayName: string;
|
|
3
|
+
preset: string;
|
|
4
|
+
testEnvironment: string;
|
|
5
|
+
transform: {
|
|
6
|
+
'^.+\\.[tj]s$': (string | {
|
|
7
|
+
tsconfig: string;
|
|
8
|
+
})[];
|
|
9
|
+
};
|
|
10
|
+
moduleFileExtensions: string[];
|
|
11
|
+
coverageDirectory: string;
|
|
12
|
+
testMatch: string[];
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
exports.default = {
|
|
5
|
+
displayName: 'node-app',
|
|
6
|
+
preset: './jest.preset.js',
|
|
7
|
+
testEnvironment: 'node',
|
|
8
|
+
transform: {
|
|
9
|
+
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
|
10
|
+
},
|
|
11
|
+
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
12
|
+
coverageDirectory: './coverage/node-app',
|
|
13
|
+
testMatch: [
|
|
14
|
+
'<rootDir>/src/**/__tests__/**/*.[jt]s?(x)',
|
|
15
|
+
'<rootDir>/src/**/*(*.)@(spec|test).[jt]s?(x)',
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=jest-project.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-project.config.js","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/generators/remove/lib/__fixtures__/jest-project.config.ts"],"names":[],"mappings":";;AAAA,oBAAoB;AACpB,kBAAe;IACb,WAAW,EAAE,UAAU;IACvB,MAAM,EAAE,kBAAkB;IAC1B,eAAe,EAAE,MAAM;IACvB,SAAS,EAAE;QACT,cAAc,EAAE,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,8BAA8B,EAAE,CAAC;KAC1E;IACD,oBAAoB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC;IAC1C,iBAAiB,EAAE,qBAAqB;IACxC,SAAS,EAAE;QACT,2CAA2C;QAC3C,8CAA8C;KAC/C;CACF,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.config.js","sourceRoot":"","sources":["../../../../../../../../packages/workspace/src/generators/remove/lib/__fixtures__/jest.config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,GAAG;IACf,QAAQ,EAAE;QACR,wBAAwB;QACxB,6BAA6B;QAC7B,uBAAuB;QACvB,8BAA8B;KAC/B;CACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Schema } from '../schema';
|
|
2
|
+
/**
|
|
3
|
+
* Check whether the project to be removed is depended on by another project
|
|
4
|
+
*
|
|
5
|
+
* Throws an error if the project is in use, unless the `--forceRemove` option is used.
|
|
6
|
+
*/
|
|
7
|
+
export declare function checkDependencies(_: any, schema: Schema): Promise<void>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkDependencies = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
/**
|
|
7
|
+
* Check whether the project to be removed is depended on by another project
|
|
8
|
+
*
|
|
9
|
+
* Throws an error if the project is in use, unless the `--forceRemove` option is used.
|
|
10
|
+
*/
|
|
11
|
+
function checkDependencies(_, schema) {
|
|
12
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
if (schema.forceRemove) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const graph = yield (0, devkit_1.createProjectGraphAsync)();
|
|
17
|
+
const reverseGraph = (0, devkit_1.reverse)(graph);
|
|
18
|
+
const deps = reverseGraph.dependencies[schema.projectName] || [];
|
|
19
|
+
if (deps.length > 0) {
|
|
20
|
+
throw new Error(`${schema.projectName} is still depended on by the following projects:\n${deps
|
|
21
|
+
.map((x) => x.target)
|
|
22
|
+
.join('\n')}`);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.checkDependencies = checkDependencies;
|
|
27
|
+
//# sourceMappingURL=check-dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-dependencies.js","sourceRoot":"","sources":["../../../../../../../packages/workspace/src/generators/remove/lib/check-dependencies.ts"],"names":[],"mappings":";;;;AAAA,uCAA4E;AAG5E;;;;GAIG;AACH,SAAsB,iBAAiB,CAAC,CAAC,EAAE,MAAc;;QACvD,IAAI,MAAM,CAAC,WAAW,EAAE;YACtB,OAAO;SACR;QAED,MAAM,KAAK,GAAiB,MAAM,IAAA,gCAAuB,GAAE,CAAC;QAE5D,MAAM,YAAY,GAAG,IAAA,gBAAO,EAAC,KAAK,CAAC,CAAC;QAEpC,MAAM,IAAI,GAAG,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAEjE,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,MAAM,IAAI,KAAK,CACb,GACE,MAAM,CAAC,WACT,qDAAqD,IAAI;iBACtD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;iBACpB,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB,CAAC;SACH;IACH,CAAC;CAAA;AApBD,8CAoBC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkProjectIsSafeToRemove = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
function checkProjectIsSafeToRemove(tree, schema, project) {
|
|
7
|
+
if (project.root === '.') {
|
|
8
|
+
throw new Error(`"${schema.projectName}" is the root project. Running this would delete every file in your workspace.`);
|
|
9
|
+
}
|
|
10
|
+
if (schema.forceRemove) {
|
|
11
|
+
devkit_1.logger.warn(`You have passed --forceRemove`);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const containedProjects = [];
|
|
15
|
+
for (const [_, p] of (0, devkit_1.getProjects)(tree)) {
|
|
16
|
+
if (project.name !== p.name &&
|
|
17
|
+
!(0, devkit_1.normalizePath)((0, path_1.relative)(project.root, p.root)).startsWith('..')) {
|
|
18
|
+
containedProjects.push(p.name);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (containedProjects.length > 0) {
|
|
22
|
+
throw new Error(`"${schema.projectName}" is a project that has nested projects within it. Removing this project would remove the following projects as well:\n - ${containedProjects.join('\n - ')}\nPass --forceRemove to remove all of the above projects`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.checkProjectIsSafeToRemove = checkProjectIsSafeToRemove;
|
|
26
|
+
//# sourceMappingURL=check-project-is-safe-to-remove.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-project-is-safe-to-remove.js","sourceRoot":"","sources":["../../../../../../../packages/workspace/src/generators/remove/lib/check-project-is-safe-to-remove.ts"],"names":[],"mappings":";;;AAAA,uCAMoB;AAEpB,+BAAgC;AAEhC,SAAgB,0BAA0B,CACxC,IAAU,EACV,MAAc,EACd,OAA6B;IAE7B,IAAI,OAAO,CAAC,IAAI,KAAK,GAAG,EAAE;QACxB,MAAM,IAAI,KAAK,CACb,IAAI,MAAM,CAAC,WAAW,gFAAgF,CACvG,CAAC;KACH;IACD,IAAI,MAAM,CAAC,WAAW,EAAE;QACtB,eAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;QAC7C,OAAO;KACR;IACD,MAAM,iBAAiB,GAAG,EAAE,CAAC;IAC7B,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAA,oBAAW,EAAC,IAAI,CAAC,EAAE;QACtC,IACE,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;YACvB,CAAC,IAAA,sBAAa,EAAC,IAAA,eAAQ,EAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,EAC/D;YACA,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SAChC;KACF;IACD,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE;QAChC,MAAM,IAAI,KAAK,CACb,IACE,MAAM,CAAC,WACT,6HAA6H,iBAAiB,CAAC,IAAI,CACjJ,OAAO,CACR,0DAA0D,CAC5D,CAAC;KACH;AACH,CAAC;AAhCD,gEAgCC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { Schema } from '../schema';
|
|
3
|
+
/**
|
|
4
|
+
* Check whether the project to be removed has builders targetted by another project
|
|
5
|
+
*
|
|
6
|
+
* Throws an error if the project is in use, unless the `--forceRemove` option is used.
|
|
7
|
+
*
|
|
8
|
+
* @param schema The options provided to the schematic
|
|
9
|
+
*/
|
|
10
|
+
export declare function checkTargets(tree: Tree, schema: Schema): Promise<void>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkTargets = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
/**
|
|
7
|
+
* Check whether the project to be removed has builders targetted by another project
|
|
8
|
+
*
|
|
9
|
+
* Throws an error if the project is in use, unless the `--forceRemove` option is used.
|
|
10
|
+
*
|
|
11
|
+
* @param schema The options provided to the schematic
|
|
12
|
+
*/
|
|
13
|
+
function checkTargets(tree, schema) {
|
|
14
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
if (schema.forceRemove) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const graph = yield (0, devkit_1.createProjectGraphAsync)();
|
|
19
|
+
const errors = [];
|
|
20
|
+
(0, devkit_1.getProjects)(tree).forEach((projectConfig, projectName) => {
|
|
21
|
+
if (projectName === schema.projectName) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
Object.entries(projectConfig.targets || {}).forEach(([, targetConfig]) => {
|
|
25
|
+
checkIfProjectIsUsed(targetConfig, (value) => {
|
|
26
|
+
try {
|
|
27
|
+
const { project } = (0, devkit_1.parseTargetString)(value, graph);
|
|
28
|
+
if (project === schema.projectName) {
|
|
29
|
+
errors.push(`"${value}" is used by "${projectName}"`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
/**
|
|
34
|
+
* It threw because the target string was not
|
|
35
|
+
* in the format of project:target:configuration
|
|
36
|
+
*
|
|
37
|
+
* In that case, we don't care about it.
|
|
38
|
+
* So we can ignore this error.
|
|
39
|
+
*/
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
if (errors.length > 0) {
|
|
45
|
+
let message = `${schema.projectName} is still targeted by some projects:\n\n`;
|
|
46
|
+
for (let error of errors) {
|
|
47
|
+
message += `${error}\n`;
|
|
48
|
+
}
|
|
49
|
+
throw new Error(message);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
exports.checkTargets = checkTargets;
|
|
54
|
+
function checkIfProjectIsUsed(config, callback) {
|
|
55
|
+
function recur(obj, key, value) {
|
|
56
|
+
if (typeof value === 'string') {
|
|
57
|
+
callback(value);
|
|
58
|
+
}
|
|
59
|
+
else if (Array.isArray(value)) {
|
|
60
|
+
value.forEach((x, idx) => recur(value, idx, x));
|
|
61
|
+
}
|
|
62
|
+
else if (typeof value === 'object') {
|
|
63
|
+
Object.entries(value).forEach(([k, v]) => {
|
|
64
|
+
recur(value, k, v);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
Object.entries(config).forEach(([k, v]) => {
|
|
69
|
+
recur(config, k, v);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=check-targets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-targets.js","sourceRoot":"","sources":["../../../../../../../packages/workspace/src/generators/remove/lib/check-targets.ts"],"names":[],"mappings":";;;;AAAA,uCAMoB;AAGpB;;;;;;GAMG;AACH,SAAsB,YAAY,CAAC,IAAU,EAAE,MAAc;;QAC3D,IAAI,MAAM,CAAC,WAAW,EAAE;YACtB,OAAO;SACR;QAED,MAAM,KAAK,GAAG,MAAM,IAAA,gCAAuB,GAAE,CAAC;QAC9C,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,WAAW,EAAE,EAAE;YACvD,IAAI,WAAW,KAAK,MAAM,CAAC,WAAW,EAAE;gBACtC,OAAO;aACR;YACD,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,EAAE;gBACvE,oB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EAAE;gBACvC,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YACrB,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;QACxC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeProjectReferencesInConfig = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function removeProjectReferencesInConfig(tree, schema) {
|
|
6
|
+
// Unset default project if deleting the default project
|
|
7
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
8
|
+
if (nxJson.defaultProject && nxJson.defaultProject === schema.projectName) {
|
|
9
|
+
delete nxJson.defaultProject;
|
|
10
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
11
|
+
}
|
|
12
|
+
// Remove implicit dependencies onto removed project
|
|
13
|
+
(0, devkit_1.getProjects)(tree).forEach((project, projectName) => {
|
|
14
|
+
if (project.implicitDependencies &&
|
|
15
|
+
project.implicitDependencies.some((projectName) => projectName === schema.projectName)) {
|
|
16
|
+
project.implicitDependencies = project.implicitDependencies.filter((projectName) => projectName !== schema.projectName);
|
|
17
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.removeProjectReferencesInConfig = removeProjectReferencesInConfig;
|
|
22
|
+
//# sourceMappingURL=remove-project-references-in-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-project-references-in-config.js","sourceRoot":"","sources":["../../../../../../../packages/workspace/src/generators/remove/lib/remove-project-references-in-config.ts"],"names":[],"mappings":";;;AACA,uCAOoB;AAEpB,SAAgB,+BAA+B,CAAC,IAAU,EAAE,MAAc;IACxE,wDAAwD;IACxD,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,CAAC;IAChC,IAAI,MAAM,CAAC,cAAc,IAAI,MAAM,CAAC,cAAc,KAAK,MAAM,CAAC,WAAW,EAAE;QACzE,OAAO,MAAM,CAAC,cAAc,CAAC;QAC7B,IAAA,qBAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;KAC5B;IAED,oDAAoD;IACpD,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE;QACjD,IACE,OAAO,CAAC,oBAAoB;YAC5B,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAC/B,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,KAAK,MAAM,CAAC,WAAW,CACpD,EACD;YACA,OAAO,CAAC,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAChE,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,KAAK,MAAM,CAAC,WAAW,CACpD,CAAC;YACF,IAAA,mCAA0B,EAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;SACxD;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAtBD,0EAsBC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeProject = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
/**
|
|
6
|
+
* Removes (deletes) a project's files from the folder tree
|
|
7
|
+
*/
|
|
8
|
+
function removeProject(tree, project) {
|
|
9
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, project.root, (file) => {
|
|
10
|
+
tree.delete(file);
|
|
11
|
+
});
|
|
12
|
+
tree.delete(project.root);
|
|
13
|
+
}
|
|
14
|
+
exports.removeProject = removeProject;
|
|
15
|
+
//# sourceMappingURL=remove-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-project.js","sourceRoot":"","sources":["../../../../../../../packages/workspace/src/generators/remove/lib/remove-project.ts"],"names":[],"mappings":";;;AAAA,uCAA8E;AAE9E;;GAEG;AACH,SAAgB,aAAa,CAAC,IAAU,EAAE,OAA6B;IACrE,IAAA,6BAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;QAChD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AALD,sCAKC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ProjectConfiguration, Tree } from '@nx/devkit';
|
|
2
|
+
import { Schema } from '../schema';
|
|
3
|
+
/**
|
|
4
|
+
* Updates the root jest config projects array and removes the project.
|
|
5
|
+
*/
|
|
6
|
+
export declare function updateJestConfig(tree: Tree, schema: Schema, projectConfig: ProjectConfiguration): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateJestConfig = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const get_source_nodes_1 = require("../../../utilities/typescript/get-source-nodes");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const typescript_1 = require("../../../utilities/typescript");
|
|
8
|
+
let tsModule;
|
|
9
|
+
function isUsingUtilityFunction(host) {
|
|
10
|
+
return host.read('jest.config.ts').toString().includes('getJestProjects()');
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* in a standalone project, the root jest.config.ts is a project config instead
|
|
14
|
+
* of multi-project config.
|
|
15
|
+
* in that case we do not need to edit it to remove it
|
|
16
|
+
**/
|
|
17
|
+
function isMonorepoConfig(tree) {
|
|
18
|
+
return tree.read('jest.config.ts', 'utf-8').includes('projects:');
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Updates the root jest config projects array and removes the project.
|
|
22
|
+
*/
|
|
23
|
+
function updateJestConfig(tree, schema, projectConfig) {
|
|
24
|
+
if (!tsModule) {
|
|
25
|
+
tsModule = (0, typescript_1.ensureTypescript)();
|
|
26
|
+
}
|
|
27
|
+
const { createSourceFile, ScriptTarget, isPropertyAssignment, isArrayLiteralExpression, isStringLiteral, } = tsModule;
|
|
28
|
+
const projectToRemove = schema.projectName;
|
|
29
|
+
if (!tree.exists('jest.config.ts') ||
|
|
30
|
+
!tree.exists((0, path_1.join)(projectConfig.root, 'jest.config.ts')) ||
|
|
31
|
+
isUsingUtilityFunction(tree) ||
|
|
32
|
+
!isMonorepoConfig(tree)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const contents = tree.read('jest.config.ts', 'utf-8');
|
|
36
|
+
const sourceFile = createSourceFile('jest.config.ts', contents, ScriptTarget.Latest);
|
|
37
|
+
const sourceNodes = (0, get_source_nodes_1.getSourceNodes)(sourceFile);
|
|
38
|
+
const projectsAssignment = sourceNodes.find((node) => isPropertyAssignment(node) &&
|
|
39
|
+
node.name.getText(sourceFile) === 'projects' &&
|
|
40
|
+
isArrayLiteralExpression(node.initializer));
|
|
41
|
+
if (!projectsAssignment) {
|
|
42
|
+
throw Error(`Could not remove ${projectToRemove} from projects in /jest.config.ts. Please remove ${projectToRemove} from your projects.`);
|
|
43
|
+
}
|
|
44
|
+
const projectsArray = projectsAssignment.initializer;
|
|
45
|
+
const project = projectsArray.elements.find((item) => isStringLiteral(item) &&
|
|
46
|
+
item.text.startsWith(`<rootDir>/${projectConfig.root}`));
|
|
47
|
+
if (!project) {
|
|
48
|
+
console.warn(`Could not find ${projectToRemove} in projects in /jest.config.ts.`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const previousProject = projectsArray.elements[projectsArray.elements.indexOf(project) - 1];
|
|
52
|
+
const start = previousProject
|
|
53
|
+
? previousProject.getEnd()
|
|
54
|
+
: project.getStart(sourceFile);
|
|
55
|
+
tree.write('jest.config.ts', (0, devkit_1.applyChangesToString)(contents, [
|
|
56
|
+
{
|
|
57
|
+
type: devkit_1.ChangeType.Delete,
|
|
58
|
+
start,
|
|
59
|
+
length: project.getEnd() - start,
|
|
60
|
+
},
|
|
61
|
+
]));
|
|
62
|
+
}
|
|
63
|
+
exports.updateJestConfig = updateJestConfig;
|
|
64
|
+
//# sourceMappingURL=update-jest-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-jest-config.js","sourceRoot":"","sources":["../../../../../../../packages/workspace/src/generators/remove/lib/update-jest-config.ts"],"names":[],"mappings":";;;AAAA,uCAKoB;AACpB,qFAAgF;AAQhF,+BAA4B;AAC5B,8DAAiE;AAEjE,IAAI,QAAqC,CAAC;AAE1C,SAAS,sBAAsB,CAAC,IAAU;IACxC,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;AAC9E,CAAC;AAED;;;;IAII;AACJ,SAAS,gBAAgB,CAAC,IAAU;IAClC,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACpE,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAC9B,IAAU,EACV,MAAc,EACd,aAAmC;IAEnC,IAAI,CAAC,QAAQ,EAAE;QACb,QAAQ,GAAG,IAAA,6BAAgB,GAAE,CAAC;KAC/B;IACD,MAAM,EACJ,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,EACxB,eAAe,GAChB,GAAG,QAAQ,CAAC;IACb,MAA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ACR;IAED,MAAM,eAAe,GACnB,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IAEtE,MAAM,KAAK,GAAG,eAAe;QAC3B,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE;QAC1B,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAEjC,IAAI,CAAC,KAAK,CACR,gBAAgB,EAChB,IAAA,6BAAoB,EAAC,QAAQ,EAAE;QAC7B;YACE,IAAI,EAAE,mBAAU,CAAC,MAAM;YACvB,KAAK;YACL,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,KAAK;SACjC;KACF,CAAC,CACH,CAAC;AACJ,CAAC;AAhFD,4CAgFC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { Schema } from '../schema';
|
|
3
|
+
/**
|
|
4
|
+
* Updates the tsconfig paths to remove the project.
|
|
5
|
+
*
|
|
6
|
+
* @param schema The options provided to the schematic
|
|
7
|
+
*/
|
|
8
|
+
export declare function updateTsconfig(tree: Tree, schema: Schema): Promise<void>;
|