@ohos-ports/nx 17.3.2-beta.0
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 +106 -0
- package/LICENSE +22 -0
- package/README.md +66 -0
- package/bin/init-local.d.ts +8 -0
- package/bin/init-local.js +175 -0
- package/bin/nx-cloud.d.ts +2 -0
- package/bin/nx-cloud.js +55 -0
- package/bin/nx.d.ts +2 -0
- package/bin/nx.js +230 -0
- package/bin/post-install.d.ts +1 -0
- package/bin/post-install.js +55 -0
- package/bin/run-executor.d.ts +1 -0
- package/bin/run-executor.js +66 -0
- package/executors.json +19 -0
- package/generators.json +10 -0
- package/migrations.json +87 -0
- package/package.json +186 -0
- package/plugins/package-json.d.ts +1 -0
- package/plugins/package-json.js +12 -0
- package/presets/core.json +1 -0
- package/presets/npm.json +7 -0
- package/release/changelog-renderer/index.d.ts +56 -0
- package/release/changelog-renderer/index.js +238 -0
- package/release/index.d.ts +4 -0
- package/release/index.js +11 -0
- package/schemas/nx-schema.json +623 -0
- package/schemas/project-schema.json +244 -0
- package/schemas/workspace-schema.json +185 -0
- package/src/adapter/angular-json.d.ts +9 -0
- package/src/adapter/angular-json.js +127 -0
- package/src/adapter/compat.d.ts +2 -0
- package/src/adapter/compat.js +136 -0
- package/src/adapter/decorate-cli.d.ts +1 -0
- package/src/adapter/decorate-cli.js +25 -0
- package/src/adapter/ngcli-adapter.d.ts +90 -0
- package/src/adapter/ngcli-adapter.js +848 -0
- package/src/adapter/rxjs-for-await.d.ts +109 -0
- package/src/adapter/rxjs-for-await.js +362 -0
- package/src/command-line/add/add.d.ts +2 -0
- package/src/command-line/add/add.js +165 -0
- package/src/command-line/add/command-object.d.ts +7 -0
- package/src/command-line/add/command-object.js +24 -0
- package/src/command-line/affected/affected.d.ts +7 -0
- package/src/command-line/affected/affected.js +105 -0
- package/src/command-line/affected/command-object.d.ts +16 -0
- package/src/command-line/affected/command-object.js +93 -0
- package/src/command-line/affected/print-affected.d.ts +11 -0
- package/src/command-line/affected/print-affected.js +108 -0
- package/src/command-line/connect/command-object.d.ts +3 -0
- package/src/command-line/connect/command-object.js +19 -0
- package/src/command-line/connect/connect-to-nx-cloud.d.ts +8 -0
- package/src/command-line/connect/connect-to-nx-cloud.js +96 -0
- package/src/command-line/connect/view-logs.d.ts +1 -0
- package/src/command-line/connect/view-logs.js +53 -0
- package/src/command-line/daemon/command-object.d.ts +2 -0
- package/src/command-line/daemon/command-object.js +21 -0
- package/src/command-line/daemon/daemon.d.ts +2 -0
- package/src/command-line/daemon/daemon.js +27 -0
- package/src/command-line/examples.d.ts +5 -0
- package/src/command-line/examples.js +347 -0
- package/src/command-line/exec/command-object.d.ts +2 -0
- package/src/command-line/exec/command-object.js +19 -0
- package/src/command-line/exec/exec.d.ts +1 -0
- package/src/command-line/exec/exec.js +141 -0
- package/src/command-line/format/command-object.d.ts +3 -0
- package/src/command-line/format/command-object.js +46 -0
- package/src/command-line/format/format.d.ts +2 -0
- package/src/command-line/format/format.js +155 -0
- package/src/command-line/generate/command-object.d.ts +2 -0
- package/src/command-line/generate/command-object.js +70 -0
- package/src/command-line/generate/generate.d.ts +21 -0
- package/src/command-line/generate/generate.js +266 -0
- package/src/command-line/generate/generator-utils.d.ts +17 -0
- package/src/command-line/generate/generator-utils.js +87 -0
- package/src/command-line/graph/command-object.d.ts +2 -0
- package/src/command-line/graph/command-object.js +21 -0
- package/src/command-line/graph/graph.d.ts +39 -0
- package/src/command-line/graph/graph.js +661 -0
- package/src/command-line/init/command-object.d.ts +2 -0
- package/src/command-line/init/command-object.js +81 -0
- package/src/command-line/init/implementation/add-nx-to-monorepo.d.ts +4 -0
- package/src/command-line/init/implementation/add-nx-to-monorepo.js +133 -0
- package/src/command-line/init/implementation/add-nx-to-nest.d.ts +5 -0
- package/src/command-line/init/implementation/add-nx-to-nest.js +346 -0
- package/src/command-line/init/implementation/add-nx-to-npm-repo.d.ts +4 -0
- package/src/command-line/init/implementation/add-nx-to-npm-repo.js +66 -0
- package/src/command-line/init/implementation/angular/index.d.ts +2 -0
- package/src/command-line/init/implementation/angular/index.js +128 -0
- package/src/command-line/init/implementation/angular/integrated-workspace.d.ts +1 -0
- package/src/command-line/init/implementation/angular/integrated-workspace.js +10 -0
- package/src/command-line/init/implementation/angular/legacy-angular-versions.d.ts +2 -0
- package/src/command-line/init/implementation/angular/legacy-angular-versions.js +125 -0
- package/src/command-line/init/implementation/angular/standalone-workspace.d.ts +1 -0
- package/src/command-line/init/implementation/angular/standalone-workspace.js +178 -0
- package/src/command-line/init/implementation/angular/types.d.ts +20 -0
- package/src/command-line/init/implementation/angular/types.js +2 -0
- package/src/command-line/init/implementation/dot-nx/add-nx-scripts.d.ts +7 -0
- package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +91 -0
- package/src/command-line/init/implementation/dot-nx/nxw.d.ts +1 -0
- package/src/command-line/init/implementation/dot-nx/nxw.js +116 -0
- package/src/command-line/init/implementation/react/add-craco-commands-to-package-scripts.d.ts +1 -0
- package/src/command-line/init/implementation/react/add-craco-commands-to-package-scripts.js +22 -0
- package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.d.ts +1 -0
- package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.js +19 -0
- package/src/command-line/init/implementation/react/check-for-custom-webpack-setup.d.ts +1 -0
- package/src/command-line/init/implementation/react/check-for-custom-webpack-setup.js +18 -0
- package/src/command-line/init/implementation/react/check-for-uncommitted-changes.d.ts +1 -0
- package/src/command-line/init/implementation/react/check-for-uncommitted-changes.js +16 -0
- package/src/command-line/init/implementation/react/clean-up-files.d.ts +1 -0
- package/src/command-line/init/implementation/react/clean-up-files.js +31 -0
- package/src/command-line/init/implementation/react/index.d.ts +4 -0
- package/src/command-line/init/implementation/react/index.js +230 -0
- package/src/command-line/init/implementation/react/read-name-from-package-json.d.ts +1 -0
- package/src/command-line/init/implementation/react/read-name-from-package-json.js +17 -0
- package/src/command-line/init/implementation/react/rename-js-to-jsx.d.ts +1 -0
- package/src/command-line/init/implementation/react/rename-js-to-jsx.js +23 -0
- package/src/command-line/init/implementation/react/tsconfig-setup.d.ts +1 -0
- package/src/command-line/init/implementation/react/tsconfig-setup.js +109 -0
- package/src/command-line/init/implementation/react/write-craco-config.d.ts +1 -0
- package/src/command-line/init/implementation/react/write-craco-config.js +62 -0
- package/src/command-line/init/implementation/react/write-vite-config.d.ts +1 -0
- package/src/command-line/init/implementation/react/write-vite-config.js +38 -0
- package/src/command-line/init/implementation/react/write-vite-index-html.d.ts +1 -0
- package/src/command-line/init/implementation/react/write-vite-index-html.js +25 -0
- package/src/command-line/init/implementation/utils.d.ts +16 -0
- package/src/command-line/init/implementation/utils.js +176 -0
- package/src/command-line/init/init-v1.d.ts +11 -0
- package/src/command-line/init/init-v1.js +118 -0
- package/src/command-line/init/init-v2.d.ts +7 -0
- package/src/command-line/init/init-v2.js +165 -0
- package/src/command-line/list/command-object.d.ts +2 -0
- package/src/command-line/list/command-object.js +15 -0
- package/src/command-line/list/list.d.ts +13 -0
- package/src/command-line/list/list.js +47 -0
- package/src/command-line/migrate/command-object.d.ts +3 -0
- package/src/command-line/migrate/command-object.js +150 -0
- package/src/command-line/migrate/migrate.d.ts +114 -0
- package/src/command-line/migrate/migrate.js +1115 -0
- package/src/command-line/new/command-object.d.ts +2 -0
- package/src/command-line/new/command-object.js +25 -0
- package/src/command-line/new/new.d.ts +3 -0
- package/src/command-line/new/new.js +30 -0
- package/src/command-line/nx-commands.d.ts +10 -0
- package/src/command-line/nx-commands.js +77 -0
- package/src/command-line/release/changelog.d.ts +8 -0
- package/src/command-line/release/changelog.js +696 -0
- package/src/command-line/release/command-object.d.ts +45 -0
- package/src/command-line/release/command-object.js +237 -0
- package/src/command-line/release/config/config.d.ts +56 -0
- package/src/command-line/release/config/config.js +501 -0
- package/src/command-line/release/config/filter-release-groups.d.ts +13 -0
- package/src/command-line/release/config/filter-release-groups.js +150 -0
- package/src/command-line/release/index.d.ts +16 -0
- package/src/command-line/release/index.js +23 -0
- package/src/command-line/release/publish.d.ts +8 -0
- package/src/command-line/release/publish.js +149 -0
- package/src/command-line/release/release.d.ts +4 -0
- package/src/command-line/release/release.js +124 -0
- package/src/command-line/release/utils/batch-projects-by-generator-config.d.ts +7 -0
- package/src/command-line/release/utils/batch-projects-by-generator-config.js +37 -0
- package/src/command-line/release/utils/exec-command.d.ts +1 -0
- package/src/command-line/release/utils/exec-command.js +34 -0
- package/src/command-line/release/utils/git.d.ts +55 -0
- package/src/command-line/release/utils/git.js +261 -0
- package/src/command-line/release/utils/github.d.ts +27 -0
- package/src/command-line/release/utils/github.js +229 -0
- package/src/command-line/release/utils/launch-editor.d.ts +1 -0
- package/src/command-line/release/utils/launch-editor.js +42 -0
- package/src/command-line/release/utils/markdown.d.ts +6 -0
- package/src/command-line/release/utils/markdown.js +29 -0
- package/src/command-line/release/utils/print-changes.d.ts +7 -0
- package/src/command-line/release/utils/print-changes.js +60 -0
- package/src/command-line/release/utils/resolve-nx-json-error-message.d.ts +1 -0
- package/src/command-line/release/utils/resolve-nx-json-error-message.js +52 -0
- package/src/command-line/release/utils/resolve-semver-specifier.d.ts +3 -0
- package/src/command-line/release/utils/resolve-semver-specifier.js +69 -0
- package/src/command-line/release/utils/semver.d.ts +17 -0
- package/src/command-line/release/utils/semver.js +56 -0
- package/src/command-line/release/utils/shared.d.ts +34 -0
- package/src/command-line/release/utils/shared.js +211 -0
- package/src/command-line/release/version.d.ts +42 -0
- package/src/command-line/release/version.js +347 -0
- package/src/command-line/repair/command-object.d.ts +2 -0
- package/src/command-line/repair/command-object.js +22 -0
- package/src/command-line/repair/repair.d.ts +3 -0
- package/src/command-line/repair/repair.js +37 -0
- package/src/command-line/repair.d.ts +4 -0
- package/src/command-line/repair.js +7 -0
- package/src/command-line/report/command-object.d.ts +2 -0
- package/src/command-line/report/command-object.js +11 -0
- package/src/command-line/report/report.d.ts +48 -0
- package/src/command-line/report/report.js +232 -0
- package/src/command-line/reset/command-object.d.ts +2 -0
- package/src/command-line/reset/command-object.js +9 -0
- package/src/command-line/reset/reset.d.ts +1 -0
- package/src/command-line/reset/reset.js +23 -0
- package/src/command-line/run/command-object.d.ts +6 -0
- package/src/command-line/run/command-object.js +25 -0
- package/src/command-line/run/executor-utils.d.ts +7 -0
- package/src/command-line/run/executor-utils.js +73 -0
- package/src/command-line/run/run-one.d.ts +7 -0
- package/src/command-line/run/run-one.js +117 -0
- package/src/command-line/run/run.d.ts +51 -0
- package/src/command-line/run/run.js +172 -0
- package/src/command-line/run-many/command-object.d.ts +2 -0
- package/src/command-line/run-many/command-object.js +11 -0
- package/src/command-line/run-many/run-many.d.ts +10 -0
- package/src/command-line/run-many/run-many.js +90 -0
- package/src/command-line/run-many.d.ts +4 -0
- package/src/command-line/run-many.js +7 -0
- package/src/command-line/run-one.d.ts +4 -0
- package/src/command-line/run-one.js +7 -0
- package/src/command-line/run.d.ts +4 -0
- package/src/command-line/run.js +7 -0
- package/src/command-line/show/command-object.d.ts +22 -0
- package/src/command-line/show/command-object.js +84 -0
- package/src/command-line/show/show.d.ts +3 -0
- package/src/command-line/show/show.js +126 -0
- package/src/command-line/watch/command-object.d.ts +2 -0
- package/src/command-line/watch/command-object.js +64 -0
- package/src/command-line/watch/watch.d.ts +23 -0
- package/src/command-line/watch/watch.js +169 -0
- package/src/command-line/watch.d.ts +4 -0
- package/src/command-line/watch.js +7 -0
- package/src/command-line/yargs-utils/documentation.d.ts +2 -0
- package/src/command-line/yargs-utils/documentation.js +12 -0
- package/src/command-line/yargs-utils/shared-options.d.ts +89 -0
- package/src/command-line/yargs-utils/shared-options.js +284 -0
- package/src/commands-runner/command-graph.d.ts +13 -0
- package/src/commands-runner/command-graph.js +2 -0
- package/src/commands-runner/create-command-graph.d.ts +4 -0
- package/src/commands-runner/create-command-graph.js +44 -0
- package/src/commands-runner/get-command-projects.d.ts +3 -0
- package/src/commands-runner/get-command-projects.js +19 -0
- package/src/config/calculate-default-project-name.d.ts +4 -0
- package/src/config/calculate-default-project-name.js +42 -0
- package/src/config/configuration.d.ts +8 -0
- package/src/config/configuration.js +17 -0
- package/src/config/misc-interfaces.d.ts +199 -0
- package/src/config/misc-interfaces.js +2 -0
- package/src/config/nx-json.d.ts +372 -0
- package/src/config/nx-json.js +40 -0
- package/src/config/project-graph.d.ts +137 -0
- package/src/config/project-graph.js +37 -0
- package/src/config/schema-utils.d.ts +15 -0
- package/src/config/schema-utils.js +59 -0
- package/src/config/task-graph.d.ts +100 -0
- package/src/config/task-graph.js +2 -0
- package/src/config/workspace-json-project-json.d.ts +189 -0
- package/src/config/workspace-json-project-json.js +2 -0
- package/src/config/workspaces.d.ts +18 -0
- package/src/config/workspaces.js +35 -0
- package/src/core/graph/3rdpartylicenses.txt +833 -0
- package/src/core/graph/environment.js +1 -0
- package/src/core/graph/favicon.ico +0 -0
- package/src/core/graph/index.html +31 -0
- package/src/core/graph/main.js +1 -0
- package/src/core/graph/polyfills.js +1 -0
- package/src/core/graph/runtime.js +1 -0
- package/src/core/graph/styles.css +3 -0
- package/src/core/graph/styles.js +1 -0
- package/src/daemon/cache.d.ts +9 -0
- package/src/daemon/cache.js +52 -0
- package/src/daemon/client/client.d.ts +56 -0
- package/src/daemon/client/client.js +359 -0
- package/src/daemon/client/daemon-socket-messenger.d.ts +13 -0
- package/src/daemon/client/daemon-socket-messenger.js +26 -0
- package/src/daemon/client/exec-is-server-available.d.ts +1 -0
- package/src/daemon/client/exec-is-server-available.js +11 -0
- package/src/daemon/client/generate-help-output.d.ts +1 -0
- package/src/daemon/client/generate-help-output.js +26 -0
- package/src/daemon/server/file-watching/changed-projects.d.ts +10 -0
- package/src/daemon/server/file-watching/changed-projects.js +45 -0
- package/src/daemon/server/file-watching/file-watcher-sockets.d.ts +13 -0
- package/src/daemon/server/file-watching/file-watcher-sockets.js +66 -0
- package/src/daemon/server/handle-hash-tasks.d.ts +10 -0
- package/src/daemon/server/handle-hash-tasks.js +26 -0
- package/src/daemon/server/handle-outputs-tracking.d.ts +15 -0
- package/src/daemon/server/handle-outputs-tracking.js +36 -0
- package/src/daemon/server/handle-process-in-background.d.ts +6 -0
- package/src/daemon/server/handle-process-in-background.js +33 -0
- package/src/daemon/server/handle-request-file-data.d.ts +4 -0
- package/src/daemon/server/handle-request-file-data.js +13 -0
- package/src/daemon/server/handle-request-project-graph.d.ts +2 -0
- package/src/daemon/server/handle-request-project-graph.js +37 -0
- package/src/daemon/server/handle-request-shutdown.d.ts +6 -0
- package/src/daemon/server/handle-request-shutdown.js +26 -0
- package/src/daemon/server/logger.d.ts +18 -0
- package/src/daemon/server/logger.js +37 -0
- package/src/daemon/server/outputs-tracking.d.ts +8 -0
- package/src/daemon/server/outputs-tracking.js +94 -0
- package/src/daemon/server/project-graph-incremental-recomputation.d.ts +22 -0
- package/src/daemon/server/project-graph-incremental-recomputation.js +227 -0
- package/src/daemon/server/server.d.ts +9 -0
- package/src/daemon/server/server.js +303 -0
- package/src/daemon/server/shutdown-utils.d.ts +17 -0
- package/src/daemon/server/shutdown-utils.js +77 -0
- package/src/daemon/server/start.d.ts +1 -0
- package/src/daemon/server/start.js +17 -0
- package/src/daemon/server/watcher.d.ts +12 -0
- package/src/daemon/server/watcher.js +96 -0
- package/src/daemon/socket-utils.d.ts +11 -0
- package/src/daemon/socket-utils.js +42 -0
- package/src/daemon/tmp-dir.d.ts +8 -0
- package/src/daemon/tmp-dir.js +68 -0
- package/src/devkit-exports.d.ts +135 -0
- package/src/devkit-exports.js +140 -0
- package/src/devkit-internals.d.ts +19 -0
- package/src/devkit-internals.js +37 -0
- package/src/devkit-testing-exports.d.ts +2 -0
- package/src/devkit-testing-exports.js +8 -0
- package/src/executors/noop/noop.impl.d.ts +3 -0
- package/src/executors/noop/noop.impl.js +6 -0
- package/src/executors/noop/schema.json +10 -0
- package/src/executors/run-commands/run-commands.impl.d.ts +42 -0
- package/src/executors/run-commands/run-commands.impl.js +247 -0
- package/src/executors/run-commands/schema.json +150 -0
- package/src/executors/run-script/run-script.impl.d.ts +8 -0
- package/src/executors/run-script/run-script.impl.js +56 -0
- package/src/executors/run-script/schema.json +28 -0
- package/src/executors/utils/convert-nx-executor.d.ts +10 -0
- package/src/executors/utils/convert-nx-executor.js +82 -0
- package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +8 -0
- package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +49 -0
- package/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +11 -0
- package/src/generators/testing-utils/create-tree-with-empty-workspace.js +46 -0
- package/src/generators/testing-utils/create-tree.d.ts +5 -0
- package/src/generators/testing-utils/create-tree.js +11 -0
- package/src/generators/tree.d.ts +128 -0
- package/src/generators/tree.js +309 -0
- package/src/generators/utils/glob.d.ts +11 -0
- package/src/generators/utils/glob.js +35 -0
- package/src/generators/utils/json.d.ts +28 -0
- package/src/generators/utils/json.js +48 -0
- package/src/generators/utils/nx-json.d.ts +11 -0
- package/src/generators/utils/nx-json.js +59 -0
- package/src/generators/utils/project-configuration.d.ts +42 -0
- package/src/generators/utils/project-configuration.js +239 -0
- package/src/hasher/create-task-hasher.d.ts +4 -0
- package/src/hasher/create-task-hasher.js +16 -0
- package/src/hasher/file-hasher.d.ts +2 -0
- package/src/hasher/file-hasher.js +19 -0
- package/src/hasher/hash-task.d.ts +7 -0
- package/src/hasher/hash-task.js +54 -0
- package/src/hasher/native-task-hasher-impl.d.ts +19 -0
- package/src/hasher/native-task-hasher-impl.js +37 -0
- package/src/hasher/node-task-hasher-impl.d.ts +49 -0
- package/src/hasher/node-task-hasher-impl.js +431 -0
- package/src/hasher/task-hasher.d.ts +129 -0
- package/src/hasher/task-hasher.js +266 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +5 -0
- package/src/migrations/update-15-0-0/migrate-to-inputs.d.ts +2 -0
- package/src/migrations/update-15-0-0/migrate-to-inputs.js +102 -0
- package/src/migrations/update-15-0-0/prefix-outputs.d.ts +2 -0
- package/src/migrations/update-15-0-0/prefix-outputs.js +64 -0
- package/src/migrations/update-15-1-0/set-project-names.d.ts +2 -0
- package/src/migrations/update-15-1-0/set-project-names.js +32 -0
- package/src/migrations/update-15-8-2/update-nxw.d.ts +2 -0
- package/src/migrations/update-15-8-2/update-nxw.js +7 -0
- package/src/migrations/update-16-0-0/remove-nrwl-cli.d.ts +2 -0
- package/src/migrations/update-16-0-0/remove-nrwl-cli.js +16 -0
- package/src/migrations/update-16-0-0/update-depends-on-to-tokens.d.ts +2 -0
- package/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +97 -0
- package/src/migrations/update-16-0-0/update-nx-cloud-runner.d.ts +2 -0
- package/src/migrations/update-16-0-0/update-nx-cloud-runner.js +27 -0
- package/src/migrations/update-16-2-0/remove-run-commands-output-path.d.ts +2 -0
- package/src/migrations/update-16-2-0/remove-run-commands-output-path.js +45 -0
- package/src/migrations/update-16-8-0/escape-dollar-sign-env-variables.d.ts +12 -0
- package/src/migrations/update-16-8-0/escape-dollar-sign-env-variables.js +60 -0
- package/src/migrations/update-16-9-0/remove-project-name-and-root-format.d.ts +2 -0
- package/src/migrations/update-16-9-0/remove-project-name-and-root-format.js +21 -0
- package/src/migrations/update-17-0-0/move-cache-directory.d.ts +2 -0
- package/src/migrations/update-17-0-0/move-cache-directory.js +35 -0
- package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.d.ts +2 -0
- package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +72 -0
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.d.ts +2 -0
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +122 -0
- package/src/migrations/update-17-3-0/nx-release-path.d.ts +3 -0
- package/src/migrations/update-17-3-0/nx-release-path.js +49 -0
- package/src/migrations/update-17-3-0/update-nxw.d.ts +2 -0
- package/src/migrations/update-17-3-0/update-nxw.js +7 -0
- package/src/native/assert-supported-platform.d.ts +1 -0
- package/src/native/assert-supported-platform.js +39 -0
- package/src/native/index.d.ts +192 -0
- package/src/native/index.js +289 -0
- package/src/native/transform-objects.d.ts +3 -0
- package/src/native/transform-objects.js +50 -0
- package/src/nx-cloud/debug-logger.d.ts +1 -0
- package/src/nx-cloud/debug-logger.js +9 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +8 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +107 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +27 -0
- package/src/nx-cloud/nx-cloud-tasks-runner-shell.d.ts +15 -0
- package/src/nx-cloud/nx-cloud-tasks-runner-shell.js +41 -0
- package/src/nx-cloud/resolution-helpers.d.ts +1 -0
- package/src/nx-cloud/resolution-helpers.js +20 -0
- package/src/nx-cloud/update-manager.d.ts +17 -0
- package/src/nx-cloud/update-manager.js +240 -0
- package/src/nx-cloud/utilities/axios.d.ts +2 -0
- package/src/nx-cloud/utilities/axios.js +24 -0
- package/src/nx-cloud/utilities/environment.d.ts +3 -0
- package/src/nx-cloud/utilities/environment.js +47 -0
- package/src/nx-cloud/utilities/get-cloud-options.d.ts +2 -0
- package/src/nx-cloud/utilities/get-cloud-options.js +11 -0
- package/src/plugins/js/hasher/hasher.d.ts +5 -0
- package/src/plugins/js/hasher/hasher.js +52 -0
- package/src/plugins/js/index.d.ts +4 -0
- package/src/plugins/js/index.js +96 -0
- package/src/plugins/js/lock-file/lock-file.d.ts +34 -0
- package/src/plugins/js/lock-file/lock-file.js +169 -0
- package/src/plugins/js/lock-file/npm-parser.d.ts +7 -0
- package/src/plugins/js/lock-file/npm-parser.js +463 -0
- package/src/plugins/js/lock-file/pnpm-parser.d.ts +7 -0
- package/src/plugins/js/lock-file/pnpm-parser.js +294 -0
- package/src/plugins/js/lock-file/project-graph-pruning.d.ts +7 -0
- package/src/plugins/js/lock-file/project-graph-pruning.js +155 -0
- package/src/plugins/js/lock-file/utils/package-json.d.ts +10 -0
- package/src/plugins/js/lock-file/utils/package-json.js +34 -0
- package/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +38 -0
- package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +575 -0
- package/src/plugins/js/lock-file/yarn-parser.d.ts +7 -0
- package/src/plugins/js/lock-file/yarn-parser.js +437 -0
- package/src/plugins/js/package-json/create-package-json.d.ts +27 -0
- package/src/plugins/js/package-json/create-package-json.js +207 -0
- package/src/plugins/js/project-graph/affected/lock-file-changes.d.ts +4 -0
- package/src/plugins/js/project-graph/affected/lock-file-changes.js +16 -0
- package/src/plugins/js/project-graph/affected/npm-packages.d.ts +4 -0
- package/src/plugins/js/project-graph/affected/npm-packages.js +56 -0
- package/src/plugins/js/project-graph/affected/touched-projects.d.ts +2 -0
- package/src/plugins/js/project-graph/affected/touched-projects.js +18 -0
- package/src/plugins/js/project-graph/affected/tsconfig-json-changes.d.ts +4 -0
- package/src/plugins/js/project-graph/affected/tsconfig-json-changes.js +63 -0
- package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +6 -0
- package/src/plugins/js/project-graph/build-dependencies/build-dependencies.js +33 -0
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +3 -0
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.js +82 -0
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +3 -0
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +94 -0
- package/src/plugins/js/project-graph/build-dependencies/strip-source-code.d.ts +7 -0
- package/src/plugins/js/project-graph/build-dependencies/strip-source-code.js +156 -0
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +32 -0
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +183 -0
- package/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.d.ts +16 -0
- package/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.js +120 -0
- package/src/plugins/js/project-graph/build-nodes/build-npm-package-nodes.d.ts +2 -0
- package/src/plugins/js/project-graph/build-nodes/build-npm-package-nodes.js +32 -0
- package/src/plugins/js/utils/config.d.ts +2 -0
- package/src/plugins/js/utils/config.js +65 -0
- package/src/plugins/js/utils/register.d.ts +151 -0
- package/src/plugins/js/utils/register.js +215 -0
- package/src/plugins/js/utils/typescript.d.ts +14 -0
- package/src/plugins/js/utils/typescript.js +98 -0
- package/src/plugins/js/versions.d.ts +1 -0
- package/src/plugins/js/versions.js +4 -0
- package/src/plugins/package-json-workspaces/create-nodes.d.ts +19 -0
- package/src/plugins/package-json-workspaces/create-nodes.js +130 -0
- package/src/plugins/package-json-workspaces/index.d.ts +1 -0
- package/src/plugins/package-json-workspaces/index.js +4 -0
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +2 -0
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +47 -0
- package/src/plugins/project-json/build-nodes/project-json.d.ts +4 -0
- package/src/plugins/project-json/build-nodes/project-json.js +29 -0
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +8 -0
- package/src/plugins/target-defaults/target-defaults-plugin.js +103 -0
- package/src/project-graph/affected/affected-project-graph-models.d.ts +11 -0
- package/src/project-graph/affected/affected-project-graph-models.js +2 -0
- package/src/project-graph/affected/affected-project-graph.d.ts +4 -0
- package/src/project-graph/affected/affected-project-graph.js +83 -0
- package/src/project-graph/affected/locators/project-glob-changes.d.ts +2 -0
- package/src/project-graph/affected/locators/project-glob-changes.js +31 -0
- package/src/project-graph/affected/locators/workspace-json-changes.d.ts +4 -0
- package/src/project-graph/affected/locators/workspace-json-changes.js +47 -0
- package/src/project-graph/affected/locators/workspace-projects.d.ts +5 -0
- package/src/project-graph/affected/locators/workspace-projects.js +85 -0
- package/src/project-graph/build-project-graph.d.ts +14 -0
- package/src/project-graph/build-project-graph.js +219 -0
- package/src/project-graph/file-map-utils.d.ts +15 -0
- package/src/project-graph/file-map-utils.js +63 -0
- package/src/project-graph/file-utils.d.ts +31 -0
- package/src/project-graph/file-utils.js +181 -0
- package/src/project-graph/nx-deps-cache.d.ts +48 -0
- package/src/project-graph/nx-deps-cache.js +228 -0
- package/src/project-graph/operators.d.ts +12 -0
- package/src/project-graph/operators.js +114 -0
- package/src/project-graph/project-graph-builder.d.ts +133 -0
- package/src/project-graph/project-graph-builder.js +379 -0
- package/src/project-graph/project-graph.d.ts +48 -0
- package/src/project-graph/project-graph.js +188 -0
- package/src/project-graph/utils/build-all-workspace-files.d.ts +2 -0
- package/src/project-graph/utils/build-all-workspace-files.js +15 -0
- package/src/project-graph/utils/find-project-for-path.d.ts +20 -0
- package/src/project-graph/utils/find-project-for-path.js +57 -0
- package/src/project-graph/utils/implicit-project-dependencies.d.ts +3 -0
- package/src/project-graph/utils/implicit-project-dependencies.js +19 -0
- package/src/project-graph/utils/normalize-project-nodes.d.ts +10 -0
- package/src/project-graph/utils/normalize-project-nodes.js +92 -0
- package/src/project-graph/utils/project-configuration-utils.d.ts +53 -0
- package/src/project-graph/utils/project-configuration-utils.js +456 -0
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +37 -0
- package/src/project-graph/utils/retrieve-workspace-files.js +109 -0
- package/src/tasks-runner/batch/batch-messages.d.ts +33 -0
- package/src/tasks-runner/batch/batch-messages.js +9 -0
- package/src/tasks-runner/batch/run-batch.d.ts +1 -0
- package/src/tasks-runner/batch/run-batch.js +77 -0
- package/src/tasks-runner/cache.d.ts +36 -0
- package/src/tasks-runner/cache.js +236 -0
- package/src/tasks-runner/create-task-graph.d.ts +25 -0
- package/src/tasks-runner/create-task-graph.js +225 -0
- package/src/tasks-runner/default-tasks-runner.d.ts +20 -0
- package/src/tasks-runner/default-tasks-runner.js +29 -0
- package/src/tasks-runner/fork.d.ts +1 -0
- package/src/tasks-runner/fork.js +23 -0
- package/src/tasks-runner/forked-process-task-runner.d.ts +44 -0
- package/src/tasks-runner/forked-process-task-runner.js +396 -0
- package/src/tasks-runner/init-tasks-runner.d.ts +11 -0
- package/src/tasks-runner/init-tasks-runner.js +57 -0
- package/src/tasks-runner/life-cycle.d.ts +43 -0
- package/src/tasks-runner/life-cycle.js +71 -0
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.d.ts +25 -0
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +345 -0
- package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.d.ts +24 -0
- package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +224 -0
- package/src/tasks-runner/life-cycles/empty-terminal-output-life-cycle.d.ts +5 -0
- package/src/tasks-runner/life-cycles/empty-terminal-output-life-cycle.js +16 -0
- package/src/tasks-runner/life-cycles/formatting-utils.d.ts +3 -0
- package/src/tasks-runner/life-cycles/formatting-utils.js +44 -0
- package/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.d.ts +17 -0
- package/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +67 -0
- package/src/tasks-runner/life-cycles/pretty-time.d.ts +4 -0
- package/src/tasks-runner/life-cycles/pretty-time.js +74 -0
- package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +33 -0
- package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +99 -0
- package/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +31 -0
- package/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +89 -0
- package/src/tasks-runner/life-cycles/store-run-information-life-cycle.d.ts +22 -0
- package/src/tasks-runner/life-cycles/store-run-information-life-cycle.js +87 -0
- package/src/tasks-runner/life-cycles/task-profiling-life-cycle.d.ts +19 -0
- package/src/tasks-runner/life-cycles/task-profiling-life-cycle.js +73 -0
- package/src/tasks-runner/life-cycles/task-timings-life-cycle.d.ts +13 -0
- package/src/tasks-runner/life-cycles/task-timings-life-cycle.js +39 -0
- package/src/tasks-runner/life-cycles/view-logs-utils.d.ts +1 -0
- package/src/tasks-runner/life-cycles/view-logs-utils.js +16 -0
- package/src/tasks-runner/psuedo-ipc.d.ts +49 -0
- package/src/tasks-runner/psuedo-ipc.js +140 -0
- package/src/tasks-runner/remove-old-cache-records.d.ts +1 -0
- package/src/tasks-runner/remove-old-cache-records.js +61 -0
- package/src/tasks-runner/run-command.d.ts +28 -0
- package/src/tasks-runner/run-command.js +353 -0
- package/src/tasks-runner/task-env.d.ts +8 -0
- package/src/tasks-runner/task-env.js +144 -0
- package/src/tasks-runner/task-graph-utils.d.ts +7 -0
- package/src/tasks-runner/task-graph-utils.js +55 -0
- package/src/tasks-runner/task-orchestrator.d.ts +50 -0
- package/src/tasks-runner/task-orchestrator.js +375 -0
- package/src/tasks-runner/tasks-runner.d.ts +23 -0
- package/src/tasks-runner/tasks-runner.js +2 -0
- package/src/tasks-runner/tasks-schedule.d.ts +36 -0
- package/src/tasks-runner/tasks-schedule.js +142 -0
- package/src/tasks-runner/utils.d.ts +51 -0
- package/src/tasks-runner/utils.js +293 -0
- package/src/utils/ab-testing.d.ts +51 -0
- package/src/utils/ab-testing.js +91 -0
- package/src/utils/all-file-data.d.ts +2 -0
- package/src/utils/all-file-data.js +15 -0
- package/src/utils/app-root.d.ts +8 -0
- package/src/utils/app-root.js +12 -0
- package/src/utils/assert-workspace-validity.d.ts +3 -0
- package/src/utils/assert-workspace-validity.js +84 -0
- package/src/utils/async-iterator.d.ts +2 -0
- package/src/utils/async-iterator.js +17 -0
- package/src/utils/cache-directory.d.ts +6 -0
- package/src/utils/cache-directory.js +60 -0
- package/src/utils/child-process.d.ts +19 -0
- package/src/utils/child-process.js +117 -0
- package/src/utils/chunkify.d.ts +1 -0
- package/src/utils/chunkify.js +38 -0
- package/src/utils/code-frames.d.ts +14 -0
- package/src/utils/code-frames.js +119 -0
- package/src/utils/collapse-expanded-outputs.d.ts +1 -0
- package/src/utils/collapse-expanded-outputs.js +41 -0
- package/src/utils/command-line-utils.d.ts +48 -0
- package/src/utils/command-line-utils.js +254 -0
- package/src/utils/consume-messages-from-socket.d.ts +1 -0
- package/src/utils/consume-messages-from-socket.js +22 -0
- package/src/utils/default-base.d.ts +1 -0
- package/src/utils/default-base.js +15 -0
- package/src/utils/exit-codes.d.ts +6 -0
- package/src/utils/exit-codes.js +20 -0
- package/src/utils/fileutils.d.ts +69 -0
- package/src/utils/fileutils.js +135 -0
- package/src/utils/find-matching-projects.d.ts +10 -0
- package/src/utils/find-matching-projects.js +198 -0
- package/src/utils/find-workspace-root.d.ts +11 -0
- package/src/utils/find-workspace-root.js +34 -0
- package/src/utils/globs.d.ts +1 -0
- package/src/utils/globs.js +8 -0
- package/src/utils/ignore.d.ts +8 -0
- package/src/utils/ignore.js +68 -0
- package/src/utils/installation-directory.d.ts +2 -0
- package/src/utils/installation-directory.js +13 -0
- package/src/utils/is-ci.d.ts +1 -0
- package/src/utils/is-ci.js +20 -0
- package/src/utils/json-diff.d.ts +18 -0
- package/src/utils/json-diff.js +112 -0
- package/src/utils/json.d.ts +44 -0
- package/src/utils/json.js +60 -0
- package/src/utils/logger.d.ts +11 -0
- package/src/utils/logger.js +47 -0
- package/src/utils/nx-cloud-utils.d.ts +4 -0
- package/src/utils/nx-cloud-utils.js +27 -0
- package/src/utils/nx-plugin.d.ts +119 -0
- package/src/utils/nx-plugin.deprecated.d.ts +31 -0
- package/src/utils/nx-plugin.deprecated.js +25 -0
- package/src/utils/nx-plugin.js +293 -0
- package/src/utils/object-sort.d.ts +1 -0
- package/src/utils/object-sort.js +10 -0
- package/src/utils/output.d.ts +72 -0
- package/src/utils/output.js +239 -0
- package/src/utils/package-json.d.ts +98 -0
- package/src/utils/package-json.js +134 -0
- package/src/utils/package-manager.d.ts +93 -0
- package/src/utils/package-manager.js +300 -0
- package/src/utils/params.d.ts +138 -0
- package/src/utils/params.js +684 -0
- package/src/utils/path.d.ts +19 -0
- package/src/utils/path.js +38 -0
- package/src/utils/perf-logging.d.ts +1 -0
- package/src/utils/perf-logging.js +11 -0
- package/src/utils/plugins/community-plugins.d.ts +2 -0
- package/src/utils/plugins/community-plugins.js +29 -0
- package/src/utils/plugins/core-plugins.d.ts +3 -0
- package/src/utils/plugins/core-plugins.js +114 -0
- package/src/utils/plugins/index.d.ts +4 -0
- package/src/utils/plugins/index.js +14 -0
- package/src/utils/plugins/installed-plugins.d.ts +6 -0
- package/src/utils/plugins/installed-plugins.js +104 -0
- package/src/utils/plugins/local-plugins.d.ts +5 -0
- package/src/utils/plugins/local-plugins.js +58 -0
- package/src/utils/plugins/models.d.ts +22 -0
- package/src/utils/plugins/models.js +2 -0
- package/src/utils/plugins/plugin-capabilities.d.ts +4 -0
- package/src/utils/plugins/plugin-capabilities.js +124 -0
- package/src/utils/plugins/shared.d.ts +1 -0
- package/src/utils/plugins/shared.js +8 -0
- package/src/utils/print-help.d.ts +11 -0
- package/src/utils/print-help.js +265 -0
- package/src/utils/project-graph-utils.d.ts +13 -0
- package/src/utils/project-graph-utils.js +74 -0
- package/src/utils/promised-based-queue.d.ts +6 -0
- package/src/utils/promised-based-queue.js +43 -0
- package/src/utils/serialize-overrides-into-command-line.d.ts +3 -0
- package/src/utils/serialize-overrides-into-command-line.js +43 -0
- package/src/utils/split-target.d.ts +3 -0
- package/src/utils/split-target.js +49 -0
- package/src/utils/strip-indents.d.ts +14 -0
- package/src/utils/strip-indents.js +24 -0
- package/src/utils/typescript.d.ts +1 -0
- package/src/utils/typescript.js +5 -0
- package/src/utils/update-nxw.d.ts +2 -0
- package/src/utils/update-nxw.js +12 -0
- package/src/utils/versions.d.ts +1 -0
- package/src/utils/versions.js +4 -0
- package/src/utils/workspace-configuration-check.d.ts +1 -0
- package/src/utils/workspace-configuration-check.js +37 -0
- package/src/utils/workspace-context.d.ts +10 -0
- package/src/utils/workspace-context.js +56 -0
- package/src/utils/workspace-root.d.ts +6 -0
- package/src/utils/workspace-root.js +39 -0
- package/tasks-runners/default.d.ts +1 -0
- package/tasks-runners/default.js +5 -0
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringifyYarnLockfile = exports.getYarnLockfileDependencies = exports.getYarnLockfileNodes = void 0;
|
|
4
|
+
const package_json_1 = require("./utils/package-json");
|
|
5
|
+
const project_graph_builder_1 = require("../../../project-graph/project-graph-builder");
|
|
6
|
+
const semver_1 = require("semver");
|
|
7
|
+
const project_graph_1 = require("../../../config/project-graph");
|
|
8
|
+
const file_hasher_1 = require("../../../hasher/file-hasher");
|
|
9
|
+
const object_sort_1 = require("../../../utils/object-sort");
|
|
10
|
+
let currentLockFileHash;
|
|
11
|
+
let cachedParsedLockFile;
|
|
12
|
+
// we use key => node map to avoid duplicate work when parsing keys
|
|
13
|
+
let keyMap = new Map();
|
|
14
|
+
function parseLockFile(lockFileContent, lockFileHash) {
|
|
15
|
+
if (currentLockFileHash === lockFileHash) {
|
|
16
|
+
return cachedParsedLockFile;
|
|
17
|
+
}
|
|
18
|
+
const { parseSyml } = require('@yarnpkg/parsers');
|
|
19
|
+
keyMap.clear();
|
|
20
|
+
const result = parseSyml(lockFileContent);
|
|
21
|
+
cachedParsedLockFile = result;
|
|
22
|
+
currentLockFileHash = lockFileHash;
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
function getYarnLockfileNodes(lockFileContent, lockFileHash, packageJson) {
|
|
26
|
+
const { __metadata, ...dependencies } = parseLockFile(lockFileContent, lockFileHash);
|
|
27
|
+
const isBerry = !!__metadata;
|
|
28
|
+
// yarn classic splits keys when parsing so we need to stich them back together
|
|
29
|
+
const groupedDependencies = groupDependencies(dependencies, isBerry);
|
|
30
|
+
return getNodes(groupedDependencies, packageJson, keyMap, isBerry);
|
|
31
|
+
}
|
|
32
|
+
exports.getYarnLockfileNodes = getYarnLockfileNodes;
|
|
33
|
+
function getYarnLockfileDependencies(lockFileContent, lockFileHash, ctx) {
|
|
34
|
+
const { __metadata, ...dependencies } = parseLockFile(lockFileContent, lockFileHash);
|
|
35
|
+
const isBerry = !!__metadata;
|
|
36
|
+
// yarn classic splits keys when parsing so we need to stich them back together
|
|
37
|
+
const groupedDependencies = groupDependencies(dependencies, isBerry);
|
|
38
|
+
return getDependencies(groupedDependencies, keyMap, ctx);
|
|
39
|
+
}
|
|
40
|
+
exports.getYarnLockfileDependencies = getYarnLockfileDependencies;
|
|
41
|
+
function getPackageNameKeyPairs(keys) {
|
|
42
|
+
const result = new Map();
|
|
43
|
+
keys.split(', ').forEach((key) => {
|
|
44
|
+
const packageName = key.slice(0, key.indexOf('@', 1));
|
|
45
|
+
if (result.has(packageName)) {
|
|
46
|
+
result.get(packageName).add(key);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
result.set(packageName, new Set([key]));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
function getNodes(dependencies, packageJson, keyMap, isBerry) {
|
|
55
|
+
const nodes = new Map();
|
|
56
|
+
const combinedDeps = {
|
|
57
|
+
...packageJson.dependencies,
|
|
58
|
+
...packageJson.devDependencies,
|
|
59
|
+
...packageJson.peerDependencies,
|
|
60
|
+
...packageJson.optionalDependencies,
|
|
61
|
+
};
|
|
62
|
+
Object.entries(dependencies).forEach(([keys, snapshot]) => {
|
|
63
|
+
// ignore workspace projects & patches
|
|
64
|
+
if (snapshot.linkType === 'soft' || keys.includes('@patch:')) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const nameKeyPairs = getPackageNameKeyPairs(keys);
|
|
68
|
+
nameKeyPairs.forEach((keySet, packageName) => {
|
|
69
|
+
const keysArray = Array.from(keySet);
|
|
70
|
+
// use key relevant to the package name
|
|
71
|
+
const version = findVersion(packageName, keysArray[0], snapshot, isBerry);
|
|
72
|
+
// use keys linked to the extracted package name
|
|
73
|
+
keysArray.forEach((key) => {
|
|
74
|
+
// we don't need to keep duplicates, we can just track the keys
|
|
75
|
+
const existingNode = nodes.get(packageName)?.get(version);
|
|
76
|
+
if (existingNode) {
|
|
77
|
+
keyMap.set(key, existingNode);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const node = {
|
|
81
|
+
type: 'npm',
|
|
82
|
+
name: version
|
|
83
|
+
? `npm:${packageName}@${version}`
|
|
84
|
+
: `npm:${packageName}`,
|
|
85
|
+
data: {
|
|
86
|
+
version,
|
|
87
|
+
packageName,
|
|
88
|
+
hash: snapshot.integrity ||
|
|
89
|
+
snapshot.checksum ||
|
|
90
|
+
(0, file_hasher_1.hashArray)([packageName, version]),
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
keyMap.set(key, node);
|
|
94
|
+
// use actual version so we can detect it later based on npm package's version
|
|
95
|
+
const mapKey = snapshot.version && version !== snapshot.version
|
|
96
|
+
? snapshot.version
|
|
97
|
+
: version;
|
|
98
|
+
if (!nodes.has(packageName)) {
|
|
99
|
+
nodes.set(packageName, new Map([[mapKey, node]]));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
nodes.get(packageName).set(mapKey, node);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
const externalNodes = {};
|
|
108
|
+
for (const [packageName, versionMap] of nodes.entries()) {
|
|
109
|
+
const hoistedNode = findHoistedNode(packageName, versionMap, combinedDeps);
|
|
110
|
+
if (hoistedNode) {
|
|
111
|
+
hoistedNode.name = `npm:${packageName}`;
|
|
112
|
+
}
|
|
113
|
+
versionMap.forEach((node) => {
|
|
114
|
+
externalNodes[node.name] = node;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return externalNodes;
|
|
118
|
+
}
|
|
119
|
+
function findHoistedNode(packageName, versionMap, combinedDeps) {
|
|
120
|
+
const hoistedVersion = getHoistedVersion(packageName);
|
|
121
|
+
if (hoistedVersion) {
|
|
122
|
+
return versionMap.get(hoistedVersion);
|
|
123
|
+
}
|
|
124
|
+
const rootVersionSpecifier = combinedDeps[packageName];
|
|
125
|
+
if (!rootVersionSpecifier) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const versions = Array.from(versionMap.keys()).sort((a, b) => (0, semver_1.gt)(a, b) ? -1 : 1);
|
|
129
|
+
// take the highest version found
|
|
130
|
+
if (rootVersionSpecifier === '*') {
|
|
131
|
+
return versionMap.get(versions[0]);
|
|
132
|
+
}
|
|
133
|
+
// take version that satisfies the root version specifier
|
|
134
|
+
let version = versions.find((v) => (0, semver_1.satisfies)(v, rootVersionSpecifier));
|
|
135
|
+
if (!version) {
|
|
136
|
+
// try to find alias version
|
|
137
|
+
version = versions.find((v) => versionMap.get(v).name === `npm:${packageName}@${rootVersionSpecifier}`);
|
|
138
|
+
}
|
|
139
|
+
if (!version) {
|
|
140
|
+
// try to find tarball package
|
|
141
|
+
version = versions.find((v) => versionMap.get(v).data.version !== v);
|
|
142
|
+
}
|
|
143
|
+
if (version) {
|
|
144
|
+
return versionMap.get(version);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function findVersion(packageName, key, snapshot, isBerry) {
|
|
148
|
+
const versionRange = key.slice(key.indexOf('@', 1) + 1);
|
|
149
|
+
// check for alias packages
|
|
150
|
+
const isAlias = isBerry
|
|
151
|
+
? snapshot.resolution && !snapshot.resolution.startsWith(`${packageName}@`)
|
|
152
|
+
: versionRange.startsWith('npm:');
|
|
153
|
+
if (isAlias) {
|
|
154
|
+
return versionRange;
|
|
155
|
+
}
|
|
156
|
+
// check for berry tarball packages
|
|
157
|
+
if (isBerry &&
|
|
158
|
+
snapshot.resolution &&
|
|
159
|
+
// different registry would yield suffix following '::' which we don't need
|
|
160
|
+
snapshot.resolution.split('::')[0] !==
|
|
161
|
+
`${packageName}@npm:${snapshot.version}`) {
|
|
162
|
+
return snapshot.resolution.slice(packageName.length + 1);
|
|
163
|
+
}
|
|
164
|
+
if (!isBerry && isTarballPackage(versionRange, snapshot)) {
|
|
165
|
+
return snapshot.resolved;
|
|
166
|
+
}
|
|
167
|
+
// otherwise it's a standard version
|
|
168
|
+
return snapshot.version;
|
|
169
|
+
}
|
|
170
|
+
// check if snapshot represents tarball package
|
|
171
|
+
function isTarballPackage(versionRange, snapshot) {
|
|
172
|
+
// if resolved is missing it's internal link
|
|
173
|
+
if (!snapshot.resolved) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
// tarballs have no integrity
|
|
177
|
+
if (snapshot.integrity) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
new semver_1.Range(versionRange);
|
|
182
|
+
// range is a valid semver
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// range is not a valid semver, it can be an npm tag or url part of a tarball
|
|
187
|
+
return snapshot.version && !snapshot.resolved.includes(snapshot.version);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function getHoistedVersion(packageName) {
|
|
191
|
+
const version = (0, package_json_1.getHoistedPackageVersion)(packageName);
|
|
192
|
+
if (version) {
|
|
193
|
+
return version;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function getDependencies(dependencies, keyMap, ctx) {
|
|
197
|
+
const projectGraphDependencies = [];
|
|
198
|
+
Object.keys(dependencies).forEach((keys) => {
|
|
199
|
+
const snapshot = dependencies[keys];
|
|
200
|
+
keys.split(', ').forEach((key) => {
|
|
201
|
+
if (keyMap.has(key)) {
|
|
202
|
+
const node = keyMap.get(key);
|
|
203
|
+
[snapshot.dependencies, snapshot.optionalDependencies].forEach((section) => {
|
|
204
|
+
if (section) {
|
|
205
|
+
Object.entries(section).forEach(([name, versionRange]) => {
|
|
206
|
+
const target = keyMap.get(`${name}@npm:${versionRange}`) ||
|
|
207
|
+
keyMap.get(`${name}@${versionRange}`);
|
|
208
|
+
if (target) {
|
|
209
|
+
const dep = {
|
|
210
|
+
source: node.name,
|
|
211
|
+
target: target.name,
|
|
212
|
+
type: project_graph_1.DependencyType.static,
|
|
213
|
+
};
|
|
214
|
+
(0, project_graph_builder_1.validateDependency)(dep, ctx);
|
|
215
|
+
projectGraphDependencies.push(dep);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
return projectGraphDependencies;
|
|
224
|
+
}
|
|
225
|
+
function stringifyYarnLockfile(graph, rootLockFileContent, packageJson) {
|
|
226
|
+
const { parseSyml, stringifySyml } = require('@yarnpkg/parsers');
|
|
227
|
+
const { __metadata, ...dependencies } = parseSyml(rootLockFileContent);
|
|
228
|
+
const isBerry = !!__metadata;
|
|
229
|
+
const snapshots = mapSnapshots(dependencies, graph.externalNodes, packageJson, isBerry);
|
|
230
|
+
if (isBerry) {
|
|
231
|
+
// add root workspace package
|
|
232
|
+
const workspacePackage = generateRootWorkspacePackage(packageJson);
|
|
233
|
+
snapshots[workspacePackage.resolution] = workspacePackage;
|
|
234
|
+
return (BERRY_LOCK_FILE_DISCLAIMER +
|
|
235
|
+
stringifySyml({
|
|
236
|
+
__metadata,
|
|
237
|
+
...(0, object_sort_1.sortObjectByKeys)(snapshots),
|
|
238
|
+
}));
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
const { stringify } = require('@yarnpkg/lockfile');
|
|
242
|
+
return stringify((0, object_sort_1.sortObjectByKeys)(snapshots));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
exports.stringifyYarnLockfile = stringifyYarnLockfile;
|
|
246
|
+
function groupDependencies(dependencies, isBerry) {
|
|
247
|
+
if (isBerry) {
|
|
248
|
+
return dependencies;
|
|
249
|
+
}
|
|
250
|
+
let groupedDependencies;
|
|
251
|
+
const resolutionMap = new Map();
|
|
252
|
+
const snapshotMap = new Map();
|
|
253
|
+
Object.entries(dependencies).forEach(([key, snapshot]) => {
|
|
254
|
+
const resolutionKey = `${snapshot.resolved}${snapshot.integrity}`;
|
|
255
|
+
if (resolutionMap.has(resolutionKey)) {
|
|
256
|
+
const existingSnapshot = resolutionMap.get(resolutionKey);
|
|
257
|
+
snapshotMap.get(existingSnapshot).add(key);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
resolutionMap.set(resolutionKey, snapshot);
|
|
261
|
+
snapshotMap.set(snapshot, new Set([key]));
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
groupedDependencies = {};
|
|
265
|
+
snapshotMap.forEach((keys, snapshot) => {
|
|
266
|
+
groupedDependencies[Array.from(keys).join(', ')] = snapshot;
|
|
267
|
+
});
|
|
268
|
+
return groupedDependencies;
|
|
269
|
+
}
|
|
270
|
+
function addPackageVersion(packageName, version, collection, isBerry) {
|
|
271
|
+
if (!collection.has(packageName)) {
|
|
272
|
+
collection.set(packageName, new Set());
|
|
273
|
+
}
|
|
274
|
+
collection.get(packageName).add(`${packageName}@${version}`);
|
|
275
|
+
if (isBerry && !version.startsWith('npm:')) {
|
|
276
|
+
collection.get(packageName).add(`${packageName}@npm:${version}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function mapSnapshots(dependencies, nodes, packageJson, isBerry) {
|
|
280
|
+
// map snapshot to set of keys (e.g. `eslint@^7.0.0, eslint@npm:^7.0.0`)
|
|
281
|
+
const snapshotMap = new Map();
|
|
282
|
+
// track all existing dependencies's keys
|
|
283
|
+
const existingKeys = new Map();
|
|
284
|
+
const combinedDependencies = {
|
|
285
|
+
...packageJson.dependencies,
|
|
286
|
+
...packageJson.devDependencies,
|
|
287
|
+
...packageJson.optionalDependencies,
|
|
288
|
+
...packageJson.peerDependencies,
|
|
289
|
+
};
|
|
290
|
+
// yarn classic splits keys when parsing so we need to stich them back together
|
|
291
|
+
const groupedDependencies = groupDependencies(dependencies, isBerry);
|
|
292
|
+
// collect snapshots and their matching keys
|
|
293
|
+
Object.values(nodes).forEach((node) => {
|
|
294
|
+
const foundOriginalKeys = findOriginalKeys(groupedDependencies, node);
|
|
295
|
+
if (!foundOriginalKeys) {
|
|
296
|
+
throw new Error(`Original key(s) not found for "${node.data.packageName}@${node.data.version}" while pruning yarn.lock.`);
|
|
297
|
+
}
|
|
298
|
+
const [matchedKeys, snapshot] = foundOriginalKeys;
|
|
299
|
+
snapshotMap.set(snapshot, new Set(matchedKeys));
|
|
300
|
+
// separately save keys that still exist
|
|
301
|
+
[snapshot.dependencies, snapshot.optionalDependencies].forEach((section) => {
|
|
302
|
+
Object.entries(section || {}).forEach(([name, versionSpec]) => addPackageVersion(name, versionSpec, existingKeys, isBerry));
|
|
303
|
+
});
|
|
304
|
+
// add package.json requested version to keys
|
|
305
|
+
const requestedVersion = getPackageJsonVersion(combinedDependencies, node);
|
|
306
|
+
if (requestedVersion) {
|
|
307
|
+
addPackageVersion(node.data.packageName, requestedVersion, existingKeys, isBerry);
|
|
308
|
+
const requestedKey = isBerry
|
|
309
|
+
? reverseMapBerryKey(node, requestedVersion, snapshot)
|
|
310
|
+
: `${node.data.packageName}@${requestedVersion}`;
|
|
311
|
+
if (!snapshotMap.get(snapshot).has(requestedKey)) {
|
|
312
|
+
snapshotMap.get(snapshot).add(requestedKey);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (isBerry) {
|
|
316
|
+
// look for patched versions
|
|
317
|
+
const patch = findPatchedKeys(groupedDependencies, node);
|
|
318
|
+
if (patch) {
|
|
319
|
+
const [matchedKeys, snapshot] = patch;
|
|
320
|
+
snapshotMap.set(snapshot, new Set(matchedKeys));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
// remove keys that match version ranges that have been pruned away
|
|
325
|
+
snapshotMap.forEach((snapshotValue, snapshotKey) => {
|
|
326
|
+
for (const key of snapshotValue.values()) {
|
|
327
|
+
const packageName = key.slice(0, key.indexOf('@', 1));
|
|
328
|
+
let normalizedKey = key;
|
|
329
|
+
if (isBerry && key.includes('@patch:') && key.includes('#')) {
|
|
330
|
+
normalizedKey = key
|
|
331
|
+
.slice(0, key.indexOf('#'))
|
|
332
|
+
.replace(`@patch:${packageName}@`, '@npm:');
|
|
333
|
+
}
|
|
334
|
+
if (!existingKeys.get(packageName) ||
|
|
335
|
+
!existingKeys.get(packageName).has(normalizedKey)) {
|
|
336
|
+
snapshotValue.delete(key);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
// join mapped snapshots to lock json file
|
|
341
|
+
const result = {};
|
|
342
|
+
snapshotMap.forEach((keysSet, snapshot) => {
|
|
343
|
+
if (isBerry) {
|
|
344
|
+
result[Array.from(keysSet).sort().join(', ')] = snapshot;
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
for (const key of keysSet.values()) {
|
|
348
|
+
result[key] = snapshot;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
return result;
|
|
353
|
+
}
|
|
354
|
+
function reverseMapBerryKey(node, version, snapshot) {
|
|
355
|
+
// alias packages already have version
|
|
356
|
+
if (version.startsWith('npm:')) {
|
|
357
|
+
`${node.data.packageName}@${version}`;
|
|
358
|
+
}
|
|
359
|
+
// check for berry tarball packages
|
|
360
|
+
if (snapshot.resolution &&
|
|
361
|
+
snapshot.resolution === `${node.data.packageName}@${version}`) {
|
|
362
|
+
return snapshot.resolution;
|
|
363
|
+
}
|
|
364
|
+
return `${node.data.packageName}@npm:${version}`;
|
|
365
|
+
}
|
|
366
|
+
function getPackageJsonVersion(combinedDependencies, node) {
|
|
367
|
+
const { packageName, version } = node.data;
|
|
368
|
+
if (combinedDependencies[packageName]) {
|
|
369
|
+
if (combinedDependencies[packageName] === version ||
|
|
370
|
+
(0, semver_1.satisfies)(version, combinedDependencies[packageName])) {
|
|
371
|
+
return combinedDependencies[packageName];
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function findOriginalKeys(dependencies, node) {
|
|
376
|
+
for (const keyExpr of Object.keys(dependencies)) {
|
|
377
|
+
const snapshot = dependencies[keyExpr];
|
|
378
|
+
const keys = keyExpr.split(', ');
|
|
379
|
+
if (!keys.some((k) => k.startsWith(`${node.data.packageName}@`))) {
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
// standard package
|
|
383
|
+
if (snapshot.version === node.data.version) {
|
|
384
|
+
return [keys, snapshot];
|
|
385
|
+
}
|
|
386
|
+
// berry alias package
|
|
387
|
+
if (snapshot.resolution &&
|
|
388
|
+
`npm:${snapshot.resolution}` === node.data.version) {
|
|
389
|
+
return [keys, snapshot];
|
|
390
|
+
}
|
|
391
|
+
// classic alias
|
|
392
|
+
if (node.data.version.startsWith('npm:') &&
|
|
393
|
+
keys.some((k) => k === `${node.data.packageName}@${node.data.version}`)) {
|
|
394
|
+
return [keys, snapshot];
|
|
395
|
+
}
|
|
396
|
+
// tarball package
|
|
397
|
+
if (snapshot.resolved === node.data.version ||
|
|
398
|
+
snapshot.resolution === `${node.data.packageName}@${node.data.version}`) {
|
|
399
|
+
return [keys, snapshot];
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
function findPatchedKeys(dependencies, node) {
|
|
404
|
+
for (const keyExpr of Object.keys(dependencies)) {
|
|
405
|
+
const snapshot = dependencies[keyExpr];
|
|
406
|
+
const keys = keyExpr.split(', ');
|
|
407
|
+
if (!keys[0].startsWith(`${node.data.packageName}@patch:`)) {
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
// local patches are currently not supported
|
|
411
|
+
if (keys[0].includes('.yarn/patches')) {
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
if (snapshot.version === node.data.version) {
|
|
415
|
+
return [keys, snapshot];
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
const BERRY_LOCK_FILE_DISCLAIMER = `# This file is generated by running "yarn install" inside your project.\n# Manual changes might be lost - proceed with caution!\n\n`;
|
|
420
|
+
function generateRootWorkspacePackage(packageJson) {
|
|
421
|
+
return {
|
|
422
|
+
version: '0.0.0-use.local',
|
|
423
|
+
resolution: `${packageJson.name}@workspace:.`,
|
|
424
|
+
...(packageJson.dependencies && { dependencies: packageJson.dependencies }),
|
|
425
|
+
...(packageJson.peerDependencies && {
|
|
426
|
+
peerDependencies: packageJson.peerDependencies,
|
|
427
|
+
}),
|
|
428
|
+
...(packageJson.devDependencies && {
|
|
429
|
+
devDependencies: packageJson.devDependencies,
|
|
430
|
+
}),
|
|
431
|
+
...(packageJson.optionalDependencies && {
|
|
432
|
+
optionalDependencies: packageJson.optionalDependencies,
|
|
433
|
+
}),
|
|
434
|
+
languageName: 'unknown',
|
|
435
|
+
linkType: 'soft',
|
|
436
|
+
};
|
|
437
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ProjectFileMap, ProjectGraph, ProjectGraphProjectNode } from '../../../config/project-graph';
|
|
2
|
+
import { PackageJson } from '../../../utils/package-json';
|
|
3
|
+
interface NpmDeps {
|
|
4
|
+
readonly dependencies: Record<string, string>;
|
|
5
|
+
readonly peerDependencies: Record<string, string>;
|
|
6
|
+
readonly peerDependenciesMeta: Record<string, {
|
|
7
|
+
optional: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates a package.json in the output directory for support to install dependencies within containers.
|
|
12
|
+
*
|
|
13
|
+
* If a package.json exists in the project, it will reuse that.
|
|
14
|
+
* If isProduction flag is set, it wil remove devDependencies and optional peerDependencies
|
|
15
|
+
*/
|
|
16
|
+
export declare function createPackageJson(projectName: string, graph: ProjectGraph, options?: {
|
|
17
|
+
target?: string;
|
|
18
|
+
root?: string;
|
|
19
|
+
isProduction?: boolean;
|
|
20
|
+
helperDependencies?: string[];
|
|
21
|
+
}, fileMap?: ProjectFileMap): PackageJson;
|
|
22
|
+
export declare function findProjectsNpmDependencies(projectNode: ProjectGraphProjectNode, graph: ProjectGraph, target: string, rootPackageJson: PackageJson, options: {
|
|
23
|
+
helperDependencies?: string[];
|
|
24
|
+
ignoredDependencies?: string[];
|
|
25
|
+
isProduction?: boolean;
|
|
26
|
+
}, fileMap?: ProjectFileMap): NpmDeps;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findProjectsNpmDependencies = exports.createPackageJson = void 0;
|
|
4
|
+
const fileutils_1 = require("../../../utils/fileutils");
|
|
5
|
+
const object_sort_1 = require("../../../utils/object-sort");
|
|
6
|
+
const project_graph_1 = require("../../../config/project-graph");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
9
|
+
const configuration_1 = require("../../../config/configuration");
|
|
10
|
+
const nx_deps_cache_1 = require("../../../project-graph/nx-deps-cache");
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
const task_hasher_1 = require("../../../hasher/task-hasher");
|
|
13
|
+
/**
|
|
14
|
+
* Creates a package.json in the output directory for support to install dependencies within containers.
|
|
15
|
+
*
|
|
16
|
+
* If a package.json exists in the project, it will reuse that.
|
|
17
|
+
* If isProduction flag is set, it wil remove devDependencies and optional peerDependencies
|
|
18
|
+
*/
|
|
19
|
+
function createPackageJson(projectName, graph, options = {}, fileMap = null) {
|
|
20
|
+
const projectNode = graph.nodes[projectName];
|
|
21
|
+
const isLibrary = projectNode.type === 'lib';
|
|
22
|
+
const rootPackageJson = (0, fileutils_1.readJsonFile)(`${options.root || workspace_root_1.workspaceRoot}/package.json`);
|
|
23
|
+
const npmDeps = findProjectsNpmDependencies(projectNode, graph, options.target, rootPackageJson, {
|
|
24
|
+
helperDependencies: options.helperDependencies,
|
|
25
|
+
isProduction: options.isProduction,
|
|
26
|
+
}, fileMap);
|
|
27
|
+
// default package.json if one does not exist
|
|
28
|
+
let packageJson = {
|
|
29
|
+
name: projectName,
|
|
30
|
+
version: '0.0.1',
|
|
31
|
+
};
|
|
32
|
+
const projectPackageJsonPath = (0, path_1.join)(options.root || workspace_root_1.workspaceRoot, projectNode.data.root, 'package.json');
|
|
33
|
+
if ((0, fs_1.existsSync)(projectPackageJsonPath)) {
|
|
34
|
+
try {
|
|
35
|
+
packageJson = (0, fileutils_1.readJsonFile)(projectPackageJsonPath);
|
|
36
|
+
// for standalone projects we don't want to include all the root dependencies
|
|
37
|
+
if (graph.nodes[projectName].data.root === '.') {
|
|
38
|
+
// TODO: We should probably think more on this - Nx can't always
|
|
39
|
+
// detect all external dependencies, and there's not a way currently
|
|
40
|
+
// to tell Nx that we need one of these deps. For non-standalone projects
|
|
41
|
+
// we tell people to add it to the package.json of the project, and we
|
|
42
|
+
// merge it. For standalone, this pattern doesn't work because of this piece of code.
|
|
43
|
+
// It breaks expectations, but also, I don't know another way around it currently.
|
|
44
|
+
// If Nx doesn't pick up a dep, say some css lib that is only imported in a .scss file,
|
|
45
|
+
// we need to be able to tell it to keep that dep in the generated package.json.
|
|
46
|
+
delete packageJson.dependencies;
|
|
47
|
+
delete packageJson.devDependencies;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (e) { }
|
|
51
|
+
}
|
|
52
|
+
const getVersion = (packageName, version, section) => {
|
|
53
|
+
return (packageJson[section][packageName] ||
|
|
54
|
+
(isLibrary && rootPackageJson[section]?.[packageName]) ||
|
|
55
|
+
version);
|
|
56
|
+
};
|
|
57
|
+
Object.entries(npmDeps.dependencies).forEach(([packageName, version]) => {
|
|
58
|
+
if (rootPackageJson.devDependencies?.[packageName] &&
|
|
59
|
+
!packageJson.dependencies?.[packageName] &&
|
|
60
|
+
!packageJson.peerDependencies?.[packageName]) {
|
|
61
|
+
// don't store dev dependencies for production
|
|
62
|
+
if (!options.isProduction) {
|
|
63
|
+
packageJson.devDependencies ??= {};
|
|
64
|
+
packageJson.devDependencies[packageName] = getVersion(packageName, version, 'devDependencies');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
if (!packageJson.peerDependencies?.[packageName]) {
|
|
69
|
+
packageJson.dependencies ??= {};
|
|
70
|
+
packageJson.dependencies[packageName] = getVersion(packageName, version, 'dependencies');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (!isLibrary) {
|
|
75
|
+
Object.entries(npmDeps.peerDependencies).forEach(([packageName, version]) => {
|
|
76
|
+
if (!packageJson.peerDependencies?.[packageName]) {
|
|
77
|
+
if (rootPackageJson.dependencies?.[packageName]) {
|
|
78
|
+
packageJson.dependencies ??= {};
|
|
79
|
+
packageJson.dependencies[packageName] = getVersion(packageName, version, 'dependencies');
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const isOptionalPeer = npmDeps.peerDependenciesMeta[packageName]?.optional;
|
|
83
|
+
if (!isOptionalPeer) {
|
|
84
|
+
if (!options.isProduction ||
|
|
85
|
+
rootPackageJson.dependencies?.[packageName]) {
|
|
86
|
+
packageJson.peerDependencies ??= {};
|
|
87
|
+
packageJson.peerDependencies[packageName] = getVersion(packageName, version, 'dependencies');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else if (!options.isProduction) {
|
|
91
|
+
// add peer optional dependencies if not in production
|
|
92
|
+
packageJson.peerDependencies ??= {};
|
|
93
|
+
packageJson.peerDependencies[packageName] = version;
|
|
94
|
+
packageJson.peerDependenciesMeta ??= {};
|
|
95
|
+
packageJson.peerDependenciesMeta[packageName] = {
|
|
96
|
+
optional: true,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
packageJson.devDependencies &&= (0, object_sort_1.sortObjectByKeys)(packageJson.devDependencies);
|
|
103
|
+
packageJson.dependencies &&= (0, object_sort_1.sortObjectByKeys)(packageJson.dependencies);
|
|
104
|
+
packageJson.peerDependencies &&= (0, object_sort_1.sortObjectByKeys)(packageJson.peerDependencies);
|
|
105
|
+
packageJson.peerDependenciesMeta &&= (0, object_sort_1.sortObjectByKeys)(packageJson.peerDependenciesMeta);
|
|
106
|
+
return packageJson;
|
|
107
|
+
}
|
|
108
|
+
exports.createPackageJson = createPackageJson;
|
|
109
|
+
function findProjectsNpmDependencies(projectNode, graph, target, rootPackageJson, options, fileMap) {
|
|
110
|
+
if (fileMap == null) {
|
|
111
|
+
fileMap = (0, nx_deps_cache_1.readFileMapCache)()?.fileMap?.projectFileMap || {};
|
|
112
|
+
}
|
|
113
|
+
const { selfInputs, dependencyInputs } = target
|
|
114
|
+
? (0, task_hasher_1.getTargetInputs)((0, configuration_1.readNxJson)(), projectNode, target)
|
|
115
|
+
: { selfInputs: [], dependencyInputs: [] };
|
|
116
|
+
const npmDeps = {
|
|
117
|
+
dependencies: {},
|
|
118
|
+
peerDependencies: {},
|
|
119
|
+
peerDependenciesMeta: {},
|
|
120
|
+
};
|
|
121
|
+
const seen = new Set();
|
|
122
|
+
options.helperDependencies?.forEach((dep) => {
|
|
123
|
+
seen.add(dep);
|
|
124
|
+
npmDeps.dependencies[graph.externalNodes[dep].data.packageName] =
|
|
125
|
+
graph.externalNodes[dep].data.version;
|
|
126
|
+
recursivelyCollectPeerDependencies(dep, graph, npmDeps, seen);
|
|
127
|
+
});
|
|
128
|
+
// if it's production, we want to ignore all found devDependencies
|
|
129
|
+
const ignoredDependencies = options.isProduction && rootPackageJson.devDependencies
|
|
130
|
+
? [
|
|
131
|
+
...(options.ignoredDependencies || []),
|
|
132
|
+
...Object.keys(rootPackageJson.devDependencies),
|
|
133
|
+
]
|
|
134
|
+
: options.ignoredDependencies || [];
|
|
135
|
+
findAllNpmDeps(fileMap, projectNode, graph, npmDeps, seen, ignoredDependencies, dependencyInputs, selfInputs);
|
|
136
|
+
return npmDeps;
|
|
137
|
+
}
|
|
138
|
+
exports.findProjectsNpmDependencies = findProjectsNpmDependencies;
|
|
139
|
+
function findAllNpmDeps(projectFileMap, projectNode, graph, npmDeps, seen, ignoredDependencies, dependencyPatterns, rootPatterns) {
|
|
140
|
+
if (seen.has(projectNode.name))
|
|
141
|
+
return;
|
|
142
|
+
seen.add(projectNode.name);
|
|
143
|
+
const projectFiles = (0, task_hasher_1.filterUsingGlobPatterns)(projectNode.data.root, projectFileMap[projectNode.name] || [], rootPatterns ?? dependencyPatterns);
|
|
144
|
+
const projectDependencies = new Set();
|
|
145
|
+
projectFiles.forEach((fileData) => fileData.deps?.forEach((dep) => projectDependencies.add((0, project_graph_1.fileDataDepTarget)(dep))));
|
|
146
|
+
for (const dep of projectDependencies) {
|
|
147
|
+
const node = graph.externalNodes[dep];
|
|
148
|
+
if (seen.has(dep)) {
|
|
149
|
+
// if it's in peerDependencies, move it to regular dependencies
|
|
150
|
+
// since this is a direct dependency of the project
|
|
151
|
+
if (node && npmDeps.peerDependencies[node.data.packageName]) {
|
|
152
|
+
npmDeps.dependencies[node.data.packageName] = node.data.version;
|
|
153
|
+
delete npmDeps.peerDependencies[node.data.packageName];
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
if (node) {
|
|
158
|
+
seen.add(dep);
|
|
159
|
+
// do not add ignored dependencies to the list or non-npm dependencies
|
|
160
|
+
if (ignoredDependencies.includes(node.data.packageName) ||
|
|
161
|
+
node.type !== 'npm') {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
npmDeps.dependencies[node.data.packageName] = node.data.version;
|
|
165
|
+
recursivelyCollectPeerDependencies(node.name, graph, npmDeps, seen);
|
|
166
|
+
}
|
|
167
|
+
else if (graph.nodes[dep]) {
|
|
168
|
+
findAllNpmDeps(projectFileMap, graph.nodes[dep], graph, npmDeps, seen, ignoredDependencies, dependencyPatterns);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function recursivelyCollectPeerDependencies(projectName, graph, npmDeps, seen) {
|
|
174
|
+
const npmPackage = graph.externalNodes[projectName];
|
|
175
|
+
if (!npmPackage) {
|
|
176
|
+
return npmDeps;
|
|
177
|
+
}
|
|
178
|
+
const packageName = npmPackage.data.packageName;
|
|
179
|
+
try {
|
|
180
|
+
const packageJson = require(`${packageName}/package.json`);
|
|
181
|
+
if (!packageJson.peerDependencies) {
|
|
182
|
+
return npmDeps;
|
|
183
|
+
}
|
|
184
|
+
Object.keys(packageJson.peerDependencies)
|
|
185
|
+
.map((dependencyName) => `npm:${dependencyName}`)
|
|
186
|
+
.map((dependency) => graph.externalNodes[dependency])
|
|
187
|
+
.filter(Boolean)
|
|
188
|
+
.forEach((node) => {
|
|
189
|
+
if (!seen.has(node.name)) {
|
|
190
|
+
seen.add(node.name);
|
|
191
|
+
npmDeps.peerDependencies[node.data.packageName] = node.data.version;
|
|
192
|
+
if (packageJson.peerDependenciesMeta &&
|
|
193
|
+
packageJson.peerDependenciesMeta[node.data.packageName] &&
|
|
194
|
+
packageJson.peerDependenciesMeta[node.data.packageName].optional) {
|
|
195
|
+
npmDeps.peerDependenciesMeta[node.data.packageName] = {
|
|
196
|
+
optional: true,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
recursivelyCollectPeerDependencies(node.name, graph, npmDeps, seen);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
return npmDeps;
|
|
203
|
+
}
|
|
204
|
+
catch (e) {
|
|
205
|
+
return npmDeps;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TouchedProjectLocator } from '../../../../project-graph/affected/affected-project-graph-models';
|
|
2
|
+
import { WholeFileChange } from '../../../../project-graph/file-utils';
|
|
3
|
+
import { JsonChange } from '../../../../utils/json-diff';
|
|
4
|
+
export declare const getTouchedProjectsFromLockFile: TouchedProjectLocator<WholeFileChange | JsonChange>;
|