@qualcomm-ui/changesets-cli 1.2.1 → 2.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.
- package/dist/{cli.cjs → cli.js} +92 -120
- package/dist/cli.js.map +1 -0
- package/dist/create-github-releases.d.ts.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/lib/cli.js +6 -0
- package/package.json +2 -2
- package/dist/cli.cjs.map +0 -1
- package/lib/cli.cjs +0 -3
package/dist/{cli.cjs → cli.js}
RENAMED
|
@@ -1,50 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
//#endregion
|
|
23
|
-
let _commander_js_extra_typings = require("@commander-js/extra-typings");
|
|
24
|
-
let node_process = require("node:process");
|
|
25
|
-
let node_readline_promises = require("node:readline/promises");
|
|
26
|
-
let _actions_core = require("@actions/core");
|
|
27
|
-
_actions_core = __toESM(_actions_core, 1);
|
|
28
|
-
let _manypkg_get_packages = require("@manypkg/get-packages");
|
|
29
|
-
let node_fs_promises = require("node:fs/promises");
|
|
30
|
-
let node_path = require("node:path");
|
|
31
|
-
let dayjs = require("dayjs");
|
|
32
|
-
dayjs = __toESM(dayjs, 1);
|
|
33
|
-
let dayjs_plugin_advancedFormat_js = require("dayjs/plugin/advancedFormat.js");
|
|
34
|
-
dayjs_plugin_advancedFormat_js = __toESM(dayjs_plugin_advancedFormat_js, 1);
|
|
35
|
-
let node_child_process = require("node:child_process");
|
|
36
|
-
let _octokit_rest = require("@octokit/rest");
|
|
37
|
-
let chalk = require("chalk");
|
|
38
|
-
chalk = __toESM(chalk, 1);
|
|
39
|
-
let node_os = require("node:os");
|
|
40
|
-
let _changesets_read = require("@changesets/read");
|
|
41
|
-
_changesets_read = __toESM(_changesets_read, 1);
|
|
42
|
-
let _changesets_write = require("@changesets/write");
|
|
43
|
-
_changesets_write = __toESM(_changesets_write, 1);
|
|
44
|
-
let node_fs = require("node:fs");
|
|
45
|
-
let ts_morph = require("ts-morph");
|
|
1
|
+
import { program } from "@commander-js/extra-typings";
|
|
2
|
+
import { stdin, stdout } from "node:process";
|
|
3
|
+
import { createInterface } from "node:readline/promises";
|
|
4
|
+
import * as core from "@actions/core";
|
|
5
|
+
import { getPackages, getPackagesSync } from "@manypkg/get-packages";
|
|
6
|
+
import { readFile, readdir, writeFile } from "node:fs/promises";
|
|
7
|
+
import { extname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
8
|
+
import dayjs from "dayjs";
|
|
9
|
+
import advancedFormat from "dayjs/plugin/advancedFormat.js";
|
|
10
|
+
import { execFileSync, execSync } from "node:child_process";
|
|
11
|
+
import { Octokit } from "@octokit/rest";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import readChangeset from "@changesets/read";
|
|
14
|
+
import writeChangeset from "@changesets/write";
|
|
15
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
16
|
+
import { Node, Project, ts } from "ts-morph";
|
|
46
17
|
//#region src/publishable-packages.ts
|
|
47
|
-
var DEFAULT_CONFIG_LOCATION =
|
|
18
|
+
var DEFAULT_CONFIG_LOCATION = join(".changeset", "config.json");
|
|
48
19
|
/**
|
|
49
20
|
* Retrieves all packages in the monorepo that should be published.
|
|
50
21
|
* Filters out packages marked as private and ignored packages.
|
|
@@ -54,8 +25,8 @@ var DEFAULT_CONFIG_LOCATION = (0, node_path.join)(".changeset", "config.json");
|
|
|
54
25
|
* @returns Array of package objects that are eligible for publishing
|
|
55
26
|
*/
|
|
56
27
|
async function getPublishablePackages(configPath, cwd = process.cwd()) {
|
|
57
|
-
const { packages } = await
|
|
58
|
-
const changesetConfig = JSON.parse(await
|
|
28
|
+
const { packages } = await getPackages(cwd);
|
|
29
|
+
const changesetConfig = JSON.parse(await readFile(resolve(cwd, configPath ?? DEFAULT_CONFIG_LOCATION), "utf-8"));
|
|
59
30
|
const ignoredPackages = new Set(changesetConfig.ignored ?? []);
|
|
60
31
|
return packages.filter((pkg) => {
|
|
61
32
|
if (ignoredPackages.has(pkg.packageJson.name)) return false;
|
|
@@ -102,26 +73,26 @@ async function checkVersions(options) {
|
|
|
102
73
|
if (newer.length > 0) {
|
|
103
74
|
console.log("The following packages will be published:");
|
|
104
75
|
newer.forEach((r) => console.log(` ${r.name}: ${r.published} -> ${r.current}`));
|
|
105
|
-
|
|
76
|
+
core.setOutput("should-publish", true);
|
|
106
77
|
} else {
|
|
107
78
|
console.log("No packages need publishing.");
|
|
108
|
-
|
|
79
|
+
core.setOutput("should-publish", false);
|
|
109
80
|
}
|
|
110
81
|
}
|
|
111
82
|
//#endregion
|
|
112
83
|
//#region src/consolidate-changelogs.ts
|
|
113
|
-
dayjs.
|
|
84
|
+
dayjs.extend(advancedFormat);
|
|
114
85
|
var DATE_FORMAT = "MMM Do, YYYY";
|
|
115
86
|
function getChangedChangelogs() {
|
|
116
87
|
try {
|
|
117
|
-
return
|
|
88
|
+
return execSync("git diff --name-only HEAD", { encoding: "utf-8" }).trim().split("\n").filter(Boolean).filter((file) => file.endsWith("CHANGELOG.md"));
|
|
118
89
|
} catch {
|
|
119
90
|
console.error("Failed to get changed files from git diff");
|
|
120
91
|
process.exit(1);
|
|
121
92
|
}
|
|
122
93
|
}
|
|
123
94
|
async function consolidateChangelog(changelogPath) {
|
|
124
|
-
const lines = (await
|
|
95
|
+
const lines = (await readFile(changelogPath, "utf-8")).split("\n");
|
|
125
96
|
const firstReleaseIndex = lines.findIndex((line) => line.startsWith("## "));
|
|
126
97
|
if (firstReleaseIndex === -1) return;
|
|
127
98
|
const secondReleaseIndex = lines.findIndex((line, i) => i > firstReleaseIndex && line.startsWith("## "));
|
|
@@ -138,10 +109,10 @@ async function consolidateChangelog(changelogPath) {
|
|
|
138
109
|
const dateMatch = line.match(/\((\d{4}\/\d{2}\/\d{2})\)/);
|
|
139
110
|
if (dateMatch) {
|
|
140
111
|
versionLine = line.replace(` (${dateMatch[1]})`, "");
|
|
141
|
-
dateLine =
|
|
112
|
+
dateLine = dayjs(dateMatch[1]).format(DATE_FORMAT);
|
|
142
113
|
} else {
|
|
143
114
|
versionLine = line;
|
|
144
|
-
dateLine =
|
|
115
|
+
dateLine = dayjs().format(DATE_FORMAT);
|
|
145
116
|
}
|
|
146
117
|
continue;
|
|
147
118
|
}
|
|
@@ -165,7 +136,7 @@ async function consolidateChangelog(changelogPath) {
|
|
|
165
136
|
output.push(...items);
|
|
166
137
|
output.push("");
|
|
167
138
|
}
|
|
168
|
-
await
|
|
139
|
+
await writeFile(changelogPath, [
|
|
169
140
|
...before,
|
|
170
141
|
...output,
|
|
171
142
|
...after
|
|
@@ -193,7 +164,7 @@ async function consolidateChangelogs() {
|
|
|
193
164
|
* @returns Object containing version, date, and body of the latest entry, or null if parsing fails
|
|
194
165
|
*/
|
|
195
166
|
async function parseChangelog(path) {
|
|
196
|
-
const lines = (await
|
|
167
|
+
const lines = (await readFile(path, "utf-8")).split("\n");
|
|
197
168
|
const firstVersionIndex = lines.findIndex((l) => l.startsWith("## "));
|
|
198
169
|
if (firstVersionIndex === -1) {
|
|
199
170
|
console.log(` No version header found`);
|
|
@@ -214,23 +185,23 @@ async function parseChangelog(path) {
|
|
|
214
185
|
};
|
|
215
186
|
}
|
|
216
187
|
function getRepoFromGitRemote() {
|
|
217
|
-
const remoteUrl =
|
|
188
|
+
const remoteUrl = execSync("git remote get-url origin").toString().trim();
|
|
218
189
|
const match = remoteUrl.match(/github\.com[/:]([\w.-]+)\/([\w.-]+?)(?:\.git)?$/);
|
|
219
|
-
if (!match) throw new Error(`Could not parse GitHub owner/repo from remote URL: ${remoteUrl}
|
|
190
|
+
if (!match) throw new Error(`Could not parse GitHub owner/repo from remote URL: ${remoteUrl}, use --repo to specify explicitly.`);
|
|
220
191
|
return {
|
|
221
192
|
owner: match[1],
|
|
222
193
|
repo: match[2]
|
|
223
194
|
};
|
|
224
195
|
}
|
|
225
196
|
async function createGitHubReleases(options) {
|
|
226
|
-
const octokit = new
|
|
197
|
+
const octokit = new Octokit({ auth: options.token });
|
|
227
198
|
const repoOpts = options.repo ? {
|
|
228
199
|
owner: options.repo.split("/")[0],
|
|
229
200
|
repo: options.repo.split("/")[1]
|
|
230
201
|
} : getRepoFromGitRemote();
|
|
231
202
|
const packages = await getPublishablePackages(options.configPath);
|
|
232
203
|
for (const pkg of packages) {
|
|
233
|
-
const changelog = await parseChangelog(
|
|
204
|
+
const changelog = await parseChangelog(join(pkg.dir, "CHANGELOG.md")).catch(() => null);
|
|
234
205
|
if (!changelog) {
|
|
235
206
|
console.warn("no changelog found, skipping package:", pkg.packageJson.name);
|
|
236
207
|
continue;
|
|
@@ -245,10 +216,10 @@ async function createGitHubReleases(options) {
|
|
|
245
216
|
tag
|
|
246
217
|
}).catch(() => null);
|
|
247
218
|
if (release) {
|
|
248
|
-
console.log(`Release ${
|
|
219
|
+
console.log(`Release \x1b[93m${release.data.name}\x1b[0m already exists, skipping`);
|
|
249
220
|
continue;
|
|
250
221
|
}
|
|
251
|
-
console.log(`Creating release: ${
|
|
222
|
+
console.log(`Creating release: \x1b[96m${tag}\x1b[0m`);
|
|
252
223
|
await octokit.repos.createRelease({
|
|
253
224
|
...repoOpts,
|
|
254
225
|
body: changelog.body,
|
|
@@ -286,7 +257,7 @@ function isDepsOnlyEntry(sections) {
|
|
|
286
257
|
return hasOnlyChoresHeader && allDepsBullets && bulletLines.length > 0;
|
|
287
258
|
}
|
|
288
259
|
function getReleaseNotesPath() {
|
|
289
|
-
return
|
|
260
|
+
return join(tmpdir(), RELEASE_NOTES_FILENAME);
|
|
290
261
|
}
|
|
291
262
|
async function generateReleaseNotes() {
|
|
292
263
|
const changedChangelogs = getChangedChangelogs();
|
|
@@ -296,7 +267,7 @@ async function generateReleaseNotes() {
|
|
|
296
267
|
}
|
|
297
268
|
const entries = [];
|
|
298
269
|
for (const changelogPath of changedChangelogs) {
|
|
299
|
-
const entry = extractLatestEntry(await
|
|
270
|
+
const entry = extractLatestEntry(await readFile(changelogPath, "utf-8"), changelogPath);
|
|
300
271
|
if (entry) entries.push(entry);
|
|
301
272
|
}
|
|
302
273
|
if (entries.length === 0) {
|
|
@@ -314,7 +285,7 @@ async function generateReleaseNotes() {
|
|
|
314
285
|
}
|
|
315
286
|
const markdown = lines.join("\n");
|
|
316
287
|
const outPath = getReleaseNotesPath();
|
|
317
|
-
await
|
|
288
|
+
await writeFile(outPath, markdown);
|
|
318
289
|
console.log(`Release notes written to ${outPath}`);
|
|
319
290
|
console.log(` ${substantive.length} package(s) with changes, ${depsOnly.length} dependency-only update(s)`);
|
|
320
291
|
return outPath;
|
|
@@ -421,14 +392,14 @@ function translateCommitsToConventionalCommitMessages(commits) {
|
|
|
421
392
|
* @returns Array of file paths that changed
|
|
422
393
|
*/
|
|
423
394
|
function getFilesChangedSince(opts) {
|
|
424
|
-
return
|
|
395
|
+
return execSync(`git diff --name-only ${opts.from}~1...${opts.to}`).toString().trim().split("\n");
|
|
425
396
|
}
|
|
426
397
|
/**
|
|
427
398
|
* Gets the absolute path to the git repository root
|
|
428
399
|
* @returns Absolute path to repository root
|
|
429
400
|
*/
|
|
430
401
|
function getRepoRoot() {
|
|
431
|
-
return
|
|
402
|
+
return execSync("git rev-parse --show-toplevel").toString().trim().replace(/\n|\r/g, "");
|
|
432
403
|
}
|
|
433
404
|
/**
|
|
434
405
|
* Gets the full commit message for a given commit hash
|
|
@@ -436,7 +407,7 @@ function getRepoRoot() {
|
|
|
436
407
|
* @returns The full commit message
|
|
437
408
|
*/
|
|
438
409
|
function getCommitMessage(commitHash) {
|
|
439
|
-
return
|
|
410
|
+
return execSync(`git log -1 --pretty=%B ${commitHash}`).toString().trim();
|
|
440
411
|
}
|
|
441
412
|
/**
|
|
442
413
|
* Extracts all conventional commit messages from a multi-line commit message
|
|
@@ -496,7 +467,7 @@ function conventionalMessagesWithCommitsToChangesets(conventionalMessagesToCommi
|
|
|
496
467
|
* @param branch - The branch name to fetch
|
|
497
468
|
*/
|
|
498
469
|
function gitFetch(branch) {
|
|
499
|
-
|
|
470
|
+
execSync(`git fetch origin ${branch}`);
|
|
500
471
|
}
|
|
501
472
|
/**
|
|
502
473
|
* Gets all commit hashes since a specific commit
|
|
@@ -504,7 +475,7 @@ function gitFetch(branch) {
|
|
|
504
475
|
* @returns Array of commit hashes since the given commit
|
|
505
476
|
*/
|
|
506
477
|
function getCommitsSinceCommit(sha) {
|
|
507
|
-
return
|
|
478
|
+
return execSync(`git rev-list ${sha}..HEAD`).toString().split("\n").filter(Boolean).reverse();
|
|
508
479
|
}
|
|
509
480
|
/**
|
|
510
481
|
* Gets all commit hashes since a reference branch or tag
|
|
@@ -513,7 +484,7 @@ function getCommitsSinceCommit(sha) {
|
|
|
513
484
|
*/
|
|
514
485
|
function getCommitsSinceBranch(branch) {
|
|
515
486
|
gitFetch(branch);
|
|
516
|
-
return
|
|
487
|
+
return execSync(`git rev-list ${`origin/${branch}`}..HEAD`).toString().split("\n").filter(Boolean).reverse();
|
|
517
488
|
}
|
|
518
489
|
/**
|
|
519
490
|
* Compares two changesets for equality
|
|
@@ -535,20 +506,20 @@ function difference(a, b) {
|
|
|
535
506
|
}
|
|
536
507
|
//#endregion
|
|
537
508
|
//#region src/main.ts
|
|
538
|
-
var CHANGESET_CONFIG_LOCATION$1 =
|
|
509
|
+
var CHANGESET_CONFIG_LOCATION$1 = join(".changeset", "config.json");
|
|
539
510
|
function getCommitsWithMessages(commitHashes) {
|
|
540
511
|
return commitHashes.map((commitHash) => {
|
|
541
512
|
return {
|
|
542
513
|
commitHash,
|
|
543
|
-
commitMessage:
|
|
514
|
+
commitMessage: execSync(`git log -n 1 --pretty=format:%B ${commitHash}`).toString()
|
|
544
515
|
};
|
|
545
516
|
});
|
|
546
517
|
}
|
|
547
518
|
async function conventionalCommitChangeset(options, cwd = process.cwd()) {
|
|
548
519
|
const configLocation = options.configPath ?? CHANGESET_CONFIG_LOCATION$1;
|
|
549
|
-
const changesetConfig = JSON.parse(
|
|
520
|
+
const changesetConfig = JSON.parse(readFileSync(join(cwd, configLocation)).toString());
|
|
550
521
|
const ignored = changesetConfig.ignore ?? [];
|
|
551
|
-
const packages =
|
|
522
|
+
const packages = getPackagesSync(cwd).packages.filter((pkg) => Boolean(pkg.packageJson.version) && !ignored.includes(pkg.packageJson.name));
|
|
552
523
|
const { baseBranch = "main" } = changesetConfig;
|
|
553
524
|
const { commitSha, includeCommitLinks } = options;
|
|
554
525
|
const changesets = conventionalMessagesWithCommitsToChangesets(translateCommitsToConventionalCommitMessages(getCommitsWithMessages(commitSha ? getCommitsSinceCommit(commitSha) : getCommitsSinceBranch(baseBranch))), {
|
|
@@ -556,9 +527,9 @@ async function conventionalCommitChangeset(options, cwd = process.cwd()) {
|
|
|
556
527
|
includeCommitLinks,
|
|
557
528
|
packages
|
|
558
529
|
});
|
|
559
|
-
const currentChangesets = await (
|
|
530
|
+
const currentChangesets = await readChangeset(cwd);
|
|
560
531
|
const newChangesets = currentChangesets.length === 0 ? changesets : difference(changesets, currentChangesets);
|
|
561
|
-
await Promise.all(newChangesets.map((changeset) => (
|
|
532
|
+
await Promise.all(newChangesets.map((changeset) => writeChangeset(changeset, cwd)));
|
|
562
533
|
}
|
|
563
534
|
//#endregion
|
|
564
535
|
//#region src/update-jsdoc-since-tags.ts
|
|
@@ -594,13 +565,13 @@ function formatJsDocSincePackageUpdateProgress({ name, version }) {
|
|
|
594
565
|
return `Processing package ${name} ${version}...`;
|
|
595
566
|
}
|
|
596
567
|
function normalizeRelativePath(cwd, filePath) {
|
|
597
|
-
return
|
|
568
|
+
return relative(cwd, filePath).split(sep).join("/");
|
|
598
569
|
}
|
|
599
570
|
function hasNextReleaseSinceTag(content) {
|
|
600
|
-
const scanner =
|
|
571
|
+
const scanner = ts.createScanner(ts.ScriptTarget.Latest, false, ts.LanguageVariant.Standard, content);
|
|
601
572
|
let token = scanner.scan();
|
|
602
|
-
while (token !==
|
|
603
|
-
if (token ===
|
|
573
|
+
while (token !== ts.SyntaxKind.EndOfFileToken) {
|
|
574
|
+
if (token === ts.SyntaxKind.MultiLineCommentTrivia) {
|
|
604
575
|
const text = scanner.getTokenText();
|
|
605
576
|
if (text.startsWith("/**") && NEXT_RELEASE_TAG_PATTERN.test(text)) return true;
|
|
606
577
|
}
|
|
@@ -609,8 +580,8 @@ function hasNextReleaseSinceTag(content) {
|
|
|
609
580
|
return false;
|
|
610
581
|
}
|
|
611
582
|
function getNodeName(node) {
|
|
612
|
-
if (
|
|
613
|
-
if (
|
|
583
|
+
if (Node.isClassDeclaration(node) || Node.isEnumDeclaration(node) || Node.isFunctionDeclaration(node) || Node.isInterfaceDeclaration(node) || Node.isMethodDeclaration(node) || Node.isMethodSignature(node) || Node.isPropertyDeclaration(node) || Node.isPropertySignature(node) || Node.isTypeAliasDeclaration(node)) return node.getName();
|
|
584
|
+
if (Node.isVariableStatement(node)) return node.getDeclarationList().getDeclarations().map((declaration) => declaration.getName()).join(", ");
|
|
614
585
|
}
|
|
615
586
|
function getQualifiedEntityName(node) {
|
|
616
587
|
const name = getNodeName(node);
|
|
@@ -631,13 +602,13 @@ function getVersionedPackages(packages) {
|
|
|
631
602
|
});
|
|
632
603
|
}
|
|
633
604
|
function isSourceFile(filePath) {
|
|
634
|
-
return SOURCE_EXTENSIONS.has(
|
|
605
|
+
return SOURCE_EXTENSIONS.has(extname(filePath)) && !TEST_FILE_PATTERN.test(filePath);
|
|
635
606
|
}
|
|
636
607
|
async function getSourceFiles(dir) {
|
|
637
|
-
const entries = (await
|
|
608
|
+
const entries = (await readdir(dir, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name));
|
|
638
609
|
const files = [];
|
|
639
610
|
for (const entry of entries) {
|
|
640
|
-
const entryPath =
|
|
611
|
+
const entryPath = join(dir, entry.name);
|
|
641
612
|
if (entry.isDirectory()) {
|
|
642
613
|
if (!EXCLUDED_DIRECTORIES.has(entry.name)) files.push(...await getSourceFiles(entryPath));
|
|
643
614
|
continue;
|
|
@@ -647,7 +618,7 @@ async function getSourceFiles(dir) {
|
|
|
647
618
|
return files;
|
|
648
619
|
}
|
|
649
620
|
async function updateSourceFile(filePath, version) {
|
|
650
|
-
const sourceFile = new
|
|
621
|
+
const sourceFile = new Project({
|
|
651
622
|
compilerOptions: {
|
|
652
623
|
allowJs: true,
|
|
653
624
|
checkJs: false
|
|
@@ -660,7 +631,7 @@ async function updateSourceFile(filePath, version) {
|
|
|
660
631
|
}).addSourceFileAtPath(filePath);
|
|
661
632
|
let tagCount = 0;
|
|
662
633
|
sourceFile.forEachDescendant((node) => {
|
|
663
|
-
if (!
|
|
634
|
+
if (!Node.isJSDocable(node)) return;
|
|
664
635
|
for (const jsDoc of node.getJsDocs()) for (const tag of jsDoc.getTags()) if (tag.getTagName() === "since" && tag.getCommentText()?.trim() === NEXT_RELEASE) {
|
|
665
636
|
tag.set({
|
|
666
637
|
tagName: "since",
|
|
@@ -674,14 +645,14 @@ async function updateSourceFile(filePath, version) {
|
|
|
674
645
|
}
|
|
675
646
|
async function findUnresolvedFiles(cwd, sourceFiles) {
|
|
676
647
|
const unresolvedFiles = [];
|
|
677
|
-
for (const filePath of sourceFiles) if (hasNextReleaseSinceTag(await
|
|
648
|
+
for (const filePath of sourceFiles) if (hasNextReleaseSinceTag(await readFile(filePath, "utf-8"))) unresolvedFiles.push(normalizeRelativePath(cwd, filePath));
|
|
678
649
|
return unresolvedFiles;
|
|
679
650
|
}
|
|
680
651
|
function collectSourceFileSinceTagLocations(cwd, sourceFile) {
|
|
681
652
|
const filePath = normalizeRelativePath(cwd, sourceFile.getFilePath());
|
|
682
653
|
const locations = [];
|
|
683
654
|
sourceFile.forEachDescendant((node) => {
|
|
684
|
-
if (!
|
|
655
|
+
if (!Node.isJSDocable(node)) return;
|
|
685
656
|
for (const jsDoc of node.getJsDocs()) for (const tag of jsDoc.getTags()) if (tag.getTagName() === "since" && tag.getCommentText()?.trim() === NEXT_RELEASE) locations.push({
|
|
686
657
|
entityName: getQualifiedEntityName(node),
|
|
687
658
|
filePath
|
|
@@ -690,7 +661,7 @@ function collectSourceFileSinceTagLocations(cwd, sourceFile) {
|
|
|
690
661
|
return locations;
|
|
691
662
|
}
|
|
692
663
|
function createProject() {
|
|
693
|
-
return new
|
|
664
|
+
return new Project({
|
|
694
665
|
compilerOptions: {
|
|
695
666
|
allowJs: true,
|
|
696
667
|
checkJs: false
|
|
@@ -765,19 +736,19 @@ function formatJsDocSinceCheckResult(result) {
|
|
|
765
736
|
}
|
|
766
737
|
//#endregion
|
|
767
738
|
//#region src/version-bump.ts
|
|
768
|
-
var CHANGESET_CONFIG_LOCATION =
|
|
739
|
+
var CHANGESET_CONFIG_LOCATION = join(".changeset", "config.json");
|
|
769
740
|
function normalizePath(path) {
|
|
770
|
-
return
|
|
741
|
+
return resolve(path);
|
|
771
742
|
}
|
|
772
743
|
function isWithinDirectory(parent, child) {
|
|
773
|
-
const relativePath =
|
|
774
|
-
return relativePath === "" || !relativePath.startsWith("..") && !
|
|
744
|
+
const relativePath = relative(parent, child);
|
|
745
|
+
return relativePath === "" || !relativePath.startsWith("..") && !isAbsolute(relativePath);
|
|
775
746
|
}
|
|
776
747
|
function getPackageLabel(directory) {
|
|
777
748
|
return directory.replaceAll("\\", "/");
|
|
778
749
|
}
|
|
779
750
|
function getSelectedDirectory(cwd, directory) {
|
|
780
|
-
return
|
|
751
|
+
return resolve(cwd, directory);
|
|
781
752
|
}
|
|
782
753
|
function getSelectedDirectories({ cwd, directories, directory }) {
|
|
783
754
|
return (directories && directories.length > 0 ? directories : directory ? [directory] : []).map((selectedDirectory) => ({
|
|
@@ -788,7 +759,7 @@ function getSelectedDirectories({ cwd, directories, directory }) {
|
|
|
788
759
|
function getPackageSourceSnapshot(pkg, versionOverride) {
|
|
789
760
|
return {
|
|
790
761
|
...pkg,
|
|
791
|
-
root:
|
|
762
|
+
root: resolve(pkg.root, "src"),
|
|
792
763
|
version: versionOverride ?? pkg.version
|
|
793
764
|
};
|
|
794
765
|
}
|
|
@@ -796,15 +767,15 @@ function getPackageSourceSnapshots(packages, versionOverride) {
|
|
|
796
767
|
return packages.map((pkg) => getPackageSourceSnapshot(pkg, versionOverride));
|
|
797
768
|
}
|
|
798
769
|
function normalizeGitPath(path) {
|
|
799
|
-
return path.split(
|
|
770
|
+
return path.split(sep).join("/");
|
|
800
771
|
}
|
|
801
772
|
function getBaseBranch({ configPath = CHANGESET_CONFIG_LOCATION, cwd }) {
|
|
802
|
-
return JSON.parse(
|
|
773
|
+
return JSON.parse(readFileSync(join(cwd, configPath), "utf-8")).baseBranch ?? "main";
|
|
803
774
|
}
|
|
804
775
|
function getPackageVersionAtRef(pkg, diffRef, cwd) {
|
|
805
|
-
const packageJsonPath = normalizeGitPath(
|
|
776
|
+
const packageJsonPath = normalizeGitPath(relative(cwd, join(pkg.root, "package.json")));
|
|
806
777
|
try {
|
|
807
|
-
const packageJson =
|
|
778
|
+
const packageJson = execFileSync("git", ["show", `${diffRef}:${packageJsonPath}`], {
|
|
808
779
|
cwd,
|
|
809
780
|
encoding: "utf-8"
|
|
810
781
|
});
|
|
@@ -815,7 +786,7 @@ function getPackageVersionAtRef(pkg, diffRef, cwd) {
|
|
|
815
786
|
}
|
|
816
787
|
function isGitRefResolvable(diffRef, cwd) {
|
|
817
788
|
try {
|
|
818
|
-
|
|
789
|
+
execFileSync("git", [
|
|
819
790
|
"rev-parse",
|
|
820
791
|
"--verify",
|
|
821
792
|
`${diffRef}^{commit}`
|
|
@@ -883,10 +854,10 @@ function selectCheckPackageSnapshots({ cwd = process.cwd(), directories, directo
|
|
|
883
854
|
return selectCustomCheckSnapshots(selectedDirectories, packages);
|
|
884
855
|
}
|
|
885
856
|
function getPackageSnapshots(cwd = process.cwd()) {
|
|
886
|
-
return
|
|
857
|
+
return getPackagesSync(cwd).packages.flatMap((pkg) => {
|
|
887
858
|
const { name, version } = pkg.packageJson;
|
|
888
859
|
if (!name) return [];
|
|
889
|
-
if (!
|
|
860
|
+
if (!existsSync(join(pkg.dir, "src"))) return [];
|
|
890
861
|
return [{
|
|
891
862
|
name,
|
|
892
863
|
root: pkg.dir,
|
|
@@ -913,7 +884,7 @@ function getUpdatePackageSnapshots({ configPath, cwd = process.cwd(), diffRef, d
|
|
|
913
884
|
version
|
|
914
885
|
});
|
|
915
886
|
}
|
|
916
|
-
function bumpVersionsAndMaybeUpdateJsDocSinceTags({ exec = (command) =>
|
|
887
|
+
function bumpVersionsAndMaybeUpdateJsDocSinceTags({ exec = (command) => execSync(command, { stdio: "inherit" }), packageManager = "pnpm" } = {}) {
|
|
917
888
|
exec(`${packageManager} changeset version`);
|
|
918
889
|
}
|
|
919
890
|
//#endregion
|
|
@@ -950,9 +921,9 @@ function buildSteps(options) {
|
|
|
950
921
|
];
|
|
951
922
|
}
|
|
952
923
|
async function waitForConfirmation(stepName) {
|
|
953
|
-
const rl =
|
|
954
|
-
input:
|
|
955
|
-
output:
|
|
924
|
+
const rl = createInterface({
|
|
925
|
+
input: stdin,
|
|
926
|
+
output: stdout
|
|
956
927
|
});
|
|
957
928
|
try {
|
|
958
929
|
return (await rl.question(`\nStep "${stepName}" completed. Continue to next step? [Y/n] `)).trim().toLowerCase() !== "n";
|
|
@@ -982,22 +953,22 @@ async function run(options) {
|
|
|
982
953
|
}
|
|
983
954
|
console.log("\nAll prep-release steps completed.");
|
|
984
955
|
}
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
956
|
+
program.allowUnknownOption(false);
|
|
957
|
+
program.command("prep-release").description("Run all prep-release steps sequentially").option("--in-steps", "Pause after each step and wait for confirmation before continuing", false).option("--commit-sha <sha>", "Diff each package against the target commit instead of the repository's base branch").option("--include-commit-links", "Embed commit hashes in changeset summaries for changelog links", false).option("--package-manager <command>", "Package manager command to use for changeset version", "pnpm").option("--config <path>", "Path to the changesets config file, relative to the project root").action((options) => run(options));
|
|
958
|
+
program.command("changeset-generate").description("Generate changesets from conventional commits").option("--commit-sha <sha>", "Diff each package against the target commit instead of the repository's base branch").option("--include-commit-links", "Embed commit hashes in changeset summaries for changelog links", false).option("--config <path>", "Path to the changesets config file, relative to the project root").action(({ config, ...options }) => conventionalCommitChangeset({
|
|
988
959
|
...options,
|
|
989
960
|
configPath: config
|
|
990
961
|
}));
|
|
991
|
-
|
|
992
|
-
|
|
962
|
+
program.command("consolidate-changelogs").description("Consolidate changelog formatting").action(() => consolidateChangelogs());
|
|
963
|
+
program.command("generate-release-notes").description("Generate combined release notes").action(async () => {
|
|
993
964
|
await generateReleaseNotes();
|
|
994
965
|
});
|
|
995
|
-
|
|
996
|
-
|
|
966
|
+
program.command("check-versions").description("Check which packages have newer versions than what is published on npm").option("--config <path>", "Path to the changesets config file, relative to the project root").action((options) => checkVersions({ configPath: options.config }));
|
|
967
|
+
program.command("check-jsdoc-since-tags").argument("[directories...]", "Directories to scan instead of package sources. If this is omitted, the `src` folder will be used by default").description("Check for JSDoc @since next-release tags without modifying files").action(async (directories) => {
|
|
997
968
|
const result = await checkJsDocSinceTags({ packages: getCheckPackageSnapshots({ directories }) });
|
|
998
969
|
for (const line of formatJsDocSinceCheckResult(result)) console.log(line);
|
|
999
970
|
});
|
|
1000
|
-
|
|
971
|
+
program.command("update-jsdoc-since-tags").argument("[directories...]", "Directories to update instead of package sources").option("--version <version>", "Version to use instead of each containing package's current version").option("--diff-ref <git-ref>", "Git ref to compare package versions against (defaults to the changesets base branch)").description("Replace JSDoc @since next-release tags with package or explicit versions").action(async (directories, options) => {
|
|
1001
972
|
console.log(formatJsDocSinceUpdateStartMessage());
|
|
1002
973
|
const lines = formatJsDocSinceUpdateResult(await updateJsDocSinceTagsForPackages({
|
|
1003
974
|
onProgress: console.log,
|
|
@@ -1013,7 +984,7 @@ _commander_js_extra_typings.program.command("update-jsdoc-since-tags").argument(
|
|
|
1013
984
|
}
|
|
1014
985
|
for (const line of lines) console.log(line);
|
|
1015
986
|
});
|
|
1016
|
-
|
|
987
|
+
program.command("create-github-releases").description("Create GitHub releases for published packages from changelogs").option("--token <token>", "GitHub token for authentication (falls back to TOKEN or GITHUB_TOKEN env vars)").option("--repo <owner/repo>", "GitHub repository in owner/repo format (defaults to git remote origin)").option("--config <path>", "Path to the changesets config file, relative to the project root").action((options) => {
|
|
1017
988
|
const token = options.token ?? process.env.TOKEN ?? process.env.GITHUB_TOKEN;
|
|
1018
989
|
if (!token) {
|
|
1019
990
|
console.error("GitHub token is required. Use --token, or set TOKEN or GITHUB_TOKEN env var.");
|
|
@@ -1025,7 +996,8 @@ _commander_js_extra_typings.program.command("create-github-releases").descriptio
|
|
|
1025
996
|
token
|
|
1026
997
|
});
|
|
1027
998
|
});
|
|
1028
|
-
|
|
999
|
+
program.parse(process.argv);
|
|
1029
1000
|
//#endregion
|
|
1001
|
+
export {};
|
|
1030
1002
|
|
|
1031
|
-
//# sourceMappingURL=cli.
|
|
1003
|
+
//# sourceMappingURL=cli.js.map
|