-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.ts
65 lines (60 loc) · 1.91 KB
/
publish.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// 👉 usage example: `bun pub --bump=1.2.3`
import { defineCommand, runMain } from "citty";
import { execa } from "execa";
import { relinka } from "~/main.js";
const main = defineCommand({
meta: {
name: "pub",
},
args: {
bump: {
type: "string",
description: "Bump the version",
valueHint: "1.2.3",
},
dryRun: {
type: "boolean",
description: "Dry run the publish process",
},
jsr: {
type: "boolean",
description: "Publish the JSR version",
},
npm: {
type: "boolean",
description: "Publish the NPM version",
},
},
run: async ({ args }) => {
if (args.jsr) {
relinka("info", "Publishing the JSR version");
await execa("bun", ["build.publish.ts", args.bump, "--jsr"], {
stdio: "inherit",
});
} else if (args.npm) {
relinka("info", "Publishing the NPM version");
await execa("bun", ["build.publish.ts", args.bump], { stdio: "inherit" });
} else if (args.dryRun) {
relinka("info", "Dry run the publish process");
await execa("bun", ["pub:jsr", "--dry-run"], { stdio: "inherit" });
await execa("bun", ["pub:npm", "--dry-run"], { stdio: "inherit" });
} else {
relinka("info", "Publishing the JSR version");
await execa("bun", ["build.publish.ts", args.bump, "--jsr"], {
stdio: "inherit",
});
relinka("info", "Publishing the NPM version");
await execa("bun", ["pub:npm", args.bump], { stdio: "inherit" });
}
},
});
function errorHandler(error: unknown, message: string) {
relinka("error", message);
relinka("error", error instanceof Error ? error.message : String(error));
}
await runMain(main).catch((error: unknown) => {
errorHandler(
error instanceof Error ? error : new Error(String(error)),
"If this issue is related to @reliverse/cli itself, please\n│ report the details at https://github.com/reliverse/cli",
);
});