swico 0.6.0-beta31 → 0.6.0-beta33
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/index.react.d.ts +1 -1
- package/src/index.react.js +2 -2
- package/src/index.vue.d.ts +1 -1
- package/src/index.vue.js +2 -2
- package/src/utils/config.js +31 -29
- package/src/utils/tools.js +5 -5
- /package/src/template/react/{hooks.d.ts → reac-hooks.d.ts} +0 -0
- /package/src/template/react/{hooks.js → reac-hooks.js} +0 -0
- /package/src/template/vue/{hooks.d.ts → vue-hooks.d.ts} +0 -0
- /package/src/template/vue/{hooks.js → vue-hooks.js} +0 -0
package/package.json
CHANGED
package/src/index.react.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const Link: FC<{
|
|
|
10
10
|
children: ReactNode;
|
|
11
11
|
}>;
|
|
12
12
|
export { Outlet } from 'react-router-dom';
|
|
13
|
-
export { useLocation } from './template/react/hooks';
|
|
13
|
+
export { useLocation } from './template/react/reac-hooks';
|
|
14
14
|
export interface DefineSwicoConfigType {
|
|
15
15
|
(env: 'base', config: CustomConfigType['base']): any;
|
|
16
16
|
(env: 'dev', config: CustomConfigType['dev']): any;
|
package/src/index.react.js
CHANGED
|
@@ -13,8 +13,8 @@ var Link = function (_a) {
|
|
|
13
13
|
exports.Link = Link;
|
|
14
14
|
var react_router_dom_2 = require("react-router-dom");
|
|
15
15
|
Object.defineProperty(exports, "Outlet", { enumerable: true, get: function () { return react_router_dom_2.Outlet; } });
|
|
16
|
-
var
|
|
17
|
-
Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return
|
|
16
|
+
var reac_hooks_1 = require("./template/react/reac-hooks");
|
|
17
|
+
Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return reac_hooks_1.useLocation; } });
|
|
18
18
|
var defineConfig = function (env, config) { return config; };
|
|
19
19
|
exports.defineConfig = defineConfig;
|
|
20
20
|
var defineGlobal = function (config) {
|
package/src/index.vue.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { App } from 'vue';
|
|
|
3
3
|
import { Router } from 'vue-router';
|
|
4
4
|
export type CustomConfigType = GlobalData['customConfig'];
|
|
5
5
|
export { RouterView as Outlet } from 'vue-router';
|
|
6
|
-
export { useLocation } from './template/vue/hooks';
|
|
6
|
+
export { useLocation } from './template/vue/vue-hooks';
|
|
7
7
|
export type { GlobalSwicoConfigType };
|
|
8
8
|
export declare const Link: import("vue").DefineComponent<{
|
|
9
9
|
to: {
|
package/src/index.vue.js
CHANGED
|
@@ -5,8 +5,8 @@ var vue_1 = require("vue");
|
|
|
5
5
|
var vue_router_1 = require("vue-router");
|
|
6
6
|
var vue_router_2 = require("vue-router");
|
|
7
7
|
Object.defineProperty(exports, "Outlet", { enumerable: true, get: function () { return vue_router_2.RouterView; } });
|
|
8
|
-
var
|
|
9
|
-
Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return
|
|
8
|
+
var vue_hooks_1 = require("./template/vue/vue-hooks");
|
|
9
|
+
Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return vue_hooks_1.useLocation; } });
|
|
10
10
|
exports.Link = (0, vue_1.defineComponent)({
|
|
11
11
|
components: {
|
|
12
12
|
RouterLink: vue_router_1.RouterLink
|
package/src/utils/config.js
CHANGED
|
@@ -231,9 +231,9 @@ var initCliIndexFile = function (templateType) { return __awaiter(void 0, void 0
|
|
|
231
231
|
fileTypesText = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, "../index.".concat(templateType, ".d.ts")), 'utf8');
|
|
232
232
|
if (templateType === 'react') {
|
|
233
233
|
formatHooksPath = path_1.default
|
|
234
|
-
.resolve(projectPath, './src/.swico/hooks')
|
|
234
|
+
.resolve(projectPath, './src/.swico/react-hooks')
|
|
235
235
|
.replaceAll('\\', '/');
|
|
236
|
-
replaceFileText = replaceFileText.replaceAll('require("./template/react/hooks");', "require(\"".concat(formatHooksPath, "\");"));
|
|
236
|
+
replaceFileText = replaceFileText.replaceAll('require("./template/react/react-hooks");', "require(\"".concat(formatHooksPath, "\");"));
|
|
237
237
|
}
|
|
238
238
|
return [4, (0, tools_1.writeFile)(targetPath, replaceFileText)];
|
|
239
239
|
case 1:
|
|
@@ -283,7 +283,7 @@ var formatRouterConfig = function (_a, templateType, env) {
|
|
|
283
283
|
var initTemplateConfig = function (routerConfig, templateType, env) {
|
|
284
284
|
var envPath = env === 'dev' ? '/.dev/' : '/.prod/';
|
|
285
285
|
return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
|
286
|
-
var copyTargetPath, replaceIndexText, replaceHooksText, e_1, e_2;
|
|
286
|
+
var copyTargetPath, replaceIndexText, hooksFilePath, replaceHooksText, e_1, e_2;
|
|
287
287
|
return __generator(this, function (_a) {
|
|
288
288
|
switch (_a.label) {
|
|
289
289
|
case 0:
|
|
@@ -291,61 +291,63 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
|
|
|
291
291
|
return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType, "/.env")), copyTargetPath, function (fileName) {
|
|
292
292
|
return !fileName.endsWith('.d.ts') &&
|
|
293
293
|
(templateType === 'vue'
|
|
294
|
-
? !['Container.js', 'hooks.js'].includes(fileName)
|
|
295
|
-
: !['hooks.js'].includes(fileName));
|
|
294
|
+
? !['Container.js', 'vue-hooks.js'].includes(fileName)
|
|
295
|
+
: !['react-hooks.js'].includes(fileName));
|
|
296
296
|
})];
|
|
297
297
|
case 1:
|
|
298
298
|
_a.sent();
|
|
299
|
-
return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType)), path_1.default.resolve(projectPath, './src/.swico'), function (fileName) { return ['hooks.js', 'loading.js'].includes(fileName); })];
|
|
299
|
+
return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType)), path_1.default.resolve(projectPath, './src/.swico'), function (fileName) { return ['react-hooks.js', 'vue-hooks.js', 'loading.js'].includes(fileName); })];
|
|
300
300
|
case 2:
|
|
301
301
|
_a.sent();
|
|
302
302
|
return [4, formatRouterConfig(routerConfig, templateType, env)];
|
|
303
303
|
case 3:
|
|
304
304
|
_a.sent();
|
|
305
305
|
replaceIndexText = fs_extra_1.default.readFileSync(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), 'utf8');
|
|
306
|
-
|
|
306
|
+
hooksFilePath = path_1.default.resolve(projectPath, "./src/.swico/".concat(templateType, "-hooks.js"));
|
|
307
|
+
replaceHooksText = fs_extra_1.default.readFileSync(hooksFilePath, 'utf8');
|
|
307
308
|
replaceHooksText = replaceHooksText.replaceAll('.env', ".".concat(env));
|
|
308
|
-
|
|
309
|
+
return [4, (0, tools_1.writeFile)(hooksFilePath, replaceHooksText)];
|
|
309
310
|
case 4:
|
|
310
|
-
_a.
|
|
311
|
-
|
|
311
|
+
_a.sent();
|
|
312
|
+
_a.label = 5;
|
|
312
313
|
case 5:
|
|
314
|
+
_a.trys.push([5, 7, , 8]);
|
|
315
|
+
return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/global.less'), fs_extra_1.default.constants.F_OK)];
|
|
316
|
+
case 6:
|
|
313
317
|
_a.sent();
|
|
314
318
|
replaceIndexText = replaceIndexText.replaceAll('require("../../global.less");', '');
|
|
315
319
|
replaceIndexText = 'require("../../global.less");\n' + replaceIndexText;
|
|
316
|
-
return [3,
|
|
317
|
-
case
|
|
320
|
+
return [3, 8];
|
|
321
|
+
case 7:
|
|
318
322
|
e_1 = _a.sent();
|
|
319
323
|
replaceIndexText = replaceIndexText.replaceAll('require("../../global.less");', '');
|
|
320
|
-
return [3,
|
|
321
|
-
case
|
|
322
|
-
if (!(templateType === 'vue')) return [3,
|
|
324
|
+
return [3, 8];
|
|
325
|
+
case 8:
|
|
326
|
+
if (!(templateType === 'vue')) return [3, 10];
|
|
323
327
|
replaceIndexText = replaceIndexText.replace('"./Container"', '"./Container.vue"');
|
|
324
328
|
return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), replaceIndexText)];
|
|
325
|
-
case 8:
|
|
326
|
-
_a.sent();
|
|
327
|
-
return [3, 15];
|
|
328
329
|
case 9:
|
|
329
|
-
|
|
330
|
-
|
|
330
|
+
_a.sent();
|
|
331
|
+
return [3, 16];
|
|
331
332
|
case 10:
|
|
332
|
-
|
|
333
|
-
|
|
333
|
+
if (!(templateType === 'react')) return [3, 16];
|
|
334
|
+
_a.label = 11;
|
|
334
335
|
case 11:
|
|
336
|
+
_a.trys.push([11, 13, 14, 16]);
|
|
337
|
+
return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/loading/index.tsx'), fs_extra_1.default.constants.F_OK)];
|
|
338
|
+
case 12:
|
|
335
339
|
_a.sent();
|
|
336
340
|
replaceIndexText = replaceIndexText.replace('"../loading"', '"../../loading"');
|
|
337
|
-
return [3,
|
|
338
|
-
case
|
|
341
|
+
return [3, 16];
|
|
342
|
+
case 13:
|
|
339
343
|
e_2 = _a.sent();
|
|
340
344
|
replaceIndexText = replaceIndexText.replace('"../../loading"', '"../loading"');
|
|
341
|
-
return [3,
|
|
342
|
-
case
|
|
343
|
-
case
|
|
345
|
+
return [3, 16];
|
|
346
|
+
case 14: return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), replaceIndexText)];
|
|
347
|
+
case 15:
|
|
344
348
|
_a.sent();
|
|
345
349
|
return [7];
|
|
346
|
-
case 15: return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, './src/.swico/hooks.js'), replaceHooksText)];
|
|
347
350
|
case 16:
|
|
348
|
-
_a.sent();
|
|
349
351
|
resolve(null);
|
|
350
352
|
return [2];
|
|
351
353
|
}
|
package/src/utils/tools.js
CHANGED
|
@@ -174,15 +174,15 @@ var initIndexFile = function () { return __awaiter(void 0, void 0, void 0, funct
|
|
|
174
174
|
fileText = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, '../index.js'), 'utf8');
|
|
175
175
|
targetPath = path_1.default.resolve(__dirname, '../index.js');
|
|
176
176
|
formatHooksPath = path_1.default
|
|
177
|
-
.resolve(process.cwd(), './src/.swico/hooks')
|
|
177
|
+
.resolve(process.cwd(), './src/.swico/react-hooks')
|
|
178
178
|
.replaceAll('\\', '/');
|
|
179
|
-
|
|
180
|
-
fileText = fileText.replaceAll("require(\"".concat(formatHooksPath, "\");"), 'require("./template/react/hooks");');
|
|
181
|
-
console.log('fileText', fileText);
|
|
179
|
+
if (!fileText.includes("require(\"".concat(formatHooksPath, "\");"))) return [3, 2];
|
|
180
|
+
fileText = fileText.replaceAll("require(\"".concat(formatHooksPath, "\");"), 'require("./template/react/react-hooks");');
|
|
182
181
|
return [4, (0, exports.writeFile)(targetPath, fileText)];
|
|
183
182
|
case 1:
|
|
184
183
|
_a.sent();
|
|
185
|
-
|
|
184
|
+
_a.label = 2;
|
|
185
|
+
case 2: return [2];
|
|
186
186
|
}
|
|
187
187
|
});
|
|
188
188
|
}); };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|