@itbox/cli 1.0.0 → 1.0.2

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