nx 19.5.6 → 19.6.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +12 -12
- package/release/index.d.ts +1 -1
- package/release/index.js +2 -1
- package/schemas/nx-schema.json +3 -0
- package/src/adapter/compat.d.ts +1 -1
- package/src/adapter/compat.js +2 -0
- package/src/command-line/affected/affected.js +1 -1
- package/src/command-line/connect/connect-to-nx-cloud.js +7 -3
- package/src/command-line/release/changelog.d.ts +2 -7
- package/src/command-line/release/changelog.js +361 -347
- package/src/command-line/release/command-object.d.ts +1 -0
- package/src/command-line/release/command-object.js +14 -0
- package/src/command-line/release/config/deep-merge-json.d.ts +1 -0
- package/src/command-line/release/config/deep-merge-json.js +28 -0
- package/src/command-line/release/index.d.ts +16 -4
- package/src/command-line/release/index.js +23 -9
- package/src/command-line/release/plan.d.ts +2 -1
- package/src/command-line/release/plan.js +90 -77
- package/src/command-line/release/publish.d.ts +2 -6
- package/src/command-line/release/publish.js +67 -52
- package/src/command-line/release/release.d.ts +2 -1
- package/src/command-line/release/release.js +181 -165
- package/src/command-line/release/utils/print-config.d.ts +7 -0
- package/src/command-line/release/utils/print-config.js +36 -0
- package/src/command-line/release/version.d.ts +2 -6
- package/src/command-line/release/version.js +179 -165
- package/src/command-line/run/run-one.js +1 -1
- package/src/command-line/run-many/run-many.js +1 -1
- package/src/command-line/yargs-utils/shared-options.d.ts +1 -0
- package/src/command-line/yargs-utils/shared-options.js +5 -0
- package/src/commands-runner/create-command-graph.js +4 -2
- package/src/config/nx-json.d.ts +10 -1
- package/src/devkit-internals.d.ts +1 -1
- package/src/devkit-internals.js +2 -1
- package/src/generators/utils/project-configuration.js +41 -11
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +4 -2
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +61 -20
- package/src/nx-cloud/nx-cloud-tasks-runner-shell.d.ts +1 -0
- package/src/nx-cloud/utilities/axios.js +9 -2
- package/src/nx-cloud/utilities/get-cloud-options.d.ts +1 -1
- package/src/nx-cloud/utilities/get-cloud-options.js +3 -2
- package/src/plugins/package-json/create-nodes.js +9 -1
- package/src/project-graph/plugins/isolation/plugin-pool.js +32 -10
- package/src/project-graph/utils/project-configuration-utils.d.ts +1 -0
- package/src/project-graph/utils/project-configuration-utils.js +1 -0
- package/src/tasks-runner/cache.js +1 -1
- package/src/tasks-runner/run-command.js +6 -1
- package/src/tasks-runner/utils.js +14 -10
- package/src/utils/command-line-utils.d.ts +1 -0
- package/src/utils/nx-cloud-utils.js +3 -1
- package/src/utils/package-json.d.ts +2 -9
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.releaseVersionCLIHandler = exports.validReleaseVersionPrefixes = exports.deriveNewSemverVersion = void 0;
|
4
|
-
exports.
|
4
|
+
exports.createAPI = createAPI;
|
5
5
|
const chalk = require("chalk");
|
6
6
|
const node_child_process_1 = require("node:child_process");
|
7
7
|
const node_fs_1 = require("node:fs");
|
@@ -17,11 +17,13 @@ const workspace_root_1 = require("../../utils/workspace-root");
|
|
17
17
|
const generate_1 = require("../generate/generate");
|
18
18
|
const generator_utils_1 = require("../generate/generator-utils");
|
19
19
|
const config_1 = require("./config/config");
|
20
|
+
const deep_merge_json_1 = require("./config/deep-merge-json");
|
20
21
|
const filter_release_groups_1 = require("./config/filter-release-groups");
|
21
22
|
const version_plans_1 = require("./config/version-plans");
|
22
23
|
const batch_projects_by_generator_config_1 = require("./utils/batch-projects-by-generator-config");
|
23
24
|
const git_1 = require("./utils/git");
|
24
25
|
const print_changes_1 = require("./utils/print-changes");
|
26
|
+
const print_config_1 = require("./utils/print-config");
|
25
27
|
const resolve_nx_json_error_message_1 = require("./utils/resolve-nx-json-error-message");
|
26
28
|
const shared_1 = require("./utils/shared");
|
27
29
|
const LARGE_BUFFER = 1024 * 1000000;
|
@@ -29,78 +31,180 @@ const LARGE_BUFFER = 1024 * 1000000;
|
|
29
31
|
var semver_1 = require("./utils/semver");
|
30
32
|
Object.defineProperty(exports, "deriveNewSemverVersion", { enumerable: true, get: function () { return semver_1.deriveNewSemverVersion; } });
|
31
33
|
exports.validReleaseVersionPrefixes = ['auto', '', '~', '^', '='];
|
32
|
-
const releaseVersionCLIHandler = (args) => (0, params_1.handleErrors)(args.verbose, () =>
|
34
|
+
const releaseVersionCLIHandler = (args) => (0, params_1.handleErrors)(args.verbose, () => createAPI({})(args));
|
33
35
|
exports.releaseVersionCLIHandler = releaseVersionCLIHandler;
|
34
|
-
|
35
|
-
* NOTE: This function is also exported for programmatic usage and forms part of the public API
|
36
|
-
* of Nx. We intentionally do not wrap the implementation with handleErrors because users need
|
37
|
-
* to have control over their own error handling when using the API.
|
38
|
-
*/
|
39
|
-
async function releaseVersion(args) {
|
40
|
-
const projectGraph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
|
41
|
-
const { projects } = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
42
|
-
const nxJson = (0, nx_json_1.readNxJson)();
|
43
|
-
if (args.verbose) {
|
44
|
-
process.env.NX_VERBOSE_LOGGING = 'true';
|
45
|
-
}
|
46
|
-
// Apply default configuration to any optional user configuration
|
47
|
-
const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, await (0, file_map_utils_1.createProjectFileMapUsingProjectGraph)(projectGraph), nxJson.release);
|
48
|
-
if (configError) {
|
49
|
-
return await (0, config_1.handleNxReleaseConfigError)(configError);
|
50
|
-
}
|
51
|
-
// The nx release top level command will always override these three git args. This is how we can tell
|
52
|
-
// if the top level release command was used or if the user is using the changelog subcommand.
|
53
|
-
// If the user explicitly overrides these args, then it doesn't matter if the top level config is set,
|
54
|
-
// as all of the git options would be overridden anyway.
|
55
|
-
if ((args.gitCommit === undefined ||
|
56
|
-
args.gitTag === undefined ||
|
57
|
-
args.stageChanges === undefined) &&
|
58
|
-
nxJson.release?.git) {
|
59
|
-
const nxJsonMessage = await (0, resolve_nx_json_error_message_1.resolveNxJsonConfigErrorMessage)([
|
60
|
-
'release',
|
61
|
-
'git',
|
62
|
-
]);
|
63
|
-
output_1.output.error({
|
64
|
-
title: `The "release.git" property in nx.json may not be used with the "nx release version" subcommand or programmatic API. Instead, configure git options for subcommands directly with "release.version.git" and "release.changelog.git".`,
|
65
|
-
bodyLines: [nxJsonMessage],
|
66
|
-
});
|
67
|
-
process.exit(1);
|
68
|
-
}
|
69
|
-
const { error: filterError, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, args.projects, args.groups);
|
70
|
-
if (filterError) {
|
71
|
-
output_1.output.error(filterError);
|
72
|
-
process.exit(1);
|
73
|
-
}
|
74
|
-
const rawVersionPlans = await (0, version_plans_1.readRawVersionPlans)();
|
75
|
-
(0, version_plans_1.setVersionPlansOnGroups)(rawVersionPlans, releaseGroups, Object.keys(projectGraph.nodes));
|
76
|
-
if (args.deleteVersionPlans === undefined) {
|
77
|
-
// default to not delete version plans after versioning as they may be needed for changelog generation
|
78
|
-
args.deleteVersionPlans = false;
|
79
|
-
}
|
80
|
-
runPreVersionCommand(nxReleaseConfig.version.preVersionCommand, {
|
81
|
-
dryRun: args.dryRun,
|
82
|
-
verbose: args.verbose,
|
83
|
-
});
|
84
|
-
const tree = new tree_1.FsTree(workspace_root_1.workspaceRoot, args.verbose);
|
85
|
-
const versionData = {};
|
86
|
-
const commitMessage = args.gitCommitMessage || nxReleaseConfig.version.git.commitMessage;
|
87
|
-
const generatorCallbacks = [];
|
36
|
+
function createAPI(overrideReleaseConfig) {
|
88
37
|
/**
|
89
|
-
*
|
90
|
-
*
|
38
|
+
* NOTE: This function is also exported for programmatic usage and forms part of the public API
|
39
|
+
* of Nx. We intentionally do not wrap the implementation with handleErrors because users need
|
40
|
+
* to have control over their own error handling when using the API.
|
91
41
|
*/
|
92
|
-
|
93
|
-
|
94
|
-
|
42
|
+
return async function releaseVersion(args) {
|
43
|
+
const projectGraph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
|
44
|
+
const { projects } = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
45
|
+
const nxJson = (0, nx_json_1.readNxJson)();
|
46
|
+
const userProvidedReleaseConfig = (0, deep_merge_json_1.deepMergeJson)(nxJson.release ?? {}, overrideReleaseConfig ?? {});
|
47
|
+
if (args.verbose) {
|
48
|
+
process.env.NX_VERBOSE_LOGGING = 'true';
|
49
|
+
}
|
50
|
+
// Apply default configuration to any optional user configuration
|
51
|
+
const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, await (0, file_map_utils_1.createProjectFileMapUsingProjectGraph)(projectGraph), userProvidedReleaseConfig);
|
52
|
+
if (configError) {
|
53
|
+
return await (0, config_1.handleNxReleaseConfigError)(configError);
|
54
|
+
}
|
55
|
+
// --print-config exits directly as it is not designed to be combined with any other programmatic operations
|
56
|
+
if (args.printConfig) {
|
57
|
+
return (0, print_config_1.printConfigAndExit)({
|
58
|
+
userProvidedReleaseConfig,
|
59
|
+
nxReleaseConfig,
|
60
|
+
isDebug: args.printConfig === 'debug',
|
61
|
+
});
|
62
|
+
}
|
63
|
+
// The nx release top level command will always override these three git args. This is how we can tell
|
64
|
+
// if the top level release command was used or if the user is using the changelog subcommand.
|
65
|
+
// If the user explicitly overrides these args, then it doesn't matter if the top level config is set,
|
66
|
+
// as all of the git options would be overridden anyway.
|
67
|
+
if ((args.gitCommit === undefined ||
|
68
|
+
args.gitTag === undefined ||
|
69
|
+
args.stageChanges === undefined) &&
|
70
|
+
userProvidedReleaseConfig.git) {
|
71
|
+
const nxJsonMessage = await (0, resolve_nx_json_error_message_1.resolveNxJsonConfigErrorMessage)([
|
72
|
+
'release',
|
73
|
+
'git',
|
74
|
+
]);
|
75
|
+
output_1.output.error({
|
76
|
+
title: `The "release.git" property in nx.json may not be used with the "nx release version" subcommand or programmatic API. Instead, configure git options for subcommands directly with "release.version.git" and "release.changelog.git".`,
|
77
|
+
bodyLines: [nxJsonMessage],
|
78
|
+
});
|
79
|
+
process.exit(1);
|
80
|
+
}
|
81
|
+
const { error: filterError, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, args.projects, args.groups);
|
82
|
+
if (filterError) {
|
83
|
+
output_1.output.error(filterError);
|
84
|
+
process.exit(1);
|
85
|
+
}
|
86
|
+
const rawVersionPlans = await (0, version_plans_1.readRawVersionPlans)();
|
87
|
+
(0, version_plans_1.setVersionPlansOnGroups)(rawVersionPlans, releaseGroups, Object.keys(projectGraph.nodes));
|
88
|
+
if (args.deleteVersionPlans === undefined) {
|
89
|
+
// default to not delete version plans after versioning as they may be needed for changelog generation
|
90
|
+
args.deleteVersionPlans = false;
|
91
|
+
}
|
92
|
+
runPreVersionCommand(nxReleaseConfig.version.preVersionCommand, {
|
93
|
+
dryRun: args.dryRun,
|
94
|
+
verbose: args.verbose,
|
95
|
+
});
|
96
|
+
const tree = new tree_1.FsTree(workspace_root_1.workspaceRoot, args.verbose);
|
97
|
+
const versionData = {};
|
98
|
+
const commitMessage = args.gitCommitMessage || nxReleaseConfig.version.git.commitMessage;
|
99
|
+
const generatorCallbacks = [];
|
100
|
+
/**
|
101
|
+
* additionalChangedFiles are files which need to be updated as a side-effect of versioning (such as package manager lock files),
|
102
|
+
* and need to get staged and committed as part of the existing commit, if applicable.
|
103
|
+
*/
|
104
|
+
const additionalChangedFiles = new Set();
|
105
|
+
const additionalDeletedFiles = new Set();
|
106
|
+
if (args.projects?.length) {
|
107
|
+
/**
|
108
|
+
* Run versioning for all remaining release groups and filtered projects within them
|
109
|
+
*/
|
110
|
+
for (const releaseGroup of releaseGroups) {
|
111
|
+
const releaseGroupName = releaseGroup.name;
|
112
|
+
const releaseGroupProjectNames = Array.from(releaseGroupToFilteredProjects.get(releaseGroup));
|
113
|
+
const projectBatches = (0, batch_projects_by_generator_config_1.batchProjectsByGeneratorConfig)(projectGraph, releaseGroup,
|
114
|
+
// Only batch based on the filtered projects within the release group
|
115
|
+
releaseGroupProjectNames);
|
116
|
+
for (const [generatorConfigString, projectNames,] of projectBatches.entries()) {
|
117
|
+
const [generatorName, generatorOptions] = JSON.parse(generatorConfigString);
|
118
|
+
// Resolve the generator for the batch and run versioning on the projects within the batch
|
119
|
+
const generatorData = resolveGeneratorData({
|
120
|
+
...extractGeneratorCollectionAndName(`batch "${JSON.stringify(projectNames)}" for release-group "${releaseGroupName}"`, generatorName),
|
121
|
+
configGeneratorOptions: generatorOptions,
|
122
|
+
// all project data from the project graph (not to be confused with projectNamesToRunVersionOn)
|
123
|
+
projects,
|
124
|
+
});
|
125
|
+
const generatorCallback = await runVersionOnProjects(projectGraph, nxJson, args, tree, generatorData, args.generatorOptionsOverrides, projectNames, releaseGroup, versionData, nxReleaseConfig.conventionalCommits);
|
126
|
+
// Capture the callback so that we can run it after flushing the changes to disk
|
127
|
+
generatorCallbacks.push(async () => {
|
128
|
+
const result = await generatorCallback(tree, {
|
129
|
+
dryRun: !!args.dryRun,
|
130
|
+
verbose: !!args.verbose,
|
131
|
+
generatorOptions: {
|
132
|
+
...generatorOptions,
|
133
|
+
...args.generatorOptionsOverrides,
|
134
|
+
},
|
135
|
+
});
|
136
|
+
const { changedFiles, deletedFiles } = parseGeneratorCallbackResult(result);
|
137
|
+
changedFiles.forEach((f) => additionalChangedFiles.add(f));
|
138
|
+
deletedFiles.forEach((f) => additionalDeletedFiles.add(f));
|
139
|
+
});
|
140
|
+
}
|
141
|
+
}
|
142
|
+
// Resolve any git tags as early as possible so that we can hard error in case of any duplicates before reaching the actual git command
|
143
|
+
const gitTagValues = args.gitTag ?? nxReleaseConfig.version.git.tag
|
144
|
+
? (0, shared_1.createGitTagValues)(releaseGroups, releaseGroupToFilteredProjects, versionData)
|
145
|
+
: [];
|
146
|
+
(0, shared_1.handleDuplicateGitTags)(gitTagValues);
|
147
|
+
printAndFlushChanges(tree, !!args.dryRun);
|
148
|
+
for (const generatorCallback of generatorCallbacks) {
|
149
|
+
await generatorCallback();
|
150
|
+
}
|
151
|
+
const changedFiles = [
|
152
|
+
...tree.listChanges().map((f) => f.path),
|
153
|
+
...additionalChangedFiles,
|
154
|
+
];
|
155
|
+
// No further actions are necessary in this scenario (e.g. if conventional commits detected no changes)
|
156
|
+
if (!changedFiles.length) {
|
157
|
+
return {
|
158
|
+
// An overall workspace version cannot be relevant when filtering to independent projects
|
159
|
+
workspaceVersion: undefined,
|
160
|
+
projectsVersionData: versionData,
|
161
|
+
};
|
162
|
+
}
|
163
|
+
if (args.gitCommit ?? nxReleaseConfig.version.git.commit) {
|
164
|
+
await (0, shared_1.commitChanges)({
|
165
|
+
changedFiles,
|
166
|
+
deletedFiles: Array.from(additionalDeletedFiles),
|
167
|
+
isDryRun: !!args.dryRun,
|
168
|
+
isVerbose: !!args.verbose,
|
169
|
+
gitCommitMessages: (0, shared_1.createCommitMessageValues)(releaseGroups, releaseGroupToFilteredProjects, versionData, commitMessage),
|
170
|
+
gitCommitArgs: args.gitCommitArgs || nxReleaseConfig.version.git.commitArgs,
|
171
|
+
});
|
172
|
+
}
|
173
|
+
else if (args.stageChanges ??
|
174
|
+
nxReleaseConfig.version.git.stageChanges) {
|
175
|
+
output_1.output.logSingleLine(`Staging changed files with git`);
|
176
|
+
await (0, git_1.gitAdd)({
|
177
|
+
changedFiles,
|
178
|
+
dryRun: args.dryRun,
|
179
|
+
verbose: args.verbose,
|
180
|
+
});
|
181
|
+
}
|
182
|
+
if (args.gitTag ?? nxReleaseConfig.version.git.tag) {
|
183
|
+
output_1.output.logSingleLine(`Tagging commit with git`);
|
184
|
+
for (const tag of gitTagValues) {
|
185
|
+
await (0, git_1.gitTag)({
|
186
|
+
tag,
|
187
|
+
message: args.gitTagMessage || nxReleaseConfig.version.git.tagMessage,
|
188
|
+
additionalArgs: args.gitTagArgs || nxReleaseConfig.version.git.tagArgs,
|
189
|
+
dryRun: args.dryRun,
|
190
|
+
verbose: args.verbose,
|
191
|
+
});
|
192
|
+
}
|
193
|
+
}
|
194
|
+
return {
|
195
|
+
// An overall workspace version cannot be relevant when filtering to independent projects
|
196
|
+
workspaceVersion: undefined,
|
197
|
+
projectsVersionData: versionData,
|
198
|
+
};
|
199
|
+
}
|
95
200
|
/**
|
96
|
-
* Run versioning for all remaining release groups
|
201
|
+
* Run versioning for all remaining release groups
|
97
202
|
*/
|
98
203
|
for (const releaseGroup of releaseGroups) {
|
99
204
|
const releaseGroupName = releaseGroup.name;
|
100
|
-
const releaseGroupProjectNames = Array.from(releaseGroupToFilteredProjects.get(releaseGroup));
|
101
205
|
const projectBatches = (0, batch_projects_by_generator_config_1.batchProjectsByGeneratorConfig)(projectGraph, releaseGroup,
|
102
|
-
//
|
103
|
-
|
206
|
+
// Batch based on all projects within the release group
|
207
|
+
releaseGroup.projects);
|
104
208
|
for (const [generatorConfigString, projectNames,] of projectBatches.entries()) {
|
105
209
|
const [generatorName, generatorOptions] = JSON.parse(generatorConfigString);
|
106
210
|
// Resolve the generator for the batch and run versioning on the projects within the batch
|
@@ -136,6 +240,15 @@ async function releaseVersion(args) {
|
|
136
240
|
for (const generatorCallback of generatorCallbacks) {
|
137
241
|
await generatorCallback();
|
138
242
|
}
|
243
|
+
// Only applicable when there is a single release group with a fixed relationship
|
244
|
+
let workspaceVersion = undefined;
|
245
|
+
if (releaseGroups.length === 1) {
|
246
|
+
const releaseGroup = releaseGroups[0];
|
247
|
+
if (releaseGroup.projectsRelationship === 'fixed') {
|
248
|
+
const releaseGroupProjectNames = Array.from(releaseGroupToFilteredProjects.get(releaseGroup));
|
249
|
+
workspaceVersion = versionData[releaseGroupProjectNames[0]].newVersion; // all projects have the same version so we can just grab the first
|
250
|
+
}
|
251
|
+
}
|
139
252
|
const changedFiles = [
|
140
253
|
...tree.listChanges().map((f) => f.path),
|
141
254
|
...additionalChangedFiles,
|
@@ -144,8 +257,7 @@ async function releaseVersion(args) {
|
|
144
257
|
// No further actions are necessary in this scenario (e.g. if conventional commits detected no changes)
|
145
258
|
if (!changedFiles.length && !deletedFiles.length) {
|
146
259
|
return {
|
147
|
-
|
148
|
-
workspaceVersion: undefined,
|
260
|
+
workspaceVersion,
|
149
261
|
projectsVersionData: versionData,
|
150
262
|
};
|
151
263
|
}
|
@@ -180,108 +292,10 @@ async function releaseVersion(args) {
|
|
180
292
|
});
|
181
293
|
}
|
182
294
|
}
|
183
|
-
return {
|
184
|
-
// An overall workspace version cannot be relevant when filtering to independent projects
|
185
|
-
workspaceVersion: undefined,
|
186
|
-
projectsVersionData: versionData,
|
187
|
-
};
|
188
|
-
}
|
189
|
-
/**
|
190
|
-
* Run versioning for all remaining release groups
|
191
|
-
*/
|
192
|
-
for (const releaseGroup of releaseGroups) {
|
193
|
-
const releaseGroupName = releaseGroup.name;
|
194
|
-
const projectBatches = (0, batch_projects_by_generator_config_1.batchProjectsByGeneratorConfig)(projectGraph, releaseGroup,
|
195
|
-
// Batch based on all projects within the release group
|
196
|
-
releaseGroup.projects);
|
197
|
-
for (const [generatorConfigString, projectNames,] of projectBatches.entries()) {
|
198
|
-
const [generatorName, generatorOptions] = JSON.parse(generatorConfigString);
|
199
|
-
// Resolve the generator for the batch and run versioning on the projects within the batch
|
200
|
-
const generatorData = resolveGeneratorData({
|
201
|
-
...extractGeneratorCollectionAndName(`batch "${JSON.stringify(projectNames)}" for release-group "${releaseGroupName}"`, generatorName),
|
202
|
-
configGeneratorOptions: generatorOptions,
|
203
|
-
// all project data from the project graph (not to be confused with projectNamesToRunVersionOn)
|
204
|
-
projects,
|
205
|
-
});
|
206
|
-
const generatorCallback = await runVersionOnProjects(projectGraph, nxJson, args, tree, generatorData, args.generatorOptionsOverrides, projectNames, releaseGroup, versionData, nxReleaseConfig.conventionalCommits);
|
207
|
-
// Capture the callback so that we can run it after flushing the changes to disk
|
208
|
-
generatorCallbacks.push(async () => {
|
209
|
-
const result = await generatorCallback(tree, {
|
210
|
-
dryRun: !!args.dryRun,
|
211
|
-
verbose: !!args.verbose,
|
212
|
-
generatorOptions: {
|
213
|
-
...generatorOptions,
|
214
|
-
...args.generatorOptionsOverrides,
|
215
|
-
},
|
216
|
-
});
|
217
|
-
const { changedFiles, deletedFiles } = parseGeneratorCallbackResult(result);
|
218
|
-
changedFiles.forEach((f) => additionalChangedFiles.add(f));
|
219
|
-
deletedFiles.forEach((f) => additionalDeletedFiles.add(f));
|
220
|
-
});
|
221
|
-
}
|
222
|
-
}
|
223
|
-
// Resolve any git tags as early as possible so that we can hard error in case of any duplicates before reaching the actual git command
|
224
|
-
const gitTagValues = args.gitTag ?? nxReleaseConfig.version.git.tag
|
225
|
-
? (0, shared_1.createGitTagValues)(releaseGroups, releaseGroupToFilteredProjects, versionData)
|
226
|
-
: [];
|
227
|
-
(0, shared_1.handleDuplicateGitTags)(gitTagValues);
|
228
|
-
printAndFlushChanges(tree, !!args.dryRun);
|
229
|
-
for (const generatorCallback of generatorCallbacks) {
|
230
|
-
await generatorCallback();
|
231
|
-
}
|
232
|
-
// Only applicable when there is a single release group with a fixed relationship
|
233
|
-
let workspaceVersion = undefined;
|
234
|
-
if (releaseGroups.length === 1) {
|
235
|
-
const releaseGroup = releaseGroups[0];
|
236
|
-
if (releaseGroup.projectsRelationship === 'fixed') {
|
237
|
-
const releaseGroupProjectNames = Array.from(releaseGroupToFilteredProjects.get(releaseGroup));
|
238
|
-
workspaceVersion = versionData[releaseGroupProjectNames[0]].newVersion; // all projects have the same version so we can just grab the first
|
239
|
-
}
|
240
|
-
}
|
241
|
-
const changedFiles = [
|
242
|
-
...tree.listChanges().map((f) => f.path),
|
243
|
-
...additionalChangedFiles,
|
244
|
-
];
|
245
|
-
// No further actions are necessary in this scenario (e.g. if conventional commits detected no changes)
|
246
|
-
if (!changedFiles.length) {
|
247
295
|
return {
|
248
296
|
workspaceVersion,
|
249
297
|
projectsVersionData: versionData,
|
250
298
|
};
|
251
|
-
}
|
252
|
-
if (args.gitCommit ?? nxReleaseConfig.version.git.commit) {
|
253
|
-
await (0, shared_1.commitChanges)({
|
254
|
-
changedFiles,
|
255
|
-
deletedFiles: Array.from(additionalDeletedFiles),
|
256
|
-
isDryRun: !!args.dryRun,
|
257
|
-
isVerbose: !!args.verbose,
|
258
|
-
gitCommitMessages: (0, shared_1.createCommitMessageValues)(releaseGroups, releaseGroupToFilteredProjects, versionData, commitMessage),
|
259
|
-
gitCommitArgs: args.gitCommitArgs || nxReleaseConfig.version.git.commitArgs,
|
260
|
-
});
|
261
|
-
}
|
262
|
-
else if (args.stageChanges ?? nxReleaseConfig.version.git.stageChanges) {
|
263
|
-
output_1.output.logSingleLine(`Staging changed files with git`);
|
264
|
-
await (0, git_1.gitAdd)({
|
265
|
-
changedFiles,
|
266
|
-
dryRun: args.dryRun,
|
267
|
-
verbose: args.verbose,
|
268
|
-
});
|
269
|
-
}
|
270
|
-
if (args.gitTag ?? nxReleaseConfig.version.git.tag) {
|
271
|
-
output_1.output.logSingleLine(`Tagging commit with git`);
|
272
|
-
for (const tag of gitTagValues) {
|
273
|
-
await (0, git_1.gitTag)({
|
274
|
-
tag,
|
275
|
-
message: args.gitTagMessage || nxReleaseConfig.version.git.tagMessage,
|
276
|
-
additionalArgs: args.gitTagArgs || nxReleaseConfig.version.git.tagArgs,
|
277
|
-
dryRun: args.dryRun,
|
278
|
-
verbose: args.verbose,
|
279
|
-
});
|
280
|
-
}
|
281
|
-
}
|
282
|
-
return {
|
283
|
-
workspaceVersion,
|
284
|
-
projectsVersionData: versionData,
|
285
299
|
};
|
286
300
|
}
|
287
301
|
function appendVersionData(existingVersionData, newVersionData) {
|
@@ -14,7 +14,7 @@ const calculate_default_project_name_1 = require("../../config/calculate-default
|
|
14
14
|
const workspace_configuration_check_1 = require("../../utils/workspace-configuration-check");
|
15
15
|
const graph_1 = require("../graph/graph");
|
16
16
|
async function runOne(cwd, args, extraTargetDependencies = {}, extraOptions = {
|
17
|
-
excludeTaskDependencies:
|
17
|
+
excludeTaskDependencies: args.excludeTaskDependencies,
|
18
18
|
loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
|
19
19
|
}) {
|
20
20
|
perf_hooks_1.performance.mark('code-loading:end');
|
@@ -15,7 +15,7 @@ const find_matching_projects_1 = require("../../utils/find-matching-projects");
|
|
15
15
|
const workspace_configuration_check_1 = require("../../utils/workspace-configuration-check");
|
16
16
|
const graph_1 = require("../graph/graph");
|
17
17
|
async function runMany(args, extraTargetDependencies = {}, extraOptions = {
|
18
|
-
excludeTaskDependencies:
|
18
|
+
excludeTaskDependencies: args.excludeTaskDependencies,
|
19
19
|
loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
|
20
20
|
}) {
|
21
21
|
perf_hooks_1.performance.mark('code-loading:end');
|
@@ -18,6 +18,7 @@ export interface RunOptions {
|
|
18
18
|
dte: boolean;
|
19
19
|
batch: boolean;
|
20
20
|
useAgents: boolean;
|
21
|
+
excludeTaskDependencies: boolean;
|
21
22
|
}
|
22
23
|
export declare function withRunOptions<T>(yargs: Argv<T>): Argv<T & RunOptions>;
|
23
24
|
export declare function withTargetAndConfigurationOption(yargs: Argv, demandOption?: boolean): Argv<{
|
@@ -66,6 +66,11 @@ function withRunOptions(yargs) {
|
|
66
66
|
describe: 'Rerun the tasks even when the results are available in the cache',
|
67
67
|
type: 'boolean',
|
68
68
|
default: false,
|
69
|
+
})
|
70
|
+
.options('excludeTaskDependencies', {
|
71
|
+
describe: 'Skips running dependent tasks first',
|
72
|
+
type: 'boolean',
|
73
|
+
default: false,
|
69
74
|
})
|
70
75
|
.options('cloud', {
|
71
76
|
type: 'boolean',
|
@@ -36,8 +36,10 @@ const recursiveResolveDeps = (projectGraph, projectName, resolved) => {
|
|
36
36
|
};
|
37
37
|
function createCommandGraph(projectGraph, projectNames, nxArgs) {
|
38
38
|
const dependencies = {};
|
39
|
-
|
40
|
-
|
39
|
+
if (!nxArgs.excludeTaskDependencies) {
|
40
|
+
for (const projectName of projectNames) {
|
41
|
+
recursiveResolveDeps(projectGraph, projectName, dependencies);
|
42
|
+
}
|
41
43
|
}
|
42
44
|
const roots = Object.keys(dependencies).filter((d) => dependencies[d].length === 0);
|
43
45
|
const commandGraph = {
|
package/src/config/nx-json.d.ts
CHANGED
@@ -145,7 +145,7 @@ export interface NxReleaseConventionalCommitsConfiguration {
|
|
145
145
|
} | boolean;
|
146
146
|
} | boolean>;
|
147
147
|
}
|
148
|
-
interface NxReleaseConfiguration {
|
148
|
+
export interface NxReleaseConfiguration {
|
149
149
|
/**
|
150
150
|
* Shorthand for amending the projects which will be included in the implicit default release group (all projects by default).
|
151
151
|
* @note Only one of `projects` or `groups` can be specified, the cannot be used together.
|
@@ -379,6 +379,11 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
|
|
379
379
|
* To use a different runner that accepts an access token, define it in {@link tasksRunnerOptions}
|
380
380
|
*/
|
381
381
|
nxCloudAccessToken?: string;
|
382
|
+
/**
|
383
|
+
* If specified Nx will use nx-cloud by default with the given cloud id.
|
384
|
+
* To use a different runner that accepts a cloud id, define it in {@link tasksRunnerOptions}
|
385
|
+
*/
|
386
|
+
nxCloudId?: string;
|
382
387
|
/**
|
383
388
|
* Specifies the url pointing to an instance of nx cloud. Used for remote
|
384
389
|
* caching and displaying run links.
|
@@ -404,6 +409,10 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
|
|
404
409
|
* Set this to false to disable adding inference plugins when generating new projects
|
405
410
|
*/
|
406
411
|
useInferencePlugins?: boolean;
|
412
|
+
/**
|
413
|
+
* Set this to false to disable connection to Nx Cloud
|
414
|
+
*/
|
415
|
+
neverConnectToCloud?: boolean;
|
407
416
|
}
|
408
417
|
export type PluginConfiguration = string | ExpandedPluginConfiguration;
|
409
418
|
export type ExpandedPluginConfiguration<T = unknown> = {
|
@@ -9,7 +9,7 @@ export { readNxJson as readNxJsonFromDisk } from './config/nx-json';
|
|
9
9
|
export { calculateDefaultProjectName } from './config/calculate-default-project-name';
|
10
10
|
export { retrieveProjectConfigurationsWithAngularProjects } from './project-graph/utils/retrieve-workspace-files';
|
11
11
|
export { mergeTargetConfigurations } from './project-graph/utils/project-configuration-utils';
|
12
|
-
export { readProjectConfigurationsFromRootMap } from './project-graph/utils/project-configuration-utils';
|
12
|
+
export { readProjectConfigurationsFromRootMap, findMatchingConfigFiles, } from './project-graph/utils/project-configuration-utils';
|
13
13
|
export { splitTarget } from './utils/split-target';
|
14
14
|
export { combineOptionsForExecutor } from './utils/params';
|
15
15
|
export { sortObjectByKeys } from './utils/object-sort';
|
package/src/devkit-internals.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.interpolate = exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
|
3
|
+
exports.interpolate = exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.findMatchingConfigFiles = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
/**
|
6
6
|
* Note to developers: STOP! These exports are available via requireNx in @nx/devkit.
|
@@ -21,6 +21,7 @@ var project_configuration_utils_1 = require("./project-graph/utils/project-confi
|
|
21
21
|
Object.defineProperty(exports, "mergeTargetConfigurations", { enumerable: true, get: function () { return project_configuration_utils_1.mergeTargetConfigurations; } });
|
22
22
|
var project_configuration_utils_2 = require("./project-graph/utils/project-configuration-utils");
|
23
23
|
Object.defineProperty(exports, "readProjectConfigurationsFromRootMap", { enumerable: true, get: function () { return project_configuration_utils_2.readProjectConfigurationsFromRootMap; } });
|
24
|
+
Object.defineProperty(exports, "findMatchingConfigFiles", { enumerable: true, get: function () { return project_configuration_utils_2.findMatchingConfigFiles; } });
|
24
25
|
var split_target_1 = require("./utils/split-target");
|
25
26
|
Object.defineProperty(exports, "splitTarget", { enumerable: true, get: function () { return split_target_1.splitTarget; } });
|
26
27
|
var params_1 = require("./utils/params");
|
@@ -17,10 +17,10 @@ const workspace_context_1 = require("../../utils/workspace-context");
|
|
17
17
|
const output_1 = require("../../utils/output");
|
18
18
|
const path_2 = require("../../utils/path");
|
19
19
|
const json_1 = require("./json");
|
20
|
-
const
|
21
|
-
var
|
22
|
-
Object.defineProperty(exports, "readNxJson", { enumerable: true, get: function () { return
|
23
|
-
Object.defineProperty(exports, "updateNxJson", { enumerable: true, get: function () { return
|
20
|
+
const to_project_name_1 = require("../../config/to-project-name");
|
21
|
+
var nx_json_1 = require("./nx-json");
|
22
|
+
Object.defineProperty(exports, "readNxJson", { enumerable: true, get: function () { return nx_json_1.readNxJson; } });
|
23
|
+
Object.defineProperty(exports, "updateNxJson", { enumerable: true, get: function () { return nx_json_1.updateNxJson; } });
|
24
24
|
/**
|
25
25
|
* Adds project configuration to the Nx workspace.
|
26
26
|
*
|
@@ -56,10 +56,35 @@ function addProjectConfiguration(tree, projectName, projectConfiguration, standa
|
|
56
56
|
* @param projectConfiguration - project configuration
|
57
57
|
*/
|
58
58
|
function updateProjectConfiguration(tree, projectName, projectConfiguration) {
|
59
|
-
|
60
|
-
|
59
|
+
if (tree.exists((0, path_2.joinPathFragments)(projectConfiguration.root, 'project.json'))) {
|
60
|
+
updateProjectConfigurationInProjectJson(tree, projectName, projectConfiguration);
|
61
|
+
}
|
62
|
+
else if (tree.exists((0, path_2.joinPathFragments)(projectConfiguration.root, 'package.json'))) {
|
63
|
+
updateProjectConfigurationInPackageJson(tree, projectName, projectConfiguration);
|
64
|
+
}
|
65
|
+
else {
|
61
66
|
throw new Error(`Cannot update Project ${projectName} at ${projectConfiguration.root}. It either doesn't exist yet, or may not use project.json for configuration. Use \`addProjectConfiguration()\` instead if you want to create a new project.`);
|
62
67
|
}
|
68
|
+
}
|
69
|
+
function updateProjectConfigurationInPackageJson(tree, projectName, projectConfiguration) {
|
70
|
+
const packageJsonFile = (0, path_2.joinPathFragments)(projectConfiguration.root, 'package.json');
|
71
|
+
const packageJson = (0, json_1.readJson)(tree, packageJsonFile);
|
72
|
+
if (packageJson.name === projectConfiguration.name ?? projectName) {
|
73
|
+
delete projectConfiguration.name;
|
74
|
+
}
|
75
|
+
if (projectConfiguration.targets &&
|
76
|
+
!Object.keys(projectConfiguration.targets).length) {
|
77
|
+
delete projectConfiguration.targets;
|
78
|
+
}
|
79
|
+
packageJson.nx = {
|
80
|
+
...packageJson.nx,
|
81
|
+
...projectConfiguration,
|
82
|
+
root: undefined,
|
83
|
+
};
|
84
|
+
(0, json_1.writeJson)(tree, packageJsonFile, packageJson);
|
85
|
+
}
|
86
|
+
function updateProjectConfigurationInProjectJson(tree, projectName, projectConfiguration) {
|
87
|
+
const projectConfigFile = (0, path_2.joinPathFragments)(projectConfiguration.root, 'project.json');
|
63
88
|
handleEmptyTargets(projectName, projectConfiguration);
|
64
89
|
(0, json_1.writeJson)(tree, projectConfigFile, {
|
65
90
|
name: projectConfiguration.name ?? projectName,
|
@@ -147,15 +172,20 @@ function readAndCombineAllProjectConfigurations(tree) {
|
|
147
172
|
}
|
148
173
|
else if ((0, path_1.basename)(projectFile) === 'package.json') {
|
149
174
|
const packageJson = (0, json_1.readJson)(tree, projectFile);
|
150
|
-
|
175
|
+
// We don't want to have all of the extra inferred stuff in here, as
|
176
|
+
// when generators update the project they shouldn't inline that stuff.
|
177
|
+
// so rather than using `buildProjectFromPackageJson` and stripping it out
|
178
|
+
// we are going to build the config manually.
|
179
|
+
const config = {
|
180
|
+
root: (0, path_1.dirname)(projectFile),
|
181
|
+
name: packageJson.name ?? (0, to_project_name_1.toProjectName)(projectFile),
|
182
|
+
...packageJson.nx,
|
183
|
+
};
|
151
184
|
if (!rootMap[config.root]) {
|
152
185
|
(0, project_configuration_utils_1.mergeProjectConfigurationIntoRootMap)(rootMap,
|
153
186
|
// Inferred targets, tags, etc don't show up when running generators
|
154
187
|
// This is to help avoid running into issues when trying to update the workspace
|
155
|
-
|
156
|
-
name: config.name,
|
157
|
-
root: config.root,
|
158
|
-
}, undefined, undefined, true);
|
188
|
+
config, undefined, undefined, true);
|
159
189
|
}
|
160
190
|
}
|
161
191
|
}
|
Binary file
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Tree } from '../../../generators/tree';
|
2
|
+
import { NxJsonConfiguration } from '../../../config/nx-json';
|
2
3
|
export declare function printSuccessMessage(token: string | undefined, installationSource: string, usesGithub: boolean): Promise<string>;
|
3
4
|
export interface ConnectToNxCloudOptions {
|
4
5
|
analytics?: boolean;
|
@@ -7,5 +8,6 @@ export interface ConnectToNxCloudOptions {
|
|
7
8
|
github?: boolean;
|
8
9
|
directory?: string;
|
9
10
|
}
|
10
|
-
export declare function connectToNxCloud(tree: Tree, schema: ConnectToNxCloudOptions): Promise<string>;
|
11
|
-
|
11
|
+
export declare function connectToNxCloud(tree: Tree, schema: ConnectToNxCloudOptions, nxJson?: NxJsonConfiguration<string[] | "*">): Promise<string>;
|
12
|
+
declare function connectToNxCloudGenerator(tree: Tree, options: ConnectToNxCloudOptions): Promise<void>;
|
13
|
+
export default connectToNxCloudGenerator;
|