@releasekit/release 0.3.0-next.4 → 0.3.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.
@@ -0,0 +1,438 @@
1
+ import {
2
+ info,
3
+ loadCIConfig,
4
+ loadConfig,
5
+ runRelease,
6
+ success,
7
+ warn
8
+ } from "./chunk-I5ABZWVU.js";
9
+
10
+ // src/preview-context.ts
11
+ import * as fs from "fs";
12
+ function resolvePreviewContext(opts) {
13
+ const token = process.env.GITHUB_TOKEN;
14
+ if (!token) {
15
+ throw new Error("GITHUB_TOKEN environment variable is required");
16
+ }
17
+ const prNumber = resolvePRNumber(opts.pr);
18
+ const { owner, repo } = resolveRepo(opts.repo);
19
+ return { prNumber, owner, repo, token };
20
+ }
21
+ function resolvePRNumber(cliValue) {
22
+ if (cliValue) {
23
+ const num = Number.parseInt(cliValue, 10);
24
+ if (Number.isNaN(num) || num <= 0) {
25
+ throw new Error(`Invalid PR number: ${cliValue}`);
26
+ }
27
+ return num;
28
+ }
29
+ const eventPath = process.env.GITHUB_EVENT_PATH;
30
+ if (eventPath && fs.existsSync(eventPath)) {
31
+ try {
32
+ const event = JSON.parse(fs.readFileSync(eventPath, "utf-8"));
33
+ if (event.pull_request?.number) {
34
+ return event.pull_request.number;
35
+ }
36
+ } catch {
37
+ }
38
+ }
39
+ throw new Error("Could not determine PR number. Use --pr <number> or run in a GitHub Actions pull_request workflow.");
40
+ }
41
+ function resolveRepo(cliValue) {
42
+ const repoStr = cliValue ?? process.env.GITHUB_REPOSITORY;
43
+ if (!repoStr) {
44
+ throw new Error("Could not determine repository. Use --repo <owner/repo> or run in a GitHub Actions workflow.");
45
+ }
46
+ const parts = repoStr.split("/");
47
+ if (parts.length !== 2 || !parts[0] || !parts[1]) {
48
+ throw new Error(`Invalid repository format: ${repoStr}. Expected "owner/repo".`);
49
+ }
50
+ return { owner: parts[0], repo: parts[1] };
51
+ }
52
+
53
+ // src/preview-detect.ts
54
+ import * as fs2 from "fs";
55
+ import * as path from "path";
56
+ function detectPrerelease(packagePaths, projectDir) {
57
+ const paths = packagePaths.length > 0 ? packagePaths.map((p) => path.join(projectDir, p, "package.json")) : [path.join(projectDir, "package.json")];
58
+ for (const pkgPath of paths) {
59
+ if (!fs2.existsSync(pkgPath)) continue;
60
+ try {
61
+ const pkg = JSON.parse(fs2.readFileSync(pkgPath, "utf-8"));
62
+ const result = parsePrerelease(pkg.version);
63
+ if (result.isPrerelease) return result;
64
+ } catch {
65
+ }
66
+ }
67
+ return { isPrerelease: false };
68
+ }
69
+ function parsePrerelease(version) {
70
+ if (!version) return { isPrerelease: false };
71
+ const match = version.match(/-([a-zA-Z0-9][a-zA-Z0-9-]*)(?:\.\d+)*(?:\+[^\s]+)?$/);
72
+ if (match) {
73
+ return { isPrerelease: true, identifier: match[1] };
74
+ }
75
+ return { isPrerelease: false };
76
+ }
77
+
78
+ // src/preview-format.ts
79
+ var MARKER = "<!-- releasekit-preview -->";
80
+ var FOOTER = "*Updated automatically by [ReleaseKit](https://github.com/goosewobbler/releasekit)*";
81
+ var TYPE_LABELS = {
82
+ added: "Added",
83
+ changed: "Changed",
84
+ fixed: "Fixed",
85
+ security: "Security",
86
+ docs: "Documentation",
87
+ chore: "Chores",
88
+ test: "Tests",
89
+ feat: "Features",
90
+ fix: "Bug Fixes",
91
+ perf: "Performance",
92
+ refactor: "Refactoring",
93
+ style: "Styles",
94
+ build: "Build",
95
+ ci: "CI",
96
+ revert: "Reverts"
97
+ };
98
+ function getNoChangesMessage(strategy) {
99
+ switch (strategy) {
100
+ case "manual":
101
+ return "> No releasable changes detected. Run the release workflow manually if a release is needed.";
102
+ case "direct":
103
+ return "> No releasable changes detected. Merging this PR will not trigger a release.";
104
+ case "standing-pr":
105
+ return "> No releasable changes detected. Merging this PR will not affect the release PR.";
106
+ case "scheduled":
107
+ return "> No releasable changes detected. These changes will not be included in the next scheduled release.";
108
+ default:
109
+ return "> No releasable changes detected.";
110
+ }
111
+ }
112
+ function getIntroMessage(strategy, standingPrNumber) {
113
+ switch (strategy) {
114
+ case "direct":
115
+ return "This PR will trigger the following release when merged:";
116
+ case "standing-pr":
117
+ return standingPrNumber ? `These changes will be added to the release PR (#${standingPrNumber}) when merged:` : "Merging this PR will create a new release PR with the following changes:";
118
+ case "scheduled":
119
+ return "These changes will be included in the next scheduled release:";
120
+ default:
121
+ return "If released, this PR would include:";
122
+ }
123
+ }
124
+ function getLabelBanner(labelContext) {
125
+ if (!labelContext) return [];
126
+ if (labelContext.trigger === "commit") {
127
+ if (labelContext.skip) {
128
+ return ["> [!WARNING]", "> This PR is marked to skip release.", ""];
129
+ }
130
+ if (labelContext.bumpLabel === "major") {
131
+ return ["> [!IMPORTANT]", "> This PR is labeled for a **major** release.", ""];
132
+ }
133
+ }
134
+ if (labelContext.trigger === "label") {
135
+ if (labelContext.noBumpLabel) {
136
+ const labels = labelContext.labels;
137
+ const labelExamples = labels ? `\`${labels.patch}\`, \`${labels.minor}\`, or \`${labels.major}\`` : "a release label (e.g., `release:patch`, `release:minor`, `release:major`)";
138
+ return ["> [!NOTE]", `> No release label detected. Add ${labelExamples} to trigger a release.`, ""];
139
+ }
140
+ if (labelContext.bumpLabel) {
141
+ return ["> [!NOTE]", `> This PR is labeled for a **${labelContext.bumpLabel}** release.`, ""];
142
+ }
143
+ }
144
+ return [];
145
+ }
146
+ function formatPreviewComment(result, options) {
147
+ const strategy = options?.strategy ?? "direct";
148
+ const labelContext = options?.labelContext;
149
+ const lines = [MARKER, ""];
150
+ const banner = getLabelBanner(labelContext);
151
+ if (!result) {
152
+ lines.push("<details>", "<summary><b>Release Preview</b> \u2014 no release</summary>", "");
153
+ lines.push(...banner);
154
+ if (!labelContext?.noBumpLabel) {
155
+ lines.push("> [!NOTE]", getNoChangesMessage(strategy));
156
+ }
157
+ lines.push("", "---", FOOTER, "</details>");
158
+ return lines.join("\n");
159
+ }
160
+ const { versionOutput } = result;
161
+ const pkgCount = versionOutput.updates.length;
162
+ const pkgSummary = pkgCount === 1 ? `${versionOutput.updates[0]?.packageName} ${versionOutput.updates[0]?.newVersion}` : `${pkgCount} packages`;
163
+ lines.push("<details>", `<summary><b>Release Preview</b> \u2014 ${pkgSummary}</summary>`, "");
164
+ lines.push(...banner);
165
+ lines.push(getIntroMessage(strategy, options?.standingPrNumber), "");
166
+ lines.push("### Packages", "");
167
+ lines.push("| Package | Version |", "|---------|---------|");
168
+ for (const update of versionOutput.updates) {
169
+ lines.push(`| \`${update.packageName}\` | ${update.newVersion} |`);
170
+ }
171
+ lines.push("");
172
+ const sharedEntries = versionOutput.sharedEntries?.length ? versionOutput.sharedEntries : void 0;
173
+ const hasPackageChangelogs = versionOutput.changelogs.some((cl) => cl.entries.length > 0);
174
+ if (sharedEntries || hasPackageChangelogs) {
175
+ lines.push("### Changelog", "");
176
+ if (sharedEntries) {
177
+ lines.push("<details>", "<summary><b>Project-wide changes</b></summary>", "");
178
+ lines.push(...renderEntries(sharedEntries));
179
+ lines.push("</details>", "");
180
+ }
181
+ for (const changelog of versionOutput.changelogs) {
182
+ if (changelog.entries.length > 0) {
183
+ lines.push(...formatPackageChangelog(changelog));
184
+ }
185
+ }
186
+ }
187
+ if (versionOutput.tags.length > 0) {
188
+ lines.push("### Tags", "");
189
+ for (const tag of versionOutput.tags) {
190
+ lines.push(`- \`${tag}\``);
191
+ }
192
+ lines.push("");
193
+ }
194
+ lines.push("---", FOOTER, "</details>");
195
+ return lines.join("\n");
196
+ }
197
+ function renderEntries(entries) {
198
+ const lines = [];
199
+ const grouped = /* @__PURE__ */ new Map();
200
+ for (const entry of entries) {
201
+ if (!grouped.has(entry.type)) grouped.set(entry.type, []);
202
+ grouped.get(entry.type)?.push(entry);
203
+ }
204
+ const renderedTypes = /* @__PURE__ */ new Set();
205
+ for (const type of Object.keys(TYPE_LABELS)) {
206
+ const group = grouped.get(type);
207
+ if (group && group.length > 0) {
208
+ lines.push(...formatEntryGroup(type, group));
209
+ renderedTypes.add(type);
210
+ }
211
+ }
212
+ for (const [type, group] of grouped) {
213
+ if (!renderedTypes.has(type) && group.length > 0) {
214
+ lines.push(...formatEntryGroup(type, group));
215
+ }
216
+ }
217
+ return lines;
218
+ }
219
+ function formatPackageChangelog(changelog) {
220
+ const lines = [];
221
+ const prevVersion = changelog.previousVersion ?? "N/A";
222
+ const summary = `<b>${changelog.packageName}</b> ${prevVersion} \u2192 ${changelog.version}`;
223
+ lines.push("<details>", `<summary>${summary}</summary>`, "");
224
+ lines.push(...renderEntries(changelog.entries));
225
+ lines.push("</details>", "");
226
+ return lines;
227
+ }
228
+ function formatEntryGroup(type, entries) {
229
+ const label = TYPE_LABELS[type] ?? capitalize(type);
230
+ const lines = [`#### ${label}`, ""];
231
+ for (const entry of entries) {
232
+ let line = `- ${entry.description}`;
233
+ if (entry.scope) {
234
+ line += ` (\`${entry.scope}\`)`;
235
+ }
236
+ if (entry.issueIds && entry.issueIds.length > 0) {
237
+ line += ` ${entry.issueIds.join(", ")}`;
238
+ }
239
+ lines.push(line);
240
+ }
241
+ lines.push("");
242
+ return lines;
243
+ }
244
+ function capitalize(str) {
245
+ return str.charAt(0).toUpperCase() + str.slice(1);
246
+ }
247
+
248
+ // src/preview-github.ts
249
+ import { Octokit } from "@octokit/rest";
250
+ function createOctokit(token) {
251
+ return new Octokit({ auth: token });
252
+ }
253
+ async function findPreviewComment(octokit, owner, repo, prNumber) {
254
+ const iterator = octokit.paginate.iterator(octokit.rest.issues.listComments, {
255
+ owner,
256
+ repo,
257
+ issue_number: prNumber,
258
+ per_page: 100
259
+ });
260
+ for await (const response of iterator) {
261
+ for (const comment of response.data) {
262
+ if (comment.body?.startsWith(MARKER)) {
263
+ return comment.id;
264
+ }
265
+ }
266
+ }
267
+ return null;
268
+ }
269
+ async function fetchPRLabels(octokit, owner, repo, prNumber) {
270
+ const { data } = await octokit.rest.issues.get({
271
+ owner,
272
+ repo,
273
+ issue_number: prNumber
274
+ });
275
+ return (data.labels ?? []).map((label) => typeof label === "string" ? label : label.name ?? "");
276
+ }
277
+ async function postOrUpdateComment(octokit, owner, repo, prNumber, body) {
278
+ const existingId = await findPreviewComment(octokit, owner, repo, prNumber);
279
+ if (existingId) {
280
+ await octokit.rest.issues.updateComment({
281
+ owner,
282
+ repo,
283
+ comment_id: existingId,
284
+ body
285
+ });
286
+ } else {
287
+ await octokit.rest.issues.createComment({
288
+ owner,
289
+ repo,
290
+ issue_number: prNumber,
291
+ body
292
+ });
293
+ }
294
+ }
295
+
296
+ // src/preview.ts
297
+ var DEFAULT_LABELS = {
298
+ stable: "release:stable",
299
+ prerelease: "release:prerelease",
300
+ skip: "release:skip",
301
+ major: "release:major",
302
+ minor: "release:minor",
303
+ patch: "release:patch"
304
+ };
305
+ async function runPreview(options) {
306
+ const ciConfig = loadCIConfig({ cwd: options.projectDir, configPath: options.config });
307
+ if (ciConfig?.prPreview === false) {
308
+ info("PR preview is disabled in config (ci.prPreview: false)");
309
+ return;
310
+ }
311
+ let context;
312
+ let octokit;
313
+ if (!options.dryRun) {
314
+ try {
315
+ context = resolvePreviewContext({ pr: options.pr, repo: options.repo });
316
+ octokit = createOctokit(context.token);
317
+ } catch (error) {
318
+ warn(`Cannot post PR comment: ${error instanceof Error ? error.message : String(error)}`);
319
+ }
320
+ }
321
+ const { options: effectiveOptions, labelContext } = await applyLabelOverrides(options, ciConfig, context, octokit);
322
+ const strategy = ciConfig?.releaseStrategy ?? "direct";
323
+ let result = null;
324
+ if (!labelContext.noBumpLabel) {
325
+ const releaseConfig = loadConfig({ cwd: effectiveOptions.projectDir, configPath: effectiveOptions.config });
326
+ const prereleaseFlag = resolvePrerelease(
327
+ effectiveOptions,
328
+ releaseConfig.version?.packages ?? [],
329
+ effectiveOptions.projectDir
330
+ );
331
+ info("Analyzing release...");
332
+ result = await runRelease({
333
+ config: effectiveOptions.config,
334
+ dryRun: true,
335
+ sync: false,
336
+ bump: effectiveOptions.bump,
337
+ prerelease: prereleaseFlag,
338
+ skipNotes: true,
339
+ skipPublish: true,
340
+ skipGit: true,
341
+ skipGithubRelease: true,
342
+ skipVerification: true,
343
+ json: false,
344
+ verbose: false,
345
+ quiet: true,
346
+ projectDir: effectiveOptions.projectDir
347
+ });
348
+ } else {
349
+ info("No release label detected \u2014 skipping version analysis");
350
+ }
351
+ const commentBody = formatPreviewComment(result, { strategy, labelContext });
352
+ if (!context || !octokit) {
353
+ console.log(commentBody);
354
+ return;
355
+ }
356
+ info(`Posting preview comment on PR #${context.prNumber}...`);
357
+ await postOrUpdateComment(octokit, context.owner, context.repo, context.prNumber, commentBody);
358
+ success(`Preview comment posted on PR #${context.prNumber}`);
359
+ }
360
+ function resolvePrerelease(options, packagePaths, projectDir) {
361
+ if (options.stable) {
362
+ return void 0;
363
+ }
364
+ if (options.prerelease !== void 0) {
365
+ return options.prerelease;
366
+ }
367
+ const detected = detectPrerelease(packagePaths, projectDir);
368
+ if (detected.isPrerelease) {
369
+ info(`Detected prerelease version (identifier: ${detected.identifier})`);
370
+ return detected.identifier;
371
+ }
372
+ return void 0;
373
+ }
374
+ async function applyLabelOverrides(options, ciConfig, context, existingOctokit) {
375
+ const trigger = ciConfig?.releaseTrigger ?? "label";
376
+ const labels = ciConfig?.labels ?? DEFAULT_LABELS;
377
+ const defaultLabelContext = { trigger, skip: false, noBumpLabel: false };
378
+ if (!context) {
379
+ return {
380
+ options,
381
+ labelContext: { ...defaultLabelContext, noBumpLabel: trigger === "label" && !options.bump, labels }
382
+ };
383
+ }
384
+ let prLabels;
385
+ const octokitToUse = existingOctokit ?? createOctokit(context.token);
386
+ try {
387
+ prLabels = await fetchPRLabels(octokitToUse, context.owner, context.repo, context.prNumber);
388
+ } catch {
389
+ warn("Could not fetch PR labels \u2014 skipping label-driven overrides");
390
+ return {
391
+ options,
392
+ labelContext: { ...defaultLabelContext, noBumpLabel: trigger === "label", labels }
393
+ };
394
+ }
395
+ const result = { ...options };
396
+ const labelContext = { trigger, skip: false, noBumpLabel: false, labels };
397
+ if (trigger === "commit") {
398
+ if (prLabels.includes(labels.skip)) {
399
+ info(`PR label "${labels.skip}" detected \u2014 release will be skipped`);
400
+ labelContext.skip = true;
401
+ }
402
+ if (!labelContext.skip && prLabels.includes(labels.major)) {
403
+ info(`PR label "${labels.major}" detected \u2014 forcing major release`);
404
+ labelContext.bumpLabel = "major";
405
+ result.bump = "major";
406
+ }
407
+ } else {
408
+ if (prLabels.includes(labels.major)) {
409
+ info(`PR label "${labels.major}" detected \u2014 major release`);
410
+ labelContext.bumpLabel = "major";
411
+ result.bump = "major";
412
+ } else if (prLabels.includes(labels.minor)) {
413
+ info(`PR label "${labels.minor}" detected \u2014 minor release`);
414
+ labelContext.bumpLabel = "minor";
415
+ result.bump = "minor";
416
+ } else if (prLabels.includes(labels.patch)) {
417
+ info(`PR label "${labels.patch}" detected \u2014 patch release`);
418
+ labelContext.bumpLabel = "patch";
419
+ result.bump = "patch";
420
+ } else {
421
+ labelContext.noBumpLabel = true;
422
+ }
423
+ }
424
+ if (!options.stable && options.prerelease === void 0) {
425
+ if (prLabels.includes(labels.stable)) {
426
+ info(`PR label "${labels.stable}" detected \u2014 using stable release preview`);
427
+ result.stable = true;
428
+ } else if (prLabels.includes(labels.prerelease)) {
429
+ info(`PR label "${labels.prerelease}" detected \u2014 using prerelease preview`);
430
+ result.prerelease = true;
431
+ }
432
+ }
433
+ return { options: result, labelContext: { ...labelContext, labels } };
434
+ }
435
+
436
+ export {
437
+ runPreview
438
+ };
package/dist/cli.d.ts CHANGED
@@ -1 +1,6 @@
1
1
  #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+
