@vitarx/release-cli 1.0.1 → 1.0.3

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/README.md CHANGED
@@ -106,6 +106,7 @@ release-cli major --tag-prefix "v" --release-count 5
106
106
 
107
107
  | 选项 | 缩写 | 描述 | 默认值 |
108
108
  |-----------------------|------|--------------------------|----------------|
109
+ | `--version` | `-v` | 显示版本信息 | - |
109
110
  | `--help` | `-h` | 显示帮助信息 | - |
110
111
  | `--dry-run` | `-d` | 试运行模式,不实际执行操作 | `false` |
111
112
  | `--preid` | - | 预发布版本标识符(alpha/beta/rc) | - |
@@ -122,7 +123,7 @@ release-cli major --tag-prefix "v" --release-count 5
122
123
  | `--context` | `-c` | 模板变量上下文文件 | - |
123
124
  | `--commit-path` | - | 只生成指定目录的提交日志 | - |
124
125
  | `--tag-prefix` | - | Git 标签前缀 | `v` |
125
- | `--verbose` | `-v` | 详细输出模式 | `false` |
126
+ | `--verbose` | - | 详细输出模式 | `false` |
126
127
  | `--release-count` | - | 生成的发布记录数量 | `0` |
127
128
  | `--package` | - | 指定要发布的包名/包相对路径 | - |
128
129
 
package/dist/release.js CHANGED
@@ -3,6 +3,7 @@ import chalk from 'chalk';
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
5
  import process from 'node:process';
6
+ import { fileURLToPath, URL } from 'node:url';
6
7
  import { checkGitStatus, detectPackageManager, formatVersionNumber, getWorkspacePackages, isWorkspaceProject, log, prompt, rollbackChanges, runCommand, selectVersion, updateVersion } from './utils.js';
7
8
  /**
8
9
  * 解析命令行参数
@@ -15,6 +16,7 @@ function parseArgs() {
15
16
  const result = {
16
17
  isDryRun: false, // 是否为试运行模式
17
18
  showHelp: false, // 是否显示帮助信息
19
+ showVersion: false, // 是否显示版本信息
18
20
  changelogPreset: 'angular', // 更改日志预设模板
19
21
  changelogInfile: 'CHANGELOG.md', // 更改日志输入文件
20
22
  changelogSameFile: true, // 是否使用同一文件
@@ -27,6 +29,9 @@ function parseArgs() {
27
29
  if (arg === '--help' || arg === '-h') {
28
30
  result.showHelp = true;
29
31
  }
32
+ else if (arg === '--version' || arg === '-v') {
33
+ result.showVersion = true;
34
+ }
30
35
  else if (arg === '--dry-run' || arg === '-d') {
31
36
  result.isDryRun = true;
32
37
  }
@@ -75,7 +80,7 @@ function parseArgs() {
75
80
  else if (arg === '--tag-prefix' && args[i + 1]) {
76
81
  result.changelogTagPrefix = args[++i];
77
82
  }
78
- else if (arg === '--verbose' || arg === '-v') {
83
+ else if (arg === '--verbose') {
79
84
  result.changelogVerbose = true;
80
85
  }
81
86
  else if (arg === '--package' && args[i + 1]) {
@@ -215,8 +220,14 @@ async function publishPackage(pkgDir, packageManager, isDryRun = false, args) {
215
220
  */
