swico 1.3.0-beta.13 → 1.3.0-beta.3

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.13",
3
+ "version": "1.3.0-beta.3",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -111,35 +111,33 @@ 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, 9];
114
+ if (!['add', 'unlink'].includes(eventName)) return [3, 7];
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, 7];
119
+ case filePath === loadingFilePath: return [3, 6];
120
120
  }
121
- return [3, 9];
122
- case 2: return [4, devServer.stop()];
121
+ return [3, 7];
122
+ case 2:
123
+ console.log('1');
124
+ return [4, devServer.stop()];
123
125
  case 3:
124
126
  _b.sent();
125
127
  return [4, tsTypingsWatcher.close()];
126
128
  case 4:
127
129
  _b.sent();
128
130
  restartServer();
129
- return [3, 9];
131
+ return [3, 7];
130
132
  case 5:
131
- replaceIndexText = (0, config_1.handleGlobalStyleFile)(replaceIndexText);
132
- return [4, (0, config_1.updateIndexFileText)(envPath, replaceIndexText)];
133
+ console.log('2');
134
+ (0, config_1.handleGlobalStyleFile)(replaceIndexText);
135
+ return [3, 7];
133
136
  case 6:
134
- _b.sent();
135
- return [3, 9];
136
- case 7:
137
- replaceIndexText = (0, config_1.handleLoadingFile)(replaceIndexText, envPath);
138
- return [4, (0, config_1.updateIndexFileText)(envPath, replaceIndexText)];
139
- case 8:
140
- _b.sent();
141
- _b.label = 9;
142
- case 9: return [2];
137
+ console.log('3');
138
+ (0, config_1.handleLoadingFile)(replaceIndexText, envPath);
139
+ _b.label = 7;
140
+ case 7: return [2];
143
141
  }
144
142
  });
145
143
  }); });
@@ -166,11 +164,6 @@ var getMockGetLogger = function (compiler) {
166
164
  return __assign(__assign({}, logger), { log: log, debug: debug, error: error, warn: warn, info: function () { } });
167
165
  };
168
166
  };
