@ohos-ports/nx 19.8.4-beta.2 → 20.8.4-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/.eslintrc.json +146 -0
- package/LICENSE +1 -1
- package/bin/init-local.js +0 -39
- package/bin/nx.js +28 -15
- package/bin/post-install.js +7 -5
- package/migrations.json +11 -37
- package/ohos-build/build-Cargo.toml.patch +12 -0
- package/ohos-build/build-cargo-config.patch +20 -0
- package/ohos-build/index.js.patch +18 -0
- package/ohos-build/native-bindings.js.patch +25 -0
- package/ohos-build/nix-0.25.1-ohos.patch +539 -0
- package/ohos-build/nix-0.27.1-ohos.patch +436 -0
- package/package.json +25 -62
- package/plugins/package-json.d.ts +5 -1
- package/plugins/package-json.js +27 -2
- package/release/changelog-renderer/index.d.ts +102 -0
- package/release/changelog-renderer/index.js +339 -0
- package/release/index.d.ts +4 -0
- package/release/index.js +13 -0
- package/schemas/nx-schema.json +964 -0
- package/schemas/project-schema.json +331 -0
- package/schemas/workspace-schema.json +185 -0
- package/src/adapter/angular-json.js +2 -8
- package/src/adapter/compat.d.ts +1 -1
- package/src/adapter/compat.js +3 -1
- package/src/adapter/ngcli-adapter.js +7 -7
- package/src/command-line/add/add.js +21 -48
- package/src/command-line/affected/affected.js +3 -3
- package/src/command-line/connect/view-logs.js +1 -1
- package/src/command-line/examples.js +0 -4
- package/src/command-line/exec/exec.js +3 -3
- package/src/command-line/format/command-object.js +9 -0
- package/src/command-line/format/format.js +10 -6
- package/src/command-line/generate/command-object.js +1 -2
- package/src/command-line/generate/generate.d.ts +1 -1
- package/src/command-line/generate/generate.js +3 -1
- package/src/command-line/generate/generator-utils.js +10 -5
- package/src/command-line/graph/graph.js +6 -9
- package/src/command-line/import/import.js +110 -71
- package/src/command-line/init/command-object.js +25 -9
- package/src/command-line/init/configure-plugins.d.ts +34 -0
- package/src/command-line/init/configure-plugins.js +203 -0
- package/src/command-line/init/implementation/add-nx-to-turborepo.d.ts +4 -0
- package/src/command-line/init/implementation/add-nx-to-turborepo.js +49 -0
- package/src/command-line/init/implementation/angular/integrated-workspace.js +1 -1
- package/src/command-line/init/implementation/angular/legacy-angular-versions.js +4 -3
- package/src/command-line/init/implementation/angular/standalone-workspace.js +8 -5
- package/src/command-line/init/implementation/check-compatible-with-plugins.d.ts +15 -0
- package/src/command-line/init/implementation/check-compatible-with-plugins.js +134 -0
- package/src/command-line/init/implementation/deduce-default-base.d.ts +1 -0
- package/src/command-line/init/implementation/deduce-default-base.js +53 -0
- package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +1 -1
- package/src/command-line/init/implementation/dot-nx/nxw.js +1 -1
- package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.js +6 -4
- package/src/command-line/init/implementation/react/check-for-uncommitted-changes.js +1 -1
- package/src/command-line/init/implementation/react/index.d.ts +1 -1
- package/src/command-line/init/implementation/react/index.js +33 -186
- package/src/command-line/init/implementation/react/write-vite-config.js +19 -3
- package/src/command-line/init/implementation/utils.d.ts +6 -2
- package/src/command-line/init/implementation/utils.js +116 -37
- package/src/command-line/init/init-v1.js +2 -2
- package/src/command-line/init/init-v2.d.ts +2 -2
- package/src/command-line/init/init-v2.js +73 -55
- package/src/command-line/login/login.js +3 -0
- package/src/command-line/logout/logout.js +3 -0
- package/src/command-line/migrate/command-object.js +2 -96
- package/src/command-line/migrate/migrate.d.ts +1 -0
- package/src/command-line/migrate/migrate.js +111 -19
- package/src/command-line/nx-commands.js +20 -6
- package/src/command-line/register/command-object.d.ts +6 -0
- package/src/command-line/{activate-powerpack → register}/command-object.js +9 -9
- package/src/command-line/register/register.d.ts +2 -0
- package/src/command-line/register/register.js +9 -0
- package/src/command-line/release/changelog.d.ts +5 -4
- package/src/command-line/release/changelog.js +64 -79
- package/src/command-line/release/command-object.d.ts +7 -4
- package/src/command-line/release/command-object.js +24 -13
- package/src/command-line/release/config/config.d.ts +8 -7
- package/src/command-line/release/config/config.js +173 -43
- package/src/command-line/release/config/conventional-commits.js +7 -0
- package/src/command-line/release/config/filter-release-groups.d.ts +4 -0
- package/src/command-line/release/config/filter-release-groups.js +10 -3
- package/src/command-line/release/config/use-legacy-versioning.d.ts +2 -0
- package/src/command-line/release/config/use-legacy-versioning.js +9 -0
- package/src/command-line/release/config/version-plans.js +1 -1
- package/src/command-line/release/index.d.ts +9 -2
- package/src/command-line/release/index.js +6 -1
- package/src/command-line/release/plan-check.js +6 -3
- package/src/command-line/release/plan.js +8 -4
- package/src/command-line/release/publish.d.ts +6 -1
- package/src/command-line/release/publish.js +50 -27
- package/src/command-line/release/release.js +33 -20
- package/src/command-line/release/utils/batch-projects-by-generator-config.js +6 -3
- package/src/command-line/release/utils/exec-command.js +1 -1
- package/src/command-line/release/utils/git.d.ts +3 -2
- package/src/command-line/release/utils/git.js +104 -19
- package/src/command-line/release/utils/github.d.ts +1 -0
- package/src/command-line/release/utils/github.js +6 -2
- package/src/command-line/release/utils/launch-editor.js +2 -2
- package/src/command-line/release/utils/resolve-changelog-renderer.d.ts +2 -2
- package/src/command-line/release/utils/resolve-changelog-renderer.js +3 -3
- package/src/command-line/release/utils/resolve-semver-specifier.d.ts +2 -1
- package/src/command-line/release/utils/resolve-semver-specifier.js +2 -1
- package/src/command-line/release/utils/semver.d.ts +8 -0
- package/src/command-line/release/utils/semver.js +8 -0
- package/src/command-line/release/utils/shared-legacy.d.ts +25 -0
- package/src/command-line/release/utils/shared-legacy.js +2 -0
- package/src/command-line/release/utils/shared.d.ts +11 -17
- package/src/command-line/release/version/derive-specifier-from-conventional-commits.d.ts +7 -0
- package/src/command-line/release/version/derive-specifier-from-conventional-commits.js +47 -0
- package/src/command-line/release/version/deriver-specifier-from-version-plans.d.ts +8 -0
- package/src/command-line/release/version/deriver-specifier-from-version-plans.js +59 -0
- package/src/command-line/release/version/project-logger.d.ts +8 -0
- package/src/command-line/release/version/project-logger.js +45 -0
- package/src/command-line/release/version/release-group-processor.d.ts +251 -0
- package/src/command-line/release/version/release-group-processor.js +1048 -0
- package/src/command-line/release/version/resolve-current-version.d.ts +32 -0
- package/src/command-line/release/version/resolve-current-version.js +241 -0
- package/src/command-line/release/version/test-utils.d.ts +95 -0
- package/src/command-line/release/version/test-utils.js +416 -0
- package/src/command-line/release/version/topological-sort.d.ts +9 -0
- package/src/command-line/release/version/topological-sort.js +41 -0
- package/src/command-line/release/version/version-actions.d.ts +170 -0
- package/src/command-line/release/version/version-actions.js +183 -0
- package/src/command-line/release/version-legacy.d.ts +46 -0
- package/src/command-line/release/version-legacy.js +453 -0
- package/src/command-line/release/version.d.ts +0 -40
- package/src/command-line/release/version.js +93 -255
- package/src/command-line/report/report.d.ts +7 -3
- package/src/command-line/report/report.js +52 -16
- package/src/command-line/run/executor-utils.js +4 -4
- package/src/command-line/run/run-one.js +37 -15
- package/src/command-line/run/run.js +1 -2
- package/src/command-line/run-many/run-many.js +1 -4
- package/src/command-line/show/project.js +25 -3
- package/src/command-line/show/projects.js +4 -0
- package/src/command-line/sync/sync.js +3 -3
- package/src/command-line/watch/watch.js +1 -1
- package/src/command-line/yargs-utils/shared-options.d.ts +4 -0
- package/src/command-line/yargs-utils/shared-options.js +26 -0
- package/src/config/misc-interfaces.d.ts +3 -15
- package/src/config/nx-json.d.ts +145 -19
- package/src/config/project-graph.d.ts +4 -4
- package/src/config/project-graph.js +8 -0
- package/src/config/schema-utils.d.ts +4 -3
- package/src/config/schema-utils.js +71 -4
- package/src/config/workspace-json-project-json.d.ts +23 -2
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/runtime.js +1 -1
- package/src/core/graph/styles.css +2 -2
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/client/client.d.ts +5 -0
- package/src/daemon/client/client.js +42 -4
- package/src/daemon/client/generate-help-output.js +1 -1
- package/src/daemon/message-types/glob.d.ts +7 -0
- package/src/daemon/message-types/glob.js +9 -1
- package/src/daemon/message-types/hash-glob.d.ts +6 -0
- package/src/daemon/message-types/hash-glob.js +9 -1
- package/src/daemon/message-types/run-tasks-execution-hooks.d.ts +13 -0
- package/src/daemon/message-types/run-tasks-execution-hooks.js +19 -0
- package/src/daemon/server/handle-glob.d.ts +1 -0
- package/src/daemon/server/handle-glob.js +8 -0
- package/src/daemon/server/handle-hash-glob.d.ts +1 -0
- package/src/daemon/server/handle-hash-glob.js +8 -0
- package/src/daemon/server/handle-hash-tasks.js +1 -1
- package/src/daemon/server/handle-tasks-execution-hooks.d.ts +19 -0
- package/src/daemon/server/handle-tasks-execution-hooks.js +35 -0
- package/src/daemon/server/logger.js +2 -1
- package/src/daemon/server/project-graph-incremental-recomputation.js +5 -5
- package/src/daemon/server/server.js +26 -2
- package/src/daemon/server/shutdown-utils.js +4 -2
- package/src/devkit-exports.d.ts +10 -7
- package/src/devkit-exports.js +4 -6
- package/src/devkit-internals.d.ts +4 -2
- package/src/devkit-internals.js +8 -3
- package/src/executors/run-commands/run-commands.impl.d.ts +1 -0
- package/src/executors/run-commands/run-commands.impl.js +11 -4
- package/src/executors/run-commands/schema.json +14 -0
- package/src/executors/run-script/run-script.impl.js +1 -1
- package/src/executors/utils/convert-nx-executor.js +2 -4
- package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +8 -0
- package/src/generators/testing-utils/create-tree.js +5 -1
- package/src/generators/utils/nx-json.d.ts +1 -1
- package/src/generators/utils/project-configuration.js +15 -4
- package/src/hasher/create-task-hasher.js +1 -1
- package/src/hasher/file-hasher.d.ts +1 -0
- package/src/hasher/file-hasher.js +5 -0
- package/src/hasher/hash-task.js +1 -1
- package/src/hasher/task-hasher.d.ts +2 -6
- package/src/hasher/task-hasher.js +6 -32
- package/src/migrations/update-20-0-0/move-use-daemon-process.d.ts +2 -0
- package/src/migrations/update-20-0-0/move-use-daemon-process.js +25 -0
- package/src/migrations/update-20-0-1/use-legacy-cache.d.ts +2 -0
- package/src/migrations/update-20-0-1/use-legacy-cache.js +20 -0
- package/src/native/index.d.ts +49 -20
- package/src/native/index.js +18 -3
- package/src/native/native-bindings.js +12 -2
- package/src/native/nx.openharmony-arm64.node +0 -0
- package/src/native/nx.wasi-browser.js +11 -8
- package/src/native/nx.wasi.cjs +11 -8
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/native/tests/__fixtures__/file-lock.fixture.js +20 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -2
- package/src/nx-cloud/update-manager.js +13 -1
- package/src/plugins/js/index.js +2 -2
- package/src/plugins/js/lock-file/lock-file.js +28 -13
- package/src/plugins/js/lock-file/utils/package-json.d.ts +1 -1
- package/src/plugins/js/lock-file/utils/package-json.js +3 -1
- package/src/plugins/js/lock-file/yarn-parser.js +102 -44
- package/src/plugins/js/project-graph/affected/lock-file-changes.js +1 -0
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +2 -2
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.js +6 -20
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +1 -1
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +14 -2
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +81 -19
- package/src/plugins/js/utils/config.js +2 -9
- package/src/plugins/js/utils/packages.d.ts +8 -0
- package/src/plugins/js/utils/packages.js +91 -0
- package/src/plugins/js/utils/register.d.ts +5 -1
- package/src/plugins/js/utils/register.js +2 -1
- package/src/plugins/js/utils/typescript.d.ts +1 -0
- package/src/plugins/js/utils/typescript.js +4 -3
- package/src/plugins/js/versions.d.ts +1 -1
- package/src/plugins/js/versions.js +1 -1
- package/src/plugins/package-json/create-nodes.d.ts +7 -8
- package/src/plugins/package-json/create-nodes.js +34 -12
- package/src/project-graph/affected/affected-project-graph.js +3 -0
- package/src/project-graph/affected/locators/project-glob-changes.js +16 -4
- package/src/project-graph/build-project-graph.d.ts +2 -1
- package/src/project-graph/build-project-graph.js +66 -43
- package/src/project-graph/error-types.d.ts +15 -12
- package/src/project-graph/error-types.js +109 -23
- package/src/project-graph/file-utils.d.ts +3 -3
- package/src/project-graph/file-utils.js +8 -7
- package/src/project-graph/nx-deps-cache.d.ts +6 -3
- package/src/project-graph/nx-deps-cache.js +66 -11
- package/src/project-graph/plugins/get-plugins.d.ts +4 -0
- package/src/project-graph/plugins/get-plugins.js +144 -0
- package/src/project-graph/plugins/in-process-loader.d.ts +10 -0
- package/src/project-graph/plugins/in-process-loader.js +60 -0
- package/src/project-graph/plugins/index.d.ts +2 -1
- package/src/project-graph/plugins/index.js +5 -3
- package/src/project-graph/plugins/isolation/enabled.d.ts +1 -0
- package/src/project-graph/plugins/isolation/enabled.js +19 -0
- package/src/project-graph/plugins/isolation/index.d.ts +2 -2
- package/src/project-graph/plugins/isolation/index.js +1 -7
- package/src/project-graph/plugins/isolation/messaging.d.ts +39 -21
- package/src/project-graph/plugins/isolation/messaging.js +5 -1
- package/src/project-graph/plugins/isolation/plugin-pool.d.ts +1 -1
- package/src/project-graph/plugins/isolation/plugin-pool.js +58 -49
- package/src/project-graph/plugins/isolation/plugin-worker.js +79 -29
- package/src/project-graph/plugins/load-resolved-plugin.d.ts +3 -0
- package/src/project-graph/plugins/load-resolved-plugin.js +22 -0
- package/src/project-graph/plugins/loaded-nx-plugin.d.ts +20 -0
- package/src/project-graph/plugins/loaded-nx-plugin.js +80 -0
- package/src/project-graph/plugins/public-api.d.ts +32 -13
- package/src/project-graph/plugins/resolve-plugin.d.ts +15 -0
- package/src/project-graph/plugins/resolve-plugin.js +134 -0
- package/src/project-graph/plugins/tasks-execution-hooks.d.ts +3 -0
- package/src/project-graph/plugins/tasks-execution-hooks.js +65 -0
- package/src/project-graph/plugins/transpiler.d.ts +8 -0
- package/src/project-graph/plugins/transpiler.js +47 -0
- package/src/project-graph/plugins/utils.d.ts +2 -8
- package/src/project-graph/plugins/utils.js +2 -39
- package/src/project-graph/project-graph.d.ts +3 -1
- package/src/project-graph/project-graph.js +86 -20
- package/src/project-graph/utils/project-configuration-utils.d.ts +2 -2
- package/src/project-graph/utils/project-configuration-utils.js +55 -25
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +3 -7
- package/src/project-graph/utils/retrieve-workspace-files.js +17 -23
- package/src/tasks-runner/batch/batch-messages.d.ts +2 -0
- package/src/tasks-runner/batch/run-batch.js +2 -4
- package/src/tasks-runner/cache.d.ts +22 -4
- package/src/tasks-runner/cache.js +160 -18
- package/src/tasks-runner/create-task-graph.d.ts +13 -1
- package/src/tasks-runner/create-task-graph.js +50 -22
- package/src/tasks-runner/default-tasks-runner.d.ts +1 -0
- package/src/tasks-runner/default-tasks-runner.js +20 -2
- package/src/tasks-runner/forked-process-task-runner.d.ts +4 -1
- package/src/tasks-runner/forked-process-task-runner.js +62 -40
- package/src/tasks-runner/init-tasks-runner.js +0 -2
- package/src/tasks-runner/life-cycle.d.ts +7 -0
- package/src/tasks-runner/run-command.d.ts +2 -4
- package/src/tasks-runner/run-command.js +51 -18
- package/src/tasks-runner/task-graph-utils.d.ts +11 -0
- package/src/tasks-runner/task-graph-utils.js +23 -0
- package/src/tasks-runner/task-orchestrator.js +14 -4
- package/src/tasks-runner/utils.js +2 -0
- package/src/utils/ab-testing.js +1 -1
- package/src/utils/assert-workspace-validity.js +4 -0
- package/src/utils/child-process.d.ts +4 -0
- package/src/utils/child-process.js +23 -30
- package/src/utils/command-line-utils.d.ts +5 -3
- package/src/utils/command-line-utils.js +37 -57
- package/src/utils/db-connection.d.ts +2 -1
- package/src/utils/db-connection.js +7 -0
- package/src/utils/default-base.js +1 -1
- package/src/utils/delayed-spinner.d.ts +42 -0
- package/src/utils/delayed-spinner.js +80 -0
- package/src/utils/find-matching-projects.js +13 -1
- package/src/utils/git-utils.index-filter.js +2 -2
- package/src/utils/git-utils.js +4 -4
- package/src/utils/git-utils.tree-filter.js +1 -1
- package/src/utils/handle-errors.js +24 -13
- package/src/utils/is-ci.js +4 -1
- package/src/utils/is-using-prettier.d.ts +3 -0
- package/src/utils/is-using-prettier.js +62 -0
- package/src/utils/nx-cloud-utils.js +3 -0
- package/src/utils/nx-key.d.ts +7 -0
- package/src/utils/nx-key.js +52 -0
- package/src/utils/package-json.d.ts +5 -1
- package/src/utils/package-json.js +9 -3
- package/src/utils/package-manager.d.ts +14 -0
- package/src/utils/package-manager.js +89 -3
- package/src/utils/path.js +1 -1
- package/src/utils/plugins/core-plugins.js +4 -0
- package/src/utils/plugins/plugin-capabilities.js +4 -5
- package/src/utils/print-help.js +3 -9
- package/src/utils/require-nx-key.d.ts +1 -0
- package/src/utils/require-nx-key.js +22 -0
- package/src/utils/sync-generators.js +9 -14
- package/src/utils/task-history.d.ts +1 -1
- package/src/utils/task-history.js +2 -2
- package/src/utils/workspace-context.d.ts +2 -0
- package/src/utils/workspace-context.js +16 -0
- package/tasks-runners/default.d.ts +1 -0
- package/tasks-runners/default.js +5 -0
- package/src/command-line/activate-powerpack/activate-powerpack.d.ts +0 -2
- package/src/command-line/activate-powerpack/activate-powerpack.js +0 -34
- package/src/command-line/activate-powerpack/command-object.d.ts +0 -6
- package/src/command-line/import/utils/needs-install.d.ts +0 -3
- package/src/command-line/import/utils/needs-install.js +0 -31
- package/src/command-line/init/implementation/react/write-craco-config.d.ts +0 -1
- package/src/command-line/init/implementation/react/write-craco-config.js +0 -61
- package/src/daemon/server/plugins.d.ts +0 -3
- package/src/daemon/server/plugins.js +0 -32
- package/src/hasher/node-task-hasher-impl.d.ts +0 -48
- package/src/hasher/node-task-hasher-impl.js +0 -449
- package/src/migrations/update-15-0-0/migrate-to-inputs.d.ts +0 -2
- package/src/migrations/update-15-0-0/migrate-to-inputs.js +0 -102
- package/src/migrations/update-15-0-0/prefix-outputs.d.ts +0 -2
- package/src/migrations/update-15-0-0/prefix-outputs.js +0 -49
- package/src/migrations/update-16-0-0/remove-nrwl-cli.d.ts +0 -2
- package/src/migrations/update-16-0-0/remove-nrwl-cli.js +0 -16
- package/src/migrations/update-16-0-0/update-depends-on-to-tokens.d.ts +0 -2
- package/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +0 -97
- package/src/migrations/update-16-0-0/update-nx-cloud-runner.d.ts +0 -2
- package/src/migrations/update-16-0-0/update-nx-cloud-runner.js +0 -29
- package/src/migrations/update-16-2-0/remove-run-commands-output-path.d.ts +0 -2
- package/src/migrations/update-16-2-0/remove-run-commands-output-path.js +0 -45
- package/src/migrations/update-16-8-0/escape-dollar-sign-env-variables.d.ts +0 -12
- package/src/migrations/update-16-8-0/escape-dollar-sign-env-variables.js +0 -67
- package/src/migrations/update-16-9-0/remove-project-name-and-root-format.d.ts +0 -2
- package/src/migrations/update-16-9-0/remove-project-name-and-root-format.js +0 -21
- package/src/native/nx.ohos-arm64.node +0 -0
- package/src/project-graph/plugins/internal-api.d.ts +0 -29
- package/src/project-graph/plugins/internal-api.js +0 -134
- package/src/project-graph/plugins/loader.d.ts +0 -24
- package/src/project-graph/plugins/loader.js +0 -220
- package/src/utils/app-root.d.ts +0 -8
- package/src/utils/app-root.js +0 -12
- package/src/utils/nx-plugin.deprecated.d.ts +0 -31
- package/src/utils/nx-plugin.deprecated.js +0 -20
- package/src/utils/powerpack.d.ts +0 -5
- package/src/utils/powerpack.js +0 -33
- package/src/utils/workspace-configuration-check.d.ts +0 -1
- package/src/utils/workspace-configuration-check.js +0 -36
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.importHandler = importHandler;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
-
const minimatch_1 = require("minimatch");
|
|
6
5
|
const node_fs_1 = require("node:fs");
|
|
7
6
|
const chalk = require("chalk");
|
|
8
|
-
const js_yaml_1 = require("@zkochan/js-yaml");
|
|
9
7
|
const git_utils_1 = require("../../utils/git-utils");
|
|
10
8
|
const promises_1 = require("node:fs/promises");
|
|
11
9
|
const tmp_1 = require("tmp");
|
|
@@ -21,12 +19,13 @@ const utils_1 = require("../init/implementation/utils");
|
|
|
21
19
|
const command_line_utils_1 = require("../../utils/command-line-utils");
|
|
22
20
|
const prepare_source_repo_1 = require("./utils/prepare-source-repo");
|
|
23
21
|
const merge_remote_source_1 = require("./utils/merge-remote-source");
|
|
24
|
-
const
|
|
25
|
-
const
|
|
22
|
+
const minimatch_1 = require("minimatch");
|
|
23
|
+
const configure_plugins_1 = require("../init/configure-plugins");
|
|
24
|
+
const check_compatible_with_plugins_1 = require("../init/implementation/check-compatible-with-plugins");
|
|
26
25
|
const importRemoteName = '__tmp_nx_import__';
|
|
27
26
|
async function importHandler(options) {
|
|
28
27
|
process.env.NX_RUNNING_NX_IMPORT = 'true';
|
|
29
|
-
let { sourceRepository, ref, source, destination } = options;
|
|
28
|
+
let { sourceRepository, ref, source, destination, verbose } = options;
|
|
30
29
|
const destinationGitClient = new git_utils_1.GitRepository(process.cwd());
|
|
31
30
|
if (await destinationGitClient.hasUncommittedChanges()) {
|
|
32
31
|
throw new Error(`You have uncommitted changes in the destination repository. Commit or revert the changes and try again.`);
|
|
@@ -143,7 +142,6 @@ async function importHandler(options) {
|
|
|
143
142
|
throw new Error(`The source directory ${source} does not exist in ${sourceRepository}. Please double check to make sure it exists.`);
|
|
144
143
|
}
|
|
145
144
|
const packageManager = (0, package_manager_1.detectPackageManager)(workspace_root_1.workspaceRoot);
|
|
146
|
-
const originalPackageWorkspaces = await (0, needs_install_1.getPackagesInPackageManagerWorkspace)(packageManager);
|
|
147
145
|
const sourceIsNxWorkspace = (0, node_fs_1.existsSync)((0, path_1.join)(sourceGitClient.root, 'nx.json'));
|
|
148
146
|
const relativeDestination = (0, path_1.relative)(destinationGitClient.root, absDestination);
|
|
149
147
|
await (0, prepare_source_repo_1.prepareSourceRepo)(sourceGitClient, ref, source, relativeDestination, tempImportBranch, sourceRepository);
|
|
@@ -166,40 +164,29 @@ async function importHandler(options) {
|
|
|
166
164
|
],
|
|
167
165
|
});
|
|
168
166
|
}
|
|
169
|
-
|
|
170
|
-
let
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
(0,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
output_1.output.error({
|
|
180
|
-
title: `Install failed: ${e.message || 'Unknown error'}`,
|
|
181
|
-
bodyLines: [e.stack],
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
else if (await (0, needs_install_1.needsInstall)(packageManager, originalPackageWorkspaces)) {
|
|
186
|
-
try {
|
|
187
|
-
output_1.output.log({
|
|
188
|
-
title: 'Installing dependencies for imported code',
|
|
189
|
-
});
|
|
190
|
-
(0, utils_1.runInstall)(workspace_root_1.workspaceRoot, (0, package_manager_1.getPackageManagerCommand)(packageManager));
|
|
191
|
-
await destinationGitClient.amendCommit();
|
|
167
|
+
await handleMissingWorkspacesEntry(packageManager, pmc, relativeDestination, destinationGitClient);
|
|
168
|
+
let installed = await runInstallDestinationRepo(packageManager, destinationGitClient);
|
|
169
|
+
if (installed) {
|
|
170
|
+
// Check compatibility with existing plugins for the workspace included new imported projects
|
|
171
|
+
if (nxJson.plugins?.length > 0) {
|
|
172
|
+
const incompatiblePlugins = await (0, check_compatible_with_plugins_1.checkCompatibleWithPlugins)();
|
|
173
|
+
if (Object.keys(incompatiblePlugins).length > 0) {
|
|
174
|
+
(0, check_compatible_with_plugins_1.updatePluginsInNxJson)(workspace_root_1.workspaceRoot, incompatiblePlugins);
|
|
175
|
+
await destinationGitClient.amendCommit();
|
|
176
|
+
}
|
|
192
177
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
178
|
+
if (plugins.length > 0) {
|
|
179
|
+
installed = await runPluginsInstall(plugins, pmc, destinationGitClient);
|
|
180
|
+
if (installed) {
|
|
181
|
+
const { succeededPlugins } = await (0, configure_plugins_1.configurePlugins)(plugins, updatePackageScripts, pmc, workspace_root_1.workspaceRoot, verbose);
|
|
182
|
+
if (succeededPlugins.length > 0) {
|
|
183
|
+
await destinationGitClient.amendCommit();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
199
186
|
}
|
|
200
187
|
}
|
|
201
188
|
console.log(await destinationGitClient.showStat());
|
|
202
|
-
if (
|
|
189
|
+
if (installed === false) {
|
|
203
190
|
const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
|
204
191
|
output_1.output.warn({
|
|
205
192
|
title: `The import was successful, but the install failed`,
|
|
@@ -207,8 +194,23 @@ async function importHandler(options) {
|
|
|
207
194
|
`You may need to run "${pmc.install}" manually to resolve the issue. The error is logged above.`,
|
|
208
195
|
],
|
|
209
196
|
});
|
|
197
|
+
if (plugins.length > 0) {
|
|
198
|
+
output_1.output.error({
|
|
199
|
+
title: `Failed to install plugins`,
|
|
200
|
+
bodyLines: [
|
|
201
|
+
'The following plugins were not installed:',
|
|
202
|
+
...plugins.map((p) => `- ${chalk.bold(p)}`),
|
|
203
|
+
],
|
|
204
|
+
});
|
|
205
|
+
output_1.output.error({
|
|
206
|
+
title: `To install the plugins manually`,
|
|
207
|
+
bodyLines: [
|
|
208
|
+
'You may need to run commands to install the plugins:',
|
|
209
|
+
...plugins.map((p) => `- ${chalk.bold(pmc.exec + ' nx add ' + p)}`),
|
|
210
|
+
],
|
|
211
|
+
});
|
|
212
|
+
}
|
|
210
213
|
}
|
|
211
|
-
await warnOnMissingWorkspacesEntry(packageManager, pmc, relativeDestination);
|
|
212
214
|
if (source != destination) {
|
|
213
215
|
output_1.output.warn({
|
|
214
216
|
title: `Check configuration files`,
|
|
@@ -259,9 +261,59 @@ async function createTemporaryRemote(destinationGitClient, sourceRemoteUrl, remo
|
|
|
259
261
|
await destinationGitClient.addGitRemote(remoteName, sourceRemoteUrl);
|
|
260
262
|
await destinationGitClient.fetch(remoteName);
|
|
261
263
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
264
|
+
/**
|
|
265
|
+
* Run install for the imported code and plugins
|
|
266
|
+
* @returns true if the install failed
|
|
267
|
+
*/
|
|
268
|
+
async function runInstallDestinationRepo(packageManager, destinationGitClient) {
|
|
269
|
+
let installed = true;
|
|
270
|
+
try {
|
|
271
|
+
output_1.output.log({
|
|
272
|
+
title: 'Installing dependencies for imported code',
|
|
273
|
+
});
|
|
274
|
+
(0, utils_1.runInstall)(workspace_root_1.workspaceRoot, (0, package_manager_1.getPackageManagerCommand)(packageManager));
|
|
275
|
+
await destinationGitClient.amendCommit();
|
|
276
|
+
}
|
|
277
|
+
catch (e) {
|
|
278
|
+
installed = false;
|
|
279
|
+
output_1.output.error({
|
|
280
|
+
title: `Install failed: ${e.message || 'Unknown error'}`,
|
|
281
|
+
bodyLines: [e.stack],
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
return installed;
|
|
285
|
+
}
|
|
286
|
+
async function runPluginsInstall(plugins, pmc, destinationGitClient) {
|
|
287
|
+
let installed = true;
|
|
288
|
+
output_1.output.log({ title: 'Installing Plugins' });
|
|
289
|
+
try {
|
|
290
|
+
(0, configure_plugins_1.installPluginPackages)(workspace_root_1.workspaceRoot, pmc, plugins);
|
|
291
|
+
await destinationGitClient.amendCommit();
|
|
292
|
+
}
|
|
293
|
+
catch (e) {
|
|
294
|
+
installed = false;
|
|
295
|
+
output_1.output.error({
|
|
296
|
+
title: `Install failed: ${e.message || 'Unknown error'}`,
|
|
297
|
+
bodyLines: [
|
|
298
|
+
'The following plugins were not installed:',
|
|
299
|
+
...plugins.map((p) => `- ${chalk.bold(p)}`),
|
|
300
|
+
e.stack,
|
|
301
|
+
],
|
|
302
|
+
});
|
|
303
|
+
output_1.output.error({
|
|
304
|
+
title: `To install the plugins manually`,
|
|
305
|
+
bodyLines: [
|
|
306
|
+
'You may need to run commands to install the plugins:',
|
|
307
|
+
...plugins.map((p) => `- ${chalk.bold(pmc.exec + ' nx add ' + p)}`),
|
|
308
|
+
],
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
return installed;
|
|
312
|
+
}
|
|
313
|
+
/*
|
|
314
|
+
* If the user imports a project that isn't in the workspaces entry, we should add that path to the workspaces entry.
|
|
315
|
+
*/
|
|
316
|
+
async function handleMissingWorkspacesEntry(pm, pmc, pkgPath, destinationGitClient) {
|
|
265
317
|
if (!(0, package_manager_1.isWorkspacesEnabled)(pm, workspace_root_1.workspaceRoot)) {
|
|
266
318
|
output_1.output.warn({
|
|
267
319
|
title: `Missing workspaces in package.json`,
|
|
@@ -292,37 +344,24 @@ async function warnOnMissingWorkspacesEntry(pm, pmc, pkgPath) {
|
|
|
292
344
|
});
|
|
293
345
|
}
|
|
294
346
|
else {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (
|
|
298
|
-
|
|
299
|
-
workspaces = packageJson.workspaces;
|
|
300
|
-
}
|
|
301
|
-
else if (pm === 'pnpm') {
|
|
302
|
-
const yamlPath = (0, path_1.join)(workspace_root_1.workspaceRoot, 'pnpm-workspace.yaml');
|
|
303
|
-
if ((0, node_fs_1.existsSync)(yamlPath)) {
|
|
304
|
-
const yamlContent = await node_fs_1.promises.readFile(yamlPath, 'utf-8');
|
|
305
|
-
const yaml = (0, js_yaml_1.load)(yamlContent);
|
|
306
|
-
workspaces = yaml.packages;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
if (workspaces) {
|
|
310
|
-
const isPkgIncluded = workspaces.some((w) => (0, minimatch_1.minimatch)(pkgPath, w));
|
|
311
|
-
if (!isPkgIncluded) {
|
|
312
|
-
const pkgsDir = (0, path_1.dirname)(pkgPath);
|
|
313
|
-
output_1.output.warn({
|
|
314
|
-
title: `Project missing in workspaces`,
|
|
315
|
-
bodyLines: pm === 'npm' || pm === 'yarn' || pm === 'bun'
|
|
316
|
-
? [
|
|
317
|
-
`The imported project (${pkgPath}) is missing the "workspaces" field in package.json.`,
|
|
318
|
-
`Add "${pkgsDir}/*" to workspaces run "${pmc.install}".`,
|
|
319
|
-
]
|
|
320
|
-
: [
|
|
321
|
-
`The imported project (${pkgPath}) is missing the "packages" field in pnpm-workspaces.yaml.`,
|
|
322
|
-
`Add "${pkgsDir}/*" to packages run "${pmc.install}".`,
|
|
323
|
-
],
|
|
324
|
-
});
|
|
325
|
-
}
|
|
347
|
+
let workspaces = (0, package_manager_1.getPackageWorkspaces)(pm, workspace_root_1.workspaceRoot);
|
|
348
|
+
const isPkgIncluded = workspaces.some((w) => (0, minimatch_1.minimatch)(pkgPath, w));
|
|
349
|
+
if (isPkgIncluded) {
|
|
350
|
+
return;
|
|
326
351
|
}
|
|
352
|
+
(0, package_manager_1.addPackagePathToWorkspaces)(pkgPath, pm, workspaces, workspace_root_1.workspaceRoot);
|
|
353
|
+
await destinationGitClient.amendCommit();
|
|
354
|
+
output_1.output.success({
|
|
355
|
+
title: `Project added in workspaces`,
|
|
356
|
+
bodyLines: pm === 'npm' || pm === 'yarn' || pm === 'bun'
|
|
357
|
+
? [
|
|
358
|
+
`The imported project (${chalk.bold(pkgPath)}) is missing the "workspaces" field in package.json.`,
|
|
359
|
+
`Added "${chalk.bold(pkgPath)}" to workspaces.`,
|
|
360
|
+
]
|
|
361
|
+
: [
|
|
362
|
+
`The imported project (${chalk.bold(pkgPath)}) is missing the "packages" field in pnpm-workspaces.yaml.`,
|
|
363
|
+
`Added "${chalk.bold(pkgPath)}" to packages.`,
|
|
364
|
+
],
|
|
365
|
+
});
|
|
327
366
|
}
|
|
328
367
|
}
|
|
@@ -2,24 +2,35 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.yargsInitCommand = void 0;
|
|
4
4
|
const shared_options_1 = require("../yargs-utils/shared-options");
|
|
5
|
-
const nx_json_1 = require("../../config/nx-json");
|
|
6
|
-
const useV2 = process.env['NX_ADD_PLUGINS'] !== 'false' &&
|
|
7
|
-
(0, nx_json_1.readNxJson)().useInferencePlugins !== false;
|
|
8
5
|
exports.yargsInitCommand = {
|
|
9
6
|
command: 'init',
|
|
10
7
|
describe: 'Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up remote caching. For more info, check https://nx.dev/recipes/adopting-nx.',
|
|
11
8
|
builder: (yargs) => withInitOptions(yargs),
|
|
12
9
|
handler: async (args) => {
|
|
13
|
-
|
|
14
|
-
await
|
|
10
|
+
try {
|
|
11
|
+
const useV2 = await isInitV2();
|
|
12
|
+
if (useV2) {
|
|
13
|
+
await require('./init-v2').initHandler(args);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
await require('./init-v1').initHandler(args);
|
|
17
|
+
}
|
|
18
|
+
process.exit(0);
|
|
15
19
|
}
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
catch {
|
|
21
|
+
// Ensure the cursor is always restored just in case the user has bailed during interactive prompts
|
|
22
|
+
process.stdout.write('\x1b[?25h');
|
|
23
|
+
process.exit(1);
|
|
18
24
|
}
|
|
19
|
-
process.exit(0);
|
|
20
25
|
},
|
|
21
26
|
};
|
|
22
|
-
function
|
|
27
|
+
async function isInitV2() {
|
|
28
|
+
return (process.env['NX_ADD_PLUGINS'] !== 'false' &&
|
|
29
|
+
(await Promise.resolve().then(() => require('../../config/nx-json'))).readNxJson().useInferencePlugins !==
|
|
30
|
+
false);
|
|
31
|
+
}
|
|
32
|
+
async function withInitOptions(yargs) {
|
|
33
|
+
const useV2 = await isInitV2();
|
|
23
34
|
if (useV2) {
|
|
24
35
|
return yargs
|
|
25
36
|
.option('nxCloud', {
|
|
@@ -35,6 +46,11 @@ function withInitOptions(yargs) {
|
|
|
35
46
|
type: 'boolean',
|
|
36
47
|
description: 'Initialize an Nx workspace setup in the .nx directory of the current repository.',
|
|
37
48
|
default: false,
|
|
49
|
+
})
|
|
50
|
+
.option('force', {
|
|
51
|
+
describe: 'Force the migration to continue and ignore custom webpack setup or uncommitted changes. Only for CRA projects.',
|
|
52
|
+
type: 'boolean',
|
|
53
|
+
default: false,
|
|
38
54
|
});
|
|
39
55
|
}
|
|
40
56
|
else {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PackageManagerCommands } from '../../utils/package-manager';
|
|
2
|
+
export declare function installPluginPackages(repoRoot: string, pmc: PackageManagerCommands, plugins: string[]): void;
|
|
3
|
+
/**
|
|
4
|
+
* Installs a plugin by running its init generator. It will change the file system tree passed in.
|
|
5
|
+
* @param plugin The name of the plugin to install
|
|
6
|
+
* @param repoRoot repo root
|
|
7
|
+
* @param pmc package manager commands
|
|
8
|
+
* @param updatePackageScripts whether to update package scripts
|
|
9
|
+
* @param verbose whether to run in verbose mode
|
|
10
|
+
* @returns void
|
|
11
|
+
*/
|
|
12
|
+
export declare function runPluginInitGenerator(plugin: string, repoRoot?: string, updatePackageScripts?: boolean, verbose?: boolean, pmc?: PackageManagerCommands): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Install plugins
|
|
15
|
+
* Get the implementation of the plugin's init generator and run it
|
|
16
|
+
* @returns a list of succeeded plugins and a map of failed plugins to errors
|
|
17
|
+
*/
|
|
18
|
+
export declare function runPluginInitGenerators(plugins: string[], updatePackageScripts: boolean, pmc: PackageManagerCommands, repoRoot?: string, verbose?: boolean): Promise<{
|
|
19
|
+
succeededPlugins: string[];
|
|
20
|
+
failedPlugins: {
|
|
21
|
+
[plugin: string]: Error;
|
|
22
|
+
};
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Configures plugins, installs them, and outputs the results
|
|
26
|
+
* @returns a list of succeeded plugins and a map of failed plugins to errors
|
|
27
|
+
*/
|
|
28
|
+
export declare function configurePlugins(plugins: string[], updatePackageScripts: boolean, pmc: PackageManagerCommands, repoRoot?: string, verbose?: boolean): Promise<{
|
|
29
|
+
succeededPlugins: string[];
|
|
30
|
+
failedPlugins: {
|
|
31
|
+
[plugin: string]: Error;
|
|
32
|
+
};
|
|
33
|
+
}>;
|
|
34
|
+
export declare function getFailedToInstallPluginErrorMessages(e: any): string[];
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.installPluginPackages = installPluginPackages;
|
|
4
|
+
exports.runPluginInitGenerator = runPluginInitGenerator;
|
|
5
|
+
exports.runPluginInitGenerators = runPluginInitGenerators;
|
|
6
|
+
exports.configurePlugins = configurePlugins;
|
|
7
|
+
exports.getFailedToInstallPluginErrorMessages = getFailedToInstallPluginErrorMessages;
|
|
8
|
+
const createSpinner = require("ora");
|
|
9
|
+
const chalk_1 = require("chalk");
|
|
10
|
+
const package_manager_1 = require("../../utils/package-manager");
|
|
11
|
+
const output_1 = require("../../utils/output");
|
|
12
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
|
13
|
+
const utils_1 = require("./implementation/utils");
|
|
14
|
+
const angular_json_1 = require("../../adapter/angular-json");
|
|
15
|
+
const error_types_1 = require("../../project-graph/error-types");
|
|
16
|
+
const generator_utils_1 = require("../generate/generator-utils");
|
|
17
|
+
const path_1 = require("path");
|
|
18
|
+
const fs_1 = require("fs");
|
|
19
|
+
const configuration_1 = require("../../config/configuration");
|
|
20
|
+
const versions_1 = require("../../utils/versions");
|
|
21
|
+
const child_process_1 = require("../../utils/child-process");
|
|
22
|
+
function installPluginPackages(repoRoot, pmc = (0, package_manager_1.getPackageManagerCommand)(), plugins) {
|
|
23
|
+
if (plugins.length === 0) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(repoRoot, 'package.json'))) {
|
|
27
|
+
(0, utils_1.addDepsToPackageJson)(repoRoot, plugins);
|
|
28
|
+
(0, utils_1.runInstall)(repoRoot, pmc);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const nxJson = (0, configuration_1.readNxJson)(repoRoot);
|
|
32
|
+
nxJson.installation.plugins ??= {};
|
|
33
|
+
for (const plugin of plugins) {
|
|
34
|
+
nxJson.installation.plugins[plugin] = versions_1.nxVersion;
|
|
35
|
+
}
|
|
36
|
+
// Invoking nx wrapper to install plugins.
|
|
37
|
+
(0, child_process_1.runNxSync)('--version', { stdio: 'ignore' });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Installs a plugin by running its init generator. It will change the file system tree passed in.
|
|
42
|
+
* @param plugin The name of the plugin to install
|
|
43
|
+
* @param repoRoot repo root
|
|
44
|
+
* @param pmc package manager commands
|
|
45
|
+
* @param updatePackageScripts whether to update package scripts
|
|
46
|
+
* @param verbose whether to run in verbose mode
|
|
47
|
+
* @returns void
|
|
48
|
+
*/
|
|
49
|
+
async function runPluginInitGenerator(plugin, repoRoot = workspace_root_1.workspaceRoot, updatePackageScripts = false, verbose = false, pmc = (0, package_manager_1.getPackageManagerCommand)()) {
|
|
50
|
+
try {
|
|
51
|
+
const { schema } = (0, generator_utils_1.getGeneratorInformation)(plugin, 'init', workspace_root_1.workspaceRoot, {});
|
|
52
|
+
let command = `g ${plugin}:init ${verbose ? '--verbose' : ''}`;
|
|
53
|
+
if (!!schema.properties['keepExistingVersions']) {
|
|
54
|
+
command += ` --keepExistingVersions`;
|
|
55
|
+
}
|
|
56
|
+
if (updatePackageScripts && !!schema.properties['updatePackageScripts']) {
|
|
57
|
+
command += ` --updatePackageScripts`;
|
|
58
|
+
}
|
|
59
|
+
(0, child_process_1.runNxSync)(command, {
|
|
60
|
+
stdio: [0, 1, 2],
|
|
61
|
+
cwd: repoRoot,
|
|
62
|
+
windowsHide: false,
|
|
63
|
+
packageManagerCommand: pmc,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// init generator does not exist, so this function should noop
|
|
68
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
69
|
+
output_1.output.log({
|
|
70
|
+
title: `No "init" generator found in ${plugin}. Skipping initialization.`,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Install plugins
|
|
78
|
+
* Get the implementation of the plugin's init generator and run it
|
|
79
|
+
* @returns a list of succeeded plugins and a map of failed plugins to errors
|
|
80
|
+
*/
|
|
81
|
+
async function runPluginInitGenerators(plugins, updatePackageScripts, pmc, repoRoot = workspace_root_1.workspaceRoot, verbose = false) {
|
|
82
|
+
if (plugins.length === 0) {
|
|
83
|
+
return {
|
|
84
|
+
succeededPlugins: [],
|
|
85
|
+
failedPlugins: {},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const spinner = createSpinner();
|
|
89
|
+
let succeededPlugins = [];
|
|
90
|
+
const failedPlugins = {};
|
|
91
|
+
for (const plugin of plugins) {
|
|
92
|
+
try {
|
|
93
|
+
spinner.start('Installing plugin ' + plugin);
|
|
94
|
+
await runPluginInitGenerator(plugin, repoRoot, updatePackageScripts, verbose, pmc);
|
|
95
|
+
succeededPlugins.push(plugin);
|
|
96
|
+
spinner.succeed('Installed plugin ' + plugin);
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
failedPlugins[plugin] = e;
|
|
100
|
+
spinner.fail('Failed to install plugin ' + plugin);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
succeededPlugins,
|
|
105
|
+
failedPlugins,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Configures plugins, installs them, and outputs the results
|
|
110
|
+
* @returns a list of succeeded plugins and a map of failed plugins to errors
|
|
111
|
+
*/
|
|
112
|
+
async function configurePlugins(plugins, updatePackageScripts, pmc, repoRoot = workspace_root_1.workspaceRoot, verbose = false) {
|
|
113
|
+
if (plugins.length === 0) {
|
|
114
|
+
return {
|
|
115
|
+
succeededPlugins: [],
|
|
116
|
+
failedPlugins: {},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
output_1.output.log({ title: '🔨 Configuring plugins' });
|
|
120
|
+
let { succeededPlugins, failedPlugins } = await runPluginInitGenerators(plugins, updatePackageScripts, pmc, repoRoot, verbose);
|
|
121
|
+
if (succeededPlugins.length > 0) {
|
|
122
|
+
output_1.output.success({
|
|
123
|
+
title: 'Installed Plugins',
|
|
124
|
+
bodyLines: succeededPlugins.map((p) => `- ${(0, chalk_1.bold)(p)}`),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (Object.keys(failedPlugins).length > 0) {
|
|
128
|
+
output_1.output.error({
|
|
129
|
+
title: `Failed to install plugins`,
|
|
130
|
+
bodyLines: [
|
|
131
|
+
'The following plugins were not installed:',
|
|
132
|
+
...Object.keys(failedPlugins).map((p) => `- ${(0, chalk_1.bold)(p)}`),
|
|
133
|
+
],
|
|
134
|
+
});
|
|
135
|
+
Object.entries(failedPlugins).forEach(([plugin, error]) => {
|
|
136
|
+
output_1.output.error({
|
|
137
|
+
title: `Failed to install ${plugin}`,
|
|
138
|
+
bodyLines: getFailedToInstallPluginErrorMessages(error),
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
output_1.output.error({
|
|
142
|
+
title: `To install the plugins manually`,
|
|
143
|
+
bodyLines: [
|
|
144
|
+
'You may need to run commands to install the plugins:',
|
|
145
|
+
...Object.keys(failedPlugins).map((p) => `- ${(0, chalk_1.bold)(pmc.exec + ' nx add ' + p)}`),
|
|
146
|
+
],
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return { succeededPlugins, failedPlugins };
|
|
150
|
+
}
|
|
151
|
+
function findInitGenerator(generators) {
|
|
152
|
+
if (generators['init']) {
|
|
153
|
+
return 'init';
|
|
154
|
+
}
|
|
155
|
+
const angularPluginInstalled = (0, angular_json_1.isAngularPluginInstalled)();
|
|
156
|
+
if (angularPluginInstalled && generators['ng-add']) {
|
|
157
|
+
return 'ng-add';
|
|
158
|
+
}
|
|
159
|
+
return Object.keys(generators).find((name) => generators[name].aliases?.includes('init') ||
|
|
160
|
+
(angularPluginInstalled && generators[name].aliases?.includes('ng-add')));
|
|
161
|
+
}
|
|
162
|
+
function getFailedToInstallPluginErrorMessages(e) {
|
|
163
|
+
const errorBodyLines = [];
|
|
164
|
+
if ((0, error_types_1.isProjectConfigurationsError)(e) && e.errors.length > 0) {
|
|
165
|
+
for (const error of e.errors) {
|
|
166
|
+
if ((0, error_types_1.isAggregateCreateNodesError)(error)) {
|
|
167
|
+
const innerErrors = error.errors;
|
|
168
|
+
for (const [file, e] of innerErrors) {
|
|
169
|
+
if (file) {
|
|
170
|
+
errorBodyLines.push(` - ${(0, chalk_1.bold)(file)}: ${e.message}`);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
errorBodyLines.push(` - ${e.message}`);
|
|
174
|
+
}
|
|
175
|
+
if (e.stack) {
|
|
176
|
+
const innerStackTrace = ' ' + e.stack.split('\n')?.join('\n ');
|
|
177
|
+
errorBodyLines.push(innerStackTrace);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else if (!(0, error_types_1.isProjectsWithNoNameError)(error)) {
|
|
182
|
+
// swallow ProjectsWithNameError
|
|
183
|
+
if (error.message) {
|
|
184
|
+
errorBodyLines.push(` - ${error.message}`);
|
|
185
|
+
}
|
|
186
|
+
if (error.stack) {
|
|
187
|
+
const innerStackTrace = ' ' + error.stack.split('\n')?.join('\n ');
|
|
188
|
+
errorBodyLines.push(innerStackTrace);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
if (e.message) {
|
|
195
|
+
errorBodyLines.push(` - ${e.message}`);
|
|
196
|
+
}
|
|
197
|
+
if (e.stack) {
|
|
198
|
+
const innerStackTrace = ' ' + e.stack.split('\n')?.join('\n ');
|
|
199
|
+
errorBodyLines.push(innerStackTrace);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return errorBodyLines;
|
|
203
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addNxToTurborepo = addNxToTurborepo;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const fileutils_1 = require("../../../utils/fileutils");
|
|
7
|
+
const output_1 = require("../../../utils/output");
|
|
8
|
+
const package_manager_1 = require("../../../utils/package-manager");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
|
+
async function addNxToTurborepo(_options) {
|
|
11
|
+
const repoRoot = process.cwd();
|
|
12
|
+
output_1.output.log({
|
|
13
|
+
title: 'Initializing Nx based on your old Turborepo configuration',
|
|
14
|
+
});
|
|
15
|
+
output_1.output.log({
|
|
16
|
+
title: '💡 Did you know?',
|
|
17
|
+
bodyLines: [
|
|
18
|
+
'- Turborepo requires you to maintain all your common scripts like "build", "lint", "test" in all your packages, as well as their applicable cache inputs and outputs.',
|
|
19
|
+
`- Nx is extensible and has plugins for the tools you use to infer all of this for you purely based on that tool's configuration file within your packages.`,
|
|
20
|
+
'',
|
|
21
|
+
' - E.g. the `@nx/vite` plugin will infer the "build" script based on the existence of a vite.config.js file.',
|
|
22
|
+
' - Therefore with zero package level config, `nx build my-app` knows to run the `vite build` CLI directly, with all Nx cache inputs and outputs automatically inferred.',
|
|
23
|
+
'',
|
|
24
|
+
`NOTE: None of your existing package.json scripts will be modified as part of this initialization process, you can already use them as-is with Nx, but you can learn more about the benefits of Nx's inferred tasks at https://nx.dev/concepts/inferred-tasks`,
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
let nxJson = (0, utils_1.createNxJsonFromTurboJson)((0, fileutils_1.readJsonFile)('turbo.json'));
|
|
28
|
+
const nxJsonPath = (0, node_path_1.join)(repoRoot, 'nx.json');
|
|
29
|
+
// Turborepo workspaces usually have prettier installed, so try and match the formatting before writing the file
|
|
30
|
+
try {
|
|
31
|
+
const prettier = await Promise.resolve().then(() => require('prettier'));
|
|
32
|
+
const config = await prettier.resolveConfig(repoRoot);
|
|
33
|
+
(0, node_fs_1.writeFileSync)(nxJsonPath,
|
|
34
|
+
// @ts-ignore - Always await prettier.format, in modern versions it's async
|
|
35
|
+
await prettier.format(JSON.stringify(nxJson, null, 2), {
|
|
36
|
+
...(config ?? {}),
|
|
37
|
+
parser: 'json',
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
// Apply fallback JSON write
|
|
42
|
+
(0, fileutils_1.writeJsonFile)(nxJsonPath, nxJson);
|
|
43
|
+
}
|
|
44
|
+
const pmc = (0, package_manager_1.getPackageManagerCommand)();
|
|
45
|
+
(0, utils_1.updateGitIgnore)(repoRoot);
|
|
46
|
+
(0, utils_1.addDepsToPackageJson)(repoRoot);
|
|
47
|
+
output_1.output.log({ title: '📦 Installing dependencies' });
|
|
48
|
+
(0, utils_1.runInstall)(repoRoot, pmc);
|
|
49
|
+
}
|
|
@@ -16,9 +16,10 @@ const connect_to_nx_cloud_1 = require("../../../connect/connect-to-nx-cloud");
|
|
|
16
16
|
const nxAngularLegacyVersionMap = {
|
|
17
17
|
14: '~17.0.0',
|
|
18
18
|
15: '~19.0.0',
|
|
19
|
+
16: '~20.1.0',
|
|
19
20
|
};
|
|
20
21
|
// min major angular version supported in latest Nx
|
|
21
|
-
const minMajorAngularVersionSupported =
|
|
22
|
+
const minMajorAngularVersionSupported = 17;
|
|
22
23
|
// version when the Nx CLI changed from @nrwl/tao & @nrwl/cli to nx
|
|
23
24
|
const versionWithConsolidatedPackages = '13.9.0';
|
|
24
25
|
// version when packages were rescoped from @nrwl/* to @nx/*
|
|
@@ -84,7 +85,7 @@ async function getLegacyMigrationFunctionIfApplicable(repoRoot, options) {
|
|
|
84
85
|
output_1.output.log({ title: '📝 Setting up workspace' });
|
|
85
86
|
(0, child_process_1.execSync)(`${pmc.exec} ${legacyMigrationCommand}`, {
|
|
86
87
|
stdio: [0, 1, 2],
|
|
87
|
-
windowsHide:
|
|
88
|
+
windowsHide: false,
|
|
88
89
|
});
|
|
89
90
|
if (useNxCloud) {
|
|
90
91
|
output_1.output.log({ title: '🛠️ Setting up Nx Cloud' });
|
|
@@ -110,7 +111,7 @@ async function installDependencies(repoRoot, pkgInfo, pmc) {
|
|
|
110
111
|
json.dependencies = (0, object_sort_1.sortObjectByKeys)(json.dependencies);
|
|
111
112
|
}
|
|
112
113
|
(0, fileutils_1.writeJsonFile)(`package.json`, json);
|
|
113
|
-
(0, child_process_1.execSync)(pmc.install, { stdio: [0, 1, 2], windowsHide:
|
|
114
|
+
(0, child_process_1.execSync)(pmc.install, { stdio: [0, 1, 2], windowsHide: false });
|
|
114
115
|
}
|
|
115
116
|
async function resolvePackageVersion(packageName, version) {
|
|
116
117
|
try {
|