bunset 1.0.2 → 1.0.4

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.4
4
+
5
+ ### Bug Fixes
6
+
7
+ - handle existing tags during commit and tagging process
8
+
9
+ ## 1.0.3
10
+
11
+ ### Bug Fixes
12
+
13
+ - show friendly error for unrecognized CLI options
14
+
3
15
  ## 1.0.2
4
16
 
5
17
  ### Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunset",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "module": "src/index.ts",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.ts CHANGED
@@ -82,26 +82,36 @@ export function resolveOptions(
82
82
  isWs: boolean,
83
83
  config: Partial<CliOptions> = {},
84
84
  ): CliOptions | Promise<CliOptions> {
85
- const { values } = parseArgs({
86
- args: Bun.argv.slice(2),
87
- options: {
88
- all: { type: "boolean", default: false },
89
- changed: { type: "boolean", default: false },
90
- patch: { type: "boolean", default: false },
91
- minor: { type: "boolean", default: false },
92
- major: { type: "boolean", default: false },
93
- commit: { type: "boolean", default: true },
94
- tag: { type: "boolean", default: true },
95
- "per-package-tags": { type: "boolean", default: false },
96
- sections: { type: "string" },
97
- "dry-run": { type: "boolean", default: false },
98
- "filter-by-package": { type: "boolean", default: true },
99
- "tag-prefix": { type: "string" },
100
- debug: { type: "boolean", default: false },
101
- help: { type: "boolean", short: "h", default: false },
102
- },
103
- strict: true,
104
- });
85
+ let values: ReturnType<typeof parseArgs>["values"];
86
+ try {
87
+ ({ values } = parseArgs({
88
+ args: Bun.argv.slice(2),
89
+ options: {
90
+ all: { type: "boolean", default: false },
91
+ changed: { type: "boolean", default: false },
92
+ patch: { type: "boolean", default: false },
93
+ minor: { type: "boolean", default: false },
94
+ major: { type: "boolean", default: false },
95
+ commit: { type: "boolean", default: true },
96
+ tag: { type: "boolean", default: true },
97
+ "per-package-tags": { type: "boolean", default: false },
98
+ sections: { type: "string" },
99
+ "dry-run": { type: "boolean", default: false },
100
+ "filter-by-package": { type: "boolean", default: true },
101
+ "tag-prefix": { type: "string" },
102
+ debug: { type: "boolean", default: false },
103
+ help: { type: "boolean", short: "h", default: false },
104
+ },
105
+ strict: true,
106
+ }));
107
+ } catch (err) {
108
+ if (err instanceof TypeError && (err as any).code === "ERR_PARSE_ARGS_UNKNOWN_OPTION") {
109
+ console.error(err.message);
110
+ console.error("\nRun bunset --help to see available options.");
111
+ process.exit(1);
112
+ }
113
+ throw err;
114
+ }
105
115
 
106
116
  if (values.help) {
107
117
  printHelp();
package/src/git.ts CHANGED
@@ -66,7 +66,15 @@ export async function commitAndTag(
66
66
  ): Promise<void> {
67
67
  await $`git -C ${cwd} add -A`.quiet();
68
68
  await $`git -C ${cwd} commit -m ${message}`.quiet();
69
+ const skipped: string[] = [];
69
70
  for (const tag of tags) {
70
- await $`git -C ${cwd} tag ${tag}`.quiet();
71
+ try {
72
+ await $`git -C ${cwd} tag ${tag}`.quiet();
73
+ } catch {
74
+ skipped.push(tag);
75
+ }
76
+ }
77
+ if (skipped.length > 0) {
78
+ console.warn(`⚠ Skipped existing tags: ${skipped.join(", ")}`);
71
79
  }
72
80
  }
package/src/index.ts CHANGED
@@ -204,6 +204,8 @@ if (options.dryRun) {
204
204
  }
205
205
  }
206
206
 
207
+ const uniqueTags = [...new Set(tags)];
208
+
207
209
  if (options.commit) {
208
210
  const msg =
209
211
  packages.length === 1
@@ -214,8 +216,8 @@ if (options.dryRun) {
214
216
  console.log("Will not commit (--commit not set).");
215
217
  }
216
218
 
217
- if (tags.length > 0) {
218
- console.log(`Would tag: ${tags.join(", ")}`);
219
+ if (uniqueTags.length > 0) {
220
+ console.log(`Would tag: ${uniqueTags.join(", ")}`);
219
221
  } else if (!options.tag) {
220
222
  console.log("Will not tag (--tag not set).");
221
223
  }
@@ -264,15 +266,17 @@ for (const pkg of packages) {
264
266
  }
265
267
  }
266
268
 
269
+ const uniqueTags = [...new Set(tags)];
270
+
267
271
  if (options.commit) {
268
272
  const msg =
269
273
  packages.length === 1
270
274
  ? `chore: release ${packages[0]!.name}@${(await Bun.file(packages[0]!.packageJsonPath).json()).version}`
271
275
  : `chore: release ${packages.length} packages`;
272
- await commitAndTag(cwd, msg, options.tag ? tags : []);
276
+ await commitAndTag(cwd, msg, options.tag ? uniqueTags : []);
273
277
  console.log(`Committed: ${msg}`);
274
- if (tags.length > 0) {
275
- console.log(`Tagged: ${tags.join(", ")}`);
278
+ if (uniqueTags.length > 0) {
279
+ console.log(`Tagged: ${uniqueTags.join(", ")}`);
276
280
  }
277
281
  }
278
282