swico 0.7.0 → 0.7.2
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/utils/config.js +1 -29
- package/src/utils/tools.d.ts +2 -1
- package/src/utils/tools.js +41 -1
package/package.json
CHANGED
package/src/utils/config.js
CHANGED
|
@@ -194,34 +194,6 @@ var getProjectConfig = function (env) { return __awaiter(void 0, void 0, void 0,
|
|
|
194
194
|
});
|
|
195
195
|
}); };
|
|
196
196
|
exports.getProjectConfig = getProjectConfig;
|
|
197
|
-
var getFormatRouter = function (routes, templateType) {
|
|
198
|
-
var _main = function (item) {
|
|
199
|
-
var path = item.path, component = item.component, name = item.name, children = item.children, redirect = item.redirect, decorator = item.decorator;
|
|
200
|
-
return decorator
|
|
201
|
-
? __assign(__assign({}, item), { component: "()=>import('".concat(projectPath, "/src/pages/").concat(decorator).concat(templateType === 'vue' ? '.vue' : '', "')"), children: [
|
|
202
|
-
{
|
|
203
|
-
path: '',
|
|
204
|
-
component: component
|
|
205
|
-
? "()=>import('".concat(projectPath, "/src/pages/").concat(component).concat(templateType === 'vue' ? '.vue' : '', "')")
|
|
206
|
-
: undefined,
|
|
207
|
-
name: name,
|
|
208
|
-
redirect: redirect,
|
|
209
|
-
children: children ? children === null || children === void 0 ? void 0 : children.map(function (item) { return _main(item); }) : undefined
|
|
210
|
-
}
|
|
211
|
-
] }) : {
|
|
212
|
-
path: path,
|
|
213
|
-
component: component
|
|
214
|
-
? "()=>import('".concat(projectPath, "/src/pages/").concat(component).concat(templateType === 'vue' ? '.vue' : '', "')")
|
|
215
|
-
: undefined,
|
|
216
|
-
name: name,
|
|
217
|
-
redirect: redirect,
|
|
218
|
-
children: children ? children === null || children === void 0 ? void 0 : children.map(function (item) { return _main(item); }) : undefined
|
|
219
|
-
};
|
|
220
|
-
};
|
|
221
|
-
return routes.map(function (item) {
|
|
222
|
-
return _main(item);
|
|
223
|
-
});
|
|
224
|
-
};
|
|
225
197
|
var initCliIndexFile = function (templateType, env) { return __awaiter(void 0, void 0, void 0, function () {
|
|
226
198
|
var targetPath, targetTypesPath, replaceFileText, fileTypesText, formatHooksPath, formatHistoryPath;
|
|
227
199
|
return __generator(this, function (_a) {
|
|
@@ -261,7 +233,7 @@ var formatRouterConfig = function (_a, templateType, env) {
|
|
|
261
233
|
return __generator(this, function (_a) {
|
|
262
234
|
switch (_a.label) {
|
|
263
235
|
case 0:
|
|
264
|
-
formatRouter = getFormatRouter(routes, templateType);
|
|
236
|
+
formatRouter = (0, tools_1.getFormatRouter)(projectPath, routes, templateType);
|
|
265
237
|
textData = "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.default = ".concat(JSON.stringify(formatRouter), ";");
|
|
266
238
|
modifiedText = textData.replace(/"(\(\)=>import\('[^']+'\))"/g, '$1');
|
|
267
239
|
return [4, fs_extra_1.default.writeFile(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "routes.js")), modifiedText)];
|
package/src/utils/tools.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { GlobalData } from './config';
|
|
1
|
+
import { ConfigRouterType, GlobalData } from './config';
|
|
2
2
|
export declare const copyDirFiles: (src: any, dest: any, filter?: (fileName: any) => boolean) => Promise<void>;
|
|
3
|
+
export declare const getFormatRouter: (projectPath: string, routes: ConfigRouterType['routes'], templateType: any) => any[];
|
|
3
4
|
export declare const getPort: () => Promise<number>;
|
|
4
5
|
export declare const toast: {
|
|
5
6
|
info: (message: string) => void;
|
package/src/utils/tools.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
14
|
if (k2 === undefined) k2 = k;
|
|
4
15
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -69,7 +80,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
69
80
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
70
81
|
};
|
|
71
82
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
|
-
exports.initIndexFile = exports.toast = exports.getPort = exports.copyDirFiles = void 0;
|
|
83
|
+
exports.initIndexFile = exports.toast = exports.getPort = exports.getFormatRouter = exports.copyDirFiles = void 0;
|
|
73
84
|
var portfinder_1 = __importDefault(require("portfinder"));
|
|
74
85
|
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
75
86
|
var path_1 = __importDefault(require("path"));
|
|
@@ -157,6 +168,35 @@ var copyDirFiles = function (src, dest, filter) { return __awaiter(void 0, void
|
|
|
157
168
|
});
|
|
158
169
|
}); };
|
|
159
170
|
exports.copyDirFiles = copyDirFiles;
|
|
171
|
+
var getFormatRouter = function (projectPath, routes, templateType) {
|
|
172
|
+
var _main = function (item) {
|
|
173
|
+
var path = item.path, component = item.component, name = item.name, children = item.children, redirect = item.redirect, decorator = item.decorator;
|
|
174
|
+
return decorator
|
|
175
|
+
? __assign(__assign({}, item), { component: "()=>import('".concat(projectPath, "/src/pages/").concat(decorator).concat(templateType === 'vue' ? '.vue' : '', "')"), children: [
|
|
176
|
+
{
|
|
177
|
+
path: '',
|
|
178
|
+
component: component
|
|
179
|
+
? "()=>import('".concat(projectPath, "/src/pages/").concat(component).concat(templateType === 'vue' ? '.vue' : '', "')")
|
|
180
|
+
: undefined,
|
|
181
|
+
name: name,
|
|
182
|
+
redirect: redirect,
|
|
183
|
+
children: children ? children === null || children === void 0 ? void 0 : children.map(function (item) { return _main(item); }) : undefined
|
|
184
|
+
}
|
|
185
|
+
] }) : {
|
|
186
|
+
path: path,
|
|
187
|
+
component: component
|
|
188
|
+
? "()=>import('".concat(projectPath, "/src/pages/").concat(component).concat(templateType === 'vue' ? '.vue' : '', "')")
|
|
189
|
+
: undefined,
|
|
190
|
+
name: name,
|
|
191
|
+
redirect: redirect,
|
|
192
|
+
children: children ? children === null || children === void 0 ? void 0 : children.map(function (item) { return _main(item); }) : undefined
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
return routes.map(function (item) {
|
|
196
|
+
return _main(item);
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
exports.getFormatRouter = getFormatRouter;
|
|
160
200
|
var getPort = function () {
|
|
161
201
|
return portfinder_1.default.getPortPromise({
|
|
162
202
|
port: 3000,
|