bunset 1.0.3 → 1.0.5
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/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/src/git.ts +11 -2
- package/src/index.ts +26 -6
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/git.ts
CHANGED
|
@@ -63,10 +63,19 @@ export async function commitAndTag(
|
|
|
63
63
|
cwd: string,
|
|
64
64
|
message: string,
|
|
65
65
|
tags: string[] = [],
|
|
66
|
+
files: string[] = [],
|
|
66
67
|
): Promise<void> {
|
|
67
|
-
await $`git -C ${cwd} add
|
|
68
|
+
await $`git -C ${cwd} add ${files}`.quiet();
|
|
68
69
|
await $`git -C ${cwd} commit -m ${message}`.quiet();
|
|
70
|
+
const skipped: string[] = [];
|
|
69
71
|
for (const tag of tags) {
|
|
70
|
-
|
|
72
|
+
try {
|
|
73
|
+
await $`git -C ${cwd} tag ${tag}`.quiet();
|
|
74
|
+
} catch {
|
|
75
|
+
skipped.push(tag);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (skipped.length > 0) {
|
|
79
|
+
console.warn(`⚠ Skipped existing tags: ${skipped.join(", ")}`);
|
|
71
80
|
}
|
|
72
81
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
+
import { $ } from "bun";
|
|
3
4
|
import { resolveOptions } from "./cli.ts";
|
|
4
5
|
import { loadConfig } from "./config.ts";
|
|
5
6
|
import {
|
|
@@ -148,6 +149,7 @@ if (options.dryRun) {
|
|
|
148
149
|
if (!dbg) console.log("--- Dry Run ---\n");
|
|
149
150
|
|
|
150
151
|
const tags: string[] = [];
|
|
152
|
+
const filesToCommit: string[] = [];
|
|
151
153
|
|
|
152
154
|
for (const pkg of packages) {
|
|
153
155
|
const groups = getPackageGroups(pkg, parsed);
|
|
@@ -179,6 +181,7 @@ if (options.dryRun) {
|
|
|
179
181
|
const oldVersion = pkg.version ?? "0.0.0";
|
|
180
182
|
const newVersion = bumpVersion(oldVersion, options.bump);
|
|
181
183
|
console.log(`${pkg.name}: ${oldVersion} → ${newVersion}`);
|
|
184
|
+
filesToCommit.push(pkg.packageJsonPath, `${pkg.path}/CHANGELOG.md`);
|
|
182
185
|
|
|
183
186
|
const updatedDeps = await getUpdatedDependencies(
|
|
184
187
|
cwd,
|
|
@@ -204,6 +207,10 @@ if (options.dryRun) {
|
|
|
204
207
|
}
|
|
205
208
|
}
|
|
206
209
|
|
|
210
|
+
const uniqueTags = [...new Set(tags)];
|
|
211
|
+
|
|
212
|
+
filesToCommit.push(`${cwd}/bun.lock`);
|
|
213
|
+
|
|
207
214
|
if (options.commit) {
|
|
208
215
|
const msg =
|
|
209
216
|
packages.length === 1
|
|
@@ -214,17 +221,21 @@ if (options.dryRun) {
|
|
|
214
221
|
console.log("Will not commit (--commit not set).");
|
|
215
222
|
}
|
|
216
223
|
|
|
217
|
-
if (
|
|
218
|
-
console.log(`Would tag: ${
|
|
224
|
+
if (uniqueTags.length > 0) {
|
|
225
|
+
console.log(`Would tag: ${uniqueTags.join(", ")}`);
|
|
219
226
|
} else if (!options.tag) {
|
|
220
227
|
console.log("Will not tag (--tag not set).");
|
|
221
228
|
}
|
|
222
229
|
|
|
223
|
-
console.log(
|
|
230
|
+
console.log(`\nFiles that would be modified (${filesToCommit.length}):`);
|
|
231
|
+
for (const f of filesToCommit) {
|
|
232
|
+
console.log(` ${f}`);
|
|
233
|
+
}
|
|
224
234
|
process.exit(0);
|
|
225
235
|
}
|
|
226
236
|
|
|
227
237
|
const tags: string[] = [];
|
|
238
|
+
const changedFiles: string[] = [];
|
|
228
239
|
|
|
229
240
|
for (const pkg of packages) {
|
|
230
241
|
const groups = getPackageGroups(pkg, parsed);
|
|
@@ -240,6 +251,7 @@ for (const pkg of packages) {
|
|
|
240
251
|
pkg.packageJsonPath,
|
|
241
252
|
options.bump,
|
|
242
253
|
);
|
|
254
|
+
changedFiles.push(pkg.packageJsonPath);
|
|
243
255
|
console.log(`${pkg.name}: ${oldVersion} → ${newVersion}`);
|
|
244
256
|
|
|
245
257
|
const updatedDeps = await getUpdatedDependencies(
|
|
@@ -254,6 +266,7 @@ for (const pkg of packages) {
|
|
|
254
266
|
options.sections,
|
|
255
267
|
);
|
|
256
268
|
await writeChangelog(pkg.path, entry);
|
|
269
|
+
changedFiles.push(`${pkg.path}/CHANGELOG.md`);
|
|
257
270
|
|
|
258
271
|
if (options.tag) {
|
|
259
272
|
if (options.perPackageTags) {
|
|
@@ -264,15 +277,22 @@ for (const pkg of packages) {
|
|
|
264
277
|
}
|
|
265
278
|
}
|
|
266
279
|
|
|
280
|
+
const uniqueTags = [...new Set(tags)];
|
|
281
|
+
|
|
282
|
+
// Update lockfile after package.json versions changed
|
|
283
|
+
await $`bun install --lockfile-only`.cwd(cwd).quiet();
|
|
284
|
+
changedFiles.push(`${cwd}/bun.lock`);
|
|
285
|
+
debug("updated bun.lock");
|
|
286
|
+
|
|
267
287
|
if (options.commit) {
|
|
268
288
|
const msg =
|
|
269
289
|
packages.length === 1
|
|
270
290
|
? `chore: release ${packages[0]!.name}@${(await Bun.file(packages[0]!.packageJsonPath).json()).version}`
|
|
271
291
|
: `chore: release ${packages.length} packages`;
|
|
272
|
-
await commitAndTag(cwd, msg, options.tag ?
|
|
292
|
+
await commitAndTag(cwd, msg, options.tag ? uniqueTags : [], changedFiles);
|
|
273
293
|
console.log(`Committed: ${msg}`);
|
|
274
|
-
if (
|
|
275
|
-
console.log(`Tagged: ${
|
|
294
|
+
if (uniqueTags.length > 0) {
|
|
295
|
+
console.log(`Tagged: ${uniqueTags.join(", ")}`);
|
|
276
296
|
}
|
|
277
297
|
}
|
|
278
298
|
|