nx 21.0.0-beta.1 → 21.0.0-beta.10
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 +5 -1
- package/migrations.json +5 -35
- package/package.json +12 -12
- package/release/index.d.ts +1 -1
- package/release/index.js +2 -1
- package/schemas/nx-schema.json +182 -35
- package/schemas/project-schema.json +5 -0
- package/src/adapter/compat.d.ts +1 -1
- package/src/adapter/compat.js +3 -0
- package/src/command-line/add/add.js +6 -16
- package/src/command-line/affected/command-object.js +6 -6
- package/src/command-line/examples.js +0 -4
- package/src/command-line/exec/command-object.js +1 -1
- package/src/command-line/generate/generator-utils.js +8 -3
- package/src/command-line/import/import.js +1 -1
- package/src/command-line/init/command-object.js +18 -6
- package/src/command-line/init/configure-plugins.d.ts +6 -7
- package/src/command-line/init/configure-plugins.js +52 -38
- 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/check-compatible-with-plugins.js +7 -1
- 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/react/add-vite-commands-to-package-scripts.js +6 -4
- package/src/command-line/init/implementation/react/index.d.ts +1 -1
- package/src/command-line/init/implementation/react/index.js +32 -185
- 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 +110 -45
- package/src/command-line/init/init-v1.js +1 -1
- package/src/command-line/init/init-v2.d.ts +1 -0
- package/src/command-line/init/init-v2.js +70 -39
- package/src/command-line/migrate/migrate-ui-api.d.ts +58 -0
- package/src/command-line/migrate/migrate-ui-api.js +227 -0
- package/src/command-line/migrate/migrate.d.ts +16 -3
- package/src/command-line/migrate/migrate.js +113 -83
- package/src/command-line/nx-commands.js +19 -5
- 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.js +18 -15
- package/src/command-line/release/command-object.d.ts +8 -0
- package/src/command-line/release/command-object.js +9 -0
- package/src/command-line/release/config/config.d.ts +8 -7
- package/src/command-line/release/config/config.js +139 -45
- 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/index.d.ts +4 -0
- 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 +7 -3
- package/src/command-line/release/publish.js +7 -3
- package/src/command-line/release/release.js +8 -3
- package/src/command-line/release/utils/batch-projects-by-generator-config.js +6 -3
- package/src/command-line/release/utils/git.d.ts +3 -2
- package/src/command-line/release/utils/git.js +65 -9
- package/src/command-line/release/utils/github.js +3 -1
- 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 +252 -0
- package/src/command-line/release/version/release-group-processor.js +1057 -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 +93 -0
- package/src/command-line/release/version/test-utils.js +415 -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 +171 -0
- package/src/command-line/release/version/version-actions.js +195 -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 +84 -262
- package/src/command-line/repair/repair.js +0 -1
- package/src/command-line/report/report.d.ts +7 -3
- package/src/command-line/report/report.js +52 -18
- package/src/command-line/run/command-object.js +2 -2
- package/src/command-line/run/executor-utils.d.ts +6 -1
- package/src/command-line/run/executor-utils.js +10 -1
- package/src/command-line/run/run.js +2 -2
- package/src/command-line/run-many/command-object.js +2 -2
- package/src/command-line/yargs-utils/shared-options.d.ts +4 -0
- package/src/command-line/yargs-utils/shared-options.js +20 -0
- package/src/config/misc-interfaces.d.ts +11 -1
- package/src/config/nx-json.d.ts +160 -16
- package/src/config/project-graph.d.ts +4 -2
- package/src/config/project-graph.js +8 -0
- package/src/config/workspace-json-project-json.d.ts +2 -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 +2 -0
- package/src/daemon/client/client.js +15 -0
- 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/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/logger.js +2 -1
- package/src/daemon/server/server.js +7 -0
- package/src/devkit-internals.d.ts +3 -2
- package/src/devkit-internals.js +5 -1
- package/src/executors/run-commands/run-commands.impl.d.ts +2 -5
- package/src/executors/run-commands/run-commands.impl.js +14 -42
- package/src/executors/run-commands/running-tasks.d.ts +9 -4
- package/src/executors/run-commands/running-tasks.js +103 -30
- package/src/executors/run-script/run-script.impl.js +4 -3
- 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/migrations/{update-17-0-0/rm-default-collection-npm-scope.d.ts → update-21-0-0/release-version-config-changes.d.ts} +1 -1
- package/src/migrations/update-21-0-0/release-version-config-changes.js +111 -0
- package/src/native/index.d.ts +98 -19
- package/src/native/index.js +16 -2
- package/src/native/native-bindings.js +7 -0
- package/src/native/nx.wasi-browser.js +20 -19
- package/src/native/nx.wasi.cjs +20 -19
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/nx-cloud-tasks-runner-shell.js +3 -3
- 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 +8 -6
- package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +3 -3
- package/src/plugins/js/lock-file/yarn-parser.js +85 -39
- package/src/plugins/js/project-graph/affected/lock-file-changes.js +1 -0
- 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 +10 -1
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +59 -6
- package/src/plugins/js/utils/packages.js +22 -3
- package/src/plugins/js/utils/register.js +1 -0
- package/src/plugins/js/utils/typescript.js +3 -3
- package/src/plugins/package-json/create-nodes.d.ts +1 -1
- package/src/plugins/package-json/create-nodes.js +4 -2
- package/src/project-graph/affected/locators/project-glob-changes.js +2 -2
- package/src/project-graph/error-types.js +32 -2
- package/src/project-graph/file-utils.d.ts +1 -10
- package/src/project-graph/file-utils.js +2 -77
- package/src/project-graph/plugins/get-plugins.js +2 -1
- package/src/project-graph/plugins/in-process-loader.js +1 -1
- package/src/project-graph/plugins/isolation/plugin-worker.js +12 -6
- package/src/project-graph/plugins/loaded-nx-plugin.d.ts +2 -1
- package/src/project-graph/plugins/public-api.d.ts +1 -1
- package/src/project-graph/plugins/utils.d.ts +2 -2
- package/src/project-graph/plugins/utils.js +2 -2
- package/src/project-graph/project-graph.js +1 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts +3 -3
- package/src/project-graph/utils/project-configuration-utils.js +54 -21
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +1 -1
- package/src/project-graph/utils/retrieve-workspace-files.js +14 -18
- package/src/tasks-runner/batch/batch-messages.d.ts +2 -0
- package/src/tasks-runner/batch/run-batch.js +3 -4
- package/src/tasks-runner/cache.d.ts +20 -6
- package/src/tasks-runner/cache.js +104 -20
- package/src/tasks-runner/create-task-graph.d.ts +0 -1
- package/src/tasks-runner/create-task-graph.js +11 -11
- package/src/tasks-runner/default-tasks-runner.js +5 -14
- package/src/tasks-runner/forked-process-task-runner.d.ts +8 -3
- package/src/tasks-runner/forked-process-task-runner.js +59 -46
- package/src/tasks-runner/init-tasks-runner.d.ts +15 -1
- package/src/tasks-runner/init-tasks-runner.js +62 -2
- package/src/tasks-runner/is-tui-enabled.d.ts +2 -0
- package/src/tasks-runner/is-tui-enabled.js +64 -0
- package/src/tasks-runner/life-cycle.d.ts +14 -3
- package/src/tasks-runner/life-cycle.js +37 -2
- package/src/tasks-runner/life-cycles/task-history-life-cycle-old.d.ts +2 -0
- package/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +15 -7
- package/src/tasks-runner/life-cycles/task-history-life-cycle.d.ts +5 -0
- package/src/tasks-runner/life-cycles/task-history-life-cycle.js +35 -5
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts +18 -0
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +229 -0
- package/src/tasks-runner/pseudo-terminal.d.ts +10 -7
- package/src/tasks-runner/pseudo-terminal.js +37 -35
- package/src/tasks-runner/run-command.d.ts +4 -1
- package/src/tasks-runner/run-command.js +220 -42
- package/src/tasks-runner/running-tasks/node-child-process.js +4 -11
- package/src/tasks-runner/running-tasks/running-task.d.ts +3 -0
- package/src/tasks-runner/running-tasks/shared-running-task.d.ts +14 -0
- package/src/tasks-runner/running-tasks/shared-running-task.js +30 -0
- package/src/tasks-runner/task-env.d.ts +1 -4
- package/src/tasks-runner/task-env.js +2 -0
- package/src/tasks-runner/task-orchestrator.d.ts +26 -10
- package/src/tasks-runner/task-orchestrator.js +212 -57
- package/src/tasks-runner/tasks-runner.d.ts +1 -0
- package/src/tasks-runner/tasks-schedule.d.ts +1 -0
- package/src/tasks-runner/tasks-schedule.js +9 -0
- package/src/tasks-runner/utils.d.ts +2 -2
- package/src/tasks-runner/utils.js +18 -12
- 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 +1 -1
- package/src/utils/find-matching-projects.js +2 -2
- package/src/utils/git-utils.d.ts +1 -1
- package/src/utils/git-utils.js +8 -3
- package/src/utils/handle-errors.js +15 -0
- 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-key.d.ts +7 -0
- package/src/utils/nx-key.js +52 -0
- package/src/utils/package-json.d.ts +1 -1
- package/src/utils/package-json.js +16 -2
- package/src/utils/package-manager.js +2 -2
- package/src/utils/path.js +1 -1
- package/src/utils/require-nx-key.d.ts +1 -0
- package/src/utils/require-nx-key.js +22 -0
- package/src/utils/workspace-context.d.ts +2 -0
- package/src/utils/workspace-context.js +16 -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/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/migrations/update-17-0-0/move-cache-directory.d.ts +0 -2
- package/src/migrations/update-17-0-0/move-cache-directory.js +0 -35
- package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +0 -72
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.d.ts +0 -2
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +0 -122
- package/src/migrations/update-17-2-0/move-default-base.d.ts +0 -5
- package/src/migrations/update-17-2-0/move-default-base.js +0 -21
- package/src/migrations/update-17-3-0/nx-release-path.d.ts +0 -3
- package/src/migrations/update-17-3-0/nx-release-path.js +0 -47
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +0 -2
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +0 -11
- package/src/utils/powerpack.d.ts +0 -5
- package/src/utils/powerpack.js +0 -33
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Cache = exports.DbCache = void 0;
|
4
4
|
exports.dbCacheEnabled = dbCacheEnabled;
|
5
5
|
exports.getCache = getCache;
|
6
|
+
exports.parseMaxCacheSize = parseMaxCacheSize;
|
7
|
+
exports.formatCacheSize = formatCacheSize;
|
6
8
|
const workspace_root_1 = require("../utils/workspace-root");
|
7
9
|
const path_1 = require("path");
|
8
10
|
const perf_hooks_1 = require("perf_hooks");
|
@@ -68,7 +70,10 @@ function getCache(options) {
|
|
68
70
|
class DbCache {
|
69
71
|
constructor(options) {
|
70
72
|
this.options = options;
|
71
|
-
this.
|
73
|
+
this.nxJson = (0, nx_json_1.readNxJson)();
|
74
|
+
this.cache = new native_1.NxCache(workspace_root_1.workspaceRoot, cache_directory_1.cacheDir, (0, db_connection_1.getDbConnection)(), undefined, this.nxJson.maxCacheSize !== undefined
|
75
|
+
? parseMaxCacheSize(this.nxJson.maxCacheSize)
|
76
|
+
: (0, native_1.getDefaultMaxCacheSize)(cache_directory_1.cacheDir));
|
72
77
|
this.isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
73
78
|
}
|
74
79
|
async init() {
|
@@ -83,6 +88,7 @@ class DbCache {
|
|
83
88
|
if (res) {
|
84
89
|
return {
|
85
90
|
...res,
|
91
|
+
terminalOutput: res.terminalOutput ?? '',
|
86
92
|
remote: false,
|
87
93
|
};
|
88
94
|
}
|
@@ -91,9 +97,10 @@ class DbCache {
|
|
91
97
|
// attempt remote cache
|
92
98
|
const res = await this.remoteCache.retrieve(task.hash, this.cache.cacheDirectory);
|
93
99
|
if (res) {
|
94
|
-
this.applyRemoteCacheResults(task.hash, res);
|
100
|
+
this.applyRemoteCacheResults(task.hash, res, task.outputs);
|
95
101
|
return {
|
96
102
|
...res,
|
103
|
+
terminalOutput: res.terminalOutput ?? '',
|
97
104
|
remote: true,
|
98
105
|
};
|
99
106
|
}
|
@@ -105,8 +112,11 @@ class DbCache {
|
|
105
112
|
return null;
|
106
113
|
}
|
107
114
|
}
|
108
|
-
|
109
|
-
return this.cache.
|
115
|
+
getUsedCacheSpace() {
|
116
|
+
return this.cache.getCacheSize();
|
117
|
+
}
|
118
|
+
applyRemoteCacheResults(hash, res, outputs) {
|
119
|
+
return this.cache.applyRemoteCacheResults(hash, res, outputs);
|
110
120
|
}
|
111
121
|
async put(task, terminalOutput, outputs, code) {
|
112
122
|
return tryAndRetry(async () => {
|
@@ -155,26 +165,49 @@ class DbCache {
|
|
155
165
|
}
|
156
166
|
}
|
157
167
|
else {
|
158
|
-
return ((await this.
|
159
|
-
(await this.
|
160
|
-
(await this.
|
161
|
-
(await this.
|
168
|
+
return ((await this.getS3Cache()) ??
|
169
|
+
(await this.getSharedCache()) ??
|
170
|
+
(await this.getGcsCache()) ??
|
171
|
+
(await this.getAzureCache()) ??
|
172
|
+
this.getHttpCache() ??
|
162
173
|
null);
|
163
174
|
}
|
164
175
|
}
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
return this.
|
170
|
-
}
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
return this.
|
176
|
+
async getS3Cache() {
|
177
|
+
const cache = await this.resolveRemoteCache('@nx/s3-cache');
|
178
|
+
if (cache)
|
179
|
+
return cache;
|
180
|
+
return this.resolveRemoteCache('@nx/powerpack-s3-cache');
|
181
|
+
}
|
182
|
+
async getSharedCache() {
|
183
|
+
const cache = await this.resolveRemoteCache('@nx/shared-fs-cache');
|
184
|
+
if (cache)
|
185
|
+
return cache;
|
186
|
+
return this.resolveRemoteCache('@nx/powerpack-shared-fs-cache');
|
187
|
+
}
|
188
|
+
async getGcsCache() {
|
189
|
+
const cache = await this.resolveRemoteCache('@nx/gcs-cache');
|
190
|
+
if (cache)
|
191
|
+
return cache;
|
192
|
+
return this.resolveRemoteCache('@nx/powerpack-gcs-cache');
|
193
|
+
}
|
194
|
+
async getAzureCache() {
|
195
|
+
const cache = await this.resolveRemoteCache('@nx/azure-cache');
|
196
|
+
if (cache)
|
197
|
+
return cache;
|
198
|
+
return this.resolveRemoteCache('@nx/powerpack-azure-cache');
|
199
|
+
}
|
200
|
+
getHttpCache() {
|
201
|
+
if (process.env.NX_SELF_HOSTED_REMOTE_CACHE_SERVER) {
|
202
|
+
if (native_1.IS_WASM) {
|
203
|
+
logger_1.logger.warn('The HTTP remote cache is not yet supported in the wasm build of Nx.');
|
204
|
+
return null;
|
205
|
+
}
|
206
|
+
return new native_1.HttpRemoteCache();
|
207
|
+
}
|
208
|
+
return null;
|
176
209
|
}
|
177
|
-
async
|
210
|
+
async resolveRemoteCache(pkg) {
|
178
211
|
let getRemoteCache = null;
|
179
212
|
try {
|
180
213
|
getRemoteCache = (await Promise.resolve(`${this.resolvePackage(pkg)}`).then(s => require(s))).getRemoteCache;
|
@@ -455,3 +488,54 @@ function tryAndRetry(fn) {
|
|
455
488
|
};
|
456
489
|
return _try();
|
457
490
|
}
|
491
|
+
/**
|
492
|
+
* Converts a string representation of a max cache size to a number.
|
493
|
+
*
|
494
|
+
* e.g. '1GB' -> 1024 * 1024 * 1024
|
495
|
+
* '1MB' -> 1024 * 1024
|
496
|
+
* '1KB' -> 1024
|
497
|
+
*
|
498
|
+
* @param maxCacheSize Max cache size as specified in nx.json
|
499
|
+
*/
|
500
|
+
function parseMaxCacheSize(maxCacheSize) {
|
501
|
+
if (maxCacheSize === null || maxCacheSize === undefined) {
|
502
|
+
return undefined;
|
503
|
+
}
|
504
|
+
let regexResult = maxCacheSize
|
505
|
+
// Covers folks who accidentally specify as a number rather than a string
|
506
|
+
.toString()
|
507
|
+
// Match a number followed by an optional unit (KB, MB, GB), with optional whitespace between the number and unit
|
508
|
+
.match(/^(?<size>[\d|.]+)\s?((?<unit>[KMG]?B)?)$/);
|
509
|
+
if (!regexResult) {
|
510
|
+
throw new Error(`Invalid max cache size specified in nx.json: ${maxCacheSize}. Must be a number followed by an optional unit (KB, MB, GB)`);
|
511
|
+
}
|
512
|
+
let sizeString = regexResult.groups.size;
|
513
|
+
let unit = regexResult.groups.unit;
|
514
|
+
if ([...sizeString].filter((c) => c === '.').length > 1) {
|
515
|
+
throw new Error(`Invalid max cache size specified in nx.json: ${maxCacheSize} (multiple decimal points in size)`);
|
516
|
+
}
|
517
|
+
let size = parseFloat(sizeString);
|
518
|
+
if (isNaN(size)) {
|
519
|
+
throw new Error(`Invalid max cache size specified in nx.json: ${maxCacheSize} (${sizeString} is not a number)`);
|
520
|
+
}
|
521
|
+
switch (unit) {
|
522
|
+
case 'KB':
|
523
|
+
return size * 1024;
|
524
|
+
case 'MB':
|
525
|
+
return size * 1024 * 1024;
|
526
|
+
case 'GB':
|
527
|
+
return size * 1024 * 1024 * 1024;
|
528
|
+
default:
|
529
|
+
return size;
|
530
|
+
}
|
531
|
+
}
|
532
|
+
function formatCacheSize(maxCacheSize, decimals = 2) {
|
533
|
+
const exponents = ['B', 'KB', 'MB', 'GB'];
|
534
|
+
let exponent = 0;
|
535
|
+
let size = maxCacheSize;
|
536
|
+
while (size >= 1024 && exponent < exponents.length - 1) {
|
537
|
+
size /= 1024;
|
538
|
+
exponent++;
|
539
|
+
}
|
540
|
+
return `${size.toFixed(decimals)} ${exponents[exponent]}`;
|
541
|
+
}
|
@@ -24,7 +24,6 @@ export declare class ProcessTasks {
|
|
24
24
|
private createDummyTask;
|
25
25
|
createTask(id: string, project: ProjectGraphProjectNode, target: string, resolvedConfiguration: string | undefined, overrides: Object): Task;
|
26
26
|
resolveConfiguration(project: ProjectGraphProjectNode, target: string, configuration: string | undefined): string;
|
27
|
-
getId(project: string, target: string, configuration: string | undefined): string;
|
28
27
|
}
|
29
28
|
export declare function createTaskGraph(projectGraph: ProjectGraph, extraTargetDependencies: TargetDependencies, projectNames: string[], targets: string[], configuration: string | undefined, overrides: Object, excludeTaskDependencies?: boolean): TaskGraph;
|
30
29
|
export declare function mapTargetDefaultsToDependencies(defaults: TargetDefaults | undefined): TargetDependencies;
|
@@ -33,7 +33,7 @@ class ProcessTasks {
|
|
33
33
|
const project = this.projectGraph.nodes[projectName];
|
34
34
|
if (targets.length === 1 || project.data.targets[target]) {
|
35
35
|
const resolvedConfiguration = this.resolveConfiguration(project, target, configuration);
|
36
|
-
const id =
|
36
|
+
const id = createTaskId(projectName, target, resolvedConfiguration);
|
37
37
|
const task = this.createTask(id, project, target, resolvedConfiguration, overrides);
|
38
38
|
this.tasks[task.id] = task;
|
39
39
|
this.dependencies[task.id] = [];
|
@@ -120,7 +120,7 @@ class ProcessTasks {
|
|
120
120
|
const selfProject = this.projectGraph.nodes[projectName];
|
121
121
|
if ((0, project_graph_utils_1.projectHasTarget)(selfProject, dependencyConfig.target)) {
|
122
122
|
const resolvedConfiguration = this.resolveConfiguration(selfProject, dependencyConfig.target, configuration);
|
123
|
-
const selfTaskId =
|
123
|
+
const selfTaskId = createTaskId(selfProject.name, dependencyConfig.target, resolvedConfiguration);
|
124
124
|
if (!this.tasks[selfTaskId]) {
|
125
125
|
const newTask = this.createTask(selfTaskId, selfProject, dependencyConfig.target, resolvedConfiguration, taskOverrides);
|
126
126
|
this.tasks[selfTaskId] = newTask;
|
@@ -149,7 +149,7 @@ class ProcessTasks {
|
|
149
149
|
continue;
|
150
150
|
if ((0, project_graph_utils_1.projectHasTarget)(depProject, dependencyConfig.target)) {
|
151
151
|
const resolvedConfiguration = this.resolveConfiguration(depProject, dependencyConfig.target, configuration);
|
152
|
-
const depTargetId =
|
152
|
+
const depTargetId = createTaskId(depProject.name, dependencyConfig.target, resolvedConfiguration);
|
153
153
|
const depTargetConfiguration = this.projectGraph.nodes[depProject.name].data.targets[dependencyConfig.target];
|
154
154
|
if (task.id !== depTargetId) {
|
155
155
|
if (depTargetConfiguration.continuous) {
|
@@ -169,7 +169,7 @@ class ProcessTasks {
|
|
169
169
|
}
|
170
170
|
else {
|
171
171
|
// Create a dummy task for task.target.project... which simulates if depProject had dependencyConfig.target
|
172
|
-
const dummyId =
|
172
|
+
const dummyId = createTaskId(depProject.name, task.target.project +
|
173
173
|
'__' +
|
174
174
|
dependencyConfig.target +
|
175
175
|
DUMMY_TASK_TARGET, undefined);
|
@@ -218,13 +218,6 @@ class ProcessTasks {
|
|
218
218
|
? configuration
|
219
219
|
: defaultConfiguration;
|
220
220
|
}
|
221
|
-
getId(project, target, configuration) {
|
222
|
-
let id = `${project}:${target}`;
|
223
|
-
if (configuration) {
|
224
|
-
id += `:${configuration}`;
|
225
|
-
}
|
226
|
-
return id;
|
227
|
-
}
|
228
221
|
}
|
229
222
|
exports.ProcessTasks = ProcessTasks;
|
230
223
|
function createTaskGraph(projectGraph, extraTargetDependencies, projectNames, targets, configuration, overrides, excludeTaskDependencies = false) {
|
@@ -299,3 +292,10 @@ function getNonDummyDeps(currentTask, dependencies, cycles, seen = new Set()) {
|
|
299
292
|
return [currentTask];
|
300
293
|
}
|
301
294
|
}
|
295
|
+
function createTaskId(project, target, configuration) {
|
296
|
+
let id = `${project}:${target}`;
|
297
|
+
if (configuration) {
|
298
|
+
id += `:${configuration}`;
|
299
|
+
}
|
300
|
+
return id;
|
301
|
+
}
|
@@ -54,27 +54,18 @@ class RemoteCacheV2 {
|
|
54
54
|
}
|
55
55
|
exports.RemoteCacheV2 = RemoteCacheV2;
|
56
56
|
const defaultTasksRunner = async (tasks, options, context) => {
|
57
|
-
|
58
|
-
|
59
|
-
options['parallel'] = 1;
|
60
|
-
}
|
61
|
-
else if (options['parallel'] === 'true' ||
|
62
|
-
options['parallel'] === true ||
|
63
|
-
options['parallel'] === undefined ||
|
64
|
-
options['parallel'] === '') {
|
65
|
-
options['parallel'] = Number(options['maxParallel'] || 3);
|
66
|
-
}
|
67
|
-
await options.lifeCycle.startCommand();
|
57
|
+
const threadCount = (0, task_orchestrator_1.getThreadCount)(options, context.taskGraph);
|
58
|
+
await options.lifeCycle.startCommand(threadCount);
|
68
59
|
try {
|
69
|
-
return await runAllTasks(
|
60
|
+
return await runAllTasks(options, context);
|
70
61
|
}
|
71
62
|
finally {
|
72
63
|
await options.lifeCycle.endCommand();
|
73
64
|
}
|
74
65
|
};
|
75
66
|
exports.defaultTasksRunner = defaultTasksRunner;
|
76
|
-
async function runAllTasks(
|
77
|
-
const orchestrator = new task_orchestrator_1.TaskOrchestrator(context.hasher, context.initiatingProject, context.projectGraph, context.taskGraph, context.nxJson, options, context.nxArgs?.nxBail, context.daemon, context.nxArgs?.outputStyle);
|
67
|
+
async function runAllTasks(options, context) {
|
68
|
+
const orchestrator = new task_orchestrator_1.TaskOrchestrator(context.hasher, context.initiatingProject, context.initiatingTasks, context.projectGraph, context.taskGraph, context.nxJson, options, context.nxArgs?.nxBail, context.daemon, context.nxArgs?.outputStyle);
|
78
69
|
return orchestrator.run();
|
79
70
|
}
|
80
71
|
exports.default = exports.defaultTasksRunner;
|
@@ -2,17 +2,21 @@ import { DefaultTasksRunnerOptions } from './default-tasks-runner';
|
|
2
2
|
import { Batch } from './tasks-schedule';
|
3
3
|
import { Task, TaskGraph } from '../config/task-graph';
|
4
4
|
import { PseudoTtyProcess } from './pseudo-terminal';
|
5
|
+
import { ProjectGraph } from '../config/project-graph';
|
5
6
|
import { BatchProcess } from './running-tasks/batch-process';
|
6
7
|
import { RunningTask } from './running-tasks/running-task';
|
7
8
|
export declare class ForkedProcessTaskRunner {
|
8
9
|
private readonly options;
|
10
|
+
private readonly tuiEnabled;
|
9
11
|
cliPath: string;
|
10
12
|
private readonly verbose;
|
11
13
|
private processes;
|
12
|
-
private
|
13
|
-
|
14
|
+
private finishedProcesses;
|
15
|
+
private pseudoTerminals;
|
16
|
+
constructor(options: DefaultTasksRunnerOptions, tuiEnabled: boolean);
|
14
17
|
init(): Promise<void>;
|
15
|
-
forkProcessForBatch({ executorName, taskGraph: batchTaskGraph }: Batch, fullTaskGraph: TaskGraph, env: NodeJS.ProcessEnv): Promise<BatchProcess>;
|
18
|
+
forkProcessForBatch({ executorName, taskGraph: batchTaskGraph }: Batch, projectGraph: ProjectGraph, fullTaskGraph: TaskGraph, env: NodeJS.ProcessEnv): Promise<BatchProcess>;
|
19
|
+
cleanUpBatchProcesses(): void;
|
16
20
|
forkProcessLegacy(task: Task, { temporaryOutputPath, streamOutput, pipeOutput, taskGraph, env, }: {
|
17
21
|
temporaryOutputPath: string;
|
18
22
|
streamOutput: boolean;
|
@@ -28,6 +32,7 @@ export declare class ForkedProcessTaskRunner {
|
|
28
32
|
env: NodeJS.ProcessEnv;
|
29
33
|
disablePseudoTerminal: boolean;
|
30
34
|
}): Promise<RunningTask | PseudoTtyProcess>;
|
35
|
+
private createPseudoTerminal;
|
31
36
|
private forkProcessWithPseudoTerminal;
|
32
37
|
private forkProcessWithPrefixAndNotTTY;
|
33
38
|
private forkProcessDirectOutputCapture;
|
@@ -12,26 +12,24 @@ const pseudo_terminal_1 = require("./pseudo-terminal");
|
|
12
12
|
const exit_codes_1 = require("../utils/exit-codes");
|
13
13
|
const node_child_process_1 = require("./running-tasks/node-child-process");
|
14
14
|
const batch_process_1 = require("./running-tasks/batch-process");
|
15
|
+
const native_1 = require("../native");
|
15
16
|
const forkScript = (0, path_1.join)(__dirname, './fork.js');
|
16
17
|
const workerPath = (0, path_1.join)(__dirname, './batch/run-batch.js');
|
17
18
|
class ForkedProcessTaskRunner {
|
18
|
-
constructor(options) {
|
19
|
+
constructor(options, tuiEnabled) {
|
19
20
|
this.options = options;
|
21
|
+
this.tuiEnabled = tuiEnabled;
|
20
22
|
this.cliPath = (0, utils_1.getCliPath)();
|
21
23
|
this.verbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
22
24
|
this.processes = new Set();
|
23
|
-
this.
|
24
|
-
|
25
|
-
: null;
|
25
|
+
this.finishedProcesses = new Set();
|
26
|
+
this.pseudoTerminals = new Set();
|
26
27
|
}
|
27
28
|
async init() {
|
28
|
-
if (this.pseudoTerminal) {
|
29
|
-
await this.pseudoTerminal.init();
|
30
|
-
}
|
31
29
|
this.setupProcessEventListeners();
|
32
30
|
}
|
33
31
|
// TODO: vsavkin delegate terminal output printing
|
34
|
-
async forkProcessForBatch({ executorName, taskGraph: batchTaskGraph }, fullTaskGraph, env) {
|
32
|
+
async forkProcessForBatch({ executorName, taskGraph: batchTaskGraph }, projectGraph, fullTaskGraph, env) {
|
35
33
|
const count = Object.keys(batchTaskGraph.tasks).length;
|
36
34
|
if (count > 1) {
|
37
35
|
output_1.output.logSingleLine(`Running ${output_1.output.bold(count)} ${output_1.output.bold('tasks')} with ${output_1.output.bold(executorName)}`);
|
@@ -53,11 +51,20 @@ class ForkedProcessTaskRunner {
|
|
53
51
|
cp.send({
|
54
52
|
type: batch_messages_1.BatchMessageType.RunTasks,
|
55
53
|
executorName,
|
54
|
+
projectGraph,
|
56
55
|
batchTaskGraph,
|
57
56
|
fullTaskGraph,
|
58
57
|
});
|
59
58
|
return cp;
|
60
59
|
}
|
60
|
+
cleanUpBatchProcesses() {
|
61
|
+
if (this.finishedProcesses.size > 0) {
|
62
|
+
this.finishedProcesses.forEach((p) => {
|
63
|
+
p.kill();
|
64
|
+
});
|
65
|
+
this.finishedProcesses.clear();
|
66
|
+
}
|
67
|
+
}
|
61
68
|
async forkProcessLegacy(task, { temporaryOutputPath, streamOutput, pipeOutput, taskGraph, env, }) {
|
62
69
|
return pipeOutput
|
63
70
|
? this.forkProcessWithPrefixAndNotTTY(task, {
|
@@ -74,14 +81,15 @@ class ForkedProcessTaskRunner {
|
|
74
81
|
});
|
75
82
|
}
|
76
83
|
async forkProcess(task, { temporaryOutputPath, streamOutput, taskGraph, env, disablePseudoTerminal, }) {
|
77
|
-
const shouldPrefix = streamOutput &&
|
84
|
+
const shouldPrefix = streamOutput &&
|
85
|
+
process.env.NX_PREFIX_OUTPUT === 'true' &&
|
86
|
+
!this.tuiEnabled;
|
78
87
|
// streamOutput would be false if we are running multiple targets
|
79
88
|
// there's no point in running the commands in a pty if we are not streaming the output
|
80
|
-
if (
|
81
|
-
disablePseudoTerminal
|
82
|
-
|
83
|
-
|
84
|
-
return this.forkProcessWithPrefixAndNotTTY(task, {
|
89
|
+
if (pseudo_terminal_1.PseudoTerminal.isSupported() &&
|
90
|
+
!disablePseudoTerminal &&
|
91
|
+
(this.tuiEnabled || (streamOutput && !shouldPrefix))) {
|
92
|
+
return this.forkProcessWithPseudoTerminal(task, {
|
85
93
|
temporaryOutputPath,
|
86
94
|
streamOutput,
|
87
95
|
taskGraph,
|
@@ -89,7 +97,7 @@ class ForkedProcessTaskRunner {
|
|
89
97
|
});
|
90
98
|
}
|
91
99
|
else {
|
92
|
-
return this.
|
100
|
+
return this.forkProcessWithPrefixAndNotTTY(task, {
|
93
101
|
temporaryOutputPath,
|
94
102
|
streamOutput,
|
95
103
|
taskGraph,
|
@@ -97,13 +105,19 @@ class ForkedProcessTaskRunner {
|
|
97
105
|
});
|
98
106
|
}
|
99
107
|
}
|
108
|
+
async createPseudoTerminal() {
|
109
|
+
const terminal = new pseudo_terminal_1.PseudoTerminal(new native_1.RustPseudoTerminal());
|
110
|
+
await terminal.init();
|
111
|
+
terminal.onMessageFromChildren((message) => {
|
112
|
+
process.send(message);
|
113
|
+
});
|
114
|
+
return terminal;
|
115
|
+
}
|
100
116
|
async forkProcessWithPseudoTerminal(task, { temporaryOutputPath, streamOutput, taskGraph, env, }) {
|
101
|
-
const args = (0, utils_1.getPrintableCommandArgsForTask)(task);
|
102
|
-
if (streamOutput) {
|
103
|
-
output_1.output.logCommand(args.join(' '));
|
104
|
-
}
|
105
117
|
const childId = task.id;
|
106
|
-
const
|
118
|
+
const pseudoTerminal = await this.createPseudoTerminal();
|
119
|
+
this.pseudoTerminals.add(pseudoTerminal);
|
120
|
+
const p = await pseudoTerminal.fork(childId, forkScript, {
|
107
121
|
cwd: process.cwd(),
|
108
122
|
execArgv: process.execArgv,
|
109
123
|
jsEnv: env,
|
@@ -124,7 +138,11 @@ class ForkedProcessTaskRunner {
|
|
124
138
|
if (code > 128) {
|
125
139
|
process.exit(code);
|
126
140
|
}
|
141
|
+
this.pseudoTerminals.delete(pseudoTerminal);
|
127
142
|
this.processes.delete(p);
|
143
|
+
if (!streamOutput) {
|
144
|
+
this.options.lifeCycle.printTaskTerminalOutput(task, code === 0 ? 'success' : 'failure', terminalOutput);
|
145
|
+
}
|
128
146
|
this.writeTerminalOutput(temporaryOutputPath, terminalOutput);
|
129
147
|
});
|
130
148
|
return p;
|
@@ -215,46 +233,41 @@ class ForkedProcessTaskRunner {
|
|
215
233
|
(0, fs_1.writeFileSync)(outputPath, content);
|
216
234
|
}
|
217
235
|
setupProcessEventListeners() {
|
218
|
-
|
219
|
-
this.
|
220
|
-
|
236
|
+
const messageHandler = (message) => {
|
237
|
+
this.pseudoTerminals.forEach((p) => {
|
238
|
+
p.sendMessageToChildren(message);
|
221
239
|
});
|
222
|
-
}
|
223
|
-
// When the nx process gets a message, it will be sent into the task's process
|
224
|
-
process.on('message', (message) => {
|
225
|
-
if (this.pseudoTerminal) {
|
226
|
-
this.pseudoTerminal.sendMessageToChildren(message);
|
227
|
-
}
|
228
240
|
this.processes.forEach((p) => {
|
229
|
-
if ('send' in p) {
|
241
|
+
if ('connected' in p && p.connected && 'send' in p) {
|
230
242
|
p.send(message);
|
231
243
|
}
|
232
244
|
});
|
233
|
-
}
|
234
|
-
//
|
235
|
-
process.on('
|
245
|
+
};
|
246
|
+
// When the nx process gets a message, it will be sent into the task's process
|
247
|
+
process.on('message', messageHandler);
|
248
|
+
const cleanUp = (signal) => {
|
236
249
|
this.processes.forEach((p) => {
|
237
|
-
p.kill();
|
250
|
+
p.kill(signal);
|
238
251
|
});
|
252
|
+
process.off('message', messageHandler);
|
253
|
+
this.cleanUpBatchProcesses();
|
254
|
+
};
|
255
|
+
// Terminate any task processes on exit
|
256
|
+
process.once('exit', () => {
|
257
|
+
cleanUp();
|
239
258
|
});
|
240
|
-
process.
|
241
|
-
|
242
|
-
p.kill('SIGTERM');
|
243
|
-
});
|
259
|
+
process.once('SIGINT', () => {
|
260
|
+
cleanUp('SIGTERM');
|
244
261
|
// we exit here because we don't need to write anything to cache.
|
245
262
|
process.exit((0, exit_codes_1.signalToCode)('SIGINT'));
|
246
263
|
});
|
247
|
-
process.
|
248
|
-
|
249
|
-
p.kill('SIGTERM');
|
250
|
-
});
|
264
|
+
process.once('SIGTERM', () => {
|
265
|
+
cleanUp('SIGTERM');
|
251
266
|
// no exit here because we expect child processes to terminate which
|
252
267
|
// will store results to the cache and will terminate this process
|
253
268
|
});
|
254
|
-
process.
|
255
|
-
|
256
|
-
p.kill('SIGTERM');
|
257
|
-
});
|
269
|
+
process.once('SIGHUP', () => {
|
270
|
+
cleanUp('SIGTERM');
|
258
271
|
// no exit here because we expect child processes to terminate which
|
259
272
|
// will store results to the cache and will terminate this process
|
260
273
|
});
|
@@ -1,6 +1,13 @@
|
|
1
|
+
import type { NxJsonConfiguration } from '../config/nx-json';
|
1
2
|
import { NxArgs } from '../utils/command-line-utils';
|
2
3
|
import { Task, TaskGraph } from '../config/task-graph';
|
3
|
-
import { TaskResult } from './life-cycle';
|
4
|
+
import { LifeCycle, TaskResult } from './life-cycle';
|
5
|
+
import type { ProjectGraph } from '../config/project-graph';
|
6
|
+
import { RunningTask } from './running-tasks/running-task';
|
7
|
+
/**
|
8
|
+
* This function is deprecated. Do not use this
|
9
|
+
* @deprecated This function is deprecated. Do not use this
|
10
|
+
*/
|
4
11
|
export declare function initTasksRunner(nxArgs: NxArgs): Promise<{
|
5
12
|
invoke: (opts: {
|
6
13
|
tasks: Task[];
|
@@ -11,3 +18,10 @@ export declare function initTasksRunner(nxArgs: NxArgs): Promise<{
|
|
11
18
|
taskResults: Record<string, TaskResult>;
|
12
19
|
}>;
|
13
20
|
}>;
|
21
|
+
export declare function runDiscreteTasks(tasks: Task[], projectGraph: ProjectGraph, taskGraphForHashing: TaskGraph, nxJson: NxJsonConfiguration, lifeCycle: LifeCycle): Promise<Promise<{
|
22
|
+
task: Task;
|
23
|
+
code: number;
|
24
|
+
status: import("./tasks-runner").TaskStatus;
|
25
|
+
terminalOutput?: string;
|
26
|
+
}>[]>;
|
27
|
+
export declare function runContinuousTasks(tasks: Task[], projectGraph: ProjectGraph, taskGraphForHashing: TaskGraph, nxJson: NxJsonConfiguration, lifeCycle: LifeCycle): Promise<Record<string, Promise<RunningTask>>>;
|
@@ -1,17 +1,28 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.initTasksRunner = initTasksRunner;
|
4
|
-
|
4
|
+
exports.runDiscreteTasks = runDiscreteTasks;
|
5
|
+
exports.runContinuousTasks = runContinuousTasks;
|
6
|
+
const nx_json_1 = require("../config/nx-json");
|
5
7
|
const project_graph_1 = require("../project-graph/project-graph");
|
6
8
|
const run_command_1 = require("./run-command");
|
7
9
|
const invoke_runner_terminal_output_life_cycle_1 = require("./life-cycles/invoke-runner-terminal-output-life-cycle");
|
8
10
|
const perf_hooks_1 = require("perf_hooks");
|
9
11
|
const utils_1 = require("./utils");
|
10
12
|
const dotenv_1 = require("../utils/dotenv");
|
13
|
+
const life_cycle_1 = require("./life-cycle");
|
14
|
+
const task_orchestrator_1 = require("./task-orchestrator");
|
15
|
+
const create_task_hasher_1 = require("../hasher/create-task-hasher");
|
16
|
+
const client_1 = require("../daemon/client/client");
|
17
|
+
const task_results_life_cycle_1 = require("./life-cycles/task-results-life-cycle");
|
18
|
+
/**
|
19
|
+
* This function is deprecated. Do not use this
|
20
|
+
* @deprecated This function is deprecated. Do not use this
|
21
|
+
*/
|
11
22
|
async function initTasksRunner(nxArgs) {
|
12
23
|
perf_hooks_1.performance.mark('init-local');
|
13
24
|
(0, dotenv_1.loadRootEnvFiles)();
|
14
|
-
const nxJson = (0,
|
25
|
+
const nxJson = (0, nx_json_1.readNxJson)();
|
15
26
|
if (nxArgs.verbose) {
|
16
27
|
process.env.NX_VERBOSE_LOGGING = 'true';
|
17
28
|
}
|
@@ -50,6 +61,7 @@ async function initTasksRunner(nxArgs) {
|
|
50
61
|
nxArgs: { ...nxArgs, parallel: opts.parallel },
|
51
62
|
loadDotEnvFiles: true,
|
52
63
|
initiatingProject: null,
|
64
|
+
initiatingTasks: [],
|
53
65
|
});
|
54
66
|
return {
|
55
67
|
status: Object.values(taskResults).some((taskResult) => taskResult.status === 'failure' || taskResult.status === 'skipped')
|
@@ -61,3 +73,51 @@ async function initTasksRunner(nxArgs) {
|
|
61
73
|
},
|
62
74
|
};
|
63
75
|
}
|
76
|
+
async function createOrchestrator(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle) {
|
77
|
+
(0, dotenv_1.loadRootEnvFiles)();
|
78
|
+
const invokeRunnerTerminalLifecycle = new invoke_runner_terminal_output_life_cycle_1.InvokeRunnerTerminalOutputLifeCycle(tasks);
|
79
|
+
const taskResultsLifecycle = new task_results_life_cycle_1.TaskResultsLifeCycle();
|
80
|
+
const compositedLifeCycle = new life_cycle_1.CompositeLifeCycle([
|
81
|
+
...(0, run_command_1.constructLifeCycles)(invokeRunnerTerminalLifecycle),
|
82
|
+
taskResultsLifecycle,
|
83
|
+
lifeCycle,
|
84
|
+
]);
|
85
|
+
const { runnerOptions: options } = (0, run_command_1.getRunner)({}, nxJson);
|
86
|
+
let hasher = (0, create_task_hasher_1.createTaskHasher)(projectGraph, nxJson, options);
|
87
|
+
const taskGraph = {
|
88
|
+
roots: tasks.map((task) => task.id),
|
89
|
+
tasks: tasks.reduce((acc, task) => {
|
90
|
+
acc[task.id] = task;
|
91
|
+
return acc;
|
92
|
+
}, {}),
|
93
|
+
dependencies: tasks.reduce((acc, task) => {
|
94
|
+
acc[task.id] = [];
|
95
|
+
return acc;
|
96
|
+
}, {}),
|
97
|
+
continuousDependencies: tasks.reduce((acc, task) => {
|
98
|
+
acc[task.id] = [];
|
99
|
+
return acc;
|
100
|
+
}, {}),
|
101
|
+
};
|
102
|
+
const nxArgs = {
|
103
|
+
...options,
|
104
|
+
parallel: tasks.length,
|
105
|
+
lifeCycle: compositedLifeCycle,
|
106
|
+
};
|
107
|
+
(0, run_command_1.setEnvVarsBasedOnArgs)(nxArgs, true);
|
108
|
+
const orchestrator = new task_orchestrator_1.TaskOrchestrator(hasher, null, [], projectGraph, taskGraph, nxJson, nxArgs, false, client_1.daemonClient, undefined, taskGraphForHashing);
|
109
|
+
await orchestrator.init();
|
110
|
+
orchestrator.processTasks(tasks.map((task) => task.id));
|
111
|
+
return orchestrator;
|
112
|
+
}
|
113
|
+
async function runDiscreteTasks(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle) {
|
114
|
+
const orchestrator = await createOrchestrator(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle);
|
115
|
+
return tasks.map((task, index) => orchestrator.applyFromCacheOrRunTask(true, task, index));
|
116
|
+
}
|
117
|
+
async function runContinuousTasks(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle) {
|
118
|
+
const orchestrator = await createOrchestrator(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle);
|
119
|
+
return tasks.reduce((current, task, index) => {
|
120
|
+
current[task.id] = orchestrator.startContinuousTask(task, index);
|
121
|
+
return current;
|
122
|
+
}, {});
|
123
|
+
}
|