nx 21.0.0-beta.8 → 21.0.0-beta.9
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 +5 -35
- package/package.json +11 -11
- package/schemas/nx-schema.json +34 -38
- 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/command-object.d.ts +6 -0
- package/src/command-line/release/config/config.js +15 -8
- package/src/command-line/release/config/use-legacy-versioning.js +4 -4
- package/src/command-line/release/version/release-group-processor.d.ts +10 -9
- package/src/command-line/release/version/release-group-processor.js +25 -8
- package/src/command-line/release/version/test-utils.d.ts +2 -4
- package/src/command-line/release/version/test-utils.js +13 -14
- package/src/command-line/release/version/version-actions.d.ts +9 -8
- package/src/command-line/release/version/version-actions.js +21 -9
- package/src/command-line/release/version.js +6 -2
- package/src/command-line/repair/repair.js +0 -1
- package/src/config/misc-interfaces.d.ts +0 -1
- package/src/config/nx-json.d.ts +15 -9
- package/src/config/workspace-json-project-json.d.ts +2 -2
- package/src/core/graph/main.js +1 -1
- package/src/migrations/{update-17-0-0/rm-default-collection-npm-scope.d.ts → update-21-0-0/release-version-config-changes.d.ts} +1 -1
- package/src/migrations/update-21-0-0/release-version-config-changes.js +111 -0
- 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/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/tasks-runner/task-orchestrator.js +3 -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.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
@@ -1,2 +1,2 @@
|
|
1
|
-
import { Tree } from '../../generators/tree';
|
1
|
+
import type { Tree } from '../../generators/tree';
|
2
2
|
export default function update(tree: Tree): Promise<void>;
|
@@ -0,0 +1,111 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = update;
|
4
|
+
const node_path_1 = require("node:path");
|
5
|
+
const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
|
6
|
+
const json_1 = require("../../generators/utils/json");
|
7
|
+
const nx_json_1 = require("../../generators/utils/nx-json");
|
8
|
+
const project_configuration_1 = require("../../generators/utils/project-configuration");
|
9
|
+
async function update(tree) {
|
10
|
+
const nxJson = (0, nx_json_1.readNxJson)(tree);
|
11
|
+
if (!nxJson) {
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
// If the user has explicitly set the useLegacyVersioning property to true, do nothing
|
15
|
+
if (nxJson.release?.version?.useLegacyVersioning === true) {
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
function updateProperties(versionConfig) {
|
19
|
+
// If the user is using a generator other than the @nx/js one, set useLegacyVersioning to true and nothing else
|
20
|
+
if ('generator' in versionConfig &&
|
21
|
+
versionConfig.generator !== '@nx/js:release-version') {
|
22
|
+
versionConfig.useLegacyVersioning =
|
23
|
+
true;
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
// These options used to live inside of generatorOptions, but are now like for like top-level nx core options
|
27
|
+
const coreOptionsToPromoteToTopLevel = [
|
28
|
+
'specifierSource',
|
29
|
+
'currentVersionResolver',
|
30
|
+
'currentVersionResolverMetadata',
|
31
|
+
'fallbackCurrentVersionResolver',
|
32
|
+
'versionPrefix',
|
33
|
+
'updateDependents',
|
34
|
+
'logUnchangedProjects',
|
35
|
+
];
|
36
|
+
if ('generatorOptions' in versionConfig) {
|
37
|
+
for (const option of coreOptionsToPromoteToTopLevel) {
|
38
|
+
if (versionConfig.generatorOptions[option]) {
|
39
|
+
versionConfig[option] = versionConfig.generatorOptions[option];
|
40
|
+
}
|
41
|
+
}
|
42
|
+
// preserveLocalDependencyProtocols has changed to true by default, so remove it if explicitly true, otherwise set to false explicitly
|
43
|
+
if (versionConfig.generatorOptions.preserveLocalDependencyProtocols) {
|
44
|
+
delete versionConfig.generatorOptions.preserveLocalDependencyProtocols;
|
45
|
+
}
|
46
|
+
else {
|
47
|
+
versionConfig.preserveLocalDependencyProtocols = false;
|
48
|
+
}
|
49
|
+
// packageRoot has been replaced by manifestRootsToUpdate
|
50
|
+
if (typeof versionConfig.generatorOptions.packageRoot === 'string') {
|
51
|
+
versionConfig.manifestRootsToUpdate =
|
52
|
+
[versionConfig.generatorOptions.packageRoot];
|
53
|
+
delete versionConfig.generatorOptions.packageRoot;
|
54
|
+
}
|
55
|
+
// These options have been moved to versionActionsOptions
|
56
|
+
const versionActionsOptions = [
|
57
|
+
'skipLockFileUpdate',
|
58
|
+
'installArgs',
|
59
|
+
'installIgnoreScripts',
|
60
|
+
];
|
61
|
+
for (const option of versionActionsOptions) {
|
62
|
+
if (versionConfig.generatorOptions[option]) {
|
63
|
+
versionConfig.versionActionsOptions =
|
64
|
+
versionConfig
|
65
|
+
.versionActionsOptions || {};
|
66
|
+
versionConfig.versionActionsOptions[option] =
|
67
|
+
versionConfig.generatorOptions[option];
|
68
|
+
delete versionConfig.generatorOptions[option];
|
69
|
+
}
|
70
|
+
}
|
71
|
+
delete versionConfig.generatorOptions;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
// nx.json
|
75
|
+
if (nxJson.release) {
|
76
|
+
// Top level version config
|
77
|
+
if (nxJson.release.version) {
|
78
|
+
updateProperties(nxJson.release.version);
|
79
|
+
}
|
80
|
+
// Version config for each group
|
81
|
+
if (nxJson.release.groups) {
|
82
|
+
for (const group of Object.values(nxJson.release.groups)) {
|
83
|
+
if (group.version) {
|
84
|
+
updateProperties(group.version);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
// project.json or package.json
|
90
|
+
const projects = (0, project_configuration_1.getProjects)(tree);
|
91
|
+
for (const project of projects.values()) {
|
92
|
+
const projectJsonPath = (0, node_path_1.join)(project.root, 'project.json');
|
93
|
+
if (tree.exists(projectJsonPath)) {
|
94
|
+
const projectJson = (0, json_1.readJson)(tree, projectJsonPath);
|
95
|
+
if (projectJson.release?.version) {
|
96
|
+
updateProperties(projectJson.release.version);
|
97
|
+
(0, json_1.writeJson)(tree, projectJsonPath, projectJson);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
const packageJsonPath = (0, node_path_1.join)(project.root, 'package.json');
|
101
|
+
if (tree.exists(packageJsonPath)) {
|
102
|
+
const packageJson = (0, json_1.readJson)(tree, packageJsonPath);
|
103
|
+
if (packageJson.nx?.release?.version) {
|
104
|
+
updateProperties(packageJson.nx.release.version);
|
105
|
+
(0, json_1.writeJson)(tree, packageJsonPath, packageJson);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
(0, nx_json_1.updateNxJson)(tree, nxJson);
|
110
|
+
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
|
111
|
+
}
|
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
|
@@ -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
|
-
}
|
@@ -548,6 +548,9 @@ class TaskOrchestrator {
|
|
548
548
|
for (const { taskId, status } of taskResults) {
|
549
549
|
if (this.completedTasks[taskId] === undefined) {
|
550
550
|
this.completedTasks[taskId] = status;
|
551
|
+
if (this.tuiEnabled) {
|
552
|
+
this.options.lifeCycle.setTaskStatus(taskId, (0, native_1.parseTaskStatus)(status));
|
553
|
+
}
|
551
554
|
if (status === 'failure' || status === 'skipped') {
|
552
555
|
if (this.bail) {
|
553
556
|
// 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
|
-
}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = nxReleasePath;
|
4
|
-
exports.visitNotIgnoredFiles = visitNotIgnoredFiles;
|
5
|
-
const node_path_1 = require("node:path");
|
6
|
-
const ignore_1 = require("../../utils/ignore");
|
7
|
-
function nxReleasePath(tree) {
|
8
|
-
visitNotIgnoredFiles(tree, '', (file) => {
|
9
|
-
const contents = tree.read(file).toString('utf-8');
|
10
|
-
if (
|
11
|
-
// the deep import usage should be replaced by the new location
|
12
|
-
contents.includes('nx/src/command-line/release') ||
|
13
|
-
// changelog-renderer has moved into nx/release
|
14
|
-
contents.includes('nx/changelog-renderer')) {
|
15
|
-
const finalContents = contents
|
16
|
-
// replace instances of old changelog renderer location
|
17
|
-
.replace(/nx\/changelog-renderer/g, 'nx/release/changelog-renderer')
|
18
|
-
// replace instances of deep import for programmatic API (only perform the replacement if an actual import by checking for trailing ' or ")
|
19
|
-
.replace(/nx\/src\/command-line\/release(['"])/g, 'nx/release$1');
|
20
|
-
tree.write(file, finalContents);
|
21
|
-
}
|
22
|
-
});
|
23
|
-
}
|
24
|
-
// Adapted from devkit
|
25
|
-
function visitNotIgnoredFiles(tree, dirPath = tree.root, visitor) {
|
26
|
-
const ig = (0, ignore_1.getIgnoreObject)();
|
27
|
-
dirPath = normalizePathRelativeToRoot(dirPath, tree.root);
|
28
|
-
if (dirPath !== '' && ig?.ignores(dirPath)) {
|
29
|
-
return;
|
30
|
-
}
|
31
|
-
for (const child of tree.children(dirPath)) {
|
32
|
-
const fullPath = (0, node_path_1.join)(dirPath, child);
|
33
|
-
if (ig?.ignores(fullPath)) {
|
34
|
-
continue;
|
35
|
-
}
|
36
|
-
if (tree.isFile(fullPath)) {
|
37
|
-
visitor(fullPath);
|
38
|
-
}
|
39
|
-
else {
|
40
|
-
visitNotIgnoredFiles(tree, fullPath, visitor);
|
41
|
-
}
|
42
|
-
}
|
43
|
-
}
|
44
|
-
// Copied from devkit
|
45
|
-
function normalizePathRelativeToRoot(path, root) {
|
46
|
-
return (0, node_path_1.relative)(root, (0, node_path_1.join)(root, path)).split(node_path_1.sep).join('/');
|
47
|
-
}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = migrate;
|
4
|
-
const nx_json_1 = require("../../generators/utils/nx-json");
|
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) {
|
7
|
-
const nxJson = (0, nx_json_1.readNxJson)(tree);
|
8
|
-
nxJson.useInferencePlugins = false;
|
9
|
-
(0, nx_json_1.updateNxJson)(tree, nxJson);
|
10
|
-
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
|
11
|
-
}
|