@storm-software/git-tools 2.123.18 → 2.124.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/bin/git.cjs +427 -65
- package/bin/git.cjs.map +1 -1
- package/bin/git.js +428 -67
- package/bin/git.js.map +1 -1
- package/dist/chunk-M4QURF2M.cjs +2454 -0
- package/dist/chunk-RJCCG4TV.js +2420 -0
- package/dist/commit/monorepo.d.cts +1 -0
- package/dist/commit/monorepo.d.ts +1 -0
- package/dist/index.cjs +11 -7
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/release/config.cjs +11 -7
- package/dist/release/config.d.cts +13 -2
- package/dist/release/config.d.ts +13 -2
- package/dist/release/config.js +1 -1
- package/dist/types.d.cts +2 -1
- package/dist/types.d.ts +2 -1
- package/package.json +5 -5
- package/dist/chunk-NZHEQPL3.cjs +0 -82
- package/dist/chunk-PKEX4GUO.js +0 -75
package/bin/git.cjs
CHANGED
|
@@ -32,17 +32,18 @@ var printChanges = require('nx/src/command-line/release/utils/print-changes');
|
|
|
32
32
|
var github = require('nx/src/command-line/release/utils/remote-release-clients/github');
|
|
33
33
|
var shared = require('nx/src/command-line/release/utils/shared');
|
|
34
34
|
var yaml = require('yaml');
|
|
35
|
+
var chalk = require('chalk');
|
|
36
|
+
var utils = require('nx/src/tasks-runner/utils');
|
|
35
37
|
var prettier = require('prettier');
|
|
36
38
|
var release = require('nx/release');
|
|
37
|
-
var changelog = require('nx/src/command-line/release/changelog');
|
|
38
39
|
var git = require('nx/src/command-line/release/utils/git');
|
|
39
40
|
var nxJson = require('nx/src/config/nx-json');
|
|
40
41
|
var tree = require('nx/src/generators/tree');
|
|
42
|
+
var fileMapUtils = require('nx/src/project-graph/file-map-utils');
|
|
41
43
|
var execCommand_js = require('nx/src/command-line/release/utils/exec-command.js');
|
|
42
|
-
var
|
|
44
|
+
var semver = require('semver');
|
|
43
45
|
var DefaultChangelogRenderer = require('nx/release/changelog-renderer');
|
|
44
46
|
var conventionalCommits = require('nx/src/command-line/release/config/conventional-commits');
|
|
45
|
-
var semver = require('semver');
|
|
46
47
|
|
|
47
48
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
48
49
|
|
|
@@ -60,6 +61,7 @@ var anchor__default = /*#__PURE__*/_interopDefault(anchor);
|
|
|
60
61
|
var ___default = /*#__PURE__*/_interopDefault(_);
|
|
61
62
|
var updateSection__default = /*#__PURE__*/_interopDefault(updateSection);
|
|
62
63
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
64
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
63
65
|
var DefaultChangelogRenderer__default = /*#__PURE__*/_interopDefault(DefaultChangelogRenderer);
|
|
64
66
|
|
|
65
67
|
function parseCargoToml(cargoString) {
|
|
@@ -1391,6 +1393,15 @@ function findFileName(filePath) {
|
|
|
1391
1393
|
function findFilePath(filePath) {
|
|
1392
1394
|
return filePath.replace(findFileName(filePath), "");
|
|
1393
1395
|
}
|
|
1396
|
+
function createFileToProjectMap(projectFileMap) {
|
|
1397
|
+
const fileToProjectMap = {};
|
|
1398
|
+
for (const [projectName, projectFiles] of Object.entries(projectFileMap)) {
|
|
1399
|
+
for (const file of projectFiles) {
|
|
1400
|
+
fileToProjectMap[file.file] = projectName;
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
return fileToProjectMap;
|
|
1404
|
+
}
|
|
1394
1405
|
var start = "<!-- START doctoc -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->";
|
|
1395
1406
|
var end = "<!-- END doctoc -->";
|
|
1396
1407
|
var skipTag = "<!-- DOCTOC SKIP -->";
|
|
@@ -1955,7 +1966,7 @@ var createRegExp = (sectionName) => {
|
|
|
1955
1966
|
var runReadme = async ({
|
|
1956
1967
|
templates = "./tools/readme-templates",
|
|
1957
1968
|
project,
|
|
1958
|
-
output:
|
|
1969
|
+
output: output4,
|
|
1959
1970
|
clean = true,
|
|
1960
1971
|
prettier = true
|
|
1961
1972
|
}) => {
|
|
@@ -1966,7 +1977,7 @@ var runReadme = async ({
|
|
|
1966
1977
|
if (project) {
|
|
1967
1978
|
await runProjectReadme(project, {
|
|
1968
1979
|
templates,
|
|
1969
|
-
output:
|
|
1980
|
+
output: output4,
|
|
1970
1981
|
clean,
|
|
1971
1982
|
prettier
|
|
1972
1983
|
});
|
|
@@ -1974,14 +1985,14 @@ var runReadme = async ({
|
|
|
1974
1985
|
for (const projectName of Object.keys(projectConfigs.projects)) {
|
|
1975
1986
|
await runProjectReadme(projectName, {
|
|
1976
1987
|
templates,
|
|
1977
|
-
output:
|
|
1988
|
+
output: output4,
|
|
1978
1989
|
clean,
|
|
1979
1990
|
prettier
|
|
1980
1991
|
});
|
|
1981
1992
|
}
|
|
1982
1993
|
}
|
|
1983
1994
|
};
|
|
1984
|
-
var runProjectReadme = async (projectName, { templates, output:
|
|
1995
|
+
var runProjectReadme = async (projectName, { templates, output: output4, clean = true, prettier = true }) => {
|
|
1985
1996
|
const projectGraph = await projectGraph_js.createProjectGraphAsync({
|
|
1986
1997
|
exitOnError: true
|
|
1987
1998
|
});
|
|
@@ -1990,7 +2001,7 @@ var runProjectReadme = async (projectName, { templates, output: output3, clean =
|
|
|
1990
2001
|
const inputFile = Path.join(project?.root ?? "./", "README.md");
|
|
1991
2002
|
if (fs$1.existsSync(inputFile)) {
|
|
1992
2003
|
console.info(`Formatting ${projectName}'s README file at "${inputFile}"`);
|
|
1993
|
-
const outputFilePath =
|
|
2004
|
+
const outputFilePath = output4 ? output4.includes("README.md") ? output4 : Path.join(findFilePath(output4), "README.md") : inputFile;
|
|
1994
2005
|
if (clean && fs$1.existsSync(outputFilePath)) {
|
|
1995
2006
|
if (outputFilePath === inputFile) {
|
|
1996
2007
|
console.warn(
|
|
@@ -2428,6 +2439,95 @@ function parseChangelogMarkdown(contents) {
|
|
|
2428
2439
|
releases
|
|
2429
2440
|
};
|
|
2430
2441
|
}
|
|
2442
|
+
function filterHiddenChanges(changes, conventionalCommitsConfig) {
|
|
2443
|
+
return changes.filter((change) => {
|
|
2444
|
+
const type = change.type;
|
|
2445
|
+
const typeConfig = conventionalCommitsConfig.types[type];
|
|
2446
|
+
if (!typeConfig) {
|
|
2447
|
+
return false;
|
|
2448
|
+
}
|
|
2449
|
+
return !typeConfig.changelog.hidden;
|
|
2450
|
+
});
|
|
2451
|
+
}
|
|
2452
|
+
async function generateChangelogForProjects({
|
|
2453
|
+
args,
|
|
2454
|
+
changes,
|
|
2455
|
+
projectsVersionData,
|
|
2456
|
+
releaseGroup,
|
|
2457
|
+
projects,
|
|
2458
|
+
releaseConfig,
|
|
2459
|
+
projectToAdditionalDependencyBumps,
|
|
2460
|
+
workspaceConfig,
|
|
2461
|
+
ChangelogRendererClass
|
|
2462
|
+
}) {
|
|
2463
|
+
const config5 = releaseGroup.changelog;
|
|
2464
|
+
if (config5 === false) {
|
|
2465
|
+
return;
|
|
2466
|
+
}
|
|
2467
|
+
const dryRun = !!args.dryRun;
|
|
2468
|
+
const remoteReleaseClient = await createGithubRemoteReleaseClient(
|
|
2469
|
+
workspaceConfig,
|
|
2470
|
+
args.gitRemote
|
|
2471
|
+
);
|
|
2472
|
+
const projectChangelogs = {};
|
|
2473
|
+
for (const project of projects) {
|
|
2474
|
+
let interpolatedTreePath = config5.file || "";
|
|
2475
|
+
if (interpolatedTreePath) {
|
|
2476
|
+
interpolatedTreePath = utils.interpolate(interpolatedTreePath, {
|
|
2477
|
+
projectName: project.name,
|
|
2478
|
+
projectRoot: project.data.root,
|
|
2479
|
+
workspaceRoot: ""
|
|
2480
|
+
// within the tree, workspaceRoot is the root
|
|
2481
|
+
});
|
|
2482
|
+
}
|
|
2483
|
+
if (!projectsVersionData[project.name] || projectsVersionData[project.name]?.newVersion === null && !projectsVersionData[project.name]?.dockerVersion) {
|
|
2484
|
+
continue;
|
|
2485
|
+
}
|
|
2486
|
+
const preferDockerVersion = shared.shouldPreferDockerVersionForReleaseGroup(releaseGroup);
|
|
2487
|
+
const releaseVersion = new shared.ReleaseVersion({
|
|
2488
|
+
version: (preferDockerVersion === true || preferDockerVersion === "both") && projectsVersionData[project.name]?.dockerVersion ? projectsVersionData[project.name]?.dockerVersion : projectsVersionData[project.name]?.newVersion,
|
|
2489
|
+
releaseTagPattern: releaseGroup.releaseTag.pattern,
|
|
2490
|
+
projectName: project.name
|
|
2491
|
+
});
|
|
2492
|
+
if (interpolatedTreePath) {
|
|
2493
|
+
const prefix = dryRun ? "Previewing" : "Generating";
|
|
2494
|
+
devkit.output.log({
|
|
2495
|
+
title: `${prefix} an entry in ${interpolatedTreePath} for ${chalk__default.default.white(
|
|
2496
|
+
releaseVersion.gitTag
|
|
2497
|
+
)}`
|
|
2498
|
+
});
|
|
2499
|
+
}
|
|
2500
|
+
const changelogRenderer = new ChangelogRendererClass({
|
|
2501
|
+
changes,
|
|
2502
|
+
changelogEntryVersion: releaseVersion.rawVersion,
|
|
2503
|
+
project: project.name,
|
|
2504
|
+
entryWhenNoChanges: typeof config5.entryWhenNoChanges === "string" ? utils.interpolate(config5.entryWhenNoChanges, {
|
|
2505
|
+
projectName: project.name,
|
|
2506
|
+
projectRoot: project.data.root,
|
|
2507
|
+
workspaceRoot: ""
|
|
2508
|
+
// within the tree, workspaceRoot is the root
|
|
2509
|
+
}) : false,
|
|
2510
|
+
changelogRenderOptions: config5.renderOptions,
|
|
2511
|
+
isVersionPlans: !!releaseGroup.versionPlans,
|
|
2512
|
+
conventionalCommitsConfig: releaseConfig.conventionalCommits,
|
|
2513
|
+
dependencyBumps: projectToAdditionalDependencyBumps.get(project.name),
|
|
2514
|
+
remoteReleaseClient,
|
|
2515
|
+
workspaceConfig
|
|
2516
|
+
});
|
|
2517
|
+
const contents = await changelogRenderer.render();
|
|
2518
|
+
const postGitTask = args.createRelease !== false && config5.createRelease ? remoteReleaseClient.createPostGitTask(
|
|
2519
|
+
releaseVersion,
|
|
2520
|
+
contents,
|
|
2521
|
+
dryRun
|
|
2522
|
+
) : null;
|
|
2523
|
+
projectChangelogs[project.name] = {
|
|
2524
|
+
releaseVersion,
|
|
2525
|
+
contents,
|
|
2526
|
+
postGitTask
|
|
2527
|
+
};
|
|
2528
|
+
}
|
|
2529
|
+
return projectChangelogs;
|
|
2530
|
+
}
|
|
2431
2531
|
|
|
2432
2532
|
// src/release/github.ts
|
|
2433
2533
|
var StormGithubRemoteReleaseClient = class extends github.GithubRemoteReleaseClient {
|
|
@@ -2648,6 +2748,48 @@ async function isUserAnOrganizationMember(userId, config5, remoteName = "origin"
|
|
|
2648
2748
|
return false;
|
|
2649
2749
|
}
|
|
2650
2750
|
}
|
|
2751
|
+
async function getCommits(fromSHA, toSHA) {
|
|
2752
|
+
const rawCommits = await git.getGitDiff(fromSHA, toSHA);
|
|
2753
|
+
return git.parseCommits(rawCommits);
|
|
2754
|
+
}
|
|
2755
|
+
async function filterProjectCommits({
|
|
2756
|
+
fromSHA,
|
|
2757
|
+
toSHA,
|
|
2758
|
+
projectPath
|
|
2759
|
+
}) {
|
|
2760
|
+
const allCommits = await getCommits(fromSHA, toSHA);
|
|
2761
|
+
return allCommits.filter(
|
|
2762
|
+
(c) => c.affectedFiles.find((f) => f.startsWith(projectPath))
|
|
2763
|
+
);
|
|
2764
|
+
}
|
|
2765
|
+
function commitChangesNonProjectFiles(commit, nonProjectFiles) {
|
|
2766
|
+
return nonProjectFiles.some(
|
|
2767
|
+
(fileData) => commit.affectedFiles.includes(fileData.file)
|
|
2768
|
+
);
|
|
2769
|
+
}
|
|
2770
|
+
function getProjectsAffectedByCommit(commit, fileToProjectMap) {
|
|
2771
|
+
const affectedProjects = /* @__PURE__ */ new Set();
|
|
2772
|
+
for (const file of commit.affectedFiles) {
|
|
2773
|
+
affectedProjects.add(fileToProjectMap[file]);
|
|
2774
|
+
}
|
|
2775
|
+
return Array.from(affectedProjects);
|
|
2776
|
+
}
|
|
2777
|
+
function extractPreid(version) {
|
|
2778
|
+
if (!shared.isPrerelease(version)) {
|
|
2779
|
+
return void 0;
|
|
2780
|
+
}
|
|
2781
|
+
const preid = semver.prerelease(version)?.[0];
|
|
2782
|
+
if (typeof preid === "string") {
|
|
2783
|
+
if (preid.trim() === "") {
|
|
2784
|
+
return void 0;
|
|
2785
|
+
}
|
|
2786
|
+
return preid;
|
|
2787
|
+
}
|
|
2788
|
+
if (typeof preid === "number") {
|
|
2789
|
+
return preid.toString();
|
|
2790
|
+
}
|
|
2791
|
+
return void 0;
|
|
2792
|
+
}
|
|
2651
2793
|
function createGitTagValues(releaseGroups, releaseGroupToFilteredProjects, versionData) {
|
|
2652
2794
|
const tags = [];
|
|
2653
2795
|
for (const releaseGroup of releaseGroups) {
|
|
@@ -2823,15 +2965,13 @@ var StormChangelogRenderer = class extends DefaultChangelogRenderer__default.def
|
|
|
2823
2965
|
...config5
|
|
2824
2966
|
};
|
|
2825
2967
|
super(resolvedConfig);
|
|
2826
|
-
this.workspaceConfig = config5.
|
|
2968
|
+
this.workspaceConfig = config5.workspaceConfig;
|
|
2969
|
+
this.remoteReleaseClient = resolvedConfig.remoteReleaseClient;
|
|
2827
2970
|
}
|
|
2828
2971
|
async render() {
|
|
2829
2972
|
if (!this.workspaceConfig) {
|
|
2830
2973
|
this.workspaceConfig = await chunkEHPPIARR_cjs.getWorkspaceConfig();
|
|
2831
2974
|
}
|
|
2832
|
-
this.remoteReleaseClient = await createGithubRemoteReleaseClient(
|
|
2833
|
-
this.workspaceConfig
|
|
2834
|
-
);
|
|
2835
2975
|
return super.render();
|
|
2836
2976
|
}
|
|
2837
2977
|
preprocessChanges() {
|
|
@@ -3080,8 +3220,6 @@ var DEFAULT_RELEASE_CONFIG = {
|
|
|
3080
3220
|
},
|
|
3081
3221
|
releaseTag: { pattern: DEFAULT_RELEASE_TAG_PATTERN }
|
|
3082
3222
|
};
|
|
3083
|
-
|
|
3084
|
-
// src/release/release-client.ts
|
|
3085
3223
|
function getReleaseGroupConfig(releaseConfig, workspaceConfig) {
|
|
3086
3224
|
return !releaseConfig?.groups || Object.keys(releaseConfig.groups).length === 0 ? {} : Object.fromEntries(
|
|
3087
3225
|
Object.entries(releaseConfig.groups).map(([name, group]) => {
|
|
@@ -3119,6 +3257,8 @@ function getReleaseGroupConfig(releaseConfig, workspaceConfig) {
|
|
|
3119
3257
|
})
|
|
3120
3258
|
);
|
|
3121
3259
|
}
|
|
3260
|
+
|
|
3261
|
+
// src/release/release-client.ts
|
|
3122
3262
|
var StormReleaseClient = class _StormReleaseClient extends release.ReleaseClient {
|
|
3123
3263
|
static async create(releaseConfig = {}, ignoreNxJsonConfig = false, workspaceConfig) {
|
|
3124
3264
|
if (!workspaceConfig) {
|
|
@@ -3145,7 +3285,6 @@ var StormReleaseClient = class _StormReleaseClient extends release.ReleaseClient
|
|
|
3145
3285
|
workspaceConfig
|
|
3146
3286
|
);
|
|
3147
3287
|
}
|
|
3148
|
-
#releaseChangelog;
|
|
3149
3288
|
/**
|
|
3150
3289
|
* The release configuration used by this release client.
|
|
3151
3290
|
*/
|
|
@@ -3191,7 +3330,10 @@ var StormReleaseClient = class _StormReleaseClient extends release.ReleaseClient
|
|
|
3191
3330
|
groups: getReleaseGroupConfig(releaseConfig, workspaceConfig)
|
|
3192
3331
|
},
|
|
3193
3332
|
{
|
|
3194
|
-
groups: getReleaseGroupConfig(
|
|
3333
|
+
groups: getReleaseGroupConfig(
|
|
3334
|
+
nxJson$1.release ?? {},
|
|
3335
|
+
workspaceConfig
|
|
3336
|
+
)
|
|
3195
3337
|
},
|
|
3196
3338
|
omit(releaseConfig, ["groups"]),
|
|
3197
3339
|
nxJson$1.release ? omit(nxJson$1.release, ["groups"]) : {},
|
|
@@ -3207,62 +3349,283 @@ var StormReleaseClient = class _StormReleaseClient extends release.ReleaseClient
|
|
|
3207
3349
|
this.config = config5;
|
|
3208
3350
|
this.workspaceConfig = workspaceConfig;
|
|
3209
3351
|
this.tree = new tree.FsTree(workspaceConfig.workspaceRoot, false);
|
|
3210
|
-
this.#releaseChangelog = changelog.createAPI(config5, true);
|
|
3211
3352
|
this.projectConfigurations = devkit.readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
3212
3353
|
}
|
|
3213
3354
|
releaseChangelog = async (options) => {
|
|
3214
|
-
const
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3355
|
+
const to = options.to || "HEAD";
|
|
3356
|
+
const toSHA = await git.getCommitHash(to);
|
|
3357
|
+
const postGitTasks = [];
|
|
3358
|
+
let projectChangelogs = {};
|
|
3359
|
+
const projectsPreid = Object.fromEntries(
|
|
3360
|
+
Object.entries(options.versionData).map(([projectName, v]) => [
|
|
3361
|
+
projectName,
|
|
3362
|
+
v.newVersion ? extractPreid(v.newVersion) : void 0
|
|
3363
|
+
])
|
|
3364
|
+
);
|
|
3365
|
+
const projectToAdditionalDependencyBumps = /* @__PURE__ */ new Map();
|
|
3366
|
+
for (const releaseGroup of options.releaseGraph.releaseGroups) {
|
|
3367
|
+
if (releaseGroup.projectsRelationship !== "independent") {
|
|
3368
|
+
continue;
|
|
3369
|
+
}
|
|
3370
|
+
for (const project of releaseGroup.projects) {
|
|
3371
|
+
if (!options.versionData[project] || options.versionData[project].newVersion === null) {
|
|
3372
|
+
continue;
|
|
3373
|
+
}
|
|
3374
|
+
const dependentProjects = (options.versionData[project].dependentProjects || []).map((dep) => {
|
|
3375
|
+
return {
|
|
3376
|
+
dependencyName: dep.source,
|
|
3377
|
+
newVersion: options.versionData[dep.source]?.newVersion ?? null
|
|
3378
|
+
};
|
|
3379
|
+
}).filter((b) => b.newVersion !== null);
|
|
3380
|
+
for (const dependent of dependentProjects) {
|
|
3381
|
+
const additionalDependencyBumpsForProject = projectToAdditionalDependencyBumps.has(dependent.dependencyName) ? projectToAdditionalDependencyBumps.get(dependent.dependencyName) : [];
|
|
3382
|
+
additionalDependencyBumpsForProject.push({
|
|
3383
|
+
dependencyName: project,
|
|
3384
|
+
newVersion: options.versionData[project].newVersion
|
|
3385
|
+
});
|
|
3386
|
+
projectToAdditionalDependencyBumps.set(
|
|
3387
|
+
dependent.dependencyName,
|
|
3388
|
+
additionalDependencyBumpsForProject
|
|
3389
|
+
);
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
const allProjectChangelogs = {};
|
|
3394
|
+
for (const releaseGroup of options.releaseGraph.releaseGroups) {
|
|
3395
|
+
const config5 = releaseGroup.changelog;
|
|
3396
|
+
if (config5 === false) {
|
|
3397
|
+
continue;
|
|
3398
|
+
}
|
|
3399
|
+
if (!options.releaseGraph.releaseGroupToFilteredProjects.has(releaseGroup)) {
|
|
3400
|
+
throw new Error(
|
|
3401
|
+
`No filtered projects found for release group ${releaseGroup.name}`
|
|
3402
|
+
);
|
|
3403
|
+
}
|
|
3404
|
+
const projects = options.projects?.length ? (
|
|
3405
|
+
// If the user has passed a list of projects, we need to use the filtered list of projects within the release group, plus any dependents
|
|
3406
|
+
Array.from(
|
|
3407
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
3408
|
+
options.releaseGraph.releaseGroupToFilteredProjects.get(
|
|
3409
|
+
releaseGroup
|
|
3410
|
+
)
|
|
3411
|
+
).flatMap((project) => {
|
|
3412
|
+
return [
|
|
3413
|
+
project,
|
|
3414
|
+
...options.versionData[project]?.dependentProjects.map(
|
|
3415
|
+
(dep) => dep.source
|
|
3416
|
+
) || []
|
|
3417
|
+
];
|
|
3418
|
+
})
|
|
3419
|
+
) : (
|
|
3420
|
+
// Otherwise, we use the full list of projects within the release group
|
|
3421
|
+
releaseGroup.projects
|
|
3422
|
+
);
|
|
3423
|
+
const projectNodes = projects.map((name) => this.projectGraph.nodes[name]);
|
|
3424
|
+
if (releaseGroup.projectsRelationship === "independent") {
|
|
3425
|
+
for (const project of projectNodes) {
|
|
3426
|
+
let changes = null;
|
|
3427
|
+
let fromRef = options.from || (await git.getLatestGitTagForPattern(
|
|
3428
|
+
releaseGroup.releaseTag.pattern,
|
|
3429
|
+
{
|
|
3430
|
+
projectName: project.name,
|
|
3431
|
+
releaseGroupName: releaseGroup.name
|
|
3432
|
+
},
|
|
3433
|
+
{
|
|
3434
|
+
checkAllBranchesWhen: releaseGroup.releaseTag.checkAllBranchesWhen,
|
|
3435
|
+
preid: projectsPreid[project.name],
|
|
3436
|
+
requireSemver: releaseGroup.releaseTag.requireSemver,
|
|
3437
|
+
strictPreid: releaseGroup.releaseTag.strictPreid
|
|
3438
|
+
}
|
|
3439
|
+
))?.tag;
|
|
3440
|
+
let commits = void 0;
|
|
3441
|
+
if (!fromRef) {
|
|
3442
|
+
const firstCommit = await git.getFirstGitCommit();
|
|
3443
|
+
commits = await filterProjectCommits({
|
|
3444
|
+
fromSHA: firstCommit,
|
|
3445
|
+
toSHA,
|
|
3446
|
+
projectPath: project.data.root
|
|
3447
|
+
});
|
|
3448
|
+
fromRef = commits[0]?.shortHash;
|
|
3449
|
+
if (options.verbose) {
|
|
3450
|
+
console.log(
|
|
3451
|
+
`Determined --from ref for ${project.name} from the first commit in which it exists: ${fromRef}`
|
|
3232
3452
|
);
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3453
|
+
}
|
|
3454
|
+
}
|
|
3455
|
+
if (!fromRef && !commits) {
|
|
3456
|
+
throw new Error(
|
|
3457
|
+
`Unable to determine the previous git tag. If this is the first release of your workspace, use the --first-release option or set the "release.changelog.automaticFromRef" config property in nx.json to generate a changelog from the first commit. Otherwise, be sure to configure the "release.releaseTag.pattern" property in nx.json to match the structure of your repository's git tags.`
|
|
3458
|
+
);
|
|
3459
|
+
}
|
|
3460
|
+
if (!commits) {
|
|
3461
|
+
commits = await filterProjectCommits({
|
|
3462
|
+
fromSHA: fromRef,
|
|
3463
|
+
toSHA,
|
|
3464
|
+
projectPath: project.data.root
|
|
3465
|
+
});
|
|
3466
|
+
}
|
|
3467
|
+
const { fileMap } = await fileMapUtils.createFileMapUsingProjectGraph(
|
|
3468
|
+
this.projectGraph
|
|
3469
|
+
);
|
|
3470
|
+
const fileToProjectMap = createFileToProjectMap(
|
|
3471
|
+
fileMap.projectFileMap
|
|
3472
|
+
);
|
|
3473
|
+
changes = filterHiddenChanges(
|
|
3474
|
+
commits.map((c) => ({
|
|
3475
|
+
type: c.type,
|
|
3476
|
+
scope: c.scope,
|
|
3477
|
+
description: c.description,
|
|
3478
|
+
body: c.body,
|
|
3479
|
+
isBreaking: c.isBreaking,
|
|
3480
|
+
githubReferences: c.references,
|
|
3481
|
+
authors: c.authors,
|
|
3482
|
+
shortHash: c.shortHash,
|
|
3483
|
+
revertedHashes: c.revertedHashes,
|
|
3484
|
+
affectedProjects: commitChangesNonProjectFiles(
|
|
3485
|
+
c,
|
|
3486
|
+
fileMap.nonProjectFiles
|
|
3487
|
+
) ? "*" : getProjectsAffectedByCommit(c, fileToProjectMap)
|
|
3488
|
+
})),
|
|
3489
|
+
this.config.conventionalCommits
|
|
3490
|
+
);
|
|
3491
|
+
projectChangelogs = await generateChangelogForProjects({
|
|
3492
|
+
tree: this.tree,
|
|
3493
|
+
args: options,
|
|
3494
|
+
changes,
|
|
3495
|
+
projectsVersionData: options.versionData,
|
|
3496
|
+
releaseGroup,
|
|
3497
|
+
projects: [project],
|
|
3498
|
+
releaseConfig: this.config,
|
|
3499
|
+
projectToAdditionalDependencyBumps,
|
|
3500
|
+
workspaceConfig: this.workspaceConfig,
|
|
3501
|
+
ChangelogRendererClass: StormChangelogRenderer
|
|
3502
|
+
});
|
|
3503
|
+
if (projectChangelogs) {
|
|
3504
|
+
for (const [projectName, projectChangelog] of Object.entries(
|
|
3505
|
+
projectChangelogs
|
|
3506
|
+
)) {
|
|
3507
|
+
if (projectChangelog.postGitTask) {
|
|
3508
|
+
postGitTasks.push(projectChangelog.postGitTask);
|
|
3236
3509
|
}
|
|
3237
|
-
|
|
3238
|
-
`\u270D\uFE0F Writing changelog for project ${project} to ${filePath}`,
|
|
3239
|
-
this.workspaceConfig
|
|
3240
|
-
);
|
|
3241
|
-
const content = await generateChangelogContent(
|
|
3242
|
-
changelog.releaseVersion,
|
|
3243
|
-
filePath,
|
|
3244
|
-
changelog.contents,
|
|
3245
|
-
currentContent,
|
|
3246
|
-
project,
|
|
3247
|
-
this.workspaceConfig
|
|
3248
|
-
);
|
|
3249
|
-
this.tree.write(filePath, content);
|
|
3250
|
-
printChanges.printAndFlushChanges(
|
|
3251
|
-
this.tree,
|
|
3252
|
-
!!options.dryRun,
|
|
3253
|
-
3,
|
|
3254
|
-
false,
|
|
3255
|
-
shared.noDiffInChangelogMessage,
|
|
3256
|
-
// Only print the change for the current changelog file at this point
|
|
3257
|
-
(f) => f.path === filePath
|
|
3258
|
-
);
|
|
3510
|
+
allProjectChangelogs[projectName] = projectChangelog;
|
|
3259
3511
|
}
|
|
3260
3512
|
}
|
|
3261
|
-
|
|
3513
|
+
}
|
|
3514
|
+
} else {
|
|
3515
|
+
let changes = [];
|
|
3516
|
+
let fromRef = options.from || (await git.getLatestGitTagForPattern(
|
|
3517
|
+
releaseGroup.releaseTag.pattern,
|
|
3518
|
+
{},
|
|
3519
|
+
{
|
|
3520
|
+
checkAllBranchesWhen: releaseGroup.releaseTag.checkAllBranchesWhen,
|
|
3521
|
+
preid: Object.keys(projectsPreid)[0] ? projectsPreid?.[Object.keys(projectsPreid)[0]] : void 0,
|
|
3522
|
+
requireSemver: releaseGroup.releaseTag.requireSemver,
|
|
3523
|
+
strictPreid: releaseGroup.releaseTag.strictPreid
|
|
3524
|
+
}
|
|
3525
|
+
))?.tag;
|
|
3526
|
+
if (!fromRef) {
|
|
3527
|
+
fromRef = await git.getFirstGitCommit();
|
|
3528
|
+
if (options.verbose) {
|
|
3529
|
+
console.log(
|
|
3530
|
+
`Determined release group --from ref from the first commit in the workspace: ${fromRef}`
|
|
3531
|
+
);
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
const fromSHA = await git.getCommitHash(fromRef);
|
|
3535
|
+
const { fileMap } = await fileMapUtils.createFileMapUsingProjectGraph(
|
|
3536
|
+
this.projectGraph
|
|
3537
|
+
);
|
|
3538
|
+
const fileToProjectMap = createFileToProjectMap(fileMap.projectFileMap);
|
|
3539
|
+
changes = filterHiddenChanges(
|
|
3540
|
+
(await getCommits(fromSHA, toSHA)).map((c) => ({
|
|
3541
|
+
type: c.type,
|
|
3542
|
+
scope: c.scope,
|
|
3543
|
+
description: c.description,
|
|
3544
|
+
body: c.body,
|
|
3545
|
+
isBreaking: c.isBreaking,
|
|
3546
|
+
githubReferences: c.references,
|
|
3547
|
+
authors: c.authors,
|
|
3548
|
+
shortHash: c.shortHash,
|
|
3549
|
+
revertedHashes: c.revertedHashes,
|
|
3550
|
+
affectedProjects: commitChangesNonProjectFiles(
|
|
3551
|
+
c,
|
|
3552
|
+
fileMap.nonProjectFiles
|
|
3553
|
+
) ? "*" : getProjectsAffectedByCommit(c, fileToProjectMap)
|
|
3554
|
+
})),
|
|
3555
|
+
this.config.conventionalCommits
|
|
3556
|
+
);
|
|
3557
|
+
projectChangelogs = await generateChangelogForProjects({
|
|
3558
|
+
tree: this.tree,
|
|
3559
|
+
args: options,
|
|
3560
|
+
changes,
|
|
3561
|
+
projectsVersionData: options.versionData,
|
|
3562
|
+
releaseGroup,
|
|
3563
|
+
projects: projectNodes,
|
|
3564
|
+
releaseConfig: this.config,
|
|
3565
|
+
projectToAdditionalDependencyBumps,
|
|
3566
|
+
workspaceConfig: this.workspaceConfig,
|
|
3567
|
+
ChangelogRendererClass: StormChangelogRenderer
|
|
3568
|
+
});
|
|
3569
|
+
if (projectChangelogs) {
|
|
3570
|
+
for (const [projectName, projectChangelog] of Object.entries(
|
|
3571
|
+
projectChangelogs
|
|
3572
|
+
)) {
|
|
3573
|
+
if (projectChangelog.postGitTask) {
|
|
3574
|
+
postGitTasks.push(projectChangelog.postGitTask);
|
|
3575
|
+
}
|
|
3576
|
+
allProjectChangelogs[projectName] = projectChangelog;
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
}
|
|
3580
|
+
}
|
|
3581
|
+
if (projectChangelogs) {
|
|
3582
|
+
await Promise.all(
|
|
3583
|
+
Object.entries(projectChangelogs).map(async ([project, changelog]) => {
|
|
3584
|
+
if (!this.projectGraph.nodes[project]?.data.root) {
|
|
3585
|
+
chunkEHPPIARR_cjs.writeWarning(
|
|
3586
|
+
`A changelog was generated for ${project}, but it could not be found in the project graph. Skipping writing changelog file.`,
|
|
3587
|
+
this.workspaceConfig
|
|
3588
|
+
);
|
|
3589
|
+
} else if (changelog.contents) {
|
|
3590
|
+
const filePath = chunkEHPPIARR_cjs.joinPaths(
|
|
3591
|
+
this.projectGraph.nodes[project].data.root,
|
|
3592
|
+
"CHANGELOG.md"
|
|
3593
|
+
);
|
|
3594
|
+
let currentContent;
|
|
3595
|
+
if (fs$1.existsSync(filePath)) {
|
|
3596
|
+
currentContent = await fs.readFile(filePath, "utf8");
|
|
3597
|
+
}
|
|
3598
|
+
chunkEHPPIARR_cjs.writeDebug(
|
|
3599
|
+
`\u270D\uFE0F Writing changelog for project ${project} to ${filePath}`,
|
|
3600
|
+
this.workspaceConfig
|
|
3601
|
+
);
|
|
3602
|
+
const content = await generateChangelogContent(
|
|
3603
|
+
changelog.releaseVersion,
|
|
3604
|
+
filePath,
|
|
3605
|
+
changelog.contents,
|
|
3606
|
+
currentContent,
|
|
3607
|
+
project,
|
|
3608
|
+
this.workspaceConfig
|
|
3609
|
+
);
|
|
3610
|
+
this.tree.write(filePath, content);
|
|
3611
|
+
printChanges.printAndFlushChanges(
|
|
3612
|
+
this.tree,
|
|
3613
|
+
!!options.dryRun,
|
|
3614
|
+
3,
|
|
3615
|
+
false,
|
|
3616
|
+
shared.noDiffInChangelogMessage,
|
|
3617
|
+
// Only print the change for the current changelog file at this point
|
|
3618
|
+
(f) => f.path === filePath
|
|
3619
|
+
);
|
|
3620
|
+
}
|
|
3621
|
+
})
|
|
3262
3622
|
);
|
|
3263
|
-
this.applyChangesAndExit(options,
|
|
3623
|
+
this.applyChangesAndExit(options, postGitTasks);
|
|
3264
3624
|
}
|
|
3265
|
-
return
|
|
3625
|
+
return {
|
|
3626
|
+
workspaceChangelog: void 0,
|
|
3627
|
+
projectChangelogs: allProjectChangelogs
|
|
3628
|
+
};
|
|
3266
3629
|
};
|
|
3267
3630
|
checkChangelogFilesEnabled() {
|
|
3268
3631
|
if (this.config.changelog?.workspaceChangelog && (this.config.changelog?.workspaceChangelog === true || this.config.changelog?.workspaceChangelog.file)) {
|
|
@@ -3281,8 +3644,7 @@ var StormReleaseClient = class _StormReleaseClient extends release.ReleaseClient
|
|
|
3281
3644
|
}
|
|
3282
3645
|
return process.env.CI || process.env.TF_BUILD === "true" || process.env.GITHUB_ACTIONS === "true" || process.env.BUILDKITE === "true" || process.env.CIRCLECI === "true" || process.env.CIRRUS_CI === "true" || process.env.TRAVIS === "true" || !!process.env["bamboo.buildKey"] || !!process.env["bamboo_buildKey"] || !!process.env.CODEBUILD_BUILD_ID || !!process.env.GITLAB_CI || !!process.env.HEROKU_TEST_RUN_ID || !!process.env.BUILD_ID || !!process.env.BUILD_NUMBER || !!process.env.BUILD_BUILDID || !!process.env.TEAMCITY_VERSION || !!process.env.JENKINS_URL || !!process.env.HUDSON_URL;
|
|
3283
3646
|
};
|
|
3284
|
-
applyChangesAndExit = async (options,
|
|
3285
|
-
const postGitTasks = Object.values(result.projectChangelogs || {}).map((project) => project.postGitTask).filter(Boolean);
|
|
3647
|
+
applyChangesAndExit = async (options, postGitTasks) => {
|
|
3286
3648
|
const to = options.to || "HEAD";
|
|
3287
3649
|
let latestCommit = await git.getCommitHash(to);
|
|
3288
3650
|
const gitTagValues = options.gitTag ?? this.config.changelog?.git?.tag ? createGitTagValues(
|