nx 21.0.0-canary.20250425-ee097a8 → 21.0.0-canary.20250429-cf4a1f3
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/migrations.json +0 -35
- package/package.json +11 -11
- package/src/adapter/angular-json.js +11 -0
- package/src/command-line/migrate/migrate-ui-api.d.ts +2 -0
- package/src/command-line/migrate/migrate-ui-api.js +39 -0
- package/src/command-line/migrate/migrate.d.ts +0 -4
- package/src/command-line/migrate/migrate.js +8 -21
- package/src/command-line/release/version/release-group-processor.js +8 -0
- package/src/command-line/repair/repair.js +0 -1
- package/src/config/misc-interfaces.d.ts +0 -1
- package/src/core/graph/main.js +1 -1
- package/src/native/index.d.ts +2 -0
- package/src/native/native-bindings.js +1 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/index.d.ts +2 -1
- package/src/plugins/js/index.js +8 -1
- package/src/plugins/js/lock-file/utils/package-json.js +6 -5
- package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +3 -3
- package/src/project-graph/file-utils.d.ts +1 -10
- package/src/project-graph/file-utils.js +2 -77
- package/src/project-graph/plugins/loaded-nx-plugin.js +1 -5
- package/src/tasks-runner/run-command.js +32 -17
- package/src/tasks-runner/task-orchestrator.js +9 -0
- package/src/migrations/update-17-0-0/move-cache-directory.d.ts +0 -2
- package/src/migrations/update-17-0-0/move-cache-directory.js +0 -35
- package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.d.ts +0 -2
- package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +0 -72
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.d.ts +0 -2
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +0 -122
- package/src/migrations/update-17-2-0/move-default-base.d.ts +0 -5
- package/src/migrations/update-17-2-0/move-default-base.js +0 -21
- package/src/migrations/update-17-3-0/nx-release-path.d.ts +0 -3
- package/src/migrations/update-17-3-0/nx-release-path.js +0 -47
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +0 -2
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +0 -11
package/src/native/index.d.ts
CHANGED
@@ -254,6 +254,8 @@ export interface NxWorkspaceFilesExternals {
|
|
254
254
|
allWorkspaceFiles: ExternalObject<Array<FileData>>
|
255
255
|
}
|
256
256
|
|
257
|
+
export declare export declare function parseTaskStatus(stringStatus: string): TaskStatus
|
258
|
+
|
257
259
|
export interface Project {
|
258
260
|
root: string
|
259
261
|
namedInputs?: Record<string, Array<JsInputs>>
|
@@ -388,6 +388,7 @@ module.exports.getTransformableOutputs = nativeBinding.getTransformableOutputs
|
|
388
388
|
module.exports.hashArray = nativeBinding.hashArray
|
389
389
|
module.exports.hashFile = nativeBinding.hashFile
|
390
390
|
module.exports.IS_WASM = nativeBinding.IS_WASM
|
391
|
+
module.exports.parseTaskStatus = nativeBinding.parseTaskStatus
|
391
392
|
module.exports.remove = nativeBinding.remove
|
392
393
|
module.exports.restoreTerminal = nativeBinding.restoreTerminal
|
393
394
|
module.exports.TaskStatus = nativeBinding.TaskStatus
|
Binary file
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import { CreateDependencies, CreateNodes } from '../../project-graph/plugins';
|
1
|
+
import { CreateDependencies, CreateNodes, CreateNodesV2 } from '../../project-graph/plugins';
|
2
2
|
export declare const name = "nx/js/dependencies-and-lockfile";
|
3
|
+
export declare const createNodesV2: CreateNodesV2;
|
3
4
|
export declare const createNodes: CreateNodes;
|
4
5
|
export declare const createDependencies: CreateDependencies;
|
package/src/plugins/js/index.js
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.createDependencies = exports.createNodes = exports.name = void 0;
|
3
|
+
exports.createDependencies = exports.createNodes = exports.createNodesV2 = exports.name = void 0;
|
4
4
|
const fs_1 = require("fs");
|
5
5
|
const path_1 = require("path");
|
6
6
|
const perf_hooks_1 = require("perf_hooks");
|
7
7
|
const cache_directory_1 = require("../../utils/cache-directory");
|
8
8
|
const globs_1 = require("../../utils/globs");
|
9
|
+
const plugins_1 = require("../../project-graph/plugins");
|
9
10
|
const lock_file_1 = require("./lock-file/lock-file");
|
10
11
|
const build_dependencies_1 = require("./project-graph/build-dependencies/build-dependencies");
|
11
12
|
const config_1 = require("./utils/config");
|
@@ -16,6 +17,12 @@ const versions_1 = require("../../utils/versions");
|
|
16
17
|
const child_process_1 = require("child_process");
|
17
18
|
exports.name = 'nx/js/dependencies-and-lockfile';
|
18
19
|
let parsedLockFile = {};
|
20
|
+
exports.createNodesV2 = [
|
21
|
+
(0, globs_1.combineGlobPatterns)(lock_file_1.LOCKFILES),
|
22
|
+
(files, _, context) => {
|
23
|
+
return (0, plugins_1.createNodesFromFiles)(exports.createNodes[1], files, _, context);
|
24
|
+
},
|
25
|
+
];
|
19
26
|
exports.createNodes = [
|
20
27
|
// Look for all lockfiles
|
21
28
|
(0, globs_1.combineGlobPatterns)(lock_file_1.LOCKFILES),
|
@@ -2,18 +2,19 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getHoistedPackageVersion = getHoistedPackageVersion;
|
4
4
|
exports.normalizePackageJson = normalizePackageJson;
|
5
|
-
const fs_1 = require("fs");
|
6
5
|
const workspace_root_1 = require("../../../../utils/workspace-root");
|
6
|
+
const fileutils_1 = require("../../../../utils/fileutils");
|
7
7
|
/**
|
8
8
|
* Get version of hoisted package if available
|
9
9
|
*/
|
10
10
|
function getHoistedPackageVersion(packageName) {
|
11
11
|
const fullPath = `${workspace_root_1.workspaceRoot}/node_modules/${packageName}/package.json`;
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
try {
|
13
|
+
return (0, fileutils_1.readJsonFile)(fullPath)?.version;
|
14
|
+
}
|
15
|
+
catch (e) {
|
16
|
+
return;
|
15
17
|
}
|
16
|
-
return;
|
17
18
|
}
|
18
19
|
/**
|
19
20
|
* Strip off non-pruning related fields from package.json
|
@@ -9,7 +9,7 @@ exports.usesLeadingDash = usesLeadingDash;
|
|
9
9
|
exports.loadPnpmHoistedDepsDefinition = loadPnpmHoistedDepsDefinition;
|
10
10
|
exports.parseAndNormalizePnpmLockfile = parseAndNormalizePnpmLockfile;
|
11
11
|
exports.stringifyToPnpmYaml = stringifyToPnpmYaml;
|
12
|
-
const
|
12
|
+
const node_fs_1 = require("node:fs");
|
13
13
|
const semver_1 = require("semver");
|
14
14
|
const workspace_root_1 = require("../../../../utils/workspace-root");
|
15
15
|
const file_hasher_1 = require("../../../../hasher/file-hasher");
|
@@ -31,8 +31,8 @@ function usesLeadingDash(data) {
|
|
31
31
|
}
|
32
32
|
function loadPnpmHoistedDepsDefinition() {
|
33
33
|
const fullPath = `${workspace_root_1.workspaceRoot}/node_modules/.modules.yaml`;
|
34
|
-
if ((0,
|
35
|
-
const content = (0,
|
34
|
+
if ((0, node_fs_1.existsSync)(fullPath)) {
|
35
|
+
const content = (0, node_fs_1.readFileSync)(fullPath, 'utf-8');
|
36
36
|
const { load } = require('@zkochan/js-yaml');
|
37
37
|
return load(content)?.hoistedDependencies ?? {};
|
38
38
|
}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import { FileData } from '../config/project-graph';
|
2
|
-
import { ProjectsConfigurations } from '../config/workspace-json-project-json';
|
1
|
+
import type { FileData } from '../config/project-graph';
|
3
2
|
import type { NxArgs } from '../utils/command-line-utils';
|
4
3
|
export interface Change {
|
5
4
|
type: string;
|
@@ -17,14 +16,6 @@ export declare function isWholeFileChange(change: Change): change is WholeFileCh
|
|
17
16
|
export declare function isDeletedFileChange(change: Change): change is DeletedFileChange;
|
18
17
|
export declare function calculateFileChanges(files: string[], allWorkspaceFiles: FileData[], nxArgs?: NxArgs, readFileAtRevision?: (f: string, r: void | string) => string, ignore?: ReturnType<typeof ignore>): FileChange[];
|
19
18
|
export declare const TEN_MEGABYTES: number;
|
20
|
-
/**
|
21
|
-
* TODO(v21): Remove this function
|
22
|
-
* @deprecated To get projects use {@link retrieveProjectConfigurations} instead. This will be removed in v21.
|
23
|
-
*/
|
24
|
-
export declare function readWorkspaceConfig(opts: {
|
25
|
-
format: 'angularCli' | 'nx';
|
26
|
-
path?: string;
|
27
|
-
}): ProjectsConfigurations;
|
28
19
|
export declare function defaultFileRead(filePath: string): string | null;
|
29
20
|
export declare function readPackageJson(root?: string): any;
|
30
21
|
export { FileData };
|
@@ -4,23 +4,15 @@ exports.TEN_MEGABYTES = exports.DeletedFileChange = exports.WholeFileChange = vo
|
|
4
4
|
exports.isWholeFileChange = isWholeFileChange;
|
5
5
|
exports.isDeletedFileChange = isDeletedFileChange;
|
6
6
|
exports.calculateFileChanges = calculateFileChanges;
|
7
|
-
exports.readWorkspaceConfig = readWorkspaceConfig;
|
8
7
|
exports.defaultFileRead = defaultFileRead;
|
9
8
|
exports.readPackageJson = readPackageJson;
|
10
9
|
const child_process_1 = require("child_process");
|
11
10
|
const fs_1 = require("fs");
|
12
11
|
const path_1 = require("path");
|
13
|
-
const configuration_1 = require("../config/configuration");
|
14
|
-
const workspace_root_1 = require("../utils/workspace-root");
|
15
12
|
const fileutils_1 = require("../utils/fileutils");
|
16
|
-
const json_diff_1 = require("../utils/json-diff");
|
17
|
-
const project_graph_1 = require("./project-graph");
|
18
|
-
const angular_json_1 = require("../adapter/angular-json");
|
19
13
|
const ignore_1 = require("../utils/ignore");
|
20
|
-
const
|
21
|
-
const
|
22
|
-
const workspace_context_1 = require("../utils/workspace-context");
|
23
|
-
const project_json_1 = require("../plugins/project-json/build-nodes/project-json");
|
14
|
+
const json_diff_1 = require("../utils/json-diff");
|
15
|
+
const workspace_root_1 = require("../utils/workspace-root");
|
24
16
|
class WholeFileChange {
|
25
17
|
constructor() {
|
26
18
|
this.type = 'WholeFileChange';
|
@@ -100,34 +92,6 @@ function defaultReadFileAtRevision(file, revision) {
|
|
100
92
|
return '';
|
101
93
|
}
|
102
94
|
}
|
103
|
-
/**
|
104
|
-
* TODO(v21): Remove this function
|
105
|
-
* @deprecated To get projects use {@link retrieveProjectConfigurations} instead. This will be removed in v21.
|
106
|
-
*/
|
107
|
-
function readWorkspaceConfig(opts) {
|
108
|
-
let configuration = null;
|
109
|
-
const root = opts.path || process.cwd();
|
110
|
-
const nxJson = (0, configuration_1.readNxJson)(root);
|
111
|
-
try {
|
112
|
-
const projectGraph = (0, project_graph_1.readCachedProjectGraph)();
|
113
|
-
configuration = {
|
114
|
-
...nxJson,
|
115
|
-
...(0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph),
|
116
|
-
};
|
117
|
-
}
|
118
|
-
catch {
|
119
|
-
configuration = {
|
120
|
-
version: 2,
|
121
|
-
projects: getProjectsSync(root, nxJson),
|
122
|
-
};
|
123
|
-
}
|
124
|
-
if (opts.format === 'angularCli') {
|
125
|
-
return (0, angular_json_1.toOldFormat)(configuration);
|
126
|
-
}
|
127
|
-
else {
|
128
|
-
return configuration;
|
129
|
-
}
|
130
|
-
}
|
131
95
|
function defaultFileRead(filePath) {
|
132
96
|
return (0, fs_1.readFileSync)((0, path_1.join)(workspace_root_1.workspaceRoot, filePath), 'utf-8');
|
133
97
|
}
|
@@ -139,42 +103,3 @@ function readPackageJson(root = workspace_root_1.workspaceRoot) {
|
|
139
103
|
return {}; // if package.json doesn't exist
|
140
104
|
}
|
141
105
|
}
|
142
|
-
/**
|
143
|
-
* TODO(v21): Remove this function.
|
144
|
-
*/
|
145
|
-
function getProjectsSync(root, nxJson) {
|
146
|
-
/**
|
147
|
-
* We can't update projects that come from plugins anyways, so we are going
|
148
|
-
* to ignore them for now. Plugins should add their own add/create/update methods
|
149
|
-
* if they would like to use devkit to update inferred projects.
|
150
|
-
*/
|
151
|
-
const patterns = [
|
152
|
-
'**/project.json',
|
153
|
-
'project.json',
|
154
|
-
...(0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(root, fileutils_1.readJsonFile),
|
155
|
-
];
|
156
|
-
const projectFiles = (0, workspace_context_1.globWithWorkspaceContextSync)(root, patterns);
|
157
|
-
const isInPackageJsonWorkspaces = (0, package_json_1.buildPackageJsonWorkspacesMatcher)(root, (f) => (0, fileutils_1.readJsonFile)((0, path_1.join)(root, f)));
|
158
|
-
const rootMap = {};
|
159
|
-
for (const projectFile of projectFiles) {
|
160
|
-
if ((0, path_1.basename)(projectFile) === 'project.json') {
|
161
|
-
const json = (0, fileutils_1.readJsonFile)(projectFile);
|
162
|
-
const config = (0, project_json_1.buildProjectFromProjectJson)(json, projectFile);
|
163
|
-
(0, project_configuration_utils_1.mergeProjectConfigurationIntoRootMap)(rootMap, config, undefined, undefined, true);
|
164
|
-
}
|
165
|
-
else if ((0, path_1.basename)(projectFile) === 'package.json') {
|
166
|
-
const packageJson = (0, fileutils_1.readJsonFile)(projectFile);
|
167
|
-
const config = (0, package_json_1.buildProjectConfigurationFromPackageJson)(packageJson, root, projectFile, nxJson, isInPackageJsonWorkspaces(projectFile));
|
168
|
-
if (!rootMap[config.root]) {
|
169
|
-
(0, project_configuration_utils_1.mergeProjectConfigurationIntoRootMap)(rootMap,
|
170
|
-
// Inferred targets, tags, etc don't show up when running generators
|
171
|
-
// This is to help avoid running into issues when trying to update the workspace
|
172
|
-
{
|
173
|
-
name: config.name,
|
174
|
-
root: config.root,
|
175
|
-
}, undefined, undefined, true);
|
176
|
-
}
|
177
|
-
}
|
178
|
-
}
|
179
|
-
return (0, project_configuration_utils_1.readProjectConfigurationsFromRootMap)(rootMap);
|
180
|
-
}
|
@@ -2,7 +2,6 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.LoadedNxPlugin = void 0;
|
4
4
|
const error_types_1 = require("../error-types");
|
5
|
-
const utils_1 = require("./utils");
|
6
5
|
const enabled_1 = require("./isolation/enabled");
|
7
6
|
const client_1 = require("../../daemon/client/client");
|
8
7
|
class LoadedNxPlugin {
|
@@ -14,10 +13,7 @@ class LoadedNxPlugin {
|
|
14
13
|
this.exclude = pluginDefinition.exclude;
|
15
14
|
}
|
16
15
|
if (plugin.createNodes && !plugin.createNodesV2) {
|
17
|
-
|
18
|
-
plugin.createNodes[0],
|
19
|
-
(configFiles, context) => (0, utils_1.createNodesFromFiles)(plugin.createNodes[1], configFiles, this.options, context).then((results) => results.map((r) => [this.name, r[0], r[1]])),
|
20
|
-
];
|
16
|
+
throw new Error(`Plugin ${plugin.name} only provides \`createNodes\` which was removed in Nx 21, it should provide a \`createNodesV2\` implementation.`);
|
21
17
|
}
|
22
18
|
if (plugin.createNodesV2) {
|
23
19
|
this.createNodes = [
|
@@ -194,6 +194,13 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
|
|
194
194
|
}
|
195
195
|
return {
|
196
196
|
lifeCycle: new life_cycle_1.CompositeLifeCycle(lifeCycles),
|
197
|
+
restoreTerminal: () => {
|
198
|
+
process.stdout.write = originalStdoutWrite;
|
199
|
+
process.stderr.write = originalStderrWrite;
|
200
|
+
console.log = originalConsoleLog;
|
201
|
+
console.error = originalConsoleError;
|
202
|
+
restoreTerminal();
|
203
|
+
},
|
197
204
|
printSummary,
|
198
205
|
renderIsDone,
|
199
206
|
};
|
@@ -289,24 +296,32 @@ async function runCommandForTasks(projectsToRun, currentProjectGraph, { nxJson }
|
|
289
296
|
const tasks = Object.values(taskGraph.tasks);
|
290
297
|
const initiatingTasks = tasks.filter((t) => projectNameSet.has(t.target.project) &&
|
291
298
|
nxArgs.targets.includes(t.target.target));
|
292
|
-
const { lifeCycle, renderIsDone, printSummary } = await getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, projectNames, tasks, taskGraph, nxArgs, nxJson, overrides);
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
printSummary
|
299
|
+
const { lifeCycle, renderIsDone, printSummary, restoreTerminal } = await getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, projectNames, tasks, taskGraph, nxArgs, nxJson, overrides);
|
300
|
+
try {
|
301
|
+
const taskResults = await invokeTasksRunner({
|
302
|
+
tasks,
|
303
|
+
projectGraph,
|
304
|
+
taskGraph,
|
305
|
+
lifeCycle,
|
306
|
+
nxJson,
|
307
|
+
nxArgs,
|
308
|
+
loadDotEnvFiles: extraOptions.loadDotEnvFiles,
|
309
|
+
initiatingProject,
|
310
|
+
initiatingTasks,
|
311
|
+
});
|
312
|
+
await renderIsDone;
|
313
|
+
if (printSummary) {
|
314
|
+
printSummary();
|
315
|
+
}
|
316
|
+
await (0, nx_key_1.printNxKey)();
|
317
|
+
return taskResults;
|
318
|
+
}
|
319
|
+
catch (e) {
|
320
|
+
if (restoreTerminal) {
|
321
|
+
restoreTerminal();
|
322
|
+
}
|
323
|
+
throw e;
|
307
324
|
}
|
308
|
-
await (0, nx_key_1.printNxKey)();
|
309
|
-
return taskResults;
|
310
325
|
}
|
311
326
|
async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, projectNames, nxArgs, overrides, extraTargetDependencies, extraOptions) {
|
312
327
|
let taskGraph = createTaskGraphAndRunValidations(projectGraph, extraTargetDependencies ?? {}, projectNames, nxArgs, overrides, extraOptions);
|
@@ -421,6 +421,9 @@ class TaskOrchestrator {
|
|
421
421
|
const runningTask = new shared_running_task_1.SharedRunningTask(this.runningTasksService, task.id);
|
422
422
|
this.runningContinuousTasks.set(task.id, runningTask);
|
423
423
|
runningTask.onExit(() => {
|
424
|
+
if (this.tuiEnabled) {
|
425
|
+
this.options.lifeCycle.setTaskStatus(task.id, 9 /* NativeTaskStatus.Stopped */);
|
426
|
+
}
|
424
427
|
this.runningContinuousTasks.delete(task.id);
|
425
428
|
});
|
426
429
|
// task is already running by another process, we schedule the next tasks
|
@@ -457,6 +460,9 @@ class TaskOrchestrator {
|
|
457
460
|
this.runningTasksService.addRunningTask(task.id);
|
458
461
|
this.runningContinuousTasks.set(task.id, childProcess);
|
459
462
|
childProcess.onExit(() => {
|
463
|
+
if (this.tuiEnabled) {
|
464
|
+
this.options.lifeCycle.setTaskStatus(task.id, 9 /* NativeTaskStatus.Stopped */);
|
465
|
+
}
|
460
466
|
this.runningTasksService.removeRunningTask(task.id);
|
461
467
|
this.runningContinuousTasks.delete(task.id);
|
462
468
|
});
|
@@ -548,6 +554,9 @@ class TaskOrchestrator {
|
|
548
554
|
for (const { taskId, status } of taskResults) {
|
549
555
|
if (this.completedTasks[taskId] === undefined) {
|
550
556
|
this.completedTasks[taskId] = status;
|
557
|
+
if (this.tuiEnabled) {
|
558
|
+
this.options.lifeCycle.setTaskStatus(taskId, (0, native_1.parseTaskStatus)(status));
|
559
|
+
}
|
551
560
|
if (status === 'failure' || status === 'skipped') {
|
552
561
|
if (this.bail) {
|
553
562
|
// mark the execution as bailed which will stop all further execution
|
@@ -1,35 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = moveCacheDirectory;
|
4
|
-
const ignore_1 = require("ignore");
|
5
|
-
function moveCacheDirectory(tree) {
|
6
|
-
// If nx.json doesn't exist the repo can't utilize
|
7
|
-
// caching, so .nx/cache is less relevant. Lerna users
|
8
|
-
// that don't want to fully opt in to Nx at this time
|
9
|
-
// may also be caught off guard by the appearance of
|
10
|
-
// a .nx directory, so we are going to special case
|
11
|
-
// this for the time being.
|
12
|
-
if (tree.exists('lerna.json') && !tree.exists('nx.json')) {
|
13
|
-
return;
|
14
|
-
}
|
15
|
-
updateGitIgnore(tree);
|
16
|
-
if (tree.exists('.prettierignore')) {
|
17
|
-
const ignored = tree.read('.prettierignore', 'utf-8');
|
18
|
-
if (!ignored.includes('.nx/cache')) {
|
19
|
-
tree.write('.prettierignore', [ignored, '/.nx/cache'].join('\n'));
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}
|
23
|
-
function updateGitIgnore(tree) {
|
24
|
-
const gitignore = tree.exists('.gitignore')
|
25
|
-
? tree.read('.gitignore', 'utf-8')
|
26
|
-
: '';
|
27
|
-
const ig = (0, ignore_1.default)();
|
28
|
-
ig.add(gitignore);
|
29
|
-
if (!ig.ignores('.nx/cache')) {
|
30
|
-
const updatedLines = gitignore.length
|
31
|
-
? [gitignore, '.nx/cache']
|
32
|
-
: ['.nx/cache'];
|
33
|
-
tree.write('.gitignore', updatedLines.join('\n'));
|
34
|
-
}
|
35
|
-
}
|
@@ -1,72 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = update;
|
4
|
-
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
5
|
-
const nx_json_1 = require("../../generators/utils/nx-json");
|
6
|
-
const json_1 = require("../../generators/utils/json");
|
7
|
-
const output_1 = require("../../utils/output");
|
8
|
-
const path_1 = require("../../utils/path");
|
9
|
-
async function update(tree) {
|
10
|
-
if (!tree.exists('nx.json')) {
|
11
|
-
return;
|
12
|
-
}
|
13
|
-
const nxJson = (0, nx_json_1.readNxJson)(tree);
|
14
|
-
delete nxJson.cli?.['defaultCollection'];
|
15
|
-
if (nxJson?.cli && Object.keys(nxJson.cli).length < 1) {
|
16
|
-
delete nxJson.cli;
|
17
|
-
}
|
18
|
-
warnNpmScopeHasChanged(tree, nxJson);
|
19
|
-
delete nxJson['npmScope'];
|
20
|
-
(0, nx_json_1.updateNxJson)(tree, nxJson);
|
21
|
-
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
|
22
|
-
}
|
23
|
-
function warnNpmScopeHasChanged(tree, nxJson) {
|
24
|
-
const originalScope = nxJson['npmScope'];
|
25
|
-
// There was no original scope
|
26
|
-
if (!originalScope) {
|
27
|
-
return false;
|
28
|
-
}
|
29
|
-
// package.json does not exist
|
30
|
-
if (!tree.exists('package.json')) {
|
31
|
-
return false;
|
32
|
-
}
|
33
|
-
const newScope = getNpmScopeFromPackageJson(tree);
|
34
|
-
// New and Original scope are the same.
|
35
|
-
if (originalScope === newScope) {
|
36
|
-
return false;
|
37
|
-
}
|
38
|
-
const packageJsonName = (0, json_1.readJson)(tree, 'package.json').name;
|
39
|
-
if (newScope) {
|
40
|
-
output_1.output.warn({
|
41
|
-
title: 'npmScope has been removed from nx.json',
|
42
|
-
bodyLines: [
|
43
|
-
'This will now be read from package.json',
|
44
|
-
`Old value which was in nx.json: ${originalScope}`,
|
45
|
-
`New value from package.json: ${newScope}`,
|
46
|
-
`Typescript path mappings for new libraries will now be generated as such: @${newScope}/new-lib instead of @${originalScope}/new-lib`,
|
47
|
-
`If you would like to change this back, change the name in package.json to ${packageJsonName.replace(newScope, originalScope)}`,
|
48
|
-
],
|
49
|
-
});
|
50
|
-
}
|
51
|
-
else {
|
52
|
-
// There is no scope in package.json
|
53
|
-
output_1.output.warn({
|
54
|
-
title: 'npmScope has been removed from nx.json',
|
55
|
-
bodyLines: [
|
56
|
-
'This will now be read from package.json',
|
57
|
-
`Old value which was in nx.json: ${originalScope}`,
|
58
|
-
`New value from package.json: null`,
|
59
|
-
`Typescript path mappings for new libraries will now be generated as such: new-lib instead of @${originalScope}/new-lib`,
|
60
|
-
`If you would like to change this back, change the name in package.json to ${(0, path_1.joinPathFragments)(`@${originalScope}`, packageJsonName)}`,
|
61
|
-
],
|
62
|
-
});
|
63
|
-
}
|
64
|
-
}
|
65
|
-
function getNpmScopeFromPackageJson(tree) {
|
66
|
-
const { name } = tree.exists('package.json')
|
67
|
-
? (0, json_1.readJson)(tree, 'package.json')
|
68
|
-
: { name: null };
|
69
|
-
if (name?.startsWith('@')) {
|
70
|
-
return name.split('/')[0].substring(1);
|
71
|
-
}
|
72
|
-
}
|
@@ -1,122 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = migrate;
|
4
|
-
const json_1 = require("../../generators/utils/json");
|
5
|
-
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
6
|
-
const nx_json_1 = require("../../generators/utils/nx-json");
|
7
|
-
const update_manager_1 = require("../../nx-cloud/update-manager");
|
8
|
-
const run_command_1 = require("../../tasks-runner/run-command");
|
9
|
-
const output_1 = require("../../utils/output");
|
10
|
-
async function migrate(tree) {
|
11
|
-
if (!tree.exists('nx.json')) {
|
12
|
-
return;
|
13
|
-
}
|
14
|
-
const nxJson = (0, nx_json_1.readNxJson)(tree);
|
15
|
-
// Already migrated
|
16
|
-
if (!nxJson.tasksRunnerOptions?.default) {
|
17
|
-
return;
|
18
|
-
}
|
19
|
-
const nxCloudClientSupported = await isNxCloudClientSupported(nxJson);
|
20
|
-
(0, json_1.updateJson)(tree, 'nx.json', (nxJson) => {
|
21
|
-
const { runner, options } = nxJson.tasksRunnerOptions.default;
|
22
|
-
// This property shouldn't ever be part of tasks runner options.
|
23
|
-
if (options.useDaemonProcess !== undefined) {
|
24
|
-
nxJson.useDaemonProcess = options.useDaemonProcess;
|
25
|
-
delete options.useDaemonProcess;
|
26
|
-
}
|
27
|
-
// Remaining keys may be specific to a given runner, so leave them alone if there are multiple runners.
|
28
|
-
if (Object.keys(nxJson.tasksRunnerOptions ?? {}).length > 1) {
|
29
|
-
return nxJson;
|
30
|
-
}
|
31
|
-
// These options can only be moved for nx-cloud.
|
32
|
-
if (runner === 'nx-cloud' || runner === '@nrwl/nx-cloud') {
|
33
|
-
nxJson.nxCloudAccessToken = options.accessToken;
|
34
|
-
delete options.accessToken;
|
35
|
-
if (options.url) {
|
36
|
-
nxJson.nxCloudUrl = options.url;
|
37
|
-
delete options.url;
|
38
|
-
}
|
39
|
-
if (nxCloudClientSupported) {
|
40
|
-
removeNxCloudDependency(tree);
|
41
|
-
}
|
42
|
-
else {
|
43
|
-
options.useLightClient = false;
|
44
|
-
}
|
45
|
-
if (options.encryptionKey) {
|
46
|
-
nxJson.nxCloudEncryptionKey = options.encryptionKey;
|
47
|
-
delete options.encryptionKey;
|
48
|
-
}
|
49
|
-
}
|
50
|
-
// These options should be safe to move for all tasks runners:
|
51
|
-
if (options.parallel !== undefined) {
|
52
|
-
nxJson.parallel = options.parallel;
|
53
|
-
delete options.parallel;
|
54
|
-
}
|
55
|
-
if (options.cacheDirectory !== undefined) {
|
56
|
-
nxJson.cacheDirectory = options.cacheDirectory;
|
57
|
-
delete options.cacheDirectory;
|
58
|
-
}
|
59
|
-
if (Array.isArray(options.cacheableOperations)) {
|
60
|
-
nxJson.targetDefaults ??= {};
|
61
|
-
for (const target of options.cacheableOperations) {
|
62
|
-
nxJson.targetDefaults[target] ??= {};
|
63
|
-
nxJson.targetDefaults[target].cache ??= true;
|
64
|
-
}
|
65
|
-
delete options.cacheableOperations;
|
66
|
-
}
|
67
|
-
if (['nx-cloud', '@nrwl/nx-cloud', 'nx/tasks-runners/default'].includes(runner)) {
|
68
|
-
delete nxJson.tasksRunnerOptions.default.runner;
|
69
|
-
if (Object.values(options).length === 0) {
|
70
|
-
delete nxJson.tasksRunnerOptions;
|
71
|
-
}
|
72
|
-
}
|
73
|
-
return nxJson;
|
74
|
-
});
|
75
|
-
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
|
76
|
-
}
|
77
|
-
async function isNxCloudClientSupported(nxJson) {
|
78
|
-
const nxCloudOptions = (0, run_command_1.getRunnerOptions)('default', nxJson, {}, true);
|
79
|
-
// Non enterprise workspaces support the Nx Cloud Client
|
80
|
-
if (!isNxCloudEnterpriseWorkspace(nxJson)) {
|
81
|
-
return true;
|
82
|
-
}
|
83
|
-
// If we can get the nx cloud client, it's supported
|
84
|
-
try {
|
85
|
-
await (0, update_manager_1.verifyOrUpdateNxCloudClient)(nxCloudOptions);
|
86
|
-
return true;
|
87
|
-
}
|
88
|
-
catch (e) {
|
89
|
-
if (e instanceof update_manager_1.NxCloudEnterpriseOutdatedError) {
|
90
|
-
output_1.output.warn({
|
91
|
-
title: 'Nx Cloud Instance is outdated.',
|
92
|
-
bodyLines: [
|
93
|
-
'If you are an Nx Enterprise customer, please reach out to your assigned Developer Productivity Engineer.',
|
94
|
-
'If you are NOT an Nx Enterprise customer but are seeing this message, please reach out to cloud-support@nrwl.io.',
|
95
|
-
],
|
96
|
-
});
|
97
|
-
}
|
98
|
-
return false;
|
99
|
-
}
|
100
|
-
}
|
101
|
-
function isNxCloudEnterpriseWorkspace(nxJson) {
|
102
|
-
const { runner, options } = nxJson.tasksRunnerOptions.default;
|
103
|
-
return ((runner === 'nx-cloud' || runner === '@nrwl/nx-cloud') &&
|
104
|
-
options.url &&
|
105
|
-
![
|
106
|
-
'https://nx.app',
|
107
|
-
'https://cloud.nx.app',
|
108
|
-
'https://staging.nx.app',
|
109
|
-
'https://snapshot.nx.app',
|
110
|
-
].includes(options.url));
|
111
|
-
}
|
112
|
-
function removeNxCloudDependency(tree) {
|
113
|
-
if (tree.exists('package.json')) {
|
114
|
-
(0, json_1.updateJson)(tree, 'package.json', (packageJson) => {
|
115
|
-
delete packageJson.dependencies?.['nx-cloud'];
|
116
|
-
delete packageJson.devDependencies?.['nx-cloud'];
|
117
|
-
delete packageJson.dependencies?.['@nrwl/nx-cloud'];
|
118
|
-
delete packageJson.devDependencies?.['@nrwl/nx-cloud'];
|
119
|
-
return packageJson;
|
120
|
-
});
|
121
|
-
}
|
122
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = update;
|
4
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
5
|
-
const nx_json_1 = require("../../generators/utils/nx-json");
|
6
|
-
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
7
|
-
/**
|
8
|
-
* Updates existing workspaces to move nx.json's affected.defaultBase to nx.json's base.
|
9
|
-
*/
|
10
|
-
async function update(host) {
|
11
|
-
const nxJson = (0, nx_json_1.readNxJson)(host);
|
12
|
-
if (nxJson?.affected?.defaultBase) {
|
13
|
-
nxJson.defaultBase = nxJson.affected.defaultBase;
|
14
|
-
delete nxJson.affected.defaultBase;
|
15
|
-
if (Object.keys(nxJson.affected).length === 0) {
|
16
|
-
delete nxJson.affected;
|
17
|
-
}
|
18
|
-
(0, nx_json_1.updateNxJson)(host, nxJson);
|
19
|
-
}
|
20
|
-
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(host);
|
21
|
-
}
|