nx 19.5.2 → 19.5.3
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/nx-cloud.d.ts +2 -1
- package/bin/nx-cloud.js +9 -17
- package/package.json +12 -12
- package/src/command-line/list/list.js +10 -14
- package/src/command-line/release/command-object.js +5 -21
- package/src/command-line/reset/command-object.d.ts +1 -0
- package/src/command-line/reset/command-object.js +4 -0
- package/src/command-line/reset/reset.js +13 -0
- package/src/command-line/run/run.js +2 -14
- package/src/command-line/watch/watch.js +1 -1
- package/src/daemon/socket-utils.js +1 -1
- package/src/daemon/tmp-dir.d.ts +1 -1
- package/src/daemon/tmp-dir.js +3 -2
- package/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -0
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +1 -1
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +3 -1
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +2 -10
- package/src/nx-cloud/utilities/client.d.ts +10 -0
- package/src/nx-cloud/utilities/client.js +35 -0
- package/src/nx-cloud/utilities/url-shorten.d.ts +2 -2
- package/src/nx-cloud/utilities/url-shorten.js +13 -6
- package/src/tasks-runner/run-command.d.ts +4 -4
- package/src/tasks-runner/run-command.js +22 -17
- package/src/tasks-runner/task-graph-utils.d.ts +3 -0
- package/src/tasks-runner/task-graph-utils.js +34 -0
- package/src/tasks-runner/utils.js +9 -5
- package/src/utils/chunkify.d.ts +10 -0
- package/src/utils/chunkify.js +19 -12
- package/src/utils/command-line-utils.d.ts +3 -0
- package/src/utils/command-line-utils.js +11 -7
- package/src/utils/git-utils.js +14 -4
- package/src/utils/plugins/core-plugins.d.ts +6 -3
- package/src/utils/plugins/core-plugins.js +107 -115
- package/src/utils/plugins/index.d.ts +4 -4
- package/src/utils/plugins/index.js +7 -8
- package/src/utils/plugins/installed-plugins.d.ts +2 -3
- package/src/utils/plugins/installed-plugins.js +4 -31
- package/src/utils/plugins/local-plugins.d.ts +2 -3
- package/src/utils/plugins/local-plugins.js +2 -29
- package/src/utils/plugins/output.d.ts +5 -0
- package/src/utils/plugins/output.js +104 -0
- package/src/utils/plugins/plugin-capabilities.d.ts +12 -2
- package/src/utils/plugins/plugin-capabilities.js +2 -87
- package/src/utils/plugins/community-plugins.d.ts +0 -2
- package/src/utils/plugins/community-plugins.js +0 -28
- package/src/utils/plugins/models.d.ts +0 -22
- package/src/utils/plugins/models.js +0 -2
- package/src/utils/plugins/shared.d.ts +0 -1
- package/src/utils/plugins/shared.js +0 -7
package/bin/nx-cloud.d.ts
CHANGED
package/bin/nx-cloud.js
CHANGED
@@ -1,38 +1,30 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
"use strict";
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
|
4
|
+
exports.invokeCommandWithNxCloudClient = invokeCommandWithNxCloudClient;
|
5
5
|
const get_cloud_options_1 = require("../src/nx-cloud/utilities/get-cloud-options");
|
6
6
|
const update_manager_1 = require("../src/nx-cloud/update-manager");
|
7
7
|
const output_1 = require("../src/utils/output");
|
8
|
+
const client_1 = require("../src/nx-cloud/utilities/client");
|
8
9
|
const command = process.argv[2];
|
9
10
|
const options = (0, get_cloud_options_1.getCloudOptions)();
|
10
11
|
Promise.resolve().then(async () => invokeCommandWithNxCloudClient(options));
|
11
12
|
async function invokeCommandWithNxCloudClient(options) {
|
12
13
|
try {
|
13
|
-
const
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
.then(() => process.exit(0))
|
19
|
-
.catch((e) => {
|
20
|
-
console.error(e);
|
21
|
-
process.exit(1);
|
22
|
-
});
|
23
|
-
}
|
24
|
-
else {
|
14
|
+
const client = await (0, client_1.getCloudClient)(options);
|
15
|
+
client.invoke(command);
|
16
|
+
}
|
17
|
+
catch (e) {
|
18
|
+
if (e instanceof client_1.UnknownCommandError) {
|
25
19
|
output_1.output.error({
|
26
|
-
title: `Unknown Command "${command}"`,
|
20
|
+
title: `Unknown Command "${e.command}"`,
|
27
21
|
});
|
28
22
|
output_1.output.log({
|
29
23
|
title: 'Available Commands:',
|
30
|
-
bodyLines:
|
24
|
+
bodyLines: e.availableCommands.map((c) => `- ${c}`),
|
31
25
|
});
|
32
26
|
process.exit(1);
|
33
27
|
}
|
34
|
-
}
|
35
|
-
catch (e) {
|
36
28
|
const body = ['Cannot run commands from the `nx-cloud` CLI.'];
|
37
29
|
if (e instanceof update_manager_1.NxCloudEnterpriseOutdatedError) {
|
38
30
|
try {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "19.5.
|
3
|
+
"version": "19.5.3",
|
4
4
|
"private": false,
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
6
6
|
"repository": {
|
@@ -71,7 +71,7 @@
|
|
71
71
|
"yargs-parser": "21.1.1",
|
72
72
|
"node-machine-id": "1.1.12",
|
73
73
|
"ora": "5.3.0",
|
74
|
-
"@nrwl/tao": "19.5.
|
74
|
+
"@nrwl/tao": "19.5.3"
|
75
75
|
},
|
76
76
|
"peerDependencies": {
|
77
77
|
"@swc-node/register": "^1.8.0",
|
@@ -86,16 +86,16 @@
|
|
86
86
|
}
|
87
87
|
},
|
88
88
|
"optionalDependencies": {
|
89
|
-
"@nx/nx-darwin-x64": "19.5.
|
90
|
-
"@nx/nx-darwin-arm64": "19.5.
|
91
|
-
"@nx/nx-linux-x64-gnu": "19.5.
|
92
|
-
"@nx/nx-linux-x64-musl": "19.5.
|
93
|
-
"@nx/nx-win32-x64-msvc": "19.5.
|
94
|
-
"@nx/nx-linux-arm64-gnu": "19.5.
|
95
|
-
"@nx/nx-linux-arm64-musl": "19.5.
|
96
|
-
"@nx/nx-linux-arm-gnueabihf": "19.5.
|
97
|
-
"@nx/nx-win32-arm64-msvc": "19.5.
|
98
|
-
"@nx/nx-freebsd-x64": "19.5.
|
89
|
+
"@nx/nx-darwin-x64": "19.5.3",
|
90
|
+
"@nx/nx-darwin-arm64": "19.5.3",
|
91
|
+
"@nx/nx-linux-x64-gnu": "19.5.3",
|
92
|
+
"@nx/nx-linux-x64-musl": "19.5.3",
|
93
|
+
"@nx/nx-win32-x64-msvc": "19.5.3",
|
94
|
+
"@nx/nx-linux-arm64-gnu": "19.5.3",
|
95
|
+
"@nx/nx-linux-arm64-musl": "19.5.3",
|
96
|
+
"@nx/nx-linux-arm-gnueabihf": "19.5.3",
|
97
|
+
"@nx/nx-win32-arm64-msvc": "19.5.3",
|
98
|
+
"@nx/nx-freebsd-x64": "19.5.3"
|
99
99
|
},
|
100
100
|
"nx-migrations": {
|
101
101
|
"migrations": "./migrations.json",
|
@@ -1,12 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.listHandler = listHandler;
|
4
|
-
const
|
4
|
+
const nx_json_1 = require("../../config/nx-json");
|
5
|
+
const project_graph_1 = require("../../project-graph/project-graph");
|
5
6
|
const output_1 = require("../../utils/output");
|
6
7
|
const plugins_1 = require("../../utils/plugins");
|
7
|
-
const
|
8
|
-
const project_graph_1 = require("../../project-graph/project-graph");
|
9
|
-
const nx_json_1 = require("../../config/nx-json");
|
8
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
10
9
|
/**
|
11
10
|
* List available plugins or capabilities within a specific plugin
|
12
11
|
*
|
@@ -16,31 +15,28 @@ const nx_json_1 = require("../../config/nx-json");
|
|
16
15
|
*
|
17
16
|
*/
|
18
17
|
async function listHandler(args) {
|
19
|
-
const nxJson = (0, nx_json_1.readNxJson)();
|
20
18
|
const projectGraph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
|
21
19
|
const projects = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
22
20
|
if (args.plugin) {
|
23
21
|
await (0, plugins_1.listPluginCapabilities)(args.plugin, projects.projects);
|
24
22
|
}
|
25
23
|
else {
|
26
|
-
const
|
27
|
-
const localPlugins = await (0,
|
24
|
+
const nxJson = (0, nx_json_1.readNxJson)();
|
25
|
+
const localPlugins = await (0, plugins_1.getLocalWorkspacePlugins)(projects, nxJson);
|
28
26
|
const installedPlugins = await (0, plugins_1.getInstalledPluginsAndCapabilities)(workspace_root_1.workspaceRoot, projects.projects);
|
29
27
|
if (localPlugins.size) {
|
30
|
-
(0,
|
28
|
+
(0, plugins_1.listPlugins)(localPlugins, 'Local workspace plugins:');
|
31
29
|
}
|
32
|
-
(0, plugins_1.
|
33
|
-
(0, plugins_1.
|
30
|
+
(0, plugins_1.listPlugins)(installedPlugins, 'Installed plugins:');
|
31
|
+
(0, plugins_1.listAlsoAvailableCorePlugins)(installedPlugins);
|
34
32
|
output_1.output.note({
|
35
33
|
title: 'Community Plugins',
|
36
34
|
bodyLines: [
|
37
35
|
'Looking for a technology / framework not listed above?',
|
38
36
|
'There are many excellent plugins maintained by the Nx community.',
|
39
|
-
'Search for the one you need here: https://nx.dev/
|
37
|
+
'Search for the one you need here: https://nx.dev/plugin-registry.',
|
40
38
|
],
|
41
39
|
});
|
42
|
-
output_1.output.note({
|
43
|
-
title: `Use "nx list [plugin]" to find out more`,
|
44
|
-
});
|
40
|
+
output_1.output.note({ title: `Use "nx list [plugin]" to find out more` });
|
45
41
|
}
|
46
42
|
}
|
@@ -5,6 +5,7 @@ const yargs_1 = require("yargs");
|
|
5
5
|
const nx_json_1 = require("../../config/nx-json");
|
6
6
|
const logger_1 = require("../../utils/logger");
|
7
7
|
const shared_options_1 = require("../yargs-utils/shared-options");
|
8
|
+
const command_line_utils_1 = require("../../utils/command-line-utils");
|
8
9
|
exports.yargsReleaseCommand = {
|
9
10
|
command: 'release',
|
10
11
|
describe: 'Orchestrate versioning and publishing of applications and libraries',
|
@@ -223,27 +224,10 @@ const planCommand = {
|
|
223
224
|
},
|
224
225
|
};
|
225
226
|
function coerceParallelOption(args) {
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
};
|
231
|
-
}
|
232
|
-
else if (args['parallel'] === 'true' ||
|
233
|
-
args['parallel'] === true ||
|
234
|
-
args['parallel'] === '') {
|
235
|
-
return {
|
236
|
-
...args,
|
237
|
-
parallel: Number(args['maxParallel'] || args['max-parallel'] || 3),
|
238
|
-
};
|
239
|
-
}
|
240
|
-
else if (args['parallel'] !== undefined) {
|
241
|
-
return {
|
242
|
-
...args,
|
243
|
-
parallel: Number(args['parallel']),
|
244
|
-
};
|
245
|
-
}
|
246
|
-
return args;
|
227
|
+
return {
|
228
|
+
...args,
|
229
|
+
parallel: (0, command_line_utils_1.readParallelFromArgsAndEnv)(args),
|
230
|
+
};
|
247
231
|
}
|
248
232
|
function withGitCommitAndGitTagOptions(yargs) {
|
249
233
|
return yargs
|
@@ -13,6 +13,10 @@ exports.yargsResetCommand = {
|
|
13
13
|
.option('onlyDaemon', {
|
14
14
|
description: 'Stops the Nx Daemon, it will be restarted fresh when the next Nx command is run.',
|
15
15
|
type: 'boolean',
|
16
|
+
})
|
17
|
+
.option('onlyCloud', {
|
18
|
+
description: 'Resets the Nx Cloud client. NOTE: Does not clear the remote cache.',
|
19
|
+
type: 'boolean',
|
16
20
|
})
|
17
21
|
.option('onlyWorkspaceData', {
|
18
22
|
description: 'Clears the workspace data directory. Used by Nx to store cached data about the current workspace (e.g. partial results, incremental data, etc)',
|
@@ -6,6 +6,8 @@ const client_1 = require("../../daemon/client/client");
|
|
6
6
|
const cache_directory_1 = require("../../utils/cache-directory");
|
7
7
|
const output_1 = require("../../utils/output");
|
8
8
|
const native_file_cache_location_1 = require("../../native/native-file-cache-location");
|
9
|
+
const client_2 = require("../../nx-cloud/utilities/client");
|
10
|
+
const get_cloud_options_1 = require("../../nx-cloud/utilities/get-cloud-options");
|
9
11
|
// Wait at max 5 seconds before giving up on a failing operation.
|
10
12
|
const INCREMENTAL_BACKOFF_MAX_DURATION = 5000;
|
11
13
|
// If an operation fails, wait 100ms before first retry.
|
@@ -61,6 +63,9 @@ async function resetHandler(args) {
|
|
61
63
|
errors.push('Failed to clean up the workspace data directory.');
|
62
64
|
}
|
63
65
|
}
|
66
|
+
if (all || args.onlyCloud) {
|
67
|
+
await resetCloudClient();
|
68
|
+
}
|
64
69
|
if (errors.length > 0) {
|
65
70
|
output_1.output.error({
|
66
71
|
title: 'Failed to reset the Nx workspace.',
|
@@ -77,6 +82,14 @@ async function resetHandler(args) {
|
|
77
82
|
function killDaemon() {
|
78
83
|
return client_1.daemonClient.stop();
|
79
84
|
}
|
85
|
+
async function resetCloudClient() {
|
86
|
+
// Remove nx cloud marker files. This helps if the use happens to run `nx-cloud start-ci-run` or
|
87
|
+
// similar commands on their local machine.
|
88
|
+
try {
|
89
|
+
(await (0, client_2.getCloudClient)((0, get_cloud_options_1.getCloudOptions)())).invoke('cleanup');
|
90
|
+
}
|
91
|
+
catch { }
|
92
|
+
}
|
80
93
|
function cleanupCacheEntries() {
|
81
94
|
return incrementalBackoff(INCREMENTAL_BACKOFF_FIRST_DELAY, INCREMENTAL_BACKOFF_MAX_DURATION, () => {
|
82
95
|
(0, fs_extra_1.rmSync)(cache_directory_1.cacheDir, { recursive: true, force: true });
|
@@ -35,20 +35,8 @@ async function* promiseToIterator(v) {
|
|
35
35
|
yield await v;
|
36
36
|
}
|
37
37
|
async function iteratorToProcessStatusCode(i) {
|
38
|
-
|
39
|
-
|
40
|
-
// on version 12.0.1, a SASS compilation implementation was
|
41
|
-
// introduced making use of workers and it's unref()-ing the worker
|
42
|
-
// too early, causing the process to exit early in environments
|
43
|
-
// like CI or when running Docker builds.
|
44
|
-
const keepProcessAliveInterval = setInterval(() => { }, 1000);
|
45
|
-
try {
|
46
|
-
const { success } = await (0, async_iterator_1.getLastValueFromAsyncIterableIterator)(i);
|
47
|
-
return success ? 0 : 1;
|
48
|
-
}
|
49
|
-
finally {
|
50
|
-
clearInterval(keepProcessAliveInterval);
|
51
|
-
}
|
38
|
+
const { success } = await (0, async_iterator_1.getLastValueFromAsyncIterableIterator)(i);
|
39
|
+
return success ? 0 : 1;
|
52
40
|
}
|
53
41
|
async function parseExecutorAndTarget({ project, target }, root, projectsConfigurations) {
|
54
42
|
const proj = projectsConfigurations.projects[project];
|
@@ -117,7 +117,7 @@ async function watch(args) {
|
|
117
117
|
if (args.verbose) {
|
118
118
|
process.env.NX_VERBOSE_LOGGING = 'true';
|
119
119
|
}
|
120
|
-
if (client_1.daemonClient.enabled()) {
|
120
|
+
if (!client_1.daemonClient.enabled()) {
|
121
121
|
output_1.output.error({
|
122
122
|
title: 'Daemon is not running. The watch command is not supported without the Nx Daemon.',
|
123
123
|
});
|
@@ -25,7 +25,7 @@ const getForkedProcessOsSocketPath = (id) => {
|
|
25
25
|
};
|
26
26
|
exports.getForkedProcessOsSocketPath = getForkedProcessOsSocketPath;
|
27
27
|
const getPluginOsSocketPath = (id) => {
|
28
|
-
let path = (0, path_1.resolve)((0, path_1.join)((0, tmp_dir_1.getSocketDir)(), 'plugin' + id + '.sock'));
|
28
|
+
let path = (0, path_1.resolve)((0, path_1.join)((0, tmp_dir_1.getSocketDir)(true), 'plugin' + id + '.sock'));
|
29
29
|
return exports.isWindows ? '\\\\.\\pipe\\nx\\' + (0, path_1.resolve)(path) : (0, path_1.resolve)(path);
|
30
30
|
};
|
31
31
|
exports.getPluginOsSocketPath = getPluginOsSocketPath;
|
package/src/daemon/tmp-dir.d.ts
CHANGED
@@ -8,5 +8,5 @@ export declare function isDaemonDisabled(): boolean;
|
|
8
8
|
* We try to create a socket file in a tmp dir, but if it doesn't work because
|
9
9
|
* for instance we don't have permissions, we create it in DAEMON_DIR_FOR_CURRENT_WORKSPACE
|
10
10
|
*/
|
11
|
-
export declare function getSocketDir(): string;
|
11
|
+
export declare function getSocketDir(alreadyUnique?: boolean): string;
|
12
12
|
export declare function removeSocketDir(): void;
|
package/src/daemon/tmp-dir.js
CHANGED
@@ -51,9 +51,10 @@ function socketDirName() {
|
|
51
51
|
* We try to create a socket file in a tmp dir, but if it doesn't work because
|
52
52
|
* for instance we don't have permissions, we create it in DAEMON_DIR_FOR_CURRENT_WORKSPACE
|
53
53
|
*/
|
54
|
-
function getSocketDir() {
|
54
|
+
function getSocketDir(alreadyUnique = false) {
|
55
55
|
try {
|
56
|
-
const dir = process.env.NX_DAEMON_SOCKET_DIR ??
|
56
|
+
const dir = process.env.NX_DAEMON_SOCKET_DIR ??
|
57
|
+
(alreadyUnique ? tmp_1.tmpdir : socketDirName());
|
57
58
|
(0, fs_extra_1.ensureDirSync)(dir);
|
58
59
|
return dir;
|
59
60
|
}
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = default_1;
|
4
4
|
const project_configuration_1 = require("../../generators/utils/project-configuration");
|
5
5
|
const json_1 = require("../../generators/utils/json");
|
6
|
+
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
6
7
|
async function default_1(tree) {
|
7
8
|
(0, json_1.updateJson)(tree, 'package.json', (json) => {
|
8
9
|
if (json.dependencies && json.dependencies['@nrwl/nx-cloud']) {
|
@@ -24,4 +25,5 @@ async function default_1(tree) {
|
|
24
25
|
}
|
25
26
|
}
|
26
27
|
(0, project_configuration_1.updateNxJson)(tree, nxJson);
|
28
|
+
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
|
27
29
|
}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { Tree } from '../../generators/tree';
|
2
|
-
export default function migrate(tree: Tree): void
|
2
|
+
export default function migrate(tree: Tree): Promise<void>;
|
@@ -2,8 +2,10 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.default = migrate;
|
4
4
|
const nx_json_1 = require("../../generators/utils/nx-json");
|
5
|
-
|
5
|
+
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
6
|
+
async function migrate(tree) {
|
6
7
|
const nxJson = (0, nx_json_1.readNxJson)(tree);
|
7
8
|
nxJson.useInferencePlugins = false;
|
8
9
|
(0, nx_json_1.updateNxJson)(tree, nxJson);
|
10
|
+
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
|
9
11
|
}
|
Binary file
|
@@ -8,7 +8,6 @@ const nx_json_1 = require("../../../generators/utils/nx-json");
|
|
8
8
|
const format_changed_files_with_prettier_if_available_1 = require("../../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
9
9
|
const url_shorten_1 = require("../../utilities/url-shorten");
|
10
10
|
const get_cloud_options_1 = require("../../utilities/get-cloud-options");
|
11
|
-
const git_utils_1 = require("../../../utils/git-utils");
|
12
11
|
const ora = require("ora");
|
13
12
|
const open = require("open");
|
14
13
|
function printCloudConnectionDisabledMessage() {
|
@@ -55,7 +54,7 @@ async function createNxCloudWorkspace(workspaceName, installationSource, nxInitD
|
|
55
54
|
}
|
56
55
|
return response.data;
|
57
56
|
}
|
58
|
-
async function printSuccessMessage(
|
57
|
+
async function printSuccessMessage(token, installationSource, usesGithub) {
|
59
58
|
const connectCloudUrl = await (0, url_shorten_1.shortenedCloudUrl)(installationSource, token, usesGithub);
|
60
59
|
if (installationSource === 'nx-connect' && usesGithub) {
|
61
60
|
try {
|
@@ -88,12 +87,6 @@ async function printSuccessMessage(url, token, installationSource, usesGithub, d
|
|
88
87
|
`${connectCloudUrl}`,
|
89
88
|
],
|
90
89
|
});
|
91
|
-
(0, git_utils_1.commitChanges)(`feat(nx): Added Nx Cloud token to your nx.json
|
92
|
-
|
93
|
-
To connect your workspace to Nx Cloud, push your repository
|
94
|
-
to your git hosting provider and go to the following URL:
|
95
|
-
|
96
|
-
${connectCloudUrl}`, directory);
|
97
90
|
}
|
98
91
|
else {
|
99
92
|
output_1.output.note({
|
@@ -141,8 +134,7 @@ async function connectToNxCloud(tree, schema) {
|
|
141
134
|
silent: schema.hideFormatLogs,
|
142
135
|
});
|
143
136
|
}
|
144
|
-
|
145
|
-
return async () => await printSuccessMessage(responseFromCreateNxCloudWorkspace?.url ?? apiUrl, responseFromCreateNxCloudWorkspace?.token, schema.installationSource, usesGithub, schema.directory);
|
137
|
+
return async () => await printSuccessMessage(responseFromCreateNxCloudWorkspace?.token, schema.installationSource, usesGithub);
|
146
138
|
}
|
147
139
|
}
|
148
140
|
function sleep(ms) {
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { CloudTaskRunnerOptions } from '../nx-cloud-tasks-runner-shell';
|
2
|
+
export declare class UnknownCommandError extends Error {
|
3
|
+
command: string;
|
4
|
+
availableCommands: string[];
|
5
|
+
constructor(command: string, availableCommands: string[]);
|
6
|
+
}
|
7
|
+
export declare function getCloudClient(options: CloudTaskRunnerOptions): Promise<{
|
8
|
+
invoke: (command: string) => void;
|
9
|
+
availableCommands: string[];
|
10
|
+
}>;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.UnknownCommandError = void 0;
|
4
|
+
exports.getCloudClient = getCloudClient;
|
5
|
+
const resolution_helpers_1 = require("../resolution-helpers");
|
6
|
+
const update_manager_1 = require("../update-manager");
|
7
|
+
class UnknownCommandError extends Error {
|
8
|
+
constructor(command, availableCommands) {
|
9
|
+
super(`Unknown Command "${command}"`);
|
10
|
+
this.command = command;
|
11
|
+
this.availableCommands = availableCommands;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
exports.UnknownCommandError = UnknownCommandError;
|
15
|
+
async function getCloudClient(options) {
|
16
|
+
const { nxCloudClient } = await (0, update_manager_1.verifyOrUpdateNxCloudClient)(options);
|
17
|
+
const paths = (0, resolution_helpers_1.findAncestorNodeModules)(__dirname, []);
|
18
|
+
nxCloudClient.configureLightClientRequire()(paths);
|
19
|
+
return {
|
20
|
+
invoke: (command) => {
|
21
|
+
if (command in nxCloudClient.commands) {
|
22
|
+
nxCloudClient.commands[command]()
|
23
|
+
.then(() => process.exit(0))
|
24
|
+
.catch((e) => {
|
25
|
+
console.error(e);
|
26
|
+
process.exit(1);
|
27
|
+
});
|
28
|
+
}
|
29
|
+
else {
|
30
|
+
throw new UnknownCommandError(command, Object.keys(nxCloudClient.commands));
|
31
|
+
}
|
32
|
+
},
|
33
|
+
availableCommands: Object.keys(nxCloudClient.commands),
|
34
|
+
};
|
35
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
export declare function shortenedCloudUrl(installationSource: string, accessToken?: string, usesGithub?: boolean): Promise<string>;
|
2
|
-
export declare function repoUsesGithub(github?: boolean): Promise<boolean>;
|
3
|
-
export declare function getURLifShortenFailed(usesGithub: boolean, githubSlug: string, apiUrl: string, source: string, accessToken?: string): string;
|
2
|
+
export declare function repoUsesGithub(github?: boolean, githubSlug?: string, apiUrl?: string): Promise<boolean>;
|
3
|
+
export declare function getURLifShortenFailed(usesGithub: boolean, githubSlug: string | null, apiUrl: string, source: string, accessToken?: string): string;
|
4
4
|
export declare function getNxCloudVersion(apiUrl: string): Promise<string | null>;
|
5
5
|
export declare function removeVersionModifier(versionString: string): string;
|
6
6
|
export declare function versionIsValid(version: string): boolean;
|
@@ -13,6 +13,9 @@ const get_cloud_options_1 = require("./get-cloud-options");
|
|
13
13
|
async function shortenedCloudUrl(installationSource, accessToken, usesGithub) {
|
14
14
|
const githubSlug = (0, git_utils_1.getGithubSlugOrNull)();
|
15
15
|
const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
|
16
|
+
if (usesGithub === undefined || usesGithub === null) {
|
17
|
+
usesGithub = await repoUsesGithub(undefined, githubSlug, apiUrl);
|
18
|
+
}
|
16
19
|
try {
|
17
20
|
const version = await getNxCloudVersion(apiUrl);
|
18
21
|
if ((version && compareCleanCloudVersions(version, '2406.11.5') < 0) ||
|
@@ -31,7 +34,7 @@ async function shortenedCloudUrl(installationSource, accessToken, usesGithub) {
|
|
31
34
|
type: usesGithub ? 'GITHUB' : 'MANUAL',
|
32
35
|
source,
|
33
36
|
accessToken: usesGithub ? null : accessToken,
|
34
|
-
selectedRepositoryName: githubSlug,
|
37
|
+
selectedRepositoryName: githubSlug === 'github' ? null : githubSlug,
|
35
38
|
});
|
36
39
|
if (!response?.data || response.data.message) {
|
37
40
|
throw new Error(response?.data?.message ?? 'Failed to shorten Nx Cloud URL');
|
@@ -41,14 +44,18 @@ async function shortenedCloudUrl(installationSource, accessToken, usesGithub) {
|
|
41
44
|
catch (e) {
|
42
45
|
devkit_exports_1.logger.verbose(`Failed to shorten Nx Cloud URL.
|
43
46
|
${e}`);
|
44
|
-
return getURLifShortenFailed(usesGithub, githubSlug, apiUrl, source, accessToken);
|
47
|
+
return getURLifShortenFailed(usesGithub, githubSlug === 'github' ? null : githubSlug, apiUrl, source, accessToken);
|
45
48
|
}
|
46
49
|
}
|
47
|
-
async function repoUsesGithub(github) {
|
48
|
-
|
49
|
-
|
50
|
+
async function repoUsesGithub(github, githubSlug, apiUrl) {
|
51
|
+
if (!apiUrl) {
|
52
|
+
apiUrl = (0, get_cloud_options_1.getCloudUrl)();
|
53
|
+
}
|
54
|
+
if (!githubSlug) {
|
55
|
+
githubSlug = (0, git_utils_1.getGithubSlugOrNull)();
|
56
|
+
}
|
50
57
|
const installationSupportsGitHub = await getInstallationSupportsGitHub(apiUrl);
|
51
|
-
return ((githubSlug || github) &&
|
58
|
+
return ((!!githubSlug || !!github) &&
|
52
59
|
(apiUrl.includes('cloud.nx.app') ||
|
53
60
|
apiUrl.includes('eu.nx.app') ||
|
54
61
|
installationSupportsGitHub));
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import { TasksRunner } from './tasks-runner';
|
2
|
-
import { NxArgs } from '../utils/command-line-utils';
|
3
|
-
import { LifeCycle } from './life-cycle';
|
4
|
-
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
|
5
1
|
import { NxJsonConfiguration } from '../config/nx-json';
|
2
|
+
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
|
6
3
|
import { Task, TaskGraph } from '../config/task-graph';
|
7
4
|
import { TargetDependencyConfig } from '../config/workspace-json-project-json';
|
5
|
+
import { NxArgs } from '../utils/command-line-utils';
|
6
|
+
import { LifeCycle } from './life-cycle';
|
7
|
+
import { TasksRunner } from './tasks-runner';
|
8
8
|
export declare function runCommand(projectsToRun: ProjectGraphProjectNode[], projectGraph: ProjectGraph, { nxJson }: {
|
9
9
|
nxJson: NxJsonConfiguration;
|
10
10
|
}, nxArgs: NxArgs, overrides: any, initiatingProject: string | null, extraTargetDependencies: Record<string, (TargetDependencyConfig | string)[]>, extraOptions: {
|
@@ -5,28 +5,28 @@ exports.invokeTasksRunner = invokeTasksRunner;
|
|
5
5
|
exports.getRunner = getRunner;
|
6
6
|
exports.getRunnerOptions = getRunnerOptions;
|
7
7
|
const path_1 = require("path");
|
8
|
-
const
|
8
|
+
const nx_json_1 = require("../config/nx-json");
|
9
|
+
const client_1 = require("../daemon/client/client");
|
10
|
+
const create_task_hasher_1 = require("../hasher/create-task-hasher");
|
11
|
+
const hash_task_1 = require("../hasher/hash-task");
|
9
12
|
const fileutils_1 = require("../utils/fileutils");
|
13
|
+
const is_ci_1 = require("../utils/is-ci");
|
14
|
+
const nx_cloud_utils_1 = require("../utils/nx-cloud-utils");
|
10
15
|
const output_1 = require("../utils/output");
|
11
|
-
const
|
16
|
+
const params_1 = require("../utils/params");
|
17
|
+
const workspace_root_1 = require("../utils/workspace-root");
|
18
|
+
const create_task_graph_1 = require("./create-task-graph");
|
12
19
|
const life_cycle_1 = require("./life-cycle");
|
13
|
-
const static_run_many_terminal_output_life_cycle_1 = require("./life-cycles/static-run-many-terminal-output-life-cycle");
|
14
|
-
const static_run_one_terminal_output_life_cycle_1 = require("./life-cycles/static-run-one-terminal-output-life-cycle");
|
15
|
-
const task_timings_life_cycle_1 = require("./life-cycles/task-timings-life-cycle");
|
16
20
|
const dynamic_run_many_terminal_output_life_cycle_1 = require("./life-cycles/dynamic-run-many-terminal-output-life-cycle");
|
17
|
-
const task_profiling_life_cycle_1 = require("./life-cycles/task-profiling-life-cycle");
|
18
|
-
const is_ci_1 = require("../utils/is-ci");
|
19
21
|
const dynamic_run_one_terminal_output_life_cycle_1 = require("./life-cycles/dynamic-run-one-terminal-output-life-cycle");
|
20
|
-
const
|
21
|
-
const
|
22
|
-
const task_graph_utils_1 = require("./task-graph-utils");
|
23
|
-
const params_1 = require("../utils/params");
|
24
|
-
const hash_task_1 = require("../hasher/hash-task");
|
25
|
-
const client_1 = require("../daemon/client/client");
|
22
|
+
const static_run_many_terminal_output_life_cycle_1 = require("./life-cycles/static-run-many-terminal-output-life-cycle");
|
23
|
+
const static_run_one_terminal_output_life_cycle_1 = require("./life-cycles/static-run-one-terminal-output-life-cycle");
|
26
24
|
const store_run_information_life_cycle_1 = require("./life-cycles/store-run-information-life-cycle");
|
27
|
-
const create_task_hasher_1 = require("../hasher/create-task-hasher");
|
28
25
|
const task_history_life_cycle_1 = require("./life-cycles/task-history-life-cycle");
|
29
|
-
const
|
26
|
+
const task_profiling_life_cycle_1 = require("./life-cycles/task-profiling-life-cycle");
|
27
|
+
const task_timings_life_cycle_1 = require("./life-cycles/task-timings-life-cycle");
|
28
|
+
const task_graph_utils_1 = require("./task-graph-utils");
|
29
|
+
const utils_1 = require("./utils");
|
30
30
|
async function getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks, nxArgs, nxJson, overrides) {
|
31
31
|
const { runnerOptions } = getRunner(nxArgs, nxJson);
|
32
32
|
const isRunOne = initiatingProject != null;
|
@@ -64,7 +64,7 @@ async function getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks
|
|
64
64
|
}
|
65
65
|
}
|
66
66
|
}
|
67
|
-
function
|
67
|
+
function createTaskGraphAndRunValidations(projectGraph, extraTargetDependencies, projectNames, nxArgs, overrides, extraOptions) {
|
68
68
|
const taskGraph = (0, create_task_graph_1.createTaskGraph)(projectGraph, extraTargetDependencies, projectNames, nxArgs.targets, nxArgs.configuration, overrides, extraOptions.excludeTaskDependencies);
|
69
69
|
const cycle = (0, task_graph_utils_1.findCycle)(taskGraph);
|
70
70
|
if (cycle) {
|
@@ -83,12 +83,17 @@ function createTaskGraphAndValidateCycles(projectGraph, extraTargetDependencies,
|
|
83
83
|
process.exit(1);
|
84
84
|
}
|
85
85
|
}
|
86
|
+
// validate that no atomized tasks like e2e-ci are used without Nx Cloud
|
87
|
+
if (!(0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)()) &&
|
88
|
+
!process.env['NX_SKIP_ATOMIZER_VALIDATION']) {
|
89
|
+
(0, task_graph_utils_1.validateNoAtomizedTasks)(taskGraph, projectGraph);
|
90
|
+
}
|
86
91
|
return taskGraph;
|
87
92
|
}
|
88
93
|
async function runCommand(projectsToRun, projectGraph, { nxJson }, nxArgs, overrides, initiatingProject, extraTargetDependencies, extraOptions) {
|
89
94
|
const status = await (0, params_1.handleErrors)(process.env.NX_VERBOSE_LOGGING === 'true', async () => {
|
90
95
|
const projectNames = projectsToRun.map((t) => t.name);
|
91
|
-
const taskGraph =
|
96
|
+
const taskGraph = createTaskGraphAndRunValidations(projectGraph, extraTargetDependencies ?? {}, projectNames, nxArgs, overrides, extraOptions);
|
92
97
|
const tasks = Object.values(taskGraph.tasks);
|
93
98
|
const { lifeCycle, renderIsDone } = await getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks, nxArgs, nxJson, overrides);
|
94
99
|
const status = await invokeTasksRunner({
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import { ProjectGraph } from '../config/project-graph';
|
2
|
+
import { TaskGraph } from '../config/task-graph';
|
1
3
|
export declare function findCycle(graph: {
|
2
4
|
dependencies: Record<string, string[]>;
|
3
5
|
}): string[] | null;
|
@@ -5,3 +7,4 @@ export declare function makeAcyclic(graph: {
|
|
5
7
|
roots: string[];
|
6
8
|
dependencies: Record<string, string[]>;
|
7
9
|
}): void;
|
10
|
+
export declare function validateNoAtomizedTasks(taskGraph: TaskGraph, projectGraph: ProjectGraph): void;
|
@@ -2,6 +2,8 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.findCycle = findCycle;
|
4
4
|
exports.makeAcyclic = makeAcyclic;
|
5
|
+
exports.validateNoAtomizedTasks = validateNoAtomizedTasks;
|
6
|
+
const output_1 = require("../utils/output");
|
5
7
|
function _findCycle(graph, id, visited, path) {
|
6
8
|
if (visited[id])
|
7
9
|
return null;
|
@@ -52,3 +54,35 @@ function makeAcyclic(graph) {
|
|
52
54
|
}
|
53
55
|
graph.roots = Object.keys(graph.dependencies).filter((t) => graph.dependencies[t].length === 0);
|
54
56
|
}
|
57
|
+
function validateNoAtomizedTasks(taskGraph, projectGraph) {
|
58
|
+
const getNonAtomizedTargetForTask = (task) => projectGraph.nodes[task.target.project]?.data?.targets?.[task.target.target]
|
59
|
+
?.metadata?.nonAtomizedTarget;
|
60
|
+
const atomizedRootTasks = Object.values(taskGraph.tasks).filter((task) => getNonAtomizedTargetForTask(task) !== undefined);
|
61
|
+
if (atomizedRootTasks.length === 0) {
|
62
|
+
return;
|
63
|
+
}
|
64
|
+
const nonAtomizedTasks = atomizedRootTasks
|
65
|
+
.map((t) => `"${getNonAtomizedTargetForTask(t)}"`)
|
66
|
+
.filter((item, index, arr) => arr.indexOf(item) === index);
|
67
|
+
const moreInfoLines = [
|
68
|
+
`Please enable Nx Cloud or use the slower ${nonAtomizedTasks.join(',')} task${nonAtomizedTasks.length > 1 ? 's' : ''}.`,
|
69
|
+
'Learn more at https://nx.dev/ci/features/split-e2e-tasks#use-atomizer-only-with-nx-cloud-distribution',
|
70
|
+
];
|
71
|
+
if (atomizedRootTasks.length === 1) {
|
72
|
+
output_1.output.error({
|
73
|
+
title: `The ${atomizedRootTasks[0].id} task should only be run with Nx Cloud.`,
|
74
|
+
bodyLines: [...moreInfoLines],
|
75
|
+
});
|
76
|
+
}
|
77
|
+
else {
|
78
|
+
output_1.output.error({
|
79
|
+
title: `The following tasks should only be run with Nx Cloud:`,
|
80
|
+
bodyLines: [
|
81
|
+
...atomizedRootTasks.map((task) => ` - ${task.id}`),
|
82
|
+
'',
|
83
|
+
...moreInfoLines,
|
84
|
+
],
|
85
|
+
});
|
86
|
+
}
|
87
|
+
process.exit(1);
|
88
|
+
}
|