169
- var filterStyleFileList = [
170
- "Can't resolve '../../global.less'",
171
- "Can't resolve '../../global.css'",
172
- "Can't resolve '../../global.scss'"
173
- ];
174
167
  var createCompileListener = function (compiler) {
175
168
  compiler.hooks.beforeCompile.tap('beforeCompile', function () {
176
169
  tools_1.toast.info('Compiling...');
@@ -178,17 +171,7 @@ var createCompileListener = function (compiler) {
178
171
  compiler.hooks.done.tap('done', function (stats) {
179
172
  var info = stats === null || stats === void 0 ? void 0 : stats.toJson();
180
173
  if (stats === null || stats === void 0 ? void 0 : stats.hasErrors()) {
181
- console.log('1');
182
- var formatErrors = info === null || info === void 0 ? void 0 : info.errors.map(function (item) { return item.message || item.stack; });
183
- console.log('formatErrors', formatErrors);
184
- var filterErrors = formatErrors.filter(function (item1) {
185
- return !filterStyleFileList.find(function (item2) {
186
- console.log('item1', item1);
187
- console.log('item2', item2);
188
- return item1.includes(item2);
189
- });
190
- });
191
- tools_1.toast.error(info === null || info === void 0 ? void 0 : info.errors.map(function (item) { return item.message || item.stack; }).filter(function (item1) { return !filterStyleFileList.find(function (item2) { return item1.includes(item2); }); }));
174
+ tools_1.toast.error(info === null || info === void 0 ? void 0 : info.errors.map(function (item) { return item.message || item.stack; }));
192
175
  return;
193
176
  }
194
177
  if (stats === null || stats === void 0 ? void 0 : stats.hasWarnings()) {
@@ -202,13 +185,13 @@ var createCompileListener = function (compiler) {
202
185
  });
203
186
  return;
204
187
  }
205
- tools_1.toast.info("Compiled successfully in ".concat(info === null || info === void 0 ? void 0 : info.time, "ms"));
188
+ tools_1.toast.info("Compiled complete in ".concat(info === null || info === void 0 ? void 0 : info.time, "ms"));
206
189
  });
207
190
  };
208
191
  function start() {
209
192
  var _a, _b, _c, _d, _e, _f;
210
193
  return __awaiter(this, void 0, void 0, function () {
211
- var availablePort, _g, projectConfig, projectPath, customConfig, env, newRouterBase, startConfig, compiler, oriLogger, devServer, e_1, strErr_1;
194
+ var availablePort, _g, projectConfig, projectPath, customConfig, env, newRouterBase, startConfig, compiler, oriLogger, devServer, e_1, strErr;
212
195
  return __generator(this, function (_h) {
213
196
  switch (_h.label) {
214
197
  case 0:
@@ -260,11 +243,8 @@ function start() {
260
243
  return [3, 10];
261
244
  case 9:
262
245
  e_1 = _h.sent();
263
- strErr_1 = e_1.toString();
264
- console.log('2', strErr_1);
265
- if (!filterStyleFileList.find(function (item) { return strErr_1.includes(item); })) {
266
- tools_1.toast.error(strErr_1);
267
- }
246
+ strErr = e_1.toString();
247
+ tools_1.toast.error(strErr);
268
248
  return [3, 10];
269
249
  case 10: return [2];
270
250
  }
@@ -44,8 +44,7 @@ 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<any>;
47
+ export declare const handleLoadingFile: (replaceIndexText: any, envPath: any) => Promise<void>;
48
48
  export declare const handleGlobalStyleFile: (replaceIndexText: any) => any;
49
- export declare const updateIndexFileText: (envPath: any, newFileText: any) => Promise<void>;
50
49
  export declare const getFormatDefineVars: (defineVarsConfigData: any) => Promise<{}>;
51
50
  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.updateIndexFileText = exports.handleGlobalStyleFile = exports.handleLoadingFile = exports.getProjectConfig = void 0;
76
+ exports.initConfig = exports.getFormatDefineVars = 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"));
@@ -185,7 +185,6 @@ var getProjectConfig = function (env) { return __awaiter(void 0, void 0, void 0,
185
185
  entryPath = path_1.default.resolve(projectPath, "./src/.swico/".concat(envPath, "index.js"));
186
186
  templatePath = path_1.default.join(projectPath, '/src/index.ejs');
187
187
  return [2, {
188
- env: env,
189
188
  projectPath: projectPath,
190
189
  entryPath: entryPath,
191
190
  templatePath: templatePath,
@@ -288,24 +287,25 @@ var getGlobalStyleFilePath = function () {
288
287
  return { filePath: filePath, fileType: fileType };
289
288
  };
290
289
  var handleLoadingFile = function (replaceIndexText, envPath) { return __awaiter(void 0, void 0, void 0, function () {
291
- var newReplaceIndexText, e_1;
290
+ var e_1;
292
291
  return __generator(this, function (_a) {
293
292
  switch (_a.label) {
294
293
  case 0:
295
- newReplaceIndexText = replaceIndexText;
296
- _a.label = 1;
297
- case 1:
298
- _a.trys.push([1, 3, , 4]);
294
+ _a.trys.push([0, 2, 3, 5]);
299
295
  return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/loading/index.tsx'), fs_extra_1.default.constants.F_OK)];
300
- case 2:
296
+ case 1:
301
297
  _a.sent();
302
- newReplaceIndexText = newReplaceIndexText.replace('"../loading"', '"../../loading"');
303
- return [3, 4];
304
- case 3:
298
+ replaceIndexText = replaceIndexText.replace('"../loading"', '"../../loading"');
299
+ return [3, 5];
300
+ case 2:
305
301
  e_1 = _a.sent();
306
- newReplaceIndexText = newReplaceIndexText.replace('"../../loading"', '"../loading"');
307
- return [3, 4];
308
- case 4: return [2, newReplaceIndexText];
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
+ _a.sent();
307
+ return [7];
308
+ case 5: return [2];
309
309
  }
310
310
  });
311
311
  }); };
@@ -323,21 +323,10 @@ var handleGlobalStyleFile = function (replaceIndexText) {
323
323
  return newReplaceIndexText;
324
324
  };
325
325
  exports.handleGlobalStyleFile = handleGlobalStyleFile;
326
- var updateIndexFileText = function (envPath, newFileText) { return __awaiter(void 0, void 0, void 0, function () {
327
- return __generator(this, function (_a) {
328
- switch (_a.label) {
329
- case 0: return [4, fs_extra_1.default.writeFile(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), newFileText)];
330
- case 1:
331
- _a.sent();
332
- return [2];
333
- }
334
- });
335
- }); };
336
- exports.updateIndexFileText = updateIndexFileText;
337
326
  var initTemplateConfig = function (routerConfig, templateType, env) {
338
327
  var envPath = env === 'dev' ? '/.dev/' : '/.prod/';
339
328
  return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
340
- var copyTargetPath, replaceIndexText, hooksFilePath, replaceHooksText, newReplaceIndexText;
329
+ var copyTargetPath, replaceIndexText, hooksFilePath, replaceHooksText;
341
330
  return __generator(this, function (_a) {
342
331
  switch (_a.label) {
343
332
  case 0:
@@ -372,20 +361,16 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
372
361
  replaceIndexText = (0, exports.handleGlobalStyleFile)(replaceIndexText);
373
362
  if (!(templateType === 'vue')) return [3, 8];
374
363
  replaceIndexText = replaceIndexText.replace('"../Container"', '"../Container.vue"');
375
- return [4, (0, exports.updateIndexFileText)(envPath, replaceIndexText)];
364
+ return [4, fs_extra_1.default.writeFile(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), replaceIndexText)];
376
365
  case 7:
377
366
  _a.sent();
378
- return [3, 11];
367
+ return [3, 9];
379
368
  case 8:
380
- if (!(templateType === 'react')) return [3, 11];
381
- return [4, (0, exports.handleLoadingFile)(replaceIndexText, envPath)];
369
+ if (templateType === 'react') {
370
+ (0, exports.handleLoadingFile)(replaceIndexText, envPath);
371
+ }
372
+ _a.label = 9;
382
373
  case 9:
383
- newReplaceIndexText = _a.sent();
384
- return [4, (0, exports.updateIndexFileText)(envPath, newReplaceIndexText)];
385
- case 10:
386
- _a.sent();
387
- _a.label = 11;
388
- case 11:
389
374
  resolve(null);
390
375
  return [2];
391
376
  }