swico 1.3.0-beta.3 → 1.3.0-beta.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swico",
3
- "version": "1.3.0-beta.3",
3
+ "version": "1.3.0-beta.4",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -111,14 +111,14 @@ var handleWatch = function (projectPath, devServer, env) {
111
111
  return [4, fs_extra_1.default.readFile(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), 'utf8')];
112
112
  case 1:
113
113
  replaceIndexText = _b.sent();
114
- if (!['add', 'unlink'].includes(eventName)) return [3, 7];
114
+ if (!['add', 'unlink'].includes(eventName)) return [3, 9];
115
115
  _a = true;
116
116
  switch (_a) {
117
117
  case filePath.endsWith('.d.ts'): return [3, 2];
118
118
  case globalStyleFilesPathList.includes(filePath): return [3, 5];
119
- case filePath === loadingFilePath: return [3, 6];
119
+ case filePath === loadingFilePath: return [3, 7];
120
120
  }
121
- return [3, 7];
121
+ return [3, 9];
122
122
  case 2:
123
123
  console.log('1');
124
124
  return [4, devServer.stop()];
@@ -128,16 +128,22 @@ var handleWatch = function (projectPath, devServer, env) {
128
128
  case 4:
129
129
  _b.sent();
130
130
  restartServer();
131
- return [3, 7];
131
+ return [3, 9];
132
132
  case 5:
133
133
  console.log('2');
134
- (0, config_1.handleGlobalStyleFile)(replaceIndexText);
135
- return [3, 7];
134
+ replaceIndexText = (0, config_1.handleGlobalStyleFile)(replaceIndexText);
135
+ return [4, (0, config_1.updateIndexFileText)(envPath, replaceIndexText)];
136
136
  case 6:
137
+ _b.sent();
138
+ return [3, 9];
139
+ case 7:
137
140
  console.log('3');
138
- (0, config_1.handleLoadingFile)(replaceIndexText, envPath);
139
- _b.label = 7;
140
- case 7: return [2];
141
+ replaceIndexText = (0, config_1.handleLoadingFile)(replaceIndexText, envPath);
142
+ return [4, (0, config_1.updateIndexFileText)(envPath, replaceIndexText)];
143
+ case 8:
144
+ _b.sent();
145
+ _b.label = 9;
146
+ case 9: return [2];
141
147
  }
142
148
  });
143
149
  }); });
@@ -44,7 +44,8 @@ export interface GlobalData {
44
44
  };
45
45
  }
46
46
  export declare const getProjectConfig: (env: GlobalData['env']) => Promise<GlobalData>;
47
- export declare const handleLoadingFile: (replaceIndexText: any, envPath: any) => Promise<void>;
47
+ export declare const handleLoadingFile: (replaceIndexText: any, envPath: any) => Promise<any>;
48
48
  export declare const handleGlobalStyleFile: (replaceIndexText: any) => any;
49
+ export declare const updateIndexFileText: (envPath: any, newFileText: any) => Promise<void>;
49
50
  export declare const getFormatDefineVars: (defineVarsConfigData: any) => Promise<{}>;
50
51
  export declare const initConfig: Omit<GlobalSwicoConfigType, 'template'>;
@@ -73,7 +73,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
73
73
  return (mod && mod.__esModule) ? mod : { "default": mod };
74
74
  };
75
75
  Object.defineProperty(exports, "__esModule", { value: true });
76
- exports.initConfig = exports.getFormatDefineVars = exports.handleGlobalStyleFile = exports.handleLoadingFile = exports.getProjectConfig = void 0;
76
+ exports.initConfig = exports.getFormatDefineVars = exports.updateIndexFileText = exports.handleGlobalStyleFile = exports.handleLoadingFile = exports.getProjectConfig = void 0;
77
77
  var fs_extra_1 = __importDefault(require("fs-extra"));
78
78
  var path_1 = __importDefault(require("path"));
79
79
  var chalk_1 = __importDefault(require("chalk"));
@@ -287,25 +287,24 @@ var getGlobalStyleFilePath = function () {
287
287
  return { filePath: filePath, fileType: fileType };
288
288
  };
