nx 18.1.0 → 18.1.1
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/bin/init-local.js +13 -1
- package/package.json +12 -12
- package/release/changelog-renderer/index.d.ts +2 -0
- package/release/changelog-renderer/index.js +4 -18
- package/schemas/nx-schema.json +62 -1
- package/schemas/project-schema.json +20 -0
- package/src/adapter/angular-json.d.ts +1 -2
- package/src/adapter/angular-json.js +0 -1
- package/src/adapter/ngcli-adapter.js +3 -3
- package/src/command-line/generate/generator-utils.js +2 -2
- 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 +3 -2
- package/src/command-line/release/changelog.js +17 -14
- package/src/command-line/release/command-object.d.ts +1 -0
- package/src/command-line/release/config/config.d.ts +12 -15
- package/src/command-line/release/config/config.js +151 -22
- package/src/command-line/release/config/conventional-commits.d.ts +2 -0
- package/src/command-line/release/config/conventional-commits.js +98 -0
- 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/resolve-semver-specifier.d.ts +2 -1
- package/src/command-line/release/utils/resolve-semver-specifier.js +2 -13
- package/src/command-line/release/utils/semver.d.ts +2 -8
- package/src/command-line/release/utils/semver.js +4 -1
- package/src/command-line/release/utils/shared.d.ts +5 -1
- package/src/command-line/release/version.d.ts +6 -1
- package/src/command-line/release/version.js +71 -19
- package/src/command-line/run/executor-utils.js +2 -2
- package/src/command-line/run/run.js +3 -3
- package/src/config/nx-json.d.ts +31 -0
- package/src/config/schema-utils.js +2 -2
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/polyfills.js +1 -1
- package/src/core/graph/styles.css +1 -1
- package/src/daemon/server/project-graph-incremental-recomputation.js +1 -0
- package/src/devkit-exports.d.ts +1 -2
- package/src/devkit-internals.d.ts +0 -1
- package/src/devkit-internals.js +1 -3
- package/src/executors/run-commands/run-commands.impl.d.ts +7 -1
- package/src/executors/run-commands/run-commands.impl.js +120 -57
- package/src/executors/run-script/run-script.impl.js +5 -5
- package/src/generators/utils/project-configuration.js +2 -2
- package/src/hasher/hash-task.js +2 -2
- package/src/migrations/update-15-1-0/set-project-names.js +2 -4
- package/src/migrations/update-17-2-0/move-default-base.d.ts +1 -1
- package/src/migrations/update-17-2-0/move-default-base.js +3 -1
- package/src/migrations/update-17-3-0/nx-release-path.js +0 -1
- package/src/native/index.d.ts +14 -11
- package/src/native/index.js +3 -4
- package/src/plugins/js/index.d.ts +1 -1
- package/src/plugins/js/lock-file/lock-file.d.ts +1 -1
- package/src/plugins/js/lock-file/lock-file.js +13 -1
- package/src/plugins/js/lock-file/npm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +1 -1
- package/src/plugins/js/utils/register.js +3 -1
- package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
- package/src/plugins/package-json-workspaces/create-nodes.js +31 -24
- package/src/plugins/package-json-workspaces/index.d.ts +0 -1
- package/src/plugins/package-json-workspaces/index.js +0 -2
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +1 -2
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +0 -1
- package/src/plugins/project-json/build-nodes/project-json.d.ts +1 -2
- package/src/plugins/project-json/build-nodes/project-json.js +0 -1
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +1 -2
- package/src/plugins/target-defaults/target-defaults-plugin.js +0 -1
- package/src/project-graph/affected/locators/project-glob-changes.js +3 -2
- package/src/project-graph/build-project-graph.js +8 -11
- package/src/project-graph/file-utils.js +6 -4
- package/src/project-graph/project-graph-builder.d.ts +1 -1
- package/src/project-graph/project-graph.js +3 -0
- package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts +4 -4
- package/src/project-graph/utils/project-configuration-utils.js +58 -17
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +4 -8
- package/src/project-graph/utils/retrieve-workspace-files.js +18 -20
- package/src/tasks-runner/fork.js +7 -7
- package/src/tasks-runner/forked-process-task-runner.d.ts +2 -4
- package/src/tasks-runner/forked-process-task-runner.js +13 -17
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +16 -13
- package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +8 -7
- package/src/tasks-runner/{psuedo-ipc.d.ts → pseudo-ipc.d.ts} +7 -7
- package/src/tasks-runner/{psuedo-ipc.js → pseudo-ipc.js} +9 -9
- package/src/tasks-runner/pseudo-terminal.d.ts +42 -0
- package/src/tasks-runner/pseudo-terminal.js +133 -0
- package/src/tasks-runner/task-orchestrator.js +45 -9
- package/src/tasks-runner/tasks-schedule.js +3 -3
- package/src/tasks-runner/utils.d.ts +7 -6
- package/src/tasks-runner/utils.js +11 -7
- package/src/utils/ignore.js +1 -1
- package/src/utils/logger.d.ts +0 -1
- package/src/utils/logger.js +0 -5
- package/src/{project-graph/plugins/public-api.d.ts → utils/nx-plugin.d.ts} +45 -7
- package/src/utils/nx-plugin.deprecated.d.ts +2 -4
- package/src/utils/nx-plugin.deprecated.js +4 -4
- package/src/utils/nx-plugin.js +293 -0
- package/src/utils/output.js +1 -1
- package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
- package/src/utils/plugins/plugin-capabilities.js +7 -8
- package/src/project-graph/plugins/index.d.ts +0 -2
- package/src/project-graph/plugins/index.js +0 -8
- package/src/project-graph/plugins/internal-api.d.ts +0 -18
- package/src/project-graph/plugins/internal-api.js +0 -48
- package/src/project-graph/plugins/messaging.d.ts +0 -94
- package/src/project-graph/plugins/messaging.js +0 -23
- package/src/project-graph/plugins/plugin-pool.d.ts +0 -4
- package/src/project-graph/plugins/plugin-pool.js +0 -216
- package/src/project-graph/plugins/plugin-worker.d.ts +0 -1
- package/src/project-graph/plugins/plugin-worker.js +0 -115
- package/src/project-graph/plugins/public-api.js +0 -4
- package/src/project-graph/plugins/utils.d.ts +0 -9
- package/src/project-graph/plugins/utils.js +0 -55
- package/src/project-graph/plugins/worker-api.d.ts +0 -26
- package/src/project-graph/plugins/worker-api.js +0 -177
@@ -1,12 +1,29 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.handleNxReleaseConfigError = exports.createNxReleaseConfig = exports.IMPLICIT_DEFAULT_RELEASE_GROUP = void 0;
|
4
|
-
|
4
|
+
/**
|
5
|
+
* `nx release` is a powerful feature which spans many possible use cases. The possible variations
|
6
|
+
* of configuration are therefore quite complex, particularly when you consider release groups.
|
7
|
+
*
|
8
|
+
* We want to provide the best possible DX for users so that they can harness the power of `nx release`
|
9
|
+
* most effectively, therefore we need to both provide sensible defaults for common scenarios (to avoid
|
10
|
+
* verbose nx.json files wherever possible), and proactively handle potential sources of config issues
|
11
|
+
* in more complex use-cases.
|
12
|
+
*
|
13
|
+
* This file is the source of truth for all `nx release` configuration reconciliation, including sensible
|
14
|
+
* defaults and user overrides, as well as handling common errors, up front to produce a single, consistent,
|
15
|
+
* and easy to consume config object for all the `nx release` command implementations.
|
16
|
+
*/
|
17
|
+
const path_1 = require("path");
|
18
|
+
const fileutils_1 = require("../../../utils/fileutils");
|
5
19
|
const find_matching_projects_1 = require("../../../utils/find-matching-projects");
|
20
|
+
const output_1 = require("../../../utils/output");
|
21
|
+
const workspace_root_1 = require("../../../utils/workspace-root");
|
6
22
|
const resolve_nx_json_error_message_1 = require("../utils/resolve-nx-json-error-message");
|
23
|
+
const conventional_commits_1 = require("./conventional-commits");
|
7
24
|
exports.IMPLICIT_DEFAULT_RELEASE_GROUP = '__default__';
|
8
25
|
// Apply default configuration to any optional user configuration and handle known errors
|
9
|
-
async function createNxReleaseConfig(projectGraph, userConfig = {}) {
|
26
|
+
async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig = {}) {
|
10
27
|
if (userConfig.projects && userConfig.groups) {
|
11
28
|
return {
|
12
29
|
error: {
|
@@ -67,6 +84,7 @@ async function createNxReleaseConfig(projectGraph, userConfig = {}) {
|
|
67
84
|
userGroups[0].projectsRelationship === 'independent') ||
|
68
85
|
(userConfig.projectsRelationship === 'independent' &&
|
69
86
|
!userGroups.some((g) => g.projectsRelationship === 'fixed'));
|
87
|
+
const defaultRendererPath = (0, path_1.join)(__dirname, '../../../../release/changelog-renderer');
|
70
88
|
const WORKSPACE_DEFAULTS = {
|
71
89
|
// By default all projects in all groups are released together
|
72
90
|
projectsRelationship: workspaceProjectsRelationship,
|
@@ -76,6 +94,7 @@ async function createNxReleaseConfig(projectGraph, userConfig = {}) {
|
|
76
94
|
conventionalCommits: userConfig.version?.conventionalCommits || false,
|
77
95
|
generator: '@nx/js:release-version',
|
78
96
|
generatorOptions: defaultGeneratorOptions,
|
97
|
+
preVersionCommand: userConfig.version?.preVersionCommand || '',
|
79
98
|
},
|
80
99
|
changelog: {
|
81
100
|
git: changelogGitDefaults,
|
@@ -85,7 +104,7 @@ async function createNxReleaseConfig(projectGraph, userConfig = {}) {
|
|
85
104
|
createRelease: false,
|
86
105
|
entryWhenNoChanges: 'This was a version bump only, there were no code changes.',
|
87
106
|
file: '{workspaceRoot}/CHANGELOG.md',
|
88
|
-
renderer:
|
107
|
+
renderer: defaultRendererPath,
|
89
108
|
renderOptions: {
|
90
109
|
authors: true,
|
91
110
|
commitReferences: true,
|
@@ -98,7 +117,7 @@ async function createNxReleaseConfig(projectGraph, userConfig = {}) {
|
|
98
117
|
createRelease: false,
|
99
118
|
file: '{projectRoot}/CHANGELOG.md',
|
100
119
|
entryWhenNoChanges: 'This was a version bump only for {projectName} to align it with other projects, there were no code changes.',
|
101
|
-
renderer:
|
120
|
+
renderer: defaultRendererPath,
|
102
121
|
renderOptions: {
|
103
122
|
authors: true,
|
104
123
|
commitReferences: true,
|
@@ -113,6 +132,7 @@ async function createNxReleaseConfig(projectGraph, userConfig = {}) {
|
|
113
132
|
(workspaceProjectsRelationship === 'independent'
|
114
133
|
? defaultIndependentReleaseTagPattern
|
115
134
|
: defaultFixedReleaseTagPattern),
|
135
|
+
conventionalCommits: conventional_commits_1.DEFAULT_CONVENTIONAL_COMMITS_CONFIG,
|
116
136
|
};
|
117
137
|
const groupProjectsRelationship = userConfig.projectsRelationship || WORKSPACE_DEFAULTS.projectsRelationship;
|
118
138
|
const GROUP_DEFAULTS = {
|
@@ -126,7 +146,7 @@ async function createNxReleaseConfig(projectGraph, userConfig = {}) {
|
|
126
146
|
createRelease: false,
|
127
147
|
entryWhenNoChanges: 'This was a version bump only for {projectName} to align it with other projects, there were no code changes.',
|
128
148
|
file: '{projectRoot}/CHANGELOG.md',
|
129
|
-
renderer:
|
149
|
+
renderer: defaultRendererPath,
|
130
150
|
renderOptions: {
|
131
151
|
authors: true,
|
132
152
|
commitReferences: true,
|
@@ -166,20 +186,23 @@ async function createNxReleaseConfig(projectGraph, userConfig = {}) {
|
|
166
186
|
git: userConfig.git,
|
167
187
|
},
|
168
188
|
], normalizeTrueToEmptyObject(userConfig.changelog));
|
169
|
-
|
170
|
-
|
171
|
-
|
189
|
+
const rootConventionalCommitsConfig = deepMergeDefaults([WORKSPACE_DEFAULTS.conventionalCommits], fillUnspecifiedConventionalCommitsProperties(normalizeConventionalCommitsConfig(userConfig.conventionalCommits)));
|
190
|
+
// these options are not supported at the group level, only the root/command level
|
191
|
+
const rootVersionWithoutGlobalOptions = { ...rootVersionConfig };
|
192
|
+
delete rootVersionWithoutGlobalOptions.git;
|
193
|
+
delete rootVersionWithoutGlobalOptions.preVersionCommand;
|
172
194
|
// Apply conventionalCommits shorthand to the final group defaults if explicitly configured in the original user config
|
173
195
|
if (userConfig.version?.conventionalCommits === true) {
|
174
|
-
|
175
|
-
...
|
196
|
+
rootVersionWithoutGlobalOptions.generatorOptions = {
|
197
|
+
...rootVersionWithoutGlobalOptions.generatorOptions,
|
176
198
|
currentVersionResolver: 'git-tag',
|
177
199
|
specifierSource: 'conventional-commits',
|
178
200
|
};
|
179
201
|
}
|
180
202
|
if (userConfig.version?.conventionalCommits === false) {
|
181
|
-
delete
|
182
|
-
|
203
|
+
delete rootVersionWithoutGlobalOptions.generatorOptions
|
204
|
+
.currentVersionResolver;
|
205
|
+
delete rootVersionWithoutGlobalOptions.generatorOptions.specifierSource;
|
183
206
|
}
|
184
207
|
const groups = userConfig.groups && Object.keys(userConfig.groups).length
|
185
208
|
? ensureProjectsConfigIsArray(userConfig.groups)
|
@@ -193,14 +216,13 @@ async function createNxReleaseConfig(projectGraph, userConfig = {}) {
|
|
193
216
|
projects: userConfig.projects
|
194
217
|
? // user-defined top level "projects" config takes priority if set
|
195
218
|
(0, find_matching_projects_1.findMatchingProjects)(ensureArray(userConfig.projects), projectGraph.nodes)
|
196
|
-
:
|
197
|
-
(0, find_matching_projects_1.findMatchingProjects)(['*'], projectGraph.nodes).filter((project) => projectGraph.nodes[project].type === 'lib'),
|
219
|
+
: await getDefaultProjects(projectGraph, projectFileMap),
|
198
220
|
/**
|
199
221
|
* For properties which are overriding config at the root, we use the root level config as the
|
200
222
|
* default values to merge with so that the group that matches a specific project will always
|
201
223
|
* be the valid source of truth for that type of config.
|
202
224
|
*/
|
203
|
-
version: deepMergeDefaults([GROUP_DEFAULTS.version],
|
225
|
+
version: deepMergeDefaults([GROUP_DEFAULTS.version], rootVersionWithoutGlobalOptions),
|
204
226
|
// If the user has set something custom for releaseTagPattern at the top level, respect it for the implicit default group
|
205
227
|
releaseTagPattern: userConfig.releaseTagPattern || GROUP_DEFAULTS.releaseTagPattern,
|
206
228
|
// Directly inherit the root level config for projectChangelogs, if set
|
@@ -265,7 +287,7 @@ async function createNxReleaseConfig(projectGraph, userConfig = {}) {
|
|
265
287
|
projects: matchingProjects,
|
266
288
|
version: deepMergeDefaults(
|
267
289
|
// First apply any group level defaults, then apply actual root level config, then group level config
|
268
|
-
[GROUP_DEFAULTS.version,
|
290
|
+
[GROUP_DEFAULTS.version, rootVersionWithoutGlobalOptions], releaseGroup.version),
|
269
291
|
// If the user has set any changelog config at all, including at the root level, then use one set of defaults, otherwise default to false for the whole feature
|
270
292
|
changelog: releaseGroup.changelog || rootChangelogConfig.projectChangelogs
|
271
293
|
? deepMergeDefaults(groupChangelogDefaults, releaseGroup.changelog || {})
|
@@ -305,6 +327,7 @@ async function createNxReleaseConfig(projectGraph, userConfig = {}) {
|
|
305
327
|
version: rootVersionConfig,
|
306
328
|
changelog: rootChangelogConfig,
|
307
329
|
groups: releaseGroups,
|
330
|
+
conventionalCommits: rootConventionalCommitsConfig,
|
308
331
|
},
|
309
332
|
};
|
310
333
|
}
|
@@ -317,6 +340,87 @@ exports.createNxReleaseConfig = createNxReleaseConfig;
|
|
317
340
|
function normalizeTrueToEmptyObject(value) {
|
318
341
|
return value === true ? {} : value;
|
319
342
|
}
|
343
|
+
function normalizeConventionalCommitsConfig(userConventionalCommitsConfig) {
|
344
|
+
if (!userConventionalCommitsConfig || !userConventionalCommitsConfig.types) {
|
345
|
+
return userConventionalCommitsConfig;
|
346
|
+
}
|
347
|
+
const types = {};
|
348
|
+
for (const [t, typeConfig] of Object.entries(userConventionalCommitsConfig.types)) {
|
349
|
+
if (typeConfig === false) {
|
350
|
+
types[t] = {
|
351
|
+
semverBump: 'none',
|
352
|
+
changelog: {
|
353
|
+
hidden: true,
|
354
|
+
},
|
355
|
+
};
|
356
|
+
continue;
|
357
|
+
}
|
358
|
+
if (typeConfig === true) {
|
359
|
+
types[t] = {};
|
360
|
+
continue;
|
361
|
+
}
|
362
|
+
if (typeConfig.changelog === false) {
|
363
|
+
types[t] = {
|
364
|
+
...typeConfig,
|
365
|
+
changelog: {
|
366
|
+
hidden: true,
|
367
|
+
},
|
368
|
+
};
|
369
|
+
continue;
|
370
|
+
}
|
371
|
+
if (typeConfig.changelog === true) {
|
372
|
+
types[t] = {
|
373
|
+
...typeConfig,
|
374
|
+
changelog: {},
|
375
|
+
};
|
376
|
+
continue;
|
377
|
+
}
|
378
|
+
types[t] = typeConfig;
|
379
|
+
}
|
380
|
+
return {
|
381
|
+
...userConventionalCommitsConfig,
|
382
|
+
types,
|
383
|
+
};
|
384
|
+
}
|
385
|
+
/**
|
386
|
+
* New, custom types specified by users will not be given the appropriate
|
387
|
+
* defaults with `deepMergeDefaults`, so we need to fill in the gaps here.
|
388
|
+
*/
|
389
|
+
function fillUnspecifiedConventionalCommitsProperties(config) {
|
390
|
+
if (!config || !config.types) {
|
391
|
+
return config;
|
392
|
+
}
|
393
|
+
const types = {};
|
394
|
+
for (const [t, typeConfig] of Object.entries(config.types)) {
|
395
|
+
const defaultTypeConfig = conventional_commits_1.DEFAULT_CONVENTIONAL_COMMITS_CONFIG.types[t];
|
396
|
+
const semverBump = typeConfig.semverBump ||
|
397
|
+
// preserve our default semver bump if it's not 'none'
|
398
|
+
// this prevents a 'feat' from becoming a 'patch' just
|
399
|
+
// because they modified the changelog config for 'feat'
|
400
|
+
(defaultTypeConfig?.semverBump !== 'none' &&
|
401
|
+
defaultTypeConfig?.semverBump) ||
|
402
|
+
'patch';
|
403
|
+
// don't preserve our default behavior for hidden, ever.
|
404
|
+
// we should assume that if users are explicitly enabling a
|
405
|
+
// type, then they intend it to be visible in the changelog
|
406
|
+
const hidden = typeConfig.changelog?.hidden || false;
|
407
|
+
const title = typeConfig.changelog?.title ||
|
408
|
+
// our default title is better than just the unmodified type name
|
409
|
+
defaultTypeConfig?.changelog.title ||
|
410
|
+
t;
|
411
|
+
types[t] = {
|
412
|
+
semverBump,
|
413
|
+
changelog: {
|
414
|
+
hidden,
|
415
|
+
title,
|
416
|
+
},
|
417
|
+
};
|
418
|
+
}
|
419
|
+
return {
|
420
|
+
...config,
|
421
|
+
types,
|
422
|
+
};
|
423
|
+
}
|
320
424
|
async function handleNxReleaseConfigError(error) {
|
321
425
|
switch (error.code) {
|
322
426
|
case 'PROJECTS_AND_GROUPS_DEFINED':
|
@@ -325,7 +429,7 @@ async function handleNxReleaseConfigError(error) {
|
|
325
429
|
'release',
|
326
430
|
'projects',
|
327
431
|
]);
|
328
|
-
|
432
|
+
output_1.output.error({
|
329
433
|
title: `"projects" is not valid when explicitly defining release groups, and everything should be expressed within "groups" in that case. If you are using "groups" then you should remove the "projects" property`,
|
330
434
|
bodyLines: [nxJsonMessage],
|
331
435
|
});
|
@@ -337,7 +441,7 @@ async function handleNxReleaseConfigError(error) {
|
|
337
441
|
'release',
|
338
442
|
'groups',
|
339
443
|
]);
|
340
|
-
|
444
|
+
output_1.output.error({
|
341
445
|
title: `Release group "${error.data.releaseGroupName}" matches no projects. Please ensure all release groups match at least one project:`,
|
342
446
|
bodyLines: [nxJsonMessage],
|
343
447
|
});
|
@@ -349,7 +453,7 @@ async function handleNxReleaseConfigError(error) {
|
|
349
453
|
'release',
|
350
454
|
'groups',
|
351
455
|
]);
|
352
|
-
|
456
|
+
output_1.output.error({
|
353
457
|
title: `Project "${error.data.project}" matches multiple release groups. Please ensure all projects are part of only one release group:`,
|
354
458
|
bodyLines: [nxJsonMessage],
|
355
459
|
});
|
@@ -363,7 +467,7 @@ async function handleNxReleaseConfigError(error) {
|
|
363
467
|
error.data.releaseGroupName,
|
364
468
|
'releaseTagPattern',
|
365
469
|
]);
|
366
|
-
|
470
|
+
output_1.output.error({
|
367
471
|
title: `Release group "${error.data.releaseGroupName}" has an invalid releaseTagPattern. Please ensure the pattern contains exactly one instance of the "{version}" placeholder`,
|
368
472
|
bodyLines: [nxJsonMessage],
|
369
473
|
});
|
@@ -374,7 +478,7 @@ async function handleNxReleaseConfigError(error) {
|
|
374
478
|
const nxJsonMessage = await (0, resolve_nx_json_error_message_1.resolveNxJsonConfigErrorMessage)([
|
375
479
|
'release',
|
376
480
|
]);
|
377
|
-
|
481
|
+
output_1.output.error({
|
378
482
|
title: `You have configured both the shorthand "version.conventionalCommits" and one or more of the related "version.generatorOptions" that it sets for you. Please use one or the other:`,
|
379
483
|
bodyLines: [nxJsonMessage],
|
380
484
|
});
|
@@ -386,7 +490,7 @@ async function handleNxReleaseConfigError(error) {
|
|
386
490
|
'release',
|
387
491
|
'git',
|
388
492
|
]);
|
389
|
-
|
493
|
+
output_1.output.error({
|
390
494
|
title: `You have duplicate conflicting git configurations. If you are using the top level 'nx release' command, then remove the 'release.version.git' and 'release.changelog.git' properties in favor of 'release.git'. If you are using the subcommands or the programmatic API, then remove the 'release.git' property in favor of 'release.version.git' and 'release.changelog.git':`,
|
391
495
|
bodyLines: [nxJsonMessage],
|
392
496
|
});
|
@@ -499,3 +603,28 @@ function hasInvalidConventionalCommitsConfig(userConfig) {
|
|
499
603
|
function hasInvalidGitConfig(userConfig) {
|
500
604
|
return (!!userConfig.git && !!(userConfig.version?.git || userConfig.changelog?.git));
|
501
605
|
}
|
606
|
+
async function getDefaultProjects(projectGraph, projectFileMap) {
|
607
|
+
// default to all library projects in the workspace with a package.json file
|
608
|
+
return (0, find_matching_projects_1.findMatchingProjects)(['*'], projectGraph.nodes).filter((project) => projectGraph.nodes[project].type === 'lib' &&
|
609
|
+
// Exclude all projects with "private": true in their package.json because this is
|
610
|
+
// a common indicator that a project is not intended for release.
|
611
|
+
// Users can override this behavior by explicitly defining the projects they want to release.
|
612
|
+
isProjectPublic(project, projectGraph, projectFileMap));
|
613
|
+
}
|
614
|
+
function isProjectPublic(project, projectGraph, projectFileMap) {
|
615
|
+
const projectNode = projectGraph.nodes[project];
|
616
|
+
const packageJsonPath = (0, path_1.join)(projectNode.data.root, 'package.json');
|
617
|
+
if (!projectFileMap[project]?.find((f) => f.file === packageJsonPath)) {
|
618
|
+
return false;
|
619
|
+
}
|
620
|
+
try {
|
621
|
+
const fullPackageJsonPath = (0, path_1.join)(workspace_root_1.workspaceRoot, packageJsonPath);
|
622
|
+
const packageJson = (0, fileutils_1.readJsonFile)(fullPackageJsonPath);
|
623
|
+
return !(packageJson.private === true);
|
624
|
+
}
|
625
|
+
catch (e) {
|
626
|
+
// do nothing and assume that the project is not public if there is a parsing issue
|
627
|
+
// this will result in it being excluded from the default projects list
|
628
|
+
return false;
|
629
|
+
}
|
630
|
+
}
|
@@ -0,0 +1,98 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.DEFAULT_CONVENTIONAL_COMMITS_CONFIG = void 0;
|
4
|
+
exports.DEFAULT_CONVENTIONAL_COMMITS_CONFIG = {
|
5
|
+
types: {
|
6
|
+
feat: {
|
7
|
+
semverBump: 'minor',
|
8
|
+
changelog: {
|
9
|
+
title: '🚀 Features',
|
10
|
+
hidden: false,
|
11
|
+
},
|
12
|
+
},
|
13
|
+
fix: {
|
14
|
+
semverBump: 'patch',
|
15
|
+
changelog: {
|
16
|
+
title: '🩹 Fixes',
|
17
|
+
hidden: false,
|
18
|
+
},
|
19
|
+
},
|
20
|
+
perf: {
|
21
|
+
semverBump: 'none',
|
22
|
+
changelog: {
|
23
|
+
title: '🔥 Performance',
|
24
|
+
hidden: false,
|
25
|
+
},
|
26
|
+
},
|
27
|
+
refactor: {
|
28
|
+
semverBump: 'none',
|
29
|
+
changelog: {
|
30
|
+
title: '💅 Refactors',
|
31
|
+
hidden: true,
|
32
|
+
},
|
33
|
+
},
|
34
|
+
docs: {
|
35
|
+
semverBump: 'none',
|
36
|
+
changelog: {
|
37
|
+
title: '📖 Documentation',
|
38
|
+
hidden: true,
|
39
|
+
},
|
40
|
+
},
|
41
|
+
build: {
|
42
|
+
semverBump: 'none',
|
43
|
+
changelog: {
|
44
|
+
title: '📦 Build',
|
45
|
+
hidden: true,
|
46
|
+
},
|
47
|
+
},
|
48
|
+
types: {
|
49
|
+
semverBump: 'none',
|
50
|
+
changelog: {
|
51
|
+
title: '🌊 Types',
|
52
|
+
hidden: true,
|
53
|
+
},
|
54
|
+
},
|
55
|
+
chore: {
|
56
|
+
semverBump: 'none',
|
57
|
+
changelog: {
|
58
|
+
title: '🏡 Chore',
|
59
|
+
hidden: true,
|
60
|
+
},
|
61
|
+
},
|
62
|
+
examples: {
|
63
|
+
semverBump: 'none',
|
64
|
+
changelog: {
|
65
|
+
title: '🏀 Examples',
|
66
|
+
hidden: true,
|
67
|
+
},
|
68
|
+
},
|
69
|
+
test: {
|
70
|
+
semverBump: 'none',
|
71
|
+
changelog: {
|
72
|
+
title: '✅ Tests',
|
73
|
+
hidden: true,
|
74
|
+
},
|
75
|
+
},
|
76
|
+
style: {
|
77
|
+
semverBump: 'none',
|
78
|
+
changelog: {
|
79
|
+
title: '🎨 Styles',
|
80
|
+
hidden: true,
|
81
|
+
},
|
82
|
+
},
|
83
|
+
ci: {
|
84
|
+
semverBump: 'none',
|
85
|
+
changelog: {
|
86
|
+
title: '🤖 CI',
|
87
|
+
hidden: true,
|
88
|
+
},
|
89
|
+
},
|
90
|
+
revert: {
|
91
|
+
semverBump: 'none',
|
92
|
+
changelog: {
|
93
|
+
title: '⏪ Revert',
|
94
|
+
hidden: true,
|
95
|
+
},
|
96
|
+
},
|
97
|
+
},
|
98
|
+
};
|
@@ -2,10 +2,11 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.releasePublish = exports.releasePublishCLIHandler = void 0;
|
4
4
|
const nx_json_1 = require("../../config/nx-json");
|
5
|
-
const
|
5
|
+
const file_map_utils_1 = require("../../project-graph/file-map-utils");
|
6
6
|
const project_graph_1 = require("../../project-graph/project-graph");
|
7
7
|
const run_command_1 = require("../../tasks-runner/run-command");
|
8
8
|
const command_line_utils_1 = require("../../utils/command-line-utils");
|
9
|
+
const output_1 = require("../../utils/output");
|
9
10
|
const params_1 = require("../../utils/params");
|
10
11
|
const project_graph_utils_1 = require("../../utils/project-graph-utils");
|
11
12
|
const graph_1 = require("../graph/graph");
|
@@ -33,13 +34,13 @@ async function releasePublish(args, isCLI = false) {
|
|
33
34
|
process.env.NX_VERBOSE_LOGGING = 'true';
|
34
35
|
}
|
35
36
|
// Apply default configuration to any optional user configuration
|
36
|
-
const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, nxJson.release);
|
37
|
+
const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, await (0, file_map_utils_1.createProjectFileMapUsingProjectGraph)(projectGraph), nxJson.release);
|
37
38
|
if (configError) {
|
38
39
|
return await (0, config_1.handleNxReleaseConfigError)(configError);
|
39
40
|
}
|
40
41
|
const { error: filterError, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, _args.projects, _args.groups);
|
41
42
|
if (filterError) {
|
42
|
-
|
43
|
+
output_1.output.error(filterError);
|
43
44
|
process.exit(1);
|
44
45
|
}
|
45
46
|
/**
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.release = exports.releaseCLIHandler = void 0;
|
4
4
|
const enquirer_1 = require("enquirer");
|
5
5
|
const nx_json_1 = require("../../config/nx-json");
|
6
|
-
const
|
6
|
+
const file_map_utils_1 = require("../../project-graph/file-map-utils");
|
7
7
|
const project_graph_1 = require("../../project-graph/project-graph");
|
8
|
+
const output_1 = require("../../utils/output");
|
8
9
|
const params_1 = require("../../utils/params");
|
9
10
|
const changelog_1 = require("./changelog");
|
10
11
|
const config_1 = require("./config/config");
|
@@ -30,14 +31,14 @@ async function release(args) {
|
|
30
31
|
? ['release', 'version', 'git']
|
31
32
|
: ['release', 'changelog', 'git'];
|
32
33
|
const nxJsonMessage = await (0, resolve_nx_json_error_message_1.resolveNxJsonConfigErrorMessage)(jsonConfigErrorPath);
|
33
|
-
|
34
|
+
output_1.output.error({
|
34
35
|
title: `The "release" top level command cannot be used with granular git configuration. Instead, configure git options in the "release.git" property in nx.json, or use the version, changelog, and publish subcommands or programmatic API directly.`,
|
35
36
|
bodyLines: [nxJsonMessage],
|
36
37
|
});
|
37
38
|
process.exit(1);
|
38
39
|
}
|
39
40
|
// Apply default configuration to any optional user configuration
|
40
|
-
const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, nxJson.release);
|
41
|
+
const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, await (0, file_map_utils_1.createProjectFileMapUsingProjectGraph)(projectGraph), nxJson.release);
|
41
42
|
if (configError) {
|
42
43
|
return await (0, config_1.handleNxReleaseConfigError)(configError);
|
43
44
|
}
|
@@ -63,11 +64,11 @@ async function release(args) {
|
|
63
64
|
});
|
64
65
|
const { error: filterError, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, args.projects, args.groups);
|
65
66
|
if (filterError) {
|
66
|
-
|
67
|
+
output_1.output.error(filterError);
|
67
68
|
process.exit(1);
|
68
69
|
}
|
69
70
|
if (shouldCommit) {
|
70
|
-
|
71
|
+
output_1.output.logSingleLine(`Committing changes with git`);
|
71
72
|
const commitMessage = nxReleaseConfig.git.commitMessage;
|
72
73
|
const commitMessageValues = (0, shared_1.createCommitMessageValues)(releaseGroups, releaseGroupToFilteredProjects, versionResult.projectsVersionData, commitMessage);
|
73
74
|
await (0, git_1.gitCommit)({
|
@@ -78,7 +79,7 @@ async function release(args) {
|
|
78
79
|
});
|
79
80
|
}
|
80
81
|
if (shouldTag) {
|
81
|
-
|
82
|
+
output_1.output.logSingleLine(`Tagging commit with git`);
|
82
83
|
// 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
|
83
84
|
const gitTagValues = (0, shared_1.createGitTagValues)(releaseGroups, releaseGroupToFilteredProjects, versionResult.projectsVersionData);
|
84
85
|
(0, shared_1.handleDuplicateGitTags)(gitTagValues);
|
@@ -96,14 +97,14 @@ async function release(args) {
|
|
96
97
|
let hasPushedChanges = false;
|
97
98
|
let latestCommit;
|
98
99
|
if (shouldCreateWorkspaceRelease && changelogResult.workspaceChangelog) {
|
99
|
-
|
100
|
+
output_1.output.logSingleLine(`Pushing to git remote`);
|
100
101
|
// Before we can create/update the release we need to ensure the commit exists on the remote
|
101
102
|
await (0, git_1.gitPush)({
|
102
103
|
dryRun: args.dryRun,
|
103
104
|
verbose: args.verbose,
|
104
105
|
});
|
105
106
|
hasPushedChanges = true;
|
106
|
-
|
107
|
+
output_1.output.logSingleLine(`Creating GitHub Release`);
|
107
108
|
latestCommit = await (0, git_1.getCommitHash)('HEAD');
|
108
109
|
await (0, github_1.createOrUpdateGithubRelease)(changelogResult.workspaceChangelog.releaseVersion, changelogResult.workspaceChangelog.contents, latestCommit, { dryRun: args.dryRun });
|
109
110
|
}
|
@@ -122,7 +123,7 @@ async function release(args) {
|
|
122
123
|
continue;
|
123
124
|
}
|
124
125
|
if (!hasPushedChanges) {
|
125
|
-
|
126
|
+
output_1.output.logSingleLine(`Pushing to git remote`);
|
126
127
|
// Before we can create/update the release we need to ensure the commit exists on the remote
|
127
128
|
await (0, git_1.gitPush)({
|
128
129
|
dryRun: args.dryRun,
|
@@ -130,7 +131,7 @@ async function release(args) {
|
|
130
131
|
});
|
131
132
|
hasPushedChanges = true;
|
132
133
|
}
|
133
|
-
|
134
|
+
output_1.output.logSingleLine(`Creating GitHub Release`);
|
134
135
|
if (!latestCommit) {
|
135
136
|
latestCommit = await (0, git_1.getCommitHash)('HEAD');
|
136
137
|
}
|
@@ -152,7 +153,7 @@ async function release(args) {
|
|
152
153
|
await (0, publish_1.releasePublish)(args);
|
153
154
|
}
|
154
155
|
else {
|
155
|
-
|
156
|
+
output_1.output.logSingleLine('Skipped publishing packages.');
|
156
157
|
}
|
157
158
|
return versionResult;
|
158
159
|
}
|
@@ -92,7 +92,26 @@ async function getGitDiff(from, to = 'HEAD') {
|
|
92
92
|
exports.getGitDiff = getGitDiff;
|
93
93
|
async function gitAdd({ changedFiles, dryRun, verbose, logFn, }) {
|
94
94
|
logFn = logFn || console.log;
|
95
|
-
|
95
|
+
let ignoredFiles = [];
|
96
|
+
let filesToAdd = [];
|
97
|
+
for (const f of changedFiles) {
|
98
|
+
const isFileIgnored = await isIgnored(f);
|
99
|
+
if (isFileIgnored) {
|
100
|
+
ignoredFiles.push(f);
|
101
|
+
}
|
102
|
+
else {
|
103
|
+
filesToAdd.push(f);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
if (verbose && ignoredFiles.length) {
|
107
|
+
logFn(`Will not add the following files because they are ignored by git:`);
|
108
|
+
ignoredFiles.forEach((f) => logFn(f));
|
109
|
+
}
|
110
|
+
if (!filesToAdd.length) {
|
111
|
+
logFn('\nNo files to stage. Skipping git add.');
|
112
|
+
return;
|
113
|
+
}
|
114
|
+
const commandArgs = ['add', ...filesToAdd];
|
96
115
|
const message = dryRun
|
97
116
|
? `Would stage files in git with the following command, but --dry-run was set:`
|
98
117
|
: `Staging files in git with the following command:`;
|
@@ -106,6 +125,16 @@ async function gitAdd({ changedFiles, dryRun, verbose, logFn, }) {
|
|
106
125
|
return (0, exec_command_1.execCommand)('git', commandArgs);
|
107
126
|
}
|
108
127
|
exports.gitAdd = gitAdd;
|
128
|
+
async function isIgnored(filePath) {
|
129
|
+
try {
|
130
|
+
// This command will error if the file is not ignored
|
131
|
+
await (0, exec_command_1.execCommand)('git', ['check-ignore', filePath]);
|
132
|
+
return true;
|
133
|
+
}
|
134
|
+
catch {
|
135
|
+
return false;
|
136
|
+
}
|
137
|
+
}
|
109
138
|
async function gitCommit({ messages, additionalArgs, dryRun, verbose, logFn, }) {
|
110
139
|
logFn = logFn || console.log;
|
111
140
|
const commandArgs = ['commit'];
|
@@ -1,3 +1,4 @@
|
|
1
1
|
import { ProjectGraph } from '../../../config/project-graph';
|
2
|
-
|
2
|
+
import { NxReleaseConfig } from '../config/config';
|
3
|
+
export declare function resolveSemverSpecifierFromConventionalCommits(from: string, projectGraph: ProjectGraph, projectNames: string[], conventionalCommitsConfig: NxReleaseConfig['conventionalCommits']): Promise<string | null>;
|
3
4
|
export declare function resolveSemverSpecifierFromPrompt(selectionMessage: string, customVersionMessage: string): Promise<string>;
|
@@ -6,22 +6,11 @@ const semver_1 = require("semver");
|
|
6
6
|
const git_1 = require("./git");
|
7
7
|
const semver_2 = require("./semver");
|
8
8
|
const shared_1 = require("./shared");
|
9
|
-
|
10
|
-
const CONVENTIONAL_COMMITS_CONFIG = {
|
11
|
-
types: {
|
12
|
-
feat: {
|
13
|
-
semver: 'minor',
|
14
|
-
},
|
15
|
-
fix: {
|
16
|
-
semver: 'patch',
|
17
|
-
},
|
18
|
-
},
|
19
|
-
};
|
20
|
-
async function resolveSemverSpecifierFromConventionalCommits(from, projectGraph, projectNames) {
|
9
|
+
async function resolveSemverSpecifierFromConventionalCommits(from, projectGraph, projectNames, conventionalCommitsConfig) {
|
21
10
|
const commits = await (0, git_1.getGitDiff)(from);
|
22
11
|
const parsedCommits = (0, git_1.parseCommits)(commits);
|
23
12
|
const relevantCommits = await (0, shared_1.getCommitsRelevantToProjects)(projectGraph, parsedCommits, projectNames);
|
24
|
-
return (0, semver_2.determineSemverChange)(relevantCommits,
|
13
|
+
return (0, semver_2.determineSemverChange)(relevantCommits, conventionalCommitsConfig);
|
25
14
|
}
|
26
15
|
exports.resolveSemverSpecifierFromConventionalCommits = resolveSemverSpecifierFromConventionalCommits;
|
27
16
|
async function resolveSemverSpecifierFromPrompt(selectionMessage, customVersionMessage) {
|
@@ -3,15 +3,9 @@
|
|
3
3
|
* https://github.com/unjs/changelogen
|
4
4
|
*/
|
5
5
|
import { ReleaseType } from 'semver';
|
6
|
+
import { NxReleaseConfig } from '../config/config';
|
6
7
|
import { GitCommit } from './git';
|
7
8
|
export declare function isRelativeVersionKeyword(val: string): val is ReleaseType;
|
8
9
|
export declare function isValidSemverSpecifier(specifier: string): boolean;
|
9
|
-
export
|
10
|
-
types: {
|
11
|
-
[type: string]: {
|
12
|
-
semver: 'patch' | 'minor' | 'major';
|
13
|
-
};
|
14
|
-
};
|
15
|
-
}
|
16
|
-
export declare function determineSemverChange(commits: GitCommit[], config: ConventionalCommitsConfig): 'patch' | 'minor' | 'major' | null;
|
10
|
+
export declare function determineSemverChange(commits: GitCommit[], config: NxReleaseConfig['conventionalCommits']): 'patch' | 'minor' | 'major' | null;
|
17
11
|
export declare function deriveNewSemverVersion(currentSemverVersion: string, semverSpecifier: string, preid?: string): string;
|
@@ -18,7 +18,7 @@ exports.isValidSemverSpecifier = isValidSemverSpecifier;
|
|
18
18
|
function determineSemverChange(commits, config) {
|
19
19
|
let [hasMajor, hasMinor, hasPatch] = [false, false, false];
|
20
20
|
for (const commit of commits) {
|
21
|
-
const semverType = config.types[commit.type]?.
|
21
|
+
const semverType = config.types[commit.type]?.semverBump;
|
22
22
|
if (semverType === 'major' || commit.isBreaking) {
|
23
23
|
hasMajor = true;
|
24
24
|
}
|
@@ -28,6 +28,9 @@ function determineSemverChange(commits, config) {
|
|
28
28
|
else if (semverType === 'patch') {
|
29
29
|
hasPatch = true;
|
30
30
|
}
|
31
|
+
else if (semverType === 'none' || !semverType) {
|
32
|
+
// do not report a change
|
33
|
+
}
|
31
34
|
}
|
32
35
|
return hasMajor ? 'major' : hasMinor ? 'minor' : hasPatch ? 'patch' : null;
|
33
36
|
}
|