216
221
  export async function main() {
217
222
  const args = parseArgs();
223
+ console.log(chalk.cyan('📦 Release CLI - NPM包发布工具'));
224
+ // 显示版本信息
225
+ if (args.showVersion) {
226
+ const { version } = JSON.parse(fs.readFileSync(fileURLToPath(new URL('../package.json', import.meta.url)), 'utf-8'));
227
+ console.log(version);
228
+ process.exit(0);
229
+ }
218
230
  if (args.showHelp) {
219
- console.log(chalk.cyan('📦 Release CLI - NPM包发布工具'));
220
231
  console.log('');
221
232
  console.log(chalk.yellow('使用方法:'));
222
233
  console.log(' release-cli [版本类型] [选项]');
@@ -234,6 +245,7 @@ export async function main() {
234
245
  console.log('');
235
246
  console.log(chalk.yellow('选项:'));
236
247
  console.log(' -h, --help - 显示帮助信息');
248
+ console.log(' -v, --version - 输出版本号');
237
249
  console.log(' -d, --dry-run - 试运行模式,不实际执行操作,(默认false)');
238
250
  console.log(' --preid <标识符> - 预发布版本标识符(alpha/beta/rc)');
239
251
  console.log(' --preset <预设> - conventional-changelog预设(默认: angular)');
@@ -249,7 +261,7 @@ export async function main() {
249
261
  console.log(' -c, --context <文件> - 模板变量上下文文件');
250
262
  console.log(' --commit-path <目录> - 只生成指定目录的提交日志');
251
263
  console.log(' --tag-prefix <前缀> - Git 标签前缀(默认: v)');
252
- console.log(' -v, --verbose - 详细输出模式');
264
+ console.log(' --verbose - 详细输出模式');
253
265
  console.log(' --release-count <数量> - 生成的发布记录数量(默认: 0)');
254
266
  console.log(' --package <包名> - 指定要发布的包名/包相对路径');
255
267
  console.log('');
@@ -267,9 +279,9 @@ export async function main() {
267
279
  }
268
280
  const packageManager = detectPackageManager();
269
281
  const isWorkspace = isWorkspaceProject();
270
- log.info(`当前包管理器: ${packageManager}`);
271
- log.info(`当前工作目录: ${process.cwd()}`);
272
- log.info(`当前运行模式: ${isDryRun ? 'dry-run' : 'publish'}`);
282
+ log.info('当前包管理器', packageManager);
283
+ log.info('当前工作目录', process.cwd());
284
+ log.info('当前运行模式', isDryRun ? 'dry-run' : 'publish');
273
285
  if (isWorkspace) {
274
286
  log.info('检测到 workspace 项目');
275
287
  const packages = getWorkspacePackages();
@@ -280,7 +292,10 @@ export async function main() {
280
292
  let selectedPackage;
281
293
  if (args.packageName) {
282
294
  // 如果指定了包名,查找对应的包(支持按包名或目录名匹配)
283
- selectedPackage = packages.find((pkg) => pkg.name === args.packageName || path.basename(pkg.path) === args.packageName);
295
+ selectedPackage = packages.find((pkg) => {
296
+ console.log(`正在匹配 ${path.basename(pkg.path)}`);
297
+ return pkg.name === args.packageName || path.basename(pkg.path) === args.packageName;
298
+ });
284
299
  if (!selectedPackage) {
285
300
  log.error(`未找到包名为 ${args.packageName} 的包`);
286
301
  process.exit(1);
package/dist/type.d.ts CHANGED
@@ -59,4 +59,6 @@ export interface ReleaseConfig {
59
59
  changelogVerbose?: boolean;
60
60
  /** 是否显示帮助信息 */
61
61
  showHelp: boolean;
62
+ /** 是否显示版本信息 */
63
+ showVersion: boolean;
62
64
  }
package/dist/utils.d.ts CHANGED
@@ -20,7 +20,7 @@ export declare function checkGitStatus(): boolean;
20
20
  * @property warn - 警告日志
21
21
  */
22
22
  export declare const log: {
23
- readonly info: (message: string) => void;
23
+ readonly info: (message: string, ...text: string[]) => void;
24
24
  readonly success: (message: string) => void;
25
25
  readonly error: (message: string) => void;
26
26
  readonly warn: (message: string) => void;
package/dist/utils.js CHANGED
@@ -49,17 +49,22 @@ export function checkGitStatus() {
49
49
  * @property warn - 警告日志
50
50
  */
51
51
  export const log = {
52
- info: (message) => {
53
- console.log(chalk.cyan(`Info:${message}`));
52
+ info: (message, ...text) => {
53
+ if (text.length) {
54
+ console.log(chalk.cyan(`📢 ${message}: `), ...text);
55
+ }
56
+ else {
57
+ console.log(`📢 ${message}`);
58
+ }
54
59
  },
55
60
  success: (message) => {
56
- console.log(chalk.green(`Success:✅ ${message}`));
61
+ console.log(chalk.green(`✅ ${message}`));
57
62
  },
58
63
  error: (message) => {
59
- console.log(chalk.red(`Error:❌ ${message}`));
64
+ console.log(chalk.red(`❌ ${message}`));
60
65
  },
61
66
  warn: (message) => {
62
- console.log(chalk.yellow(`Warn:⚠️ ${message}`));
67
+ console.log(chalk.yellow(`⚠️ ${message}`));
63
68
  }
64
69
  };
65
70
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitarx/release-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A CLI tool for automated npm package release with workspace support",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",