289
289
  var handleLoadingFile = function (replaceIndexText, envPath) { return __awaiter(void 0, void 0, void 0, function () {
290
- var e_1;
290
+ var newReplaceIndexText, e_1;
291
291
  return __generator(this, function (_a) {
292
292
  switch (_a.label) {
293
293
  case 0:
294
- _a.trys.push([0, 2, 3, 5]);
295
- return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/loading/index.tsx'), fs_extra_1.default.constants.F_OK)];
294
+ newReplaceIndexText = replaceIndexText;
295
+ _a.label = 1;
296
296
  case 1:
297
- _a.sent();
298
- replaceIndexText = replaceIndexText.replace('"../loading"', '"../../loading"');
299
- return [3, 5];
297
+ _a.trys.push([1, 3, , 4]);
298
+ return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/loading/index.tsx'), fs_extra_1.default.constants.F_OK)];
300
299
  case 2:
301
- e_1 = _a.sent();
302
- replaceIndexText = replaceIndexText.replace('"../../loading"', '"../loading"');
303
- return [3, 5];
304
- case 3: return [4, fs_extra_1.default.writeFile(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), replaceIndexText)];
305
- case 4:
306
300
  _a.sent();
307
- return [7];
308
- case 5: return [2];
301
+ newReplaceIndexText = newReplaceIndexText.replace('"../loading"', '"../../loading"');
302
+ return [3, 4];
303
+ case 3:
304
+ e_1 = _a.sent();
305
+ newReplaceIndexText = newReplaceIndexText.replace('"../../loading"', '"../loading"');
306
+ return [3, 4];
307
+ case 4: return [2, newReplaceIndexText];
309
308
  }
310
309
  });
311
310
  }); };
@@ -323,10 +322,21 @@ var handleGlobalStyleFile = function (replaceIndexText) {
323
322
  return newReplaceIndexText;
324
323
  };
325
324
  exports.handleGlobalStyleFile = handleGlobalStyleFile;
325
+ var updateIndexFileText = function (envPath, newFileText) { return __awaiter(void 0, void 0, void 0, function () {
326
+ return __generator(this, function (_a) {
327
+ switch (_a.label) {
328
+ case 0: return [4, fs_extra_1.default.writeFile(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), newFileText)];
329
+ case 1:
330
+ _a.sent();
331
+ return [2];
332
+ }
333
+ });
334
+ }); };
335
+ exports.updateIndexFileText = updateIndexFileText;
326
336
  var initTemplateConfig = function (routerConfig, templateType, env) {
327
337
  var envPath = env === 'dev' ? '/.dev/' : '/.prod/';
328
338
  return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
329
- var copyTargetPath, replaceIndexText, hooksFilePath, replaceHooksText;
339
+ var copyTargetPath, replaceIndexText, hooksFilePath, replaceHooksText, newReplaceIndexText;
330
340
  return __generator(this, function (_a) {
331
341
  switch (_a.label) {
332
342
  case 0:
@@ -361,16 +371,18 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
361
371
  replaceIndexText = (0, exports.handleGlobalStyleFile)(replaceIndexText);
362
372
  if (!(templateType === 'vue')) return [3, 8];
363
373
  replaceIndexText = replaceIndexText.replace('"../Container"', '"../Container.vue"');
364
- return [4, fs_extra_1.default.writeFile(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), replaceIndexText)];
374
+ return [4, (0, exports.updateIndexFileText)(envPath, replaceIndexText)];
365
375
  case 7:
366
376
  _a.sent();
367
- return [3, 9];
377
+ return [3, 10];
368
378
  case 8:
369
- if (templateType === 'react') {
370
- (0, exports.handleLoadingFile)(replaceIndexText, envPath);
371
- }
372
- _a.label = 9;
379
+ if (!(templateType === 'react')) return [3, 10];
380
+ newReplaceIndexText = (0, exports.handleLoadingFile)(replaceIndexText, envPath);
381
+ return [4, (0, exports.updateIndexFileText)(envPath, newReplaceIndexText)];
373
382
  case 9:
383
+ _a.sent();
384
+ _a.label = 10;
385
+ case 10:
374
386
  resolve(null);
375
387
  return [2];
376
388
  }