@htyf-mp/cli 0.2.3 → 0.2.4
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/package.json
CHANGED
|
@@ -193,8 +193,26 @@ export class ProjectInitializer {
|
|
|
193
193
|
const projectConfig = this.config.createProjectConfig(appName, displayName, appid);
|
|
194
194
|
|
|
195
195
|
// 写入配置文件
|
|
196
|
-
const configPath = path.join(appRootPath, '
|
|
197
|
-
|
|
196
|
+
const configPath = path.join(appRootPath, 'app.json');
|
|
197
|
+
let existingConfig = {};
|
|
198
|
+
|
|
199
|
+
// 检查 app.json 是否存在
|
|
200
|
+
if (fs.existsSync(configPath)) {
|
|
201
|
+
// 如果存在,读取现有内容
|
|
202
|
+
const existingContent = fs.readFileSync(configPath, 'utf-8');
|
|
203
|
+
try {
|
|
204
|
+
existingConfig = JSON.parse(existingContent);
|
|
205
|
+
} catch (error) {
|
|
206
|
+
Logger.warn('app.json 格式错误,将创建新配置');
|
|
207
|
+
existingConfig = {};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// 添加 htyf 字段
|
|
212
|
+
existingConfig.htyf = projectConfig;
|
|
213
|
+
|
|
214
|
+
// 写入配置文件
|
|
215
|
+
fs.writeFileSync(configPath, JSON.stringify(existingConfig, undefined, 2));
|
|
198
216
|
|
|
199
217
|
// 清理临时文件
|
|
200
218
|
spinner.text = '正在清理临时文件...';
|
|
@@ -89,7 +89,7 @@ export class TemplateProcessor {
|
|
|
89
89
|
// 复制模板文件
|
|
90
90
|
Object.entries(template.files).forEach(([key, fileName]) => {
|
|
91
91
|
const srcPath = path.join(tempPath, fileName);
|
|
92
|
-
const destPath = path.join(appRootPath, key === 'src' ? './src' : `./${key === 'app' ? 'App.tsx' : key === 'index' ? 'index.js' : key === 'babel' ? 'babel.config.js' : '
|
|
92
|
+
const destPath = path.join(appRootPath, key === 'src' ? './src' : `./${key === 'app' ? 'App.tsx' : key === 'index' ? 'index.js' : key === 'babel' ? 'babel.config.js' : 'app.json'}`);
|
|
93
93
|
|
|
94
94
|
if (fs.existsSync(srcPath)) {
|
|
95
95
|
fse.copySync(srcPath, destPath);
|
|
@@ -125,7 +125,7 @@ export class TemplateProcessor {
|
|
|
125
125
|
// 复制模板文件
|
|
126
126
|
Object.entries(template.files).forEach(([key, fileName]) => {
|
|
127
127
|
const srcPath = path.join(tempPath, fileName);
|
|
128
|
-
const destPath = path.join(appRootPath, key === 'src' ? './src' : `./${key === 'app' ? 'App.tsx' : key === 'index' ? 'index.js' : key === 'babel' ? 'babel.config.js' : '
|
|
128
|
+
const destPath = path.join(appRootPath, key === 'src' ? './src' : `./${key === 'app' ? 'App.tsx' : key === 'index' ? 'index.js' : key === 'babel' ? 'babel.config.js' : 'app.json'}`);
|
|
129
129
|
|
|
130
130
|
if (fs.existsSync(srcPath)) {
|
|
131
131
|
fse.copySync(srcPath, destPath);
|