nx 18.0.0-beta.1 → 18.0.0-beta.2
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/bin/init-local.js +1 -34
- package/package.json +12 -12
- package/src/command-line/add/add.js +2 -1
- package/src/command-line/add/command-object.js +1 -1
- package/src/command-line/connect/connect-to-nx-cloud.js +1 -1
- package/src/command-line/init/command-object.js +3 -3
- package/src/command-line/init/init-v1.js +1 -1
- package/src/command-line/init/init-v2.js +2 -2
- package/src/command-line/nx-commands.js +1 -0
- package/src/command-line/run/command-object.d.ts +4 -0
- package/src/command-line/run/command-object.js +10 -1
- package/src/command-line/run/run-one.js +2 -2
- package/src/command-line/yargs-utils/shared-options.d.ts +1 -0
- package/src/command-line/yargs-utils/shared-options.js +9 -1
- package/src/core/graph/main.js +1 -1
- package/src/executors/run-script/run-script.impl.js +33 -14
- package/src/plugins/target-defaults/target-defaults-plugin.js +24 -22
- package/src/project-graph/build-project-graph.js +3 -0
- package/src/project-graph/utils/project-configuration-utils.js +3 -0
- package/src/utils/package-json.d.ts +1 -2
package/bin/init-local.js
CHANGED
|
@@ -54,8 +54,7 @@ function initLocal(workspace) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
57
|
-
|
|
58
|
-
nx_commands_1.commandsObject.parse(newArgs);
|
|
57
|
+
nx_commands_1.commandsObject.parse(process.argv.slice(2));
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
catch (e) {
|
|
@@ -95,38 +94,6 @@ function rewriteTargetsAndProjects(args) {
|
|
|
95
94
|
return newArgs;
|
|
96
95
|
}
|
|
97
96
|
exports.rewriteTargetsAndProjects = rewriteTargetsAndProjects;
|
|
98
|
-
function rewritePositionalArguments(args) {
|
|
99
|
-
const relevantPositionalArgs = [];
|
|
100
|
-
const rest = [];
|
|
101
|
-
for (let i = 2; i < args.length; i++) {
|
|
102
|
-
if (args[i] === '--') {
|
|
103
|
-
rest.push(...args.slice(i + 1));
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
else if (!args[i].startsWith('-')) {
|
|
107
|
-
relevantPositionalArgs.push(args[i]);
|
|
108
|
-
if (relevantPositionalArgs.length === 2) {
|
|
109
|
-
rest.push(...args.slice(i + 1));
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
rest.push(args[i]);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (relevantPositionalArgs.length === 1) {
|
|
118
|
-
return [
|
|
119
|
-
'run',
|
|
120
|
-
`${wrapIntoQuotesIfNeeded(relevantPositionalArgs[0])}`,
|
|
121
|
-
...rest,
|
|
122
|
-
];
|
|
123
|
-
}
|
|
124
|
-
return [
|
|
125
|
-
'run',
|
|
126
|
-
`${relevantPositionalArgs[1]}:${wrapIntoQuotesIfNeeded(relevantPositionalArgs[0])}`,
|
|
127
|
-
...rest,
|
|
128
|
-
];
|
|
129
|
-
}
|
|
130
97
|
function wrapIntoQuotesIfNeeded(arg) {
|
|
131
98
|
return arg.indexOf(':') > -1 ? `"${arg}"` : arg;
|
|
132
99
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nx",
|
|
3
|
-
"version": "18.0.0-beta.
|
|
3
|
+
"version": "18.0.0-beta.2",
|
|
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": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"yargs-parser": "21.1.1",
|
|
67
67
|
"node-machine-id": "1.1.12",
|
|
68
68
|
"ora": "5.3.0",
|
|
69
|
-
"@nrwl/tao": "18.0.0-beta.
|
|
69
|
+
"@nrwl/tao": "18.0.0-beta.2"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"@swc-node/register": "^1.6.7",
|
|
@@ -81,16 +81,16 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"optionalDependencies": {
|
|
84
|
-
"@nx/nx-darwin-x64": "18.0.0-beta.
|
|
85
|
-
"@nx/nx-darwin-arm64": "18.0.0-beta.
|
|
86
|
-
"@nx/nx-linux-x64-gnu": "18.0.0-beta.
|
|
87
|
-
"@nx/nx-linux-x64-musl": "18.0.0-beta.
|
|
88
|
-
"@nx/nx-win32-x64-msvc": "18.0.0-beta.
|
|
89
|
-
"@nx/nx-linux-arm64-gnu": "18.0.0-beta.
|
|
90
|
-
"@nx/nx-linux-arm64-musl": "18.0.0-beta.
|
|
91
|
-
"@nx/nx-linux-arm-gnueabihf": "18.0.0-beta.
|
|
92
|
-
"@nx/nx-win32-arm64-msvc": "18.0.0-beta.
|
|
93
|
-
"@nx/nx-freebsd-x64": "18.0.0-beta.
|
|
84
|
+
"@nx/nx-darwin-x64": "18.0.0-beta.2",
|
|
85
|
+
"@nx/nx-darwin-arm64": "18.0.0-beta.2",
|
|
86
|
+
"@nx/nx-linux-x64-gnu": "18.0.0-beta.2",
|
|
87
|
+
"@nx/nx-linux-x64-musl": "18.0.0-beta.2",
|
|
88
|
+
"@nx/nx-win32-x64-msvc": "18.0.0-beta.2",
|
|
89
|
+
"@nx/nx-linux-arm64-gnu": "18.0.0-beta.2",
|
|
90
|
+
"@nx/nx-linux-arm64-musl": "18.0.0-beta.2",
|
|
91
|
+
"@nx/nx-linux-arm-gnueabihf": "18.0.0-beta.2",
|
|
92
|
+
"@nx/nx-win32-arm64-msvc": "18.0.0-beta.2",
|
|
93
|
+
"@nx/nx-freebsd-x64": "18.0.0-beta.2"
|
|
94
94
|
},
|
|
95
95
|
"nx-migrations": {
|
|
96
96
|
"migrations": "./migrations.json",
|
|
@@ -97,7 +97,8 @@ async function initializePlugin(pkgName, options) {
|
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
99
99
|
updatePackageScripts =
|
|
100
|
-
process.env.
|
|
100
|
+
process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
101
|
+
coreNxPlugins.includes(pkgName);
|
|
101
102
|
}
|
|
102
103
|
await (0, child_process_2.runNxAsync)(`g ${pkgName}:${initGenerator} --keepExistingVersions${updatePackageScripts ? ' --updatePackageScripts' : ''}`);
|
|
103
104
|
}
|
|
@@ -11,7 +11,7 @@ exports.yargsAddCommand = {
|
|
|
11
11
|
})
|
|
12
12
|
.option('updatePackageScripts', {
|
|
13
13
|
type: 'boolean',
|
|
14
|
-
description: 'Update `package.json` scripts with inferred targets. Defaults to `true` when
|
|
14
|
+
description: 'Update `package.json` scripts with inferred targets. Defaults to `true` when the package is a core Nx plugin',
|
|
15
15
|
})
|
|
16
16
|
.option('verbose', {
|
|
17
17
|
type: 'boolean',
|
|
@@ -41,7 +41,7 @@ async function connectToNxCloudCommand() {
|
|
|
41
41
|
const nxJson = (0, configuration_1.readNxJson)();
|
|
42
42
|
if ((0, nx_cloud_utils_1.isNxCloudUsed)(nxJson)) {
|
|
43
43
|
output_1.output.log({
|
|
44
|
-
title: '✔ This workspace has
|
|
44
|
+
title: '✔ This workspace already has Nx Cloud set up',
|
|
45
45
|
bodyLines: [
|
|
46
46
|
'If you have not done so already, connect your workspace to your Nx Cloud account:',
|
|
47
47
|
`- Login at ${(0, nx_cloud_utils_1.getNxCloudUrl)(nxJson)} to connect your repository`,
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.yargsInitCommand = void 0;
|
|
4
4
|
const shared_options_1 = require("../yargs-utils/shared-options");
|
|
5
|
-
const
|
|
5
|
+
const useV2 = process.env['NX_ADD_PLUGINS'] !== 'false';
|
|
6
6
|
exports.yargsInitCommand = {
|
|
7
7
|
command: 'init',
|
|
8
8
|
describe: 'Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up remote caching. For more info, check https://nx.dev/recipes/adopting-nx.',
|
|
9
9
|
builder: (yargs) => withInitOptions(yargs),
|
|
10
10
|
handler: async (args) => {
|
|
11
|
-
if (
|
|
11
|
+
if (useV2) {
|
|
12
12
|
await require('./init-v2').initHandler(args);
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
@@ -18,7 +18,7 @@ exports.yargsInitCommand = {
|
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
20
|
function withInitOptions(yargs) {
|
|
21
|
-
if (
|
|
21
|
+
if (useV2) {
|
|
22
22
|
return yargs
|
|
23
23
|
.option('nxCloud', {
|
|
24
24
|
type: 'boolean',
|
|
@@ -114,5 +114,5 @@ function setupDotNxInstallation(version) {
|
|
|
114
114
|
}
|
|
115
115
|
(0, add_nx_scripts_1.generateDotNxSetup)(version);
|
|
116
116
|
// invokes the wrapper, thus invoking the initial installation process
|
|
117
|
-
(0, child_process_2.runNxSync)('');
|
|
117
|
+
(0, child_process_2.runNxSync)('--version');
|
|
118
118
|
}
|
|
@@ -32,7 +32,7 @@ async function initHandler(options) {
|
|
|
32
32
|
(0, child_process_1.runNxSync)('');
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
// TODO(jack): Remove this Angular logic once `@nx/
|
|
35
|
+
// TODO(jack): Remove this Angular logic once `@nx/angular` is compatible with inferred targets.
|
|
36
36
|
if ((0, fs_1.existsSync)('angular.json')) {
|
|
37
37
|
await (0, angular_1.addNxToAngularCliRepo)({
|
|
38
38
|
...options,
|
|
@@ -64,7 +64,7 @@ async function initHandler(options) {
|
|
|
64
64
|
}
|
|
65
65
|
if (useNxCloud) {
|
|
66
66
|
output_1.output.log({ title: '🛠️ Setting up Nx Cloud' });
|
|
67
|
-
(0, child_process_2.execSync)(`${pmc.exec} nx g nx:connect-to-nx-cloud --installationSource=nx-init
|
|
67
|
+
(0, child_process_2.execSync)(`${pmc.exec} nx g nx:connect-to-nx-cloud --installationSource=nx-init --quiet --hideFormatLogs --no-interactive`, {
|
|
68
68
|
stdio: [0, 1, 2],
|
|
69
69
|
cwd: repoRoot,
|
|
70
70
|
});
|
|
@@ -68,6 +68,7 @@ exports.commandsObject = yargs
|
|
|
68
68
|
.command(command_object_16.yargsShowCommand)
|
|
69
69
|
.command(command_object_2.yargsViewLogsCommand)
|
|
70
70
|
.command(command_object_17.yargsWatchCommand)
|
|
71
|
+
.command(command_object_14.yargsNxInfixCommand)
|
|
71
72
|
.scriptName('nx')
|
|
72
73
|
.help()
|
|
73
74
|
// NOTE: we handle --version in nx.ts, this just tells yargs that the option exists
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.yargsRunCommand = void 0;
|
|
3
|
+
exports.yargsNxInfixCommand = exports.yargsRunCommand = void 0;
|
|
4
4
|
const shared_options_1 = require("../yargs-utils/shared-options");
|
|
5
5
|
exports.yargsRunCommand = {
|
|
6
6
|
command: 'run [project][:target][:configuration] [_..]',
|
|
@@ -14,3 +14,12 @@ exports.yargsRunCommand = {
|
|
|
14
14
|
builder: (yargs) => (0, shared_options_1.withRunOneOptions)((0, shared_options_1.withBatch)(yargs)),
|
|
15
15
|
handler: async (args) => (await Promise.resolve().then(() => require('./run-one'))).runOne(process.cwd(), (0, shared_options_1.withOverrides)(args)),
|
|
16
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Handles the infix notation for running a target.
|
|
19
|
+
*/
|
|
20
|
+
exports.yargsNxInfixCommand = {
|
|
21
|
+
...exports.yargsRunCommand,
|
|
22
|
+
command: '$0 <target> [project] [_..]',
|
|
23
|
+
describe: 'Run a target for a project',
|
|
24
|
+
handler: async (args) => (await Promise.resolve().then(() => require('./run-one'))).runOne(process.cwd(), (0, shared_options_1.withOverrides)(args, 0)),
|
|
25
|
+
};
|
|
@@ -77,7 +77,7 @@ function parseRunOneOptions(cwd, parsedArgs, projectGraph, nxJson) {
|
|
|
77
77
|
let project;
|
|
78
78
|
let target;
|
|
79
79
|
let configuration;
|
|
80
|
-
if (parsedArgs['project:target:configuration']
|
|
80
|
+
if (parsedArgs['project:target:configuration']?.indexOf(':') > -1) {
|
|
81
81
|
// run case
|
|
82
82
|
[project, target, configuration] = (0, split_target_1.splitTarget)(parsedArgs['project:target:configuration'], projectGraph);
|
|
83
83
|
// this is to account for "nx npmsript:dev"
|
|
@@ -87,7 +87,7 @@ function parseRunOneOptions(cwd, parsedArgs, projectGraph, nxJson) {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
else {
|
|
90
|
-
target = parsedArgs['project:target:configuration'];
|
|
90
|
+
target = parsedArgs.target ?? parsedArgs['project:target:configuration'];
|
|
91
91
|
}
|
|
92
92
|
if (parsedArgs.project) {
|
|
93
93
|
project = parsedArgs.project;
|
|
@@ -17,6 +17,7 @@ export interface RunOptions {
|
|
|
17
17
|
cloud: boolean;
|
|
18
18
|
dte: boolean;
|
|
19
19
|
batch: boolean;
|
|
20
|
+
useAgents: boolean;
|
|
20
21
|
}
|
|
21
22
|
export declare function withRunOptions<T>(yargs: Argv<T>): Argv<T & RunOptions>;
|
|
22
23
|
export declare function withTargetAndConfigurationOption(yargs: Argv, demandOption?: boolean): Argv<{
|
|
@@ -68,6 +68,11 @@ function withRunOptions(yargs) {
|
|
|
68
68
|
.options('dte', {
|
|
69
69
|
type: 'boolean',
|
|
70
70
|
hidden: true,
|
|
71
|
+
})
|
|
72
|
+
.options('useAgents', {
|
|
73
|
+
type: 'boolean',
|
|
74
|
+
hidden: true,
|
|
75
|
+
alias: 'agents',
|
|
71
76
|
});
|
|
72
77
|
}
|
|
73
78
|
exports.withRunOptions = withRunOptions;
|
|
@@ -273,7 +278,10 @@ function parseCSV(args) {
|
|
|
273
278
|
return [];
|
|
274
279
|
}
|
|
275
280
|
if (Array.isArray(args)) {
|
|
276
|
-
|
|
281
|
+
// If parseCSV is used on `type: 'array'`, the first option may be something like ['a,b,c'].
|
|
282
|
+
return args.length === 1 && args[0].includes(',')
|
|
283
|
+
? parseCSV(args[0])
|
|
284
|
+
: args;
|
|
277
285
|
}
|
|
278
286
|
const items = args.split(',');
|
|
279
287
|
return items.map((i) => i.startsWith('"') && i.endsWith('"') ? i.slice(1, -1) : i);
|