swico 2.5.0-beta.1 → 2.5.0-beta.3
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
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {
|
|
2
|
+
error: import("vue").Ref<string, string>;
|
|
3
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
4
|
export default _default;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const vue_1 = require("vue");
|
|
4
|
-
exports.default = (0, vue_1.defineComponent)({
|
|
4
|
+
exports.default = (0, vue_1.defineComponent)({
|
|
5
|
+
name: 'Container',
|
|
6
|
+
setup(props) {
|
|
7
|
+
const error = (0, vue_1.ref)(null);
|
|
8
|
+
(0, vue_1.onErrorCaptured)((err) => {
|
|
9
|
+
error.value = err.toString();
|
|
10
|
+
return false;
|
|
11
|
+
});
|
|
12
|
+
return { error };
|
|
13
|
+
},
|
|
14
|
+
template: '<Layout v-if="!error"><RouterView /></Layout>'
|
|
15
|
+
});
|
package/src/task.js
CHANGED
|
@@ -14,18 +14,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const copyVueFiles = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
const filePath = path_1.default.resolve(__dirname, './project-path/.swico-vue/Container.vue');
|
|
19
|
-
const targetPath = path_1.default.resolve(__dirname, '../dist/src/project-path/.swico-vue/Container.vue');
|
|
20
|
-
yield fs_extra_1.default.copyFile(filePath, targetPath);
|
|
21
|
-
});
|
|
22
17
|
const copyReadMeFiles = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
18
|
const filePath = path_1.default.resolve(__dirname, '../README.md');
|
|
24
19
|
const targetPath = path_1.default.resolve(__dirname, '../dist/README.md');
|
|
25
20
|
yield fs_extra_1.default.copyFile(filePath, targetPath);
|
|
26
21
|
});
|
|
27
22
|
const main = () => {
|
|
28
|
-
copyVueFiles();
|
|
29
23
|
copyReadMeFiles();
|
|
30
24
|
};
|
|
31
25
|
main();
|
package/src/utils/config.js
CHANGED
|
@@ -234,22 +234,18 @@ const initTemplateConfig = (routerConfig, templateType, env) => {
|
|
|
234
234
|
const envPath = env === 'dev' ? '/.dev/' : '/.prod/';
|
|
235
235
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
236
236
|
const copyTargetPath = path_1.default.resolve(projectPath, `./.swico${envPath}`);
|
|
237
|
-
yield (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, `../project-path/.swico-${templateType}/$env`), copyTargetPath, (fileName) => !fileName.endsWith('.d.ts') &&
|
|
238
|
-
|
|
239
|
-
? !['Container.js', 'hooks.js'].includes(fileName)
|
|
240
|
-
: !['hooks.js'].includes(fileName)));
|
|
241
|
-
yield (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, `../project-path/.swico-${templateType}`), path_1.default.resolve(projectPath, './.swico'), (fileName) => ['hooks.js', 'Link.js', 'loading.js', 'Container.vue'].includes(fileName));
|
|
237
|
+
yield (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, `../project-path/.swico-${templateType}/$env`), copyTargetPath, (fileName) => !fileName.endsWith('.d.ts') && !['hooks.js'].includes(fileName));
|
|
238
|
+
yield (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, `../project-path/.swico-${templateType}`), path_1.default.resolve(projectPath, './.swico'), (fileName) => ['hooks.js', 'Link.js', 'loading.js'].includes(fileName));
|
|
242
239
|
const entryFilePath = path_1.default.resolve(projectPath, './.swico/index.js');
|
|
243
|
-
yield fs_extra_1.default.copyFile(path_1.default.resolve(__dirname, `../index.${templateType}`), entryFilePath);
|
|
240
|
+
yield fs_extra_1.default.copyFile(path_1.default.resolve(__dirname, `../index.${templateType}.js`), entryFilePath);
|
|
244
241
|
yield formatRouterConfig(routerConfig, templateType, env);
|
|
245
|
-
const hooksFilePath = path_1.default.resolve(projectPath,
|
|
242
|
+
const hooksFilePath = path_1.default.resolve(projectPath, './.swico/hooks.js');
|
|
246
243
|
let replaceHooksText = yield fs_extra_1.default.readFile(hooksFilePath, 'utf8');
|
|
247
244
|
replaceHooksText = replaceHooksText.replaceAll('$env', `.${env}`);
|
|
248
245
|
yield fs_extra_1.default.writeFile(hooksFilePath, replaceHooksText);
|
|
249
246
|
let replaceIndexText = yield fs_extra_1.default.readFile(path_1.default.resolve(projectPath, `./.swico${envPath}index.js`), 'utf8');
|
|
250
247
|
replaceIndexText = (0, exports.handleGlobalStyleFile)(replaceIndexText);
|
|
251
248
|
if (templateType === 'vue') {
|
|
252
|
-
replaceIndexText = replaceIndexText.replace('"../Container"', '"../Container.vue"');
|
|
253
249
|
yield (0, exports.updateIndexFileText)(envPath, replaceIndexText);
|
|
254
250
|
}
|
|
255
251
|
else if (templateType === 'react') {
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { onErrorCaptured, ref } from 'vue';
|
|
3
|
-
const error = ref<string | null>(null);
|
|
4
|
-
onErrorCaptured((err, instance, info) => {
|
|
5
|
-
console.error(err);
|
|
6
|
-
error.value = err.toString();
|
|
7
|
-
return false;
|
|
8
|
-
});
|
|
9
|
-
</script>
|
|
10
|
-
|
|
11
|
-
<template>
|
|
12
|
-
<Layout v-if="!error"><RouterView /></Layout>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<style scoped></style>
|