nx 18.1.0-canary.20240301-d705372 → 18.1.0-canary.20240306-cc2f655
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/schemas/nx-schema.json +10 -1
- package/schemas/project-schema.json +20 -0
- package/src/command-line/init/implementation/add-nx-to-nest.js +2 -2
- package/src/command-line/init/implementation/add-nx-to-npm-repo.js +2 -2
- package/src/command-line/init/implementation/utils.d.ts +1 -3
- package/src/command-line/init/implementation/utils.js +9 -16
- package/src/command-line/init/init-v2.js +1 -1
- package/src/command-line/release/changelog.js +6 -2
- package/src/command-line/release/command-object.d.ts +1 -0
- package/src/command-line/release/config/config.d.ts +2 -15
- package/src/command-line/release/config/config.js +62 -19
- package/src/command-line/release/publish.js +4 -3
- package/src/command-line/release/release.js +12 -11
- package/src/command-line/release/utils/git.js +30 -1
- package/src/command-line/release/utils/shared.d.ts +5 -1
- package/src/command-line/release/version.d.ts +4 -1
- package/src/command-line/release/version.js +70 -19
- package/src/config/nx-json.d.ts +6 -0
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.css +1 -1
- package/src/devkit-exports.d.ts +1 -1
- package/src/devkit-exports.js +2 -1
- package/src/migrations/update-17-2-0/move-default-base.js +2 -0
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +13 -2
- package/src/plugins/target-defaults/target-defaults-plugin.js +17 -5
- package/src/project-graph/plugins/public-api.d.ts +1 -1
- package/src/project-graph/utils/project-configuration-utils.js +5 -1
- package/src/utils/package-manager.d.ts +6 -0
- package/src/utils/package-manager.js +16 -1
@@ -4,7 +4,7 @@ import { ReleaseGroupWithName } from './config/filter-release-groups';
|
|
4
4
|
import { VersionData } from './utils/shared';
|
5
5
|
export { deriveNewSemverVersion } from './utils/semver';
|
6
6
|
export type { ReleaseVersionGeneratorResult, VersionData, } from './utils/shared';
|
7
|
-
export declare const validReleaseVersionPrefixes:
|
7
|
+
export declare const validReleaseVersionPrefixes: readonly ["auto", "", "~", "^", "="];
|
8
8
|
export interface ReleaseVersionGeneratorSchema {
|
9
9
|
projects: ProjectGraphProjectNode[];
|
10
10
|
releaseGroup: ReleaseGroupWithName;
|
@@ -18,6 +18,9 @@ export interface ReleaseVersionGeneratorSchema {
|
|
18
18
|
fallbackCurrentVersionResolver?: 'disk';
|
19
19
|
firstRelease?: boolean;
|
20
20
|
versionPrefix?: typeof validReleaseVersionPrefixes[number];
|
21
|
+
skipLockFileUpdate?: boolean;
|
22
|
+
installArgs?: string;
|
23
|
+
installIgnoreScripts?: boolean;
|
21
24
|
}
|
22
25
|
export interface NxReleaseVersionResult {
|
23
26
|
/**
|
@@ -2,13 +2,17 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.releaseVersion = exports.releaseVersionCLIHandler = exports.validReleaseVersionPrefixes = exports.deriveNewSemverVersion = void 0;
|
4
4
|
const chalk = require("chalk");
|
5
|
+
const node_child_process_1 = require("node:child_process");
|
5
6
|
const node_fs_1 = require("node:fs");
|
6
7
|
const node_path_1 = require("node:path");
|
7
8
|
const nx_json_1 = require("../../config/nx-json");
|
8
|
-
const devkit_exports_1 = require("../../devkit-exports");
|
9
9
|
const tree_1 = require("../../generators/tree");
|
10
|
+
const file_map_utils_1 = require("../../project-graph/file-map-utils");
|
10
11
|
const project_graph_1 = require("../../project-graph/project-graph");
|
12
|
+
const output_1 = require("../../utils/output");
|
11
13
|
const params_1 = require("../../utils/params");
|
14
|
+
const path_1 = require("../../utils/path");
|
15
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
12
16
|
const generate_1 = require("../generate/generate");
|
13
17
|
const generator_utils_1 = require("../generate/generator-utils");
|
14
18
|
const config_1 = require("./config/config");
|
@@ -18,10 +22,11 @@ const git_1 = require("./utils/git");
|
|
18
22
|
const print_changes_1 = require("./utils/print-changes");
|
19
23
|
const resolve_nx_json_error_message_1 = require("./utils/resolve-nx-json-error-message");
|
20
24
|
const shared_1 = require("./utils/shared");
|
25
|
+
const LARGE_BUFFER = 1024 * 1000000;
|
21
26
|
// Reexport some utils for use in plugin release-version generator implementations
|
22
27
|
var semver_1 = require("./utils/semver");
|
23
28
|
Object.defineProperty(exports, "deriveNewSemverVersion", { enumerable: true, get: function () { return semver_1.deriveNewSemverVersion; } });
|
24
|
-
exports.validReleaseVersionPrefixes = ['auto', '', '~', '^'];
|
29
|
+
exports.validReleaseVersionPrefixes = ['auto', '', '~', '^', '='];
|
25
30
|
const releaseVersionCLIHandler = (args) => (0, params_1.handleErrors)(args.verbose, () => releaseVersion(args));
|
26
31
|
exports.releaseVersionCLIHandler = releaseVersionCLIHandler;
|
27
32
|
/**
|
@@ -37,7 +42,7 @@ async function releaseVersion(args) {
|
|
37
42
|
process.env.NX_VERBOSE_LOGGING = 'true';
|
38
43
|
}
|
39
44
|
// Apply default configuration to any optional user configuration
|
40
|
-
const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, nxJson.release);
|
45
|
+
const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, await (0, file_map_utils_1.createProjectFileMapUsingProjectGraph)(projectGraph), nxJson.release);
|
41
46
|
if (configError) {
|
42
47
|
return await (0, config_1.handleNxReleaseConfigError)(configError);
|
43
48
|
}
|
@@ -53,7 +58,7 @@ async function releaseVersion(args) {
|
|
53
58
|
'release',
|
54
59
|
'git',
|
55
60
|
]);
|
56
|
-
|
61
|
+
output_1.output.error({
|
57
62
|
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".`,
|
58
63
|
bodyLines: [nxJsonMessage],
|
59
64
|
});
|
@@ -61,10 +66,14 @@ async function releaseVersion(args) {
|
|
61
66
|
}
|
62
67
|
const { error: filterError, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, args.projects, args.groups);
|
63
68
|
if (filterError) {
|
64
|
-
|
69
|
+
output_1.output.error(filterError);
|
65
70
|
process.exit(1);
|
66
71
|
}
|
67
|
-
|
72
|
+
runPreVersionCommand(nxReleaseConfig.version.preVersionCommand, {
|
73
|
+
dryRun: args.dryRun,
|
74
|
+
verbose: args.verbose,
|
75
|
+
});
|
76
|
+
const tree = new tree_1.FsTree(workspace_root_1.workspaceRoot, args.verbose);
|
68
77
|
const versionData = {};
|
69
78
|
const commitMessage = args.gitCommitMessage || nxReleaseConfig.version.git.commitMessage;
|
70
79
|
const additionalChangedFiles = new Set();
|
@@ -88,13 +97,16 @@ async function releaseVersion(args) {
|
|
88
97
|
// all project data from the project graph (not to be confused with projectNamesToRunVersionOn)
|
89
98
|
projects,
|
90
99
|
});
|
91
|
-
const generatorCallback = await runVersionOnProjects(projectGraph, nxJson, args, tree, generatorData, projectNames, releaseGroup, versionData);
|
100
|
+
const generatorCallback = await runVersionOnProjects(projectGraph, nxJson, args, tree, generatorData, args.generatorOptionsOverrides, projectNames, releaseGroup, versionData);
|
92
101
|
// Capture the callback so that we can run it after flushing the changes to disk
|
93
102
|
generatorCallbacks.push(async () => {
|
94
103
|
const changedFiles = await generatorCallback(tree, {
|
95
104
|
dryRun: !!args.dryRun,
|
96
105
|
verbose: !!args.verbose,
|
97
|
-
generatorOptions
|
106
|
+
generatorOptions: {
|
107
|
+
...generatorOptions,
|
108
|
+
...args.generatorOptionsOverrides,
|
109
|
+
},
|
98
110
|
});
|
99
111
|
changedFiles.forEach((f) => additionalChangedFiles.add(f));
|
100
112
|
});
|
@@ -125,7 +137,7 @@ async function releaseVersion(args) {
|
|
125
137
|
await (0, shared_1.commitChanges)(changedFiles, !!args.dryRun, !!args.verbose, (0, shared_1.createCommitMessageValues)(releaseGroups, releaseGroupToFilteredProjects, versionData, commitMessage), args.gitCommitArgs || nxReleaseConfig.version.git.commitArgs);
|
126
138
|
}
|
127
139
|
else if (args.stageChanges ?? nxReleaseConfig.version.git.stageChanges) {
|
128
|
-
|
140
|
+
output_1.output.logSingleLine(`Staging changed files with git`);
|
129
141
|
await (0, git_1.gitAdd)({
|
130
142
|
changedFiles,
|
131
143
|
dryRun: args.dryRun,
|
@@ -133,7 +145,7 @@ async function releaseVersion(args) {
|
|
133
145
|
});
|
134
146
|
}
|
135
147
|
if (args.gitTag ?? nxReleaseConfig.version.git.tag) {
|
136
|
-
|
148
|
+
output_1.output.logSingleLine(`Tagging commit with git`);
|
137
149
|
for (const tag of gitTagValues) {
|
138
150
|
await (0, git_1.gitTag)({
|
139
151
|
tag,
|
@@ -167,13 +179,16 @@ async function releaseVersion(args) {
|
|
167
179
|
// all project data from the project graph (not to be confused with projectNamesToRunVersionOn)
|
168
180
|
projects,
|
169
181
|
});
|
170
|
-
const generatorCallback = await runVersionOnProjects(projectGraph, nxJson, args, tree, generatorData, projectNames, releaseGroup, versionData);
|
182
|
+
const generatorCallback = await runVersionOnProjects(projectGraph, nxJson, args, tree, generatorData, args.generatorOptionsOverrides, projectNames, releaseGroup, versionData);
|
171
183
|
// Capture the callback so that we can run it after flushing the changes to disk
|
172
184
|
generatorCallbacks.push(async () => {
|
173
185
|
const changedFiles = await generatorCallback(tree, {
|
174
186
|
dryRun: !!args.dryRun,
|
175
187
|
verbose: !!args.verbose,
|
176
|
-
generatorOptions
|
188
|
+
generatorOptions: {
|
189
|
+
...generatorOptions,
|
190
|
+
...args.generatorOptionsOverrides,
|
191
|
+
},
|
177
192
|
});
|
178
193
|
changedFiles.forEach((f) => additionalChangedFiles.add(f));
|
179
194
|
});
|
@@ -212,7 +227,7 @@ async function releaseVersion(args) {
|
|
212
227
|
await (0, shared_1.commitChanges)(changedFiles, !!args.dryRun, !!args.verbose, (0, shared_1.createCommitMessageValues)(releaseGroups, releaseGroupToFilteredProjects, versionData, commitMessage), args.gitCommitArgs || nxReleaseConfig.version.git.commitArgs);
|
213
228
|
}
|
214
229
|
else if (args.stageChanges ?? nxReleaseConfig.version.git.stageChanges) {
|
215
|
-
|
230
|
+
output_1.output.logSingleLine(`Staging changed files with git`);
|
216
231
|
await (0, git_1.gitAdd)({
|
217
232
|
changedFiles,
|
218
233
|
dryRun: args.dryRun,
|
@@ -220,7 +235,7 @@ async function releaseVersion(args) {
|
|
220
235
|
});
|
221
236
|
}
|
222
237
|
if (args.gitTag ?? nxReleaseConfig.version.git.tag) {
|
223
|
-
|
238
|
+
output_1.output.logSingleLine(`Tagging commit with git`);
|
224
239
|
for (const tag of gitTagValues) {
|
225
240
|
await (0, git_1.gitTag)({
|
226
241
|
tag,
|
@@ -247,12 +262,13 @@ function appendVersionData(existingVersionData, newVersionData) {
|
|
247
262
|
}
|
248
263
|
return existingVersionData;
|
249
264
|
}
|
250
|
-
async function runVersionOnProjects(projectGraph, nxJson, args, tree, generatorData, projectNames, releaseGroup, versionData) {
|
265
|
+
async function runVersionOnProjects(projectGraph, nxJson, args, tree, generatorData, generatorOverrides, projectNames, releaseGroup, versionData) {
|
251
266
|
const generatorOptions = {
|
252
267
|
// Always ensure a string to avoid generator schema validation errors
|
253
268
|
specifier: args.specifier ?? '',
|
254
269
|
preid: args.preid ?? '',
|
255
270
|
...generatorData.configGeneratorOptions,
|
271
|
+
...(generatorOverrides ?? {}),
|
256
272
|
// The following are not overridable by user config
|
257
273
|
projects: projectNames.map((p) => projectGraph.nodes[p]),
|
258
274
|
projectGraph,
|
@@ -260,7 +276,7 @@ async function runVersionOnProjects(projectGraph, nxJson, args, tree, generatorD
|
|
260
276
|
firstRelease: args.firstRelease ?? false,
|
261
277
|
};
|
262
278
|
// Apply generator defaults from schema.json file etc
|
263
|
-
const combinedOpts = await (0, params_1.combineOptionsForGenerator)(generatorOptions, generatorData.collectionName, generatorData.normalizedGeneratorName, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph), nxJson, generatorData.schema, false, null, (0, node_path_1.relative)(process.cwd(),
|
279
|
+
const combinedOpts = await (0, params_1.combineOptionsForGenerator)(generatorOptions, generatorData.collectionName, generatorData.normalizedGeneratorName, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph), nxJson, generatorData.schema, false, null, (0, node_path_1.relative)(process.cwd(), workspace_root_1.workspaceRoot), args.verbose);
|
264
280
|
const releaseVersionGenerator = generatorData.implementationFactory();
|
265
281
|
// We expect all version generator implementations to return a ReleaseVersionGeneratorResult object, rather than a GeneratorCallback
|
266
282
|
const versionResult = (await releaseVersionGenerator(tree, combinedOpts));
|
@@ -282,7 +298,7 @@ function printAndFlushChanges(tree, isDryRun) {
|
|
282
298
|
}
|
283
299
|
else if (f.type === 'UPDATE') {
|
284
300
|
console.error(`${chalk.white('UPDATE')} ${f.path}${isDryRun ? chalk.keyword('orange')(' [dry-run]') : ''}`);
|
285
|
-
const currentContentsOnDisk = (0, node_fs_1.readFileSync)((0,
|
301
|
+
const currentContentsOnDisk = (0, node_fs_1.readFileSync)((0, path_1.joinPathFragments)(tree.root, f.path)).toString();
|
286
302
|
(0, print_changes_1.printDiff)(currentContentsOnDisk, f.content?.toString() || '');
|
287
303
|
}
|
288
304
|
else if (f.type === 'DELETE') {
|
@@ -290,7 +306,7 @@ function printAndFlushChanges(tree, isDryRun) {
|
|
290
306
|
}
|
291
307
|
});
|
292
308
|
if (!isDryRun) {
|
293
|
-
(0, tree_1.flushChanges)(
|
309
|
+
(0, tree_1.flushChanges)(workspace_root_1.workspaceRoot, changes);
|
294
310
|
}
|
295
311
|
}
|
296
312
|
function extractGeneratorCollectionAndName(description, generatorString) {
|
@@ -306,7 +322,7 @@ function extractGeneratorCollectionAndName(description, generatorString) {
|
|
306
322
|
}
|
307
323
|
function resolveGeneratorData({ collectionName, generatorName, configGeneratorOptions, projects, }) {
|
308
324
|
try {
|
309
|
-
const { normalizedGeneratorName, schema, implementationFactory } = (0, generator_utils_1.getGeneratorInformation)(collectionName, generatorName,
|
325
|
+
const { normalizedGeneratorName, schema, implementationFactory } = (0, generator_utils_1.getGeneratorInformation)(collectionName, generatorName, workspace_root_1.workspaceRoot, projects);
|
310
326
|
return {
|
311
327
|
collectionName,
|
312
328
|
generatorName,
|
@@ -339,3 +355,38 @@ function resolveGeneratorData({ collectionName, generatorName, configGeneratorOp
|
|
339
355
|
throw err;
|
340
356
|
}
|
341
357
|
}
|
358
|
+
function runPreVersionCommand(preVersionCommand, { dryRun, verbose }) {
|
359
|
+
if (!preVersionCommand) {
|
360
|
+
return;
|
361
|
+
}
|
362
|
+
output_1.output.logSingleLine(`Executing pre-version command`);
|
363
|
+
if (verbose) {
|
364
|
+
console.log(`Executing the following pre-version command:`);
|
365
|
+
console.log(preVersionCommand);
|
366
|
+
}
|
367
|
+
let env = {
|
368
|
+
...process.env,
|
369
|
+
};
|
370
|
+
if (dryRun) {
|
371
|
+
env.NX_DRY_RUN = 'true';
|
372
|
+
}
|
373
|
+
const stdio = verbose ? 'inherit' : 'pipe';
|
374
|
+
try {
|
375
|
+
(0, node_child_process_1.execSync)(preVersionCommand, {
|
376
|
+
encoding: 'utf-8',
|
377
|
+
maxBuffer: LARGE_BUFFER,
|
378
|
+
stdio,
|
379
|
+
env,
|
380
|
+
});
|
381
|
+
}
|
382
|
+
catch (e) {
|
383
|
+
const title = verbose
|
384
|
+
? `The pre-version command failed. See the full output above.`
|
385
|
+
: `The pre-version command failed. Retry with --verbose to see the full output of the pre-version command.`;
|
386
|
+
output_1.output.error({
|
387
|
+
title,
|
388
|
+
bodyLines: [preVersionCommand, e],
|
389
|
+
});
|
390
|
+
process.exit(1);
|
391
|
+
}
|
392
|
+
}
|
package/src/config/nx-json.d.ts
CHANGED
@@ -207,6 +207,12 @@ interface NxReleaseConfiguration {
|
|
207
207
|
* Enable or override configuration for git operations as part of the version subcommand
|
208
208
|
*/
|
209
209
|
git?: NxReleaseGitConfiguration;
|
210
|
+
/**
|
211
|
+
* A command to run after validation of nx release configuration, but before versioning begins.
|
212
|
+
* Used for preparing build artifacts. If --dry-run is passed, the command is still executed, but
|
213
|
+
* with the NX_DRY_RUN environment variable set to 'true'.
|
214
|
+
*/
|
215
|
+
preVersionCommand?: string;
|
210
216
|
};
|
211
217
|
/**
|
212
218
|
* Optionally override the git/release tag pattern to use. This field is the source of truth
|