@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
|
@@ -50,7 +50,7 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
|
|
|
50
50
|
].filter(Boolean)
|
|
51
51
|
: []),
|
|
52
52
|
...(eslintProjectConfigFile
|
|
53
|
-
? ['!{projectRoot}/.eslintrc.json', '!{projectRoot}/eslint.config.
|
|
53
|
+
? ['!{projectRoot}/.eslintrc.json', '!{projectRoot}/eslint.config.cjs']
|
|
54
54
|
: []),
|
|
55
55
|
].filter(Boolean),
|
|
56
56
|
};
|
|
@@ -83,8 +83,8 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
|
|
|
83
83
|
if ((0, fileutils_1.fileExists)((0, path_1.join)(repoRoot, '.eslintrc.json'))) {
|
|
84
84
|
inputs.push('{workspaceRoot}/.eslintrc.json');
|
|
85
85
|
}
|
|
86
|
-
if ((0, fileutils_1.fileExists)((0, path_1.join)(repoRoot, 'eslint.config.
|
|
87
|
-
inputs.push('{workspaceRoot}/eslint.config.
|
|
86
|
+
if ((0, fileutils_1.fileExists)((0, path_1.join)(repoRoot, 'eslint.config.cjs'))) {
|
|
87
|
+
inputs.push('{workspaceRoot}/eslint.config.cjs');
|
|
88
88
|
}
|
|
89
89
|
nxJson.targetDefaults.lint = {
|
|
90
90
|
...nxJson.targetDefaults.lint,
|
|
@@ -114,7 +114,8 @@ function updateProjectOutputs(repoRoot, project) {
|
|
|
114
114
|
else if (target.executor === '@angular-eslint/builder:lint') {
|
|
115
115
|
target.outputs = ['{options.outputFile}'];
|
|
116
116
|
}
|
|
117
|
-
else if (target.executor === '@angular-devkit/build-angular:ng-packagr'
|
|
117
|
+
else if (target.executor === '@angular-devkit/build-angular:ng-packagr' ||
|
|
118
|
+
target.executor === '@angular/build:ng-packagr') {
|
|
118
119
|
try {
|
|
119
120
|
const ngPackageJsonPath = (0, path_1.join)(repoRoot, target.options.project);
|
|
120
121
|
const ngPackageJson = (0, fileutils_1.readJsonFile)(ngPackageJsonPath);
|
|
@@ -159,7 +160,9 @@ function projectHasKarmaConfig(project) {
|
|
|
159
160
|
}
|
|
160
161
|
function projectHasEslintConfig(project) {
|
|
161
162
|
return ((0, fileutils_1.fileExists)((0, path_1.join)(project.root, '.eslintrc.json')) ||
|
|
162
|
-
(0, fileutils_1.fileExists)((0, path_1.join)(project.root, 'eslint.config.js'))
|
|
163
|
+
(0, fileutils_1.fileExists)((0, path_1.join)(project.root, 'eslint.config.js')) ||
|
|
164
|
+
(0, fileutils_1.fileExists)((0, path_1.join)(project.root, 'eslint.config.mjs')) ||
|
|
165
|
+
(0, fileutils_1.fileExists)((0, path_1.join)(project.root, 'eslint.config.cjs')));
|
|
163
166
|
}
|
|
164
167
|
function replaceNgWithNxInPackageJsonScripts(repoRoot) {
|
|
165
168
|
const packageJsonPath = (0, path_1.join)(repoRoot, 'package.json');
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface IncompatibleFiles {
|
|
2
|
+
[pluginIndex: number]: {
|
|
3
|
+
file: string;
|
|
4
|
+
error?: any;
|
|
5
|
+
}[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* This function checks if the imported project is compatible with the plugins.
|
|
9
|
+
* @returns a map of plugin names to files that are incompatible with the plugins
|
|
10
|
+
*/
|
|
11
|
+
export declare function checkCompatibleWithPlugins(): Promise<IncompatibleFiles>;
|
|
12
|
+
/**
|
|
13
|
+
* This function updates the plugins in the nx.json file with the given plugin names and files to exclude.
|
|
14
|
+
*/
|
|
15
|
+
export declare function updatePluginsInNxJson(root: string, pluginToExcludeFiles: IncompatibleFiles): void;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkCompatibleWithPlugins = checkCompatibleWithPlugins;
|
|
4
|
+
exports.updatePluginsInNxJson = updatePluginsInNxJson;
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const chalk_1 = require("chalk");
|
|
8
|
+
const error_types_1 = require("../../../project-graph/error-types");
|
|
9
|
+
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
10
|
+
const fileutils_1 = require("../../../utils/fileutils");
|
|
11
|
+
const output_1 = require("../../../utils/output");
|
|
12
|
+
const project_graph_1 = require("../../../project-graph/project-graph");
|
|
13
|
+
/**
|
|
14
|
+
* This function checks if the imported project is compatible with the plugins.
|
|
15
|
+
* @returns a map of plugin names to files that are incompatible with the plugins
|
|
16
|
+
*/
|
|
17
|
+
async function checkCompatibleWithPlugins() {
|
|
18
|
+
let pluginToExcludeFiles = {};
|
|
19
|
+
try {
|
|
20
|
+
await (0, project_graph_1.createProjectGraphAsync)();
|
|
21
|
+
}
|
|
22
|
+
catch (projectGraphError) {
|
|
23
|
+
if (projectGraphError instanceof error_types_1.ProjectGraphError) {
|
|
24
|
+
projectGraphError.getErrors()?.forEach((error) => {
|
|
25
|
+
const { pluginIndex, excludeFiles } = findPluginAndFilesWithError(error) ?? {};
|
|
26
|
+
if (pluginIndex !== undefined && excludeFiles?.length) {
|
|
27
|
+
pluginToExcludeFiles[pluginIndex] ??= [];
|
|
28
|
+
pluginToExcludeFiles[pluginIndex].push(...excludeFiles);
|
|
29
|
+
}
|
|
30
|
+
else if (!(0, error_types_1.isProjectsWithNoNameError)(error)) {
|
|
31
|
+
// print error if it is not ProjectsWithNoNameError and unable to exclude files
|
|
32
|
+
output_1.output.error({
|
|
33
|
+
title: error.message,
|
|
34
|
+
bodyLines: error.stack?.split('\n'),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
output_1.output.error({
|
|
41
|
+
title: 'Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.',
|
|
42
|
+
bodyLines: projectGraphError.stack?.split('\n'),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return pluginToExcludeFiles;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* This function finds the plugin name and files that caused the error.
|
|
50
|
+
* @param error the error to find the plugin name and files for
|
|
51
|
+
* @returns pluginName and excludeFiles if found, otherwise undefined
|
|
52
|
+
*/
|
|
53
|
+
function findPluginAndFilesWithError(error) {
|
|
54
|
+
let pluginIndex;
|
|
55
|
+
let excludeFiles = [];
|
|
56
|
+
if ((0, error_types_1.isAggregateCreateNodesError)(error)) {
|
|
57
|
+
pluginIndex = error.pluginIndex;
|
|
58
|
+
excludeFiles =
|
|
59
|
+
error.errors?.map((error) => {
|
|
60
|
+
return {
|
|
61
|
+
file: error?.[0],
|
|
62
|
+
error: error?.[1],
|
|
63
|
+
};
|
|
64
|
+
}) ?? [];
|
|
65
|
+
}
|
|
66
|
+
else if ((0, error_types_1.isMergeNodesError)(error)) {
|
|
67
|
+
pluginIndex = error.pluginIndex;
|
|
68
|
+
excludeFiles = [
|
|
69
|
+
{
|
|
70
|
+
file: error.file,
|
|
71
|
+
error: error,
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
excludeFiles = excludeFiles.filter(Boolean).map((excludeFile) => {
|
|
76
|
+
const file = excludeFile.file;
|
|
77
|
+
excludeFile.file = file.startsWith(workspace_root_1.workspaceRoot)
|
|
78
|
+
? (0, node_path_1.relative)(workspace_root_1.workspaceRoot, file)
|
|
79
|
+
: file;
|
|
80
|
+
return excludeFile;
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
pluginIndex,
|
|
84
|
+
excludeFiles,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* This function updates the plugins in the nx.json file with the given plugin names and files to exclude.
|
|
89
|
+
*/
|
|
90
|
+
function updatePluginsInNxJson(root = workspace_root_1.workspaceRoot, pluginToExcludeFiles) {
|
|
91
|
+
const nxJsonPath = (0, node_path_1.join)(root, 'nx.json');
|
|
92
|
+
if (!(0, node_fs_1.existsSync)(nxJsonPath)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
let nxJson;
|
|
96
|
+
try {
|
|
97
|
+
nxJson = (0, fileutils_1.readJsonFile)(nxJsonPath);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
// If there is an error reading the nx.json file, no need to update it
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (!Object.keys(pluginToExcludeFiles)?.length || !nxJson?.plugins?.length) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
Object.entries(pluginToExcludeFiles).forEach(([pluginIndex, excludeFiles]) => {
|
|
107
|
+
let plugin = nxJson.plugins[pluginIndex];
|
|
108
|
+
if (!plugin || excludeFiles.length === 0) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (typeof plugin === 'string') {
|
|
112
|
+
plugin = { plugin };
|
|
113
|
+
}
|
|
114
|
+
output_1.output.warn({
|
|
115
|
+
title: `The following files were incompatible with ${plugin.plugin} and has been excluded for now:`,
|
|
116
|
+
bodyLines: excludeFiles
|
|
117
|
+
.map((file) => {
|
|
118
|
+
const output = [` - ${(0, chalk_1.bold)(file.file)}`];
|
|
119
|
+
if (file.error?.message) {
|
|
120
|
+
output.push(` ${file.error.message}`);
|
|
121
|
+
}
|
|
122
|
+
return output;
|
|
123
|
+
})
|
|
124
|
+
.flat(),
|
|
125
|
+
});
|
|
126
|
+
const excludes = new Set(plugin.exclude ?? []);
|
|
127
|
+
excludeFiles.forEach((file) => {
|
|
128
|
+
excludes.add(file.file);
|
|
129
|
+
});
|
|
130
|
+
plugin.exclude = Array.from(excludes);
|
|
131
|
+
nxJson.plugins[pluginIndex] = plugin;
|
|
132
|
+
});
|
|
133
|
+
(0, fileutils_1.writeJsonFile)(nxJsonPath, nxJson);
|
|
134
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deduceDefaultBase(): string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deduceDefaultBase = deduceDefaultBase;
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
const default_base_1 = require("../../../utils/default-base");
|
|
6
|
+
function deduceDefaultBase() {
|
|
7
|
+
try {
|
|
8
|
+
(0, node_child_process_1.execSync)(`git rev-parse --verify main`, {
|
|
9
|
+
stdio: ['ignore', 'ignore', 'ignore'],
|
|
10
|
+
windowsHide: false,
|
|
11
|
+
});
|
|
12
|
+
return 'main';
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
try {
|
|
16
|
+
(0, node_child_process_1.execSync)(`git rev-parse --verify dev`, {
|
|
17
|
+
stdio: ['ignore', 'ignore', 'ignore'],
|
|
18
|
+
windowsHide: false,
|
|
19
|
+
});
|
|
20
|
+
return 'dev';
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
try {
|
|
24
|
+
(0, node_child_process_1.execSync)(`git rev-parse --verify develop`, {
|
|
25
|
+
stdio: ['ignore', 'ignore', 'ignore'],
|
|
26
|
+
windowsHide: false,
|
|
27
|
+
});
|
|
28
|
+
return 'develop';
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
try {
|
|
32
|
+
(0, node_child_process_1.execSync)(`git rev-parse --verify next`, {
|
|
33
|
+
stdio: ['ignore', 'ignore', 'ignore'],
|
|
34
|
+
windowsHide: false,
|
|
35
|
+
});
|
|
36
|
+
return 'next';
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
try {
|
|
40
|
+
(0, node_child_process_1.execSync)(`git rev-parse --verify master`, {
|
|
41
|
+
stdio: ['ignore', 'ignore', 'ignore'],
|
|
42
|
+
windowsHide: false,
|
|
43
|
+
});
|
|
44
|
+
return 'master';
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return (0, default_base_1.deduceDefaultBase)();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -63,7 +63,7 @@ function generateDotNxSetup(version) {
|
|
|
63
63
|
function normalizeVersionForNxJson(pkg, version) {
|
|
64
64
|
if (!(0, semver_1.valid)(version)) {
|
|
65
65
|
version = (0, child_process_1.execSync)(`npm view ${pkg}@${version} version`, {
|
|
66
|
-
windowsHide:
|
|
66
|
+
windowsHide: false,
|
|
67
67
|
}).toString();
|
|
68
68
|
}
|
|
69
69
|
return version.trimEnd();
|
|
@@ -9,10 +9,12 @@ function addViteCommandsToPackageScripts(appName, isStandalone) {
|
|
|
9
9
|
const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
|
|
10
10
|
packageJson.scripts = {
|
|
11
11
|
...packageJson.scripts,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
// These should be replaced by the vite init generator later.
|
|
13
|
+
start: 'vite',
|
|
14
|
+
test: 'vitest',
|
|
15
|
+
dev: 'vite',
|
|
16
|
+
build: 'vite build',
|
|
17
|
+
eject: undefined,
|
|
16
18
|
};
|
|
17
19
|
(0, fileutils_1.writeJsonFile)(packageJsonPath, packageJson, { spaces: 2 });
|
|
18
20
|
}
|
|
@@ -4,7 +4,7 @@ exports.checkForUncommittedChanges = checkForUncommittedChanges;
|
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
function checkForUncommittedChanges() {
|
|
6
6
|
const gitResult = (0, child_process_1.execSync)('git status --porcelain', {
|
|
7
|
-
windowsHide:
|
|
7
|
+
windowsHide: false,
|
|
8
8
|
}).toString();
|
|
9
9
|
const filteredResults = gitResult
|
|
10
10
|
.split('\n')
|
|
@@ -2,46 +2,55 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addNxToCraRepo = addNxToCraRepo;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
|
-
const node_fs_1 = require("node:fs");
|
|
6
5
|
const path_1 = require("path");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
7
|
const fileutils_1 = require("../../../../utils/fileutils");
|
|
8
8
|
const output_1 = require("../../../../utils/output");
|
|
9
9
|
const package_manager_1 = require("../../../../utils/package-manager");
|
|
10
10
|
const check_for_custom_webpack_setup_1 = require("./check-for-custom-webpack-setup");
|
|
11
|
-
const check_for_uncommitted_changes_1 = require("./check-for-uncommitted-changes");
|
|
12
|
-
const clean_up_files_1 = require("./clean-up-files");
|
|
13
11
|
const read_name_from_package_json_1 = require("./read-name-from-package-json");
|
|
14
12
|
const rename_js_to_jsx_1 = require("./rename-js-to-jsx");
|
|
15
|
-
const tsconfig_setup_1 = require("./tsconfig-setup");
|
|
16
|
-
const write_craco_config_1 = require("./write-craco-config");
|
|
17
13
|
const write_vite_config_1 = require("./write-vite-config");
|
|
18
14
|
const write_vite_index_html_1 = require("./write-vite-index-html");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!options.force) {
|
|
22
|
-
(0, check_for_uncommitted_changes_1.checkForUncommittedChanges)();
|
|
15
|
+
async function addNxToCraRepo(_options) {
|
|
16
|
+
if (!_options.force) {
|
|
23
17
|
(0, check_for_custom_webpack_setup_1.checkForCustomWebpackSetup)();
|
|
24
18
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
const options = await normalizeOptions(_options);
|
|
20
|
+
await addBundler(options);
|
|
21
|
+
(0, fs_1.appendFileSync)(`.gitignore`, '\nnode_modules');
|
|
22
|
+
(0, fs_1.appendFileSync)(`.gitignore`, '\ndist');
|
|
23
|
+
installDependencies(options);
|
|
24
|
+
// Vite expects index.html to be in the root as the main entry point.
|
|
25
|
+
const indexPath = options.isStandalone
|
|
26
|
+
? 'index.html'
|
|
27
|
+
: (0, path_1.join)('apps', options.reactAppName, 'index.html');
|
|
28
|
+
const oldIndexPath = options.isStandalone
|
|
29
|
+
? (0, path_1.join)('public', 'index.html')
|
|
30
|
+
: (0, path_1.join)('apps', options.reactAppName, 'public', 'index.html');
|
|
31
|
+
output_1.output.note({
|
|
32
|
+
title: `A new ${indexPath} has been created. Compare it to the previous ${oldIndexPath} file and make any changes needed, then delete the previous file.`,
|
|
33
|
+
});
|
|
34
|
+
if (_options.force) {
|
|
35
|
+
output_1.output.note({
|
|
36
|
+
title: `Using --force converts projects with custom Webpack setup. You will need to manually update your vite.config.js file to match the plugins used in your old Webpack configuration.`,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
28
39
|
}
|
|
29
40
|
function installDependencies(options) {
|
|
30
41
|
const dependencies = [
|
|
42
|
+
'@rollup/plugin-replace',
|
|
31
43
|
'@testing-library/jest-dom',
|
|
44
|
+
'@vitejs/plugin-react',
|
|
32
45
|
'eslint-config-react-app',
|
|
33
46
|
'web-vitals',
|
|
34
47
|
'jest-watch-typeahead',
|
|
48
|
+
'vite',
|
|
49
|
+
'vitest',
|
|
35
50
|
];
|
|
36
|
-
if (options.isVite) {
|
|
37
|
-
dependencies.push('vite', 'vitest', '@vitejs/plugin-react');
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
dependencies.push('@craco/craco', 'cross-env', 'react-scripts', 'tsconfig-paths-webpack-plugin');
|
|
41
|
-
}
|
|
42
51
|
(0, child_process_1.execSync)(`${options.pmc.addDev} ${dependencies.join(' ')}`, {
|
|
43
52
|
stdio: [0, 1, 2],
|
|
44
|
-
windowsHide:
|
|
53
|
+
windowsHide: false,
|
|
45
54
|
});
|
|
46
55
|
}
|
|
47
56
|
async function normalizeOptions(options) {
|
|
@@ -49,182 +58,20 @@ async function normalizeOptions(options) {
|
|
|
49
58
|
const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
|
50
59
|
const appIsJs = !(0, fileutils_1.fileExists)(`tsconfig.json`);
|
|
51
60
|
const reactAppName = (0, read_name_from_package_json_1.readNameFromPackageJson)();
|
|
52
|
-
const packageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(process.cwd(), 'package.json'));
|
|
53
|
-
const deps = {
|
|
54
|
-
...packageJson.dependencies,
|
|
55
|
-
...packageJson.devDependencies,
|
|
56
|
-
};
|
|
57
|
-
const isCRA5 = /^[^~]?5/.test(deps['react-scripts']);
|
|
58
|
-
const npmVersion = (0, child_process_1.execSync)('npm -v', {
|
|
59
|
-
windowsHide: true,
|
|
60
|
-
}).toString();
|
|
61
|
-
// Should remove this check 04/2023 once Node 14 & npm 6 reach EOL
|
|
62
|
-
const npxYesFlagNeeded = !npmVersion.startsWith('6'); // npm 7 added -y flag to npx
|
|
63
|
-
const isVite = options.vite;
|
|
64
61
|
const isStandalone = !options.integrated;
|
|
65
|
-
const nxCloud = options.nxCloud ??
|
|
66
|
-
(options.interactive ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)() : false);
|
|
67
62
|
return {
|
|
68
63
|
...options,
|
|
69
|
-
nxCloud,
|
|
70
64
|
packageManager,
|
|
71
65
|
pmc,
|
|
72
66
|
appIsJs,
|
|
73
67
|
reactAppName,
|
|
74
|
-
isCRA5,
|
|
75
|
-
npxYesFlagNeeded,
|
|
76
|
-
isVite,
|
|
77
68
|
isStandalone,
|
|
78
69
|
};
|
|
79
70
|
}
|
|
80
|
-
/**
|
|
81
|
-
* - Create a temp workspace
|
|
82
|
-
* - Move all files to temp workspace
|
|
83
|
-
* - Add bundler to temp workspace
|
|
84
|
-
* - Move files back to root
|
|
85
|
-
* - Clean up unused files
|
|
86
|
-
*/
|
|
87
|
-
async function reorgnizeWorkspaceStructure(options) {
|
|
88
|
-
createTempWorkspace(options);
|
|
89
|
-
moveFilesToTempWorkspace(options);
|
|
90
|
-
await addBundler(options);
|
|
91
|
-
output_1.output.log({ title: '๐งถ Updating .gitignore file' });
|
|
92
|
-
(0, child_process_1.execSync)(`echo "node_modules" >> .gitignore`, {
|
|
93
|
-
stdio: [0, 1, 2],
|
|
94
|
-
windowsHide: true,
|
|
95
|
-
});
|
|
96
|
-
(0, child_process_1.execSync)(`echo "dist" >> .gitignore`, {
|
|
97
|
-
stdio: [0, 1, 2],
|
|
98
|
-
windowsHide: true,
|
|
99
|
-
});
|
|
100
|
-
process.chdir('..');
|
|
101
|
-
copyFromTempWorkspaceToRoot();
|
|
102
|
-
cleanUpUnusedFilesAndAddConfigFiles(options);
|
|
103
|
-
output_1.output.log({ title: '๐ Please be patient, one final step remaining!' });
|
|
104
|
-
output_1.output.log({ title: '๐ฆ Installing dependencies' });
|
|
105
|
-
installDependencies(options);
|
|
106
|
-
if (options.isVite) {
|
|
107
|
-
const indexPath = options.isStandalone
|
|
108
|
-
? 'index.html'
|
|
109
|
-
: (0, path_1.join)('apps', options.reactAppName, 'index.html');
|
|
110
|
-
const oldIndexPath = options.isStandalone
|
|
111
|
-
? (0, path_1.join)('public', 'index.html')
|
|
112
|
-
: (0, path_1.join)('apps', options.reactAppName, 'public', 'index.html');
|
|
113
|
-
output_1.output.note({
|
|
114
|
-
title: `A new ${indexPath} has been created. Compare it to the previous ${oldIndexPath} file and make any changes needed, then delete the previous file.`,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function createTempWorkspace(options) {
|
|
119
|
-
(0, node_fs_1.rmSync)('temp-workspace', { recursive: true, force: true });
|
|
120
|
-
(0, child_process_1.execSync)(`npx ${options.npxYesFlagNeeded ? '-y' : ''} create-nx-workspace@latest temp-workspace --appName=${options.reactAppName} --preset=react-monorepo --style=css --bundler=${options.isVite ? 'vite' : 'webpack'} --packageManager=${options.packageManager} ${options.nxCloud ? '--nxCloud=yes' : '--nxCloud=skip'} ${options.addE2e ? '--e2eTestRunner=playwright' : '--e2eTestRunner=none'}`, { stdio: [0, 1, 2], windowsHide: true });
|
|
121
|
-
output_1.output.log({ title: '๐ Welcome to Nx!' });
|
|
122
|
-
output_1.output.log({ title: '๐งน Clearing unused files' });
|
|
123
|
-
(0, node_fs_1.cpSync)((0, path_1.join)('temp-workspace', 'apps', options.reactAppName, 'project.json'), 'project.json', { recursive: true });
|
|
124
|
-
(0, node_fs_1.rmSync)((0, path_1.join)('temp-workspace', 'apps', options.reactAppName), {
|
|
125
|
-
recursive: true,
|
|
126
|
-
force: true,
|
|
127
|
-
});
|
|
128
|
-
(0, node_fs_1.rmSync)('node_modules', { recursive: true, force: true });
|
|
129
|
-
}
|
|
130
|
-
function copyPackageJsonDepsFromTempWorkspace() {
|
|
131
|
-
const repoRoot = process.cwd();
|
|
132
|
-
let rootPackageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(repoRoot, 'package.json'));
|
|
133
|
-
const tempWorkspacePackageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(repoRoot, 'temp-workspace', 'package.json'));
|
|
134
|
-
rootPackageJson = overridePackageDeps('dependencies', rootPackageJson, tempWorkspacePackageJson);
|
|
135
|
-
rootPackageJson = overridePackageDeps('devDependencies', rootPackageJson, tempWorkspacePackageJson);
|
|
136
|
-
rootPackageJson.scripts = {}; // remove existing scripts
|
|
137
|
-
(0, fileutils_1.writeJsonFile)((0, path_1.join)(repoRoot, 'package.json'), rootPackageJson);
|
|
138
|
-
(0, fileutils_1.writeJsonFile)((0, path_1.join)(repoRoot, 'temp-workspace', 'package.json'), rootPackageJson);
|
|
139
|
-
}
|
|
140
|
-
function overridePackageDeps(depConfigName, base, override) {
|
|
141
|
-
if (!base[depConfigName]) {
|
|
142
|
-
base[depConfigName] = override[depConfigName];
|
|
143
|
-
return base;
|
|
144
|
-
}
|
|
145
|
-
const deps = override[depConfigName];
|
|
146
|
-
Object.keys(deps).forEach((dep) => {
|
|
147
|
-
if (base.dependencies?.[dep]) {
|
|
148
|
-
delete base.dependencies[dep];
|
|
149
|
-
}
|
|
150
|
-
if (base.devDependencies?.[dep]) {
|
|
151
|
-
delete base.devDependencies[dep];
|
|
152
|
-
}
|
|
153
|
-
base[depConfigName][dep] = deps[dep];
|
|
154
|
-
});
|
|
155
|
-
return base;
|
|
156
|
-
}
|
|
157
|
-
function moveSync(src, dest) {
|
|
158
|
-
const destParentDir = (0, path_1.dirname)(dest);
|
|
159
|
-
(0, node_fs_1.mkdirSync)(destParentDir, { recursive: true });
|
|
160
|
-
(0, node_fs_1.rmSync)(dest, { recursive: true, force: true });
|
|
161
|
-
return (0, node_fs_1.renameSync)(src, dest);
|
|
162
|
-
}
|
|
163
|
-
function moveFilesToTempWorkspace(options) {
|
|
164
|
-
output_1.output.log({ title: '๐ Moving your React app in your new Nx workspace' });
|
|
165
|
-
copyPackageJsonDepsFromTempWorkspace();
|
|
166
|
-
const requiredCraFiles = [
|
|
167
|
-
'project.json',
|
|
168
|
-
'package.json',
|
|
169
|
-
'src',
|
|
170
|
-
'public',
|
|
171
|
-
options.appIsJs ? null : 'tsconfig.json',
|
|
172
|
-
options.packageManager === 'yarn' ? 'yarn.lock' : null,
|
|
173
|
-
options.packageManager === 'pnpm' ? 'pnpm-lock.yaml' : null,
|
|
174
|
-
options.packageManager === 'npm' ? 'package-lock.json' : null,
|
|
175
|
-
options.packageManager === 'bun' ? 'bun.lockb' : null,
|
|
176
|
-
];
|
|
177
|
-
const optionalCraFiles = ['README.md'];
|
|
178
|
-
const filesToMove = [...requiredCraFiles, ...optionalCraFiles].filter(Boolean);
|
|
179
|
-
filesToMove.forEach((f) => {
|
|
180
|
-
try {
|
|
181
|
-
moveSync(f, options.isStandalone
|
|
182
|
-
? (0, path_1.join)('temp-workspace', f)
|
|
183
|
-
: (0, path_1.join)('temp-workspace', 'apps', options.reactAppName, f));
|
|
184
|
-
}
|
|
185
|
-
catch (error) {
|
|
186
|
-
if (requiredCraFiles.includes(f)) {
|
|
187
|
-
throw error;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
process.chdir('temp-workspace');
|
|
192
|
-
}
|
|
193
71
|
async function addBundler(options) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
(0, write_vite_index_html_1.writeViteIndexHtml)(options.reactAppName, options.isStandalone, options.appIsJs);
|
|
200
|
-
await (0, rename_js_to_jsx_1.renameJsToJsx)(options.reactAppName, options.isStandalone);
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
output_1.output.log({ title: '๐งโ๐ง Setting up craco + Webpack' });
|
|
204
|
-
const { addCracoCommandsToPackageScripts } = await Promise.resolve().then(() => require('./add-craco-commands-to-package-scripts'));
|
|
205
|
-
addCracoCommandsToPackageScripts(options.reactAppName, options.isStandalone);
|
|
206
|
-
(0, write_craco_config_1.writeCracoConfig)(options.reactAppName, options.isCRA5, options.isStandalone);
|
|
207
|
-
output_1.output.log({
|
|
208
|
-
title: '๐ฌ Skip CRA preflight check since Nx manages the monorepo',
|
|
209
|
-
});
|
|
210
|
-
(0, child_process_1.execSync)(`echo "SKIP_PREFLIGHT_CHECK=true" > .env`, {
|
|
211
|
-
stdio: [0, 1, 2],
|
|
212
|
-
windowsHide: true,
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
function copyFromTempWorkspaceToRoot() {
|
|
217
|
-
output_1.output.log({ title: '๐ Folder restructuring.' });
|
|
218
|
-
(0, node_fs_1.readdirSync)('temp-workspace').forEach((f) => {
|
|
219
|
-
moveSync((0, path_1.join)('temp-workspace', f), f);
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
function cleanUpUnusedFilesAndAddConfigFiles(options) {
|
|
223
|
-
output_1.output.log({ title: '๐งน Cleaning up.' });
|
|
224
|
-
(0, clean_up_files_1.cleanUpFiles)(options.reactAppName, options.isStandalone);
|
|
225
|
-
output_1.output.log({ title: "๐ Extend the app's tsconfig.json from the base" });
|
|
226
|
-
(0, tsconfig_setup_1.setupTsConfig)(options.reactAppName, options.isStandalone);
|
|
227
|
-
if (options.isStandalone) {
|
|
228
|
-
(0, node_fs_1.rmSync)('apps', { recursive: true, force: true });
|
|
229
|
-
}
|
|
72
|
+
const { addViteCommandsToPackageScripts } = await Promise.resolve().then(() => require('./add-vite-commands-to-package-scripts'));
|
|
73
|
+
addViteCommandsToPackageScripts(options.reactAppName, options.isStandalone);
|
|
74
|
+
(0, write_vite_config_1.writeViteConfig)(options.reactAppName, options.isStandalone, options.appIsJs);
|
|
75
|
+
(0, write_vite_index_html_1.writeViteIndexHtml)(options.reactAppName, options.isStandalone, options.appIsJs);
|
|
76
|
+
await (0, rename_js_to_jsx_1.renameJsToJsx)(options.reactAppName, options.isStandalone);
|
|
230
77
|
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.writeViteConfig = writeViteConfig;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
function writeViteConfig(appName, isStandalone, isJs) {
|
|
6
|
-
let port =
|
|
6
|
+
let port = 3000;
|
|
7
7
|
// Use PORT from .env file if it exists in project.
|
|
8
8
|
if ((0, fs_1.existsSync)(`../.env`)) {
|
|
9
9
|
const envFile = (0, fs_1.readFileSync)(`../.env`).toString();
|
|
@@ -13,8 +13,20 @@ function writeViteConfig(appName, isStandalone, isJs) {
|
|
|
13
13
|
port = portCandidate;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
(0, fs_1.writeFileSync)(isStandalone ? 'vite.config.
|
|
16
|
+
(0, fs_1.writeFileSync)(isStandalone ? 'vite.config.mjs' : `apps/${appName}/vite.config.mjs`, `import { defineConfig } from 'vite'
|
|
17
17
|
import react from '@vitejs/plugin-react'
|
|
18
|
+
import replace from '@rollup/plugin-replace';
|
|
19
|
+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
20
|
+
|
|
21
|
+
// Match CRA's environment variables.
|
|
22
|
+
// TODO: Replace these with VITE_ prefixed environment variables, and using import.meta.env.VITE_* instead of process.env.REACT_APP_*.
|
|
23
|
+
const craEnvVarRegex = /^REACT_APP/i;
|
|
24
|
+
const craEnvVars = Object.keys(process.env)
|
|
25
|
+
.filter((key) => craEnvVarRegex.test(key))
|
|
26
|
+
.reduce((env, key) => {
|
|
27
|
+
env[\`process.env.\${key}\`] = JSON.stringify(process.env[key]);
|
|
28
|
+
return env;
|
|
29
|
+
}, {});
|
|
18
30
|
|
|
19
31
|
// https://vitejs.dev/config/
|
|
20
32
|
export default defineConfig({
|
|
@@ -31,7 +43,11 @@ export default defineConfig({
|
|
|
31
43
|
setupFiles: 'src/setupTests.${isJs ? 'js' : 'ts'}',
|
|
32
44
|
css: true,
|
|
33
45
|
},
|
|
34
|
-
plugins: [
|
|
46
|
+
plugins: [
|
|
47
|
+
react(),
|
|
48
|
+
replace({ values: craEnvVars, preventAssignment: true }),
|
|
49
|
+
nxViteTsPaths(),
|
|
50
|
+
],
|
|
35
51
|
});
|
|
36
52
|
`);
|
|
37
53
|
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
+
import { NxJsonConfiguration } from '../../../config/nx-json';
|
|
1
2
|
import { PackageJson } from '../../../utils/package-json';
|
|
2
3
|
import { PackageManagerCommands } from '../../../utils/package-manager';
|
|
3
4
|
export declare function createNxJsonFile(repoRoot: string, topologicalTargets: string[], cacheableOperations: string[], scriptOutputs: {
|
|
4
5
|
[name: string]: string;
|
|
5
6
|
}): void;
|
|
7
|
+
export declare function createNxJsonFromTurboJson(turboJson: Record<string, any>): NxJsonConfiguration;
|
|
6
8
|
export declare function addDepsToPackageJson(repoRoot: string, additionalPackages?: string[]): void;
|
|
7
9
|
export declare function updateGitIgnore(root: string): void;
|
|
8
10
|
export declare function runInstall(repoRoot: string, pmc?: PackageManagerCommands): void;
|
|
9
|
-
export declare function initCloud(installationSource: 'nx-init' | 'nx-init-angular' | 'nx-init-cra' | 'nx-init-monorepo' | 'nx-init-nest' | 'nx-init-npm-repo'): Promise<void>;
|
|
11
|
+
export declare function initCloud(installationSource: 'nx-init' | 'nx-init-angular' | 'nx-init-cra' | 'nx-init-monorepo' | 'nx-init-nest' | 'nx-init-npm-repo' | 'nx-init-turborepo'): Promise<void>;
|
|
10
12
|
export declare function addVsCodeRecommendedExtensions(repoRoot: string, extensions: string[]): void;
|
|
11
13
|
export declare function markRootPackageJsonAsNxProjectLegacy(repoRoot: string, cacheableScripts: string[], pmc: PackageManagerCommands): void;
|
|
12
14
|
export declare function markPackageJsonAsNxProject(packageJsonPath: string): void;
|
|
13
|
-
export declare function printFinalMessage({ learnMoreLink, }: {
|
|
15
|
+
export declare function printFinalMessage({ learnMoreLink, appendLines, }: {
|
|
14
16
|
learnMoreLink?: string;
|
|
17
|
+
appendLines?: string[];
|
|
15
18
|
}): void;
|
|
16
19
|
export declare function isMonorepo(packageJson: PackageJson): boolean;
|
|
20
|
+
export declare function isCRA(packageJson: PackageJson): boolean;
|