swico 0.6.0-beta23 → 0.6.0-beta25
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/build.js +2 -2
- package/src/command/start.js +2 -2
- package/src/utils/config.js +8 -9
- package/src/utils/tools.d.ts +2 -1
- package/src/utils/tools.js +5 -3
package/package.json
CHANGED
package/src/command/build.js
CHANGED
|
@@ -55,8 +55,8 @@ function default_1() {
|
|
|
55
55
|
case 0:
|
|
56
56
|
process.env.SWICO_ENV = 'prod';
|
|
57
57
|
tools_1.toast.info("Swico v".concat(package_json_1.default.version));
|
|
58
|
-
|
|
59
|
-
return [4, (0, tools_1.initIndexFile)()];
|
|
58
|
+
tools_1.toast.info('Initializing Swico production config...');
|
|
59
|
+
return [4, (0, tools_1.initIndexFile)('prod')];
|
|
60
60
|
case 1:
|
|
61
61
|
_a.sent();
|
|
62
62
|
return [4, (0, config_1.getProjectConfig)('prod')];
|
package/src/command/start.js
CHANGED
|
@@ -132,8 +132,8 @@ function start() {
|
|
|
132
132
|
case 0:
|
|
133
133
|
process.env.SWICO_ENV = 'dev';
|
|
134
134
|
tools_1.toast.info("Swico v".concat(package_json_1.default.version));
|
|
135
|
-
|
|
136
|
-
return [4, (0, tools_1.initIndexFile)()];
|
|
135
|
+
tools_1.toast.info('Initializing Swico development config...\n');
|
|
136
|
+
return [4, (0, tools_1.initIndexFile)('dev')];
|
|
137
137
|
case 1:
|
|
138
138
|
_b.sent();
|
|
139
139
|
if (!(envPort !== null && envPort !== void 0)) return [3, 2];
|
package/src/utils/config.js
CHANGED
|
@@ -299,14 +299,6 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
|
|
|
299
299
|
_a.sent();
|
|
300
300
|
replaceIndexText = fs_extra_1.default.readFileSync(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), 'utf8');
|
|
301
301
|
replaceIndexText = replaceIndexText.replaceAll('require("../global");', '');
|
|
302
|
-
if (env === 'prod') {
|
|
303
|
-
if (templateType === 'react') {
|
|
304
|
-
replaceIndexText = replaceIndexText.replaceAll('require("../layout")', 'require("../../layout")');
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
replaceIndexText = replaceIndexText.replaceAll('require("../layout/Layout")', 'require("../../layout/Layout")');
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
302
|
envAncPath = env === 'dev' ? '..' : '../..';
|
|
311
303
|
_a.label = 3;
|
|
312
304
|
case 3:
|
|
@@ -336,6 +328,9 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
|
|
|
336
328
|
case 9:
|
|
337
329
|
if (!(templateType === 'vue')) return [3, 11];
|
|
338
330
|
replaceIndexText = replaceIndexText.replace('"./Container"', '"./Container.vue"');
|
|
331
|
+
if (env === 'prod') {
|
|
332
|
+
replaceIndexText = replaceIndexText.replaceAll('require("../layout/Layout")', 'require("../../layout/Layout")');
|
|
333
|
+
}
|
|
339
334
|
return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), replaceIndexText)];
|
|
340
335
|
case 10:
|
|
341
336
|
_a.sent();
|
|
@@ -354,7 +349,11 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
|
|
|
354
349
|
e_3 = _a.sent();
|
|
355
350
|
replaceIndexText = replaceIndexText.replace('"../loading"', '"./loading"');
|
|
356
351
|
return [3, 17];
|
|
357
|
-
case 15:
|
|
352
|
+
case 15:
|
|
353
|
+
if (env === 'prod') {
|
|
354
|
+
replaceIndexText = replaceIndexText.replaceAll('require("../layout")', 'require("../../layout")');
|
|
355
|
+
}
|
|
356
|
+
return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), replaceIndexText)];
|
|
358
357
|
case 16:
|
|
359
358
|
_a.sent();
|
|
360
359
|
return [7];
|
package/src/utils/tools.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GlobalData } from './config';
|
|
1
2
|
export declare const copyDirFiles: (src: any, dest: any, filter?: (fileName: any) => boolean) => Promise<any>;
|
|
2
3
|
export declare const getPort: () => Promise<number>;
|
|
3
4
|
export declare const toast: {
|
|
@@ -6,4 +7,4 @@ export declare const toast: {
|
|
|
6
7
|
warning: (message: string | string[]) => void;
|
|
7
8
|
};
|
|
8
9
|
export declare const writeFile: (sourcePath: any, text: any) => Promise<unknown>;
|
|
9
|
-
export declare const initIndexFile: () => Promise<void>;
|
|
10
|
+
export declare const initIndexFile: (env: GlobalData['env']) => Promise<void>;
|
package/src/utils/tools.js
CHANGED
|
@@ -166,16 +166,18 @@ var writeFile = function (sourcePath, text) {
|
|
|
166
166
|
});
|
|
167
167
|
};
|
|
168
168
|
exports.writeFile = writeFile;
|
|
169
|
-
var initIndexFile = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
170
|
-
var fileText, targetPath, formatHooksPath;
|
|
169
|
+
var initIndexFile = function (env) { return __awaiter(void 0, void 0, void 0, function () {
|
|
170
|
+
var envPath, fileText, targetPath, formatHooksPath;
|
|
171
171
|
return __generator(this, function (_a) {
|
|
172
172
|
switch (_a.label) {
|
|
173
173
|
case 0:
|
|
174
|
+
envPath = env === 'dev' ? '/' : '/.prod/';
|
|
174
175
|
fileText = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, '../index.js'), 'utf8');
|
|
175
176
|
targetPath = path_1.default.resolve(__dirname, '../index.js');
|
|
176
177
|
formatHooksPath = path_1.default
|
|
177
|
-
.resolve(process.cwd(),
|
|
178
|
+
.resolve(process.cwd(), "./src/.swico".concat(envPath, "hooks.js"))
|
|
178
179
|
.replaceAll('\\', '/');
|
|
180
|
+
console.log('replace', "require(\"".concat(formatHooksPath, "\");"));
|
|
179
181
|
fileText = fileText.replaceAll("require(\"".concat(formatHooksPath, "\");"), 'require("./template/react/hooks");');
|
|
180
182
|
return [4, (0, exports.writeFile)(targetPath, fileText)];
|
|
181
183
|
case 1:
|