nx 17.3.0-beta.5 → 17.3.0-beta.8

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.
Files changed (86) hide show
  1. package/bin/init-local.js +1 -31
  2. package/migrations.json +6 -0
  3. package/package.json +14 -13
  4. package/plugins/package-json.js +1 -1
  5. package/{changelog-renderer → release/changelog-renderer}/index.d.ts +3 -3
  6. package/{changelog-renderer → release/changelog-renderer}/index.js +2 -2
  7. package/release/index.d.ts +4 -0
  8. package/release/index.js +11 -0
  9. package/schemas/nx-schema.json +5 -0
  10. package/src/command-line/add/add.d.ts +2 -0
  11. package/src/command-line/add/add.js +165 -0
  12. package/src/command-line/add/command-object.d.ts +7 -0
  13. package/src/command-line/add/command-object.js +24 -0
  14. package/src/command-line/affected/affected.js +0 -3
  15. package/src/command-line/connect/connect-to-nx-cloud.d.ts +3 -1
  16. package/src/command-line/connect/connect-to-nx-cloud.js +38 -21
  17. package/src/command-line/connect/view-logs.js +5 -21
  18. package/src/command-line/examples.js +14 -0
  19. package/src/command-line/graph/graph.js +2 -2
  20. package/src/command-line/init/implementation/add-nx-to-monorepo.js +6 -2
  21. package/src/command-line/init/implementation/add-nx-to-nest.js +6 -2
  22. package/src/command-line/init/implementation/add-nx-to-npm-repo.js +6 -2
  23. package/src/command-line/init/implementation/angular/index.js +3 -1
  24. package/src/command-line/init/implementation/angular/legacy-angular-versions.js +6 -3
  25. package/src/command-line/init/implementation/dot-nx/nxw.js +47 -16
  26. package/src/command-line/init/implementation/react/index.js +4 -2
  27. package/src/command-line/init/implementation/utils.d.ts +0 -1
  28. package/src/command-line/init/implementation/utils.js +1 -24
  29. package/src/command-line/init/init-v2.js +11 -6
  30. package/src/command-line/migrate/migrate.js +1 -10
  31. package/src/command-line/nx-commands.js +2 -0
  32. package/src/command-line/release/config/config.d.ts +1 -1
  33. package/src/command-line/release/config/config.js +82 -5
  34. package/src/command-line/release/publish.js +0 -3
  35. package/src/command-line/release/version.d.ts +2 -0
  36. package/src/command-line/release/version.js +2 -1
  37. package/src/command-line/run/run-one.js +0 -3
  38. package/src/command-line/run-many/run-many.js +0 -3
  39. package/src/command-line/show/show.js +1 -1
  40. package/src/config/nx-json.d.ts +13 -2
  41. package/src/config/project-graph.d.ts +1 -1
  42. package/src/core/graph/3rdpartylicenses.txt +0 -50
  43. package/src/core/graph/main.js +1 -1
  44. package/src/core/graph/polyfills.js +1 -1
  45. package/src/core/graph/styles.css +1 -1
  46. package/src/generators/utils/glob.js +2 -2
  47. package/src/generators/utils/project-configuration.js +10 -6
  48. package/src/hasher/node-task-hasher-impl.js +3 -3
  49. package/src/hasher/task-hasher.js +3 -3
  50. package/src/migrations/update-15-8-2/update-nxw.js +2 -6
  51. package/src/migrations/update-17-3-0/nx-release-path.d.ts +3 -0
  52. package/src/migrations/update-17-3-0/nx-release-path.js +49 -0
  53. package/src/migrations/update-17-3-0/update-nxw.d.ts +2 -0
  54. package/src/migrations/update-17-3-0/update-nxw.js +7 -0
  55. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +4 -1
  56. package/src/plugins/js/index.d.ts +1 -1
  57. package/src/plugins/js/index.js +1 -1
  58. package/{plugins/package-json-workspaces.d.ts → src/plugins/package-json-workspaces/create-nodes.d.ts} +4 -4
  59. package/{plugins/package-json-workspaces.js → src/plugins/package-json-workspaces/create-nodes.js} +9 -9
  60. package/src/plugins/package-json-workspaces/index.d.ts +1 -0
  61. package/src/plugins/package-json-workspaces/index.js +4 -0
  62. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +1 -1
  63. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +5 -3
  64. package/src/plugins/project-json/build-nodes/project-json.d.ts +1 -1
  65. package/src/plugins/project-json/build-nodes/project-json.js +3 -3
  66. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +8 -0
  67. package/src/plugins/target-defaults/target-defaults-plugin.js +91 -0
  68. package/src/project-graph/affected/locators/project-glob-changes.js +2 -2
  69. package/src/project-graph/affected/locators/workspace-projects.js +2 -2
  70. package/src/project-graph/build-project-graph.js +1 -1
  71. package/src/project-graph/file-utils.js +3 -3
  72. package/src/project-graph/utils/normalize-project-nodes.d.ts +2 -3
  73. package/src/project-graph/utils/normalize-project-nodes.js +7 -12
  74. package/src/project-graph/utils/project-configuration-utils.d.ts +7 -2
  75. package/src/project-graph/utils/project-configuration-utils.js +23 -10
  76. package/src/project-graph/utils/retrieve-workspace-files.js +2 -2
  77. package/src/tasks-runner/run-command.d.ts +1 -1
  78. package/src/utils/ab-testing.d.ts +36 -2
  79. package/src/utils/ab-testing.js +34 -16
  80. package/src/utils/child-process.d.ts +5 -1
  81. package/src/utils/child-process.js +37 -1
  82. package/src/utils/find-matching-projects.js +2 -2
  83. package/src/utils/nx-plugin.deprecated.js +4 -2
  84. package/src/utils/nx-plugin.js +5 -3
  85. package/src/utils/update-nxw.d.ts +2 -0
  86. package/src/utils/update-nxw.js +12 -0
