swico 0.6.0-beta12 → 0.6.0-beta13
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 +1 -1
- package/src/utils/config.js +43 -49
package/package.json
CHANGED
package/src/utils/config.js
CHANGED
|
@@ -308,101 +308,95 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
|
|
|
308
308
|
switch (_a.label) {
|
|
309
309
|
case 0:
|
|
310
310
|
copyTargetPath = path_1.default.resolve(projectPath, './src/.swico');
|
|
311
|
-
if (!fs_extra_1.default.existsSync(copyTargetPath)) return [3, 2];
|
|
312
|
-
return [4, fs_extra_1.default.remove(copyTargetPath)];
|
|
313
|
-
case 1:
|
|
314
|
-
_a.sent();
|
|
315
|
-
_a.label = 2;
|
|
316
|
-
case 2:
|
|
317
311
|
copyFileNameList = getCopyFileNameList(templateType, env);
|
|
318
312
|
return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType)), copyTargetPath, function (fileName) { return copyFileNameList.includes(fileName); })];
|
|
319
|
-
case
|
|
313
|
+
case 1:
|
|
320
314
|
_a.sent();
|
|
321
315
|
return [4, formatRouterConfig(routerConfig, templateType, env)];
|
|
322
|
-
case
|
|
316
|
+
case 2:
|
|
323
317
|
_a.sent();
|
|
324
318
|
replaceIndexText = fs_extra_1.default.readFileSync(path_1.default.resolve(projectPath, './src/.swico/index.js'), 'utf8');
|
|
325
319
|
if (env === 'prod') {
|
|
326
|
-
replaceIndexText = replaceIndexText.replaceAll('require("./config")
|
|
327
|
-
replaceIndexText = replaceIndexText.replaceAll('require("./routes")
|
|
320
|
+
replaceIndexText = replaceIndexText.replaceAll('require("./config")', 'require("./config.prod")');
|
|
321
|
+
replaceIndexText = replaceIndexText.replaceAll('require("./routes")', 'require("./routes.prod")');
|
|
328
322
|
}
|
|
329
323
|
else {
|
|
330
|
-
replaceIndexText = replaceIndexText.replaceAll('require("./config.prod")
|
|
331
|
-
replaceIndexText = replaceIndexText.replaceAll('require("./routes.prod")
|
|
324
|
+
replaceIndexText = replaceIndexText.replaceAll('require("./config.prod")', 'require("./config")');
|
|
325
|
+
replaceIndexText = replaceIndexText.replaceAll('require("./routes.prod")', 'require("./routes")');
|
|
332
326
|
}
|
|
333
|
-
_a.label =
|
|
334
|
-
case
|
|
335
|
-
_a.trys.push([
|
|
327
|
+
_a.label = 3;
|
|
328
|
+
case 3:
|
|
329
|
+
_a.trys.push([3, 5, , 6]);
|
|
336
330
|
return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/global.ts'), fs_extra_1.default.constants.F_OK)];
|
|
337
|
-
case
|
|
331
|
+
case 4:
|
|
338
332
|
_a.sent();
|
|
339
333
|
replaceIndexText = replaceIndexText.replaceAll('require("../global");', '');
|
|
340
334
|
replaceIndexText = 'require("../global");\n' + replaceIndexText;
|
|
341
|
-
return [3,
|
|
342
|
-
case
|
|
335
|
+
return [3, 6];
|
|
336
|
+
case 5:
|
|
343
337
|
e_1 = _a.sent();
|
|
344
338
|
replaceIndexText = replaceIndexText.replaceAll('require("../global");', '');
|
|
345
|
-
return [3,
|
|
346
|
-
case
|
|
347
|
-
_a.trys.push([
|
|
339
|
+
return [3, 6];
|
|
340
|
+
case 6:
|
|
341
|
+
_a.trys.push([6, 8, , 9]);
|
|
348
342
|
return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/global.less'), fs_extra_1.default.constants.F_OK)];
|
|
349
|
-
case
|
|
343
|
+
case 7:
|
|
350
344
|
_a.sent();
|
|
351
345
|
replaceIndexText = replaceIndexText.replaceAll('require("../global.less");', '');
|
|
352
346
|
replaceIndexText = 'require("../global.less");\n' + replaceIndexText;
|
|
353
|
-
return [3,
|
|
354
|
-
case
|
|
347
|
+
return [3, 9];
|
|
348
|
+
case 8:
|
|
355
349
|
e_2 = _a.sent();
|
|
356
350
|
replaceIndexText = replaceIndexText.replaceAll('require("../global.less");', '');
|
|
357
|
-
return [3,
|
|
358
|
-
case
|
|
359
|
-
if (!(templateType === 'vue')) return [3,
|
|
351
|
+
return [3, 9];
|
|
352
|
+
case 9:
|
|
353
|
+
if (!(templateType === 'vue')) return [3, 12];
|
|
360
354
|
replaceIndexText = replaceIndexText.replace('"./Container"', '"./Container.vue"');
|
|
361
355
|
return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, './src/.swico/index.js'), replaceIndexText)];
|
|
362
|
-
case
|
|
356
|
+
case 10:
|
|
363
357
|
_a.sent();
|
|
364
358
|
replaceHooksText = fs_extra_1.default.readFileSync(path_1.default.resolve(projectPath, './src/.swico/hooks.js'), 'utf8');
|
|
365
359
|
if (env === 'prod') {
|
|
366
|
-
replaceHooksText = replaceHooksText.replaceAll('require("./config")
|
|
360
|
+
replaceHooksText = replaceHooksText.replaceAll('require("./config")', 'require("./config.prod")');
|
|
367
361
|
}
|
|
368
362
|
else {
|
|
369
|
-
replaceHooksText = replaceIndexText.replaceAll('require("./config.prod")
|
|
363
|
+
replaceHooksText = replaceIndexText.replaceAll('require("./config.prod")', 'require("./config")');
|
|
370
364
|
}
|
|
371
365
|
return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, './src/.swico/hooks.js'), replaceHooksText)];
|
|
372
|
-
case
|
|
366
|
+
case 11:
|
|
373
367
|
_a.sent();
|
|
374
|
-
return [3,
|
|
375
|
-
case
|
|
376
|
-
if (!(templateType === 'react')) return [3,
|
|
377
|
-
_a.label =
|
|
378
|
-
case
|
|
379
|
-
_a.trys.push([
|
|
368
|
+
return [3, 19];
|
|
369
|
+
case 12:
|
|
370
|
+
if (!(templateType === 'react')) return [3, 19];
|
|
371
|
+
_a.label = 13;
|
|
372
|
+
case 13:
|
|
373
|
+
_a.trys.push([13, 15, 16, 19]);
|
|
380
374
|
return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/loading/index.tsx'), fs_extra_1.default.constants.F_OK)];
|
|
381
|
-
case
|
|
375
|
+
case 14:
|
|
382
376
|
_a.sent();
|
|
383
377
|
replaceIndexText = replaceIndexText.replace('"./loading"', '"../loading"');
|
|
384
|
-
return [3,
|
|
385
|
-
case
|
|
378
|
+
return [3, 19];
|
|
379
|
+
case 15:
|
|
386
380
|
e_3 = _a.sent();
|
|
387
381
|
replaceIndexText = replaceIndexText.replace('"../loading"', '"./loading"');
|
|
388
|
-
return [3,
|
|
389
|
-
case
|
|
390
|
-
case
|
|
382
|
+
return [3, 19];
|
|
383
|
+
case 16: return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, './src/.swico/index.js'), replaceIndexText)];
|
|
384
|
+
case 17:
|
|
391
385
|
_a.sent();
|
|
392
386
|
replaceHistoryText = fs_extra_1.default.readFileSync(path_1.default.resolve(projectPath, './src/.swico/history.js'), 'utf8');
|
|
393
387
|
if (env === 'prod') {
|
|
394
|
-
replaceHistoryText = replaceHistoryText.replaceAll('require("./config")
|
|
395
|
-
replaceHistoryText = replaceHistoryText.replaceAll('require("./routes")
|
|
388
|
+
replaceHistoryText = replaceHistoryText.replaceAll('require("./config")', 'require("./config.prod")');
|
|
389
|
+
replaceHistoryText = replaceHistoryText.replaceAll('require("./routes")', 'require("./routes.prod")');
|
|
396
390
|
}
|
|
397
391
|
else {
|
|
398
|
-
replaceHistoryText = replaceHistoryText.replaceAll('require("./config.prod")
|
|
399
|
-
replaceHistoryText = replaceHistoryText.replaceAll('require("./routes.prod")
|
|
392
|
+
replaceHistoryText = replaceHistoryText.replaceAll('require("./config.prod")', 'require("./config")');
|
|
393
|
+
replaceHistoryText = replaceHistoryText.replaceAll('require("./routes.prod")', 'require("./routes")');
|
|
400
394
|
}
|
|
401
395
|
return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, './src/.swico/history.js'), replaceHistoryText)];
|
|
402
|
-
case
|
|
396
|
+
case 18:
|
|
403
397
|
_a.sent();
|
|
404
398
|
return [7];
|
|
405
|
-
case
|
|
399
|
+
case 19:
|
|
406
400
|
resolve(null);
|
|
407
401
|
return [2];
|
|
408
402
|
}
|