swico 0.8.0-beta2 → 0.8.0-beta4
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 +1 -1
- package/src/command/start.js +1 -1
- package/src/template/vue/vue-hooks.js +2 -2
- package/src/utils/tools.d.ts +2 -2
- package/src/utils/tools.js +18 -8
package/package.json
CHANGED
package/src/command/build.js
CHANGED
|
@@ -56,7 +56,7 @@ function default_1() {
|
|
|
56
56
|
process.env.SWICO_ENV = 'prod';
|
|
57
57
|
tools_1.toast.info("Swico v".concat(package_json_1.default.version));
|
|
58
58
|
tools_1.toast.info('Initializing Swico production config...');
|
|
59
|
-
return [4, (0, tools_1.initIndexFile)(
|
|
59
|
+
return [4, (0, tools_1.initIndexFile)()];
|
|
60
60
|
case 1:
|
|
61
61
|
_a.sent();
|
|
62
62
|
return [4, (0, config_1.getProjectConfig)('prod')];
|
package/src/command/start.js
CHANGED
|
@@ -133,7 +133,7 @@ function start() {
|
|
|
133
133
|
tools_1.toast.info("Swico v".concat(package_json_1.default.version));
|
|
134
134
|
tools_1.toast.info('Initializing Swico development config...');
|
|
135
135
|
}
|
|
136
|
-
return [4, (0, tools_1.initIndexFile)(
|
|
136
|
+
return [4, (0, tools_1.initIndexFile)()];
|
|
137
137
|
case 1:
|
|
138
138
|
_b.sent();
|
|
139
139
|
if (!(envPort !== null && envPort !== void 0)) return [3, 2];
|
|
@@ -43,7 +43,7 @@ var useNav = function () {
|
|
|
43
43
|
var newNavigate = function (to, options) {
|
|
44
44
|
switch (typeof to) {
|
|
45
45
|
case 'string':
|
|
46
|
-
if (options.replace) {
|
|
46
|
+
if (options === null || options === void 0 ? void 0 : options.replace) {
|
|
47
47
|
router.replace(to);
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
@@ -54,7 +54,7 @@ var useNav = function () {
|
|
|
54
54
|
router.go(to);
|
|
55
55
|
break;
|
|
56
56
|
case 'object':
|
|
57
|
-
if (options.replace) {
|
|
57
|
+
if (options === null || options === void 0 ? void 0 : options.replace) {
|
|
58
58
|
router.replace(to);
|
|
59
59
|
}
|
|
60
60
|
else {
|
package/src/utils/tools.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigRouterType
|
|
1
|
+
import { ConfigRouterType } from './config';
|
|
2
2
|
export declare const copyDirFiles: (src: any, dest: any, filter?: (fileName: any) => boolean) => Promise<void>;
|
|
3
3
|
export declare const getFormatRouter: (projectPath: string, routes: ConfigRouterType['routes'], templateType: any) => any[];
|
|
4
4
|
export declare const getPort: () => Promise<number>;
|
|
@@ -7,4 +7,4 @@ export declare const toast: {
|
|
|
7
7
|
error: (message: string | string[]) => void;
|
|
8
8
|
warning: (message: string | string[]) => void;
|
|
9
9
|
};
|
|
10
|
-
export declare const initIndexFile: (
|
|
10
|
+
export declare const initIndexFile: () => Promise<void>;
|
package/src/utils/tools.js
CHANGED
|
@@ -231,8 +231,8 @@ exports.toast = {
|
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
|
-
var initIndexFile = function (
|
|
235
|
-
var fileText, targetPath, formatHooksPath,
|
|
234
|
+
var initIndexFile = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
235
|
+
var fileText, targetPath, formatHooksPath, formatDevHistoryPath, formatProdHistoryPath;
|
|
236
236
|
return __generator(this, function (_a) {
|
|
237
237
|
switch (_a.label) {
|
|
238
238
|
case 0: return [4, fs_extra_1.default.readFile(path_1.default.resolve(__dirname, '../index.js'), 'utf8')];
|
|
@@ -249,16 +249,26 @@ var initIndexFile = function (env) { return __awaiter(void 0, void 0, void 0, fu
|
|
|
249
249
|
_a.sent();
|
|
250
250
|
_a.label = 3;
|
|
251
251
|
case 3:
|
|
252
|
-
|
|
253
|
-
.resolve(process.cwd(),
|
|
252
|
+
formatDevHistoryPath = path_1.default
|
|
253
|
+
.resolve(process.cwd(), './src/.swico/.dev/history')
|
|
254
254
|
.replaceAll('\\', '/');
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
formatProdHistoryPath = path_1.default
|
|
256
|
+
.resolve(process.cwd(), './src/.swico/.prod/history')
|
|
257
|
+
.replaceAll('\\', '/');
|
|
258
|
+
if (!fileText.includes("require(\"".concat(formatDevHistoryPath, "\");"))) return [3, 5];
|
|
259
|
+
fileText = fileText.replaceAll("require(\"".concat(formatDevHistoryPath, "\");"), 'require("./mock-history");');
|
|
257
260
|
return [4, fs_extra_1.default.writeFile(targetPath, fileText)];
|
|
258
261
|
case 4:
|
|
259
262
|
_a.sent();
|
|
260
|
-
|
|
261
|
-
case 5:
|
|
263
|
+
return [3, 7];
|
|
264
|
+
case 5:
|
|
265
|
+
if (!fileText.includes("require(\"".concat(formatProdHistoryPath, "\");"))) return [3, 7];
|
|
266
|
+
fileText = fileText.replaceAll("require(\"".concat(formatProdHistoryPath, "\");"), 'require("./mock-history");');
|
|
267
|
+
return [4, fs_extra_1.default.writeFile(targetPath, fileText)];
|
|
268
|
+
case 6:
|
|
269
|
+
_a.sent();
|
|
270
|
+
_a.label = 7;
|
|
271
|
+
case 7: return [2];
|
|
262
272
|
}
|
|
263
273
|
});
|
|
264
274
|
}); };
|