4
+ declare function createReleaseProgram(): Command;
5
+
6
+ export { createReleaseProgram };
package/dist/cli.js CHANGED
@@ -1,41 +1,59 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- runRelease
4
- } from "./chunk-ONEIHH2F.js";
3
+ createReleaseCommand
4
+ } from "./chunk-EDF3BZFF.js";
5
+ import {
6
+ runPreview
7
+ } from "./chunk-J5NT6OX2.js";
8
+ import {
9
+ EXIT_CODES,
10
+ readPackageVersion
11
+ } from "./chunk-I5ABZWVU.js";
5
12
 
6
13
  // src/cli.ts
7
- import { EXIT_CODES } from "@releasekit/core";
14
+ import { realpathSync } from "fs";
15
+ import { fileURLToPath } from "url";
16
+ import { Command as Command2 } from "commander";
17
+
18
+ // src/preview-command.ts
8
19
  import { Command } from "commander";
9
- var program = new Command();
10
- program.name("releasekit").description("Unified release pipeline: version, changelog, and publish").version("0.1.0").command("release", { isDefault: true }).description("Run the full release pipeline").option("-c, --config <path>", "Path to config file").option("-d, --dry-run", "Preview all steps without side effects", false).option("-b, --bump <type>", "Force bump type (patch|minor|major)").option("-p, --prerelease [identifier]", "Create prerelease version").option("-s, --sync", "Use synchronized versioning across all packages", false).option("-t, --target <packages>", "Target specific packages (comma-separated)").option("--skip-notes", "Skip changelog generation", false).option("--skip-publish", "Skip registry publishing and git operations", false).option("--skip-git", "Skip git commit/tag/push", false).option("--skip-github-release", "Skip GitHub release creation", false).option("--skip-verification", "Skip post-publish verification", false).option("-j, --json", "Output results as JSON", false).option("-v, --verbose", "Verbose logging", false).option("-q, --quiet", "Suppress non-error output", false).option("--project-dir <path>", "Project directory", process.cwd()).action(async (opts) => {
11
- const options = {
12
- config: opts.config,
13
- dryRun: opts.dryRun,
14
- bump: opts.bump,
15
- prerelease: opts.prerelease,
16
- sync: opts.sync,
17
- target: opts.target,
18
- skipNotes: opts.skipNotes,
19
- skipPublish: opts.skipPublish,
20
- skipGit: opts.skipGit,
21
- skipGithubRelease: opts.skipGithubRelease,
22
- skipVerification: opts.skipVerification,
23
- json: opts.json,
24
- verbose: opts.verbose,
25
- quiet: opts.quiet,
26
- projectDir: opts.projectDir
27
- };
28
- try {
29
- const result = await runRelease(options);
30
- if (options.json && result) {
31
- console.log(JSON.stringify(result, null, 2));
20
+ function createPreviewCommand() {
21
+ return new Command("preview").description("Post a release preview comment on the current pull request").option("-c, --config <path>", "Path to config file").option("--project-dir <path>", "Project directory", process.cwd()).option("--pr <number>", "PR number (auto-detected from GitHub Actions)").option("--repo <owner/repo>", "Repository (auto-detected from GITHUB_REPOSITORY)").option("-p, --prerelease [identifier]", "Force prerelease preview (auto-detected by default)").option("--stable", "Force stable release preview (graduation from prerelease)", false).option(
22
+ "-d, --dry-run",
23
+ "Print the comment to stdout without posting (GitHub context not available in dry-run mode)",
24
+ false
25
+ ).action(async (opts) => {
26
+ try {
27
+ await runPreview({
28
+ config: opts.config,
29
+ projectDir: opts.projectDir,
30
+ pr: opts.pr,
31
+ repo: opts.repo,
32
+ prerelease: opts.prerelease,
33
+ stable: opts.stable,
34
+ dryRun: opts.dryRun
35
+ });
36
+ } catch (error) {
37
+ console.error(error instanceof Error ? error.message : String(error));
38
+ process.exit(EXIT_CODES.GENERAL_ERROR);
32
39
  }
33
- if (!result) {
34
- process.exit(0);
35
- }
36
- } catch (error) {
37
- console.error(error instanceof Error ? error.message : String(error));
38
- process.exit(EXIT_CODES.GENERAL_ERROR);
40
+ });
41
+ }
42
+
43
+ // src/cli.ts
44
+ function createReleaseProgram() {
45
+ return new Command2().name("releasekit-release").description("Unified release pipeline: version, changelog, and publish").version(readPackageVersion(import.meta.url)).addCommand(createReleaseCommand(), { isDefault: true }).addCommand(createPreviewCommand());
46
+ }
47
+ var isMain = (() => {
48
+ try {
49
+ return process.argv[1] ? realpathSync(process.argv[1]) === fileURLToPath(import.meta.url) : false;
50
+ } catch {
51
+ return false;
39
52
  }
40
- });
41
- program.parse();
53
+ })();
54
+ if (isMain) {
55
+ createReleaseProgram().parse();
56
+ }
57
+ export {
58
+ createReleaseProgram
59
+ };
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+
4
+ declare function createDispatcherProgram(): Command;
5
+
6
+ export { createDispatcherProgram };
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ createReleaseCommand
4
+ } from "./chunk-EDF3BZFF.js";
5
+ import {
6
+ readPackageVersion
7
+ } from "./chunk-I5ABZWVU.js";
8
+
9
+ // src/dispatcher.ts
10
+ import { realpathSync } from "fs";
11
+ import { fileURLToPath } from "url";
12
+ import { createNotesCommand } from "@releasekit/notes/cli";
13
+ import { createPublishCommand } from "@releasekit/publish/cli";
14
+ import { createVersionCommand } from "@releasekit/version/cli";
15
+ import { Command } from "commander";
16
+ function createDispatcherProgram() {
17
+ const program = new Command().name("releasekit").description("Unified release pipeline: version, changelog, and publish").version(readPackageVersion(import.meta.url));
18
+ program.addCommand(createReleaseCommand(), { isDefault: true });
19
+ program.addCommand(createVersionCommand());
20
+ program.addCommand(createNotesCommand());
21
+ program.addCommand(createPublishCommand());
22
+ return program;
23
+ }
24
+ var isMain = (() => {
25
+ try {
26
+ return process.argv[1] ? realpathSync(process.argv[1]) === fileURLToPath(import.meta.url) : false;
27
+ } catch {
28
+ return false;
29
+ }
30
+ })();
31
+ if (isMain) {
32
+ createDispatcherProgram().parse();
33
+ }
34
+ export {
35
+ createDispatcherProgram
36
+ };
package/dist/index.d.ts CHANGED
@@ -1,29 +1,3 @@
1
- import { VersionOutput } from '@releasekit/core';
2
- import { PublishOutput } from '@releasekit/publish';
3
-
4
- interface ReleaseOptions {
5
- config?: string;
6
- dryRun: boolean;
7
- bump?: string;
8
- prerelease?: string | boolean;
9
- sync: boolean;
10
- target?: string;
11
- skipNotes: boolean;
12
- skipPublish: boolean;
13
- skipGit: boolean;
14
- skipGithubRelease: boolean;
15
- skipVerification: boolean;
16
- json: boolean;
17
- verbose: boolean;
18
- quiet: boolean;
19
- projectDir: string;
20
- }
21
- interface ReleaseOutput {
22
- versionOutput: VersionOutput;
23
- notesGenerated: boolean;
24
- publishOutput?: PublishOutput;
25
- }
26
-
27
- declare function runRelease(options: ReleaseOptions): Promise<ReleaseOutput | null>;
28
-
29
- export { type ReleaseOptions, type ReleaseOutput, runRelease };
1
+ export { PreviewOptions, runPreview } from './preview.ts';
2
+ export { runRelease } from './release.ts';
3
+ export { ReleaseOptions, ReleaseOutput } from './types.ts';
package/dist/index.js CHANGED
@@ -1,6 +1,10 @@
1
+ import {
2
+ runPreview
3
+ } from "./chunk-J5NT6OX2.js";
1
4
  import {
2
5
  runRelease
3
- } from "./chunk-ONEIHH2F.js";
6
+ } from "./chunk-I5ABZWVU.js";
4
7
  export {
8
+ runPreview,
5
9
  runRelease
6
10
  };