@itbox/cli 0.0.1 → 0.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
@@ -194,15 +194,6 @@ itbox config help
194
194
  - 安装选择的包管理器:`npm install -g npm` 或 `npm install -g pnpm`
195
195
  - 检查包管理器是否在系统PATH中
196
196
 
197
- ## 更新日志
198
-
199
- ### v1.0.0
200
- - 初始版本发布
201
- - 支持从Gitee动态获取模板分支
202
- - 支持npm/pnpm包管理器选择
203
- - 实现配置管理功能
204
- - 支持 `pnpm create itbox` 调用方式
205
-
206
197
  ## License
207
198
 
208
199
  MIT
package/bin/index.js CHANGED
@@ -6,8 +6,11 @@ import path from 'path';
6
6
  import ora from 'ora';
7
7
  import { execSync } from 'child_process';
8
8
  import os from 'os';
9
+ import { fileURLToPath } from 'url';
9
10
 
10
11
  const { prompt } = inquirer;
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = path.dirname(__filename);
11
14
 
12
15
  // 配置文件相关
13
16
  const CONFIG_DIR = path.join(os.homedir(), '.fe-cli');
@@ -100,12 +103,24 @@ function getRemoteBranches(repoUrl) {
100
103
 
101
104
 
102
105
 
103
- // 指定的gitee仓库(优先从配置文件读取,否则使用默认值)
104
- const DEFAULT_TEMPLATE_REPO = 'https://gitee.com/jianlidmeng/template.git';
105
- let TEMPLATE_REPO = getConfig('templateRepo') || DEFAULT_TEMPLATE_REPO;
106
+ let TEMPLATE_REPO = getConfig('templateRepo');
107
+
108
+ // 检查模板仓库配置
109
+ function checkTemplateRepoConfig() {
110
+ if (!TEMPLATE_REPO) {
111
+ console.error('❌ 模板仓库地址未配置');
112
+ console.error('\n请使用以下命令配置模板仓库地址:');
113
+ console.error(' itbox config set templateRepo <仓库地址>');
114
+ console.error('\n示例:');
115
+ console.error(' itbox config set templateRepo https://gitee.com/username/template.git');
116
+ console.error('\n配置完成后,重新运行命令即可。');
117
+ process.exit(1);
118
+ }
119
+ return TEMPLATE_REPO;
120
+ }
106
121
 
107
122
  // 从package.json获取项目信息
108
- const packagePath = path.resolve(path.dirname(new URL(import.meta.url).pathname), '../package.json');
123
+ const packagePath = path.resolve(__dirname, '../package.json');
109
124
  const packageInfo = fs.readJSONSync(packagePath);
110
125
 
111
126
  // 命令行配置
@@ -125,9 +140,12 @@ program
125
140
  process.exit(1);
126
141
  }
127
142
 
143
+ // 检查模板仓库配置
144
+ const templateRepo = checkTemplateRepoConfig();
145
+
128
146
  // 获取远程仓库分支(模板)
129
147
  const spinner = ora('正在获取可用模板列表...').start();
130
- const branches = getRemoteBranches(TEMPLATE_REPO);
148
+ const branches = getRemoteBranches(templateRepo);
131
149
  spinner.succeed('✅ 模板列表获取完成');
132
150
 
133
151
  // 显示模板列表
@@ -162,9 +180,12 @@ program
162
180
  process.exit(1);
163
181
  }
164
182
 
183
+ // 检查模板仓库配置
184
+ const templateRepo = checkTemplateRepoConfig();
185
+
165
186
  // 获取远程仓库分支
166
187
  const spinner = ora('正在获取模板列表...').start();
167
- const branches = getRemoteBranches(TEMPLATE_REPO);
188
+ const branches = getRemoteBranches(templateRepo);
168
189
  spinner.succeed('✅ 模板列表获取完成');
169
190
 
170
191
  // 如果没有分支
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itbox/cli",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "前端项目模板生成工具,支持Vue、Vue+TypeScript、Nuxt、Nest等模板",
5
5
  "type": "module",
6
6
  "main": "bin/index.js",