@agile-team/robot-cli 1.0.6 → 1.0.7

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 (2) hide show
  1. package/bin/index.js +31 -2
  2. package/package.json +1 -1
package/bin/index.js CHANGED
@@ -3,11 +3,40 @@
3
3
  import { fileURLToPath, pathToFileURL } from 'url';
4
4
  import { dirname, join, resolve } from 'path';
5
5
  import { existsSync } from 'fs';
6
+ import { readFileSync } from 'fs';
6
7
 
7
8
  // 获取当前文件的目录
8
9
  const __filename = fileURLToPath(import.meta.url);
9
10
  const __dirname = dirname(__filename);
10
11
 
12
+ /**
13
+ * 获取包版本号
14
+ */
15
+ function getPackageVersion() {
16
+ try {
17
+ // 尝试从多个位置读取 package.json
18
+ const possiblePaths = [
19
+ join(__dirname, '..', 'package.json'),
20
+ join(__dirname, 'package.json'),
21
+ join(__dirname, '..', '..', 'package.json')
22
+ ];
23
+
24
+ for (const packagePath of possiblePaths) {
25
+ if (existsSync(packagePath)) {
26
+ const packageJson = JSON.parse(readFileSync(packagePath, 'utf8'));
27
+ return packageJson.version || '1.0.0';
28
+ }
29
+ }
30
+
31
+ return '1.0.0'; // 默认版本
32
+ } catch (error) {
33
+ return '1.0.0'; // 出错时返回默认版本
34
+ }
35
+ }
36
+
37
+ // 获取版本号
38
+ const PACKAGE_VERSION = getPackageVersion();
39
+
11
40
  /**
12
41
  * 智能路径解析 - 兼容不同包管理器的安装路径
13
42
  */
@@ -159,7 +188,7 @@ async function main() {
159
188
 
160
189
  const titleBox = boxen(
161
190
  logo + '\n\n' +
162
- ' 🤖 Robot 项目脚手架工具 v1.0.4\n' +
191
+ ` 🤖 Robot 项目脚手架工具 v${PACKAGE_VERSION}\n` +
163
192
  ' 兼容 npm/yarn/pnpm/bun',
164
193
  {
165
194
  padding: { top: 1, bottom: 1, left: 2, right: 2 },
@@ -233,7 +262,7 @@ async function main() {
233
262
  program
234
263
  .name('robot')
235
264
  .description('🤖 Robot 项目脚手架工具 - @agile-team/robot-cli')
236
- .version('1.0.4')
265
+ .version(PACKAGE_VERSION) // 🎯 使用动态版本号
237
266
  .hook('preAction', () => {
238
267
  showWelcome();
239
268
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agile-team/robot-cli",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "🤖 现代化项目脚手架工具,支持多技术栈快速创建项目",
5
5
  "type": "module",
6
6
  "bin": {