swico 1.3.0-beta.2 → 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 +1 -1
- package/src/command/start.js +23 -11
- package/src/utils/config.d.ts +2 -1
- package/src/utils/config.js +33 -21
package/package.json
CHANGED
package/src/command/start.js
CHANGED
|
@@ -106,32 +106,44 @@ var handleWatch = function (projectPath, devServer, env) {
|
|
|
106
106
|
var replaceIndexText, _a;
|
|
107
107
|
return __generator(this, function (_b) {
|
|
108
108
|
switch (_b.label) {
|
|
109
|
-
case 0:
|
|
109
|
+
case 0:
|
|
110
|
+
console.log('eventName', eventName, filePath);
|
|
111
|
+
return [4, fs_extra_1.default.readFile(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), 'utf8')];
|
|
110
112
|
case 1:
|
|
111
113
|
replaceIndexText = _b.sent();
|
|
112
|
-
if (!['add', 'unlink'].includes(eventName)) return [3,
|
|
114
|
+
if (!['add', 'unlink'].includes(eventName)) return [3, 9];
|
|
113
115
|
_a = true;
|
|
114
116
|
switch (_a) {
|
|
115
117
|
case filePath.endsWith('.d.ts'): return [3, 2];
|
|
116
118
|
case globalStyleFilesPathList.includes(filePath): return [3, 5];
|
|
117
|
-
case filePath === loadingFilePath: return [3,
|
|
119
|
+
case filePath === loadingFilePath: return [3, 7];
|
|
118
120
|
}
|
|
119
|
-
return [3,
|
|
120
|
-
case 2:
|
|
121
|
+
return [3, 9];
|
|
122
|
+
case 2:
|
|
123
|
+
console.log('1');
|
|
124
|
+
return [4, devServer.stop()];
|
|
121
125
|
case 3:
|
|
122
126
|
_b.sent();
|
|
123
127
|
return [4, tsTypingsWatcher.close()];
|
|
124
128
|
case 4:
|
|
125
129
|
_b.sent();
|
|
126
130
|
restartServer();
|
|
127
|
-
return [3,
|
|
131
|
+
return [3, 9];
|
|
128
132
|
case 5:
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
console.log('2');
|
|
134
|
+
replaceIndexText = (0, config_1.handleGlobalStyleFile)(replaceIndexText);
|
|
135
|
+
return [4, (0, config_1.updateIndexFileText)(envPath, replaceIndexText)];
|
|
131
136
|
case 6:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
case 7:
|
|
137
|
+
_b.sent();
|
|
138
|
+
return [3, 9];
|
|
139
|
+
case 7:
|
|
140
|
+
console.log('3');
|
|
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];
|
|
135
147
|
}
|
|
136
148
|
});
|
|
137
149
|
}); });
|
package/src/utils/config.d.ts
CHANGED
|
@@ -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<
|
|
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'>;
|
package/src/utils/config.js
CHANGED
|
@@ -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
|
-
|
|
295
|
-
|
|
294
|
+
newReplaceIndexText = replaceIndexText;
|
|
295
|
+
_a.label = 1;
|
|
296
296
|
case 1:
|
|
297
|
-
_a.
|
|
298
|
-
|
|
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
|
-
|
|
308
|
-
|
|
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,
|
|
374
|
+
return [4, (0, exports.updateIndexFileText)(envPath, replaceIndexText)];
|
|
365
375
|
case 7:
|
|
366
376
|
_a.sent();
|
|
367
|
-
return [3,
|
|
377
|
+
return [3, 10];
|
|
368
378
|
case 8:
|
|
369
|
-
if (templateType === 'react')
|
|
370
|
-
|
|
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
|
}
|