bun-push 0.1.9

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.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +320 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +1459 -0
  6. package/dist/cli.js.map +22 -0
  7. package/dist/i18n/index.d.ts +21 -0
  8. package/dist/i18n/index.d.ts.map +1 -0
  9. package/dist/i18n/index.js +126 -0
  10. package/dist/i18n/locales/en.d.ts +119 -0
  11. package/dist/i18n/locales/en.d.ts.map +1 -0
  12. package/dist/i18n/locales/en.js +125 -0
  13. package/dist/i18n/locales/ja.d.ts +119 -0
  14. package/dist/i18n/locales/ja.d.ts.map +1 -0
  15. package/dist/i18n/locales/ja.js +125 -0
  16. package/dist/i18n/locales/ko.d.ts +119 -0
  17. package/dist/i18n/locales/ko.d.ts.map +1 -0
  18. package/dist/i18n/locales/ko.js +125 -0
  19. package/dist/i18n/locales/zh.d.ts +119 -0
  20. package/dist/i18n/locales/zh.d.ts.map +1 -0
  21. package/dist/i18n/locales/zh.js +125 -0
  22. package/dist/index.d.ts +33 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +1114 -0
  25. package/dist/index.js.map +20 -0
  26. package/dist/index.test.d.ts +2 -0
  27. package/dist/index.test.d.ts.map +1 -0
  28. package/dist/index.test.js +90 -0
  29. package/dist/logo.d.ts +9 -0
  30. package/dist/logo.d.ts.map +1 -0
  31. package/dist/logo.js +58 -0
  32. package/dist/prompts.d.ts +42 -0
  33. package/dist/prompts.d.ts.map +1 -0
  34. package/dist/prompts.js +312 -0
  35. package/dist/publisher.d.ts +7 -0
  36. package/dist/publisher.d.ts.map +1 -0
  37. package/dist/publisher.js +110 -0
  38. package/dist/publisher.test.d.ts +2 -0
  39. package/dist/publisher.test.d.ts.map +1 -0
  40. package/dist/publisher.test.js +92 -0
  41. package/dist/types.d.ts +78 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/types.js +4 -0
  44. package/dist/utils/changelog.d.ts +32 -0
  45. package/dist/utils/changelog.d.ts.map +1 -0
  46. package/dist/utils/changelog.js +210 -0
  47. package/dist/utils/changelog.test.d.ts +2 -0
  48. package/dist/utils/changelog.test.d.ts.map +1 -0
  49. package/dist/utils/changelog.test.js +126 -0
  50. package/dist/utils/scripts.d.ts +13 -0
  51. package/dist/utils/scripts.d.ts.map +1 -0
  52. package/dist/utils/scripts.js +30 -0
  53. package/dist/utils/scripts.test.d.ts +2 -0
  54. package/dist/utils/scripts.test.d.ts.map +1 -0
  55. package/dist/utils/scripts.test.js +58 -0
  56. package/dist/utils/version.d.ts +24 -0
  57. package/dist/utils/version.d.ts.map +1 -0
  58. package/dist/utils/version.js +71 -0
  59. package/dist/utils/version.test.d.ts +2 -0
  60. package/dist/utils/version.test.d.ts.map +1 -0
  61. package/dist/utils/version.test.js +78 -0
  62. package/dist/utils/workspace.d.ts +14 -0
  63. package/dist/utils/workspace.d.ts.map +1 -0
  64. package/dist/utils/workspace.js +174 -0
  65. package/dist/utils/workspace.test.d.ts +2 -0
  66. package/dist/utils/workspace.test.d.ts.map +1 -0
  67. package/dist/utils/workspace.test.js +124 -0
  68. package/package.json +56 -0
