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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 ccode
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,320 @@
1
+ # bun-push
2
+
3
+ <div align="center">
4
+
5
+ **一个支持 monorepo 和单仓库的 npm 包发布工具,支持 CLI 和 JS API 两种使用方式**
6
+
7
+ 🇨🇳 **中文** | [🇺🇸 English](docs/README.en.md) | [🇯🇵 日本語](docs/README.ja.md) | [🇰🇷 한국어](docs/README.ko.md)
8
+
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
10
+ [![Bun](https://img.shields.io/badge/Bun-1.3.0+-black?logo=bun)](https://bun.sh)
11
+
12
+ </div>
13
+
14
+ ---
15
+
16
+ ## ✨ 特性
17
+
18
+ - 🎯 **支持 Monorepo 和单仓库**:自动检测项目类型,支持 workspace 模式
19
+ - 📦 **交互式发布流程**:友好的命令行交互界面
20
+ - 🔄 **自动化版本管理**:支持语义化版本(semver)
21
+ - 🏷️ **Git Tag 管理**:自动创建和推送 git tag
22
+ - 📝 **Changelog 支持**:发布前记录变更日志,自动生成 CHANGELOG.md 文件
23
+ - 🛠️ **脚本执行**:支持发布前执行构建脚本(如 build)
24
+ - 🎨 **美观的 UI**:带有 loading 动画和成功提示
25
+ - 📚 **JS API**:同时提供程序化 API 供 Node.js 脚本使用
26
+ - 🌍 **多语言支持**:支持中文、英文、日语、韩语,默认使用中文
27
+
28
+ ## 📦 安装
29
+
30
+ ```bash
31
+ # 使用 bun
32
+ bun add -g bun-push
33
+
34
+ # 或使用 npm
35
+ npm install -g bun-push
36
+
37
+ # 或使用 yarn
38
+ yarn global add bun-push
39
+
40
+ # 或使用 pnpm
41
+ pnpm add -g bun-push
42
+ ```
43
+
44
+ ## 🌍 多语言支持
45
+
46
+ bun-push 支持以下语言:
47
+ - 🇨🇳 中文 (Chinese) - **默认语言**
48
+ - 🇺🇸 English
49
+ - 🇯🇵 日本語 (Japanese)
50
+ - 🇰🇷 한국어 (Korean)
51
+
52
+ ### 语言设置
53
+
54
+ 工具默认使用中文。如果需要手动指定语言,可以通过环境变量设置:
55
+
56
+ ```bash
57
+ # 设置语言为英文
58
+ export BUN_PUSH_LANG=en
59
+ bun-push
60
+
61
+ # 设置语言为日语
62
+ export BUN_PUSH_LANG=ja
63
+ bun-push
64
+
65
+ # 设置语言为韩语
66
+ export BUN_PUSH_LANG=ko
67
+ bun-push
68
+
69
+ # 设置语言为中文
70
+ export BUN_PUSH_LANG=zh
71
+ bun-push
72
+ ```
73
+
74
+ ## 🚀 使用
75
+
76
+ ### CLI 方式
77
+
78
+ 在项目根目录运行:
79
+
80
+ ```bash
81
+ bun-push
82
+ ```
83
+
84
+ CLI 会引导您完成以下流程:
85
+
86
+ 1. **选择包**(monorepo 模式下)
87
+ - 自动检测 workspace 配置
88
+ - 列出所有可发布的包供选择
89
+
90
+ 2. **填写 Changelog**
91
+ - 输入本次发布的变更说明
92
+ - 支持多行输入,每行一个条目
93
+ - 输入完成后,按 Enter 键(空行)结束输入
94
+ - 支持格式:`新增: 描述`、`修复: 描述`、`变更: 描述` 等
95
+ - 也支持简单格式:`- 描述`
96
+
97
+ 3. **选择版本类型**
98
+ - `patch`:补丁版本 (1.0.0 -> 1.0.1)
99
+ - `minor`:次版本 (1.0.0 -> 1.1.0)
100
+ - `major`:主版本 (1.0.0 -> 2.0.0)
101
+ - `custom`:自定义版本号
102
+
103
+ 4. **选择要执行的脚本**(可选)
104
+ - 通常选择 `build` 脚本进行构建
105
+ - 也可以跳过脚本执行
106
+
107
+ 5. **确认是否推送 Git Tag**
108
+ - 选择是否创建并推送 git tag
109
+
110
+ 6. **确认是否生成 CHANGELOG.md 文件**
111
+ - 选择是否自动生成或更新 CHANGELOG.md 文件
112
+ - 文件遵循 [Keep a Changelog](https://keepachangelog.com/) 格式
113
+
114
+ 7. **确认 npm Registry 地址**
115
+ - 默认使用官方 npm registry
116
+ - 可以切换到其他 registry(如私有 npm)
117
+
118
+ 8. **最终确认**
119
+ - 预览发布配置
120
+ - 确认后开始发布
121
+
122
+ ### JS API 方式
123
+
124
+ ```typescript
125
+ import { NpmPush, publishPackage } from "bun-push";
126
+
127
+ // 方式 1: 使用类
128
+ const npmPush = new NpmPush();
129
+
130
+ // 获取 workspace 信息
131
+ const workspaceInfo = npmPush.getWorkspaceInfo();
132
+ console.log("是否是 monorepo:", workspaceInfo.isMonorepo);
133
+
134
+ // 获取所有包
135
+ const packages = npmPush.getPackages();
136
+ console.log("包列表:", packages.map((pkg) => pkg.name));
137
+
138
+ // 查找包
139
+ const pkg = npmPush.findPackage("my-package");
140
+
141
+ // 发布包
142
+ await npmPush.publish({
143
+ packagePath: "./packages/my-package",
144
+ changelog: "修复: 修复了重要 bug",
145
+ version: "1.0.1",
146
+ script: "build",
147
+ pushTag: true,
148
+ registry: "https://registry.npmjs.org/",
149
+ generateChangelog: true, // 生成 CHANGELOG.md 文件
150
+ });
151
+
152
+ // 方式 2: 使用函数式 API
153
+ await publishPackage({
154
+ packagePath: "./packages/my-package",
155
+ changelog: "新增: 新功能\n修复: 修复了 bug",
156
+ version: "1.1.0",
157
+ script: "build",
158
+ pushTag: true,
159
+ registry: "https://registry.npmjs.org/",
160
+ generateChangelog: true, // 生成 CHANGELOG.md 文件
161
+ });
162
+ ```
163
+
164
+ ## 📖 API 文档
165
+
166
+ ### `NpmPush` 类
167
+
168
+ #### 构造函数
169
+
170
+ ```typescript
171
+ new NpmPush(workingDir?: string)
172
+ ```
173
+
174
+ - `workingDir`: 工作目录,默认为当前目录
175
+
176
+ #### 方法
177
+
178
+ ##### `getWorkspaceInfo()`
179
+
180
+ 获取 workspace 信息。
181
+
182
+ 返回类型:`WorkspaceInfo`
183
+
184
+ ##### `getPackages()`
185
+
186
+ 获取所有包列表。
187
+
188
+ 返回类型:`PackageInfo[]`
189
+
190
+ ##### `findPackage(packageName: string)`
191
+
192
+ 根据包名查找包。
193
+
194
+ 参数:
195
+ - `packageName`: 包名
196
+
197
+ 返回类型:`PackageInfo | undefined`
198
+
199
+ ##### `publish(options: PublishOptions)`
200
+
201
+ 发布包。
202
+
203
+ 参数:
204
+ - `options.packagePath?`: 包路径(monorepo 模式下必填)
205
+ - `options.skipConfirm?`: 是否跳过交互式确认
206
+ - `options.version?`: 自定义版本号
207
+ - `options.changelog?`: changelog 内容
208
+ - `options.tag?`: git tag 名称
209
+ - `options.script?`: 要执行的脚本
210
+ - `options.pushTag?`: 是否推送 git tag
211
+ - `options.registry?`: npm registry 地址
212
+ - `options.generateChangelog?`: 是否生成 CHANGELOG.md 文件
213
+
214
+ ### `publishPackage(options: PublishOptions)`
215
+
216
+ 发布包的函数式 API。
217
+
218
+ ## 📝 Changelog 格式
219
+
220
+ bun-push 支持自动生成符合 [Keep a Changelog](https://keepachangelog.com/) 规范的 CHANGELOG.md 文件。
221
+
222
+ ### 支持的格式
223
+
224
+ 1. **带类型的格式**(推荐):
225
+ ```
226
+ 新增: 添加了新功能
227
+ 修复: 修复了重要 bug
228
+ 变更: 改进了性能
229
+ 移除: 移除了废弃的 API
230
+ 安全: 修复了安全漏洞
231
+ ```
232
+
233
+ 2. **简单格式**:
234
+ ```
235
+ - 添加了新功能
236
+ - 修复了 bug
237
+ - 改进了性能
238
+ ```
239
+
240
+ ### Changelog 类型
241
+
242
+ - `新增` / `added`: 新功能
243
+ - `变更` / `changed`: 对现有功能的变更
244
+ - `废弃` / `deprecated`: 即将移除的功能
245
+ - `移除` / `removed`: 已移除的功能
246
+ - `修复` / `fixed`: Bug 修复
247
+ - `安全` / `security`: 安全相关的修复
248
+
249
+ 生成的 CHANGELOG.md 文件会自动按类型分组,并包含版本号和发布日期。
250
+
251
+ ## 🛠️ 开发
252
+
253
+ ```bash
254
+ # 克隆项目
255
+ git clone https://github.com/ccode/bun-push.git
256
+ cd bun-push
257
+
258
+ # 安装依赖
259
+ bun install
260
+
261
+ # 开发模式运行
262
+ bun run dev
263
+
264
+ # 构建
265
+ bun run build
266
+
267
+ # 运行测试
268
+ bun test
269
+
270
+ # 运行测试并查看覆盖率
271
+ bun test --coverage
272
+ ```
273
+
274
+ ## 📝 要求
275
+
276
+ - Bun >= 1.1.0
277
+ - TypeScript 5.7+
278
+
279
+ > 注意:这是一个完全的 Bun 项目,使用 Bun 的原生类型系统,不依赖 Node.js 类型定义。
280
+
281
+ ## 🤝 贡献
282
+
283
+ 欢迎提交 Issue 和 Pull Request!
284
+
285
+ 更多信息请参阅 [贡献指南](docs/.github/CONTRIBUTING.zh.md)。
286
+
287
+ ## 📄 许可证
288
+
289
+ 本项目采用 [MIT License](LICENSE) 许可证。
290
+
291
+ 完整的许可证文本请参阅 [LICENSE](LICENSE) 文件。更多法律相关信息,请参阅 [LEGAL.zh.md](docs/LEGAL.zh.md)。
292
+
293
+ ---
294
+
295
+ ## 📚 其他语言文档
296
+
297
+ 选择您的语言:
298
+
299
+ - 🇨🇳 **中文**(当前页面)
300
+ - 🇺🇸 [English](docs/README.en.md)
301
+ - 🇯🇵 [日本語ドキュメント](docs/README.ja.md)
302
+ - 🇰🇷 [한국어 문서](docs/README.ko.md)
303
+
304
+ ## ⚖️ 法律声明
305
+
306
+ - [法律声明 (中文)](docs/LEGAL.zh.md)
307
+ - [Legal Notice (English)](docs/LEGAL.en.md)
308
+ - [法律声明 (日本語)](docs/LEGAL.ja.md)
309
+ - [법적 고지 (한국어)](docs/LEGAL.ko.md)
310
+
311
+ ## 🤝 贡献指南
312
+
313
+ - [贡献指南 (中文)](docs/.github/CONTRIBUTING.zh.md)
314
+ - [Contributing Guide (English)](docs/.github/CONTRIBUTING.en.md)
315
+ - [貢献ガイド (日本語)](docs/.github/CONTRIBUTING.ja.md)
316
+ - [기여 가이드 (한국어)](docs/.github/CONTRIBUTING.ko.md)
317
+
318
+ ---
319
+
320
+ Copyright (c) 2024 ccode
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bun
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}