swico 0.6.0-beta21 → 0.6.0-beta3
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 +3 -5
- package/src/command/build.js +5 -7
- package/src/command/start.js +19 -21
- package/src/utils/config.d.ts +1 -1
- package/src/utils/config.js +45 -88
- package/src/utils/tools.d.ts +0 -1
- package/src/utils/tools.js +4 -48
- package/src/template/react/config.prod.d.ts +0 -3
- package/src/template/react/config.prod.js +0 -5
- package/src/template/react/routes.prod.d.ts +0 -3
- package/src/template/react/routes.prod.js +0 -3
- package/src/template/vue/config.prod.d.ts +0 -3
- package/src/template/vue/config.prod.js +0 -5
- package/src/template/vue/routes.prod.d.ts +0 -6
- package/src/template/vue/routes.prod.js +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swico",
|
|
3
|
-
"version": "0.6.0-
|
|
3
|
+
"version": "0.6.0-beta3",
|
|
4
4
|
"description": "Simple, efficient, and practical front-end framework",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -15,11 +15,9 @@
|
|
|
15
15
|
"template",
|
|
16
16
|
"webpack"
|
|
17
17
|
],
|
|
18
|
-
"bin": {
|
|
19
|
-
"swico": "./src/bin.js"
|
|
20
|
-
},
|
|
18
|
+
"bin": {},
|
|
21
19
|
"scripts": {
|
|
22
|
-
"compile": "tsc && ts-node ./src/task.ts",
|
|
20
|
+
"compile": "tsc && ts-node ./src/task.ts", "swico": "./src/bin.js",
|
|
23
21
|
"publish:offical": "npm run compile && cd ./dist && npm publish",
|
|
24
22
|
"publish:beta": "npm run compile && cd ./dist && npm publish --tag=beta"
|
|
25
23
|
},
|
package/src/command/build.js
CHANGED
|
@@ -54,13 +54,10 @@ function default_1() {
|
|
|
54
54
|
switch (_a.label) {
|
|
55
55
|
case 0:
|
|
56
56
|
process.env.SWICO_ENV = 'prod';
|
|
57
|
-
tools_1.toast.info("Swico
|
|
58
|
-
spinner.
|
|
59
|
-
return [4, (0, tools_1.initIndexFile)()];
|
|
60
|
-
case 1:
|
|
61
|
-
_a.sent();
|
|
57
|
+
tools_1.toast.info("Swico V".concat(package_json_1.default.version));
|
|
58
|
+
spinner.start('Initializing Swico production config...');
|
|
62
59
|
return [4, (0, config_1.getProjectConfig)('prod')];
|
|
63
|
-
case
|
|
60
|
+
case 1:
|
|
64
61
|
projectConfig = _a.sent();
|
|
65
62
|
entryPath = projectConfig.entryPath, templatePath = projectConfig.templatePath, projectPath = projectConfig.projectPath, customConfig = projectConfig.customConfig, templateType = projectConfig.templateType;
|
|
66
63
|
return [4, (0, webpack_prod_1.default)({
|
|
@@ -70,8 +67,9 @@ function default_1() {
|
|
|
70
67
|
customConfig: customConfig,
|
|
71
68
|
templateType: templateType
|
|
72
69
|
})];
|
|
73
|
-
case
|
|
70
|
+
case 2:
|
|
74
71
|
buildConfig = _a.sent();
|
|
72
|
+
spinner.succeed();
|
|
75
73
|
compiler = (0, webpack_1.default)(buildConfig);
|
|
76
74
|
compiler.run(function (err, stats) {
|
|
77
75
|
if (err) {
|
package/src/command/start.js
CHANGED
|
@@ -131,43 +131,41 @@ function start() {
|
|
|
131
131
|
switch (_b.label) {
|
|
132
132
|
case 0:
|
|
133
133
|
process.env.SWICO_ENV = 'dev';
|
|
134
|
-
|
|
135
|
-
spinner.succeed('Initializing Swico development config...\n');
|
|
136
|
-
return [4, (0, tools_1.initIndexFile)()];
|
|
137
|
-
case 1:
|
|
138
|
-
_b.sent();
|
|
139
|
-
if (!(envPort !== null && envPort !== void 0)) return [3, 2];
|
|
134
|
+
if (!(envPort !== null && envPort !== void 0)) return [3, 1];
|
|
140
135
|
_a = envPort;
|
|
141
|
-
return [3,
|
|
142
|
-
case
|
|
143
|
-
case
|
|
136
|
+
return [3, 3];
|
|
137
|
+
case 1: return [4, (0, tools_1.getPort)()];
|
|
138
|
+
case 2:
|
|
144
139
|
_a = (_b.sent());
|
|
145
|
-
_b.label =
|
|
146
|
-
case
|
|
140
|
+
_b.label = 3;
|
|
141
|
+
case 3:
|
|
147
142
|
availablePort = _a;
|
|
143
|
+
tools_1.toast.info("Swico V".concat(package_json_1.default.version));
|
|
144
|
+
spinner.start('Initializing Swico development config...');
|
|
148
145
|
return [4, (0, config_1.getProjectConfig)('dev')];
|
|
149
|
-
case
|
|
146
|
+
case 4:
|
|
150
147
|
projectConfig = _b.sent();
|
|
151
148
|
projectPath = projectConfig.projectPath;
|
|
152
149
|
return [4, (0, webpack_dev_1.default)(projectConfig)];
|
|
153
|
-
case
|
|
150
|
+
case 5:
|
|
154
151
|
startConfig = _b.sent();
|
|
152
|
+
spinner.succeed();
|
|
155
153
|
compiler = (0, webpack_1.default)(startConfig);
|
|
156
154
|
devServer = new webpack_dev_server_1.default(__assign(__assign({}, startConfig.devServer), { port: availablePort }), compiler);
|
|
157
|
-
_b.label =
|
|
158
|
-
case
|
|
159
|
-
_b.trys.push([
|
|
155
|
+
_b.label = 6;
|
|
156
|
+
case 6:
|
|
157
|
+
_b.trys.push([6, 8, , 9]);
|
|
160
158
|
return [4, devServer.start()];
|
|
161
|
-
case
|
|
159
|
+
case 7:
|
|
162
160
|
_b.sent();
|
|
163
161
|
handleWatch(projectPath, devServer);
|
|
164
|
-
return [3,
|
|
165
|
-
case
|
|
162
|
+
return [3, 9];
|
|
163
|
+
case 8:
|
|
166
164
|
e_1 = _b.sent();
|
|
167
165
|
strErr = e_1.toString();
|
|
168
166
|
tools_1.toast.error(strErr);
|
|
169
|
-
return [3,
|
|
170
|
-
case
|
|
167
|
+
return [3, 9];
|
|
168
|
+
case 9: return [2];
|
|
171
169
|
}
|
|
172
170
|
});
|
|
173
171
|
});
|
package/src/utils/config.d.ts
CHANGED
|
@@ -42,6 +42,6 @@ export interface GlobalData {
|
|
|
42
42
|
prod: Pick<GlobalSwicoConfigType, 'plugins' | 'console' | 'copy' | 'devtool' | 'router'>;
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
export declare const getProjectConfig: (env
|
|
45
|
+
export declare const getProjectConfig: (env?: GlobalData['env']) => Promise<GlobalData>;
|
|
46
46
|
export declare const getFormatDefineVars: (defineVarsConfigData: any) => Promise<{}>;
|
|
47
47
|
export declare const initConfig: Omit<GlobalSwicoConfigType, 'template'>;
|
package/src/utils/config.js
CHANGED
|
@@ -172,7 +172,7 @@ var getProjectConfig = function (env) { return __awaiter(void 0, void 0, void 0,
|
|
|
172
172
|
case 4:
|
|
173
173
|
templateType = customConfig['base'].template;
|
|
174
174
|
routerConfig = __assign(__assign(__assign({}, exports.initConfig.router), customConfig['base'].router), customConfig[env].router);
|
|
175
|
-
return [4, initTemplateConfig(routerConfig, templateType
|
|
175
|
+
return [4, initTemplateConfig(routerConfig, templateType)];
|
|
176
176
|
case 5:
|
|
177
177
|
_e.sent();
|
|
178
178
|
return [4, initCliIndexFile(templateType)];
|
|
@@ -226,7 +226,9 @@ var initCliIndexFile = function (templateType) { return __awaiter(void 0, void 0
|
|
|
226
226
|
case 0:
|
|
227
227
|
targetPath = path_1.default.resolve(__dirname, '../index.js');
|
|
228
228
|
targetTypesPath = path_1.default.resolve(__dirname, '../index.d.ts');
|
|
229
|
-
|
|
229
|
+
return [4, fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, "../index.".concat(templateType, ".js")), 'utf8')];
|
|
230
|
+
case 1:
|
|
231
|
+
replaceFileText = _a.sent();
|
|
230
232
|
fileTypesText = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, "../index.".concat(templateType, ".d.ts")), 'utf8');
|
|
231
233
|
if (templateType === 'react') {
|
|
232
234
|
formatHooksPath = path_1.default
|
|
@@ -235,18 +237,17 @@ var initCliIndexFile = function (templateType) { return __awaiter(void 0, void 0
|
|
|
235
237
|
replaceFileText = replaceFileText.replaceAll('require("./template/react/hooks");', "require(\"".concat(formatHooksPath, "\");"));
|
|
236
238
|
}
|
|
237
239
|
return [4, (0, tools_1.writeFile)(targetPath, replaceFileText)];
|
|
238
|
-
case
|
|
240
|
+
case 2:
|
|
239
241
|
_a.sent();
|
|
240
242
|
return [4, (0, tools_1.writeFile)(targetTypesPath, fileTypesText)];
|
|
241
|
-
case
|
|
243
|
+
case 3:
|
|
242
244
|
_a.sent();
|
|
243
245
|
return [2];
|
|
244
246
|
}
|
|
245
247
|
});
|
|
246
248
|
}); };
|
|
247
|
-
var formatRouterConfig = function (_a, templateType
|
|
249
|
+
var formatRouterConfig = function (_a, templateType) {
|
|
248
250
|
var _b = _a.routes, routes = _b === void 0 ? [] : _b, _c = _a.type, type = _c === void 0 ? 'browser' : _c, _d = _a.base, base = _d === void 0 ? '/' : _d;
|
|
249
|
-
var envPathSuffix = env === 'dev' ? '' : 'prod.';
|
|
250
251
|
return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
|
251
252
|
var formatRouter, textData, modifiedText, configFilePath, replaceConfigText;
|
|
252
253
|
return __generator(this, function (_a) {
|
|
@@ -255,10 +256,10 @@ var formatRouterConfig = function (_a, templateType, env) {
|
|
|
255
256
|
formatRouter = getFormatRouter(routes, templateType);
|
|
256
257
|
textData = "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.default = ".concat(JSON.stringify(formatRouter), ";");
|
|
257
258
|
modifiedText = textData.replace(/"(\(\)=>import\('[^']+'\))"/g, '$1');
|
|
258
|
-
return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath,
|
|
259
|
+
return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, './src/.swico/routes.js'), modifiedText)];
|
|
259
260
|
case 1:
|
|
260
261
|
_a.sent();
|
|
261
|
-
configFilePath = path_1.default.resolve(projectPath,
|
|
262
|
+
configFilePath = path_1.default.resolve(projectPath, './src/.swico/config.js');
|
|
262
263
|
replaceConfigText = fs_extra_1.default.readFileSync(configFilePath, 'utf8');
|
|
263
264
|
if (base) {
|
|
264
265
|
replaceConfigText = replaceConfigText.replace(/exports\.routerBase\s*=\s*(.*)/gm, function (match, p1) {
|
|
@@ -279,119 +280,75 @@ var formatRouterConfig = function (_a, templateType, env) {
|
|
|
279
280
|
});
|
|
280
281
|
}); });
|
|
281
282
|
};
|
|
282
|
-
var
|
|
283
|
-
var list = ['hooks.js', 'index.js', 'history.js', 'loading.js'];
|
|
284
|
-
switch (true) {
|
|
285
|
-
case templateType === 'vue' && env === 'dev':
|
|
286
|
-
list.push('config.js', 'Container.vue', 'routes.js');
|
|
287
|
-
break;
|
|
288
|
-
case templateType === 'vue' && env === 'prod':
|
|
289
|
-
list.push('config.prod.js', 'Container.vue', 'routes.prod.js');
|
|
290
|
-
break;
|
|
291
|
-
case templateType === 'react' && env === 'dev':
|
|
292
|
-
list.push('config.js', 'history.js', 'routes.js');
|
|
293
|
-
break;
|
|
294
|
-
case templateType === 'react' && env === 'prod':
|
|
295
|
-
list.push('config.prod.js', 'history.js', 'routes.prod.js');
|
|
296
|
-
break;
|
|
297
|
-
default:
|
|
298
|
-
break;
|
|
299
|
-
}
|
|
300
|
-
return list;
|
|
301
|
-
};
|
|
302
|
-
var initTemplateConfig = function (routerConfig, templateType, env) {
|
|
283
|
+
var initTemplateConfig = function (routerConfig, templateType) {
|
|
303
284
|
return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
|
304
|
-
var copyTargetPath,
|
|
285
|
+
var copyTargetPath, replaceIndexText, e_1, e_2, e_3;
|
|
305
286
|
return __generator(this, function (_a) {
|
|
306
287
|
switch (_a.label) {
|
|
307
288
|
case 0:
|
|
308
|
-
console.log('0');
|
|
309
289
|
copyTargetPath = path_1.default.resolve(projectPath, './src/.swico');
|
|
310
|
-
|
|
311
|
-
return [4,
|
|
290
|
+
if (!fs_extra_1.default.existsSync(copyTargetPath)) return [3, 2];
|
|
291
|
+
return [4, fs_extra_1.default.remove(copyTargetPath)];
|
|
312
292
|
case 1:
|
|
313
293
|
_a.sent();
|
|
314
|
-
|
|
315
|
-
case 2:
|
|
294
|
+
_a.label = 2;
|
|
295
|
+
case 2: return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType)), copyTargetPath, function (fileName) {
|
|
296
|
+
return !fileName.endsWith('.d.ts') &&
|
|
297
|
+
(templateType === 'vue' ? fileName !== 'Container.js' : true);
|
|
298
|
+
})];
|
|
299
|
+
case 3:
|
|
300
|
+
_a.sent();
|
|
301
|
+
return [4, formatRouterConfig(routerConfig, templateType)];
|
|
302
|
+
case 4:
|
|
316
303
|
_a.sent();
|
|
317
304
|
replaceIndexText = fs_extra_1.default.readFileSync(path_1.default.resolve(projectPath, './src/.swico/index.js'), 'utf8');
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
replaceIndexText = replaceIndexText.replaceAll('require("./config.prod")', 'require("./config")');
|
|
324
|
-
replaceIndexText = replaceIndexText.replaceAll('require("./routes.prod")', 'require("./routes")');
|
|
325
|
-
}
|
|
326
|
-
_a.label = 3;
|
|
327
|
-
case 3:
|
|
328
|
-
_a.trys.push([3, 5, , 6]);
|
|
305
|
+
_a.label = 5;
|
|
306
|
+
case 5:
|
|
307
|
+
_a.trys.push([5, 7, , 8]);
|
|
329
308
|
return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/global.ts'), fs_extra_1.default.constants.F_OK)];
|
|
330
|
-
case
|
|
309
|
+
case 6:
|
|
331
310
|
_a.sent();
|
|
332
311
|
replaceIndexText = replaceIndexText.replaceAll('require("../global");', '');
|
|
333
312
|
replaceIndexText = 'require("../global");\n' + replaceIndexText;
|
|
334
|
-
return [3,
|
|
335
|
-
case
|
|
313
|
+
return [3, 8];
|
|
314
|
+
case 7:
|
|
336
315
|
e_1 = _a.sent();
|
|
337
316
|
replaceIndexText = replaceIndexText.replaceAll('require("../global");', '');
|
|
338
|
-
return [3,
|
|
339
|
-
case
|
|
340
|
-
_a.trys.push([
|
|
317
|
+
return [3, 8];
|
|
318
|
+
case 8:
|
|
319
|
+
_a.trys.push([8, 10, , 11]);
|
|
341
320
|
return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/global.less'), fs_extra_1.default.constants.F_OK)];
|
|
342
|
-
case
|
|
321
|
+
case 9:
|
|
343
322
|
_a.sent();
|
|
344
323
|
replaceIndexText = replaceIndexText.replaceAll('require("../global.less");', '');
|
|
345
324
|
replaceIndexText = 'require("../global.less");\n' + replaceIndexText;
|
|
346
|
-
return [3,
|
|
347
|
-
case
|
|
325
|
+
return [3, 11];
|
|
326
|
+
case 10:
|
|
348
327
|
e_2 = _a.sent();
|
|
349
328
|
replaceIndexText = replaceIndexText.replaceAll('require("../global.less");', '');
|
|
350
|
-
return [3,
|
|
351
|
-
case
|
|
352
|
-
if (!(templateType === 'vue')) return [3,
|
|
329
|
+
return [3, 11];
|
|
330
|
+
case 11:
|
|
331
|
+
if (!(templateType === 'vue')) return [3, 13];
|
|
353
332
|
replaceIndexText = replaceIndexText.replace('"./Container"', '"./Container.vue"');
|
|
354
333
|
return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, './src/.swico/index.js'), replaceIndexText)];
|
|
355
|
-
case 10:
|
|
356
|
-
_a.sent();
|
|
357
|
-
replaceHooksText = fs_extra_1.default.readFileSync(path_1.default.resolve(projectPath, './src/.swico/hooks.js'), 'utf8');
|
|
358
|
-
if (env === 'prod') {
|
|
359
|
-
replaceHooksText = replaceHooksText.replaceAll('require("./config")', 'require("./config.prod")');
|
|
360
|
-
}
|
|
361
|
-
else {
|
|
362
|
-
replaceHooksText = replaceIndexText.replaceAll('require("./config.prod")', 'require("./config")');
|
|
363
|
-
}
|
|
364
|
-
return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, './src/.swico/hooks.js'), replaceHooksText)];
|
|
365
|
-
case 11:
|
|
366
|
-
_a.sent();
|
|
367
|
-
return [3, 19];
|
|
368
334
|
case 12:
|
|
369
|
-
|
|
335
|
+
_a.sent();
|
|
370
336
|
_a.label = 13;
|
|
371
337
|
case 13:
|
|
372
|
-
|
|
373
|
-
|
|
338
|
+
if (!(templateType === 'react')) return [3, 19];
|
|
339
|
+
_a.label = 14;
|
|
374
340
|
case 14:
|
|
341
|
+
_a.trys.push([14, 16, 17, 19]);
|
|
342
|
+
return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/loading/index.tsx'), fs_extra_1.default.constants.F_OK)];
|
|
343
|
+
case 15:
|
|
375
344
|
_a.sent();
|
|
376
345
|
replaceIndexText = replaceIndexText.replace('"./loading"', '"../loading"');
|
|
377
346
|
return [3, 19];
|
|
378
|
-
case
|
|
347
|
+
case 16:
|
|
379
348
|
e_3 = _a.sent();
|
|
380
349
|
replaceIndexText = replaceIndexText.replace('"../loading"', '"./loading"');
|
|
381
350
|
return [3, 19];
|
|
382
|
-
case
|
|
383
|
-
case 17:
|
|
384
|
-
_a.sent();
|
|
385
|
-
replaceHistoryText = fs_extra_1.default.readFileSync(path_1.default.resolve(projectPath, './src/.swico/history.js'), 'utf8');
|
|
386
|
-
if (env === 'prod') {
|
|
387
|
-
replaceHistoryText = replaceHistoryText.replaceAll('require("./config")', 'require("./config.prod")');
|
|
388
|
-
replaceHistoryText = replaceHistoryText.replaceAll('require("./routes")', 'require("./routes.prod")');
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
replaceHistoryText = replaceHistoryText.replaceAll('require("./config.prod")', 'require("./config")');
|
|
392
|
-
replaceHistoryText = replaceHistoryText.replaceAll('require("./routes.prod")', 'require("./routes")');
|
|
393
|
-
}
|
|
394
|
-
return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, './src/.swico/history.js'), replaceHistoryText)];
|
|
351
|
+
case 17: return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, './src/.swico/index.js'), replaceIndexText)];
|
|
395
352
|
case 18:
|
|
396
353
|
_a.sent();
|
|
397
354
|
return [7];
|
package/src/utils/tools.d.ts
CHANGED
package/src/utils/tools.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -62,12 +39,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
62
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
40
|
};
|
|
64
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
-
exports.
|
|
42
|
+
exports.writeFile = exports.toast = exports.getPort = exports.copyDirFiles = void 0;
|
|
66
43
|
var portfinder_1 = __importDefault(require("portfinder"));
|
|
67
44
|
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
68
45
|
var path_1 = __importDefault(require("path"));
|
|
69
46
|
var chalk_1 = __importDefault(require("chalk"));
|
|
70
|
-
var process = __importStar(require("process"));
|
|
71
47
|
var copyDirFiles = function (src, dest, filter) { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
48
|
var _copy, e_1;
|
|
73
49
|
return __generator(this, function (_a) {
|
|
@@ -126,10 +102,10 @@ var getPort = function () {
|
|
|
126
102
|
exports.getPort = getPort;
|
|
127
103
|
exports.toast = {
|
|
128
104
|
info: function (message) {
|
|
129
|
-
console.log("\n
|
|
105
|
+
console.log("\n".concat(chalk_1.default.hex('#5f72f5')(message), "\n"));
|
|
130
106
|
},
|
|
131
107
|
error: function (message) {
|
|
132
|
-
console.log("\n
|
|
108
|
+
console.log("\n".concat(chalk_1.default.hex('#5f72f5')('There are some errors about Swico:'), " \n"));
|
|
133
109
|
if (Array.isArray(message)) {
|
|
134
110
|
message.forEach(function (item) {
|
|
135
111
|
console.log(" > ".concat(chalk_1.default.red.bold(item), " \n"));
|
|
@@ -140,7 +116,7 @@ exports.toast = {
|
|
|
140
116
|
}
|
|
141
117
|
},
|
|
142
118
|
warning: function (message) {
|
|
143
|
-
console.log("\n
|
|
119
|
+
console.log("\n".concat(chalk_1.default.hex('#5f72f5')('There are some warnings about Swico:'), " \n"));
|
|
144
120
|
if (Array.isArray(message)) {
|
|
145
121
|
message.forEach(function (item) {
|
|
146
122
|
console.log(" > ".concat(chalk_1.default.hex('#fb8918').bold(item), " \n"));
|
|
@@ -166,23 +142,3 @@ var writeFile = function (sourcePath, text) {
|
|
|
166
142
|
});
|
|
167
143
|
};
|
|
168
144
|
exports.writeFile = writeFile;
|
|
169
|
-
var initIndexFile = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
170
|
-
var fileText, targetPath, formatHooksPath;
|
|
171
|
-
return __generator(this, function (_a) {
|
|
172
|
-
switch (_a.label) {
|
|
173
|
-
case 0:
|
|
174
|
-
fileText = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, '../index.js'), 'utf8');
|
|
175
|
-
console.log('fileText', fileText);
|
|
176
|
-
targetPath = path_1.default.resolve(__dirname, '../index.js');
|
|
177
|
-
formatHooksPath = path_1.default
|
|
178
|
-
.resolve(process.cwd(), './src/.swico/hooks')
|
|
179
|
-
.replaceAll('\\', '/');
|
|
180
|
-
fileText = fileText.replaceAll("require(\"".concat(formatHooksPath, "\");"), 'require("./template/react/hooks");');
|
|
181
|
-
return [4, (0, exports.writeFile)(targetPath, fileText)];
|
|
182
|
-
case 1:
|
|
183
|
-
_a.sent();
|
|
184
|
-
return [2];
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
}); };
|
|
188
|
-
exports.initIndexFile = initIndexFile;
|