package/dist/cli.js ADDED
@@ -0,0 +1,1459 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+ var __create = Object.create;
4
+ var __getProtoOf = Object.getPrototypeOf;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __toESM = (mod, isNodeMode, target) => {
9
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
10
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
+ for (let key of __getOwnPropNames(mod))
12
+ if (!__hasOwnProp.call(to, key))
13
+ __defProp(to, key, {
14
+ get: () => mod[key],
15
+ enumerable: true
16
+ });
17
+ return to;
18
+ };
19
+ var __require = import.meta.require;
20
+
21
+ // src/cli.ts
22
+ import ora from "ora";
23
+ import chalk3 from "chalk";
24
+
25
+ // src/utils/workspace.ts
26
+ import { readFileSync, existsSync, readdirSync, statSync } from "fs";
27
+ import { join, resolve } from "path";
28
+
29
+ // src/i18n/locales/zh.ts
30
+ var zh_default = {
31
+ common: {
32
+ yes: "\u662F",
33
+ no: "\u5426",
34
+ skip: "\u8DF3\u8FC7",
35
+ cancel: "\u53D6\u6D88",
36
+ confirm: "\u786E\u8BA4",
37
+ error: "\u9519\u8BEF",
38
+ success: "\u6210\u529F"
39
+ },
40
+ package: {
41
+ selectPackage: "\u8BF7\u9009\u62E9\u8981\u53D1\u5E03\u7684\u5305",
42
+ selectedPackage: "\u5DF2\u9009\u62E9\u5305"
43
+ },
44
+ changelog: {
45
+ input: "\u8BF7\u8F93\u5165 changelog\uFF08\u5355\u884C\u8F93\u5165\uFF0C\u652F\u6301\u591A\u6B21\u8F93\u5165\uFF0C\u8F93\u5165\u7A7A\u884C\u7ED3\u675F\uFF09",
46
+ singleLineHint: "\u652F\u6301\u591A\u6B21\u5355\u884C\u8F93\u5165\uFF0C\u8F93\u5165\u7A7A\u884C\u7ED3\u675F\u3002\u5982\u679C\u8F93\u5165\u4E3A\u7A7A\uFF0C\u5C06\u4F7F\u7528\u9ED8\u8BA4\u7684\u7248\u672C\u5347\u7EA7\u8BB0\u5F55",
47
+ empty: "changelog \u4E0D\u80FD\u4E3A\u7A7A",
48
+ generate: "\u662F\u5426\u751F\u6210 CHANGELOG.md \u6587\u4EF6\uFF1F",
49
+ usingDefault: "\u4F7F\u7528\u9ED8\u8BA4 changelog\uFF1A\u7248\u672C\u5347\u7EA7\u8BB0\u5F55",
50
+ defaultContent: "\u5347\u7EA7\u7248\u672C\u53F7: {currentVersion} \u2192 {newVersion}"
51
+ },
52
+ version: {
53
+ selectType: "\u9009\u62E9\u7248\u672C\u7C7B\u578B",
54
+ currentVersion: "\u5F53\u524D\u7248\u672C",
55
+ finalVersion: "\u6700\u7EC8\u7248\u672C",
56
+ customVersion: "\u81EA\u5B9A\u4E49\u7248\u672C\u53F7",
57
+ customVersionDesc: "\u624B\u52A8\u8F93\u5165\u7248\u672C\u53F7",
58
+ inputVersion: "\u8BF7\u8F93\u5165\u7248\u672C\u53F7",
59
+ example: "\u793A\u4F8B",
60
+ versionEmpty: "\u7248\u672C\u53F7\u4E0D\u80FD\u4E3A\u7A7A",
61
+ patch: "\u8865\u4E01\u7248\u672C - \u4FEE\u590D bug",
62
+ minor: "\u6B21\u7248\u672C - \u65B0\u529F\u80FD\uFF0C\u5411\u540E\u517C\u5BB9",
63
+ major: "\u4E3B\u7248\u672C - \u7834\u574F\u6027\u53D8\u66F4",
64
+ invalid: "\u65E0\u6548\u7684\u7248\u672C\u53F7",
65
+ invalidWithVersion: "\u65E0\u6548\u7684\u7248\u672C\u53F7: {version}",
66
+ cannotGenerate: "\u65E0\u6CD5\u751F\u6210\u4E0B\u4E00\u4E2A\u7248\u672C\u53F7",
67
+ unsupportedType: "\u4E0D\u652F\u6301\u7684\u53D1\u5E03\u7C7B\u578B",
68
+ unsupportedTypeWithType: "\u4E0D\u652F\u6301\u7684\u53D1\u5E03\u7C7B\u578B: {type}",
69
+ versionFormat: "{current} -> {next}"
70
+ },
71
+ script: {
72
+ select: "\u8BF7\u9009\u62E9\u8981\u6267\u884C\u7684\u811A\u672C\uFF08\u901A\u5E38\u662F build\uFF09",
73
+ noScripts: "\u8BE5\u5305\u6CA1\u6709 scripts",
74
+ running: "\u6267\u884C\u811A\u672C",
75
+ success: "\u811A\u672C\u6267\u884C\u6210\u529F",
76
+ failed: "\u811A\u672C\u6267\u884C\u5931\u8D25",
77
+ notFound: "\u811A\u672C\u4E0D\u5B58\u5728",
78
+ notFoundWithName: '\u811A\u672C "{name}" \u4E0D\u5B58\u5728',
79
+ executionFailed: "\u811A\u672C\u6267\u884C\u5931\u8D25\uFF0C\u9000\u51FA\u7801: {exitCode}"
80
+ },
81
+ git: {
82
+ pushTag: "\u662F\u5426\u63A8\u9001 git tag\uFF1F",
83
+ createTagFailed: "\u521B\u5EFA git tag \u5931\u8D25\uFF0C\u9000\u51FA\u7801: {exitCode}",
84
+ pushTagFailed: "\u63A8\u9001 git tag \u5931\u8D25\uFF0C\u9000\u51FA\u7801: {exitCode}"
85
+ },
86
+ registry: {
87
+ input: "\u8BF7\u8F93\u5165 npm registry \u5730\u5740",
88
+ empty: "registry \u5730\u5740\u4E0D\u80FD\u4E3A\u7A7A",
89
+ invalid: "\u8BF7\u8F93\u5165\u6709\u6548\u7684 URL"
90
+ },
91
+ publish: {
92
+ preview: "\u53D1\u5E03\u914D\u7F6E\u9884\u89C8",
93
+ packageName: "\u5305\u540D",
94
+ currentVersion: "\u5F53\u524D\u7248\u672C",
95
+ newVersion: "\u65B0\u7248\u672C",
96
+ tag: "Tag",
97
+ changelog: "Changelog",
98
+ registry: "Registry",
99
+ pushTag: "\u63A8\u9001 Tag",
100
+ generateChangelog: "\u751F\u6210 Changelog",
101
+ script: "\u6267\u884C\u811A\u672C",
102
+ confirm: "\u786E\u8BA4\u53D1\u5E03\uFF1F",
103
+ publishing: "\u6B63\u5728\u53D1\u5E03\u5230 npm...",
104
+ success: "\u53D1\u5E03\u6210\u529F\uFF01",
105
+ failed: "\u53D1\u5E03\u5931\u8D25",
106
+ cancelled: "\u5DF2\u53D6\u6D88\u53D1\u5E03",
107
+ error: "\u53D1\u5E03\u8FC7\u7A0B\u4E2D\u51FA\u73B0\u9519\u8BEF",
108
+ generalError: "\u9519\u8BEF",
109
+ npmPublishFailed: "npm \u53D1\u5E03\u5931\u8D25\uFF0C\u9000\u51FA\u7801: {exitCode}",
110
+ npmNotLoggedIn: "\u672A\u767B\u5F55\u5230 npm registry: {registry}\uFF0C\u8BF7\u5148\u8FD0\u884C 'npm login --registry {registry}' \u767B\u5F55",
111
+ npmAuthCheckFailed: "\u68C0\u67E5 npm \u767B\u5F55\u72B6\u6001\u5931\u8D25 (registry: {registry}): {error}",
112
+ needOtp: "\u662F\u5426\u9700\u8981\u8F93\u5165 npm \u53D1\u5E03\u7684\u4E00\u6B21\u6027\u4EE3\u7801\uFF08OTP\uFF09\uFF1F",
113
+ inputOtp: "\u8BF7\u8F93\u5165\u4E00\u6B21\u6027\u4EE3\u7801\uFF08OTP\uFF09",
114
+ otpEmpty: "\u4E00\u6B21\u6027\u4EE3\u7801\u4E0D\u80FD\u4E3A\u7A7A",
115
+ otpInvalid: "\u4E00\u6B21\u6027\u4EE3\u7801\u5FC5\u987B\u662F 6 \u4F4D\u6570\u5B57",
116
+ otp: "\u4E00\u6B21\u6027\u4EE3\u7801\uFF08OTP\uFF09",
117
+ rollingBack: "\u53D1\u5E03\u5931\u8D25\uFF0C\u6B63\u5728\u56DE\u6EDA\u4FEE\u6539...",
118
+ rollbackComplete: "\u56DE\u6EDA\u5B8C\u6210",
119
+ rollbackFailed: "\u56DE\u6EDA\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u6062\u590D\u7248\u672C\u53F7\u548C changelog:"
120
+ },
121
+ success: {
122
+ title: "\u53D1\u5E03\u6210\u529F\uFF01",
123
+ packageName: "\u5305\u540D",
124
+ version: "\u7248\u672C",
125
+ registry: "Registry",
126
+ thanks: "\u611F\u8C22\u4F7F\u7528 bun-push\uFF01"
127
+ },
128
+ changelogTypes: {
129
+ added: "\u65B0\u589E",
130
+ changed: "\u53D8\u66F4",
131
+ deprecated: "\u5E9F\u5F03",
132
+ removed: "\u79FB\u9664",
133
+ fixed: "\u4FEE\u590D",
134
+ security: "\u5B89\u5168"
135
+ },
136
+ workspace: {
137
+ packageJsonNotFound: "\u672A\u627E\u5230 package.json \u6587\u4EF6",
138
+ workspacesConfigInvalid: "workspaces \u914D\u7F6E\u65E0\u6548",
139
+ packageNotFound: "\u672A\u627E\u5230\u8981\u53D1\u5E03\u7684\u5305",
140
+ packageNotFoundByPath: "\u672A\u627E\u5230\u8DEF\u5F84\u4E3A {path} \u7684\u5305",
141
+ monorepoRequiresPath: "monorepo \u6A21\u5F0F\u4E0B\u5FC5\u987B\u6307\u5B9A packagePath \u6216\u4F7F\u7528 CLI \u6A21\u5F0F"
142
+ }
143
+ };
144
+
145
+ // src/i18n/locales/en.ts
146
+ var en_default = {
147
+ common: {
148
+ yes: "Yes",
149
+ no: "No",
150
+ skip: "Skip",
151
+ cancel: "Cancel",
152
+ confirm: "Confirm",
153
+ error: "Error",
154
+ success: "Success"
155
+ },
156
+ package: {
157
+ selectPackage: "Select package to publish",
158
+ selectedPackage: "Selected package"
159
+ },
160
+ changelog: {
161
+ input: "Enter changelog (single line input, supports multiple inputs, press Enter to finish)",
162
+ singleLineHint: "Supports multiple single-line inputs, press Enter to finish. If input is empty, default version upgrade record will be used",
163
+ empty: "changelog cannot be empty",
164
+ generate: "Generate CHANGELOG.md file?",
165
+ usingDefault: "Using default changelog: version upgrade record",
166
+ defaultContent: "Upgrade version: {currentVersion} \u2192 {newVersion}"
167
+ },
168
+ version: {
169
+ selectType: "Select version type",
170
+ currentVersion: "Current version",
171
+ finalVersion: "Final version",
172
+ customVersion: "Custom version",
173
+ customVersionDesc: "Enter version manually",
174
+ inputVersion: "Enter version number",
175
+ example: "Example",
176
+ versionEmpty: "Version cannot be empty",
177
+ patch: "Patch version - Bug fixes",
178
+ minor: "Minor version - New features, backward compatible",
179
+ major: "Major version - Breaking changes",
180
+ invalid: "Invalid version number",
181
+ invalidWithVersion: "Invalid version number: {version}",
182
+ cannotGenerate: "Cannot generate next version",
183
+ unsupportedType: "Unsupported release type",
184
+ unsupportedTypeWithType: "Unsupported release type: {type}",
185
+ versionFormat: "{current} -> {next}"
186
+ },
187
+ script: {
188
+ select: "Select script to run (usually build)",
189
+ noScripts: "This package has no scripts",
190
+ running: "Running script",
191
+ success: "Script executed successfully",
192
+ failed: "Script execution failed",
193
+ notFound: "Script not found",
194
+ notFoundWithName: 'Script "{name}" not found',
195
+ executionFailed: "Script execution failed, exit code: {exitCode}"
196
+ },
197
+ git: {
198
+ pushTag: "Push git tag?",
199
+ createTagFailed: "Failed to create git tag, exit code: {exitCode}",
200
+ pushTagFailed: "Failed to push git tag, exit code: {exitCode}"
201
+ },
202
+ registry: {
203
+ input: "Enter npm registry address",
204
+ empty: "Registry address cannot be empty",
205
+ invalid: "Please enter a valid URL"
206
+ },
207
+ publish: {
208
+ preview: "Publish configuration preview",
209
+ packageName: "Package name",
210
+ currentVersion: "Current version",
211
+ newVersion: "New version",
212
+ tag: "Tag",
213
+ changelog: "Changelog",
214
+ registry: "Registry",
215
+ pushTag: "Push Tag",
216
+ generateChangelog: "Generate Changelog",
217
+ script: "Script",
218
+ confirm: "Confirm publish?",
219
+ publishing: "Publishing to npm...",
220
+ success: "Published successfully!",
221
+ failed: "Publish failed",
222
+ cancelled: "Publish cancelled",
223
+ error: "Error during publish",
224
+ generalError: "Error",
225
+ npmPublishFailed: "npm publish failed, exit code: {exitCode}",
226
+ npmNotLoggedIn: "Not logged in to npm registry: {registry}, please run 'npm login --registry {registry}' first",
227
+ npmAuthCheckFailed: "Failed to check npm login status (registry: {registry}): {error}",
228
+ needOtp: "Do you need to enter npm publish one-time code (OTP)?",
229
+ inputOtp: "Enter one-time code (OTP)",
230
+ otpEmpty: "One-time code cannot be empty",
231
+ otpInvalid: "One-time code must be 6 digits",
232
+ otp: "One-time code (OTP)",
233
+ rollingBack: "Publish failed, rolling back changes...",
234
+ rollbackComplete: "Rollback completed",
235
+ rollbackFailed: "Rollback failed, please manually restore version and changelog:"
236
+ },
237
+ success: {
238
+ title: "Published successfully!",
239
+ packageName: "Package name",
240
+ version: "Version",
241
+ registry: "Registry",
242
+ thanks: "Thanks for using bun-push!"
243
+ },
244
+ changelogTypes: {
245
+ added: "Added",
246
+ changed: "Changed",
247
+ deprecated: "Deprecated",
248
+ removed: "Removed",
249
+ fixed: "Fixed",
250
+ security: "Security"
251
+ },
252
+ workspace: {
253
+ packageJsonNotFound: "package.json file not found",
254
+ workspacesConfigInvalid: "workspaces configuration is invalid",
255
+ packageNotFound: "Package not found",
256
+ packageNotFoundByPath: "Package not found at path: {path}",
257
+ monorepoRequiresPath: "In monorepo mode, packagePath must be specified or use CLI mode"
258
+ }
259
+ };
260
+
261
+ // src/i18n/locales/ja.ts
262
+ var ja_default = {
263
+ common: {
264
+ yes: "\u306F\u3044",
265
+ no: "\u3044\u3044\u3048",
266
+ skip: "\u30B9\u30AD\u30C3\u30D7",
267
+ cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
268
+ confirm: "\u78BA\u8A8D",
269
+ error: "\u30A8\u30E9\u30FC",
270
+ success: "\u6210\u529F"
271
+ },
272
+ package: {
273
+ selectPackage: "\u516C\u958B\u3059\u308B\u30D1\u30C3\u30B1\u30FC\u30B8\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044",
274
+ selectedPackage: "\u9078\u629E\u3055\u308C\u305F\u30D1\u30C3\u30B1\u30FC\u30B8"
275
+ },
276
+ changelog: {
277
+ input: "changelog\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\uFF081\u884C\u5165\u529B\u3001\u8907\u6570\u56DE\u5165\u529B\u5BFE\u5FDC\u3001Enter\u30AD\u30FC\u3067\u7D42\u4E86\uFF09",
278
+ singleLineHint: "\u8907\u6570\u56DE\u306E1\u884C\u5165\u529B\u3092\u30B5\u30DD\u30FC\u30C8\u3001Enter\u30AD\u30FC\u3067\u7D42\u4E86\u3002\u5165\u529B\u304C\u7A7A\u306E\u5834\u5408\u3001\u30C7\u30D5\u30A9\u30EB\u30C8\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u30A2\u30C3\u30D7\u30B0\u30EC\u30FC\u30C9\u8A18\u9332\u304C\u4F7F\u7528\u3055\u308C\u307E\u3059",
279
+ empty: "changelog\u306F\u7A7A\u306B\u3067\u304D\u307E\u305B\u3093",
280
+ generate: "CHANGELOG.md\u30D5\u30A1\u30A4\u30EB\u3092\u751F\u6210\u3057\u307E\u3059\u304B\uFF1F",
281
+ usingDefault: "\u30C7\u30D5\u30A9\u30EB\u30C8\u306Echangelog\u3092\u4F7F\u7528\uFF1A\u30D0\u30FC\u30B8\u30E7\u30F3\u30A2\u30C3\u30D7\u30B0\u30EC\u30FC\u30C9\u8A18\u9332",
282
+ defaultContent: "\u30D0\u30FC\u30B8\u30E7\u30F3\u30A2\u30C3\u30D7\u30B0\u30EC\u30FC\u30C9: {currentVersion} \u2192 {newVersion}"
283
+ },
284
+ version: {
285
+ selectType: "\u30D0\u30FC\u30B8\u30E7\u30F3\u30BF\u30A4\u30D7\u3092\u9078\u629E",
286
+ currentVersion: "\u73FE\u5728\u306E\u30D0\u30FC\u30B8\u30E7\u30F3",
287
+ finalVersion: "\u6700\u7D42\u30D0\u30FC\u30B8\u30E7\u30F3",
288
+ customVersion: "\u30AB\u30B9\u30BF\u30E0\u30D0\u30FC\u30B8\u30E7\u30F3",
289
+ customVersionDesc: "\u30D0\u30FC\u30B8\u30E7\u30F3\u3092\u624B\u52D5\u3067\u5165\u529B",
290
+ inputVersion: "\u30D0\u30FC\u30B8\u30E7\u30F3\u756A\u53F7\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
291
+ example: "\u4F8B",
292
+ versionEmpty: "\u30D0\u30FC\u30B8\u30E7\u30F3\u306F\u7A7A\u306B\u3067\u304D\u307E\u305B\u3093",
293
+ patch: "\u30D1\u30C3\u30C1\u30D0\u30FC\u30B8\u30E7\u30F3 - \u30D0\u30B0\u4FEE\u6B63",
294
+ minor: "\u30DE\u30A4\u30CA\u30FC\u30D0\u30FC\u30B8\u30E7\u30F3 - \u65B0\u6A5F\u80FD\u3001\u5F8C\u65B9\u4E92\u63DB",
295
+ major: "\u30E1\u30B8\u30E3\u30FC\u30D0\u30FC\u30B8\u30E7\u30F3 - \u7834\u58CA\u7684\u5909\u66F4",
296
+ invalid: "\u7121\u52B9\u306A\u30D0\u30FC\u30B8\u30E7\u30F3\u756A\u53F7",
297
+ invalidWithVersion: "\u7121\u52B9\u306A\u30D0\u30FC\u30B8\u30E7\u30F3\u756A\u53F7: {version}",
298
+ cannotGenerate: "\u6B21\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u3092\u751F\u6210\u3067\u304D\u307E\u305B\u3093",
299
+ unsupportedType: "\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u306A\u3044\u30EA\u30EA\u30FC\u30B9\u30BF\u30A4\u30D7",
300
+ unsupportedTypeWithType: "\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u306A\u3044\u30EA\u30EA\u30FC\u30B9\u30BF\u30A4\u30D7: {type}",
301
+ versionFormat: "{current} -> {next}"
302
+ },
303
+ script: {
304
+ select: "\u5B9F\u884C\u3059\u308B\u30B9\u30AF\u30EA\u30D7\u30C8\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u901A\u5E38\u306Fbuild\uFF09",
305
+ noScripts: "\u3053\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306B\u306F\u30B9\u30AF\u30EA\u30D7\u30C8\u304C\u3042\u308A\u307E\u305B\u3093",
306
+ running: "\u30B9\u30AF\u30EA\u30D7\u30C8\u3092\u5B9F\u884C\u4E2D",
307
+ success: "\u30B9\u30AF\u30EA\u30D7\u30C8\u306E\u5B9F\u884C\u306B\u6210\u529F\u3057\u307E\u3057\u305F",
308
+ failed: "\u30B9\u30AF\u30EA\u30D7\u30C8\u306E\u5B9F\u884C\u306B\u5931\u6557\u3057\u307E\u3057\u305F",
309
+ notFound: "\u30B9\u30AF\u30EA\u30D7\u30C8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093",
310
+ notFoundWithName: '\u30B9\u30AF\u30EA\u30D7\u30C8 "{name}" \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093',
311
+ executionFailed: "\u30B9\u30AF\u30EA\u30D7\u30C8\u306E\u5B9F\u884C\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3001\u7D42\u4E86\u30B3\u30FC\u30C9: {exitCode}"
312
+ },
313
+ git: {
314
+ pushTag: "git tag\u3092\u30D7\u30C3\u30B7\u30E5\u3057\u307E\u3059\u304B\uFF1F",
315
+ createTagFailed: "git tag\u306E\u4F5C\u6210\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3001\u7D42\u4E86\u30B3\u30FC\u30C9: {exitCode}",
316
+ pushTagFailed: "git tag\u306E\u30D7\u30C3\u30B7\u30E5\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3001\u7D42\u4E86\u30B3\u30FC\u30C9: {exitCode}"
317
+ },
318
+ registry: {
319
+ input: "npm registry\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
320
+ empty: "registry\u30A2\u30C9\u30EC\u30B9\u306F\u7A7A\u306B\u3067\u304D\u307E\u305B\u3093",
321
+ invalid: "\u6709\u52B9\u306AURL\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"
322
+ },
323
+ publish: {
324
+ preview: "\u516C\u958B\u8A2D\u5B9A\u30D7\u30EC\u30D3\u30E5\u30FC",
325
+ packageName: "\u30D1\u30C3\u30B1\u30FC\u30B8\u540D",
326
+ currentVersion: "\u73FE\u5728\u306E\u30D0\u30FC\u30B8\u30E7\u30F3",
327
+ newVersion: "\u65B0\u3057\u3044\u30D0\u30FC\u30B8\u30E7\u30F3",
328
+ tag: "Tag",
329
+ changelog: "Changelog",
330
+ registry: "Registry",
331
+ pushTag: "Tag\u3092\u30D7\u30C3\u30B7\u30E5",
332
+ generateChangelog: "Changelog\u3092\u751F\u6210",
333
+ script: "\u30B9\u30AF\u30EA\u30D7\u30C8",
334
+ confirm: "\u516C\u958B\u3092\u78BA\u8A8D\u3057\u307E\u3059\u304B\uFF1F",
335
+ publishing: "npm\u306B\u516C\u958B\u4E2D...",
336
+ success: "\u516C\u958B\u306B\u6210\u529F\u3057\u307E\u3057\u305F\uFF01",
337
+ failed: "\u516C\u958B\u306B\u5931\u6557\u3057\u307E\u3057\u305F",
338
+ cancelled: "\u516C\u958B\u304C\u30AD\u30E3\u30F3\u30BB\u30EB\u3055\u308C\u307E\u3057\u305F",
339
+ error: "\u516C\u958B\u4E2D\u306B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F",
340
+ generalError: "\u30A8\u30E9\u30FC",
341
+ npmPublishFailed: "npm\u516C\u958B\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3001\u7D42\u4E86\u30B3\u30FC\u30C9: {exitCode}",
342
+ npmNotLoggedIn: "npm registry \u306B\u30ED\u30B0\u30A4\u30F3\u3057\u3066\u3044\u307E\u305B\u3093: {registry}\uFF0C\u5148\u306B 'npm login --registry {registry}' \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044",
343
+ npmAuthCheckFailed: "npm \u30ED\u30B0\u30A4\u30F3\u72B6\u614B\u306E\u78BA\u8A8D\u306B\u5931\u6557\u3057\u307E\u3057\u305F (registry: {registry}): {error}",
344
+ needOtp: "npm\u516C\u958B\u306E\u30EF\u30F3\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9\uFF08OTP\uFF09\u3092\u5165\u529B\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u304B\uFF1F",
345
+ inputOtp: "\u30EF\u30F3\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9\uFF08OTP\uFF09\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
346
+ otpEmpty: "\u30EF\u30F3\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9\u306F\u7A7A\u306B\u3067\u304D\u307E\u305B\u3093",
347
+ otpInvalid: "\u30EF\u30F3\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9\u306F6\u6841\u306E\u6570\u5B57\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
348
+ otp: "\u30EF\u30F3\u30BF\u30A4\u30E0\u30B3\u30FC\u30C9\uFF08OTP\uFF09",
349
+ rollingBack: "\u516C\u958B\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3001\u5909\u66F4\u3092\u30ED\u30FC\u30EB\u30D0\u30C3\u30AF\u4E2D...",
350
+ rollbackComplete: "\u30ED\u30FC\u30EB\u30D0\u30C3\u30AF\u304C\u5B8C\u4E86\u3057\u307E\u3057\u305F",
351
+ rollbackFailed: "\u30ED\u30FC\u30EB\u30D0\u30C3\u30AF\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3001\u30D0\u30FC\u30B8\u30E7\u30F3\u3068changelog\u3092\u624B\u52D5\u3067\u5FA9\u5143\u3057\u3066\u304F\u3060\u3055\u3044:"
352
+ },
353
+ success: {
354
+ title: "\u516C\u958B\u306B\u6210\u529F\u3057\u307E\u3057\u305F\uFF01",
355
+ packageName: "\u30D1\u30C3\u30B1\u30FC\u30B8\u540D",
356
+ version: "\u30D0\u30FC\u30B8\u30E7\u30F3",
357
+ registry: "Registry",
358
+ thanks: "bun-push\u3092\u3054\u5229\u7528\u3044\u305F\u3060\u304D\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\uFF01"
359
+ },
360
+ changelogTypes: {
361
+ added: "\u8FFD\u52A0",
362
+ changed: "\u5909\u66F4",
363
+ deprecated: "\u975E\u63A8\u5968",
364
+ removed: "\u524A\u9664",
365
+ fixed: "\u4FEE\u6B63",
366
+ security: "\u30BB\u30AD\u30E5\u30EA\u30C6\u30A3"
367
+ },
368
+ workspace: {
369
+ packageJsonNotFound: "package.json\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093",
370
+ workspacesConfigInvalid: "workspaces\u8A2D\u5B9A\u304C\u7121\u52B9\u3067\u3059",
371
+ packageNotFound: "\u30D1\u30C3\u30B1\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093",
372
+ packageNotFoundByPath: "\u30D1\u30B9 {path} \u306B\u30D1\u30C3\u30B1\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093",
373
+ monorepoRequiresPath: "monorepo\u30E2\u30FC\u30C9\u3067\u306F\u3001packagePath\u3092\u6307\u5B9A\u3059\u308B\u304BCLI\u30E2\u30FC\u30C9\u3092\u4F7F\u7528\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"
374
+ }
375
+ };
376
+
377
+ // src/i18n/locales/ko.ts
378
+ var ko_default = {
379
+ common: {
380
+ yes: "\uC608",
381
+ no: "\uC544\uB2C8\uC624",
382
+ skip: "\uAC74\uB108\uB6F0\uAE30",
383
+ cancel: "\uCDE8\uC18C",
384
+ confirm: "\uD655\uC778",
385
+ error: "\uC624\uB958",
386
+ success: "\uC131\uACF5"
387
+ },
388
+ package: {
389
+ selectPackage: "\uAC8C\uC2DC\uD560 \uD328\uD0A4\uC9C0\uB97C \uC120\uD0DD\uD558\uC138\uC694",
390
+ selectedPackage: "\uC120\uD0DD\uB41C \uD328\uD0A4\uC9C0"
391
+ },
392
+ changelog: {
393
+ input: "changelog\uB97C \uC785\uB825\uD558\uC138\uC694 (\uD55C \uC904 \uC785\uB825, \uC5EC\uB7EC \uBC88 \uC785\uB825 \uC9C0\uC6D0, Enter \uD0A4\uB85C \uC885\uB8CC)",
394
+ singleLineHint: "\uC5EC\uB7EC \uBC88\uC758 \uD55C \uC904 \uC785\uB825\uC744 \uC9C0\uC6D0\uD558\uBA70, Enter \uD0A4\uB85C \uC885\uB8CC\uD569\uB2C8\uB2E4. \uC785\uB825\uC774 \uBE44\uC5B4 \uC788\uC73C\uBA74 \uAE30\uBCF8 \uBC84\uC804 \uC5C5\uADF8\uB808\uC774\uB4DC \uAE30\uB85D\uC774 \uC0AC\uC6A9\uB429\uB2C8\uB2E4",
395
+ empty: "changelog\uB294 \uBE44\uC5B4 \uC788\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",
396
+ generate: "CHANGELOG.md \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uC2DC\uACA0\uC2B5\uB2C8\uAE4C?",
397
+ usingDefault: "\uAE30\uBCF8 changelog \uC0AC\uC6A9: \uBC84\uC804 \uC5C5\uADF8\uB808\uC774\uB4DC \uAE30\uB85D",
398
+ defaultContent: "\uBC84\uC804 \uC5C5\uADF8\uB808\uC774\uB4DC: {currentVersion} \u2192 {newVersion}"
399
+ },
400
+ version: {
401
+ selectType: "\uBC84\uC804 \uC720\uD615 \uC120\uD0DD",
402
+ currentVersion: "\uD604\uC7AC \uBC84\uC804",
403
+ finalVersion: "\uCD5C\uC885 \uBC84\uC804",
404
+ customVersion: "\uC0AC\uC6A9\uC790 \uC815\uC758 \uBC84\uC804",
405
+ customVersionDesc: "\uBC84\uC804\uC744 \uC218\uB3D9\uC73C\uB85C \uC785\uB825",
406
+ inputVersion: "\uBC84\uC804 \uBC88\uD638\uB97C \uC785\uB825\uD558\uC138\uC694",
407
+ example: "\uC608",
408
+ versionEmpty: "\uBC84\uC804\uC740 \uBE44\uC5B4 \uC788\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",
409
+ patch: "\uD328\uCE58 \uBC84\uC804 - \uBC84\uADF8 \uC218\uC815",
410
+ minor: "\uB9C8\uC774\uB108 \uBC84\uC804 - \uC0C8 \uAE30\uB2A5, \uD558\uC704 \uD638\uD658",
411
+ major: "\uBA54\uC774\uC800 \uBC84\uC804 - \uC8FC\uC694 \uBCC0\uACBD \uC0AC\uD56D",
412
+ invalid: "\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 \uBC84\uC804 \uBC88\uD638",
413
+ invalidWithVersion: "\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 \uBC84\uC804 \uBC88\uD638: {version}",
414
+ cannotGenerate: "\uB2E4\uC74C \uBC84\uC804\uC744 \uC0DD\uC131\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",
415
+ unsupportedType: "\uC9C0\uC6D0\uB418\uC9C0 \uC54A\uB294 \uB9B4\uB9AC\uC2A4 \uC720\uD615",
416
+ unsupportedTypeWithType: "\uC9C0\uC6D0\uB418\uC9C0 \uC54A\uB294 \uB9B4\uB9AC\uC2A4 \uC720\uD615: {type}",
417
+ versionFormat: "{current} -> {next}"
418
+ },
419
+ script: {
420
+ select: "\uC2E4\uD589\uD560 \uC2A4\uD06C\uB9BD\uD2B8\uB97C \uC120\uD0DD\uD558\uC138\uC694 (\uBCF4\uD1B5 build)",
421
+ noScripts: "\uC774 \uD328\uD0A4\uC9C0\uC5D0\uB294 \uC2A4\uD06C\uB9BD\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4",
422
+ running: "\uC2A4\uD06C\uB9BD\uD2B8 \uC2E4\uD589 \uC911",
423
+ success: "\uC2A4\uD06C\uB9BD\uD2B8 \uC2E4\uD589 \uC131\uACF5",
424
+ failed: "\uC2A4\uD06C\uB9BD\uD2B8 \uC2E4\uD589 \uC2E4\uD328",
425
+ notFound: "\uC2A4\uD06C\uB9BD\uD2B8\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",
426
+ notFoundWithName: '\uC2A4\uD06C\uB9BD\uD2B8 "{name}"\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4',
427
+ executionFailed: "\uC2A4\uD06C\uB9BD\uD2B8 \uC2E4\uD589 \uC2E4\uD328, \uC885\uB8CC \uCF54\uB4DC: {exitCode}"
428
+ },
429
+ git: {
430
+ pushTag: "git tag\uB97C \uD478\uC2DC\uD558\uC2DC\uACA0\uC2B5\uB2C8\uAE4C?",
431
+ createTagFailed: "git tag \uC0DD\uC131 \uC2E4\uD328, \uC885\uB8CC \uCF54\uB4DC: {exitCode}",
432
+ pushTagFailed: "git tag \uD478\uC2DC \uC2E4\uD328, \uC885\uB8CC \uCF54\uB4DC: {exitCode}"
433
+ },
434
+ registry: {
435
+ input: "npm registry \uC8FC\uC18C\uB97C \uC785\uB825\uD558\uC138\uC694",
436
+ empty: "registry \uC8FC\uC18C\uB294 \uBE44\uC5B4 \uC788\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",
437
+ invalid: "\uC720\uD6A8\uD55C URL\uC744 \uC785\uB825\uD558\uC138\uC694"
438
+ },
439
+ publish: {
440
+ preview: "\uAC8C\uC2DC \uAD6C\uC131 \uBBF8\uB9AC\uBCF4\uAE30",
441
+ packageName: "\uD328\uD0A4\uC9C0 \uC774\uB984",
442
+ currentVersion: "\uD604\uC7AC \uBC84\uC804",
443
+ newVersion: "\uC0C8 \uBC84\uC804",
444
+ tag: "Tag",
445
+ changelog: "Changelog",
446
+ registry: "Registry",
447
+ pushTag: "Tag \uD478\uC2DC",
448
+ generateChangelog: "Changelog \uC0DD\uC131",
449
+ script: "\uC2A4\uD06C\uB9BD\uD2B8",
450
+ confirm: "\uAC8C\uC2DC\uB97C \uD655\uC778\uD558\uC2DC\uACA0\uC2B5\uB2C8\uAE4C?",
451
+ publishing: "npm\uC5D0 \uAC8C\uC2DC \uC911...",
452
+ success: "\uAC8C\uC2DC \uC131\uACF5!",
453
+ failed: "\uAC8C\uC2DC \uC2E4\uD328",
454
+ cancelled: "\uAC8C\uC2DC \uCDE8\uC18C\uB428",
455
+ error: "\uAC8C\uC2DC \uC911 \uC624\uB958 \uBC1C\uC0DD",
456
+ generalError: "\uC624\uB958",
457
+ npmPublishFailed: "npm \uAC8C\uC2DC \uC2E4\uD328, \uC885\uB8CC \uCF54\uB4DC: {exitCode}",
458
+ npmNotLoggedIn: "npm registry\uC5D0 \uB85C\uADF8\uC778\uD558\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4: {registry}\uFF0C\uBA3C\uC800 'npm login --registry {registry}'\uB97C \uC2E4\uD589\uD558\uC138\uC694",
459
+ npmAuthCheckFailed: "npm \uB85C\uADF8\uC778 \uC0C1\uD0DC \uD655\uC778 \uC2E4\uD328 (registry: {registry}): {error}",
460
+ needOtp: "npm \uAC8C\uC2DC \uC77C\uD68C\uC6A9 \uCF54\uB4DC(OTP)\uB97C \uC785\uB825\uD574\uC57C \uD569\uB2C8\uAE4C?",
461
+ inputOtp: "\uC77C\uD68C\uC6A9 \uCF54\uB4DC(OTP)\uB97C \uC785\uB825\uD558\uC138\uC694",
462
+ otpEmpty: "\uC77C\uD68C\uC6A9 \uCF54\uB4DC\uB294 \uBE44\uC5B4 \uC788\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",
463
+ otpInvalid: "\uC77C\uD68C\uC6A9 \uCF54\uB4DC\uB294 6\uC790\uB9AC \uC22B\uC790\uC5EC\uC57C \uD569\uB2C8\uB2E4",
464
+ otp: "\uC77C\uD68C\uC6A9 \uCF54\uB4DC(OTP)",
465
+ rollingBack: "\uAC8C\uC2DC \uC2E4\uD328, \uBCC0\uACBD \uC0AC\uD56D \uB864\uBC31 \uC911...",
466
+ rollbackComplete: "\uB864\uBC31 \uC644\uB8CC",
467
+ rollbackFailed: "\uB864\uBC31 \uC2E4\uD328, \uBC84\uC804\uACFC changelog\uB97C \uC218\uB3D9\uC73C\uB85C \uBCF5\uC6D0\uD558\uC138\uC694:"
468
+ },
469
+ success: {
470
+ title: "\uAC8C\uC2DC \uC131\uACF5!",
471
+ packageName: "\uD328\uD0A4\uC9C0 \uC774\uB984",
472
+ version: "\uBC84\uC804",
473
+ registry: "Registry",
474
+ thanks: "bun-push\uB97C \uC0AC\uC6A9\uD574 \uC8FC\uC154\uC11C \uAC10\uC0AC\uD569\uB2C8\uB2E4!"
475
+ },
476
+ changelogTypes: {
477
+ added: "\uCD94\uAC00\uB428",
478
+ changed: "\uBCC0\uACBD\uB428",
479
+ deprecated: "\uC0AC\uC6A9 \uC911\uB2E8\uB428",
480
+ removed: "\uC81C\uAC70\uB428",
481
+ fixed: "\uC218\uC815\uB428",
482
+ security: "\uBCF4\uC548"
483
+ },
484
+ workspace: {
485
+ packageJsonNotFound: "package.json \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",
486
+ workspacesConfigInvalid: "workspaces \uAD6C\uC131\uC774 \uC720\uD6A8\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4",
487
+ packageNotFound: "\uD328\uD0A4\uC9C0\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",
488
+ packageNotFoundByPath: "\uACBD\uB85C {path}\uC5D0\uC11C \uD328\uD0A4\uC9C0\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",
489
+ monorepoRequiresPath: "monorepo \uBAA8\uB4DC\uC5D0\uC11C\uB294 packagePath\uB97C \uC9C0\uC815\uD558\uAC70\uB098 CLI \uBAA8\uB4DC\uB97C \uC0AC\uC6A9\uD574\uC57C \uD569\uB2C8\uB2E4"
490
+ }
491
+ };
492
+
493
+ // src/i18n/index.ts
494
+ var SUPPORTED_LANGUAGES = ["zh", "en", "ja", "ko"];
495
+ var translations = {
496
+ zh: zh_default,
497
+ en: en_default,
498
+ ja: ja_default,
499
+ ko: ko_default
500
+ };
501
+ var currentLanguage = "zh";
502
+ function detectLanguage() {
503
+ const envLang = process.env.LANG || process.env.LANGUAGE || process.env.LC_ALL || process.env.LC_MESSAGES || "";
504
+ if (envLang) {
505
+ const langMatch = envLang.match(/(?:^|_|-)(zh|en|ja|ko)(?:[._-]|$)/i);
506
+ if (langMatch) {
507
+ const lang = langMatch[1].toLowerCase();
508
+ if (SUPPORTED_LANGUAGES.includes(lang)) {
509
+ return lang;
510
+ }
511
+ }
512
+ }
513
+ try {
514
+ const locale = Intl.DateTimeFormat().resolvedOptions().locale;
515
+ const lang = locale.split("-")[0].toLowerCase();
516
+ if (SUPPORTED_LANGUAGES.includes(lang)) {
517
+ return lang;
518
+ }
519
+ } catch {}
520
+ try {
521
+ const collator = new Intl.Collator;
522
+ const locale = collator.resolvedOptions().locale;
523
+ const lang = locale.split("-")[0].toLowerCase();
524
+ if (SUPPORTED_LANGUAGES.includes(lang)) {
525
+ return lang;
526
+ }
527
+ } catch {}
528
+ return "zh";
529
+ }
530
+ function initLanguage() {
531
+ const envLang = process.env.BUN_PUSH_LANG;
532
+ if (envLang && SUPPORTED_LANGUAGES.includes(envLang)) {
533
+ currentLanguage = envLang;
534
+ return;
535
+ }
536
+ currentLanguage = detectLanguage();
537
+ }
538
+ function t(key, params) {
539
+ const keys = key.split(".");
540
+ let value = translations[currentLanguage];
541
+ for (const k of keys) {
542
+ if (value && typeof value === "object" && k in value) {
543
+ value = value[k];
544
+ } else {
545
+ if (currentLanguage !== "zh") {
546
+ value = translations.zh;
547
+ for (const k2 of keys) {
548
+ if (value && typeof value === "object" && k2 in value) {
549
+ value = value[k2];
550
+ } else {
551
+ return key;
552
+ }
553
+ }
554
+ } else {
555
+ return key;
556
+ }
557
+ }
558
+ }
559
+ let result = typeof value === "string" ? value : key;
560
+ if (params) {
561
+ for (const [paramKey, paramValue] of Object.entries(params)) {
562
+ result = result.replace(new RegExp(`\\{${paramKey}\\}`, "g"), String(paramValue));
563
+ }
564
+ }
565
+ return result;
566
+ }
567
+ initLanguage();
568
+
569
+ // src/utils/workspace.ts
570
+ function readPackageJson(path) {
571
+ const packageJsonPath = join(path, "package.json");
572
+ if (!existsSync(packageJsonPath)) {
573
+ return null;
574
+ }
575
+ try {
576
+ const content = readFileSync(packageJsonPath, "utf-8");
577
+ return JSON.parse(content);
578
+ } catch {
579
+ return null;
580
+ }
581
+ }
582
+ function isMonorepo(packageJson) {
583
+ if (packageJson.workspaces && Array.isArray(packageJson.workspaces)) {
584
+ return true;
585
+ }
586
+ if (packageJson.workspaces?.packages && Array.isArray(packageJson.workspaces.packages)) {
587
+ return true;
588
+ }
589
+ return false;
590
+ }
591
+ function parseWorkspacePatterns(workspaces) {
592
+ if (Array.isArray(workspaces)) {
593
+ return workspaces;
594
+ }
595
+ if (workspaces?.packages) {
596
+ return workspaces.packages;
597
+ }
598
+ return [];
599
+ }
600
+ function matchesPattern(path, pattern) {
601
+ const regex = pattern.replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\//g, "\\/");
602
+ return new RegExp(`^${regex}$`).test(path);
603
+ }
604
+ function scanPackages(rootPath, patterns, found = []) {
605
+ const rootPackageJson = readPackageJson(rootPath);
606
+ if (!rootPackageJson) {
607
+ return found;
608
+ }
609
+ function scanDirectory(dir, depth = 0) {
610
+ if (depth > 10)
611
+ return;
612
+ try {
613
+ const entries = readdirSync(dir);
614
+ for (const entry of entries) {
615
+ const fullPath = join(dir, entry);
616
+ const relativePath = fullPath.startsWith(rootPath) ? fullPath.slice(rootPath.length).replace(/^[/\\]/, "") : fullPath;
617
+ if (entry.startsWith(".") || entry === "node_modules") {
618
+ continue;
619
+ }
620
+ const stat = statSync(fullPath);
621
+ if (stat.isDirectory()) {
622
+ const matches = patterns.some((pattern) => matchesPattern(relativePath, pattern));
623
+ if (matches) {
624
+ const packageJson = readPackageJson(fullPath);
625
+ if (packageJson && packageJson.name) {
626
+ found.push({
627
+ name: packageJson.name,
628
+ version: packageJson.version || "0.0.0",
629
+ path: fullPath,
630
+ packageJson
631
+ });
632
+ }
633
+ } else {
634
+ scanDirectory(fullPath, depth + 1);
635
+ }
636
+ }
637
+ }
638
+ } catch (error) {}
639
+ }
640
+ scanDirectory(rootPath);
641
+ return found;
642
+ }
643
+ function getWorkspaceInfo(workingDir = process.cwd()) {
644
+ const rootPath = resolve(workingDir);
645
+ const rootPackageJson = readPackageJson(rootPath);
646
+ if (!rootPackageJson) {
647
+ throw new Error(t("workspace.packageJsonNotFound"));
648
+ }
649
+ const isMonorepoProject = isMonorepo(rootPackageJson);
650
+ if (!isMonorepoProject) {
651
+ return {
652
+ isMonorepo: false,
653
+ packages: [
654
+ {
655
+ name: rootPackageJson.name || "unknown",
656
+ version: rootPackageJson.version || "0.0.0",
657
+ path: rootPath,
658
+ packageJson: rootPackageJson
659
+ }
660
+ ],
661
+ rootPackageJson,
662
+ rootPath
663
+ };
664
+ }
665
+ const workspaceConfig = rootPackageJson.workspaces;
666
+ const patterns = parseWorkspacePatterns(workspaceConfig);
667
+ if (patterns.length === 0) {
668
+ throw new Error(t("workspace.workspacesConfigInvalid"));
669
+ }
670
+ const packages = scanPackages(rootPath, patterns);
671
+ if (packages.length === 0 && rootPackageJson.name) {
672
+ packages.push({
673
+ name: rootPackageJson.name,
674
+ version: rootPackageJson.version || "0.0.0",
675
+ path: rootPath,
676
+ packageJson: rootPackageJson
677
+ });
678
+ }
679
+ return {
680
+ isMonorepo: true,
681
+ packages,
682
+ rootPackageJson,
683
+ rootPath
684
+ };
685
+ }
686
+
687
+ // src/prompts.ts
688
+ import prompts from "prompts";
689
+ import chalk from "chalk";
690
+
691
+ // src/utils/version.ts
692
+ import semver from "semver";
693
+ var RELEASE_TYPES = ["patch", "minor", "major"];
694
+ function getNextVersion(currentVersion, releaseType = "patch") {
695
+ if (!semver.valid(currentVersion)) {
696
+ throw new Error(t("version.invalidWithVersion", { version: currentVersion }));
697
+ }
698
+ const nextVersion = semver.inc(currentVersion, releaseType);
699
+ if (!nextVersion) {
700
+ throw new Error(t("version.cannotGenerate"));
701
+ }
702
+ return nextVersion;
703
+ }
704
+ function isValidVersion(version) {
705
+ if (!version || typeof version !== "string") {
706
+ return false;
707
+ }
708
+ const trimmed = version.trim();
709
+ if (!trimmed) {
710
+ return false;
711
+ }
712
+ const standardVersionPattern = /^\d+\.\d+\.\d+$/;
713
+ if (!standardVersionPattern.test(trimmed)) {
714
+ return false;
715
+ }
716
+ const valid = semver.valid(trimmed);
717
+ if (!valid) {
718
+ return false;
719
+ }
720
+ return valid === trimmed;
721
+ }
722
+ function generateTag(packageName, version) {
723
+ const nameWithoutScope = packageName.replace(/^@[^/]+\//, "");
724
+ return `${nameWithoutScope}@${version}`;
725
+ }
726
+ function getReleaseTypeDescription(type) {
727
+ const descriptions = {
728
+ patch: t("version.patch"),
729
+ minor: t("version.minor"),
730
+ major: t("version.major")
731
+ };
732
+ return descriptions[type];
733
+ }
734
+
735
+ // src/utils/scripts.ts
736
+ function getPackageScripts(packageInfo) {
737
+ const scripts = packageInfo.packageJson.scripts;
738
+ if (!scripts || typeof scripts !== "object") {
739
+ return [];
740
+ }
741
+ return Object.keys(scripts);
742
+ }
743
+ async function runScript(packageInfo, scriptName) {
744
+ const scripts = packageInfo.packageJson.scripts;
745
+ if (!scripts || !scripts[scriptName]) {
746
+ throw new Error(t("script.notFoundWithName", { name: scriptName }));
747
+ }
748
+ const proc = Bun.spawn(["bun", "run", scriptName], {
749
+ cwd: packageInfo.path,
750
+ stdout: "inherit",
751
+ stderr: "inherit"
752
+ });
753
+ const exitCode = await proc.exited;
754
+ if (exitCode !== 0) {
755
+ throw new Error(t("script.executionFailed", { exitCode }));
756
+ }
757
+ }
758
+
759
+ // src/prompts.ts
760
+ async function selectPackage(packages) {
761
+ if (packages.length === 1) {
762
+ return packages[0];
763
+ }
764
+ const { value } = await prompts({
765
+ type: "select",
766
+ name: "value",
767
+ message: t("package.selectPackage"),
768
+ choices: packages.map((pkg) => ({
769
+ title: `${pkg.name} (${pkg.version})`,
770
+ value: pkg,
771
+ description: pkg.path
772
+ }))
773
+ });
774
+ if (!value) {
775
+ process.exit(0);
776
+ }
777
+ return value;
778
+ }
779
+ function generateDefaultChangelog(packageName, currentVersion, newVersion) {
780
+ return t("changelog.defaultContent", { packageName, currentVersion, newVersion });
781
+ }
782
+ async function inputChangelog(packageName, currentVersion, newVersion) {
783
+ const { createInterface } = await import("readline");
784
+ const rl = createInterface({
785
+ input: process.stdin,
786
+ output: process.stdout
787
+ });
788
+ console.log(chalk.cyan(t("changelog.input")));
789
+ console.log(chalk.gray(t("changelog.singleLineHint")));
790
+ const lines = [];
791
+ let lineNumber = 1;
792
+ return new Promise((resolve2) => {
793
+ const promptLine = () => {
794
+ rl.setPrompt(chalk.gray(`[${lineNumber}] `));
795
+ rl.prompt();
796
+ };
797
+ promptLine();
798
+ rl.on("line", (line) => {
799
+ const trimmed = line.trim();
800
+ if (trimmed === "" && lines.length > 0) {
801
+ rl.close();
802
+ return;
803
+ }
804
+ if (trimmed === "" && lines.length === 0) {
805
+ rl.close();
806
+ return;
807
+ }
808
+ if (trimmed !== "") {
809
+ lines.push(trimmed);
810
+ lineNumber++;
811
+ promptLine();
812
+ }
813
+ });
814
+ rl.on("close", () => {
815
+ const result = lines.join(`
816
+ `).trim();
817
+ if (!result) {
818
+ const defaultChangelog = generateDefaultChangelog(packageName, currentVersion, newVersion);
819
+ console.log(chalk.yellow(t("changelog.usingDefault")));
820
+ resolve2(defaultChangelog);
821
+ return;
822
+ }
823
+ resolve2(result);
824
+ });
825
+ rl.on("SIGINT", () => {
826
+ rl.close();
827
+ process.exit(0);
828
+ });
829
+ });
830
+ }
831
+ async function confirmGenerateChangelog() {
832
+ const { value } = await prompts({
833
+ type: "confirm",
834
+ name: "value",
835
+ message: t("changelog.generate"),
836
+ initial: true
837
+ });
838
+ if (value === undefined) {
839
+ process.exit(0);
840
+ }
841
+ return value;
842
+ }
843
+ async function selectVersion(currentVersion) {
844
+ const choices = RELEASE_TYPES.map((type) => {
845
+ const nextVersion = getNextVersion(currentVersion, type);
846
+ return {
847
+ title: getReleaseTypeDescription(type),
848
+ value: type,
849
+ description: `${t("version.currentVersion")}: ${chalk.cyan(currentVersion)} \u2192 ${t("version.finalVersion")}: ${chalk.bold.green(nextVersion)}`
850
+ };
851
+ });
852
+ choices.push({
853
+ title: t("version.customVersion"),
854
+ value: "custom",
855
+ description: t("version.customVersionDesc")
856
+ });
857
+ const { value: releaseType } = await prompts({
858
+ type: "select",
859
+ name: "value",
860
+ message: `${t("version.currentVersion")}: ${chalk.cyan(currentVersion)} | ${t("version.selectType")}`,
861
+ choices
862
+ });
863
+ if (!releaseType) {
864
+ process.exit(0);
865
+ }
866
+ if (releaseType === "custom") {
867
+ const { value: customVersion } = await prompts({
868
+ type: "text",
869
+ name: "value",
870
+ message: `${t("version.inputVersion")} ${chalk.gray(`(${t("version.example")}: 1.0.0-beta.1)`)}`,
871
+ validate: (input) => {
872
+ const trimmed = input.trim();
873
+ if (!trimmed) {
874
+ return t("version.versionEmpty");
875
+ }
876
+ if (!isValidVersion(trimmed)) {
877
+ return t("version.invalidWithVersion", { version: trimmed });
878
+ }
879
+ return true;
880
+ }
881
+ });
882
+ if (!customVersion) {
883
+ process.exit(0);
884
+ }
885
+ const trimmedVersion = customVersion.trim();
886
+ if (!isValidVersion(trimmedVersion)) {
887
+ throw new Error(t("version.invalidWithVersion", { version: trimmedVersion }));
888
+ }
889
+ return {
890
+ version: trimmedVersion,
891
+ releaseType: "custom"
892
+ };
893
+ }
894
+ if (RELEASE_TYPES.includes(releaseType)) {
895
+ return {
896
+ version: getNextVersion(currentVersion, releaseType),
897
+ releaseType
898
+ };
899
+ }
900
+ throw new Error(t("version.unsupportedTypeWithType", { type: releaseType }));
901
+ }
902
+ async function selectScript(packageInfo) {
903
+ const scripts = getPackageScripts(packageInfo);
904
+ if (scripts.length === 0) {
905
+ return;
906
+ }
907
+ const choices = scripts.map((script) => ({
908
+ title: script,
909
+ value: script
910
+ }));
911
+ choices.push({
912
+ title: t("common.skip"),
913
+ value: "skip"
914
+ });
915
+ const { value: answer } = await prompts({
916
+ type: "select",
917
+ name: "value",
918
+ message: t("script.select"),
919
+ choices
920
+ });
921
+ if (!answer) {
922
+ process.exit(0);
923
+ }
924
+ return answer === "skip" ? undefined : answer;
925
+ }
926
+ async function confirmPushTag() {
927
+ const { value } = await prompts({
928
+ type: "confirm",
929
+ name: "value",
930
+ message: t("git.pushTag"),
931
+ initial: true
932
+ });
933
+ if (value === undefined) {
934
+ process.exit(0);
935
+ }
936
+ return value;
937
+ }
938
+ async function confirmOtp() {
939
+ const { value: needOtp } = await prompts({
940
+ type: "confirm",
941
+ name: "value",
942
+ message: t("publish.needOtp"),
943
+ initial: false
944
+ });
945
+ if (needOtp === undefined) {
946
+ process.exit(0);
947
+ }
948
+ if (!needOtp) {
949
+ return;
950
+ }
951
+ const { value: otp } = await prompts({
952
+ type: "text",
953
+ name: "value",
954
+ message: t("publish.inputOtp"),
955
+ validate: (input) => {
956
+ const trimmed = input.trim();
957
+ if (!trimmed) {
958
+ return t("publish.otpEmpty");
959
+ }
960
+ if (!/^\d{6}$/.test(trimmed)) {
961
+ return t("publish.otpInvalid");
962
+ }
963
+ return true;
964
+ }
965
+ });
966
+ if (!otp) {
967
+ process.exit(0);
968
+ }
969
+ return otp.trim();
970
+ }
971
+ async function confirmRegistry() {
972
+ const { value } = await prompts({
973
+ type: "text",
974
+ name: "value",
975
+ message: t("registry.input"),
976
+ initial: process.env.NPM_CONFIG_REGISTRY || "https://registry.npmjs.org/",
977
+ validate: (input) => {
978
+ if (!input.trim()) {
979
+ return t("registry.empty");
980
+ }
981
+ try {
982
+ new URL(input);
983
+ return true;
984
+ } catch {
985
+ return t("registry.invalid");
986
+ }
987
+ }
988
+ });
989
+ if (!value) {
990
+ process.exit(0);
991
+ }
992
+ return value.trim();
993
+ }
994
+ async function confirmPublish(config) {
995
+ console.log(chalk.bold(`
996
+ \uD83D\uDCE6 ${t("publish.preview")}`));
997
+ console.log(chalk.gray("\u2500".repeat(50)));
998
+ console.log(chalk.cyan(`${t("publish.packageName")}:`), config.package.name);
999
+ console.log(chalk.cyan(`${t("publish.currentVersion")}:`), config.package.version);
1000
+ console.log(chalk.cyan(`${t("publish.newVersion")}:`), config.newVersion);
1001
+ console.log(chalk.cyan(`${t("publish.tag")}:`), config.tag);
1002
+ console.log(chalk.cyan(`${t("publish.changelog")}:`), config.changelog);
1003
+ console.log(chalk.cyan(`${t("publish.registry")}:`), config.registry);
1004
+ console.log(chalk.cyan(`${t("publish.pushTag")}:`), config.pushTag ? t("common.yes") : t("common.no"));
1005
+ console.log(chalk.cyan(`${t("publish.generateChangelog")}:`), config.generateChangelog ? t("common.yes") : t("common.no"));
1006
+ if (config.otp) {
1007
+ console.log(chalk.cyan(`${t("publish.otp")}:`), chalk.gray("***"));
1008
+ }
1009
+ if (config.script) {
1010
+ console.log(chalk.cyan(`${t("publish.script")}:`), config.script);
1011
+ }
1012
+ console.log(chalk.gray("\u2500".repeat(50)));
1013
+ const { value } = await prompts({
1014
+ type: "confirm",
1015
+ name: "value",
1016
+ message: t("publish.confirm"),
1017
+ initial: true
1018
+ });
1019
+ if (value === undefined) {
1020
+ process.exit(0);
1021
+ }
1022
+ return value;
1023
+ }
1024
+
1025
+ // src/publisher.ts
1026
+ import { writeFileSync as writeFileSync2, readFileSync as readFileSync3, existsSync as existsSync3, unlinkSync } from "fs";
1027
+ import { join as join3 } from "path";
1028
+
1029
+ // src/utils/changelog.ts
1030
+ import { readFileSync as readFileSync2, writeFileSync, existsSync as existsSync2 } from "fs";
1031
+ import { join as join2 } from "path";
1032
+ function formatChangelogEntry(entry) {
1033
+ const typeLabels = {
1034
+ added: t("changelogTypes.added"),
1035
+ changed: t("changelogTypes.changed"),
1036
+ deprecated: t("changelogTypes.deprecated"),
1037
+ removed: t("changelogTypes.removed"),
1038
+ fixed: t("changelogTypes.fixed"),
1039
+ security: t("changelogTypes.security")
1040
+ };
1041
+ return `- ${typeLabels[entry.type]}: ${entry.description}`;
1042
+ }
1043
+ function parseChangelog(changelogText) {
1044
+ const entries = [];
1045
+ const lines = changelogText.split(`
1046
+ `).filter((line) => line.trim());
1047
+ const typeMaps = {
1048
+ zh: { \u{65b0}\u{589e}: "added", \u{53d8}\u{66f4}: "changed", \u{5e9f}\u{5f03}: "deprecated", \u{79fb}\u{9664}: "removed", \u{4fee}\u{590d}: "fixed", \u{5b89}\u{5168}: "security" },
1049
+ en: { Added: "added", Changed: "changed", Deprecated: "deprecated", Removed: "removed", Fixed: "fixed", Security: "security" },
1050
+ ja: { \u{8ffd}\u{52a0}: "added", \u{5909}\u{66f4}: "changed", \u{975e}\u{63a8}\u{5968}: "deprecated", \u{524a}\u{9664}: "removed", \u{4fee}\u{6b63}: "fixed", \u{30bb}\u{30ad}\u{30e5}\u{30ea}\u{30c6}\u{30a3}: "security" },
1051
+ ko: { \u{cd94}\u{ac00}\u{b428}: "added", \u{bcc0}\u{acbd}\u{b428}: "changed", \u{c0ac}\u{c6a9}\u{c911}\u{b2e8}\u{b428}: "deprecated", \u{c81c}\u{ac70}\u{b428}: "removed", \u{c218}\u{c815}\u{b428}: "fixed", \u{bcf4}\u{c548}: "security" }
1052
+ };
1053
+ const allTypeLabels = [];
1054
+ for (const langMap of Object.values(typeMaps)) {
1055
+ allTypeLabels.push(...Object.keys(langMap));
1056
+ }
1057
+ const typePattern = allTypeLabels.join("|");
1058
+ for (const line of lines) {
1059
+ const matchWithDash = line.match(new RegExp(`^-\\s*(${typePattern}):\\s*(.+)$`));
1060
+ if (matchWithDash) {
1061
+ const [, typeLabel, description] = matchWithDash;
1062
+ let type;
1063
+ for (const langMap of Object.values(typeMaps)) {
1064
+ if (typeLabel in langMap) {
1065
+ type = langMap[typeLabel];
1066
+ break;
1067
+ }
1068
+ }
1069
+ if (type) {
1070
+ entries.push({ type, description: description.trim() });
1071
+ continue;
1072
+ }
1073
+ }
1074
+ const matchWithoutDash = line.match(new RegExp(`^(${typePattern}):\\s*(.+)$`));
1075
+ if (matchWithoutDash) {
1076
+ const [, typeLabel, description] = matchWithoutDash;
1077
+ let type;
1078
+ for (const langMap of Object.values(typeMaps)) {
1079
+ if (typeLabel in langMap) {
1080
+ type = langMap[typeLabel];
1081
+ break;
1082
+ }
1083
+ }
1084
+ if (type) {
1085
+ entries.push({ type, description: description.trim() });
1086
+ continue;
1087
+ }
1088
+ }
1089
+ if (line.trim().startsWith("-")) {
1090
+ const description = line.replace(/^-\s*/, "").trim();
1091
+ if (description) {
1092
+ entries.push({ type: "added", description });
1093
+ continue;
1094
+ }
1095
+ }
1096
+ const trimmedLine = line.trim();
1097
+ if (trimmedLine) {
1098
+ entries.push({ type: "added", description: trimmedLine });
1099
+ }
1100
+ }
1101
+ return entries;
1102
+ }
1103
+ function generateChangelogSection(version, date, entries) {
1104
+ const sections = {
1105
+ added: [],
1106
+ changed: [],
1107
+ deprecated: [],
1108
+ removed: [],
1109
+ fixed: [],
1110
+ security: []
1111
+ };
1112
+ for (const entry of entries) {
1113
+ sections[entry.type].push(formatChangelogEntry(entry));
1114
+ }
1115
+ const lines = [];
1116
+ lines.push(`## [${version}] - ${date}`);
1117
+ lines.push("");
1118
+ const typeOrder = ["added", "changed", "deprecated", "removed", "fixed", "security"];
1119
+ for (const type of typeOrder) {
1120
+ if (sections[type].length > 0) {
1121
+ const typeLabels = {
1122
+ added: `### ${t("changelogTypes.added")}`,
1123
+ changed: `### ${t("changelogTypes.changed")}`,
1124
+ deprecated: `### ${t("changelogTypes.deprecated")}`,
1125
+ removed: `### ${t("changelogTypes.removed")}`,
1126
+ fixed: `### ${t("changelogTypes.fixed")}`,
1127
+ security: `### ${t("changelogTypes.security")}`
1128
+ };
1129
+ lines.push(typeLabels[type]);
1130
+ lines.push("");
1131
+ lines.push(...sections[type]);
1132
+ lines.push("");
1133
+ }
1134
+ }
1135
+ return lines.join(`
1136
+ `);
1137
+ }
1138
+ function readChangelog(packagePath) {
1139
+ const changelogPath = join2(packagePath, "CHANGELOG.md");
1140
+ if (!existsSync2(changelogPath)) {
1141
+ return "";
1142
+ }
1143
+ try {
1144
+ return readFileSync2(changelogPath, "utf-8");
1145
+ } catch {
1146
+ return "";
1147
+ }
1148
+ }
1149
+ function updateChangelog(packagePath, version, changelogText) {
1150
+ const changelogPath = join2(packagePath, "CHANGELOG.md");
1151
+ const existingContent = readChangelog(packagePath);
1152
+ const entries = parseChangelog(changelogText);
1153
+ const date = new Date().toISOString().split("T")[0];
1154
+ const newSection = generateChangelogSection(version, date, entries);
1155
+ let newContent = "";
1156
+ if (existingContent) {
1157
+ const versionMatch = existingContent.match(/^##\s+\[/m);
1158
+ if (versionMatch && versionMatch.index !== undefined) {
1159
+ newContent = existingContent.slice(0, versionMatch.index) + newSection + `
1160
+
1161
+ ` + existingContent.slice(versionMatch.index);
1162
+ } else {
1163
+ newContent = newSection + `
1164
+
1165
+ ` + existingContent;
1166
+ }
1167
+ } else {
1168
+ const lang = t("common.yes") === "\u662F" ? "zh-CN" : t("common.yes") === "Yes" ? "en" : t("common.yes") === "\u306F\u3044" ? "ja" : "ko";
1169
+ const headers = {
1170
+ "zh-CN": `# Changelog
1171
+
1172
+ \u6240\u6709\u91CD\u8981\u7684\u9879\u76EE\u53D8\u66F4\u90FD\u4F1A\u8BB0\u5F55\u5728\u8FD9\u4E2A\u6587\u4EF6\u4E2D\u3002
1173
+
1174
+ \u683C\u5F0F\u57FA\u4E8E [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/)\uFF0C
1175
+ \u672C\u9879\u76EE\u9075\u5FAA [\u8BED\u4E49\u5316\u7248\u672C](https://semver.org/lang/zh-CN/)\u3002
1176
+
1177
+ `,
1178
+ en: `# Changelog
1179
+
1180
+ All notable changes to this project will be documented in this file.
1181
+
1182
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1183
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1184
+
1185
+ `,
1186
+ ja: `# Changelog
1187
+
1188
+ \u3053\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u91CD\u8981\u306A\u5909\u66F4\u306F\u3059\u3079\u3066\u3053\u306E\u30D5\u30A1\u30A4\u30EB\u306B\u8A18\u9332\u3055\u308C\u307E\u3059\u3002
1189
+
1190
+ \u5F62\u5F0F\u306F [Keep a Changelog](https://keepachangelog.com/ja/1.0.0/) \u306B\u57FA\u3065\u3044\u3066\u304A\u308A\u3001
1191
+ \u3053\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306F [\u30BB\u30DE\u30F3\u30C6\u30A3\u30C3\u30AF\u30D0\u30FC\u30B8\u30E7\u30CB\u30F3\u30B0](https://semver.org/lang/ja/) \u306B\u6E96\u62E0\u3057\u3066\u3044\u307E\u3059\u3002
1192
+
1193
+ `,
1194
+ ko: `# Changelog
1195
+
1196
+ \uC774 \uD504\uB85C\uC81D\uD2B8\uC758 \uBAA8\uB4E0 \uC911\uC694\uD55C \uBCC0\uACBD \uC0AC\uD56D\uC740 \uC774 \uD30C\uC77C\uC5D0 \uAE30\uB85D\uB429\uB2C8\uB2E4.
1197
+
1198
+ \uD615\uC2DD\uC740 [Keep a Changelog](https://keepachangelog.com/ko/1.0.0/)\uB97C \uAE30\uBC18\uC73C\uB85C \uD558\uBA70,
1199
+ \uC774 \uD504\uB85C\uC81D\uD2B8\uB294 [\uC2DC\uB9E8\uD2F1 \uBC84\uC804 \uAD00\uB9AC](https://semver.org/lang/ko/)\uB97C \uC900\uC218\uD569\uB2C8\uB2E4.
1200
+
1201
+ `
1202
+ };
1203
+ newContent = `${headers[lang] || headers.en}${newSection}
1204
+ `;
1205
+ }
1206
+ writeFileSync(changelogPath, newContent, "utf-8");
1207
+ }
1208
+
1209
+ // src/publisher.ts
1210
+ function readPackageVersion(packagePath) {
1211
+ const packageJsonPath = join3(packagePath, "package.json");
1212
+ const packageJson = JSON.parse(readFileSync3(packageJsonPath, "utf-8"));
1213
+ return packageJson.version;
1214
+ }
1215
+ function updatePackageVersion(packagePath, newVersion) {
1216
+ const packageJsonPath = join3(packagePath, "package.json");
1217
+ const packageJson = JSON.parse(readFileSync3(packageJsonPath, "utf-8"));
1218
+ packageJson.version = newVersion;
1219
+ writeFileSync2(packageJsonPath, JSON.stringify(packageJson, null, 2) + `
1220
+ `, "utf-8");
1221
+ }
1222
+ function restorePackageVersion(packagePath, oldVersion) {
1223
+ updatePackageVersion(packagePath, oldVersion);
1224
+ }
1225
+ function restoreChangelog(packagePath, oldContent) {
1226
+ const changelogPath = join3(packagePath, "CHANGELOG.md");
1227
+ if (oldContent === "") {
1228
+ if (existsSync3(changelogPath)) {
1229
+ try {
1230
+ unlinkSync(changelogPath);
1231
+ } catch (error) {
1232
+ writeFileSync2(changelogPath, "", "utf-8");
1233
+ }
1234
+ }
1235
+ } else {
1236
+ writeFileSync2(changelogPath, oldContent, "utf-8");
1237
+ }
1238
+ }
1239
+ async function createGitTag(tag) {
1240
+ const proc = Bun.spawn(["git", "tag", tag], {
1241
+ stdout: "inherit",
1242
+ stderr: "inherit"
1243
+ });
1244
+ const exitCode = await proc.exited;
1245
+ if (exitCode !== 0) {
1246
+ throw new Error(t("git.createTagFailed", { exitCode }));
1247
+ }
1248
+ }
1249
+ async function deleteGitTag(tag) {
1250
+ const proc = Bun.spawn(["git", "tag", "-d", tag], {
1251
+ stdout: "pipe",
1252
+ stderr: "pipe"
1253
+ });
1254
+ await proc.exited;
1255
+ }
1256
+ async function pushGitTag(tag) {
1257
+ const proc = Bun.spawn(["git", "push", "origin", tag], {
1258
+ stdout: "inherit",
1259
+ stderr: "inherit"
1260
+ });
1261
+ const exitCode = await proc.exited;
1262
+ if (exitCode !== 0) {
1263
+ throw new Error(t("git.pushTagFailed", { exitCode }));
1264
+ }
1265
+ }
1266
+ async function checkNpmAuth(registry) {
1267
+ const proc = Bun.spawn(["bun", "pm", "whoami"], {
1268
+ stdout: "pipe",
1269
+ stderr: "pipe"
1270
+ });
1271
+ const exitCode = await proc.exited;
1272
+ if (exitCode !== 0) {
1273
+ const stderr = await new Response(proc.stderr).text();
1274
+ const errorMsg = stderr.trim();
1275
+ if (errorMsg.includes("not logged in") || errorMsg.includes("Unauthorized") || errorMsg === "") {
1276
+ throw new Error(t("publish.npmNotLoggedIn", { registry }));
1277
+ }
1278
+ throw new Error(t("publish.npmAuthCheckFailed", { registry, error: errorMsg }));
1279
+ }
1280
+ const stdout = await new Response(proc.stdout).text();
1281
+ const username = stdout.trim();
1282
+ if (!username) {
1283
+ throw new Error(t("publish.npmNotLoggedIn", { registry }));
1284
+ }
1285
+ }
1286
+ async function publishToNpm(packagePath, registry, otp) {
1287
+ const args = ["bun", "publish", "--registry", registry];
1288
+ if (otp) {
1289
+ args.push("--otp", otp);
1290
+ }
1291
+ const proc = Bun.spawn(args, {
1292
+ cwd: packagePath,
1293
+ stdout: "inherit",
1294
+ stderr: "inherit",
1295
+ env: {
1296
+ ...process.env,
1297
+ NPM_CONFIG_REGISTRY: registry
1298
+ }
1299
+ });
1300
+ const exitCode = await proc.exited;
1301
+ if (exitCode !== 0) {
1302
+ return Promise.reject(new Error(t("publish.npmPublishFailed", { exitCode })));
1303
+ }
1304
+ }
1305
+ async function publish(config) {
1306
+ const originalVersion = readPackageVersion(config.package.path);
1307
+ const originalChangelog = config.generateChangelog ? readChangelog(config.package.path) : "";
1308
+ let gitTagCreated = false;
1309
+ try {
1310
+ updatePackageVersion(config.package.path, config.newVersion);
1311
+ if (config.generateChangelog) {
1312
+ updateChangelog(config.package.path, config.newVersion, config.changelog);
1313
+ }
1314
+ await checkNpmAuth(config.registry);
1315
+ if (config.pushTag) {
1316
+ await createGitTag(config.tag);
1317
+ gitTagCreated = true;
1318
+ }
1319
+ await publishToNpm(config.package.path, config.registry, config.otp);
1320
+ if (config.pushTag) {
1321
+ await pushGitTag(config.tag);
1322
+ }
1323
+ } catch (error) {
1324
+ console.error(t("publish.rollingBack") || "\u53D1\u5E03\u5931\u8D25\uFF0C\u6B63\u5728\u56DE\u6EDA\u4FEE\u6539...");
1325
+ try {
1326
+ restorePackageVersion(config.package.path, originalVersion);
1327
+ if (config.generateChangelog) {
1328
+ restoreChangelog(config.package.path, originalChangelog);
1329
+ }
1330
+ if (gitTagCreated) {
1331
+ await deleteGitTag(config.tag);
1332
+ }
1333
+ console.error(t("publish.rollbackComplete") || "\u56DE\u6EDA\u5B8C\u6210");
1334
+ } catch (rollbackError) {
1335
+ console.error(t("publish.rollbackFailed") || "\u56DE\u6EDA\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u6062\u590D\u7248\u672C\u53F7\u548C changelog:", rollbackError);
1336
+ }
1337
+ throw error;
1338
+ }
1339
+ }
1340
+
1341
+ // src/logo.ts
1342
+ import chalk2 from "chalk";
1343
+ import figlet from "figlet";
1344
+ function showLogo() {
1345
+ try {
1346
+ const asciiText = figlet.textSync("bun-push", {
1347
+ font: "Standard",
1348
+ horizontalLayout: "default",
1349
+ verticalLayout: "default"
1350
+ });
1351
+ const lines = asciiText.split(`
1352
+ `).filter((line) => line.trim().length > 0);
1353
+ if (lines.length === 0) {
1354
+ console.log(chalk2.cyan.bold(`
1355
+ bun-push
1356
+ `));
1357
+ return;
1358
+ }
1359
+ const coloredLines = lines.map((line, index) => {
1360
+ const midPoint = Math.floor(line.length / 2);
1361
+ if (index < lines.length / 2) {
1362
+ return chalk2.red(line.substring(0, midPoint)) + chalk2.yellow(line.substring(midPoint));
1363
+ } else {
1364
+ return chalk2.magenta(line.substring(0, midPoint)) + chalk2.blue(line.substring(midPoint));
1365
+ }
1366
+ });
1367
+ const logo = `
1368
+ ` + coloredLines.join(`
1369
+ `) + `
1370
+ `;
1371
+ console.log(logo);
1372
+ } catch (error) {
1373
+ console.log(chalk2.cyan.bold(`
1374
+ bun-push
1375
+ `));
1376
+ }
1377
+ }
1378
+ function showSuccessMessage(packageName, version, registry) {
1379
+ console.log(chalk2.green.bold(`
1380
+ \u2705 ${t("success.title")}
1381
+ `));
1382
+ console.log(chalk2.gray("\u2500".repeat(60)));
1383
+ console.log(chalk2.cyan.bold(`\uD83D\uDCE6 ${t("success.packageName")}:`), chalk2.white(packageName));
1384
+ console.log(chalk2.cyan.bold(`\uD83C\uDFF7\uFE0F ${t("success.version")}:`), chalk2.white(version));
1385
+ console.log(chalk2.cyan.bold(`\uD83C\uDF10 ${t("success.registry")}:`), chalk2.white(registry));
1386
+ console.log(chalk2.gray("\u2500".repeat(60)));
1387
+ console.log(chalk2.green(`
1388
+ \uD83C\uDF89 ${t("success.thanks")}
1389
+ `));
1390
+ }
1391
+
1392
+ // src/cli.ts
1393
+ async function main() {
1394
+ try {
1395
+ showLogo();
1396
+ const workspaceInfo = getWorkspaceInfo();
1397
+ let selectedPackage;
1398
+ if (workspaceInfo.isMonorepo) {
1399
+ selectedPackage = await selectPackage(workspaceInfo.packages);
1400
+ } else {
1401
+ selectedPackage = workspaceInfo.packages[0];
1402
+ }
1403
+ console.log(chalk3.green(`
1404
+ \u2705 ${t("package.selectedPackage")}: ${chalk3.bold(selectedPackage.name)} (${selectedPackage.version})`));
1405
+ const { version: newVersion } = await selectVersion(selectedPackage.version);
1406
+ const changelog = await inputChangelog(selectedPackage.name, selectedPackage.version, newVersion);
1407
+ const tag = generateTag(selectedPackage.name, newVersion);
1408
+ const script = await selectScript(selectedPackage);
1409
+ if (script) {
1410
+ const spinner = ora(`${t("script.running")}: ${chalk3.cyan(script)}`).start();
1411
+ try {
1412
+ await runScript(selectedPackage, script);
1413
+ spinner.succeed(`${t("script.success")}: ${chalk3.cyan(script)}`);
1414
+ } catch (error) {
1415
+ spinner.fail(`${t("script.failed")}: ${chalk3.red(script)}`);
1416
+ throw error;
1417
+ }
1418
+ }
1419
+ const pushTag = await confirmPushTag();
1420
+ const registry = await confirmRegistry();
1421
+ const generateChangelog = await confirmGenerateChangelog();
1422
+ const otp = await confirmOtp();
1423
+ const config = {
1424
+ package: selectedPackage,
1425
+ changelog,
1426
+ newVersion,
1427
+ tag,
1428
+ script,
1429
+ pushTag,
1430
+ registry,
1431
+ generateChangelog,
1432
+ otp
1433
+ };
1434
+ const confirmed = await confirmPublish(config);
1435
+ if (!confirmed) {
1436
+ console.log(chalk3.yellow(`
1437
+ \u274C ${t("publish.cancelled")}`));
1438
+ process.exit(0);
1439
+ }
1440
+ const publishSpinner = ora(t("publish.publishing")).start();
1441
+ try {
1442
+ await publish(config);
1443
+ publishSpinner.succeed(t("publish.success"));
1444
+ showSuccessMessage(selectedPackage.name, newVersion, registry);
1445
+ } catch (error) {
1446
+ publishSpinner.fail(t("publish.failed"));
1447
+ console.error(chalk3.red(`
1448
+ \u274C ${t("publish.error")}:`), error);
1449
+ process.exit(1);
1450
+ }
1451
+ } catch (error) {
1452
+ console.error(chalk3.red(`
1453
+ \u274C ${t("publish.generalError")}:`), error);
1454
+ process.exit(1);
1455
+ }
1456
+ }
1457
+ main();
1458
+
1459
+ //# debugId=5DAA9E169C926ABE64756E2164756E21