@varlet/cli 2.0.6 → 2.1.0-alpha.1667210582672
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/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/babel.config.cjs +29 -0
- package/cjs/babel.sfc.transform.cjs +18 -0
- package/cjs/jest.config.cjs +33 -0
- package/cjs/jest.media.mock.cjs +1 -0
- package/cjs/jest.style.mock.cjs +1 -0
- package/client.d.ts +1 -0
- package/client.js +1 -0
- package/lib/client/appType.d.ts +4 -0
- package/lib/client/appType.js +7 -0
- package/lib/client/index.d.ts +17 -0
- package/lib/client/index.js +106 -0
- package/lib/{bin.d.ts → node/bin.d.ts} +0 -0
- package/lib/node/bin.js +122 -0
- package/lib/{commands → node/commands}/build.d.ts +0 -0
- package/lib/node/commands/build.js +15 -0
- package/lib/{commands → node/commands}/changelog.d.ts +0 -0
- package/lib/node/commands/changelog.js +20 -0
- package/lib/{commands → node/commands}/commitLint.d.ts +0 -0
- package/lib/node/commands/commitLint.js +45 -0
- package/lib/{commands → node/commands}/compile.d.ts +0 -0
- package/lib/node/commands/compile.js +35 -0
- package/lib/{commands → node/commands}/create.d.ts +0 -0
- package/lib/node/commands/create.js +91 -0
- package/lib/{commands → node/commands}/dev.d.ts +0 -0
- package/lib/node/commands/dev.js +38 -0
- package/lib/{commands → node/commands}/gen.d.ts +0 -0
- package/lib/node/commands/gen.js +75 -0
- package/lib/{commands → node/commands}/jest.d.ts +0 -0
- package/lib/node/commands/jest.js +27 -0
- package/lib/{commands → node/commands}/lint.d.ts +0 -0
- package/lib/node/commands/lint.js +42 -0
- package/lib/{commands → node/commands}/preview.d.ts +0 -0
- package/lib/node/commands/preview.js +18 -0
- package/lib/{commands → node/commands}/release.d.ts +0 -0
- package/lib/node/commands/release.js +146 -0
- package/lib/{commands → node/commands}/vite.d.ts +0 -0
- package/lib/node/commands/vite.js +13 -0
- package/lib/{compiler → node/compiler}/compileModule.d.ts +0 -0
- package/lib/node/compiler/compileModule.js +74 -0
- package/lib/{compiler → node/compiler}/compileSFC.d.ts +0 -0
- package/lib/node/compiler/compileSFC.js +79 -0
- package/lib/{compiler → node/compiler}/compileScript.d.ts +1 -1
- package/lib/node/compiler/compileScript.js +141 -0
- package/lib/{compiler → node/compiler}/compileSiteEntry.d.ts +0 -0
- package/lib/node/compiler/compileSiteEntry.js +128 -0
- package/lib/{compiler → node/compiler}/compileStyle.d.ts +0 -0
- package/lib/node/compiler/compileStyle.js +39 -0
- package/lib/{compiler → node/compiler}/compileTemplateHighlight.d.ts +0 -0
- package/lib/node/compiler/compileTemplateHighlight.js +133 -0
- package/lib/{compiler → node/compiler}/compileTypes.d.ts +0 -0
- package/lib/node/compiler/compileTypes.js +45 -0
- package/lib/{config → node/config}/varlet.config.d.ts +5 -4
- package/lib/node/config/varlet.config.js +27 -0
- package/lib/node/config/varlet.default.config.d.ts +2 -0
- package/lib/node/config/varlet.default.config.js +264 -0
- package/lib/node/config/vite.config.d.ts +6 -0
- package/lib/node/config/vite.config.js +144 -0
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.js +1 -0
- package/lib/{shared → node/shared}/constant.d.ts +1 -2
- package/lib/node/shared/constant.js +47 -0
- package/lib/{shared → node/shared}/fsUtils.d.ts +1 -0
- package/lib/node/shared/fsUtils.js +48 -0
- package/lib/{shared → node/shared}/logger.d.ts +0 -0
- package/lib/node/shared/logger.js +18 -0
- package/package.json +22 -20
- package/{preset.js → preset.cjs} +1 -1
- package/site/components/code-example/CodeExample.vue +2 -1
- package/site/components/utils/components.ts +1 -4
- package/site/components/utils/elements.ts +1 -1
- package/site/mobile/App.vue +27 -26
- package/site/mobile/components/AppHome.vue +2 -1
- package/site/pc/App.vue +2 -1
- package/site/pc/Layout.vue +4 -3
- package/site/pc/components/AppHeader.vue +4 -2
- package/site/pc/pages/index/index.vue +8 -4
- package/site/useProgress.ts +2 -1
- package/site/utils.ts +6 -137
- package/template/create/index.ts.ejs +1 -1
- package/template/generators/config/default/base/{varlet.config.js → varlet.config.mjs} +2 -2
- package/template/generators/config/i18n/base/{varlet.config.js → varlet.config.mjs} +2 -2
- package/tsconfig.json +2 -9
- package/lib/bin.js +0 -102
- package/lib/commands/build.js +0 -67
- package/lib/commands/changelog.js +0 -27
- package/lib/commands/commitLint.js +0 -21
- package/lib/commands/compile.js +0 -119
- package/lib/commands/create.js +0 -166
- package/lib/commands/dev.js +0 -123
- package/lib/commands/gen.js +0 -138
- package/lib/commands/jest.js +0 -85
- package/lib/commands/lint.js +0 -123
- package/lib/commands/preview.js +0 -74
- package/lib/commands/release.js +0 -305
- package/lib/commands/vite.js +0 -69
- package/lib/compiler/compileModule.js +0 -190
- package/lib/compiler/compileSFC.js +0 -135
- package/lib/compiler/compileScript.js +0 -194
- package/lib/compiler/compileSiteEntry.js +0 -237
- package/lib/compiler/compileStyle.js +0 -91
- package/lib/compiler/compileTemplateHighlight.js +0 -193
- package/lib/compiler/compileTypes.js +0 -85
- package/lib/config/babel.config.d.ts +0 -2
- package/lib/config/babel.config.js +0 -31
- package/lib/config/babel.sfc.transform.d.ts +0 -1
- package/lib/config/babel.sfc.transform.js +0 -18
- package/lib/config/jest.config.d.ts +0 -1
- package/lib/config/jest.config.js +0 -37
- package/lib/config/jest.media.mock.d.ts +0 -0
- package/lib/config/jest.media.mock.js +0 -2
- package/lib/config/jest.style.mock.d.ts +0 -0
- package/lib/config/jest.style.mock.js +0 -2
- package/lib/config/varlet.config.js +0 -35
- package/lib/config/vite.config.d.ts +0 -5
- package/lib/config/vite.config.js +0 -162
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -5
- package/lib/shared/constant.js +0 -50
- package/lib/shared/fsUtils.js +0 -108
- package/lib/shared/logger.js +0 -23
- package/site/mobile/components/AppType.vue +0 -22
- package/varlet.default.config.js +0 -267
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.compileSFC = exports.injectRender = void 0;
|
|
43
|
-
var hash_sum_1 = __importDefault(require("hash-sum"));
|
|
44
|
-
var path_1 = require("path");
|
|
45
|
-
var fs_extra_1 = require("fs-extra");
|
|
46
|
-
var compiler_sfc_1 = require("@vue/compiler-sfc");
|
|
47
|
-
var fsUtils_1 = require("../shared/fsUtils");
|
|
48
|
-
var compileScript_1 = require("./compileScript");
|
|
49
|
-
var compileStyle_1 = require("./compileStyle");
|
|
50
|
-
var logger_1 = __importDefault(require("../shared/logger"));
|
|
51
|
-
var NORMAL_EXPORT_START_RE = /export\s+default\s+{/;
|
|
52
|
-
var DEFINE_EXPORT_START_RE = /export\s+default\s+defineComponent\s*\(\s*{/;
|
|
53
|
-
function injectRender(script, render) {
|
|
54
|
-
if (DEFINE_EXPORT_START_RE.test(script.trim())) {
|
|
55
|
-
return script.trim().replace(DEFINE_EXPORT_START_RE, "".concat(render, "\nexport default defineComponent({\n render, "));
|
|
56
|
-
}
|
|
57
|
-
if (NORMAL_EXPORT_START_RE.test(script.trim())) {
|
|
58
|
-
return script.trim().replace(NORMAL_EXPORT_START_RE, "".concat(render, "\nexport default {\n render, "));
|
|
59
|
-
}
|
|
60
|
-
return script;
|
|
61
|
-
}
|
|
62
|
-
exports.injectRender = injectRender;
|
|
63
|
-
function compileSFC(sfc) {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
-
var sources, descriptor, script, scriptSetup, template, styles, hasScope, id, scopeId, render, content, code, index, style, file, _a, base, dir, dependencyPath, cssFile, code;
|
|
66
|
-
return __generator(this, function (_b) {
|
|
67
|
-
switch (_b.label) {
|
|
68
|
-
case 0: return [4 /*yield*/, (0, fs_extra_1.readFile)(sfc, 'utf-8')];
|
|
69
|
-
case 1:
|
|
70
|
-
sources = _b.sent();
|
|
71
|
-
descriptor = (0, compiler_sfc_1.parse)(sources, { sourceMap: false }).descriptor;
|
|
72
|
-
script = descriptor.script, scriptSetup = descriptor.scriptSetup, template = descriptor.template, styles = descriptor.styles;
|
|
73
|
-
if (scriptSetup) {
|
|
74
|
-
logger_1.default.warning("\n Varlet Cli does not support compiling script setup syntax \n The error in ".concat(sfc));
|
|
75
|
-
return [2 /*return*/];
|
|
76
|
-
}
|
|
77
|
-
hasScope = styles.some(function (style) { return style.scoped; });
|
|
78
|
-
id = (0, hash_sum_1.default)(sources);
|
|
79
|
-
scopeId = hasScope ? "data-v-".concat(id) : '';
|
|
80
|
-
if (!script) return [3 /*break*/, 6];
|
|
81
|
-
render = template &&
|
|
82
|
-
(0, compiler_sfc_1.compileTemplate)({
|
|
83
|
-
id: id,
|
|
84
|
-
source: template.content,
|
|
85
|
-
filename: sfc,
|
|
86
|
-
compilerOptions: {
|
|
87
|
-
scopeId: scopeId,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
content = script.content;
|
|
91
|
-
if (render) {
|
|
92
|
-
code = render.code;
|
|
93
|
-
content = injectRender(content, code);
|
|
94
|
-
}
|
|
95
|
-
// script
|
|
96
|
-
return [4 /*yield*/, (0, compileScript_1.compileScript)(content, sfc)
|
|
97
|
-
// style
|
|
98
|
-
];
|
|
99
|
-
case 2:
|
|
100
|
-
// script
|
|
101
|
-
_b.sent();
|
|
102
|
-
index = 0;
|
|
103
|
-
_b.label = 3;
|
|
104
|
-
case 3:
|
|
105
|
-
if (!(index < styles.length)) return [3 /*break*/, 6];
|
|
106
|
-
style = styles[index];
|
|
107
|
-
file = (0, fsUtils_1.replaceExt)(sfc, "Sfc".concat(index || '', ".").concat(style.lang || 'css'));
|
|
108
|
-
_a = (0, path_1.parse)(file), base = _a.base, dir = _a.dir;
|
|
109
|
-
dependencyPath = (0, compileStyle_1.normalizeStyleDependency)(base, compileStyle_1.STYLE_IMPORT_RE);
|
|
110
|
-
cssFile = (0, path_1.resolve)(dir, './style/index.js');
|
|
111
|
-
code = (0, compiler_sfc_1.compileStyle)({
|
|
112
|
-
source: style.content,
|
|
113
|
-
filename: file,
|
|
114
|
-
id: scopeId,
|
|
115
|
-
scoped: style.scoped,
|
|
116
|
-
}).code;
|
|
117
|
-
code = (0, compileStyle_1.extractStyleDependencies)(file, code, compileStyle_1.STYLE_IMPORT_RE);
|
|
118
|
-
(0, fs_extra_1.writeFileSync)(file, (0, compileStyle_1.clearEmptyLine)(code), 'utf-8');
|
|
119
|
-
(0, fsUtils_1.smartAppendFileSync)(cssFile, process.env.BABEL_MODULE === 'commonjs'
|
|
120
|
-
? "require('".concat(dependencyPath, ".css')\n")
|
|
121
|
-
: "import '".concat(dependencyPath, ".css'\n"));
|
|
122
|
-
if (!(style.lang === 'less')) return [3 /*break*/, 5];
|
|
123
|
-
return [4 /*yield*/, (0, compileStyle_1.compileLess)(file)];
|
|
124
|
-
case 4:
|
|
125
|
-
_b.sent();
|
|
126
|
-
_b.label = 5;
|
|
127
|
-
case 5:
|
|
128
|
-
index++;
|
|
129
|
-
return [3 /*break*/, 3];
|
|
130
|
-
case 6: return [2 /*return*/];
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
exports.compileSFC = compileSFC;
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.compileCommonJSEntry = exports.compileESEntry = exports.compileScriptFile = exports.compileScript = exports.moduleCompatible = exports.replaceTSXExt = exports.replaceJSXExt = exports.replaceTSExt = exports.replaceVueExt = exports.REQUIRE_TSX_PATH_RE = exports.REQUIRE_JSX_PATH_RE = exports.REQUIRE_TS_PATH_RE = exports.REQUIRE_VUE_PATH_RE = exports.IMPORT_TSX_PATH_RE = exports.IMPORT_JSX_PATH_RE = exports.IMPORT_TS_PATH_RE = exports.IMPORT_VUE_PATH_RE = void 0;
|
|
40
|
-
var core_1 = require("@babel/core");
|
|
41
|
-
var shared_1 = require("@varlet/shared");
|
|
42
|
-
var fsUtils_1 = require("../shared/fsUtils");
|
|
43
|
-
var fs_extra_1 = require("fs-extra");
|
|
44
|
-
var compileStyle_1 = require("./compileStyle");
|
|
45
|
-
var path_1 = require("path");
|
|
46
|
-
var lodash_1 = require("lodash");
|
|
47
|
-
var varlet_config_1 = require("../config/varlet.config");
|
|
48
|
-
exports.IMPORT_VUE_PATH_RE = /((?<!['"`])import\s+.+from\s+['"]\s*\.{1,2}\/.+)\.vue(\s*['"`]);?(?!\s*['"`])/g;
|
|
49
|
-
exports.IMPORT_TS_PATH_RE = /((?<!['"`])import\s+.+from\s+['"]\s*\.{1,2}\/.+)\.ts(\s*['"`]);?(?!\s*['"`])/g;
|
|
50
|
-
exports.IMPORT_JSX_PATH_RE = /((?<!['"`])import\s+.+from\s+['"]\s*\.{1,2}\/.+)\.jsx(\s*['"`]);?(?!\s*['"`])/g;
|
|
51
|
-
exports.IMPORT_TSX_PATH_RE = /((?<!['"`])import\s+.+from\s+['"]\s*\.{1,2}\/.+)\.tsx(\s*['"`]);?(?!\s*['"`])/g;
|
|
52
|
-
exports.REQUIRE_VUE_PATH_RE = /(?<!['"`]\s*)(require\s*\(\s*['"]\s*\.{1,2}\/.+)\.vue(\s*['"`]\))(?!\s*['"`])/g;
|
|
53
|
-
exports.REQUIRE_TS_PATH_RE = /(?<!['"`]\s*)(require\s*\(\s*['"]\s*\.{1,2}\/.+)\.ts(\s*['"`]\))(?!\s*['"`])/g;
|
|
54
|
-
exports.REQUIRE_JSX_PATH_RE = /(?<!['"`]\s*)(require\s*\(\s*['"]\s*\.{1,2}\/.+)\.jsx(\s*['"`]\))(?!\s*['"`])/g;
|
|
55
|
-
exports.REQUIRE_TSX_PATH_RE = /(?<!['"`]\s*)(require\s*\(\s*['"]\s*\.{1,2}\/.+)\.tsx(\s*['"`]\))(?!\s*['"`])/g;
|
|
56
|
-
var scriptReplacer = function (_, p1, p2) { return "".concat(p1, ".js").concat(p2); };
|
|
57
|
-
var replaceVueExt = function (script) {
|
|
58
|
-
return script.replace(exports.IMPORT_VUE_PATH_RE, scriptReplacer).replace(exports.REQUIRE_VUE_PATH_RE, scriptReplacer);
|
|
59
|
-
};
|
|
60
|
-
exports.replaceVueExt = replaceVueExt;
|
|
61
|
-
var replaceTSExt = function (script) {
|
|
62
|
-
return script.replace(exports.IMPORT_TS_PATH_RE, scriptReplacer).replace(exports.REQUIRE_TS_PATH_RE, scriptReplacer);
|
|
63
|
-
};
|
|
64
|
-
exports.replaceTSExt = replaceTSExt;
|
|
65
|
-
var replaceJSXExt = function (script) {
|
|
66
|
-
return script.replace(exports.IMPORT_JSX_PATH_RE, scriptReplacer).replace(exports.REQUIRE_JSX_PATH_RE, scriptReplacer);
|
|
67
|
-
};
|
|
68
|
-
exports.replaceJSXExt = replaceJSXExt;
|
|
69
|
-
var replaceTSXExt = function (script) {
|
|
70
|
-
return script.replace(exports.IMPORT_TSX_PATH_RE, scriptReplacer).replace(exports.REQUIRE_TSX_PATH_RE, scriptReplacer);
|
|
71
|
-
};
|
|
72
|
-
exports.replaceTSXExt = replaceTSXExt;
|
|
73
|
-
var moduleCompatible = function (script) {
|
|
74
|
-
var moduleCompatible = (0, lodash_1.get)((0, varlet_config_1.getVarletConfig)(), 'moduleCompatible', {});
|
|
75
|
-
Object.keys(moduleCompatible).forEach(function (esm) {
|
|
76
|
-
var commonjs = moduleCompatible[esm];
|
|
77
|
-
script = script.replace(esm, commonjs);
|
|
78
|
-
});
|
|
79
|
-
return script;
|
|
80
|
-
};
|
|
81
|
-
exports.moduleCompatible = moduleCompatible;
|
|
82
|
-
function compileScript(script, file) {
|
|
83
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
-
var modules, code;
|
|
85
|
-
return __generator(this, function (_a) {
|
|
86
|
-
switch (_a.label) {
|
|
87
|
-
case 0:
|
|
88
|
-
modules = process.env.BABEL_MODULE;
|
|
89
|
-
if (modules === 'commonjs') {
|
|
90
|
-
script = (0, exports.moduleCompatible)(script);
|
|
91
|
-
}
|
|
92
|
-
return [4 /*yield*/, (0, core_1.transformAsync)(script, {
|
|
93
|
-
filename: file,
|
|
94
|
-
})];
|
|
95
|
-
case 1:
|
|
96
|
-
code = (_a.sent()).code;
|
|
97
|
-
code = (0, compileStyle_1.extractStyleDependencies)(file, code, modules === 'commonjs' ? compileStyle_1.REQUIRE_CSS_RE : compileStyle_1.IMPORT_CSS_RE);
|
|
98
|
-
code = (0, compileStyle_1.extractStyleDependencies)(file, code, modules === 'commonjs' ? compileStyle_1.REQUIRE_LESS_RE : compileStyle_1.IMPORT_LESS_RE);
|
|
99
|
-
code = (0, exports.replaceVueExt)(code);
|
|
100
|
-
code = (0, exports.replaceTSXExt)(code);
|
|
101
|
-
code = (0, exports.replaceJSXExt)(code);
|
|
102
|
-
code = (0, exports.replaceTSExt)(code);
|
|
103
|
-
(0, fs_extra_1.removeSync)(file);
|
|
104
|
-
(0, fs_extra_1.writeFileSync)((0, fsUtils_1.replaceExt)(file, '.js'), code, 'utf8');
|
|
105
|
-
return [2 /*return*/];
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
exports.compileScript = compileScript;
|
|
111
|
-
function compileScriptFile(file) {
|
|
112
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
113
|
-
var sources;
|
|
114
|
-
return __generator(this, function (_a) {
|
|
115
|
-
switch (_a.label) {
|
|
116
|
-
case 0:
|
|
117
|
-
sources = (0, fs_extra_1.readFileSync)(file, 'utf-8');
|
|
118
|
-
return [4 /*yield*/, compileScript(sources, file)];
|
|
119
|
-
case 1:
|
|
120
|
-
_a.sent();
|
|
121
|
-
return [2 /*return*/];
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
exports.compileScriptFile = compileScriptFile;
|
|
127
|
-
function compileESEntry(dir, publicDirs) {
|
|
128
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
-
var imports, plugins, constInternalComponents, cssImports, publicComponents, install, indexTemplate, styleTemplate, umdTemplate;
|
|
130
|
-
return __generator(this, function (_a) {
|
|
131
|
-
switch (_a.label) {
|
|
132
|
-
case 0:
|
|
133
|
-
imports = [];
|
|
134
|
-
plugins = [];
|
|
135
|
-
constInternalComponents = [];
|
|
136
|
-
cssImports = [];
|
|
137
|
-
publicComponents = [];
|
|
138
|
-
publicDirs.forEach(function (dirname) {
|
|
139
|
-
var publicComponent = (0, shared_1.bigCamelize)(dirname);
|
|
140
|
-
publicComponents.push(publicComponent);
|
|
141
|
-
imports.push("import ".concat(publicComponent, ", * as ").concat(publicComponent, "Module from './").concat(dirname, "'"));
|
|
142
|
-
constInternalComponents.push("export const _".concat(publicComponent, "Component = ").concat(publicComponent, "Module._").concat(publicComponent, "Component || {}"));
|
|
143
|
-
plugins.push("".concat(publicComponent, ".install && app.use(").concat(publicComponent, ")"));
|
|
144
|
-
cssImports.push("import './".concat(dirname, "/style'"));
|
|
145
|
-
});
|
|
146
|
-
install = "\nfunction install(app) {\n ".concat(plugins.join('\n '), "\n}\n");
|
|
147
|
-
indexTemplate = "".concat(imports.join('\n'), "\n\n").concat(constInternalComponents.join('\n'), "\n\n").concat(install, "\nexport {\n install,\n ").concat(publicComponents.join(',\n '), "\n}\n\nexport default {\n install,\n ").concat(publicComponents.join(',\n '), "\n}\n");
|
|
148
|
-
styleTemplate = "".concat(cssImports.join('\n'), "\n");
|
|
149
|
-
umdTemplate = "".concat(imports.join('\n'), "\n\n").concat(cssImports.join('\n'), "\n\n").concat(install, "\nexport {\n install,\n ").concat(publicComponents.join(',\n '), "\n}\n\nexport default {\n install,\n ").concat(publicComponents.join(',\n '), "\n}\n");
|
|
150
|
-
return [4 /*yield*/, Promise.all([
|
|
151
|
-
(0, fs_extra_1.writeFile)((0, path_1.resolve)(dir, 'index.js'), indexTemplate, 'utf-8'),
|
|
152
|
-
(0, fs_extra_1.writeFile)((0, path_1.resolve)(dir, 'umdIndex.js'), umdTemplate, 'utf-8'),
|
|
153
|
-
(0, fs_extra_1.writeFile)((0, path_1.resolve)(dir, 'style.js'), styleTemplate, 'utf-8'),
|
|
154
|
-
])];
|
|
155
|
-
case 1:
|
|
156
|
-
_a.sent();
|
|
157
|
-
return [2 /*return*/];
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
exports.compileESEntry = compileESEntry;
|
|
163
|
-
function compileCommonJSEntry(dir, publicDirs) {
|
|
164
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
165
|
-
var requires, plugins, cssRequires, publicComponents, install, indexTemplate, styleTemplate;
|
|
166
|
-
return __generator(this, function (_a) {
|
|
167
|
-
switch (_a.label) {
|
|
168
|
-
case 0:
|
|
169
|
-
requires = [];
|
|
170
|
-
plugins = [];
|
|
171
|
-
cssRequires = [];
|
|
172
|
-
publicComponents = [];
|
|
173
|
-
publicDirs.forEach(function (dirname) {
|
|
174
|
-
var publicComponent = (0, shared_1.bigCamelize)(dirname);
|
|
175
|
-
publicComponents.push(publicComponent);
|
|
176
|
-
requires.push("var ".concat(publicComponent, " = require('./").concat(dirname, "')['default']"));
|
|
177
|
-
plugins.push("".concat(publicComponent, ".install && app.use(").concat(publicComponent, ")"));
|
|
178
|
-
cssRequires.push("require('./".concat(dirname, "/style')"));
|
|
179
|
-
});
|
|
180
|
-
install = "\nfunction install(app) {\n ".concat(plugins.join('\n '), "\n}\n");
|
|
181
|
-
indexTemplate = "".concat(requires.join('\n'), "\n\n").concat(install, "\n\nmodule.exports = {\n install,\n ").concat(publicComponents.join(',\n '), "\n}\n");
|
|
182
|
-
styleTemplate = "".concat(cssRequires.join('\n'), "\n");
|
|
183
|
-
return [4 /*yield*/, Promise.all([
|
|
184
|
-
(0, fs_extra_1.writeFile)((0, path_1.resolve)(dir, 'index.js'), indexTemplate, 'utf-8'),
|
|
185
|
-
(0, fs_extra_1.writeFile)((0, path_1.resolve)(dir, 'style.js'), styleTemplate, 'utf-8'),
|
|
186
|
-
])];
|
|
187
|
-
case 1:
|
|
188
|
-
_a.sent();
|
|
189
|
-
return [2 /*return*/];
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
exports.compileCommonJSEntry = compileCommonJSEntry;
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
-
if (!m) return o;
|
|
41
|
-
var i = m.call(o), r, ar = [], e;
|
|
42
|
-
try {
|
|
43
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
-
}
|
|
45
|
-
catch (error) { e = { error: error }; }
|
|
46
|
-
finally {
|
|
47
|
-
try {
|
|
48
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
-
}
|
|
50
|
-
finally { if (e) throw e.error; }
|
|
51
|
-
}
|
|
52
|
-
return ar;
|
|
53
|
-
};
|
|
54
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
55
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
56
|
-
if (ar || !(i in from)) {
|
|
57
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
-
ar[i] = from[i];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
62
|
-
};
|
|
63
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
64
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
65
|
-
};
|
|
66
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
|
-
exports.buildSiteEntry = exports.buildSiteSource = exports.buildPcSiteRoutes = exports.buildMobileSiteRoutes = exports.findRootLocales = exports.findRootDocs = exports.findComponentDocs = exports.findExamples = exports.getRootFilePath = exports.getRootRoutePath = exports.getRootDocRoutePath = exports.getComponentDocRoutePath = exports.getExampleRoutePath = void 0;
|
|
68
|
-
var constant_1 = require("../shared/constant");
|
|
69
|
-
var fs_extra_1 = require("fs-extra");
|
|
70
|
-
var slash_1 = __importDefault(require("slash"));
|
|
71
|
-
var fsUtils_1 = require("../shared/fsUtils");
|
|
72
|
-
var varlet_config_1 = require("../config/varlet.config");
|
|
73
|
-
var lodash_1 = require("lodash");
|
|
74
|
-
var EXAMPLE_COMPONENT_NAME_RE = /\/([-\w]+)\/example\/index.vue/;
|
|
75
|
-
var COMPONENT_DOCS_RE = /\/([-\w]+)\/docs\/([-\w]+)\.md/;
|
|
76
|
-
var ROOT_DOCS_RE = /\/docs\/([-\w]+)\.([-\w]+)\.md/;
|
|
77
|
-
var ROOT_LOCALE_RE = /\/pages\/([-\w]+)\/locale\/([-\w]+)\.ts/;
|
|
78
|
-
function getExampleRoutePath(examplePath) {
|
|
79
|
-
var _a;
|
|
80
|
-
return '/' + ((_a = examplePath.match(EXAMPLE_COMPONENT_NAME_RE)) === null || _a === void 0 ? void 0 : _a[1]);
|
|
81
|
-
}
|
|
82
|
-
exports.getExampleRoutePath = getExampleRoutePath;
|
|
83
|
-
function getComponentDocRoutePath(componentDocsPath) {
|
|
84
|
-
var _a;
|
|
85
|
-
var _b = __read((_a = componentDocsPath.match(COMPONENT_DOCS_RE)) !== null && _a !== void 0 ? _a : [], 3), routePath = _b[1], language = _b[2];
|
|
86
|
-
return "/".concat(language, "/").concat(routePath);
|
|
87
|
-
}
|
|
88
|
-
exports.getComponentDocRoutePath = getComponentDocRoutePath;
|
|
89
|
-
function getRootDocRoutePath(rootDocsPath) {
|
|
90
|
-
var _a;
|
|
91
|
-
var _b = __read((_a = rootDocsPath.match(ROOT_DOCS_RE)) !== null && _a !== void 0 ? _a : [], 3), routePath = _b[1], language = _b[2];
|
|
92
|
-
return "/".concat(language, "/").concat(routePath);
|
|
93
|
-
}
|
|
94
|
-
exports.getRootDocRoutePath = getRootDocRoutePath;
|
|
95
|
-
function getRootRoutePath(rootLocalePath) {
|
|
96
|
-
var _a;
|
|
97
|
-
var _b = __read((_a = rootLocalePath.match(ROOT_LOCALE_RE)) !== null && _a !== void 0 ? _a : [], 3), routePath = _b[1], language = _b[2];
|
|
98
|
-
return "/".concat(language, "/").concat(routePath);
|
|
99
|
-
}
|
|
100
|
-
exports.getRootRoutePath = getRootRoutePath;
|
|
101
|
-
function getRootFilePath(rootLocalePath) {
|
|
102
|
-
return rootLocalePath.replace(/locale\/.+/, constant_1.DIR_INDEX);
|
|
103
|
-
}
|
|
104
|
-
exports.getRootFilePath = getRootFilePath;
|
|
105
|
-
function findExamples() {
|
|
106
|
-
return (0, fsUtils_1.glob)("".concat(constant_1.SRC_DIR, "/**/").concat(constant_1.EXAMPLE_DIR_NAME, "/").concat(constant_1.DIR_INDEX));
|
|
107
|
-
}
|
|
108
|
-
exports.findExamples = findExamples;
|
|
109
|
-
function findComponentDocs() {
|
|
110
|
-
return (0, fsUtils_1.glob)("".concat(constant_1.SRC_DIR, "/**/").concat(constant_1.DOCS_DIR_NAME, "/*.md"));
|
|
111
|
-
}
|
|
112
|
-
exports.findComponentDocs = findComponentDocs;
|
|
113
|
-
function findRootDocs() {
|
|
114
|
-
return (0, fsUtils_1.glob)("".concat(constant_1.ROOT_DOCS_DIR, "/*.md"));
|
|
115
|
-
}
|
|
116
|
-
exports.findRootDocs = findRootDocs;
|
|
117
|
-
function findRootLocales() {
|
|
118
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
119
|
-
var defaultLanguage, userPages, baseLocales, userLocales, filterMap;
|
|
120
|
-
var _this = this;
|
|
121
|
-
return __generator(this, function (_a) {
|
|
122
|
-
switch (_a.label) {
|
|
123
|
-
case 0:
|
|
124
|
-
defaultLanguage = (0, lodash_1.get)((0, varlet_config_1.getVarletConfig)(), 'defaultLanguage');
|
|
125
|
-
return [4 /*yield*/, (0, fsUtils_1.glob)("".concat(constant_1.ROOT_PAGES_DIR, "/*"))];
|
|
126
|
-
case 1:
|
|
127
|
-
userPages = _a.sent();
|
|
128
|
-
return [4 /*yield*/, (0, fsUtils_1.glob)("".concat(constant_1.SITE, "/pc/pages/**/").concat(constant_1.LOCALE_DIR_NAME, "/*.ts"))];
|
|
129
|
-
case 2:
|
|
130
|
-
baseLocales = _a.sent();
|
|
131
|
-
return [4 /*yield*/, userPages.reduce(function (userLocales, page) { return __awaiter(_this, void 0, void 0, function () {
|
|
132
|
-
var locales;
|
|
133
|
-
var _a;
|
|
134
|
-
return __generator(this, function (_b) {
|
|
135
|
-
switch (_b.label) {
|
|
136
|
-
case 0:
|
|
137
|
-
if (!(0, fsUtils_1.isDir)(page)) return [3 /*break*/, 3];
|
|
138
|
-
return [4 /*yield*/, (0, fsUtils_1.glob)("".concat(page, "/").concat(constant_1.LOCALE_DIR_NAME, "/*.ts"))];
|
|
139
|
-
case 1:
|
|
140
|
-
locales = _b.sent();
|
|
141
|
-
if (!locales.length)
|
|
142
|
-
locales.push("".concat(page, "/").concat(constant_1.LOCALE_DIR_NAME, "/").concat(defaultLanguage, ".ts"));
|
|
143
|
-
return [4 /*yield*/, userLocales];
|
|
144
|
-
case 2:
|
|
145
|
-
(_a = (_b.sent())).push.apply(_a, __spreadArray([], __read(locales), false));
|
|
146
|
-
_b.label = 3;
|
|
147
|
-
case 3: return [2 /*return*/, userLocales];
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
}); }, Promise.resolve([]))
|
|
151
|
-
// filter
|
|
152
|
-
];
|
|
153
|
-
case 3:
|
|
154
|
-
userLocales = _a.sent();
|
|
155
|
-
filterMap = new Map();
|
|
156
|
-
baseLocales.forEach(function (locale) {
|
|
157
|
-
var _a;
|
|
158
|
-
var _b = __read((_a = locale.match(ROOT_LOCALE_RE)) !== null && _a !== void 0 ? _a : [], 3), routePath = _b[1], language = _b[2];
|
|
159
|
-
filterMap.set(routePath + language, (0, slash_1.default)("".concat(constant_1.SITE_PC_DIR, "/pages/").concat(routePath, "/locale/").concat(language, ".ts")));
|
|
160
|
-
});
|
|
161
|
-
userLocales.forEach(function (locale) {
|
|
162
|
-
var _a;
|
|
163
|
-
var _b = __read((_a = locale.match(ROOT_LOCALE_RE)) !== null && _a !== void 0 ? _a : [], 3), routePath = _b[1], language = _b[2];
|
|
164
|
-
filterMap.set(routePath + language, locale);
|
|
165
|
-
});
|
|
166
|
-
return [2 /*return*/, Promise.resolve(Array.from(filterMap.values()))];
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
exports.findRootLocales = findRootLocales;
|
|
172
|
-
function buildMobileSiteRoutes() {
|
|
173
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
174
|
-
var examples, routes, source;
|
|
175
|
-
return __generator(this, function (_a) {
|
|
176
|
-
switch (_a.label) {
|
|
177
|
-
case 0: return [4 /*yield*/, findExamples()];
|
|
178
|
-
case 1:
|
|
179
|
-
examples = _a.sent();
|
|
180
|
-
routes = examples.map(function (example) { return "\n {\n path: '".concat(getExampleRoutePath(example), "',\n // @ts-ignore\n component: () => import('").concat(example, "')\n }"); });
|
|
181
|
-
source = "export default [ ".concat(routes.join(','), "\n]");
|
|
182
|
-
return [4 /*yield*/, (0, fsUtils_1.outputFileSyncOnChange)(constant_1.SITE_MOBILE_ROUTES, source)];
|
|
183
|
-
case 2:
|
|
184
|
-
_a.sent();
|
|
185
|
-
return [2 /*return*/];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
exports.buildMobileSiteRoutes = buildMobileSiteRoutes;
|
|
191
|
-
function buildPcSiteRoutes() {
|
|
192
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
193
|
-
var _a, componentDocs, rootDocs, rootLocales, rootPagesRoutes, componentDocsRoutes, rootDocsRoutes, layoutRoutes, source;
|
|
194
|
-
return __generator(this, function (_b) {
|
|
195
|
-
switch (_b.label) {
|
|
196
|
-
case 0: return [4 /*yield*/, Promise.all([
|
|
197
|
-
findComponentDocs(),
|
|
198
|
-
findRootDocs(),
|
|
199
|
-
findRootLocales(),
|
|
200
|
-
])];
|
|
201
|
-
case 1:
|
|
202
|
-
_a = __read.apply(void 0, [_b.sent(), 3]), componentDocs = _a[0], rootDocs = _a[1], rootLocales = _a[2];
|
|
203
|
-
rootPagesRoutes = rootLocales.map(function (rootLocale) { return "\n {\n path: '".concat(getRootRoutePath(rootLocale), "',\n // @ts-ignore\n component: () => import('").concat(getRootFilePath(rootLocale), "')\n }"); });
|
|
204
|
-
componentDocsRoutes = componentDocs.map(function (componentDoc) { return "\n {\n path: '".concat(getComponentDocRoutePath(componentDoc), "',\n // @ts-ignore\n component: () => import('").concat(componentDoc, "')\n }"); });
|
|
205
|
-
rootDocsRoutes = rootDocs.map(function (rootDoc) { return "\n {\n path: '".concat(getRootDocRoutePath(rootDoc), "',\n // @ts-ignore\n component: () => import('").concat(rootDoc, "')\n }"); });
|
|
206
|
-
layoutRoutes = "{\n path: '/layout',\n // @ts-ignore\n component:()=> import('".concat((0, slash_1.default)(constant_1.SITE_PC_DIR), "/Layout.vue'),\n children: [\n ").concat(__spreadArray(__spreadArray([], __read(componentDocsRoutes), false), [rootDocsRoutes], false).join(','), ",\n ]\n }");
|
|
207
|
-
source = "export default [ ".concat(rootPagesRoutes.join(','), ",\n ").concat(layoutRoutes, "\n]");
|
|
208
|
-
(0, fsUtils_1.outputFileSyncOnChange)(constant_1.SITE_PC_ROUTES, source);
|
|
209
|
-
return [2 /*return*/];
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
exports.buildPcSiteRoutes = buildPcSiteRoutes;
|
|
215
|
-
function buildSiteSource() {
|
|
216
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
217
|
-
return __generator(this, function (_a) {
|
|
218
|
-
return [2 /*return*/, (0, fs_extra_1.copy)(constant_1.SITE, constant_1.SITE_DIR)];
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
exports.buildSiteSource = buildSiteSource;
|
|
223
|
-
function buildSiteEntry() {
|
|
224
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
225
|
-
return __generator(this, function (_a) {
|
|
226
|
-
switch (_a.label) {
|
|
227
|
-
case 0:
|
|
228
|
-
(0, varlet_config_1.getVarletConfig)(true);
|
|
229
|
-
return [4 /*yield*/, Promise.all([buildMobileSiteRoutes(), buildPcSiteRoutes(), buildSiteSource()])];
|
|
230
|
-
case 1:
|
|
231
|
-
_a.sent();
|
|
232
|
-
return [2 /*return*/];
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
exports.buildSiteEntry = buildSiteEntry;
|