nx 20.5.0-beta.3 → 20.5.0-beta.4
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 +11 -11
- package/schemas/nx-schema.json +36 -2
- package/src/command-line/add/add.js +6 -16
- package/src/command-line/init/configure-plugins.d.ts +5 -6
- package/src/command-line/init/configure-plugins.js +13 -22
- package/src/command-line/release/changelog.js +3 -5
- package/src/command-line/release/command-object.d.ts +1 -0
- package/src/command-line/release/command-object.js +5 -0
- package/src/command-line/release/config/config.js +6 -0
- package/src/command-line/release/utils/git.d.ts +1 -1
- package/src/command-line/release/utils/git.js +55 -7
- package/src/config/nx-json.d.ts +19 -1
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/server/server.js +1 -0
- package/src/native/index.d.ts +1 -1
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/lock-file/lock-file.js +28 -13
- package/src/plugins/js/project-graph/affected/lock-file-changes.js +1 -0
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +1 -1
- package/src/plugins/js/utils/typescript.js +3 -3
- package/src/project-graph/plugins/isolation/plugin-worker.js +8 -6
- package/src/tasks-runner/run-command.js +2 -3
- package/src/utils/command-line-utils.d.ts +1 -1
- package/src/utils/package-manager.js +2 -2
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "20.5.0-beta.
|
3
|
+
"version": "20.5.0-beta.4",
|
4
4
|
"private": false,
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
6
6
|
"repository": {
|
@@ -82,16 +82,16 @@
|
|
82
82
|
}
|
83
83
|
},
|
84
84
|
"optionalDependencies": {
|
85
|
-
"@nx/nx-darwin-arm64": "20.5.0-beta.
|
86
|
-
"@nx/nx-darwin-x64": "20.5.0-beta.
|
87
|
-
"@nx/nx-freebsd-x64": "20.5.0-beta.
|
88
|
-
"@nx/nx-linux-arm-gnueabihf": "20.5.0-beta.
|
89
|
-
"@nx/nx-linux-arm64-gnu": "20.5.0-beta.
|
90
|
-
"@nx/nx-linux-arm64-musl": "20.5.0-beta.
|
91
|
-
"@nx/nx-linux-x64-gnu": "20.5.0-beta.
|
92
|
-
"@nx/nx-linux-x64-musl": "20.5.0-beta.
|
93
|
-
"@nx/nx-win32-arm64-msvc": "20.5.0-beta.
|
94
|
-
"@nx/nx-win32-x64-msvc": "20.5.0-beta.
|
85
|
+
"@nx/nx-darwin-arm64": "20.5.0-beta.4",
|
86
|
+
"@nx/nx-darwin-x64": "20.5.0-beta.4",
|
87
|
+
"@nx/nx-freebsd-x64": "20.5.0-beta.4",
|
88
|
+
"@nx/nx-linux-arm-gnueabihf": "20.5.0-beta.4",
|
89
|
+
"@nx/nx-linux-arm64-gnu": "20.5.0-beta.4",
|
90
|
+
"@nx/nx-linux-arm64-musl": "20.5.0-beta.4",
|
91
|
+
"@nx/nx-linux-x64-gnu": "20.5.0-beta.4",
|
92
|
+
"@nx/nx-linux-x64-musl": "20.5.0-beta.4",
|
93
|
+
"@nx/nx-win32-arm64-msvc": "20.5.0-beta.4",
|
94
|
+
"@nx/nx-win32-x64-msvc": "20.5.0-beta.4"
|
95
95
|
},
|
96
96
|
"nx-migrations": {
|
97
97
|
"migrations": "./migrations.json",
|
package/schemas/nx-schema.json
CHANGED
@@ -21,6 +21,10 @@
|
|
21
21
|
"additionalProperties": false,
|
22
22
|
"deprecated": "Use `defaultBase` instead. Support for setting `defaultBase` in `affected` will be removed in Nx 20."
|
23
23
|
},
|
24
|
+
"extends": {
|
25
|
+
"type": "string",
|
26
|
+
"description": "Specifies the base config to extend."
|
27
|
+
},
|
24
28
|
"defaultBase": {
|
25
29
|
"type": "string",
|
26
30
|
"description": "Default --base used by affected logic."
|
@@ -169,7 +173,22 @@
|
|
169
173
|
]
|
170
174
|
},
|
171
175
|
"releaseTagPattern": {
|
172
|
-
"type": "string"
|
176
|
+
"type": "string",
|
177
|
+
"description": "Optionally override the git/release tag pattern to use for this group."
|
178
|
+
},
|
179
|
+
"releaseTagPatternCheckAllBranchesWhen": {
|
180
|
+
"oneOf": [
|
181
|
+
{
|
182
|
+
"type": "boolean"
|
183
|
+
},
|
184
|
+
{
|
185
|
+
"type": "array",
|
186
|
+
"items": {
|
187
|
+
"type": "string"
|
188
|
+
}
|
189
|
+
}
|
190
|
+
],
|
191
|
+
"description": "By default, we will try and resolve the latest match for the releaseTagPattern from the current branch, falling back to all branches if no match is found on the current branch. Setting this to true will cause us to ALWAYS check all branches for the latest match. Setting it to false will cause us to ONLY check the current branch for the latest match. Setting it to an array of strings will cause us to check all branches WHEN the current branch is one of the strings in the array. Glob patterns are supported."
|
173
192
|
},
|
174
193
|
"versionPlans": {
|
175
194
|
"oneOf": [
|
@@ -243,7 +262,22 @@
|
|
243
262
|
]
|
244
263
|
},
|
245
264
|
"releaseTagPattern": {
|
246
|
-
"type": "string"
|
265
|
+
"type": "string",
|
266
|
+
"description": "Optionally override the git/release tag pattern to use. This field is the source of truth for changelog generation and release tagging, as well as for conventional commits parsing. It supports interpolating the version as {version} and (if releasing independently or forcing project level version control system releases) the project name as {projectName} within the string. The default releaseTagPattern for fixed/unified releases is: \"v{version}\". The default releaseTagPattern for independent releases at the project level is: \"{projectName}@{version}\""
|
267
|
+
},
|
268
|
+
"releaseTagPatternCheckAllBranchesWhen": {
|
269
|
+
"oneOf": [
|
270
|
+
{
|
271
|
+
"type": "boolean"
|
272
|
+
},
|
273
|
+
{
|
274
|
+
"type": "array",
|
275
|
+
"items": {
|
276
|
+
"type": "string"
|
277
|
+
}
|
278
|
+
}
|
279
|
+
],
|
280
|
+
"description": "By default, we will try and resolve the latest match for the releaseTagPattern from the current branch, falling back to all branches if no match is found on the current branch. Setting this to true will cause us to ALWAYS check all branches for the latest match. Setting it to false will cause us to ONLY check the current branch for the latest match. Setting it to an array of strings will cause us to check all branches WHEN the current branch is one of the strings in the array. Glob patterns are supported."
|
247
281
|
}
|
248
282
|
}
|
249
283
|
},
|
@@ -5,7 +5,6 @@ exports.addHandler = addHandler;
|
|
5
5
|
const child_process_1 = require("child_process");
|
6
6
|
const fs_1 = require("fs");
|
7
7
|
const ora = require("ora");
|
8
|
-
const yargsParser = require("yargs-parser");
|
9
8
|
const nx_json_1 = require("../../config/nx-json");
|
10
9
|
const child_process_2 = require("../../utils/child-process");
|
11
10
|
const fileutils_1 = require("../../utils/fileutils");
|
@@ -79,27 +78,18 @@ async function installPackage(pkgName, version, nxJson) {
|
|
79
78
|
spinner.succeed();
|
80
79
|
}
|
81
80
|
async function initializePlugin(pkgName, options, nxJson) {
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
'parse-positional-numbers': false,
|
86
|
-
'dot-notation': false,
|
87
|
-
'camel-case-expansion': false,
|
88
|
-
},
|
89
|
-
});
|
90
|
-
if (exports.coreNxPluginVersions.has(pkgName)) {
|
91
|
-
parsedCommandArgs.keepExistingVersions = true;
|
92
|
-
if (options.updatePackageScripts ||
|
81
|
+
let updatePackageScripts = false;
|
82
|
+
if (exports.coreNxPluginVersions.has(pkgName) &&
|
83
|
+
(options.updatePackageScripts ||
|
93
84
|
(options.updatePackageScripts === undefined &&
|
94
85
|
nxJson.useInferencePlugins !== false &&
|
95
|
-
process.env.NX_ADD_PLUGINS !== 'false')) {
|
96
|
-
|
97
|
-
}
|
86
|
+
process.env.NX_ADD_PLUGINS !== 'false'))) {
|
87
|
+
updatePackageScripts = true;
|
98
88
|
}
|
99
89
|
const spinner = ora(`Initializing ${pkgName}...`);
|
100
90
|
spinner.start();
|
101
91
|
try {
|
102
|
-
await (0, configure_plugins_1.installPlugin)(pkgName, workspace_root_1.workspaceRoot, options.verbose
|
92
|
+
await (0, configure_plugins_1.installPlugin)(pkgName, workspace_root_1.workspaceRoot, updatePackageScripts, options.verbose);
|
103
93
|
}
|
104
94
|
catch (e) {
|
105
95
|
spinner.fail();
|
@@ -4,19 +4,18 @@ export declare function runPackageManagerInstallPlugins(repoRoot: string, pmc: P
|
|
4
4
|
* Installs a plugin by running its init generator. It will change the file system tree passed in.
|
5
5
|
* @param plugin The name of the plugin to install
|
6
6
|
* @param repoRoot repo root
|
7
|
-
* @param
|
8
|
-
* @param
|
7
|
+
* @param pmc package manager commands
|
8
|
+
* @param updatePackageScripts whether to update package scripts
|
9
|
+
* @param verbose whether to run in verbose mode
|
9
10
|
* @returns void
|
10
11
|
*/
|
11
|
-
export declare function installPlugin(plugin: string, repoRoot
|
12
|
-
[k: string]: any;
|
13
|
-
}): Promise<void>;
|
12
|
+
export declare function installPlugin(plugin: string, repoRoot?: string, updatePackageScripts?: boolean, verbose?: boolean, pmc?: PackageManagerCommands): Promise<void>;
|
14
13
|
/**
|
15
14
|
* Install plugins
|
16
15
|
* Get the implementation of the plugin's init generator and run it
|
17
16
|
* @returns a list of succeeded plugins and a map of failed plugins to errors
|
18
17
|
*/
|
19
|
-
export declare function installPlugins(plugins: string[], updatePackageScripts: boolean, repoRoot?: string, verbose?: boolean): Promise<{
|
18
|
+
export declare function installPlugins(plugins: string[], updatePackageScripts: boolean, pmc: PackageManagerCommands, repoRoot?: string, verbose?: boolean): Promise<{
|
20
19
|
succeededPlugins: string[];
|
21
20
|
failedPlugins: {
|
22
21
|
[plugin: string]: Error;
|
@@ -7,10 +7,9 @@ exports.configurePlugins = configurePlugins;
|
|
7
7
|
exports.getFailedToInstallPluginErrorMessages = getFailedToInstallPluginErrorMessages;
|
8
8
|
const createSpinner = require("ora");
|
9
9
|
const chalk_1 = require("chalk");
|
10
|
+
const child_process_1 = require("child_process");
|
10
11
|
const package_manager_1 = require("../../utils/package-manager");
|
11
12
|
const output_1 = require("../../utils/output");
|
12
|
-
const tree_1 = require("../../generators/tree");
|
13
|
-
const generator_utils_1 = require("../generate/generator-utils");
|
14
13
|
const workspace_root_1 = require("../../utils/workspace-root");
|
15
14
|
const utils_1 = require("./implementation/utils");
|
16
15
|
const plugins_1 = require("../../utils/plugins");
|
@@ -27,12 +26,12 @@ function runPackageManagerInstallPlugins(repoRoot, pmc = (0, package_manager_1.g
|
|
27
26
|
* Installs a plugin by running its init generator. It will change the file system tree passed in.
|
28
27
|
* @param plugin The name of the plugin to install
|
29
28
|
* @param repoRoot repo root
|
30
|
-
* @param
|
31
|
-
* @param
|
29
|
+
* @param pmc package manager commands
|
30
|
+
* @param updatePackageScripts whether to update package scripts
|
31
|
+
* @param verbose whether to run in verbose mode
|
32
32
|
* @returns void
|
33
33
|
*/
|
34
|
-
async function installPlugin(plugin, repoRoot = workspace_root_1.workspaceRoot, verbose = false,
|
35
|
-
const host = new tree_1.FsTree(repoRoot, verbose, `install ${plugin}`);
|
34
|
+
async function installPlugin(plugin, repoRoot = workspace_root_1.workspaceRoot, updatePackageScripts = false, verbose = false, pmc = (0, package_manager_1.getPackageManagerCommand)()) {
|
36
35
|
const capabilities = await (0, plugins_1.getPluginCapabilities)(repoRoot, plugin, {});
|
37
36
|
const generators = capabilities?.generators;
|
38
37
|
if (!generators) {
|
@@ -45,20 +44,18 @@ async function installPlugin(plugin, repoRoot = workspace_root_1.workspaceRoot,
|
|
45
44
|
});
|
46
45
|
return;
|
47
46
|
}
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
await task();
|
54
|
-
}
|
47
|
+
(0, child_process_1.execSync)(`${pmc.exec} nx g ${plugin}:init --keepExistingVersions ${updatePackageScripts ? '--updatePackageScripts' : ''} ${verbose ? '--verbose' : ''}`, {
|
48
|
+
stdio: [0, 1, 2],
|
49
|
+
cwd: repoRoot,
|
50
|
+
windowsHide: false,
|
51
|
+
});
|
55
52
|
}
|
56
53
|
/**
|
57
54
|
* Install plugins
|
58
55
|
* Get the implementation of the plugin's init generator and run it
|
59
56
|
* @returns a list of succeeded plugins and a map of failed plugins to errors
|
60
57
|
*/
|
61
|
-
async function installPlugins(plugins, updatePackageScripts, repoRoot = workspace_root_1.workspaceRoot, verbose = false) {
|
58
|
+
async function installPlugins(plugins, updatePackageScripts, pmc, repoRoot = workspace_root_1.workspaceRoot, verbose = false) {
|
62
59
|
if (plugins.length === 0) {
|
63
60
|
return {
|
64
61
|
succeededPlugins: [],
|
@@ -71,13 +68,7 @@ async function installPlugins(plugins, updatePackageScripts, repoRoot = workspac
|
|
71
68
|
for (const plugin of plugins) {
|
72
69
|
try {
|
73
70
|
spinner.start('Installing plugin ' + plugin);
|
74
|
-
await installPlugin(plugin, repoRoot, verbose,
|
75
|
-
keepExistingVersions: true,
|
76
|
-
updatePackageScripts,
|
77
|
-
addPlugin: true,
|
78
|
-
skipFormat: false,
|
79
|
-
skipPackageJson: false,
|
80
|
-
});
|
71
|
+
await installPlugin(plugin, repoRoot, updatePackageScripts, verbose, pmc);
|
81
72
|
succeededPlugins.push(plugin);
|
82
73
|
spinner.succeed('Installed plugin ' + plugin);
|
83
74
|
}
|
@@ -103,7 +94,7 @@ async function configurePlugins(plugins, updatePackageScripts, pmc, repoRoot = w
|
|
103
94
|
};
|
104
95
|
}
|
105
96
|
output_1.output.log({ title: '🔨 Configuring plugins' });
|
106
|
-
let { succeededPlugins, failedPlugins } = await installPlugins(plugins, updatePackageScripts, repoRoot, verbose);
|
97
|
+
let { succeededPlugins, failedPlugins } = await installPlugins(plugins, updatePackageScripts, pmc, repoRoot, verbose);
|
107
98
|
if (succeededPlugins.length > 0) {
|
108
99
|
output_1.output.success({
|
109
100
|
title: 'Installed Plugins',
|
@@ -191,8 +191,7 @@ function createAPI(overrideReleaseConfig) {
|
|
191
191
|
}
|
192
192
|
else {
|
193
193
|
let workspaceChangelogFromRef = args.from ||
|
194
|
-
(await (0, git_1.getLatestGitTagForPattern)(nxReleaseConfig.releaseTagPattern))
|
195
|
-
?.tag;
|
194
|
+
(await (0, git_1.getLatestGitTagForPattern)(nxReleaseConfig.releaseTagPattern, {}, nxReleaseConfig.releaseTagPatternCheckAllBranchesWhen))?.tag;
|
196
195
|
if (!workspaceChangelogFromRef) {
|
197
196
|
if (useAutomaticFromRef) {
|
198
197
|
workspaceChangelogFromRef = await (0, git_1.getFirstGitCommit)();
|
@@ -335,7 +334,7 @@ function createAPI(overrideReleaseConfig) {
|
|
335
334
|
(await (0, git_1.getLatestGitTagForPattern)(releaseGroup.releaseTagPattern, {
|
336
335
|
projectName: project.name,
|
337
336
|
releaseGroupName: releaseGroup.name,
|
338
|
-
}))?.tag;
|
337
|
+
}, releaseGroup.releaseTagPatternCheckAllBranchesWhen))?.tag;
|
339
338
|
if (!fromRef && useAutomaticFromRef) {
|
340
339
|
const firstCommit = await (0, git_1.getFirstGitCommit)();
|
341
340
|
const allCommits = await getCommits(firstCommit, toSHA);
|
@@ -442,8 +441,7 @@ function createAPI(overrideReleaseConfig) {
|
|
442
441
|
}
|
443
442
|
else {
|
444
443
|
let fromRef = args.from ||
|
445
|
-
(await (0, git_1.getLatestGitTagForPattern)(releaseGroup.releaseTagPattern))
|
446
|
-
?.tag;
|
444
|
+
(await (0, git_1.getLatestGitTagForPattern)(releaseGroup.releaseTagPattern, {}, releaseGroup.releaseTagPatternCheckAllBranchesWhen))?.tag;
|
447
445
|
if (!fromRef) {
|
448
446
|
if (useAutomaticFromRef) {
|
449
447
|
fromRef = await (0, git_1.getFirstGitCommit)();
|
@@ -58,6 +58,7 @@ export type PlanCheckOptions = BaseNxReleaseArgs & {
|
|
58
58
|
export type ReleaseOptions = NxReleaseArgs & FirstReleaseArgs & {
|
59
59
|
specifier?: string;
|
60
60
|
yes?: boolean;
|
61
|
+
preid?: VersionOptions['preid'];
|
61
62
|
skipPublish?: boolean;
|
62
63
|
};
|
63
64
|
export type VersionPlanArgs = {
|
@@ -75,6 +75,11 @@ const releaseCommand = {
|
|
75
75
|
.positional('specifier', {
|
76
76
|
type: 'string',
|
77
77
|
describe: 'Exact version or semver keyword to apply to the selected release group.',
|
78
|
+
})
|
79
|
+
.option('preid', {
|
80
|
+
type: 'string',
|
81
|
+
describe: 'The optional prerelease identifier to apply to the version. This will only be applied in the case that the specifier argument has been set to `prerelease` OR when conventional commits are enabled, in which case it will modify the resolved specifier from conventional commits to be its prerelease equivalent. E.g. minor -> preminor.',
|
82
|
+
default: '',
|
78
83
|
})
|
79
84
|
.option('yes', {
|
80
85
|
type: 'boolean',
|
@@ -177,6 +177,7 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
|
|
177
177
|
(workspaceProjectsRelationship === 'independent'
|
178
178
|
? defaultIndependentReleaseTagPattern
|
179
179
|
: defaultFixedReleaseTagPattern),
|
180
|
+
releaseTagPatternCheckAllBranchesWhen: userConfig.releaseTagPatternCheckAllBranchesWhen ?? undefined,
|
180
181
|
conventionalCommits: conventional_commits_1.DEFAULT_CONVENTIONAL_COMMITS_CONFIG,
|
181
182
|
versionPlans: (userConfig.versionPlans ||
|
182
183
|
false),
|
@@ -207,6 +208,7 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
|
|
207
208
|
groupProjectsRelationship === 'independent'
|
208
209
|
? defaultIndependentReleaseTagPattern
|
209
210
|
: WORKSPACE_DEFAULTS.releaseTagPattern,
|
211
|
+
releaseTagPatternCheckAllBranchesWhen: userConfig.releaseTagPatternCheckAllBranchesWhen ?? undefined,
|
210
212
|
versionPlans: false,
|
211
213
|
};
|
212
214
|
/**
|
@@ -365,6 +367,9 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
|
|
365
367
|
(projectsRelationship === 'independent'
|
366
368
|
? defaultIndependentReleaseTagPattern
|
367
369
|
: userConfig.releaseTagPattern || defaultFixedReleaseTagPattern),
|
370
|
+
releaseTagPatternCheckAllBranchesWhen: releaseGroup.releaseTagPatternCheckAllBranchesWhen ??
|
371
|
+
userConfig.releaseTagPatternCheckAllBranchesWhen ??
|
372
|
+
undefined,
|
368
373
|
versionPlans: releaseGroup.versionPlans ?? rootVersionPlansConfig,
|
369
374
|
};
|
370
375
|
const finalReleaseGroup = deepMergeDefaults([groupDefaults], {
|
@@ -413,6 +418,7 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
|
|
413
418
|
nxReleaseConfig: {
|
414
419
|
projectsRelationship: WORKSPACE_DEFAULTS.projectsRelationship,
|
415
420
|
releaseTagPattern: WORKSPACE_DEFAULTS.releaseTagPattern,
|
421
|
+
releaseTagPatternCheckAllBranchesWhen: WORKSPACE_DEFAULTS.releaseTagPatternCheckAllBranchesWhen,
|
416
422
|
git: rootGitConfig,
|
417
423
|
version: rootVersionConfig,
|
418
424
|
changelog: rootChangelogConfig,
|
@@ -22,7 +22,7 @@ export interface GitCommit extends RawGitCommit {
|
|
22
22
|
affectedFiles: string[];
|
23
23
|
revertedHashes: string[];
|
24
24
|
}
|
25
|
-
export declare function getLatestGitTagForPattern(releaseTagPattern: string, additionalInterpolationData?: {}): Promise<{
|
25
|
+
export declare function getLatestGitTagForPattern(releaseTagPattern: string, additionalInterpolationData?: {}, checkAllBranchesWhen?: boolean | string[]): Promise<{
|
26
26
|
tag: string;
|
27
27
|
extractedVersion: string;
|
28
28
|
} | null>;
|
@@ -16,6 +16,7 @@ exports.getFirstGitCommit = getFirstGitCommit;
|
|
16
16
|
* https://github.com/unjs/changelogen
|
17
17
|
*/
|
18
18
|
const node_path_1 = require("node:path");
|
19
|
+
const minimatch_1 = require("minimatch");
|
19
20
|
const utils_1 = require("../../../tasks-runner/utils");
|
20
21
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
21
22
|
const exec_command_1 = require("./exec-command");
|
@@ -24,22 +25,69 @@ function escapeRegExp(string) {
|
|
24
25
|
}
|
25
26
|
// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
|
26
27
|
const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/g;
|
27
|
-
async function getLatestGitTagForPattern(releaseTagPattern, additionalInterpolationData = {}) {
|
28
|
+
async function getLatestGitTagForPattern(releaseTagPattern, additionalInterpolationData = {}, checkAllBranchesWhen) {
|
29
|
+
/**
|
30
|
+
* By default, we will try and resolve the latest match for the releaseTagPattern from the current branch,
|
31
|
+
* falling back to all branches if no match is found on the current branch.
|
32
|
+
*
|
33
|
+
* - If checkAllBranchesWhen is true it will cause us to ALWAYS check all branches for the latest match.
|
34
|
+
* - If checkAllBranchesWhen is explicitly set to false it will cause us to ONLY check the current branch for the latest match.
|
35
|
+
* - If checkAllBranchesWhen is an array of strings it will cause us to check all branches WHEN the current branch is one of the strings in the array.
|
36
|
+
*/
|
37
|
+
let alwaysCheckAllBranches = false;
|
38
|
+
if (typeof checkAllBranchesWhen !== 'undefined') {
|
39
|
+
if (typeof checkAllBranchesWhen === 'boolean') {
|
40
|
+
alwaysCheckAllBranches = checkAllBranchesWhen;
|
41
|
+
}
|
42
|
+
else if (Array.isArray(checkAllBranchesWhen)) {
|
43
|
+
/**
|
44
|
+
* Get the current git branch and determine whether to check all branches based on the checkAllBranchesWhen parameter
|
45
|
+
*/
|
46
|
+
const currentBranch = await (0, exec_command_1.execCommand)('git', [
|
47
|
+
'rev-parse',
|
48
|
+
'--abbrev-ref',
|
49
|
+
'HEAD',
|
50
|
+
]).then((r) => r.trim());
|
51
|
+
// Check exact match first
|
52
|
+
alwaysCheckAllBranches = checkAllBranchesWhen.includes(currentBranch);
|
53
|
+
// Check if any glob pattern matches next
|
54
|
+
if (!alwaysCheckAllBranches) {
|
55
|
+
alwaysCheckAllBranches = checkAllBranchesWhen.some((pattern) => {
|
56
|
+
const r = minimatch_1.minimatch.makeRe(pattern, { dot: true });
|
57
|
+
if (!r) {
|
58
|
+
return false;
|
59
|
+
}
|
60
|
+
return r.test(currentBranch);
|
61
|
+
});
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
const defaultGitArgs = [
|
66
|
+
// Apply git config to take version suffixes into account when sorting, e.g. 1.0.0 is newer than 1.0.0-beta.1
|
67
|
+
'-c',
|
68
|
+
'versionsort.suffix=-',
|
69
|
+
'tag',
|
70
|
+
'--sort',
|
71
|
+
'-v:refname',
|
72
|
+
];
|
28
73
|
try {
|
29
74
|
let tags;
|
30
75
|
tags = await (0, exec_command_1.execCommand)('git', [
|
31
|
-
|
32
|
-
'--
|
33
|
-
'-v:refname',
|
34
|
-
'--merged',
|
76
|
+
...defaultGitArgs,
|
77
|
+
...(alwaysCheckAllBranches ? [] : ['--merged']),
|
35
78
|
]).then((r) => r
|
36
79
|
.trim()
|
37
80
|
.split('\n')
|
38
81
|
.map((t) => t.trim())
|
39
82
|
.filter(Boolean));
|
40
|
-
if (
|
83
|
+
if (
|
84
|
+
// Do not run this fallback if the user explicitly set checkAllBranchesWhen to false
|
85
|
+
checkAllBranchesWhen !== false &&
|
86
|
+
!tags.length &&
|
87
|
+
// There is no point in running this fallback if we already checked against all branches
|
88
|
+
!alwaysCheckAllBranches) {
|
41
89
|
// try again, but include all tags on the repo instead of just --merged ones
|
42
|
-
tags = await (0, exec_command_1.execCommand)('git',
|
90
|
+
tags = await (0, exec_command_1.execCommand)('git', defaultGitArgs).then((r) => r
|
43
91
|
.trim()
|
44
92
|
.split('\n')
|
45
93
|
.map((t) => t.trim())
|
package/src/config/nx-json.d.ts
CHANGED
@@ -215,6 +215,15 @@ export interface NxReleaseConfiguration {
|
|
215
215
|
* Optionally override the git/release tag pattern to use for this group.
|
216
216
|
*/
|
217
217
|
releaseTagPattern?: string;
|
218
|
+
/**
|
219
|
+
* By default, we will try and resolve the latest match for the releaseTagPattern from the current branch,
|
220
|
+
* falling back to all branches if no match is found on the current branch.
|
221
|
+
*
|
222
|
+
* - Setting this to true will cause us to ALWAYS check all branches for the latest match.
|
223
|
+
* - Setting it to false will cause us to ONLY check the current branch for the latest match.
|
224
|
+
* - Setting it to an array of strings will cause us to check all branches WHEN the current branch matches one of the strings in the array. Glob patterns are supported.
|
225
|
+
*/
|
226
|
+
releaseTagPatternCheckAllBranchesWhen?: boolean | string[];
|
218
227
|
/**
|
219
228
|
* Enables using version plans as a specifier source for versioning and
|
220
229
|
* to determine changes for changelog generation.
|
@@ -281,6 +290,15 @@ export interface NxReleaseConfiguration {
|
|
281
290
|
* The default releaseTagPattern for independent releases at the project level is: "{projectName}@{version}"
|
282
291
|
*/
|
283
292
|
releaseTagPattern?: string;
|
293
|
+
/**
|
294
|
+
* By default, we will try and resolve the latest match for the releaseTagPattern from the current branch,
|
295
|
+
* falling back to all branches if no match is found on the current branch.
|
296
|
+
*
|
297
|
+
* - Setting this to true will cause us to ALWAYS check all branches for the latest match.
|
298
|
+
* - Setting it to false will cause us to ONLY check the current branch for the latest match.
|
299
|
+
* - Setting it to an array of strings will cause us to check all branches WHEN the current branch matches one of the strings in the array. Glob patterns are supported.
|
300
|
+
*/
|
301
|
+
releaseTagPatternCheckAllBranchesWhen?: boolean | string[];
|
284
302
|
/**
|
285
303
|
* Enable and configure automatic git operations as part of the release
|
286
304
|
*/
|
@@ -358,7 +376,7 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
|
|
358
376
|
appsDir?: string;
|
359
377
|
};
|
360
378
|
/**
|
361
|
-
* @deprecated Custom task runners will
|
379
|
+
* @deprecated Custom task runners will be replaced by a new API starting with Nx 21. More info: https://nx.dev/deprecated/custom-tasks-runner
|
362
380
|
* Available Task Runners for Nx to use
|
363
381
|
*/
|
364
382
|
tasksRunnerOptions?: {
|