@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
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadResolvedNxPluginAsync = loadResolvedNxPluginAsync;
|
|
4
|
+
const loaded_nx_plugin_1 = require("./loaded-nx-plugin");
|
|
5
|
+
async function loadResolvedNxPluginAsync(pluginConfiguration, pluginPath, name) {
|
|
6
|
+
const plugin = await importPluginModule(pluginPath);
|
|
7
|
+
plugin.name ??= name;
|
|
8
|
+
return new loaded_nx_plugin_1.LoadedNxPlugin(plugin, pluginConfiguration);
|
|
9
|
+
}
|
|
10
|
+
async function importPluginModule(pluginPath) {
|
|
11
|
+
const m = await Promise.resolve(`${pluginPath}`).then(s => require(s));
|
|
12
|
+
if (m.default &&
|
|
13
|
+
('createNodes' in m.default ||
|
|
14
|
+
'createNodesV2' in m.default ||
|
|
15
|
+
'createDependencies' in m.default ||
|
|
16
|
+
'createMetadata' in m.default ||
|
|
17
|
+
'preTasksExecution' in m.default ||
|
|
18
|
+
'postTasksExecution' in m.default)) {
|
|
19
|
+
return m.default;
|
|
20
|
+
}
|
|
21
|
+
return m;
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ProjectGraph } from '../../config/project-graph';
|
|
2
|
+
import { type PluginConfiguration } from '../../config/nx-json';
|
|
3
|
+
import type { RawProjectGraphDependency } from '../project-graph-builder';
|
|
4
|
+
import type { CreateDependenciesContext, CreateMetadataContext, CreateNodesContextV2, CreateNodesResult, NxPluginV2, PostTasksExecutionContext, PreTasksExecutionContext, ProjectsMetadata } from './public-api';
|
|
5
|
+
export declare class LoadedNxPlugin {
|
|
6
|
+
index?: number;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly createNodes?: [
|
|
9
|
+
filePattern: string,
|
|
10
|
+
fn: (matchedFiles: string[], context: CreateNodesContextV2) => Promise<Array<readonly [plugin: string, file: string, result: CreateNodesResult]>>
|
|
11
|
+
];
|
|
12
|
+
readonly createDependencies?: (context: CreateDependenciesContext) => Promise<RawProjectGraphDependency[]>;
|
|
13
|
+
readonly createMetadata?: (graph: ProjectGraph, context: CreateMetadataContext) => Promise<ProjectsMetadata>;
|
|
14
|
+
readonly preTasksExecution?: (context: PreTasksExecutionContext) => Promise<NodeJS.ProcessEnv>;
|
|
15
|
+
readonly postTasksExecution?: (context: PostTasksExecutionContext) => Promise<void>;
|
|
16
|
+
readonly options?: unknown;
|
|
17
|
+
readonly include?: string[];
|
|
18
|
+
readonly exclude?: string[];
|
|
19
|
+
constructor(plugin: NxPluginV2, pluginDefinition: PluginConfiguration);
|
|
20
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoadedNxPlugin = void 0;
|
|
4
|
+
const error_types_1 = require("../error-types");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
const enabled_1 = require("./isolation/enabled");
|
|
7
|
+
const client_1 = require("../../daemon/client/client");
|
|
8
|
+
class LoadedNxPlugin {
|
|
9
|
+
constructor(plugin, pluginDefinition) {
|
|
10
|
+
this.name = plugin.name;
|
|
11
|
+
if (typeof pluginDefinition !== 'string') {
|
|
12
|
+
this.options = pluginDefinition.options;
|
|
13
|
+
this.include = pluginDefinition.include;
|
|
14
|
+
this.exclude = pluginDefinition.exclude;
|
|
15
|
+
}
|
|
16
|
+
if (plugin.createNodes && !plugin.createNodesV2) {
|
|
17
|
+
this.createNodes = [
|
|
18
|
+
plugin.createNodes[0],
|
|
19
|
+
(configFiles, context) => (0, utils_1.createNodesFromFiles)(plugin.createNodes[1], configFiles, this.options, context).then((results) => results.map((r) => [this.name, r[0], r[1]])),
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
if (plugin.createNodesV2) {
|
|
23
|
+
this.createNodes = [
|
|
24
|
+
plugin.createNodesV2[0],
|
|
25
|
+
async (configFiles, context) => {
|
|
26
|
+
const result = await plugin.createNodesV2[1](configFiles, this.options, context);
|
|
27
|
+
return result.map((r) => [this.name, r[0], r[1]]);
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
if (this.createNodes) {
|
|
32
|
+
const inner = this.createNodes[1];
|
|
33
|
+
this.createNodes[1] = async (...args) => {
|
|
34
|
+
performance.mark(`${plugin.name}:createNodes - start`);
|
|
35
|
+
try {
|
|
36
|
+
return await inner(...args);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
if ((0, error_types_1.isAggregateCreateNodesError)(e)) {
|
|
40
|
+
throw e;
|
|
41
|
+
}
|
|
42
|
+
// The underlying plugin errored out. We can't know any partial results.
|
|
43
|
+
throw new error_types_1.AggregateCreateNodesError([[null, e]], []);
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
performance.mark(`${plugin.name}:createNodes - end`);
|
|
47
|
+
performance.measure(`${plugin.name}:createNodes`, `${plugin.name}:createNodes - start`, `${plugin.name}:createNodes - end`);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (plugin.createDependencies) {
|
|
52
|
+
this.createDependencies = async (context) => plugin.createDependencies(this.options, context);
|
|
53
|
+
}
|
|
54
|
+
if (plugin.createMetadata) {
|
|
55
|
+
this.createMetadata = async (graph, context) => plugin.createMetadata(graph, this.options, context);
|
|
56
|
+
}
|
|
57
|
+
if (plugin.preTasksExecution) {
|
|
58
|
+
this.preTasksExecution = async (context) => {
|
|
59
|
+
const updates = {};
|
|
60
|
+
let originalEnv = process.env;
|
|
61
|
+
if ((0, enabled_1.isIsolationEnabled)() || (0, client_1.isDaemonEnabled)()) {
|
|
62
|
+
process.env = new Proxy(originalEnv, {
|
|
63
|
+
set: (target, key, value) => {
|
|
64
|
+
target[key] = value;
|
|
65
|
+
updates[key] = value;
|
|
66
|
+
return true;
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
await plugin.preTasksExecution(this.options, context);
|
|
71
|
+
process.env = originalEnv;
|
|
72
|
+
return updates;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (plugin.postTasksExecution) {
|
|
76
|
+
this.postTasksExecution = async (context) => plugin.postTasksExecution(this.options, context);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.LoadedNxPlugin = LoadedNxPlugin;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import type { FileMap, ProjectGraph, ProjectGraphExternalNode } from '../../config/project-graph';
|
|
2
|
+
import type { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
|
3
|
+
import type { NxJsonConfiguration } from '../../config/nx-json';
|
|
4
|
+
import type { RawProjectGraphDependency } from '../project-graph-builder';
|
|
5
|
+
import type { TaskResults } from '../../tasks-runner/life-cycle';
|
|
6
6
|
/**
|
|
7
7
|
* Context for {@link CreateNodesFunction}
|
|
8
8
|
*/
|
|
@@ -38,12 +38,12 @@ export interface CreateNodesResult {
|
|
|
38
38
|
* A pair of file patterns and {@link CreateNodesFunction}
|
|
39
39
|
*
|
|
40
40
|
* Nx 19.2+: Both original `CreateNodes` and `CreateNodesV2` are supported. Nx will only invoke `CreateNodesV2` if it is present.
|
|
41
|
-
* Nx
|
|
41
|
+
* Nx 21.X : The `CreateNodesV2` will be the only supported API. This typing will still exist, but be identical to `CreateNodesV2`.
|
|
42
42
|
Nx **will not** invoke the original `plugin.createNodes` callback. This should give plugin authors a window to transition.
|
|
43
43
|
Plugin authors should update their plugin's `createNodes` function to align with `CreateNodesV2` / the updated `CreateNodes`.
|
|
44
44
|
The plugin should contain something like: `export createNodes = createNodesV2;` during this period. This will allow the plugin
|
|
45
45
|
to maintain compatibility with Nx 19.2 and up.
|
|
46
|
-
* Nx
|
|
46
|
+
* Nx 22.X : The `CreateNodesV2` typing will be removed, as it has replaced `CreateNodes`.
|
|
47
47
|
*
|
|
48
48
|
* @deprecated Use {@link CreateNodesV2} instead. CreateNodesV2 will replace this API. Read more about the transition above.
|
|
49
49
|
*/
|
|
@@ -53,7 +53,7 @@ export type CreateNodes<T = unknown> = readonly [
|
|
|
53
53
|
];
|
|
54
54
|
/**
|
|
55
55
|
* A pair of file patterns and {@link CreateNodesFunctionV2}
|
|
56
|
-
* In Nx
|
|
56
|
+
* In Nx 21 {@link CreateNodes} will be replaced with this type. In Nx 22, this type will be removed.
|
|
57
57
|
*/
|
|
58
58
|
export type CreateNodesV2<T = unknown> = readonly [
|
|
59
59
|
projectFilePattern: string,
|
|
@@ -97,7 +97,7 @@ export type CreateMetadataContext = {
|
|
|
97
97
|
export type ProjectsMetadata = Record<string, Pick<ProjectConfiguration, 'metadata'>>;
|
|
98
98
|
export type CreateMetadata<T = unknown> = (graph: ProjectGraph, options: T | undefined, context: CreateMetadataContext) => ProjectsMetadata | Promise<ProjectsMetadata>;
|
|
99
99
|
/**
|
|
100
|
-
* A plugin
|
|
100
|
+
* A plugin which enhances the behavior of Nx
|
|
101
101
|
*/
|
|
102
102
|
export type NxPluginV2<TOptions = unknown> = {
|
|
103
103
|
name: string;
|
|
@@ -105,14 +105,14 @@ export type NxPluginV2<TOptions = unknown> = {
|
|
|
105
105
|
* Provides a file pattern and function that retrieves configuration info from
|
|
106
106
|
* those files. e.g. { '**\/*.csproj': buildProjectsFromCsProjFile }
|
|
107
107
|
*
|
|
108
|
-
* @deprecated Use {@link createNodesV2} instead. In Nx
|
|
108
|
+
* @deprecated Use {@link createNodesV2} instead. In Nx 21 support for calling createNodes with a single file for the first argument will be removed.
|
|
109
109
|
*/
|
|
110
110
|
createNodes?: CreateNodes<TOptions>;
|
|
111
111
|
/**
|
|
112
112
|
* Provides a file pattern and function that retrieves configuration info from
|
|
113
113
|
* those files. e.g. { '**\/*.csproj': buildProjectsFromCsProjFiles }
|
|
114
114
|
*
|
|
115
|
-
* In Nx
|
|
115
|
+
* In Nx 21 {@link createNodes} will be replaced with this property. In Nx 22, this property will be removed.
|
|
116
116
|
*/
|
|
117
117
|
createNodesV2?: CreateNodesV2<TOptions>;
|
|
118
118
|
/**
|
|
@@ -123,8 +123,27 @@ export type NxPluginV2<TOptions = unknown> = {
|
|
|
123
123
|
* Provides a function to create metadata for the {@link ProjectGraph}
|
|
124
124
|
*/
|
|
125
125
|
createMetadata?: CreateMetadata<TOptions>;
|
|
126
|
+
/**
|
|
127
|
+
* Provides a function to run before the Nx runs tasks
|
|
128
|
+
*/
|
|
129
|
+
preTasksExecution?: PreTasksExecution<TOptions>;
|
|
130
|
+
/**
|
|
131
|
+
* Provides a function to run after the Nx runs tasks
|
|
132
|
+
*/
|
|
133
|
+
postTasksExecution?: PostTasksExecution<TOptions>;
|
|
134
|
+
};
|
|
135
|
+
export type PreTasksExecutionContext = {
|
|
136
|
+
readonly workspaceRoot: string;
|
|
137
|
+
readonly nxJsonConfiguration: NxJsonConfiguration;
|
|
138
|
+
};
|
|
139
|
+
export type PostTasksExecutionContext = {
|
|
140
|
+
readonly workspaceRoot: string;
|
|
141
|
+
readonly nxJsonConfiguration: NxJsonConfiguration;
|
|
142
|
+
readonly taskResults: TaskResults;
|
|
126
143
|
};
|
|
144
|
+
export type PreTasksExecution<TOptions = unknown> = (options: TOptions | undefined, context: PreTasksExecutionContext) => void | Promise<void>;
|
|
145
|
+
export type PostTasksExecution<TOptions = unknown> = (options: TOptions | undefined, context: PostTasksExecutionContext) => void | Promise<void>;
|
|
127
146
|
/**
|
|
128
|
-
* A plugin
|
|
147
|
+
* A plugin which enhances the behavior of Nx
|
|
129
148
|
*/
|
|
130
|
-
export type NxPlugin =
|
|
149
|
+
export type NxPlugin = NxPluginV2;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
|
2
|
+
export declare function resolveNxPlugin(moduleName: string, root: string, paths: string[]): Promise<{
|
|
3
|
+
pluginPath: string;
|
|
4
|
+
name: any;
|
|
5
|
+
shouldRegisterTSTranspiler: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function resolveLocalNxPlugin(importPath: string, projects: Record<string, ProjectConfiguration>, root?: string): {
|
|
8
|
+
path: string;
|
|
9
|
+
projectConfig: ProjectConfiguration;
|
|
10
|
+
} | null;
|
|
11
|
+
export declare function getPluginPathAndName(moduleName: string, paths: string[], projects: Record<string, ProjectConfiguration>, root: string): {
|
|
12
|
+
pluginPath: string;
|
|
13
|
+
name: any;
|
|
14
|
+
shouldRegisterTSTranspiler: boolean;
|
|
15
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveNxPlugin = resolveNxPlugin;
|
|
4
|
+
exports.resolveLocalNxPlugin = resolveLocalNxPlugin;
|
|
5
|
+
exports.getPluginPathAndName = getPluginPathAndName;
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const packages_1 = require("../../plugins/js/utils/packages");
|
|
9
|
+
const fileutils_1 = require("../../utils/fileutils");
|
|
10
|
+
const logger_1 = require("../../utils/logger");
|
|
11
|
+
const path_1 = require("../../utils/path");
|
|
12
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
|
13
|
+
const find_project_for_path_1 = require("../utils/find-project-for-path");
|
|
14
|
+
const retrieve_workspace_files_1 = require("../utils/retrieve-workspace-files");
|
|
15
|
+
let projectsWithoutInference;
|
|
16
|
+
async function resolveNxPlugin(moduleName, root, paths) {
|
|
17
|
+
try {
|
|
18
|
+
require.resolve(moduleName);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// If a plugin cannot be resolved, we will need projects to resolve it
|
|
22
|
+
projectsWithoutInference ??=
|
|
23
|
+
await (0, retrieve_workspace_files_1.retrieveProjectConfigurationsWithoutPluginInference)(root);
|
|
24
|
+
}
|
|
25
|
+
const { pluginPath, name, shouldRegisterTSTranspiler } = getPluginPathAndName(moduleName, paths, projectsWithoutInference, root);
|
|
26
|
+
return { pluginPath, name, shouldRegisterTSTranspiler };
|
|
27
|
+
}
|
|
28
|
+
function readPluginMainFromProjectConfiguration(plugin) {
|
|
29
|
+
const { main } = Object.values(plugin.targets).find((x) => [
|
|
30
|
+
'@nx/js:tsc',
|
|
31
|
+
'@nrwl/js:tsc',
|
|
32
|
+
'@nx/js:swc',
|
|
33
|
+
'@nrwl/js:swc',
|
|
34
|
+
'@nx/node:package',
|
|
35
|
+
'@nrwl/node:package',
|
|
36
|
+
].includes(x.executor))?.options ||
|
|
37
|
+
plugin.targets?.build?.options ||
|
|
38
|
+
{};
|
|
39
|
+
return main;
|
|
40
|
+
}
|
|
41
|
+
function resolveLocalNxPlugin(importPath, projects, root = workspace_root_1.workspaceRoot) {
|
|
42
|
+
return lookupLocalPlugin(importPath, projects, root);
|
|
43
|
+
}
|
|
44
|
+
function getPluginPathAndName(moduleName, paths, projects, root) {
|
|
45
|
+
let pluginPath;
|
|
46
|
+
let shouldRegisterTSTranspiler = false;
|
|
47
|
+
try {
|
|
48
|
+
pluginPath = require.resolve(moduleName, {
|
|
49
|
+
paths,
|
|
50
|
+
});
|
|
51
|
+
const extension = path.extname(pluginPath);
|
|
52
|
+
shouldRegisterTSTranspiler = extension === '.ts';
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
if (e.code === 'MODULE_NOT_FOUND') {
|
|
56
|
+
const plugin = resolveLocalNxPlugin(moduleName, projects, root);
|
|
57
|
+
if (plugin) {
|
|
58
|
+
shouldRegisterTSTranspiler = true;
|
|
59
|
+
const main = readPluginMainFromProjectConfiguration(plugin.projectConfig);
|
|
60
|
+
pluginPath = main ? path.join(root, main) : plugin.path;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
logger_1.logger.error(`Plugin listed in \`nx.json\` not found: ${moduleName}`);
|
|
64
|
+
throw e;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
throw e;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const packageJsonPath = path.join(pluginPath, 'package.json');
|
|
72
|
+
const { name } = !['.ts', '.js'].some((x) => path.extname(moduleName) === x) && // Not trying to point to a ts or js file
|
|
73
|
+
(0, node_fs_1.existsSync)(packageJsonPath) // plugin has a package.json
|
|
74
|
+
? (0, fileutils_1.readJsonFile)(packageJsonPath) // read name from package.json
|
|
75
|
+
: { name: moduleName };
|
|
76
|
+
return { pluginPath, name, shouldRegisterTSTranspiler };
|
|
77
|
+
}
|
|
78
|
+
function lookupLocalPlugin(importPath, projects, root = workspace_root_1.workspaceRoot) {
|
|
79
|
+
const projectConfig = findNxProjectForImportPath(importPath, projects, root);
|
|
80
|
+
if (!projectConfig) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
return { path: path.join(root, projectConfig.root), projectConfig };
|
|
84
|
+
}
|
|
85
|
+
let packageEntryPointsToProjectMap;
|
|
86
|
+
let wildcardEntryPointsToProjectMap;
|
|
87
|
+
function findNxProjectForImportPath(importPath, projects, root = workspace_root_1.workspaceRoot) {
|
|
88
|
+
const tsConfigPaths = readTsConfigPaths(root);
|
|
89
|
+
const possibleTsPaths = tsConfigPaths[importPath]?.map((p) => (0, path_1.normalizePath)(path.relative(root, path.join(root, p)))) ?? [];
|
|
90
|
+
const projectRootMappings = new Map();
|
|
91
|
+
if (possibleTsPaths.length) {
|
|
92
|
+
const projectNameMap = new Map();
|
|
93
|
+
for (const projectRoot in projects) {
|
|
94
|
+
const project = projects[projectRoot];
|
|
95
|
+
projectRootMappings.set(project.root, project.name);
|
|
96
|
+
projectNameMap.set(project.name, project);
|
|
97
|
+
}
|
|
98
|
+
for (const tsConfigPath of possibleTsPaths) {
|
|
99
|
+
const nxProject = (0, find_project_for_path_1.findProjectForPath)(tsConfigPath, projectRootMappings);
|
|
100
|
+
if (nxProject) {
|
|
101
|
+
return projectNameMap.get(nxProject);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (!packageEntryPointsToProjectMap && !wildcardEntryPointsToProjectMap) {
|
|
106
|
+
({
|
|
107
|
+
entryPointsToProjectMap: packageEntryPointsToProjectMap,
|
|
108
|
+
wildcardEntryPointsToProjectMap,
|
|
109
|
+
} = (0, packages_1.getWorkspacePackagesMetadata)(projects));
|
|
110
|
+
}
|
|
111
|
+
if (packageEntryPointsToProjectMap[importPath]) {
|
|
112
|
+
return packageEntryPointsToProjectMap[importPath];
|
|
113
|
+
}
|
|
114
|
+
const project = (0, packages_1.matchImportToWildcardEntryPointsToProjectMap)(wildcardEntryPointsToProjectMap, importPath);
|
|
115
|
+
if (project) {
|
|
116
|
+
return project;
|
|
117
|
+
}
|
|
118
|
+
logger_1.logger.verbose('Unable to find local plugin', possibleTsPaths, projectRootMappings);
|
|
119
|
+
throw new Error('Unable to resolve local plugin with import path ' + importPath);
|
|
120
|
+
}
|
|
121
|
+
let tsconfigPaths;
|
|
122
|
+
function readTsConfigPaths(root = workspace_root_1.workspaceRoot) {
|
|
123
|
+
if (!tsconfigPaths) {
|
|
124
|
+
const tsconfigPath = ['tsconfig.base.json', 'tsconfig.json']
|
|
125
|
+
.map((x) => path.join(root, x))
|
|
126
|
+
.filter((x) => (0, node_fs_1.existsSync)(x))[0];
|
|
127
|
+
if (!tsconfigPath) {
|
|
128
|
+
throw new Error('unable to find tsconfig.base.json or tsconfig.json');
|
|
129
|
+
}
|
|
130
|
+
const { compilerOptions } = (0, fileutils_1.readJsonFile)(tsconfigPath);
|
|
131
|
+
tsconfigPaths = compilerOptions?.paths;
|
|
132
|
+
}
|
|
133
|
+
return tsconfigPaths ?? {};
|
|
134
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PostTasksExecutionContext, PreTasksExecutionContext } from './public-api';
|
|
2
|
+
export declare function runPreTasksExecution(pluginContext: PreTasksExecutionContext): Promise<NodeJS.ProcessEnv[]>;
|
|
3
|
+
export declare function runPostTasksExecution(context: PostTasksExecutionContext): Promise<void>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runPreTasksExecution = runPreTasksExecution;
|
|
4
|
+
exports.runPostTasksExecution = runPostTasksExecution;
|
|
5
|
+
const get_plugins_1 = require("./get-plugins");
|
|
6
|
+
const is_on_daemon_1 = require("../../daemon/is-on-daemon");
|
|
7
|
+
const client_1 = require("../../daemon/client/client");
|
|
8
|
+
async function runPreTasksExecution(pluginContext) {
|
|
9
|
+
if ((0, is_on_daemon_1.isOnDaemon)() || !(0, client_1.isDaemonEnabled)()) {
|
|
10
|
+
performance.mark(`preTasksExecution:start`);
|
|
11
|
+
const plugins = await (0, get_plugins_1.getPlugins)(pluginContext.workspaceRoot);
|
|
12
|
+
const envs = await Promise.all(plugins
|
|
13
|
+
.filter((p) => p.preTasksExecution)
|
|
14
|
+
.map(async (plugin) => {
|
|
15
|
+
performance.mark(`${plugin.name}:preTasksExecution:start`);
|
|
16
|
+
try {
|
|
17
|
+
return await plugin.preTasksExecution(pluginContext);
|
|
18
|
+
}
|
|
19
|
+
finally {
|
|
20
|
+
performance.mark(`${plugin.name}:preTasksExecution:end`);
|
|
21
|
+
performance.measure(`${plugin.name}:preTasksExecution`, `${plugin.name}:preTasksExecution:start`, `${plugin.name}:preTasksExecution:end`);
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
if (!(0, client_1.isDaemonEnabled)()) {
|
|
25
|
+
applyProcessEnvs(envs);
|
|
26
|
+
}
|
|
27
|
+
performance.mark(`preTasksExecution:end`);
|
|
28
|
+
performance.measure(`preTasksExecution`, `preTasksExecution:start`, `preTasksExecution:end`);
|
|
29
|
+
return envs;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const envs = await client_1.daemonClient.runPreTasksExecution(pluginContext);
|
|
33
|
+
applyProcessEnvs(envs);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function applyProcessEnvs(envs) {
|
|
37
|
+
for (const env of envs) {
|
|
38
|
+
for (const key in env) {
|
|
39
|
+
process.env[key] = env[key];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function runPostTasksExecution(context) {
|
|
44
|
+
if ((0, is_on_daemon_1.isOnDaemon)() || !(0, client_1.isDaemonEnabled)()) {
|
|
45
|
+
performance.mark(`postTasksExecution:start`);
|
|
46
|
+
const plugins = await (0, get_plugins_1.getPlugins)();
|
|
47
|
+
await Promise.all(plugins
|
|
48
|
+
.filter((p) => p.postTasksExecution)
|
|
49
|
+
.map(async (plugin) => {
|
|
50
|
+
performance.mark(`${plugin.name}:postTasksExecution:start`);
|
|
51
|
+
try {
|
|
52
|
+
await plugin.postTasksExecution(context);
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
performance.mark(`${plugin.name}:postTasksExecution:end`);
|
|
56
|
+
performance.measure(`${plugin.name}:postTasksExecution`, `${plugin.name}:postTasksExecution:start`, `${plugin.name}:postTasksExecution:end`);
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
59
|
+
performance.mark(`postTasksExecution:end`);
|
|
60
|
+
performance.measure(`postTasksExecution`, `postTasksExecution:start`, `postTasksExecution:end`);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
await client_1.daemonClient.runPostTasksExecution(context);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare let unregisterPluginTSTranspiler: (() => void) | null;
|
|
2
|
+
/**
|
|
3
|
+
* Register swc-node or ts-node if they are not currently registered
|
|
4
|
+
* with some default settings which work well for Nx plugins.
|
|
5
|
+
*/
|
|
6
|
+
export declare function registerPluginTSTranspiler(): void;
|
|
7
|
+
export declare function pluginTranspilerIsRegistered(): boolean;
|
|
8
|
+
export declare function cleanupPluginTSTranspiler(): void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unregisterPluginTSTranspiler = void 0;
|
|
4
|
+
exports.registerPluginTSTranspiler = registerPluginTSTranspiler;
|
|
5
|
+
exports.pluginTranspilerIsRegistered = pluginTranspilerIsRegistered;
|
|
6
|
+
exports.cleanupPluginTSTranspiler = cleanupPluginTSTranspiler;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const posix_1 = require("node:path/posix");
|
|
9
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
|
10
|
+
const register_1 = require("../../plugins/js/utils/register");
|
|
11
|
+
const typescript_1 = require("../../plugins/js/utils/typescript");
|
|
12
|
+
exports.unregisterPluginTSTranspiler = null;
|
|
13
|
+
/**
|
|
14
|
+
* Register swc-node or ts-node if they are not currently registered
|
|
15
|
+
* with some default settings which work well for Nx plugins.
|
|
16
|
+
*/
|
|
17
|
+
function registerPluginTSTranspiler() {
|
|
18
|
+
// Get the first tsconfig that matches the allowed set
|
|
19
|
+
const tsConfigName = [
|
|
20
|
+
(0, posix_1.join)(workspace_root_1.workspaceRoot, 'tsconfig.base.json'),
|
|
21
|
+
(0, posix_1.join)(workspace_root_1.workspaceRoot, 'tsconfig.json'),
|
|
22
|
+
].find((x) => (0, node_fs_1.existsSync)(x));
|
|
23
|
+
if (!tsConfigName) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const tsConfigOptions = tsConfigName
|
|
27
|
+
? (0, typescript_1.readTsConfigOptions)(tsConfigName)
|
|
28
|
+
: {};
|
|
29
|
+
const cleanupFns = [
|
|
30
|
+
(0, register_1.registerTsConfigPaths)(tsConfigName),
|
|
31
|
+
(0, register_1.registerTranspiler)({
|
|
32
|
+
experimentalDecorators: true,
|
|
33
|
+
emitDecoratorMetadata: true,
|
|
34
|
+
...tsConfigOptions,
|
|
35
|
+
}),
|
|
36
|
+
];
|
|
37
|
+
exports.unregisterPluginTSTranspiler = () => {
|
|
38
|
+
cleanupFns.forEach((fn) => fn?.());
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function pluginTranspilerIsRegistered() {
|
|
42
|
+
return exports.unregisterPluginTSTranspiler !== null;
|
|
43
|
+
}
|
|
44
|
+
function cleanupPluginTSTranspiler() {
|
|
45
|
+
(0, exports.unregisterPluginTSTranspiler)?.();
|
|
46
|
+
exports.unregisterPluginTSTranspiler = null;
|
|
47
|
+
}
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { CreateNodesContextV2, CreateNodesFunction, CreateNodesResult, type NxPlugin, type NxPluginV2 } from './public-api';
|
|
4
|
-
export declare function isNxPluginV2(plugin: NxPlugin): plugin is NxPluginV2;
|
|
5
|
-
export declare function isNxPluginV1(plugin: NxPlugin | LoadedNxPlugin): plugin is NxPluginV1;
|
|
6
|
-
export declare function normalizeNxPlugin(plugin: NxPlugin): NormalizedPlugin;
|
|
7
|
-
export type AsyncFn<T extends Function> = T extends (...args: infer A) => infer R ? (...args: A) => Promise<Awaited<R>> : never;
|
|
8
|
-
export declare function createNodesFromFiles<T = unknown>(createNodes: CreateNodesFunction<T>, configFiles: readonly string[], options: T, context: CreateNodesContextV2): Promise<[file: string, value: CreateNodesResult][]>;
|
|
1
|
+
import { CreateNodesContext, CreateNodesContextV2, CreateNodesResult } from './public-api';
|
|
2
|
+
export declare function createNodesFromFiles<T = unknown>(createNodes: (projectConfigurationFile: string, options: T | undefined, context: CreateNodesContext, idx: number) => CreateNodesResult | Promise<CreateNodesResult>, configFiles: readonly string[], options: T, context: CreateNodesContextV2): Promise<[file: string, value: CreateNodesResult][]>;
|
|
@@ -1,53 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNxPluginV2 = isNxPluginV2;
|
|
4
|
-
exports.isNxPluginV1 = isNxPluginV1;
|
|
5
|
-
exports.normalizeNxPlugin = normalizeNxPlugin;
|
|
6
3
|
exports.createNodesFromFiles = createNodesFromFiles;
|
|
7
|
-
const node_path_1 = require("node:path");
|
|
8
|
-
const to_project_name_1 = require("../../config/to-project-name");
|
|
9
|
-
const globs_1 = require("../../utils/globs");
|
|
10
4
|
const error_types_1 = require("../error-types");
|
|
11
|
-
function isNxPluginV2(plugin) {
|
|
12
|
-
return 'createNodes' in plugin || 'createDependencies' in plugin;
|
|
13
|
-
}
|
|
14
|
-
function isNxPluginV1(plugin) {
|
|
15
|
-
return 'processProjectGraph' in plugin || 'projectFilePatterns' in plugin;
|
|
16
|
-
}
|
|
17
|
-
function normalizeNxPlugin(plugin) {
|
|
18
|
-
if (isNxPluginV2(plugin)) {
|
|
19
|
-
return plugin;
|
|
20
|
-
}
|
|
21
|
-
if (isNxPluginV1(plugin) && plugin.projectFilePatterns) {
|
|
22
|
-
return {
|
|
23
|
-
...plugin,
|
|
24
|
-
createNodes: [
|
|
25
|
-
`*/**/${(0, globs_1.combineGlobPatterns)(plugin.projectFilePatterns)}`,
|
|
26
|
-
(configFilePath) => {
|
|
27
|
-
const root = (0, node_path_1.dirname)(configFilePath);
|
|
28
|
-
return {
|
|
29
|
-
projects: {
|
|
30
|
-
[root]: {
|
|
31
|
-
name: (0, to_project_name_1.toProjectName)(configFilePath),
|
|
32
|
-
targets: plugin.registerProjectTargets?.(configFilePath),
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
return plugin;
|
|
41
|
-
}
|
|
42
5
|
async function createNodesFromFiles(createNodes, configFiles, options, context) {
|
|
43
6
|
const results = [];
|
|
44
7
|
const errors = [];
|
|
45
|
-
await Promise.all(configFiles.map(async (file) => {
|
|
8
|
+
await Promise.all(configFiles.map(async (file, idx) => {
|
|
46
9
|
try {
|
|
47
10
|
const value = await createNodes(file, options, {
|
|
48
11
|
...context,
|
|
49
12
|
configFiles,
|
|
50
|
-
});
|
|
13
|
+
}, idx);
|
|
51
14
|
if (value) {
|
|
52
15
|
results.push([file, value]);
|
|
53
16
|
}
|
|
@@ -2,9 +2,11 @@ import { ProjectGraph } from '../config/project-graph';
|
|
|
2
2
|
import { ProjectConfiguration, ProjectsConfigurations } from '../config/workspace-json-project-json';
|
|
3
3
|
/**
|
|
4
4
|
* Synchronously reads the latest cached copy of the workspace's ProjectGraph.
|
|
5
|
+
*
|
|
6
|
+
* @param {number} [minimumComputedAt] - The minimum timestamp that the cached ProjectGraph must have been computed at.
|
|
5
7
|
* @throws {Error} if there is no cached ProjectGraph to read from
|
|
6
8
|
*/
|
|
7
|
-
export declare function readCachedProjectGraph(): ProjectGraph;
|
|
9
|
+
export declare function readCachedProjectGraph(minimumComputedAt?: number): ProjectGraph;
|
|
8
10
|
export declare function readCachedProjectConfiguration(projectName: string): ProjectConfiguration;
|
|
9
11
|
/**
|
|
10
12
|
* Get the {@link ProjectsConfigurations} from the {@link ProjectGraph}
|