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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/utils/config.js +43 -49
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swico",
3
- "version": "0.6.0-beta12",
3
+ "version": "0.6.0-beta13",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -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 3:
313
+ case 1:
320
314
  _a.sent();
321
315
  return [4, formatRouterConfig(routerConfig, templateType, env)];
322
- case 4:
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");', 'require("./config.prod");');
327
- replaceIndexText = replaceIndexText.replaceAll('require("./routes");', 'require("./routes.prod");');
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");', 'require("./config");');
331
- replaceIndexText = replaceIndexText.replaceAll('require("./routes.prod");', 'require("./routes");');
324
+ replaceIndexText = replaceIndexText.replaceAll('require("./config.prod")', 'require("./config")');
325
+ replaceIndexText = replaceIndexText.replaceAll('require("./routes.prod")', 'require("./routes")');
332
326
  }
333
- _a.label = 5;
334
- case 5:
335
- _a.trys.push([5, 7, , 8]);
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 6:
331
+ case 4:
338
332
  _a.sent();
339
333
  replaceIndexText = replaceIndexText.replaceAll('require("../global");', '');
340
334
  replaceIndexText = 'require("../global");\n' + replaceIndexText;
341
- return [3, 8];
342
- case 7:
335
+ return [3, 6];
336
+ case 5:
343
337
  e_1 = _a.sent();
344
338
  replaceIndexText = replaceIndexText.replaceAll('require("../global");', '');
345
- return [3, 8];
346
- case 8:
347
- _a.trys.push([8, 10, , 11]);
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 9:
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, 11];
354
- case 10:
347
+ return [3, 9];
348
+ case 8:
355
349
  e_2 = _a.sent();
356
350
  replaceIndexText = replaceIndexText.replaceAll('require("../global.less");', '');
357
- return [3, 11];
358
- case 11:
359
- if (!(templateType === 'vue')) return [3, 14];
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 12:
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");', 'require("./config.prod");');
360
+ replaceHooksText = replaceHooksText.replaceAll('require("./config")', 'require("./config.prod")');
367
361
  }
368
362
  else {
369
- replaceHooksText = replaceIndexText.replaceAll('require("./config.prod");', 'require("./config");');
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 13:
366
+ case 11:
373
367
  _a.sent();
374
- return [3, 21];
375
- case 14:
376
- if (!(templateType === 'react')) return [3, 21];
377
- _a.label = 15;
378
- case 15:
379
- _a.trys.push([15, 17, 18, 21]);
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 16:
375
+ case 14:
382
376
  _a.sent();
383
377
  replaceIndexText = replaceIndexText.replace('"./loading"', '"../loading"');
384
- return [3, 21];
385
- case 17:
378
+ return [3, 19];
379
+ case 15:
386
380
  e_3 = _a.sent();
387
381
  replaceIndexText = replaceIndexText.replace('"../loading"', '"./loading"');
388
- return [3, 21];
389
- case 18: return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, './src/.swico/index.js'), replaceIndexText)];
390
- case 19:
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");', 'require("./config.prod");');
395
- replaceHistoryText = replaceHistoryText.replaceAll('require("./routes");', 'require("./routes.prod");');
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");', 'require("./config");');
399
- replaceHistoryText = replaceHistoryText.replaceAll('require("./routes.prod");', 'require("./routes");');
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 20:
396
+ case 18:
403
397
  _a.sent();
404
398
  return [7];
405
- case 21:
399
+ case 19:
406
400
  resolve(null);
407
401
  return [2];
408
402
  }