@storm-software/git-tools 2.123.18 → 2.124.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/git.cjs +646 -317
- package/bin/git.cjs.map +1 -1
- package/bin/git.js +645 -317
- package/bin/git.js.map +1 -1
- package/dist/chunk-HGBVETOW.js +2421 -0
- package/dist/chunk-UIYXCHBI.cjs +2455 -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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
require('./chunk-AU5PZKTN.cjs');
|
|
4
5
|
var chunkFH5OSXAJ_cjs = require('./chunk-FH5OSXAJ.cjs');
|
|
5
6
|
var chunkEHPPIARR_cjs = require('./chunk-EHPPIARR.cjs');
|
|
6
7
|
var TOML = require('@ltd/j-toml');
|
|
@@ -26,23 +27,23 @@ var _ = require('underscore');
|
|
|
26
27
|
var updateSection = require('update-section');
|
|
27
28
|
var devkit = require('@nx/devkit');
|
|
28
29
|
var axios = require('axios');
|
|
29
|
-
require('enquirer');
|
|
30
30
|
var os = require('os');
|
|
31
|
-
var printChanges = require('nx/src/command-line/release/utils/print-changes');
|
|
32
31
|
var github = require('nx/src/command-line/release/utils/remote-release-clients/github');
|
|
33
|
-
var shared = require('nx/src/command-line/release/utils/shared');
|
|
34
32
|
var yaml = require('yaml');
|
|
33
|
+
var chalk = require('chalk');
|
|
34
|
+
var printChanges = require('nx/src/command-line/release/utils/print-changes');
|
|
35
|
+
var shared = require('nx/src/command-line/release/utils/shared');
|
|
36
|
+
var utils = require('nx/src/tasks-runner/utils');
|
|
35
37
|
var prettier = require('prettier');
|
|
36
|
-
var
|
|
37
|
-
var changelog = require('nx/src/command-line/release/changelog');
|
|
38
|
+
var execCommand_js = require('nx/src/command-line/release/utils/exec-command.js');
|
|
38
39
|
var git = require('nx/src/command-line/release/utils/git');
|
|
40
|
+
var semver = require('semver');
|
|
41
|
+
var release = require('nx/release');
|
|
39
42
|
var nxJson = require('nx/src/config/nx-json');
|
|
40
43
|
var tree = require('nx/src/generators/tree');
|
|
41
|
-
var
|
|
42
|
-
var utils = require('nx/src/tasks-runner/utils');
|
|
44
|
+
var fileMapUtils = require('nx/src/project-graph/file-map-utils');
|
|
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 -->";
|
|
@@ -2399,7 +2410,7 @@ function generateChangelogTitle(version, project, workspaceConfig) {
|
|
|
2399
2410
|
if (!workspaceConfig?.name || !project) {
|
|
2400
2411
|
return version;
|
|
2401
2412
|
}
|
|
2402
|
-
return `[${version}](https://github.com/${typeof workspaceConfig.organization === "string" ? workspaceConfig.organization : workspaceConfig.organization?.name}/${workspaceConfig.name}/releases/tag/${project}%40${version}) (${(/* @__PURE__ */ new Date()).getMonth() + 1}/${(/* @__PURE__ */ new Date()).getDate()}/${(/* @__PURE__ */ new Date()).getFullYear()})`;
|
|
2413
|
+
return `[${version}](https://github.com/${typeof workspaceConfig.organization === "string" ? workspaceConfig.organization : workspaceConfig.organization?.name}/${workspaceConfig.name}/releases/tag/${project}%40${version}) (${(/* @__PURE__ */ new Date()).getMonth() + 1 < 10 ? `0${(/* @__PURE__ */ new Date()).getMonth() + 1}` : (/* @__PURE__ */ new Date()).getMonth() + 1}/${(/* @__PURE__ */ new Date()).getDate() < 10 ? `0${(/* @__PURE__ */ new Date()).getDate()}` : (/* @__PURE__ */ new Date()).getDate()}/${(/* @__PURE__ */ new Date()).getFullYear()})`;
|
|
2403
2414
|
}
|
|
2404
2415
|
function parseChangelogMarkdown(contents) {
|
|
2405
2416
|
const CHANGELOG_RELEASE_HEAD_RE = new RegExp(
|
|
@@ -2428,11 +2439,321 @@ 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
|
+
tree,
|
|
2454
|
+
args,
|
|
2455
|
+
changes,
|
|
2456
|
+
projectGraph,
|
|
2457
|
+
projectsVersionData,
|
|
2458
|
+
releaseGroup,
|
|
2459
|
+
projects,
|
|
2460
|
+
releaseConfig,
|
|
2461
|
+
projectToAdditionalDependencyBumps,
|
|
2462
|
+
workspaceConfig,
|
|
2463
|
+
ChangelogRendererClass
|
|
2464
|
+
}) {
|
|
2465
|
+
const config5 = releaseGroup.changelog;
|
|
2466
|
+
if (config5 === false) {
|
|
2467
|
+
return;
|
|
2468
|
+
}
|
|
2469
|
+
const dryRun = !!args.dryRun;
|
|
2470
|
+
const repoData = getGitHubRepoData(args.gitRemote, "github");
|
|
2471
|
+
if (!repoData) {
|
|
2472
|
+
throw new Error(
|
|
2473
|
+
`Unable to create a remote release client because the GitHub repo slug could not be determined. Please ensure you have a valid GitHub remote configured.`
|
|
2474
|
+
);
|
|
2475
|
+
}
|
|
2476
|
+
const remoteReleaseClient = new StormGithubRemoteReleaseClient(
|
|
2477
|
+
repoData,
|
|
2478
|
+
{
|
|
2479
|
+
provider: "github",
|
|
2480
|
+
hostname: repoData.hostname,
|
|
2481
|
+
apiBaseUrl: repoData.apiBaseUrl
|
|
2482
|
+
},
|
|
2483
|
+
await resolveTokenData(repoData.hostname),
|
|
2484
|
+
workspaceConfig
|
|
2485
|
+
);
|
|
2486
|
+
const projectChangelogs = {};
|
|
2487
|
+
for (const project of projects) {
|
|
2488
|
+
let interpolatedTreePath = config5.file || "";
|
|
2489
|
+
if (interpolatedTreePath) {
|
|
2490
|
+
interpolatedTreePath = utils.interpolate(interpolatedTreePath, {
|
|
2491
|
+
projectName: project.name,
|
|
2492
|
+
projectRoot: project.data.root,
|
|
2493
|
+
workspaceRoot: ""
|
|
2494
|
+
// within the tree, workspaceRoot is the root
|
|
2495
|
+
});
|
|
2496
|
+
}
|
|
2497
|
+
if (!projectsVersionData[project.name] || projectsVersionData[project.name]?.newVersion === null && !projectsVersionData[project.name]?.dockerVersion) {
|
|
2498
|
+
continue;
|
|
2499
|
+
}
|
|
2500
|
+
const preferDockerVersion = shared.shouldPreferDockerVersionForReleaseGroup(releaseGroup);
|
|
2501
|
+
const releaseVersion = new shared.ReleaseVersion({
|
|
2502
|
+
version: (preferDockerVersion === true || preferDockerVersion === "both") && projectsVersionData[project.name]?.dockerVersion ? projectsVersionData[project.name]?.dockerVersion : projectsVersionData[project.name]?.newVersion,
|
|
2503
|
+
releaseTagPattern: releaseGroup.releaseTag.pattern,
|
|
2504
|
+
projectName: project.name
|
|
2505
|
+
});
|
|
2506
|
+
if (interpolatedTreePath) {
|
|
2507
|
+
const prefix = dryRun ? "Previewing" : "Generating";
|
|
2508
|
+
devkit.output.log({
|
|
2509
|
+
title: `${prefix} an entry in ${interpolatedTreePath} for ${chalk__default.default.white(
|
|
2510
|
+
releaseVersion.gitTag
|
|
2511
|
+
)}`
|
|
2512
|
+
});
|
|
2513
|
+
}
|
|
2514
|
+
const changelogRenderer = new ChangelogRendererClass({
|
|
2515
|
+
changes,
|
|
2516
|
+
changelogEntryVersion: releaseVersion.rawVersion,
|
|
2517
|
+
project: project.name,
|
|
2518
|
+
entryWhenNoChanges: typeof config5.entryWhenNoChanges === "string" ? utils.interpolate(config5.entryWhenNoChanges, {
|
|
2519
|
+
projectName: project.name,
|
|
2520
|
+
projectRoot: project.data.root,
|
|
2521
|
+
workspaceRoot: ""
|
|
2522
|
+
// within the tree, workspaceRoot is the root
|
|
2523
|
+
}) : false,
|
|
2524
|
+
changelogRenderOptions: config5.renderOptions,
|
|
2525
|
+
isVersionPlans: !!releaseGroup.versionPlans,
|
|
2526
|
+
conventionalCommitsConfig: releaseConfig.conventionalCommits,
|
|
2527
|
+
dependencyBumps: projectToAdditionalDependencyBumps.get(project.name),
|
|
2528
|
+
remoteReleaseClient,
|
|
2529
|
+
workspaceConfig
|
|
2530
|
+
});
|
|
2531
|
+
const contents = await changelogRenderer.render();
|
|
2532
|
+
const postGitTask = args.createRelease !== false && config5.createRelease ? remoteReleaseClient.createPostGitTask(
|
|
2533
|
+
releaseVersion,
|
|
2534
|
+
contents,
|
|
2535
|
+
dryRun
|
|
2536
|
+
) : null;
|
|
2537
|
+
projectChangelogs[project.name] = {
|
|
2538
|
+
releaseVersion,
|
|
2539
|
+
contents,
|
|
2540
|
+
postGitTask
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2543
|
+
for (const [projectName, projectChangelog] of Object.entries(
|
|
2544
|
+
projectChangelogs
|
|
2545
|
+
)) {
|
|
2546
|
+
if (!projectGraph.nodes[projectName]?.data.root) {
|
|
2547
|
+
chunkEHPPIARR_cjs.writeWarning(
|
|
2548
|
+
`A changelog was generated for ${projectName}, but it could not be found in the project graph. Skipping writing changelog file.`,
|
|
2549
|
+
workspaceConfig
|
|
2550
|
+
);
|
|
2551
|
+
} else if (projectChangelog.contents) {
|
|
2552
|
+
const filePath = chunkEHPPIARR_cjs.joinPaths(
|
|
2553
|
+
projectGraph.nodes[projectName].data.root,
|
|
2554
|
+
"CHANGELOG.md"
|
|
2555
|
+
);
|
|
2556
|
+
let currentContent;
|
|
2557
|
+
if (fs$1.existsSync(filePath)) {
|
|
2558
|
+
currentContent = await fs.readFile(filePath, "utf8");
|
|
2559
|
+
}
|
|
2560
|
+
chunkEHPPIARR_cjs.writeDebug(
|
|
2561
|
+
`\u270D\uFE0F Writing changelog for project ${projectName} to ${filePath}`,
|
|
2562
|
+
workspaceConfig
|
|
2563
|
+
);
|
|
2564
|
+
const content = await generateChangelogContent(
|
|
2565
|
+
projectChangelog.releaseVersion,
|
|
2566
|
+
filePath,
|
|
2567
|
+
projectChangelog.contents,
|
|
2568
|
+
currentContent,
|
|
2569
|
+
projectName,
|
|
2570
|
+
workspaceConfig
|
|
2571
|
+
);
|
|
2572
|
+
tree.write(filePath, content);
|
|
2573
|
+
printChanges.printAndFlushChanges(
|
|
2574
|
+
tree,
|
|
2575
|
+
!!args.dryRun,
|
|
2576
|
+
3,
|
|
2577
|
+
false,
|
|
2578
|
+
shared.noDiffInChangelogMessage,
|
|
2579
|
+
// Only print the change for the current changelog file at this point
|
|
2580
|
+
(f) => f.path === filePath
|
|
2581
|
+
);
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
return projectChangelogs;
|
|
2585
|
+
}
|
|
2586
|
+
async function getCommits(fromSHA, toSHA) {
|
|
2587
|
+
const rawCommits = await git.getGitDiff(fromSHA, toSHA);
|
|
2588
|
+
return git.parseCommits(rawCommits);
|
|
2589
|
+
}
|
|
2590
|
+
async function filterProjectCommits({
|
|
2591
|
+
fromSHA,
|
|
2592
|
+
toSHA,
|
|
2593
|
+
projectPath
|
|
2594
|
+
}) {
|
|
2595
|
+
const allCommits = await getCommits(fromSHA, toSHA);
|
|
2596
|
+
return allCommits.filter(
|
|
2597
|
+
(c) => c.affectedFiles.find((f) => f.startsWith(projectPath))
|
|
2598
|
+
);
|
|
2599
|
+
}
|
|
2600
|
+
function commitChangesNonProjectFiles(commit, nonProjectFiles) {
|
|
2601
|
+
return nonProjectFiles.some(
|
|
2602
|
+
(fileData) => commit.affectedFiles.includes(fileData.file)
|
|
2603
|
+
);
|
|
2604
|
+
}
|
|
2605
|
+
function getProjectsAffectedByCommit(commit, fileToProjectMap) {
|
|
2606
|
+
const affectedProjects = /* @__PURE__ */ new Set();
|
|
2607
|
+
for (const file of commit.affectedFiles) {
|
|
2608
|
+
affectedProjects.add(fileToProjectMap[file]);
|
|
2609
|
+
}
|
|
2610
|
+
return Array.from(affectedProjects);
|
|
2611
|
+
}
|
|
2612
|
+
function extractPreid(version) {
|
|
2613
|
+
if (!shared.isPrerelease(version)) {
|
|
2614
|
+
return void 0;
|
|
2615
|
+
}
|
|
2616
|
+
const preid = semver.prerelease(version)?.[0];
|
|
2617
|
+
if (typeof preid === "string") {
|
|
2618
|
+
if (preid.trim() === "") {
|
|
2619
|
+
return void 0;
|
|
2620
|
+
}
|
|
2621
|
+
return preid;
|
|
2622
|
+
}
|
|
2623
|
+
if (typeof preid === "number") {
|
|
2624
|
+
return preid.toString();
|
|
2625
|
+
}
|
|
2626
|
+
return void 0;
|
|
2627
|
+
}
|
|
2628
|
+
async function gitTag({
|
|
2629
|
+
tag,
|
|
2630
|
+
message,
|
|
2631
|
+
additionalArgs,
|
|
2632
|
+
dryRun,
|
|
2633
|
+
verbose,
|
|
2634
|
+
logFn
|
|
2635
|
+
}) {
|
|
2636
|
+
logFn = logFn || console.log;
|
|
2637
|
+
const commandArgs = [
|
|
2638
|
+
"tag",
|
|
2639
|
+
// Create an annotated tag (recommended for releases here: https://git-scm.com/docs/git-tag)
|
|
2640
|
+
"--annotate",
|
|
2641
|
+
"--sign",
|
|
2642
|
+
tag,
|
|
2643
|
+
"--message",
|
|
2644
|
+
message || tag
|
|
2645
|
+
];
|
|
2646
|
+
if (additionalArgs) {
|
|
2647
|
+
if (Array.isArray(additionalArgs)) {
|
|
2648
|
+
commandArgs.push(...additionalArgs);
|
|
2649
|
+
} else {
|
|
2650
|
+
commandArgs.push(...additionalArgs.split(" "));
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
if (verbose) {
|
|
2654
|
+
logFn(
|
|
2655
|
+
dryRun ? `Would tag the current commit in git with the following command, but --dry-run was set:` : `Tagging the current commit in git with the following command:`
|
|
2656
|
+
);
|
|
2657
|
+
logFn(`git ${commandArgs.join(" ")}`);
|
|
2658
|
+
}
|
|
2659
|
+
if (dryRun) {
|
|
2660
|
+
return "";
|
|
2661
|
+
}
|
|
2662
|
+
try {
|
|
2663
|
+
return await execCommand_js.execCommand("git", commandArgs);
|
|
2664
|
+
} catch (err) {
|
|
2665
|
+
throw new Error(`Unexpected error when creating tag ${tag}:
|
|
2666
|
+
|
|
2667
|
+
${err}`);
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
async function gitCommit({
|
|
2671
|
+
messages,
|
|
2672
|
+
additionalArgs,
|
|
2673
|
+
dryRun,
|
|
2674
|
+
verbose,
|
|
2675
|
+
logFn
|
|
2676
|
+
}) {
|
|
2677
|
+
logFn = logFn || console.log;
|
|
2678
|
+
const commandArgs = ["commit", "-S"];
|
|
2679
|
+
for (const message of messages) {
|
|
2680
|
+
commandArgs.push("--message", message);
|
|
2681
|
+
}
|
|
2682
|
+
if (additionalArgs) {
|
|
2683
|
+
if (Array.isArray(additionalArgs)) {
|
|
2684
|
+
commandArgs.push(...additionalArgs);
|
|
2685
|
+
} else {
|
|
2686
|
+
commandArgs.push(...additionalArgs.split(" "));
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2689
|
+
if (verbose) {
|
|
2690
|
+
logFn(
|
|
2691
|
+
dryRun ? `Would commit all previously staged files in git with the following command, but --dry-run was set:` : `Committing files in git with the following command:`
|
|
2692
|
+
);
|
|
2693
|
+
logFn(`git ${commandArgs.join(" ")}`);
|
|
2694
|
+
}
|
|
2695
|
+
if (dryRun) {
|
|
2696
|
+
return;
|
|
2697
|
+
}
|
|
2698
|
+
let hasStagedFiles = false;
|
|
2699
|
+
try {
|
|
2700
|
+
await execCommand_js.execCommand("git", ["diff-index", "--quiet", "HEAD", "--cached"]);
|
|
2701
|
+
} catch {
|
|
2702
|
+
hasStagedFiles = true;
|
|
2703
|
+
}
|
|
2704
|
+
if (!hasStagedFiles) {
|
|
2705
|
+
logFn("\nNo staged files found. Skipping commit.");
|
|
2706
|
+
return;
|
|
2707
|
+
}
|
|
2708
|
+
return execCommand_js.execCommand("git", commandArgs);
|
|
2709
|
+
}
|
|
2710
|
+
async function commitChanges({
|
|
2711
|
+
changedFiles,
|
|
2712
|
+
deletedFiles,
|
|
2713
|
+
isDryRun,
|
|
2714
|
+
isVerbose: isVerbose2,
|
|
2715
|
+
gitCommitMessages,
|
|
2716
|
+
gitCommitArgs,
|
|
2717
|
+
logFn
|
|
2718
|
+
}) {
|
|
2719
|
+
logFn = logFn || console.log;
|
|
2720
|
+
if (!changedFiles?.length && !deletedFiles?.length) {
|
|
2721
|
+
throw new Error("Error: No changed files to commit");
|
|
2722
|
+
}
|
|
2723
|
+
logFn(`Committing changes with git`);
|
|
2724
|
+
await git.gitAdd({
|
|
2725
|
+
changedFiles,
|
|
2726
|
+
deletedFiles,
|
|
2727
|
+
dryRun: isDryRun,
|
|
2728
|
+
verbose: isVerbose2
|
|
2729
|
+
});
|
|
2730
|
+
if (isVerbose2) {
|
|
2731
|
+
console.log("");
|
|
2732
|
+
}
|
|
2733
|
+
await gitCommit({
|
|
2734
|
+
messages: gitCommitMessages || [],
|
|
2735
|
+
additionalArgs: gitCommitArgs,
|
|
2736
|
+
dryRun: isDryRun,
|
|
2737
|
+
verbose: isVerbose2
|
|
2738
|
+
});
|
|
2739
|
+
}
|
|
2740
|
+
|
|
2741
|
+
// src/utilities/omit.ts
|
|
2742
|
+
function omit(obj, keys) {
|
|
2743
|
+
const result = { ...obj };
|
|
2744
|
+
for (let i = 0; i < keys.length; i++) {
|
|
2745
|
+
const key = keys[i];
|
|
2746
|
+
if (key && key in result) {
|
|
2747
|
+
delete result[key];
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
return result;
|
|
2751
|
+
}
|
|
2431
2752
|
|
|
2432
2753
|
// src/release/github.ts
|
|
2433
2754
|
var StormGithubRemoteReleaseClient = class extends github.GithubRemoteReleaseClient {
|
|
2434
|
-
|
|
2435
|
-
|
|
2755
|
+
repoData;
|
|
2756
|
+
workspaceConfig;
|
|
2436
2757
|
/**
|
|
2437
2758
|
* Creates an instance of {@link StormGithubRemoteReleaseClient}.
|
|
2438
2759
|
*
|
|
@@ -2441,63 +2762,71 @@ var StormGithubRemoteReleaseClient = class extends github.GithubRemoteReleaseCli
|
|
|
2441
2762
|
* @param tokenData - Token data for authentication
|
|
2442
2763
|
* @param workspaceConfig - The Storm workspace configuration object, which is loaded from the storm-workspace.json file.
|
|
2443
2764
|
*/
|
|
2444
|
-
constructor(
|
|
2445
|
-
super(
|
|
2446
|
-
this
|
|
2447
|
-
this
|
|
2765
|
+
constructor(repoData, createReleaseConfig, tokenData, workspaceConfig) {
|
|
2766
|
+
super(repoData, createReleaseConfig, tokenData);
|
|
2767
|
+
this.repoData = repoData;
|
|
2768
|
+
this.workspaceConfig = workspaceConfig;
|
|
2448
2769
|
}
|
|
2449
2770
|
createPostGitTask(releaseVersion, changelogContents, dryRun) {
|
|
2450
2771
|
return async (latestCommit) => {
|
|
2451
|
-
if (!this.#workspaceConfig) {
|
|
2452
|
-
this.#workspaceConfig = await chunkEHPPIARR_cjs.getWorkspaceConfig();
|
|
2453
|
-
}
|
|
2454
2772
|
devkit.output.logSingleLine(`Creating GitHub Release`);
|
|
2455
|
-
const name = releaseVersion.gitTag.includes("@") ? releaseVersion.gitTag.replace(new RegExp(`^@${this.#workspaceConfig.name}/`), "").replace(/@.*$/, "") : releaseVersion.gitTag;
|
|
2456
2773
|
await this.createOrUpdateRelease(
|
|
2457
2774
|
releaseVersion,
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2775
|
+
changelogContents,
|
|
2776
|
+
latestCommit,
|
|
2777
|
+
{ dryRun }
|
|
2778
|
+
);
|
|
2779
|
+
};
|
|
2780
|
+
}
|
|
2781
|
+
async createOrUpdateRelease(releaseVersion, changelogContents, latestCommit, { dryRun }) {
|
|
2782
|
+
if (!this.workspaceConfig) {
|
|
2783
|
+
this.workspaceConfig = await chunkEHPPIARR_cjs.getWorkspaceConfig();
|
|
2784
|
+
}
|
|
2785
|
+
const name = releaseVersion.gitTag.includes("@") ? releaseVersion.gitTag.replace(new RegExp(`^@${this.workspaceConfig.name}/`), "").replace(/@.*$/, "") : releaseVersion.gitTag;
|
|
2786
|
+
return super.createOrUpdateRelease(
|
|
2787
|
+
releaseVersion,
|
|
2788
|
+
`
|
|
2791
|
+
${this.workspaceConfig.release.header || ""}
|
|
2462
2792
|
|
|
2463
2793
|
# ${name ? `${titleCase(name)} ` : ""}v${releaseVersion.rawVersion}
|
|
2464
2794
|
|
|
2465
|
-
We at [${this
|
|
2466
|
-
|
|
2467
|
-
|
|
2795
|
+
We at [${this.workspaceConfig.organization ? titleCase(
|
|
2796
|
+
typeof this.workspaceConfig.organization === "string" ? this.workspaceConfig.organization : this.workspaceConfig.organization.name
|
|
2797
|
+
) : ""}](${this.workspaceConfig.homepage}) are very excited to announce the v${releaseVersion.rawVersion} release of the ${name ? this.workspaceConfig.name ? `${titleCase(this.workspaceConfig.name)} - ${titleCase(name)}` : titleCase(name) : this.workspaceConfig.name ? titleCase(this.workspaceConfig.name) : "Storm Software"} project! \u{1F680}
|
|
2468
2798
|
|
|
2469
|
-
These changes are released under the ${this
|
|
2799
|
+
These changes are released under the ${this.workspaceConfig.license.includes("license") ? this.workspaceConfig.license : `${this.workspaceConfig.license} license`}. You can find more details on [our licensing page](${this.workspaceConfig.licensing}). You can find guides, API references, and other documentation around this release (and much more) on [our documentation site](${this.workspaceConfig.docs}).
|
|
2470
2800
|
|
|
2471
|
-
If you have any questions or comments, feel free to reach out to the team on [Discord](${this
|
|
2801
|
+
If you have any questions or comments, feel free to reach out to the team on [Discord](${this.workspaceConfig.socials.discord}) or [our contact page](${this.workspaceConfig.contact}). Please help us spread the word by giving [this repository](https://github.com/${typeof this.workspaceConfig.organization === "string" ? this.workspaceConfig.organization : this.workspaceConfig.organization?.name}/${this.workspaceConfig.name}) a star \u2B50 on GitHub or [posting on X (Twitter)](https://x.com/intent/tweet?text=Check%20out%20the%20latest%20@${this.workspaceConfig.socials.twitter}%20release%20${name ? `${titleCase(name)?.replaceAll(" ", "%20")}%20` : ""}v${releaseVersion.rawVersion}%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/${typeof this.workspaceConfig.organization === "string" ? this.workspaceConfig.organization : this.workspaceConfig.organization?.name}/${this.workspaceConfig.name}/releases/tag/${releaseVersion.gitTag}) about this release!
|
|
2472
2802
|
|
|
2473
2803
|
## Release Notes
|
|
2474
2804
|
|
|
2475
2805
|
${changelogContents.replaceAll(
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2806
|
+
`## ${generateChangelogTitle(
|
|
2807
|
+
releaseVersion.rawVersion,
|
|
2808
|
+
name,
|
|
2809
|
+
this.workspaceConfig
|
|
2810
|
+
)}`,
|
|
2811
|
+
""
|
|
2812
|
+
).replaceAll(
|
|
2813
|
+
`# ${generateChangelogTitle(releaseVersion.rawVersion, name, this.workspaceConfig)}`,
|
|
2814
|
+
""
|
|
2815
|
+
)}
|
|
2486
2816
|
|
|
2487
2817
|
---
|
|
2488
2818
|
|
|
2489
|
-
${this
|
|
2819
|
+
${this.workspaceConfig.release.footer}
|
|
2490
2820
|
`,
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
};
|
|
2821
|
+
latestCommit,
|
|
2822
|
+
{ dryRun }
|
|
2823
|
+
);
|
|
2495
2824
|
}
|
|
2496
2825
|
/**
|
|
2497
2826
|
* Get remote repository data, attempting to resolve it if not already set.
|
|
2498
2827
|
*/
|
|
2499
2828
|
getRemoteRepoData() {
|
|
2500
|
-
if (!this
|
|
2829
|
+
if (!this.repoData) {
|
|
2501
2830
|
let githubRepoData = super.getRemoteRepoData();
|
|
2502
2831
|
if (!githubRepoData) {
|
|
2503
2832
|
githubRepoData = getGitHubRepoData();
|
|
@@ -2511,9 +2840,9 @@ ${this.#workspaceConfig.release.footer}
|
|
|
2511
2840
|
process.exit(1);
|
|
2512
2841
|
}
|
|
2513
2842
|
}
|
|
2514
|
-
this
|
|
2843
|
+
this.repoData = githubRepoData;
|
|
2515
2844
|
}
|
|
2516
|
-
return this
|
|
2845
|
+
return this.repoData;
|
|
2517
2846
|
}
|
|
2518
2847
|
};
|
|
2519
2848
|
function getGitHubRepoData(remoteName = "origin", createReleaseConfig = "github") {
|
|
@@ -2598,24 +2927,6 @@ async function makeGithubRequest(config5, url, opts = {}) {
|
|
|
2598
2927
|
}
|
|
2599
2928
|
});
|
|
2600
2929
|
}
|
|
2601
|
-
async function createGithubRemoteReleaseClient(workspaceConfig, remoteName = "origin") {
|
|
2602
|
-
const repoData = getGitHubRepoData(remoteName, "github");
|
|
2603
|
-
if (!repoData) {
|
|
2604
|
-
throw new Error(
|
|
2605
|
-
`Unable to create a remote release client because the GitHub repo slug could not be determined. Please ensure you have a valid GitHub remote configured.`
|
|
2606
|
-
);
|
|
2607
|
-
}
|
|
2608
|
-
return new StormGithubRemoteReleaseClient(
|
|
2609
|
-
repoData,
|
|
2610
|
-
{
|
|
2611
|
-
provider: "github",
|
|
2612
|
-
hostname: repoData.hostname,
|
|
2613
|
-
apiBaseUrl: repoData.apiBaseUrl
|
|
2614
|
-
},
|
|
2615
|
-
await resolveTokenData(repoData.hostname),
|
|
2616
|
-
workspaceConfig
|
|
2617
|
-
);
|
|
2618
|
-
}
|
|
2619
2930
|
async function isUserAnOrganizationMember(userId, config5, remoteName = "origin") {
|
|
2620
2931
|
try {
|
|
2621
2932
|
const repoData = getGitHubRepoData(remoteName, "github");
|
|
@@ -2648,164 +2959,6 @@ async function isUserAnOrganizationMember(userId, config5, remoteName = "origin"
|
|
|
2648
2959
|
return false;
|
|
2649
2960
|
}
|
|
2650
2961
|
}
|
|
2651
|
-
function createGitTagValues(releaseGroups, releaseGroupToFilteredProjects, versionData) {
|
|
2652
|
-
const tags = [];
|
|
2653
|
-
for (const releaseGroup of releaseGroups) {
|
|
2654
|
-
const releaseGroupProjectNames = Array.from(
|
|
2655
|
-
releaseGroupToFilteredProjects.get(releaseGroup) ?? []
|
|
2656
|
-
);
|
|
2657
|
-
if (releaseGroup.projectsRelationship === "independent") {
|
|
2658
|
-
for (const project of releaseGroupProjectNames) {
|
|
2659
|
-
const projectVersionData = versionData[project];
|
|
2660
|
-
if (projectVersionData?.newVersion) {
|
|
2661
|
-
tags.push(
|
|
2662
|
-
utils.interpolate(releaseGroup.releaseTagPattern, {
|
|
2663
|
-
version: projectVersionData.newVersion,
|
|
2664
|
-
projectName: project
|
|
2665
|
-
})
|
|
2666
|
-
);
|
|
2667
|
-
}
|
|
2668
|
-
}
|
|
2669
|
-
continue;
|
|
2670
|
-
}
|
|
2671
|
-
if (releaseGroupProjectNames.length > 0 && releaseGroupProjectNames[0]) {
|
|
2672
|
-
const projectVersionData = versionData[releaseGroupProjectNames[0]];
|
|
2673
|
-
if (projectVersionData?.newVersion) {
|
|
2674
|
-
tags.push(
|
|
2675
|
-
utils.interpolate(releaseGroup.releaseTagPattern, {
|
|
2676
|
-
version: projectVersionData.newVersion,
|
|
2677
|
-
releaseGroupName: releaseGroup.name
|
|
2678
|
-
})
|
|
2679
|
-
);
|
|
2680
|
-
}
|
|
2681
|
-
}
|
|
2682
|
-
}
|
|
2683
|
-
return tags;
|
|
2684
|
-
}
|
|
2685
|
-
async function gitTag({
|
|
2686
|
-
tag,
|
|
2687
|
-
message,
|
|
2688
|
-
additionalArgs,
|
|
2689
|
-
dryRun,
|
|
2690
|
-
verbose,
|
|
2691
|
-
logFn
|
|
2692
|
-
}) {
|
|
2693
|
-
logFn = logFn || console.log;
|
|
2694
|
-
const commandArgs = [
|
|
2695
|
-
"tag",
|
|
2696
|
-
// Create an annotated tag (recommended for releases here: https://git-scm.com/docs/git-tag)
|
|
2697
|
-
"--annotate",
|
|
2698
|
-
"--sign",
|
|
2699
|
-
tag,
|
|
2700
|
-
"--message",
|
|
2701
|
-
message || tag
|
|
2702
|
-
];
|
|
2703
|
-
if (additionalArgs) {
|
|
2704
|
-
if (Array.isArray(additionalArgs)) {
|
|
2705
|
-
commandArgs.push(...additionalArgs);
|
|
2706
|
-
} else {
|
|
2707
|
-
commandArgs.push(...additionalArgs.split(" "));
|
|
2708
|
-
}
|
|
2709
|
-
}
|
|
2710
|
-
if (verbose) {
|
|
2711
|
-
logFn(
|
|
2712
|
-
dryRun ? `Would tag the current commit in git with the following command, but --dry-run was set:` : `Tagging the current commit in git with the following command:`
|
|
2713
|
-
);
|
|
2714
|
-
logFn(`git ${commandArgs.join(" ")}`);
|
|
2715
|
-
}
|
|
2716
|
-
if (dryRun) {
|
|
2717
|
-
return "";
|
|
2718
|
-
}
|
|
2719
|
-
try {
|
|
2720
|
-
return await execCommand_js.execCommand("git", commandArgs);
|
|
2721
|
-
} catch (err) {
|
|
2722
|
-
throw new Error(`Unexpected error when creating tag ${tag}:
|
|
2723
|
-
|
|
2724
|
-
${err}`);
|
|
2725
|
-
}
|
|
2726
|
-
}
|
|
2727
|
-
async function gitCommit({
|
|
2728
|
-
messages,
|
|
2729
|
-
additionalArgs,
|
|
2730
|
-
dryRun,
|
|
2731
|
-
verbose,
|
|
2732
|
-
logFn
|
|
2733
|
-
}) {
|
|
2734
|
-
logFn = logFn || console.log;
|
|
2735
|
-
const commandArgs = ["commit", "-S"];
|
|
2736
|
-
for (const message of messages) {
|
|
2737
|
-
commandArgs.push("--message", message);
|
|
2738
|
-
}
|
|
2739
|
-
if (additionalArgs) {
|
|
2740
|
-
if (Array.isArray(additionalArgs)) {
|
|
2741
|
-
commandArgs.push(...additionalArgs);
|
|
2742
|
-
} else {
|
|
2743
|
-
commandArgs.push(...additionalArgs.split(" "));
|
|
2744
|
-
}
|
|
2745
|
-
}
|
|
2746
|
-
if (verbose) {
|
|
2747
|
-
logFn(
|
|
2748
|
-
dryRun ? `Would commit all previously staged files in git with the following command, but --dry-run was set:` : `Committing files in git with the following command:`
|
|
2749
|
-
);
|
|
2750
|
-
logFn(`git ${commandArgs.join(" ")}`);
|
|
2751
|
-
}
|
|
2752
|
-
if (dryRun) {
|
|
2753
|
-
return;
|
|
2754
|
-
}
|
|
2755
|
-
let hasStagedFiles = false;
|
|
2756
|
-
try {
|
|
2757
|
-
await execCommand_js.execCommand("git", ["diff-index", "--quiet", "HEAD", "--cached"]);
|
|
2758
|
-
} catch {
|
|
2759
|
-
hasStagedFiles = true;
|
|
2760
|
-
}
|
|
2761
|
-
if (!hasStagedFiles) {
|
|
2762
|
-
logFn("\nNo staged files found. Skipping commit.");
|
|
2763
|
-
return;
|
|
2764
|
-
}
|
|
2765
|
-
return execCommand_js.execCommand("git", commandArgs);
|
|
2766
|
-
}
|
|
2767
|
-
async function commitChanges({
|
|
2768
|
-
changedFiles,
|
|
2769
|
-
deletedFiles,
|
|
2770
|
-
isDryRun,
|
|
2771
|
-
isVerbose: isVerbose2,
|
|
2772
|
-
gitCommitMessages,
|
|
2773
|
-
gitCommitArgs,
|
|
2774
|
-
logFn
|
|
2775
|
-
}) {
|
|
2776
|
-
logFn = logFn || console.log;
|
|
2777
|
-
if (!changedFiles?.length && !deletedFiles?.length) {
|
|
2778
|
-
throw new Error("Error: No changed files to commit");
|
|
2779
|
-
}
|
|
2780
|
-
logFn(`Committing changes with git`);
|
|
2781
|
-
await git.gitAdd({
|
|
2782
|
-
changedFiles,
|
|
2783
|
-
deletedFiles,
|
|
2784
|
-
dryRun: isDryRun,
|
|
2785
|
-
verbose: isVerbose2
|
|
2786
|
-
});
|
|
2787
|
-
if (isVerbose2) {
|
|
2788
|
-
console.log("");
|
|
2789
|
-
}
|
|
2790
|
-
await gitCommit({
|
|
2791
|
-
messages: gitCommitMessages || [],
|
|
2792
|
-
additionalArgs: gitCommitArgs,
|
|
2793
|
-
dryRun: isDryRun,
|
|
2794
|
-
verbose: isVerbose2
|
|
2795
|
-
});
|
|
2796
|
-
}
|
|
2797
|
-
|
|
2798
|
-
// src/utilities/omit.ts
|
|
2799
|
-
function omit(obj, keys) {
|
|
2800
|
-
const result = { ...obj };
|
|
2801
|
-
for (let i = 0; i < keys.length; i++) {
|
|
2802
|
-
const key = keys[i];
|
|
2803
|
-
if (key && key in result) {
|
|
2804
|
-
delete result[key];
|
|
2805
|
-
}
|
|
2806
|
-
}
|
|
2807
|
-
return result;
|
|
2808
|
-
}
|
|
2809
2962
|
var StormChangelogRenderer = class extends DefaultChangelogRenderer__default.default {
|
|
2810
2963
|
/**
|
|
2811
2964
|
* The Storm workspace configuration object, which is loaded from the storm-workspace.json file.
|
|
@@ -2823,15 +2976,13 @@ var StormChangelogRenderer = class extends DefaultChangelogRenderer__default.def
|
|
|
2823
2976
|
...config5
|
|
2824
2977
|
};
|
|
2825
2978
|
super(resolvedConfig);
|
|
2826
|
-
this.workspaceConfig = config5.
|
|
2979
|
+
this.workspaceConfig = config5.workspaceConfig;
|
|
2980
|
+
this.remoteReleaseClient = resolvedConfig.remoteReleaseClient;
|
|
2827
2981
|
}
|
|
2828
2982
|
async render() {
|
|
2829
2983
|
if (!this.workspaceConfig) {
|
|
2830
2984
|
this.workspaceConfig = await chunkEHPPIARR_cjs.getWorkspaceConfig();
|
|
2831
2985
|
}
|
|
2832
|
-
this.remoteReleaseClient = await createGithubRemoteReleaseClient(
|
|
2833
|
-
this.workspaceConfig
|
|
2834
|
-
);
|
|
2835
2986
|
return super.render();
|
|
2836
2987
|
}
|
|
2837
2988
|
preprocessChanges() {
|
|
@@ -3080,8 +3231,6 @@ var DEFAULT_RELEASE_CONFIG = {
|
|
|
3080
3231
|
},
|
|
3081
3232
|
releaseTag: { pattern: DEFAULT_RELEASE_TAG_PATTERN }
|
|
3082
3233
|
};
|
|
3083
|
-
|
|
3084
|
-
// src/release/release-client.ts
|
|
3085
3234
|
function getReleaseGroupConfig(releaseConfig, workspaceConfig) {
|
|
3086
3235
|
return !releaseConfig?.groups || Object.keys(releaseConfig.groups).length === 0 ? {} : Object.fromEntries(
|
|
3087
3236
|
Object.entries(releaseConfig.groups).map(([name, group]) => {
|
|
@@ -3119,6 +3268,8 @@ function getReleaseGroupConfig(releaseConfig, workspaceConfig) {
|
|
|
3119
3268
|
})
|
|
3120
3269
|
);
|
|
3121
3270
|
}
|
|
3271
|
+
|
|
3272
|
+
// src/release/release-client.ts
|
|
3122
3273
|
var StormReleaseClient = class _StormReleaseClient extends release.ReleaseClient {
|
|
3123
3274
|
static async create(releaseConfig = {}, ignoreNxJsonConfig = false, workspaceConfig) {
|
|
3124
3275
|
if (!workspaceConfig) {
|
|
@@ -3145,7 +3296,6 @@ var StormReleaseClient = class _StormReleaseClient extends release.ReleaseClient
|
|
|
3145
3296
|
workspaceConfig
|
|
3146
3297
|
);
|
|
3147
3298
|
}
|
|
3148
|
-
#releaseChangelog;
|
|
3149
3299
|
/**
|
|
3150
3300
|
* The release configuration used by this release client.
|
|
3151
3301
|
*/
|
|
@@ -3191,7 +3341,10 @@ var StormReleaseClient = class _StormReleaseClient extends release.ReleaseClient
|
|
|
3191
3341
|
groups: getReleaseGroupConfig(releaseConfig, workspaceConfig)
|
|
3192
3342
|
},
|
|
3193
3343
|
{
|
|
3194
|
-
groups: getReleaseGroupConfig(
|
|
3344
|
+
groups: getReleaseGroupConfig(
|
|
3345
|
+
nxJson$1.release ?? {},
|
|
3346
|
+
workspaceConfig
|
|
3347
|
+
)
|
|
3195
3348
|
},
|
|
3196
3349
|
omit(releaseConfig, ["groups"]),
|
|
3197
3350
|
nxJson$1.release ? omit(nxJson$1.release, ["groups"]) : {},
|
|
@@ -3207,89 +3360,265 @@ var StormReleaseClient = class _StormReleaseClient extends release.ReleaseClient
|
|
|
3207
3360
|
this.config = config5;
|
|
3208
3361
|
this.workspaceConfig = workspaceConfig;
|
|
3209
3362
|
this.tree = new tree.FsTree(workspaceConfig.workspaceRoot, false);
|
|
3210
|
-
this.#releaseChangelog = changelog.createAPI(config5, true);
|
|
3211
3363
|
this.projectConfigurations = devkit.readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
3212
3364
|
}
|
|
3213
3365
|
releaseChangelog = async (options) => {
|
|
3214
|
-
const
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3366
|
+
const to = options.to || "HEAD";
|
|
3367
|
+
const toSHA = await git.getCommitHash(to);
|
|
3368
|
+
const postGitTasks = [];
|
|
3369
|
+
let projectChangelogs = {};
|
|
3370
|
+
const projectsPreid = Object.fromEntries(
|
|
3371
|
+
Object.entries(options.versionData).map(([projectName, v]) => [
|
|
3372
|
+
projectName,
|
|
3373
|
+
v.newVersion ? extractPreid(v.newVersion) : void 0
|
|
3374
|
+
])
|
|
3375
|
+
);
|
|
3376
|
+
const projectToAdditionalDependencyBumps = /* @__PURE__ */ new Map();
|
|
3377
|
+
for (const releaseGroup of options.releaseGraph.releaseGroups) {
|
|
3378
|
+
if (releaseGroup.projectsRelationship !== "independent") {
|
|
3379
|
+
continue;
|
|
3380
|
+
}
|
|
3381
|
+
for (const project of releaseGroup.projects) {
|
|
3382
|
+
if (!options.versionData[project] || options.versionData[project].newVersion === null) {
|
|
3383
|
+
continue;
|
|
3384
|
+
}
|
|
3385
|
+
const dependentProjects = (options.versionData[project].dependentProjects || []).map((dep) => {
|
|
3386
|
+
return {
|
|
3387
|
+
dependencyName: dep.source,
|
|
3388
|
+
newVersion: options.versionData[dep.source]?.newVersion ?? null
|
|
3389
|
+
};
|
|
3390
|
+
}).filter((b) => b.newVersion !== null);
|
|
3391
|
+
for (const dependent of dependentProjects) {
|
|
3392
|
+
const additionalDependencyBumpsForProject = projectToAdditionalDependencyBumps.has(dependent.dependencyName) ? projectToAdditionalDependencyBumps.get(dependent.dependencyName) : [];
|
|
3393
|
+
additionalDependencyBumpsForProject.push({
|
|
3394
|
+
dependencyName: project,
|
|
3395
|
+
newVersion: options.versionData[project].newVersion
|
|
3396
|
+
});
|
|
3397
|
+
projectToAdditionalDependencyBumps.set(
|
|
3398
|
+
dependent.dependencyName,
|
|
3399
|
+
additionalDependencyBumpsForProject
|
|
3400
|
+
);
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3404
|
+
const allProjectChangelogs = {};
|
|
3405
|
+
for (const releaseGroup of options.releaseGraph.releaseGroups) {
|
|
3406
|
+
const config5 = releaseGroup.changelog;
|
|
3407
|
+
if (config5 === false) {
|
|
3408
|
+
continue;
|
|
3409
|
+
}
|
|
3410
|
+
if (!options.releaseGraph.releaseGroupToFilteredProjects.has(releaseGroup)) {
|
|
3411
|
+
throw new Error(
|
|
3412
|
+
`No filtered projects found for release group ${releaseGroup.name}`
|
|
3413
|
+
);
|
|
3414
|
+
}
|
|
3415
|
+
const projects = options.projects?.length ? (
|
|
3416
|
+
// 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
|
|
3417
|
+
Array.from(
|
|
3418
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
3419
|
+
options.releaseGraph.releaseGroupToFilteredProjects.get(
|
|
3420
|
+
releaseGroup
|
|
3421
|
+
)
|
|
3422
|
+
).flatMap((project) => {
|
|
3423
|
+
return [
|
|
3424
|
+
project,
|
|
3425
|
+
...options.versionData[project]?.dependentProjects.map(
|
|
3426
|
+
(dep) => dep.source
|
|
3427
|
+
) || []
|
|
3428
|
+
];
|
|
3429
|
+
})
|
|
3430
|
+
) : (
|
|
3431
|
+
// Otherwise, we use the full list of projects within the release group
|
|
3432
|
+
releaseGroup.projects
|
|
3433
|
+
);
|
|
3434
|
+
const projectNodes = projects.map((name) => this.projectGraph.nodes[name]);
|
|
3435
|
+
if (releaseGroup.projectsRelationship === "independent") {
|
|
3436
|
+
for (const project of projectNodes) {
|
|
3437
|
+
let changes = null;
|
|
3438
|
+
let fromRef = options.from || (await git.getLatestGitTagForPattern(
|
|
3439
|
+
releaseGroup.releaseTag.pattern,
|
|
3440
|
+
{
|
|
3441
|
+
projectName: project.name,
|
|
3442
|
+
releaseGroupName: releaseGroup.name
|
|
3443
|
+
},
|
|
3444
|
+
{
|
|
3445
|
+
checkAllBranchesWhen: releaseGroup.releaseTag.checkAllBranchesWhen,
|
|
3446
|
+
preid: projectsPreid[project.name],
|
|
3447
|
+
requireSemver: releaseGroup.releaseTag.requireSemver,
|
|
3448
|
+
strictPreid: releaseGroup.releaseTag.strictPreid
|
|
3449
|
+
}
|
|
3450
|
+
))?.tag;
|
|
3451
|
+
let commits = void 0;
|
|
3452
|
+
if (!fromRef) {
|
|
3453
|
+
const firstCommit = await git.getFirstGitCommit();
|
|
3454
|
+
commits = await filterProjectCommits({
|
|
3455
|
+
fromSHA: firstCommit,
|
|
3456
|
+
toSHA,
|
|
3457
|
+
projectPath: project.data.root
|
|
3458
|
+
});
|
|
3459
|
+
fromRef = commits[0]?.shortHash;
|
|
3460
|
+
if (options.verbose) {
|
|
3461
|
+
console.log(
|
|
3462
|
+
`Determined --from ref for ${project.name} from the first commit in which it exists: ${fromRef}`
|
|
3232
3463
|
);
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3464
|
+
}
|
|
3465
|
+
}
|
|
3466
|
+
if (!fromRef && !commits) {
|
|
3467
|
+
throw new Error(
|
|
3468
|
+
`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.`
|
|
3469
|
+
);
|
|
3470
|
+
}
|
|
3471
|
+
if (!commits) {
|
|
3472
|
+
commits = await filterProjectCommits({
|
|
3473
|
+
fromSHA: fromRef,
|
|
3474
|
+
toSHA,
|
|
3475
|
+
projectPath: project.data.root
|
|
3476
|
+
});
|
|
3477
|
+
}
|
|
3478
|
+
const { fileMap } = await fileMapUtils.createFileMapUsingProjectGraph(
|
|
3479
|
+
this.projectGraph
|
|
3480
|
+
);
|
|
3481
|
+
const fileToProjectMap = createFileToProjectMap(
|
|
3482
|
+
fileMap.projectFileMap
|
|
3483
|
+
);
|
|
3484
|
+
changes = filterHiddenChanges(
|
|
3485
|
+
commits.map((c) => ({
|
|
3486
|
+
type: c.type,
|
|
3487
|
+
scope: c.scope,
|
|
3488
|
+
description: c.description,
|
|
3489
|
+
body: c.body,
|
|
3490
|
+
isBreaking: c.isBreaking,
|
|
3491
|
+
githubReferences: c.references,
|
|
3492
|
+
authors: c.authors,
|
|
3493
|
+
shortHash: c.shortHash,
|
|
3494
|
+
revertedHashes: c.revertedHashes,
|
|
3495
|
+
affectedProjects: commitChangesNonProjectFiles(
|
|
3496
|
+
c,
|
|
3497
|
+
fileMap.nonProjectFiles
|
|
3498
|
+
) ? "*" : getProjectsAffectedByCommit(c, fileToProjectMap)
|
|
3499
|
+
})),
|
|
3500
|
+
this.config.conventionalCommits
|
|
3501
|
+
);
|
|
3502
|
+
chunkEHPPIARR_cjs.writeDebug(
|
|
3503
|
+
`Running changelog generation for the ${releaseGroup.name} release group`,
|
|
3504
|
+
this.workspaceConfig
|
|
3505
|
+
);
|
|
3506
|
+
projectChangelogs = await generateChangelogForProjects({
|
|
3507
|
+
tree: this.tree,
|
|
3508
|
+
args: options,
|
|
3509
|
+
changes,
|
|
3510
|
+
projectGraph: this.projectGraph,
|
|
3511
|
+
projectsVersionData: options.versionData,
|
|
3512
|
+
releaseGroup,
|
|
3513
|
+
projects: [project],
|
|
3514
|
+
releaseConfig: this.config,
|
|
3515
|
+
projectToAdditionalDependencyBumps,
|
|
3516
|
+
workspaceConfig: this.workspaceConfig,
|
|
3517
|
+
ChangelogRendererClass: StormChangelogRenderer
|
|
3518
|
+
});
|
|
3519
|
+
if (projectChangelogs) {
|
|
3520
|
+
for (const [projectName, projectChangelog] of Object.entries(
|
|
3521
|
+
projectChangelogs
|
|
3522
|
+
)) {
|
|
3523
|
+
if (projectChangelog.postGitTask) {
|
|
3524
|
+
postGitTasks.push(projectChangelog.postGitTask);
|
|
3236
3525
|
}
|
|
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
|
-
);
|
|
3526
|
+
allProjectChangelogs[projectName] = projectChangelog;
|
|
3259
3527
|
}
|
|
3260
3528
|
}
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3529
|
+
}
|
|
3530
|
+
} else {
|
|
3531
|
+
let changes = [];
|
|
3532
|
+
let fromRef = options.from || (await git.getLatestGitTagForPattern(
|
|
3533
|
+
releaseGroup.releaseTag.pattern,
|
|
3534
|
+
{},
|
|
3535
|
+
{
|
|
3536
|
+
checkAllBranchesWhen: releaseGroup.releaseTag.checkAllBranchesWhen,
|
|
3537
|
+
preid: Object.keys(projectsPreid)[0] ? projectsPreid?.[Object.keys(projectsPreid)[0]] : void 0,
|
|
3538
|
+
requireSemver: releaseGroup.releaseTag.requireSemver,
|
|
3539
|
+
strictPreid: releaseGroup.releaseTag.strictPreid
|
|
3540
|
+
}
|
|
3541
|
+
))?.tag;
|
|
3542
|
+
if (!fromRef) {
|
|
3543
|
+
fromRef = await git.getFirstGitCommit();
|
|
3544
|
+
if (options.verbose) {
|
|
3545
|
+
console.log(
|
|
3546
|
+
`Determined release group --from ref from the first commit in the workspace: ${fromRef}`
|
|
3547
|
+
);
|
|
3548
|
+
}
|
|
3549
|
+
}
|
|
3550
|
+
const fromSHA = await git.getCommitHash(fromRef);
|
|
3551
|
+
const { fileMap } = await fileMapUtils.createFileMapUsingProjectGraph(
|
|
3552
|
+
this.projectGraph
|
|
3553
|
+
);
|
|
3554
|
+
const fileToProjectMap = createFileToProjectMap(fileMap.projectFileMap);
|
|
3555
|
+
changes = filterHiddenChanges(
|
|
3556
|
+
(await getCommits(fromSHA, toSHA)).map((c) => ({
|
|
3557
|
+
type: c.type,
|
|
3558
|
+
scope: c.scope,
|
|
3559
|
+
description: c.description,
|
|
3560
|
+
body: c.body,
|
|
3561
|
+
isBreaking: c.isBreaking,
|
|
3562
|
+
githubReferences: c.references,
|
|
3563
|
+
authors: c.authors,
|
|
3564
|
+
shortHash: c.shortHash,
|
|
3565
|
+
revertedHashes: c.revertedHashes,
|
|
3566
|
+
affectedProjects: commitChangesNonProjectFiles(
|
|
3567
|
+
c,
|
|
3568
|
+
fileMap.nonProjectFiles
|
|
3569
|
+
) ? "*" : getProjectsAffectedByCommit(c, fileToProjectMap)
|
|
3570
|
+
})),
|
|
3571
|
+
this.config.conventionalCommits
|
|
3572
|
+
);
|
|
3573
|
+
chunkEHPPIARR_cjs.writeDebug(
|
|
3574
|
+
`Running changelog generation for the ${releaseGroup.name} release group`,
|
|
3575
|
+
this.workspaceConfig
|
|
3576
|
+
);
|
|
3577
|
+
projectChangelogs = await generateChangelogForProjects({
|
|
3578
|
+
tree: this.tree,
|
|
3579
|
+
args: options,
|
|
3580
|
+
changes,
|
|
3581
|
+
projectGraph: this.projectGraph,
|
|
3582
|
+
projectsVersionData: options.versionData,
|
|
3583
|
+
releaseGroup,
|
|
3584
|
+
projects: projectNodes,
|
|
3585
|
+
releaseConfig: this.config,
|
|
3586
|
+
projectToAdditionalDependencyBumps,
|
|
3587
|
+
workspaceConfig: this.workspaceConfig,
|
|
3588
|
+
ChangelogRendererClass: StormChangelogRenderer
|
|
3589
|
+
});
|
|
3590
|
+
if (projectChangelogs) {
|
|
3591
|
+
for (const [projectName, projectChangelog] of Object.entries(
|
|
3592
|
+
projectChangelogs
|
|
3593
|
+
)) {
|
|
3594
|
+
if (projectChangelog.postGitTask) {
|
|
3595
|
+
postGitTasks.push(projectChangelog.postGitTask);
|
|
3596
|
+
}
|
|
3597
|
+
allProjectChangelogs[projectName] = projectChangelog;
|
|
3598
|
+
}
|
|
3599
|
+
}
|
|
3274
3600
|
}
|
|
3275
3601
|
}
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3602
|
+
chunkEHPPIARR_cjs.writeDebug(
|
|
3603
|
+
`Generated changelogs for ${Object.keys(allProjectChangelogs).length} projects:
|
|
3604
|
+
${Object.keys(allProjectChangelogs).map((p) => ` - ${p}`).join("\n")}
|
|
3605
|
+
`,
|
|
3606
|
+
this.workspaceConfig
|
|
3607
|
+
);
|
|
3608
|
+
await this.applyChangesAndExit(options, postGitTasks);
|
|
3609
|
+
return {
|
|
3610
|
+
workspaceChangelog: void 0,
|
|
3611
|
+
projectChangelogs: allProjectChangelogs
|
|
3612
|
+
};
|
|
3283
3613
|
};
|
|
3284
|
-
applyChangesAndExit = async (options,
|
|
3285
|
-
const postGitTasks = Object.values(result.projectChangelogs || {}).map((project) => project.postGitTask).filter(Boolean);
|
|
3614
|
+
applyChangesAndExit = async (options, postGitTasks) => {
|
|
3286
3615
|
const to = options.to || "HEAD";
|
|
3287
3616
|
let latestCommit = await git.getCommitHash(to);
|
|
3288
|
-
const gitTagValues =
|
|
3617
|
+
const gitTagValues = shared.createGitTagValues(
|
|
3289
3618
|
options.releaseGraph.releaseGroups,
|
|
3290
3619
|
options.releaseGraph.releaseGroupToFilteredProjects,
|
|
3291
3620
|
options.versionData
|
|
3292
|
-
)
|
|
3621
|
+
);
|
|
3293
3622
|
shared.handleDuplicateGitTags(gitTagValues);
|
|
3294
3623
|
const commitMessageValues = shared.createCommitMessageValues(
|
|
3295
3624
|
options.releaseGraph.releaseGroups,
|
|
@@ -3298,13 +3627,11 @@ var StormReleaseClient = class _StormReleaseClient extends release.ReleaseClient
|
|
|
3298
3627
|
options.gitCommitMessage || this.config.changelog?.git?.commitMessage || "release(monorepo): Publish workspace release updates"
|
|
3299
3628
|
);
|
|
3300
3629
|
const changes = this.tree.listChanges();
|
|
3301
|
-
if (
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
]
|
|
3307
|
-
});
|
|
3630
|
+
if (!changes.length) {
|
|
3631
|
+
chunkEHPPIARR_cjs.writeWarning(
|
|
3632
|
+
"No changes were detected for any changelog files, so no changelog entries will be generated.",
|
|
3633
|
+
this.workspaceConfig
|
|
3634
|
+
);
|
|
3308
3635
|
if (!postGitTasks.length) {
|
|
3309
3636
|
return;
|
|
3310
3637
|
}
|
|
@@ -3323,7 +3650,10 @@ var StormReleaseClient = class _StormReleaseClient extends release.ReleaseClient
|
|
|
3323
3650
|
gitCommitArgs: options.gitCommitArgs || this.config.changelog?.git?.commitArgs
|
|
3324
3651
|
});
|
|
3325
3652
|
latestCommit = await git.getCommitHash("HEAD");
|
|
3326
|
-
|
|
3653
|
+
chunkEHPPIARR_cjs.writeDebug(
|
|
3654
|
+
`Creating git tags: ${gitTagValues.join(", ")}`,
|
|
3655
|
+
this.workspaceConfig
|
|
3656
|
+
);
|
|
3327
3657
|
for (const tag of gitTagValues) {
|
|
3328
3658
|
await gitTag({
|
|
3329
3659
|
tag,
|
|
@@ -3333,17 +3663,16 @@ var StormReleaseClient = class _StormReleaseClient extends release.ReleaseClient
|
|
|
3333
3663
|
verbose: options.verbose
|
|
3334
3664
|
});
|
|
3335
3665
|
}
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
}
|
|
3666
|
+
chunkEHPPIARR_cjs.writeDebug(
|
|
3667
|
+
`Pushing to git remote "${options.gitRemote ?? "origin"}"`,
|
|
3668
|
+
this.workspaceConfig
|
|
3669
|
+
);
|
|
3670
|
+
await git.gitPush({
|
|
3671
|
+
gitRemote: options.gitRemote,
|
|
3672
|
+
dryRun: options.dryRun,
|
|
3673
|
+
verbose: options.verbose,
|
|
3674
|
+
additionalArgs: options.gitPushArgs || this.config.changelog?.git?.pushArgs
|
|
3675
|
+
});
|
|
3347
3676
|
for (const postGitTask of postGitTasks) {
|
|
3348
3677
|
await postGitTask(latestCommit);
|
|
3349
3678
|
}
|