@williamthorsen/release-kit 6.0.0 → 7.0.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.
Files changed (134) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +3 -3
  3. package/dist/esm/.cache +1 -1
  4. package/dist/esm/assertCleanWorkingTree.js +9 -14
  5. package/dist/esm/bin/release-kit.js +200 -199
  6. package/dist/esm/buildChangelogEntries.d.ts +2 -2
  7. package/dist/esm/buildChangelogEntries.js +142 -149
  8. package/dist/esm/buildDependencyGraph.d.ts +1 -1
  9. package/dist/esm/buildDependencyGraph.js +60 -59
  10. package/dist/esm/buildEmptyReleaseEntry.d.ts +1 -1
  11. package/dist/esm/buildEmptyReleaseEntry.js +12 -15
  12. package/dist/esm/buildReleaseSummary.d.ts +1 -1
  13. package/dist/esm/buildReleaseSummary.js +23 -26
  14. package/dist/esm/buildSyntheticChangelogEntry.d.ts +1 -1
  15. package/dist/esm/buildSyntheticChangelogEntry.js +9 -12
  16. package/dist/esm/bumpAllVersions.d.ts +1 -1
  17. package/dist/esm/bumpAllVersions.js +51 -52
  18. package/dist/esm/bumpVersion.d.ts +1 -1
  19. package/dist/esm/bumpVersion.js +25 -28
  20. package/dist/esm/changelogJsonFile.d.ts +1 -1
  21. package/dist/esm/changelogJsonFile.js +59 -62
  22. package/dist/esm/changelogJsonUtils.d.ts +1 -1
  23. package/dist/esm/changelogJsonUtils.js +35 -32
  24. package/dist/esm/changelogOverrides.d.ts +1 -1
  25. package/dist/esm/changelogOverrides.js +374 -377
  26. package/dist/esm/checkWorkTypesDrift.js +104 -102
  27. package/dist/esm/collectPolicyViolations.d.ts +2 -2
  28. package/dist/esm/collectPolicyViolations.js +11 -14
  29. package/dist/esm/commitCommand.js +48 -46
  30. package/dist/esm/compareVersions.js +20 -23
  31. package/dist/esm/createGithubRelease.js +56 -59
  32. package/dist/esm/createGithubReleaseCommand.js +21 -23
  33. package/dist/esm/createTags.js +57 -56
  34. package/dist/esm/decideRelease.d.ts +2 -2
  35. package/dist/esm/decideRelease.js +27 -41
  36. package/dist/esm/defaults.d.ts +3 -3
  37. package/dist/esm/defaults.js +36 -48
  38. package/dist/esm/deleteFileIfExists.js +10 -12
  39. package/dist/esm/deriveWorkspaceConfig.d.ts +1 -1
  40. package/dist/esm/deriveWorkspaceConfig.js +34 -36
  41. package/dist/esm/detectPackageManager.js +35 -37
  42. package/dist/esm/detectUndeclaredTagPrefixes.js +41 -40
  43. package/dist/esm/determineBumpFromCommits.d.ts +2 -2
  44. package/dist/esm/determineBumpFromCommits.js +25 -29
  45. package/dist/esm/determineBumpType.d.ts +1 -1
  46. package/dist/esm/determineBumpType.js +31 -32
  47. package/dist/esm/discoverWorkspaces.js +38 -40
  48. package/dist/esm/format.js +6 -11
  49. package/dist/esm/generateChangelogs.d.ts +1 -1
  50. package/dist/esm/generateChangelogs.js +13 -17
  51. package/dist/esm/getCommitsSinceTarget.d.ts +1 -1
  52. package/dist/esm/getCommitsSinceTarget.js +54 -55
  53. package/dist/esm/hasPrettierConfig.js +33 -35
  54. package/dist/esm/help/prepareHelp.js +4 -8
  55. package/dist/esm/index.d.ts +4 -4
  56. package/dist/esm/index.js +2 -8
  57. package/dist/esm/init/checks.js +28 -32
  58. package/dist/esm/init/detectRepoType.js +12 -15
  59. package/dist/esm/init/initCommand.js +60 -54
  60. package/dist/esm/init/parseJsonRecord.js +9 -11
  61. package/dist/esm/init/scaffold.d.ts +1 -1
  62. package/dist/esm/init/scaffold.js +32 -38
  63. package/dist/esm/init/templates.d.ts +1 -1
  64. package/dist/esm/init/templates.js +16 -22
  65. package/dist/esm/injectReleaseNotesIntoReadme.js +42 -49
  66. package/dist/esm/injectSection.js +17 -27
  67. package/dist/esm/loadConfig.d.ts +1 -1
  68. package/dist/esm/loadConfig.js +206 -225
  69. package/dist/esm/parseCommitMessage.d.ts +1 -1
  70. package/dist/esm/parseCommitMessage.js +72 -76
  71. package/dist/esm/parseRequestedTags.js +6 -9
  72. package/dist/esm/prepareCommand.d.ts +1 -1
  73. package/dist/esm/prepareCommand.js +225 -235
  74. package/dist/esm/previewTagPrefixes.d.ts +1 -1
  75. package/dist/esm/previewTagPrefixes.js +101 -96
  76. package/dist/esm/propagateBumps.d.ts +2 -2
  77. package/dist/esm/propagateBumps.js +48 -50
  78. package/dist/esm/publish.d.ts +2 -2
  79. package/dist/esm/publish.js +22 -28
  80. package/dist/esm/publishCommand.js +75 -80
  81. package/dist/esm/pushCommand.js +33 -34
  82. package/dist/esm/pushRelease.d.ts +1 -1
  83. package/dist/esm/pushRelease.js +21 -24
  84. package/dist/esm/readCurrentVersion.js +13 -17
  85. package/dist/esm/releasePrepare.d.ts +1 -1
  86. package/dist/esm/releasePrepare.js +213 -231
  87. package/dist/esm/releasePrepareMono.d.ts +2 -2
  88. package/dist/esm/releasePrepareMono.js +434 -494
  89. package/dist/esm/releasePrepareProject.d.ts +2 -2
  90. package/dist/esm/releasePrepareProject.js +143 -153
  91. package/dist/esm/renderChangelogMarkdown.d.ts +1 -1
  92. package/dist/esm/renderChangelogMarkdown.js +20 -24
  93. package/dist/esm/renderReleaseNotes.d.ts +1 -1
  94. package/dist/esm/renderReleaseNotes.js +50 -55
  95. package/dist/esm/reportPrepare.d.ts +1 -1
  96. package/dist/esm/reportPrepare.js +230 -231
  97. package/dist/esm/resolveCliffConfigPath.js +18 -23
  98. package/dist/esm/resolveCommandTags.d.ts +1 -1
  99. package/dist/esm/resolveCommandTags.js +47 -45
  100. package/dist/esm/resolveReleaseNotesConfig.d.ts +1 -1
  101. package/dist/esm/resolveReleaseNotesConfig.js +39 -43
  102. package/dist/esm/resolveReleaseTags.d.ts +1 -1
  103. package/dist/esm/resolveReleaseTags.js +39 -40
  104. package/dist/esm/runGitCliff.js +27 -30
  105. package/dist/esm/showTagPrefixesCommand.js +48 -70
  106. package/dist/esm/stripEmojiPrefix.js +2 -5
  107. package/dist/esm/stripScope.js +18 -21
  108. package/dist/esm/sync-labels/generateCommand.d.ts +1 -1
  109. package/dist/esm/sync-labels/generateCommand.js +51 -53
  110. package/dist/esm/sync-labels/initCommand.js +46 -48
  111. package/dist/esm/sync-labels/loadSyncLabelsConfig.d.ts +1 -1
  112. package/dist/esm/sync-labels/loadSyncLabelsConfig.js +46 -52
  113. package/dist/esm/sync-labels/presets.d.ts +1 -1
  114. package/dist/esm/sync-labels/presets.js +40 -43
  115. package/dist/esm/sync-labels/resolveLabels.d.ts +1 -1
  116. package/dist/esm/sync-labels/resolveLabels.js +28 -35
  117. package/dist/esm/sync-labels/syncCommand.js +30 -31
  118. package/dist/esm/sync-labels/templates.d.ts +1 -1
  119. package/dist/esm/sync-labels/templates.js +23 -26
  120. package/dist/esm/sync-labels/types.js +1 -0
  121. package/dist/esm/syncWorkTypes.js +83 -84
  122. package/dist/esm/tagCommand.js +12 -14
  123. package/dist/esm/typeGuards.js +4 -8
  124. package/dist/esm/types.js +66 -60
  125. package/dist/esm/validateConfig.d.ts +1 -1
  126. package/dist/esm/validateConfig.js +109 -115
  127. package/dist/esm/validateOnlyExcludesStrandedDependents.d.ts +2 -2
  128. package/dist/esm/validateOnlyExcludesStrandedDependents.js +97 -91
  129. package/dist/esm/validateOverridesCommand.d.ts +2 -2
  130. package/dist/esm/validateOverridesCommand.js +110 -111
  131. package/dist/esm/workTypesData.js +57 -60
  132. package/dist/esm/workTypesUtils.js +16 -21
  133. package/dist/esm/writeReleaseNotesPreviews.js +55 -57
  134. package/package.json +2 -2