package/bin/init-local.js CHANGED
@@ -2,8 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rewriteTargetsAndProjects = exports.initLocal = void 0;
4
4
  const perf_hooks_1 = require("perf_hooks");
5
- const child_process_1 = require("child_process");
6
- const package_manager_1 = require("../src/utils/package-manager");
7
5
  const nx_commands_1 = require("../src/command-line/nx-commands");
8
6
  const strip_indents_1 = require("../src/utils/strip-indents");
9
7
  const Mod = require("module");
@@ -134,14 +132,7 @@ function isKnownCommand(command) {
134
132
  }
135
133
  function shouldDelegateToAngularCLI() {
136
134
  const command = process.argv[2];
137
- const commands = [
138
- 'add',
139
- 'analytics',
140
- 'config',
141
- 'doc',
142
- 'update',
143
- 'completion',
144
- ];
135
+ const commands = ['analytics', 'config', 'doc', 'update', 'completion'];
145
136
  return commands.indexOf(command) > -1;
146
137
  }
147
138
  function handleAngularCLIFallbacks(workspace) {
@@ -157,27 +148,6 @@ function handleAngularCLIFallbacks(workspace) {
157
148
  console.log(`Running "ng update" can still be useful in some dev workflows, so we aren't planning to remove it.`);
158
149
  console.log(`If you need to use it, run "FORCE_NG_UPDATE=true ng update".`);
159
150
  }
160
- else if (process.argv[2] === 'add') {
161
- console.log('Ng add is not natively supported by Nx');
162
- const pkg = process.argv[2] === 'add' ? process.argv[3] : process.argv[4];
163
- if (!pkg) {
164
- process.exit(1);
165
- }
166
- const pm = (0, package_manager_1.getPackageManagerCommand)();
167
- const cmd = `${pm.add} ${pkg} && ${pm.exec} nx g ${pkg}:ng-add`;
168
- console.log(`Instead, we recommend running \`${cmd}\``);
169
- Promise.resolve().then(() => require('enquirer')).then((x) => x
170
- .prompt({
171
- name: 'c',
172
- type: 'confirm',
173
- message: 'Run this command?',
174
- })
175
- .then(({ c }) => {
176
- if (c) {
177
- (0, child_process_1.execSync)(cmd, { stdio: 'inherit' });
178
- }
179
- }));
180
- }
181
151
  else if (process.argv[2] === 'completion') {
182
152
  if (!process.argv[3]) {
183
153
  console.log(`"ng completion" is not natively supported by Nx.
package/migrations.json CHANGED
@@ -82,6 +82,12 @@
82
82
  "version": "17.3.0-beta.3",
83
83
  "description": "Explicitly opt-out of git operations in nx release",
84
84
  "implementation": "./src/migrations/update-17-3-0/nx-release-git-operations-explicit-opt-out"
85
+ },
86
+ "17.3.0-update-nx-wrapper": {
87
+ "cli": "nx",
88
+ "version": "17.3.0-beta.6",
89
+ "description": "Updates the nx wrapper.",
90
+ "implementation": "./src/migrations/update-17-3-0/update-nxw"
85
91
  }
86
92
  }
87
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "17.3.0-beta.5",
3
+ "version": "17.3.0-beta.8",
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": {
@@ -52,7 +52,7 @@
52
52
  "js-yaml": "4.1.0",
53
53
  "jsonc-parser": "3.2.0",
54
54
  "lines-and-columns": "~2.0.3",
55
- "minimatch": "3.0.5",
55
+ "minimatch": "9.0.3",
56
56
  "npm-run-path": "^4.0.1",
57
57
  "open": "^8.4.0",
58
58
  "semver": "7.5.3",
@@ -65,7 +65,8 @@
65
65
  "yargs": "^17.6.2",
66
66
  "yargs-parser": "21.1.1",
67
67
  "node-machine-id": "1.1.12",
68
- "@nrwl/tao": "17.3.0-beta.5"
68
+ "ora": "5.3.0",
69
+ "@nrwl/tao": "17.3.0-beta.8"
69
70
  },
70
71
  "peerDependencies": {
71
72
  "@swc-node/register": "^1.6.7",
@@ -80,16 +81,16 @@
80
81
  }
81
82
  },
82
83
  "optionalDependencies": {
83
- "@nx/nx-darwin-x64": "17.3.0-beta.5",
84
- "@nx/nx-darwin-arm64": "17.3.0-beta.5",
85
- "@nx/nx-linux-x64-gnu": "17.3.0-beta.5",
86
- "@nx/nx-linux-x64-musl": "17.3.0-beta.5",
87
- "@nx/nx-win32-x64-msvc": "17.3.0-beta.5",
88
- "@nx/nx-linux-arm64-gnu": "17.3.0-beta.5",
89
- "@nx/nx-linux-arm64-musl": "17.3.0-beta.5",
90
- "@nx/nx-linux-arm-gnueabihf": "17.3.0-beta.5",
91
- "@nx/nx-win32-arm64-msvc": "17.3.0-beta.5",
92
- "@nx/nx-freebsd-x64": "17.3.0-beta.5"
84
+ "@nx/nx-darwin-x64": "17.3.0-beta.8",
85
+ "@nx/nx-darwin-arm64": "17.3.0-beta.8",
86
+ "@nx/nx-linux-x64-gnu": "17.3.0-beta.8",
87
+ "@nx/nx-linux-x64-musl": "17.3.0-beta.8",
88
+ "@nx/nx-win32-x64-msvc": "17.3.0-beta.8",
89
+ "@nx/nx-linux-arm64-gnu": "17.3.0-beta.8",
90
+ "@nx/nx-linux-arm64-musl": "17.3.0-beta.8",
91
+ "@nx/nx-linux-arm-gnueabihf": "17.3.0-beta.8",
92
+ "@nx/nx-win32-arm64-msvc": "17.3.0-beta.8",
93
+ "@nx/nx-freebsd-x64": "17.3.0-beta.8"
93
94
  },
94
95
  "nx-migrations": {
95
96
  "migrations": "./migrations.json",
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const workspace_root_1 = require("../src/utils/workspace-root");
4
- const package_json_workspaces_1 = require("./package-json-workspaces");
4
+ const package_json_workspaces_1 = require("../src/plugins/package-json-workspaces");
5
5
  const plugin = {
6
6
  name: 'nx-all-package-jsons-plugin',
7
7
  createNodes: [
@@ -1,6 +1,6 @@
1
- import type { GitCommit } from '../src/command-line/release/utils/git';
2
- import { RepoSlug } from '../src/command-line/release/utils/github';
3
- import type { ProjectGraph } from '../src/config/project-graph';
1
+ import type { GitCommit } from '../../src/command-line/release/utils/git';
2
+ import { RepoSlug } from '../../src/command-line/release/utils/github';
3
+ import type { ProjectGraph } from '../../src/config/project-graph';
4
4
  /**
5
5
  * The ChangelogRenderOptions are specific to each ChangelogRenderer implementation, and are taken
6
6
  * from the user's nx.json configuration and passed as is into the ChangelogRenderer function.
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const semver_1 = require("semver");
4
- const github_1 = require("../src/command-line/release/utils/github");
5
- const shared_1 = require("../src/command-line/release/utils/shared");
4
+ const github_1 = require("../../src/command-line/release/utils/github");
5
+ const shared_1 = require("../../src/command-line/release/utils/shared");
6
6
  // axios types and values don't seem to match
7
7
  const _axios = require("axios");
8
8
  const axios = _axios;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @public Programmatic API for nx release
3
+ */
4
+ export { release, releaseChangelog, releasePublish, releaseVersion, } from '../src/command-line/release';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.releaseVersion = exports.releasePublish = exports.releaseChangelog = exports.release = void 0;
4
+ /**
5
+ * @public Programmatic API for nx release
6
+ */
7
+ var release_1 = require("../src/command-line/release");
8
+ Object.defineProperty(exports, "release", { enumerable: true, get: function () { return release_1.release; } });
9
+ Object.defineProperty(exports, "releaseChangelog", { enumerable: true, get: function () { return release_1.releaseChangelog; } });
10
+ Object.defineProperty(exports, "releasePublish", { enumerable: true, get: function () { return release_1.releasePublish; } });
11
+ Object.defineProperty(exports, "releaseVersion", { enumerable: true, get: function () { return release_1.releaseVersion; } });
@@ -542,6 +542,11 @@
542
542
  "NxReleaseVersionConfiguration": {
543
543
  "type": "object",
544
544
  "properties": {
545
+ "conventionalCommits": {
546
+ "type": "boolean",
547
+ "description": "Shorthand for enabling the current version of projects to be resolved from git tags, and the next version to be determined by analyzing commit messages according to the Conventional Commits specification.",
548
+ "default": false
549
+ },
545
550
  "generator": {
546
551
  "type": "string"
547
552
  },
@@ -0,0 +1,2 @@
1
+ import type { AddOptions } from './command-object';
2
+ export declare function addHandler(options: AddOptions): Promise<void>;
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addHandler = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const fs_1 = require("fs");
6
+ const ora = require("ora");
7
+ const angular_json_1 = require("../../adapter/angular-json");
8
+ const nx_json_1 = require("../../config/nx-json");
9
+ const child_process_2 = require("../../utils/child-process");
10
+ const fileutils_1 = require("../../utils/fileutils");
11
+ const logger_1 = require("../../utils/logger");
12
+ const output_1 = require("../../utils/output");
13
+ const package_manager_1 = require("../../utils/package-manager");
14
+ const params_1 = require("../../utils/params");
15
+ const plugins_1 = require("../../utils/plugins");
16
+ const versions_1 = require("../../utils/versions");
17
+ const workspace_root_1 = require("../../utils/workspace-root");
18
+ function addHandler(options) {
19
+ if (options.verbose) {
20
+ process.env.NX_VERBOSE_LOGGING = 'true';
21
+ }
22
+ const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
23
+ return (0, params_1.handleErrors)(isVerbose, async () => {
24
+ output_1.output.addNewline();
25
+ const [pkgName, version] = parsePackageSpecifier(options.packageSpecifier);
26
+ await installPackage(pkgName, version);
27
+ await initializePlugin(pkgName, options);
28
+ output_1.output.success({
29
+ title: `Package ${pkgName} added successfully.`,
30
+ });
31
+ });
32
+ }
33
+ exports.addHandler = addHandler;
34
+ async function installPackage(pkgName, version) {
35
+ const spinner = ora(`Installing ${pkgName}@${version}...`);
36
+ spinner.start();
37
+ if ((0, fs_1.existsSync)('package.json')) {
38
+ const pmc = (0, package_manager_1.getPackageManagerCommand)();
39
+ await new Promise((resolve) => (0, child_process_1.exec)(`${pmc.addDev} ${pkgName}@${version}`, (error, stdout) => {
40
+ if (error) {
41
+ spinner.fail();
42
+ output_1.output.addNewline();
43
+ logger_1.logger.error(stdout);
44
+ output_1.output.error({
45
+ title: `Failed to install ${pkgName}. Please check the error above for more details.`,
46
+ });
47
+ process.exit(1);
48
+ }
49
+ return resolve();
50
+ }));
51
+ }
52
+ else {
53
+ const nxJson = (0, nx_json_1.readNxJson)();
54
+ nxJson.installation.plugins ??= {};
55
+ nxJson.installation.plugins[pkgName] = version;
56
+ (0, fileutils_1.writeJsonFile)('nx.json', nxJson);
57
+ try {
58
+ await (0, child_process_2.runNxAsync)('');
59
+ }
60
+ catch (e) {
61
+ // revert adding the plugin to nx.json
62
+ nxJson.installation.plugins[pkgName] = undefined;
63
+ (0, fileutils_1.writeJsonFile)('nx.json', nxJson);
64
+ spinner.fail();
65
+ output_1.output.addNewline();
66
+ logger_1.logger.error(e.message);
67
+ output_1.output.error({
68
+ title: `Failed to install ${pkgName}. Please check the error above for more details.`,
69
+ });
70
+ process.exit(1);
71
+ }
72
+ }
73
+ spinner.succeed();
74
+ }
75
+ async function initializePlugin(pkgName, options) {
76
+ const capabilities = await (0, plugins_1.getPluginCapabilities)(workspace_root_1.workspaceRoot, pkgName, {});
77
+ const generators = capabilities?.generators;
78
+ if (!generators) {
79
+ output_1.output.log({
80
+ title: `No generators found in ${pkgName}. Skipping initialization.`,
81
+ });
82
+ return;
83
+ }
84
+ const initGenerator = findInitGenerator(generators);
85
+ if (!initGenerator) {
86
+ output_1.output.log({
87
+ title: `No "init" generator found in ${pkgName}. Skipping initialization.`,
88
+ });
89
+ return;
90
+ }
91
+ const spinner = ora(`Initializing ${pkgName}...`);
92
+ spinner.start();
93
+ try {
94
+ let updatePackageScripts;
95
+ if (options.updatePackageScripts !== undefined) {
96
+ updatePackageScripts = options.updatePackageScripts;
97
+ }
98
+ else {
99
+ updatePackageScripts =
100
+ process.env.NX_PCV3 === 'true' && coreNxPlugins.includes(pkgName);
101
+ }
102
+ await (0, child_process_2.runNxAsync)(`g ${pkgName}:${initGenerator} --keepExistingVersions${updatePackageScripts ? ' --updatePackageScripts' : ''}`);
103
+ }
104
+ catch (e) {
105
+ spinner.fail();
106
+ output_1.output.addNewline();
107
+ logger_1.logger.error(e.message);
108
+ output_1.output.error({
109
+ title: `Failed to initialize ${pkgName}. Please check the error above for more details.`,
110
+ });
111
+ process.exit(1);
112
+ }
113
+ spinner.succeed();
114
+ }
115
+ function findInitGenerator(generators) {
116
+ if (generators['init']) {
117
+ return 'init';
118
+ }
119
+ const angularPluginInstalled = (0, angular_json_1.isAngularPluginInstalled)();
120
+ if (angularPluginInstalled && generators['ng-add']) {
121
+ return 'ng-add';
122
+ }
123
+ return Object.keys(generators).find((name) => generators[name].aliases?.includes('init') ||
124
+ (angularPluginInstalled && generators[name].aliases?.includes('ng-add')));
125
+ }
126
+ function parsePackageSpecifier(packageSpecifier) {
127
+ const i = packageSpecifier.lastIndexOf('@');
128
+ if (i <= 0) {
129
+ if (coreNxPlugins.includes(packageSpecifier)) {
130
+ return [packageSpecifier, versions_1.nxVersion];
131
+ }
132
+ return [packageSpecifier, 'latest'];
133
+ }
134
+ const pkgName = packageSpecifier.substring(0, i);
135
+ const version = packageSpecifier.substring(i + 1);
136
+ return [pkgName, version];
137
+ }
138
+ const coreNxPlugins = [
139
+ '@nx/angular',
140
+ '@nx/cypress',
141
+ '@nx/detox',
142
+ '@nx/devkit',
143
+ '@nx/esbuild',
144
+ '@nx/eslint',
145
+ '@nx/eslint-plugin',
146
+ '@nx/expo',
147
+ '@nx/express',
148
+ '@nx/jest',
149
+ '@nx/nest',
150
+ '@nx/next',
151
+ '@nx/node',
152
+ '@nx/nuxt',
153
+ '@nx/playwright',
154
+ '@nx/plugin',
155
+ '@nx/react',
156
+ '@nx/react-native',
157
+ '@nx/remix',
158
+ '@nx/rollup',
159
+ '@nx/storybook',
160
+ '@nx/vite',
161
+ '@nx/vue',
162
+ '@nx/web',
163
+ '@nx/webpack',
164
+ '@nx/workspace',
165
+ ];
@@ -0,0 +1,7 @@
1
+ import { CommandModule } from 'yargs';
2
+ export interface AddOptions {
3
+ packageSpecifier: string;
4
+ updatePackageScripts?: boolean;
5
+ verbose?: boolean;
6
+ }
7
+ export declare const yargsAddCommand: CommandModule<Record<string, unknown>, AddOptions>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.yargsAddCommand = void 0;
4
+ exports.yargsAddCommand = {
5
+ command: 'add <packageSpecifier>',
6
+ describe: 'Install a plugin and initialize it.',
7
+ builder: (yargs) => yargs
8
+ .positional('packageSpecifier', {
9
+ type: 'string',
10
+ description: 'The package name and optional version (e.g. `@nx/react` or `@nx/react@latest`) to install and initialize. If the version is not specified it will install the same version as the `nx` package for Nx core plugins or the latest version for other packages',
11
+ })
12
+ .option('updatePackageScripts', {
13
+ type: 'boolean',
14
+ description: 'Update `package.json` scripts with inferred targets. Defaults to `true` when `NX_PCV3=true` and the package is a core Nx plugin',
15
+ })
16
+ .option('verbose', {
17
+ type: 'boolean',
18
+ description: 'Prints additional information about the commands (e.g., stack traces)',
19
+ })
20
+ .example('$0 add @nx/react', 'Install the latest version of the `@nx/react` package and run its `@nx/react:init` generator')
21
+ .example('$0 add non-core-nx-plugin', 'Install the latest version of the `non-core-nx-plugin` package and run its `non-core-nx-plugin:init` generator if available')
22
+ .example('$0 add @nx/react@17.0.0', 'Install version `17.0.0` of the `@nx/react` package and run its `@nx/react:init` generator'),
23
+ handler: (args) => Promise.resolve().then(() => require('./add')).then((m) => m.addHandler(args)),
24
+ };
@@ -63,9 +63,6 @@ async function affected(command, args, extraTargetDependencies = {}) {
63
63
  }
64
64
  else {
65
65
  const status = await (0, run_command_1.runCommand)(projectsWithTarget, projectGraph, { nxJson }, nxArgs, overrides, null, extraTargetDependencies, { excludeTaskDependencies: false, loadDotEnvFiles: true });
66
- // fix for https://github.com/nrwl/nx/issues/1666
67
- if (process.stdin['unref'])
68
- process.stdin.unref();
69
66
  process.exit(status);
70
67
  }
71
68
  break;
@@ -1,6 +1,8 @@
1
1
  import { NxJsonConfiguration } from '../../config/nx-json';
2
2
  import { NxArgs } from '../../utils/command-line-utils';
3
+ import { MessageKey } from '../../utils/ab-testing';
3
4
  export declare function onlyDefaultRunnerIsUsed(nxJson: NxJsonConfiguration): boolean;
4
5
  export declare function connectToNxCloudIfExplicitlyAsked(opts: NxArgs): Promise<void>;
5
6
  export declare function connectToNxCloudCommand(): Promise<boolean>;
6
- export declare function connectToNxCloudPrompt(prompt?: string): Promise<boolean>;
7
+ export declare function connectToNxCloudWithPrompt(command: string): Promise<void>;
8
+ export declare function connectExistingRepoToNxCloudPrompt(key?: MessageKey): Promise<boolean>;
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.connectToNxCloudPrompt = exports.connectToNxCloudCommand = exports.connectToNxCloudIfExplicitlyAsked = exports.onlyDefaultRunnerIsUsed = void 0;
3
+ exports.connectExistingRepoToNxCloudPrompt = exports.connectToNxCloudWithPrompt = exports.connectToNxCloudCommand = exports.connectToNxCloudIfExplicitlyAsked = exports.onlyDefaultRunnerIsUsed = void 0;
4
4
  const output_1 = require("../../utils/output");
5
5
  const configuration_1 = require("../../config/configuration");
6
6
  const nx_cloud_utils_1 = require("../../utils/nx-cloud-utils");
7
7
  const child_process_1 = require("../../utils/child-process");
8
+ const ab_testing_1 = require("../../utils/ab-testing");
9
+ const versions_1 = require("../../utils/versions");
10
+ const chalk = require("chalk");
8
11
  function onlyDefaultRunnerIsUsed(nxJson) {
9
12
  const defaultRunner = nxJson.tasksRunnerOptions?.default?.runner;
10
13
  if (!defaultRunner) {
@@ -55,25 +58,39 @@ async function connectToNxCloudCommand() {
55
58
  return true;
56
59
  }
57
60
  exports.connectToNxCloudCommand = connectToNxCloudCommand;
58
- async function connectToNxCloudPrompt(prompt) {
61
+ async function connectToNxCloudWithPrompt(command) {
62
+ const setNxCloud = await nxCloudPrompt('setupNxCloud');
63
+ const useCloud = setNxCloud ? await connectToNxCloudCommand() : false;
64
+ await (0, ab_testing_1.recordStat)({
65
+ command,
66
+ nxVersion: versions_1.nxVersion,
67
+ useCloud,
68
+ meta: ab_testing_1.messages.codeOfSelectedPromptMessage('setupNxCloud'),
69
+ });
70
+ }
71
+ exports.connectToNxCloudWithPrompt = connectToNxCloudWithPrompt;
72
+ async function connectExistingRepoToNxCloudPrompt(key = 'setupNxCloud') {
73
+ return nxCloudPrompt(key).then((value) => value === 'yes');
74
+ }
75
+ exports.connectExistingRepoToNxCloudPrompt = connectExistingRepoToNxCloudPrompt;
76
+ async function nxCloudPrompt(key) {
77
+ const { message, choices, initial, footer, hint } = ab_testing_1.messages.getPrompt(key);
78
+ const promptConfig = {
79
+ name: 'NxCloud',
80
+ message,
81
+ type: 'autocomplete',
82
+ choices,
83
+ initial,
84
+ }; // meeroslav: types in enquirer are not up to date
85
+ if (footer) {
86
+ promptConfig.footer = () => chalk.dim(footer);
87
+ }
88
+ if (hint) {
89
+ promptConfig.hint = () => chalk.dim(hint);
90
+ }
59
91
  return await (await Promise.resolve().then(() => require('enquirer')))
60
- .prompt([
61
- {
62
- name: 'NxCloud',
63
- message: prompt ?? `Enable remote caching to make your CI faster`,
64
- type: 'autocomplete',
65
- choices: [
66
- {
67
- name: 'Yes',
68
- hint: 'I want faster builds',
69
- },
70
- {
71
- name: 'No',
72
- },
73
- ],
74
- initial: 'Yes',
75
- },
76
- ])
77
- .then((a) => a.NxCloud === 'Yes');
92
+ .prompt([promptConfig])
93
+ .then((a) => {
94
+ return a.NxCloud;
95
+ });
78
96
  }
79
- exports.connectToNxCloudPrompt = connectToNxCloudPrompt;
@@ -7,6 +7,7 @@ const nx_cloud_utils_1 = require("../../utils/nx-cloud-utils");
7
7
  const output_1 = require("../../utils/output");
8
8
  const child_process_2 = require("../../utils/child-process");
9
9
  const nx_json_1 = require("../../config/nx-json");
10
+ const connect_to_nx_cloud_1 = require("./connect-to-nx-cloud");
10
11
  async function viewLogs() {
11
12
  const cloudUsed = (0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)());
12
13
  if (cloudUsed) {
@@ -18,28 +19,10 @@ async function viewLogs() {
18
19
  });
19
20
  return 1;
20
21
  }
21
- const installCloud = await (await Promise.resolve().then(() => require('enquirer')))
22
- .prompt([
23
- {
24
- name: 'NxCloud',
25
- message: `To view the logs, Nx needs to connect your workspace to Nx Cloud and upload the most recent run details.`,
26
- type: 'autocomplete',
27
- choices: [
28
- {
29
- name: 'Yes',
30
- hint: 'Connect to Nx Cloud and upload the run details',
31
- },
32
- {
33
- name: 'No',
34
- },
35
- ],
36
- initial: 'Yes',
37
- },
38
- ])
39
- .then((a) => a.NxCloud === 'Yes');
40
- if (!installCloud)
22
+ const setupNxCloud = await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)('setupViewLogs');
23
+ if (!setupNxCloud) {
41
24
  return;
42
- const pmc = (0, package_manager_1.getPackageManagerCommand)();
25
+ }
43
26
  try {
44
27
  output_1.output.log({
45
28
  title: 'Connecting to Nx Cloud',
@@ -55,6 +38,7 @@ async function viewLogs() {
55
38
  console.log(e);
56
39
  return 1;
57
40
  }
41
+ const pmc = (0, package_manager_1.getPackageManagerCommand)();
58
42
  (0, child_process_1.execSync)(`${pmc.exec} nx-cloud upload-and-show-run-details`, {
59
43
  stdio: [0, 1, 2],
60
44
  });
@@ -326,4 +326,18 @@ exports.examples = {
326
326
  description: 'Watch all projects (including newly created projects) in the workspace',
327
327
  },
328
328
  ],
329
+ add: [
330
+ {
331
+ command: 'add @nx/react',
332
+ description: 'Install the `@nx/react` package matching the installed version of the `nx` package and run its `@nx/react:init` generator',
333
+ },
334
+ {
335
+ command: 'add non-core-nx-plugin',
336
+ description: 'Install the latest version of the `non-core-nx-plugin` package and run its `non-core-nx-plugin:init` generator if available',
337
+ },
338
+ {
339
+ command: 'add @nx/react@17.0.0',
340
+ description: 'Install version `17.0.0` of the `@nx/react` package and run its `@nx/react:init` generator',
341
+ },
342
+ ],
329
343
  };
@@ -5,7 +5,7 @@ const crypto_1 = require("crypto");
5
5
  const fs_1 = require("fs");
6
6
  const fs_extra_1 = require("fs-extra");
7
7
  const http = require("http");
8
- const minimatch = require("minimatch");
8
+ const minimatch_1 = require("minimatch");
9
9
  const node_url_1 = require("node:url");
10
10
  const open = require("open");
11
11
  const path_1 = require("path");
@@ -601,7 +601,7 @@ function expandInputs(inputs, project, allWorkspaceFiles, depGraphClientResponse
601
601
  }
602
602
  else {
603
603
  allWorkspaceFiles
604
- .filter((f) => minimatch(f.file, withoutWorkspaceRoot))
604
+ .filter((f) => (0, minimatch_1.minimatch)(f.file, withoutWorkspaceRoot))
605
605
  .forEach((f) => {
606
606
  matches.push(f.file);
607
607
  });
@@ -9,6 +9,7 @@ const fileutils_1 = require("../../../utils/fileutils");
9
9
  const output_1 = require("../../../utils/output");
10
10
  const package_manager_1 = require("../../../utils/package-manager");
11
11
  const utils_1 = require("./utils");
12
+ const connect_to_nx_cloud_1 = require("../../connect/connect-to-nx-cloud");
12
13
  async function addNxToMonorepo(options) {
13
14
  const repoRoot = process.cwd();
14
15
  output_1.output.log({ title: '🐳 Nx initialization' });
@@ -47,14 +48,17 @@ async function addNxToMonorepo(options) {
47
48
  },
48
49
  ]))[scriptName];
49
50
  }
50
- useNxCloud = options.nxCloud ?? (await (0, utils_1.askAboutNxCloud)());
51
+ useNxCloud =
52
+ options.nxCloud ?? (await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)());
51
53
  }
52
54
  else {
53
55
  targetDefaults = [];
54
56
  cacheableOperations = options.cacheable ?? [];
55
57
  useNxCloud =
56
58
  options.nxCloud ??
57
- (options.interactive ? await (0, utils_1.askAboutNxCloud)() : false);
59
+ (options.interactive
60
+ ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)()
61
+ : false);
58
62
  }
59
63
  (0, utils_1.createNxJsonFile)(repoRoot, targetDefaults, cacheableOperations, scriptOutputs);
60
64
  (0, utils_1.updateGitIgnore)(repoRoot);
@@ -9,6 +9,7 @@ const output_1 = require("../../../utils/output");
9
9
  const package_manager_1 = require("../../../utils/package-manager");
10
10
  const utils_1 = require("./utils");
11
11
  const versions_1 = require("../../../utils/versions");
12
+ const connect_to_nx_cloud_1 = require("../../connect/connect-to-nx-cloud");
12
13
  async function addNxToNest(options, packageJson) {
13
14
  const repoRoot = process.cwd();
14
15
  output_1.output.log({ title: '🐳 Nx initialization' });
@@ -61,13 +62,16 @@ async function addNxToNest(options, packageJson) {
61
62
  },
62
63
  ]))[scriptName];
63
64
  }
64
- useNxCloud = options.nxCloud ?? (await (0, utils_1.askAboutNxCloud)());
65
+ useNxCloud =
66
+ options.nxCloud ?? (await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)());
65
67
  }
66
68
  else {
67
69
  cacheableOperations = options.cacheable ?? [];
68
70
  useNxCloud =
69
71
  options.nxCloud ??
70
- (options.interactive ? await (0, utils_1.askAboutNxCloud)() : false);
72
+ (options.interactive
73
+ ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)()
74
+ : false);
71
75
  }
72
76
  (0, utils_1.createNxJsonFile)(repoRoot, [], [...cacheableOperations, ...nestCacheableScripts], {});
73
77
  const pmc = (0, package_manager_1.getPackageManagerCommand)();
@@ -6,6 +6,7 @@ const fileutils_1 = require("../../../utils/fileutils");
6
6
  const output_1 = require("../../../utils/output");
7
7
  const package_manager_1 = require("../../../utils/package-manager");
8
8
  const utils_1 = require("./utils");
9
+ const connect_to_nx_cloud_1 = require("../../connect/connect-to-nx-cloud");
9
10
  async function addNxToNpmRepo(options) {
10
11
  const repoRoot = process.cwd();
11
12
  output_1.output.log({ title: '🐳 Nx initialization' });
@@ -36,13 +37,16 @@ async function addNxToNpmRepo(options) {
36
37
  },
37
38
  ]))[scriptName];
38
39
  }
39
- useNxCloud = options.nxCloud ?? (await (0, utils_1.askAboutNxCloud)());
40
+ useNxCloud =
41
+ options.nxCloud ?? (await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)());
40
42
  }
41
43
  else {
42
44
  cacheableOperations = options.cacheable ?? [];
43
45
  useNxCloud =
44
46
  options.nxCloud ??
45
- (options.interactive ? await (0, utils_1.askAboutNxCloud)() : false);
47
+ (options.interactive
48
+ ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)()
49
+ : false);
46
50
  }
47
51
  (0, utils_1.createNxJsonFile)(repoRoot, [], cacheableOperations, {});
48
52
  const pmc = (0, package_manager_1.getPackageManagerCommand)();