nx 21.3.0 → 21.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -11
- package/src/command-line/init/implementation/add-nx-to-monorepo.d.ts +1 -1
- package/src/command-line/init/implementation/add-nx-to-monorepo.js +2 -2
- package/src/command-line/init/implementation/add-nx-to-npm-repo.d.ts +1 -1
- package/src/command-line/init/implementation/add-nx-to-npm-repo.js +2 -2
- package/src/command-line/init/implementation/utils.js +1 -5
- package/src/command-line/init/init-v2.js +44 -22
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -7
- package/src/utils/ab-testing.d.ts +3 -3
- package/src/utils/ab-testing.js +3 -3
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "21.3.
|
3
|
+
"version": "21.3.1",
|
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": {
|
@@ -83,16 +83,16 @@
|
|
83
83
|
}
|
84
84
|
},
|
85
85
|
"optionalDependencies": {
|
86
|
-
"@nx/nx-darwin-arm64": "21.3.
|
87
|
-
"@nx/nx-darwin-x64": "21.3.
|
88
|
-
"@nx/nx-freebsd-x64": "21.3.
|
89
|
-
"@nx/nx-linux-arm-gnueabihf": "21.3.
|
90
|
-
"@nx/nx-linux-arm64-gnu": "21.3.
|
91
|
-
"@nx/nx-linux-arm64-musl": "21.3.
|
92
|
-
"@nx/nx-linux-x64-gnu": "21.3.
|
93
|
-
"@nx/nx-linux-x64-musl": "21.3.
|
94
|
-
"@nx/nx-win32-arm64-msvc": "21.3.
|
95
|
-
"@nx/nx-win32-x64-msvc": "21.3.
|
86
|
+
"@nx/nx-darwin-arm64": "21.3.1",
|
87
|
+
"@nx/nx-darwin-x64": "21.3.1",
|
88
|
+
"@nx/nx-freebsd-x64": "21.3.1",
|
89
|
+
"@nx/nx-linux-arm-gnueabihf": "21.3.1",
|
90
|
+
"@nx/nx-linux-arm64-gnu": "21.3.1",
|
91
|
+
"@nx/nx-linux-arm64-musl": "21.3.1",
|
92
|
+
"@nx/nx-linux-x64-gnu": "21.3.1",
|
93
|
+
"@nx/nx-linux-x64-musl": "21.3.1",
|
94
|
+
"@nx/nx-win32-arm64-msvc": "21.3.1",
|
95
|
+
"@nx/nx-win32-x64-msvc": "21.3.1"
|
96
96
|
},
|
97
97
|
"nx-migrations": {
|
98
98
|
"migrations": "./migrations.json",
|
@@ -2,5 +2,5 @@ import { InitArgs } from '../init-v1';
|
|
2
2
|
type Options = Pick<InitArgs, 'nxCloud' | 'interactive' | 'cacheable'> & {
|
3
3
|
legacy?: boolean;
|
4
4
|
};
|
5
|
-
export declare function addNxToMonorepo(options: Options): Promise<void>;
|
5
|
+
export declare function addNxToMonorepo(options: Options, guided?: boolean): Promise<void>;
|
6
6
|
export {};
|
@@ -9,7 +9,7 @@ const fileutils_1 = require("../../../utils/fileutils");
|
|
9
9
|
const output_1 = require("../../../utils/output");
|
10
10
|
const utils_1 = require("./utils");
|
11
11
|
const connect_to_nx_cloud_1 = require("../../nx-cloud/connect/connect-to-nx-cloud");
|
12
|
-
async function addNxToMonorepo(options) {
|
12
|
+
async function addNxToMonorepo(options, guided = true) {
|
13
13
|
const repoRoot = process.cwd();
|
14
14
|
output_1.output.log({ title: '🐳 Nx initialization' });
|
15
15
|
const packageJsonFiles = allProjectPackageJsonFiles(repoRoot);
|
@@ -18,7 +18,7 @@ async function addNxToMonorepo(options) {
|
|
18
18
|
let cacheableOperations;
|
19
19
|
let scriptOutputs = {};
|
20
20
|
let useNxCloud;
|
21
|
-
if (options.interactive && scripts.length > 0) {
|
21
|
+
if (options.interactive && scripts.length > 0 && guided) {
|
22
22
|
output_1.output.log({
|
23
23
|
title: '🧑🔧 Please answer the following questions about the scripts found in your workspace in order to generate task runner configuration',
|
24
24
|
});
|
@@ -2,5 +2,5 @@ import { InitArgs } from '../init-v1';
|
|
2
2
|
type Options = Pick<InitArgs, 'nxCloud' | 'interactive' | 'cacheable'> & {
|
3
3
|
legacy?: boolean;
|
4
4
|
};
|
5
|
-
export declare function addNxToNpmRepo(options: Options): Promise<void>;
|
5
|
+
export declare function addNxToNpmRepo(options: Options, guided?: boolean): Promise<void>;
|
6
6
|
export {};
|
@@ -8,7 +8,7 @@ const output_1 = require("../../../utils/output");
|
|
8
8
|
const package_manager_1 = require("../../../utils/package-manager");
|
9
9
|
const utils_1 = require("./utils");
|
10
10
|
const connect_to_nx_cloud_1 = require("../../nx-cloud/connect/connect-to-nx-cloud");
|
11
|
-
async function addNxToNpmRepo(options) {
|
11
|
+
async function addNxToNpmRepo(options, guided = true) {
|
12
12
|
const repoRoot = process.cwd();
|
13
13
|
output_1.output.log({ title: '🐳 Nx initialization' });
|
14
14
|
let cacheableOperations;
|
@@ -16,7 +16,7 @@ async function addNxToNpmRepo(options) {
|
|
16
16
|
let useNxCloud;
|
17
17
|
const packageJson = (0, fileutils_1.readJsonFile)('package.json');
|
18
18
|
const scripts = Object.keys(packageJson.scripts ?? {}).filter((s) => !s.startsWith('pre') && !s.startsWith('post'));
|
19
|
-
if (options.interactive && scripts.length > 0) {
|
19
|
+
if (options.interactive && scripts.length > 0 && guided) {
|
20
20
|
output_1.output.log({
|
21
21
|
title: '🧑🔧 Please answer the following questions about the scripts found in your package.json in order to generate task runner configuration',
|
22
22
|
});
|
@@ -24,7 +24,6 @@ const connect_to_nx_cloud_1 = require("../../../nx-cloud/generators/connect-to-n
|
|
24
24
|
const url_shorten_1 = require("../../../nx-cloud/utilities/url-shorten");
|
25
25
|
const connect_to_nx_cloud_2 = require("../../nx-cloud/connect/connect-to-nx-cloud");
|
26
26
|
const deduce_default_base_1 = require("./deduce-default-base");
|
27
|
-
const child_process_2 = require("../../../utils/child-process");
|
28
27
|
function createNxJsonFile(repoRoot, topologicalTargets, cacheableOperations, scriptOutputs) {
|
29
28
|
const nxJsonPath = (0, path_2.joinPathFragments)(repoRoot, 'nx.json');
|
30
29
|
let nxJson = {};
|
@@ -263,13 +262,10 @@ function markPackageJsonAsNxProject(packageJsonPath) {
|
|
263
262
|
(0, fileutils_1.writeJsonFile)(packageJsonPath, json);
|
264
263
|
}
|
265
264
|
function printFinalMessage({ learnMoreLink, appendLines, }) {
|
266
|
-
const pmc = (0, package_manager_1.getPackageManagerCommand)();
|
267
265
|
output_1.output.success({
|
268
266
|
title: '🎉 Done!',
|
269
267
|
bodyLines: [
|
270
|
-
`-
|
271
|
-
`- Run "${(0, child_process_2.getRunNxBaseCommand)(pmc)} graph" to see the graph of projects and tasks in your workspace. https://nx.dev/core-features/explore-graph`,
|
272
|
-
learnMoreLink ? `- Learn more at ${learnMoreLink}.` : undefined,
|
268
|
+
`- Learn more about what to do next at ${learnMoreLink ?? 'https://nx.dev/getting-started/adding-to-existing'}`,
|
273
269
|
...(appendLines ?? []),
|
274
270
|
].filter(Boolean),
|
275
271
|
});
|
@@ -34,7 +34,7 @@ async function initHandler(options) {
|
|
34
34
|
integrated: !!options.integrated,
|
35
35
|
});
|
36
36
|
(0, utils_1.printFinalMessage)({
|
37
|
-
learnMoreLink: 'https://nx.dev/
|
37
|
+
learnMoreLink: 'https://nx.dev/technologies/angular/migration/angular',
|
38
38
|
});
|
39
39
|
return;
|
40
40
|
}
|
@@ -45,6 +45,21 @@ async function initHandler(options) {
|
|
45
45
|
const _isTurborepo = (0, fs_1.existsSync)('turbo.json');
|
46
46
|
const _isMonorepo = _isNonJs ? false : (0, utils_1.isMonorepo)(packageJson);
|
47
47
|
const _isCRA = _isNonJs ? false : (0, utils_1.isCRA)(packageJson);
|
48
|
+
let guided = true;
|
49
|
+
if (options.interactive && !(_isTurborepo || _isCRA || _isNonJs)) {
|
50
|
+
const setupType = await (0, enquirer_1.prompt)([
|
51
|
+
{
|
52
|
+
type: 'select',
|
53
|
+
name: 'setupPreference',
|
54
|
+
message: 'Would you like a minimum or guided setup?',
|
55
|
+
choices: [
|
56
|
+
{ name: 'Minimum', value: 'min' },
|
57
|
+
{ name: 'Guided', value: 'guided' },
|
58
|
+
],
|
59
|
+
},
|
60
|
+
]).then((r) => r.setupPreference);
|
61
|
+
guided = setupType === 'guided';
|
62
|
+
}
|
48
63
|
/**
|
49
64
|
* Turborepo users must have set up individual scripts already, and we keep the transition as minimal as possible.
|
50
65
|
* We log a message during the conversion process in addNxToTurborepo about how they can learn more about the power
|
@@ -75,7 +90,7 @@ async function initHandler(options) {
|
|
75
90
|
await (0, add_nx_to_monorepo_1.addNxToMonorepo)({
|
76
91
|
interactive: options.interactive,
|
77
92
|
nxCloud: false,
|
78
|
-
});
|
93
|
+
}, guided);
|
79
94
|
}
|
80
95
|
else if (_isNonJs) {
|
81
96
|
(0, add_nx_scripts_1.generateDotNxSetup)(version);
|
@@ -85,41 +100,48 @@ async function initHandler(options) {
|
|
85
100
|
await (0, add_nx_to_npm_repo_1.addNxToNpmRepo)({
|
86
101
|
interactive: options.interactive,
|
87
102
|
nxCloud: false,
|
88
|
-
});
|
103
|
+
}, guided);
|
89
104
|
}
|
90
|
-
const useNxCloud = options.nxCloud ??
|
91
|
-
(options.interactive ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)() : false);
|
92
105
|
const repoRoot = process.cwd();
|
93
106
|
(0, utils_1.createNxJsonFile)(repoRoot, [], [], {});
|
94
107
|
(0, utils_1.updateGitIgnore)(repoRoot);
|
95
108
|
const nxJson = (0, nx_json_1.readNxJson)(repoRoot);
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
109
|
+
if (guided) {
|
110
|
+
output_1.output.log({ title: '🧐 Checking dependencies' });
|
111
|
+
let plugins;
|
112
|
+
let updatePackageScripts;
|
113
|
+
if (_isCRA) {
|
114
|
+
plugins = ['@nx/vite'];
|
115
|
+
updatePackageScripts = true;
|
116
|
+
}
|
117
|
+
else {
|
118
|
+
const { plugins: _plugins, updatePackageScripts: _updatePackageScripts } = await detectPlugins(nxJson, options.interactive);
|
119
|
+
plugins = _plugins;
|
120
|
+
updatePackageScripts = _updatePackageScripts;
|
121
|
+
}
|
122
|
+
output_1.output.log({ title: '📦 Installing Nx' });
|
123
|
+
(0, configure_plugins_1.installPluginPackages)(repoRoot, pmc, plugins);
|
124
|
+
await (0, configure_plugins_1.configurePlugins)(plugins, updatePackageScripts, pmc, repoRoot, options.verbose);
|
102
125
|
}
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
126
|
+
let useNxCloud = options.nxCloud;
|
127
|
+
if (useNxCloud === undefined) {
|
128
|
+
output_1.output.log({ title: '🛠️ Setting up Self-Healing CI and Remote Caching' });
|
129
|
+
useNxCloud = options.interactive
|
130
|
+
? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)()
|
131
|
+
: false;
|
107
132
|
}
|
108
|
-
output_1.output.log({ title: '📦 Installing Nx' });
|
109
|
-
(0, configure_plugins_1.installPluginPackages)(repoRoot, pmc, plugins);
|
110
|
-
await (0, configure_plugins_1.configurePlugins)(plugins, updatePackageScripts, pmc, repoRoot, options.verbose);
|
111
133
|
if (useNxCloud) {
|
112
|
-
output_1.output.log({ title: '🛠️ Setting up Nx Cloud' });
|
113
134
|
await (0, utils_1.initCloud)('nx-init');
|
114
135
|
}
|
115
136
|
(0, utils_1.printFinalMessage)({
|
137
|
+
learnMoreLink: _isMonorepo
|
138
|
+
? 'https://nx.dev/recipes/adopting-nx/adding-to-monorepo'
|
139
|
+
: 'https://nx.dev/getting-started/adding-to-existing',
|
116
140
|
appendLines: _isMonorepo
|
117
141
|
? [
|
118
142
|
`- Learn how Nx helps manage your TypeScript monorepo at https://nx.dev/features/maintain-ts-monorepos.`,
|
119
143
|
]
|
120
|
-
: [
|
121
|
-
`- Learn how Nx works with any type of project at https://nx.dev/recipes/adopting-nx/adding-to-existing-project.`,
|
122
|
-
],
|
144
|
+
: [],
|
123
145
|
});
|
124
146
|
}
|
125
147
|
const npmPackageToPluginMap = {
|
@@ -69,14 +69,10 @@ async function createNxCloudWorkspaceV2(workspaceName, installationSource, nxIni
|
|
69
69
|
async function printSuccessMessage(token, installationSource, usesGithub) {
|
70
70
|
const connectCloudUrl = await (0, url_shorten_1.createNxCloudOnboardingURL)(installationSource, token, usesGithub);
|
71
71
|
output_1.output.note({
|
72
|
-
title: `Your
|
72
|
+
title: `Your Self-Healing CI and Remote Caching setup is almost complete`,
|
73
73
|
bodyLines: [
|
74
|
-
`
|
75
|
-
|
76
|
-
`- Create a pull request for the changes.`,
|
77
|
-
`- Go to the following URL to connect your workspace to Nx Cloud:`,
|
78
|
-
'',
|
79
|
-
`${connectCloudUrl}`,
|
74
|
+
`1. Commit your changes and push a pull request to your repository.`,
|
75
|
+
`2. Go to Nx Cloud and finish the setup: ${connectCloudUrl}`,
|
80
76
|
],
|
81
77
|
});
|
82
78
|
return connectCloudUrl;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
export type MessageOptionKey = 'yes' | 'skip';
|
2
2
|
declare const messageOptions: {
|
3
3
|
readonly setupNxCloud: readonly [{
|
4
|
-
readonly code: "enable-
|
5
|
-
readonly message: "Would you like
|
4
|
+
readonly code: "enable-ci";
|
5
|
+
readonly message: "Would you like to enable AI-powered Self-Healing CI and Remote Caching?";
|
6
6
|
readonly initial: 0;
|
7
7
|
readonly choices: readonly [{
|
8
8
|
readonly value: "yes";
|
@@ -11,7 +11,7 @@ declare const messageOptions: {
|
|
11
11
|
readonly value: "skip";
|
12
12
|
readonly name: "Skip for now";
|
13
13
|
}];
|
14
|
-
readonly footer: "\
|
14
|
+
readonly footer: "\nLearn about it at https://nx.dev/nx-cloud";
|
15
15
|
readonly hint: "\n(it's free and can be disabled any time)";
|
16
16
|
}];
|
17
17
|
readonly setupViewLogs: readonly [{
|
package/src/utils/ab-testing.js
CHANGED
@@ -9,14 +9,14 @@ const get_cloud_options_1 = require("../nx-cloud/utilities/get-cloud-options");
|
|
9
9
|
const messageOptions = {
|
10
10
|
setupNxCloud: [
|
11
11
|
{
|
12
|
-
code: 'enable-
|
13
|
-
message: `Would you like
|
12
|
+
code: 'enable-ci',
|
13
|
+
message: `Would you like to enable AI-powered Self-Healing CI and Remote Caching?`,
|
14
14
|
initial: 0,
|
15
15
|
choices: [
|
16
16
|
{ value: 'yes', name: 'Yes' },
|
17
17
|
{ value: 'skip', name: 'Skip for now' },
|
18
18
|
],
|
19
|
-
footer: '\
|
19
|
+
footer: '\nLearn about it at https://nx.dev/nx-cloud',
|
20
20
|
hint: `\n(it's free and can be disabled any time)`,
|
21
21
|
},
|
22
22
|
],
|