@@ -1,120 +1,125 @@
1
- import { execFileSync } from "node:child_process";
2
- import { basename } from "node:path";
1
+ import { execFileSync } from 'node:child_process';
2
+ import { basename } from 'node:path';
3
3
  import { deriveWorkspaceConfig } from "./deriveWorkspaceConfig.js";
4
4
  import { detectUndeclaredTagPrefixes } from "./detectUndeclaredTagPrefixes.js";
5
5
  import { discoverWorkspaces } from "./discoverWorkspaces.js";
6
6
  import { loadConfig } from "./loadConfig.js";
7
7
  import { validateConfig } from "./validateConfig.js";
8
- async function previewTagPrefixes() {
9
- const workspacePaths = await discoverWorkspaces() ?? [];
10
- const userConfig = await loadUserConfig();
11
- const overridesByDir = buildOverrideMap(userConfig);
12
- const workspaces = [];
13
- for (const workspacePath of workspacePaths) {
14
- workspaces.push(buildPreviewRow(workspacePath, overridesByDir));
15
- }
16
- const retiredPackages = buildRetiredPreviewEntries(userConfig?.retiredPackages ?? []);
17
- const collisions = detectCollisions(workspaces);
18
- const knownPrefixes = collectKnownPrefixes(workspaces, retiredPackages);
19
- const undeclaredCandidates = detectUndeclaredTagPrefixes(knownPrefixes);
20
- return { workspaces, collisions, undeclaredCandidates, retiredPackages };
8
+ export async function previewTagPrefixes() {
9
+ const workspacePaths = (await discoverWorkspaces()) ?? [];
10
+ const userConfig = await loadUserConfig();
11
+ const overridesByDir = buildOverrideMap(userConfig);
12
+ const workspaces = [];
13
+ for (const workspacePath of workspacePaths) {
14
+ workspaces.push(buildPreviewRow(workspacePath, overridesByDir));
15
+ }
16
+ const retiredPackages = buildRetiredPreviewEntries(userConfig?.retiredPackages ?? []);
17
+ const collisions = detectCollisions(workspaces);
18
+ const knownPrefixes = collectKnownPrefixes(workspaces, retiredPackages);
19
+ const undeclaredCandidates = detectUndeclaredTagPrefixes(knownPrefixes);
20
+ return { workspaces, collisions, undeclaredCandidates, retiredPackages };
21
21
  }
22
22
  async function loadUserConfig() {
23
- let raw;
24
- try {
25
- raw = await loadConfig();
26
- } catch {
27
- return void 0;
28
- }
29
- if (raw === void 0) return void 0;
30
- const { config, errors } = validateConfig(raw);
31
- return errors.length === 0 ? config : void 0;
23
+ let raw;
24
+ try {
25
+ raw = await loadConfig();
26
+ }
27
+ catch {
28
+ return undefined;
29
+ }
30
+ if (raw === undefined)
31
+ return undefined;
32
+ const { config, errors } = validateConfig(raw);
33
+ return errors.length === 0 ? config : undefined;
32
34
  }
33
35
  function buildOverrideMap(userConfig) {
34
- const map = /* @__PURE__ */ new Map();
35
- if (userConfig?.workspaces === void 0) return map;
36
- for (const entry of userConfig.workspaces) {
37
- if (entry.legacyIdentities !== void 0) {
38
- map.set(entry.dir, entry.legacyIdentities);
36
+ const map = new Map();
37
+ if (userConfig?.workspaces === undefined)
38
+ return map;
39
+ for (const entry of userConfig.workspaces) {
40
+ if (entry.legacyIdentities !== undefined) {
41
+ map.set(entry.dir, entry.legacyIdentities);
42
+ }
39
43
  }
40
- }
41
- return map;
44
+ return map;
42
45
  }
43
46
  function buildPreviewRow(workspacePath, overridesByDir) {
44
- const dir = basename(workspacePath);
45
- let derivedPrefix = null;
46
- let derivationError = null;
47
- try {
48
- derivedPrefix = deriveWorkspaceConfig(workspacePath).tagPrefix;
49
- } catch (error) {
50
- derivationError = error instanceof Error ? error.message : String(error);
51
- }
52
- const derivedTagCount = derivedPrefix === null ? 0 : countTagsMatching(derivedPrefix);
53
- const declaredIdentities = overridesByDir.get(dir) ?? [];
54
- const legacyEntries = declaredIdentities.map((identity) => ({
55
- prefix: identity.tagPrefix,
56
- tagCount: countTagsMatching(identity.tagPrefix)
57
- }));
58
- return {
59
- workspacePath,
60
- dir,
61
- derivedPrefix,
62
- derivationError,
63
- derivedTagCount,
64
- legacyEntries
65
- };
47
+ const dir = basename(workspacePath);
48
+ let derivedPrefix = null;
49
+ let derivationError = null;
50
+ try {
51
+ derivedPrefix = deriveWorkspaceConfig(workspacePath).tagPrefix;
52
+ }
53
+ catch (error) {
54
+ derivationError = error instanceof Error ? error.message : String(error);
55
+ }
56
+ const derivedTagCount = derivedPrefix === null ? 0 : countTagsMatching(derivedPrefix);
57
+ const declaredIdentities = overridesByDir.get(dir) ?? [];
58
+ const legacyEntries = declaredIdentities.map((identity) => ({
59
+ prefix: identity.tagPrefix,
60
+ tagCount: countTagsMatching(identity.tagPrefix),
61
+ }));
62
+ return {
63
+ workspacePath,
64
+ dir,
65
+ derivedPrefix,
66
+ derivationError,
67
+ derivedTagCount,
68
+ legacyEntries,
69
+ };
66
70
  }
67
71
  function countTagsMatching(prefix) {
68
- try {
69
- const output = execFileSync("git", ["tag", "--list", `${prefix}*`], {
70
- encoding: "utf8",
71
- stdio: ["pipe", "pipe", "pipe"]
72
- });
73
- return output.split("\n").filter((line) => line.trim() !== "").length;
74
- } catch {
75
- return 0;
76
- }
72
+ try {
73
+ const output = execFileSync('git', ['tag', '--list', `${prefix}*`], {
74
+ encoding: 'utf8',
75
+ stdio: ['pipe', 'pipe', 'pipe'],
76
+ });
77
+ return output.split('\n').filter((line) => line.trim() !== '').length;
78
+ }
79
+ catch {
80
+ return 0;
81
+ }
77
82
  }
78
83
  function detectCollisions(rows) {
79
- const pathsByPrefix = /* @__PURE__ */ new Map();
80
- for (const row of rows) {
81
- if (row.derivedPrefix === null) continue;
82
- const existing = pathsByPrefix.get(row.derivedPrefix);
83
- if (existing === void 0) {
84
- pathsByPrefix.set(row.derivedPrefix, [row.workspacePath]);
85
- } else {
86
- existing.push(row.workspacePath);
84
+ const pathsByPrefix = new Map();
85
+ for (const row of rows) {
86
+ if (row.derivedPrefix === null)
87
+ continue;
88
+ const existing = pathsByPrefix.get(row.derivedPrefix);
89
+ if (existing === undefined) {
90
+ pathsByPrefix.set(row.derivedPrefix, [row.workspacePath]);
91
+ }
92
+ else {
93
+ existing.push(row.workspacePath);
94
+ }
87
95
  }
88
- }
89
- const collisions = [];
90
- for (const [tagPrefix, workspacePaths] of pathsByPrefix) {
91
- if (workspacePaths.length > 1) {
92
- collisions.push({ tagPrefix, workspacePaths });
96
+ const collisions = [];
97
+ for (const [tagPrefix, workspacePaths] of pathsByPrefix) {
98
+ if (workspacePaths.length > 1) {
99
+ collisions.push({ tagPrefix, workspacePaths });
100
+ }
93
101
  }
94
- }
95
- return collisions;
102
+ return collisions;
96
103
  }
97
104
  function collectKnownPrefixes(rows, retiredPackages) {
98
- const known = /* @__PURE__ */ new Set();
99
- for (const row of rows) {
100
- if (row.derivedPrefix !== null) known.add(row.derivedPrefix);
101
- for (const entry of row.legacyEntries) {
102
- known.add(entry.prefix);
105
+ const known = new Set();
106
+ for (const row of rows) {
107
+ if (row.derivedPrefix !== null)
108
+ known.add(row.derivedPrefix);
109
+ for (const entry of row.legacyEntries) {
110
+ known.add(entry.prefix);
111
+ }
112
+ }
113
+ for (const retired of retiredPackages) {
114
+ known.add(retired.tagPrefix);
103
115
  }
104
- }
105
- for (const retired of retiredPackages) {
106
- known.add(retired.tagPrefix);
107
- }
108
- return [...known];
116
+ return [...known];
109
117
  }
110
118
  function buildRetiredPreviewEntries(retiredPackages) {
111
- return retiredPackages.map((retired) => ({
112
- name: retired.name,
113
- tagPrefix: retired.tagPrefix,
114
- tagCount: countTagsMatching(retired.tagPrefix),
115
- ...retired.successor !== void 0 ? { successor: retired.successor } : {}
116
- }));
119
+ return retiredPackages.map((retired) => ({
120
+ name: retired.name,
121
+ tagPrefix: retired.tagPrefix,
122
+ tagCount: countTagsMatching(retired.tagPrefix),
123
+ ...(retired.successor !== undefined ? { successor: retired.successor } : {}),
124
+ }));
117
125
  }
118
- export {
119
- previewTagPrefixes
120
- };
@@ -1,5 +1,5 @@
1
- import type { DependencyGraph } from './buildDependencyGraph.ts';
2
- import type { PropagationSource, ReleaseType } from './types.ts';
1
+ import type { DependencyGraph } from './buildDependencyGraph.js';
2
+ import type { PropagationSource, ReleaseType } from './types.js';
3
3
  export interface ReleaseEntry {
4
4
  releaseType: ReleaseType;
5
5
  propagatedFrom?: PropagationSource[];
@@ -1,54 +1,52 @@
1
1
  import { bumpVersion } from "./bumpVersion.js";
2
- function propagateBumps(directBumps, graph, currentVersions) {
3
- const result = /* @__PURE__ */ new Map();
4
- for (const [dir, entry] of directBumps) {
5
- result.set(dir, { ...entry });
6
- }
7
- const queue = [...directBumps.keys()];
8
- const visited = /* @__PURE__ */ new Set();
9
- while (queue.length > 0) {
10
- const dir = queue.shift();
11
- if (dir === void 0) {
12
- break;
2
+ export function propagateBumps(directBumps, graph, currentVersions) {
3
+ const result = new Map();
4
+ for (const [dir, entry] of directBumps) {
5
+ result.set(dir, { ...entry });
13
6
  }
14
- if (visited.has(dir)) {
15
- continue;
7
+ const queue = [...directBumps.keys()];
8
+ const visited = new Set();
9
+ while (queue.length > 0) {
10
+ const dir = queue.shift();
11
+ if (dir === undefined) {
12
+ break;
13
+ }
14
+ if (visited.has(dir)) {
15
+ continue;
16
+ }
17
+ visited.add(dir);
18
+ const packageName = graph.dirToPackageName.get(dir);
19
+ if (packageName === undefined) {
20
+ continue;
21
+ }
22
+ const currentVersion = currentVersions.get(dir);
23
+ const entry = result.get(dir);
24
+ if (currentVersion === undefined || entry === undefined) {
25
+ continue;
26
+ }
27
+ const newVersion = entry.newVersionOverride ?? bumpVersion(currentVersion, entry.releaseType);
28
+ const dependents = graph.dependentsOf.get(packageName);
29
+ if (dependents === undefined) {
30
+ continue;
31
+ }
32
+ for (const dependent of dependents) {
33
+ const dependentDir = dependent.dir;
34
+ const existing = result.get(dependentDir);
35
+ const propagationInfo = { packageName, newVersion };
36
+ if (existing === undefined) {
37
+ result.set(dependentDir, {
38
+ releaseType: 'patch',
39
+ propagatedFrom: [propagationInfo],
40
+ });
41
+ }
42
+ else {
43
+ const existingPropagated = existing.propagatedFrom ?? [];
44
+ existing.propagatedFrom = [...existingPropagated, propagationInfo];
45
+ }
46
+ if (!visited.has(dependentDir)) {
47
+ queue.push(dependentDir);
48
+ }
49
+ }
16
50
  }
17
- visited.add(dir);
18
- const packageName = graph.dirToPackageName.get(dir);
19
- if (packageName === void 0) {
20
- continue;
21
- }
22
- const currentVersion = currentVersions.get(dir);
23
- const entry = result.get(dir);
24
- if (currentVersion === void 0 || entry === void 0) {
25
- continue;
26
- }
27
- const newVersion = entry.newVersionOverride ?? bumpVersion(currentVersion, entry.releaseType);
28
- const dependents = graph.dependentsOf.get(packageName);
29
- if (dependents === void 0) {
30
- continue;
31
- }
32
- for (const dependent of dependents) {
33
- const dependentDir = dependent.dir;
34
- const existing = result.get(dependentDir);
35
- const propagationInfo = { packageName, newVersion };
36
- if (existing === void 0) {
37
- result.set(dependentDir, {
38
- releaseType: "patch",
39
- propagatedFrom: [propagationInfo]
40
- });
41
- } else {
42
- const existingPropagated = existing.propagatedFrom ?? [];
43
- existing.propagatedFrom = [...existingPropagated, propagationInfo];
44
- }
45
- if (!visited.has(dependentDir)) {
46
- queue.push(dependentDir);
47
- }
48
- }
49
- }
50
- return result;
51
+ return result;
51
52
  }
52
- export {
53
- propagateBumps
54
- };
@@ -1,5 +1,5 @@
1
- import type { PackageManager } from './detectPackageManager.ts';
2
- import type { ResolvedTag } from './resolveReleaseTags.ts';
1
+ import type { PackageManager } from './detectPackageManager.js';
2
+ import type { ResolvedTag } from './resolveReleaseTags.js';
3
3
  export interface PublishOptions {
4
4
  dryRun: boolean;
5
5
  provenance: boolean;
@@ -1,33 +1,27 @@
1
- import { execFileSync } from "node:child_process";
2
- function publishPackage(resolvedTag, packageManager, options) {
3
- const { dryRun, provenance } = options;
4
- const executable = resolveExecutable(packageManager);
5
- const args = buildPublishArgs(packageManager, { dryRun, provenance });
6
- console.info(
7
- `
8
- ${dryRun ? "[dry-run] " : ""}Running: ${executable} ${args.join(" ")} (cwd: ${resolvedTag.workspacePath})`
9
- );
10
- execFileSync(executable, args, { cwd: resolvedTag.workspacePath, stdio: "inherit" });
1
+ import { execFileSync } from 'node:child_process';
2
+ export function publishPackage(resolvedTag, packageManager, options) {
3
+ const { dryRun, provenance } = options;
4
+ const executable = resolveExecutable(packageManager);
5
+ const args = buildPublishArgs(packageManager, { dryRun, provenance });
6
+ console.info(`\n${dryRun ? '[dry-run] ' : ''}Running: ${executable} ${args.join(' ')} (cwd: ${resolvedTag.workspacePath})`);
7
+ execFileSync(executable, args, { cwd: resolvedTag.workspacePath, stdio: 'inherit' });
11
8
  }
12
9
  function resolveExecutable(packageManager) {
13
- if (packageManager === "yarn-berry") {
14
- return "yarn";
15
- }
16
- return packageManager;
10
+ if (packageManager === 'yarn-berry') {
11
+ return 'yarn';
12
+ }
13
+ return packageManager;
17
14
  }
18
15
  function buildPublishArgs(packageManager, options) {
19
- const args = packageManager === "yarn-berry" ? ["npm", "publish"] : ["publish"];
20
- if (options.dryRun) {
21
- args.push("--dry-run");
22
- }
23
- if (packageManager === "pnpm") {
24
- args.push("--no-git-checks");
25
- }
26
- if (options.provenance && packageManager !== "yarn") {
27
- args.push("--provenance");
28
- }
29
- return args;
16
+ const args = packageManager === 'yarn-berry' ? ['npm', 'publish'] : ['publish'];
17
+ if (options.dryRun) {
18
+ args.push('--dry-run');
19
+ }
20
+ if (packageManager === 'pnpm') {
21
+ args.push('--no-git-checks');
22
+ }
23
+ if (options.provenance && packageManager !== 'yarn') {
24
+ args.push('--provenance');
25
+ }
26
+ return args;
30
27
  }
31
- export {
32
- publishPackage
33
- };
@@ -1,6 +1,6 @@
1
- import { writeFileSync } from "node:fs";
2
- import { join } from "node:path";
3
- import { parseArgsOrExit, reportError } from "@williamthorsen/nmr-core";
1
+ import { writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { parseArgsOrExit, reportError } from '@williamthorsen/nmr-core';
4
4
  import { assertCleanWorkingTree } from "./assertCleanWorkingTree.js";
5
5
  import { detectPackageManager } from "./detectPackageManager.js";
6
6
  import { injectReleaseNotesIntoReadme, resolveReadmePath } from "./injectReleaseNotesIntoReadme.js";
@@ -9,89 +9,84 @@ import { publishPackage } from "./publish.js";
9
9
  import { resolveCommandTags } from "./resolveCommandTags.js";
10
10
  import { resolveReleaseNotesConfig } from "./resolveReleaseNotesConfig.js";
11
11
  const publishFlagSchema = {
12
- dryRun: { long: "--dry-run", type: "boolean" },
13
- noGitChecks: { long: "--no-git-checks", type: "boolean" },
14
- provenance: { long: "--provenance", type: "boolean" },
15
- tags: { long: "--tags", type: "string" }
12
+ dryRun: { long: '--dry-run', type: 'boolean' },
13
+ noGitChecks: { long: '--no-git-checks', type: 'boolean' },
14
+ provenance: { long: '--provenance', type: 'boolean' },
15
+ tags: { long: '--tags', type: 'string' },
16
16
  };
17
- async function publishCommand(argv) {
18
- const parsed = parseArgsOrExit(argv, publishFlagSchema);
19
- const { dryRun, noGitChecks, provenance } = parsed.flags;
20
- if (!dryRun && !noGitChecks) {
21
- try {
22
- assertCleanWorkingTree();
23
- } catch (error) {
24
- reportError(error instanceof Error ? error.message : String(error));
25
- process.exit(1);
26
- }
27
- }
28
- const requestedTags = parseRequestedTags(parsed.flags.tags);
29
- const resolvedTags = await resolveCommandTags(requestedTags);
30
- if (resolvedTags.length === 0) {
31
- return;
32
- }
33
- const publishableTags = filterPublishableTags(resolvedTags, requestedTags !== void 0);
34
- if (publishableTags.length === 0) {
35
- console.info("Nothing to publish.");
36
- return;
37
- }
38
- const packageManager = detectPackageManager();
39
- const { releaseNotes, changelogJsonOutputPath, sectionOrder } = await resolveReleaseNotesConfig();
40
- const shouldInject = releaseNotes.shouldInjectIntoReadme;
41
- console.info(dryRun ? "[dry-run] Would publish:" : "Publishing:");
42
- for (const { tag, workspacePath } of publishableTags) {
43
- console.info(` ${tag} (${workspacePath})`);
44
- }
45
- const published = [];
46
- try {
47
- for (const resolvedTag of publishableTags) {
48
- let readmePath;
49
- let originalReadme;
50
- if (shouldInject) {
51
- readmePath = resolveReadmePath(resolvedTag.workspacePath);
52
- if (readmePath !== void 0) {
53
- originalReadme = injectReleaseNotesIntoReadme(
54
- readmePath,
55
- join(resolvedTag.workspacePath, changelogJsonOutputPath),
56
- resolvedTag.tag,
57
- sectionOrder
58
- );
17
+ export async function publishCommand(argv) {
18
+ const parsed = parseArgsOrExit(argv, publishFlagSchema);
19
+ const { dryRun, noGitChecks, provenance } = parsed.flags;
20
+ if (!dryRun && !noGitChecks) {
21
+ try {
22
+ assertCleanWorkingTree();
23
+ }
24
+ catch (error) {
25
+ reportError(error instanceof Error ? error.message : String(error));
26
+ process.exit(1);
59
27
  }
60
- }
61
- try {
62
- publishPackage(resolvedTag, packageManager, { dryRun, provenance });
63
- published.push(resolvedTag.tag);
64
- } finally {
65
- if (readmePath !== void 0 && originalReadme !== void 0) {
66
- writeFileSync(readmePath, originalReadme, "utf8");
28
+ }
29
+ const requestedTags = parseRequestedTags(parsed.flags.tags);
30
+ const resolvedTags = await resolveCommandTags(requestedTags);
31
+ if (resolvedTags.length === 0) {
32
+ return;
33
+ }
34
+ const publishableTags = filterPublishableTags(resolvedTags, requestedTags !== undefined);
35
+ if (publishableTags.length === 0) {
36
+ console.info('Nothing to publish.');
37
+ return;
38
+ }
39
+ const packageManager = detectPackageManager();
40
+ const { releaseNotes, changelogJsonOutputPath, sectionOrder } = await resolveReleaseNotesConfig();
41
+ const shouldInject = releaseNotes.shouldInjectIntoReadme;
42
+ console.info(dryRun ? '[dry-run] Would publish:' : 'Publishing:');
43
+ for (const { tag, workspacePath } of publishableTags) {
44
+ console.info(` ${tag} (${workspacePath})`);
45
+ }
46
+ const published = [];
47
+ try {
48
+ for (const resolvedTag of publishableTags) {
49
+ let readmePath;
50
+ let originalReadme;
51
+ if (shouldInject) {
52
+ readmePath = resolveReadmePath(resolvedTag.workspacePath);
53
+ if (readmePath !== undefined) {
54
+ originalReadme = injectReleaseNotesIntoReadme(readmePath, join(resolvedTag.workspacePath, changelogJsonOutputPath), resolvedTag.tag, sectionOrder);
55
+ }
56
+ }
57
+ try {
58
+ publishPackage(resolvedTag, packageManager, { dryRun, provenance });
59
+ published.push(resolvedTag.tag);
60
+ }
61
+ finally {
62
+ if (readmePath !== undefined && originalReadme !== undefined) {
63
+ writeFileSync(readmePath, originalReadme, 'utf8');
64
+ }
65
+ }
67
66
  }
68
- }
69
67
  }
70
- } catch (error) {
71
- if (published.length > 0) {
72
- console.warn("Packages published before failure:");
73
- for (const t of published) {
74
- console.warn(` ${t}`);
75
- }
68
+ catch (error) {
69
+ if (published.length > 0) {
70
+ console.warn('Packages published before failure:');
71
+ for (const t of published) {
72
+ console.warn(` ${t}`);
73
+ }
74
+ }
75
+ reportError(error instanceof Error ? error.message : String(error));
76
+ process.exit(1);
76
77
  }
77
- reportError(error instanceof Error ? error.message : String(error));
78
- process.exit(1);
79
- }
80
78
  }
81
79
  function filterPublishableTags(resolvedTags, isExplicit) {
82
- const publishable = [];
83
- const unpublishable = [];
84
- for (const tag of resolvedTags) {
85
- (tag.isPublishable ? publishable : unpublishable).push(tag);
86
- }
87
- if (isExplicit && unpublishable.length > 0) {
88
- for (const { tag, workspacePath } of unpublishable) {
89
- reportError(`${tag} (${workspacePath}) cannot be published: package.json#private is true.`);
80
+ const publishable = [];
81
+ const unpublishable = [];
82
+ for (const tag of resolvedTags) {
83
+ (tag.isPublishable ? publishable : unpublishable).push(tag);
90
84
  }
91
- process.exit(1);
92
- }
93
- return publishable;
85
+ if (isExplicit && unpublishable.length > 0) {
86
+ for (const { tag, workspacePath } of unpublishable) {
87
+ reportError(`${tag} (${workspacePath}) cannot be published: package.json#private is true.`);
88
+ }
89
+ process.exit(1);
90
+ }
91
+ return publishable;
94
92
  }
95
- export {
96
- publishCommand
97
- };
@@ -1,41 +1,40 @@
1
- import { parseArgsOrExit, reportError } from "@williamthorsen/nmr-core";
1
+ import { parseArgsOrExit, reportError } from '@williamthorsen/nmr-core';
2
2
  import { parseRequestedTags } from "./parseRequestedTags.js";
3
3
  import { pushRelease } from "./pushRelease.js";
4
4
  import { resolveCommandTags } from "./resolveCommandTags.js";
5
5
  const pushFlagSchema = {
6
- dryRun: { long: "--dry-run", type: "boolean" },
7
- tags: { long: "--tags", type: "string" },
8
- tagsOnly: { long: "--tags-only", type: "boolean" }
6
+ dryRun: { long: '--dry-run', type: 'boolean' },
7
+ tags: { long: '--tags', type: 'string' },
8
+ tagsOnly: { long: '--tags-only', type: 'boolean' },
9
9
  };
10
- async function pushCommand(argv) {
11
- const parsed = parseArgsOrExit(argv, pushFlagSchema);
12
- const { dryRun, tagsOnly } = parsed.flags;
13
- const requestedTags = parseRequestedTags(parsed.flags.tags);
14
- const resolvedTags = await resolveCommandTags(requestedTags);
15
- if (resolvedTags.length === 0) {
16
- return;
17
- }
18
- const prefix = dryRun ? "[dry-run] Would push" : "Pushing";
19
- if (!tagsOnly) {
20
- console.info(`${prefix} branch and ${resolvedTags.length} tag(s):`);
21
- } else {
22
- console.info(`${prefix} ${resolvedTags.length} tag(s):`);
23
- }
24
- for (const { tag } of resolvedTags) {
25
- console.info(` ${tag}`);
26
- }
27
- try {
28
- const steps = pushRelease(resolvedTags, { dryRun, tagsOnly });
29
- if (dryRun) {
30
- for (const step of steps) {
31
- console.info(`[dry-run] ${step.command.join(" ")}`);
32
- }
10
+ export async function pushCommand(argv) {
11
+ const parsed = parseArgsOrExit(argv, pushFlagSchema);
12
+ const { dryRun, tagsOnly } = parsed.flags;
13
+ const requestedTags = parseRequestedTags(parsed.flags.tags);
14
+ const resolvedTags = await resolveCommandTags(requestedTags);
15
+ if (resolvedTags.length === 0) {
16
+ return;
17
+ }
18
+ const prefix = dryRun ? '[dry-run] Would push' : 'Pushing';
19
+ if (!tagsOnly) {
20
+ console.info(`${prefix} branch and ${resolvedTags.length} tag(s):`);
21
+ }
22
+ else {
23
+ console.info(`${prefix} ${resolvedTags.length} tag(s):`);
24
+ }
25
+ for (const { tag } of resolvedTags) {
26
+ console.info(` ${tag}`);
27
+ }
28
+ try {
29
+ const steps = pushRelease(resolvedTags, { dryRun, tagsOnly });
30
+ if (dryRun) {
31
+ for (const step of steps) {
32
+ console.info(`[dry-run] ${step.command.join(' ')}`);
33
+ }
34
+ }
35
+ }
36
+ catch (error) {
37
+ reportError(error instanceof Error ? error.message : String(error));
38
+ process.exit(1);
33
39
  }
34
- } catch (error) {
35
- reportError(error instanceof Error ? error.message : String(error));
36
- process.exit(1);
37
- }
38
40
  }
39
- export {
40
- pushCommand
41
- };
@@ -1,4 +1,4 @@
1
- import type { ResolvedTag } from './resolveReleaseTags.ts';
1
+ import type { ResolvedTag } from './resolveReleaseTags.js';
2
2
  export interface PushReleaseOptions {
3
3
  dryRun?: boolean;
4
4
  tagsOnly?: boolean;