@varlet/cli 1.24.0 → 1.24.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.
@@ -0,0 +1,203 @@
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.release = void 0;
43
+ var inquirer_1 = __importDefault(require("inquirer"));
44
+ var ora_1 = __importDefault(require("ora"));
45
+ var execa_1 = __importDefault(require("execa"));
46
+ var logger_1 = __importDefault(require("../shared/logger"));
47
+ var semver_1 = __importDefault(require("semver"));
48
+ var glob_1 = __importDefault(require("glob"));
49
+ var constant_1 = require("../shared/constant");
50
+ var path_1 = require("path");
51
+ var fs_extra_1 = require("fs-extra");
52
+ var changelog_1 = require("./changelog");
53
+ var releaseTypes = ['premajor', 'preminor', 'prepatch', 'major', 'minor', 'patch'];
54
+ function isWorktreeEmpty() {
55
+ return __awaiter(this, void 0, void 0, function () {
56
+ var ret;
57
+ return __generator(this, function (_a) {
58
+ switch (_a.label) {
59
+ case 0: return [4 /*yield*/, (0, execa_1.default)('git', ['status', '--porcelain'])];
60
+ case 1:
61
+ ret = _a.sent();
62
+ return [2 /*return*/, !ret.stdout];
63
+ }
64
+ });
65
+ });
66
+ }
67
+ function publish(preRelease) {
68
+ return __awaiter(this, void 0, void 0, function () {
69
+ var s, args, ret;
70
+ return __generator(this, function (_a) {
71
+ switch (_a.label) {
72
+ case 0:
73
+ s = (0, ora_1.default)().start('Publishing all packages');
74
+ args = ['-r', 'publish', '--no-git-checks', '--access', 'public'];
75
+ preRelease && args.push('--tag', 'alpha');
76
+ return [4 /*yield*/, (0, execa_1.default)('pnpm', args)];
77
+ case 1:
78
+ ret = _a.sent();
79
+ s.succeed('Publish all packages successfully');
80
+ ret.stdout && logger_1.default.info(ret.stdout);
81
+ return [2 /*return*/];
82
+ }
83
+ });
84
+ });
85
+ }
86
+ function pushGit(version, message) {
87
+ return __awaiter(this, void 0, void 0, function () {
88
+ var s, ret;
89
+ return __generator(this, function (_a) {
90
+ switch (_a.label) {
91
+ case 0:
92
+ s = (0, ora_1.default)().start('Pushing to remote git repository');
93
+ return [4 /*yield*/, (0, execa_1.default)('git', ['add', '.'])];
94
+ case 1:
95
+ _a.sent();
96
+ return [4 /*yield*/, (0, execa_1.default)('git', ['commit', '-m', message])];
97
+ case 2:
98
+ _a.sent();
99
+ return [4 /*yield*/, (0, execa_1.default)('git', ['tag', version])];
100
+ case 3:
101
+ _a.sent();
102
+ return [4 /*yield*/, (0, execa_1.default)('git', ['push'])];
103
+ case 4:
104
+ ret = _a.sent();
105
+ s.succeed('Push remote repository successfully');
106
+ ret.stdout && logger_1.default.info(ret.stdout);
107
+ return [2 /*return*/];
108
+ }
109
+ });
110
+ });
111
+ }
112
+ function updateVersion(version) {
113
+ var packageJsons = glob_1.default.sync('packages/*/package.json');
114
+ packageJsons.push('package.json');
115
+ return packageJsons.map(function (path) {
116
+ var file = (0, path_1.resolve)(constant_1.CWD, path);
117
+ var config = require(file);
118
+ var currentVersion = config.version;
119
+ config.version = version;
120
+ (0, fs_extra_1.writeFileSync)(file, JSON.stringify(config, null, 2));
121
+ config.version = currentVersion;
122
+ return { file: file, content: JSON.stringify(config, null, 2) };
123
+ });
124
+ }
125
+ function release() {
126
+ return __awaiter(this, void 0, void 0, function () {
127
+ var currentVersion, name_1, ret, type, isPreRelease, expectVersion, confirm_1, packageJsonMaps, error_1;
128
+ return __generator(this, function (_a) {
129
+ switch (_a.label) {
130
+ case 0:
131
+ _a.trys.push([0, 10, , 11]);
132
+ currentVersion = require((0, path_1.resolve)(constant_1.CWD, 'package.json')).version;
133
+ if (!currentVersion) {
134
+ logger_1.default.error('Your package is missing the version field');
135
+ return [2 /*return*/];
136
+ }
137
+ return [4 /*yield*/, isWorktreeEmpty()];
138
+ case 1:
139
+ if (!(_a.sent())) {
140
+ logger_1.default.error('Git worktree is not empty, please commit changed');
141
+ return [2 /*return*/];
142
+ }
143
+ name_1 = 'Please select release type';
144
+ return [4 /*yield*/, inquirer_1.default.prompt([
145
+ {
146
+ name: name_1,
147
+ type: 'list',
148
+ choices: releaseTypes,
149
+ },
150
+ ])];
151
+ case 2:
152
+ ret = _a.sent();
153
+ type = ret[name_1];
154
+ isPreRelease = type.startsWith('pre');
155
+ expectVersion = semver_1.default.inc(currentVersion, type, "alpha.".concat(Date.now()));
156
+ expectVersion = isPreRelease ? expectVersion.slice(0, -2) : expectVersion;
157
+ name_1 = 'version confirm';
158
+ return [4 /*yield*/, inquirer_1.default.prompt([
159
+ {
160
+ name: name_1,
161
+ type: 'confirm',
162
+ message: "All packages version ".concat(currentVersion, " -> ").concat(expectVersion, ":"),
163
+ },
164
+ ])];
165
+ case 3:
166
+ confirm_1 = _a.sent();
167
+ if (!confirm_1[name_1]) {
168
+ return [2 /*return*/];
169
+ }
170
+ packageJsonMaps = updateVersion(expectVersion);
171
+ if (!!isPreRelease) return [3 /*break*/, 6];
172
+ return [4 /*yield*/, (0, changelog_1.changelog)()];
173
+ case 4:
174
+ _a.sent();
175
+ return [4 /*yield*/, pushGit(expectVersion, "v".concat(expectVersion))];
176
+ case 5:
177
+ _a.sent();
178
+ _a.label = 6;
179
+ case 6: return [4 /*yield*/, publish(isPreRelease)];
180
+ case 7:
181
+ _a.sent();
182
+ if (!isPreRelease) return [3 /*break*/, 9];
183
+ packageJsonMaps.forEach(function (_a) {
184
+ var file = _a.file, content = _a.content;
185
+ return (0, fs_extra_1.writeFileSync)(file, content);
186
+ });
187
+ return [4 /*yield*/, (0, execa_1.default)('git', ['restore', '**/package.json'])];
188
+ case 8:
189
+ _a.sent();
190
+ _a.label = 9;
191
+ case 9:
192
+ logger_1.default.success("Release version ".concat(expectVersion, " successfully!"));
193
+ return [3 /*break*/, 11];
194
+ case 10:
195
+ error_1 = _a.sent();
196
+ logger_1.default.error(error_1.toString());
197
+ return [3 /*break*/, 11];
198
+ case 11: return [2 /*return*/];
199
+ }
200
+ });
201
+ });
202
+ }
203
+ exports.release = release;
@@ -51,10 +51,10 @@ var NORMAL_EXPORT_START_RE = /export\s+default\s+{/;
51
51
  var DEFINE_EXPORT_START_RE = /export\s+default\s+defineComponent\s*\(\s*{/;
52
52
  function injectRender(script, render) {
53
53
  if (DEFINE_EXPORT_START_RE.test(script.trim())) {
54
- return script.trim().replace(DEFINE_EXPORT_START_RE, render + "\nexport default defineComponent({\n render, ");
54
+ return script.trim().replace(DEFINE_EXPORT_START_RE, "".concat(render, "\nexport default defineComponent({\n render, "));
55
55
  }
56
56
  if (NORMAL_EXPORT_START_RE.test(script.trim())) {
57
- return script.trim().replace(NORMAL_EXPORT_START_RE, render + "\nexport default {\n render, ");
57
+ return script.trim().replace(NORMAL_EXPORT_START_RE, "".concat(render, "\nexport default {\n render, "));
58
58
  }
59
59
  return script;
60
60
  }
@@ -70,12 +70,12 @@ function compileSFC(sfc) {
70
70
  descriptor = (0, compiler_sfc_1.parse)(sources, { sourceMap: false }).descriptor;
71
71
  script = descriptor.script, scriptSetup = descriptor.scriptSetup, template = descriptor.template, styles = descriptor.styles;
72
72
  if (scriptSetup) {
73
- logger_1.default.warning("\n Varlet Cli does not support compiling script setup syntax \n The error in " + sfc);
73
+ logger_1.default.warning("\n Varlet Cli does not support compiling script setup syntax \n The error in ".concat(sfc));
74
74
  return [2 /*return*/];
75
75
  }
76
76
  hasScope = styles.some(function (style) { return style.scoped; });
77
77
  id = (0, hash_sum_1.default)(sources);
78
- scopeId = hasScope ? "data-v-" + id : '';
78
+ scopeId = hasScope ? "data-v-".concat(id) : '';
79
79
  if (!script) return [3 /*break*/, 7];
80
80
  render = template &&
81
81
  (0, compiler_sfc_1.compileTemplate)({
@@ -103,7 +103,7 @@ function compileSFC(sfc) {
103
103
  case 3:
104
104
  if (!(index < styles.length)) return [3 /*break*/, 7];
105
105
  style = styles[index];
106
- file = (0, fsUtils_1.replaceExt)(sfc, "Sfc" + (index || '') + "." + (style.lang || 'css'));
106
+ file = (0, fsUtils_1.replaceExt)(sfc, "Sfc".concat(index || '', ".").concat(style.lang || 'css'));
107
107
  code = (0, compiler_sfc_1.compileStyle)({
108
108
  source: style.content,
109
109
  filename: file,
@@ -52,7 +52,7 @@ exports.REQUIRE_VUE_PATH_RE = /(?<!['"`]\s*)(require\s*\(\s*['"]\s*\.{1,2}\/.+)\
52
52
  exports.REQUIRE_TS_PATH_RE = /(?<!['"`]\s*)(require\s*\(\s*['"]\s*\.{1,2}\/.+)\.ts(\s*['"`]\))(?!\s*['"`])/g;
53
53
  exports.REQUIRE_JSX_PATH_RE = /(?<!['"`]\s*)(require\s*\(\s*['"]\s*\.{1,2}\/.+)\.jsx(\s*['"`]\))(?!\s*['"`])/g;
54
54
  exports.REQUIRE_TSX_PATH_RE = /(?<!['"`]\s*)(require\s*\(\s*['"]\s*\.{1,2}\/.+)\.tsx(\s*['"`]\))(?!\s*['"`])/g;
55
- var scriptReplacer = function (_, p1, p2) { return p1 + ".js" + p2; };
55
+ var scriptReplacer = function (_, p1, p2) { return "".concat(p1, ".js").concat(p2); };
56
56
  var replaceVueExt = function (script) {
57
57
  return script.replace(exports.IMPORT_VUE_PATH_RE, scriptReplacer).replace(exports.REQUIRE_VUE_PATH_RE, scriptReplacer);
58
58
  };
@@ -138,17 +138,17 @@ function compileESEntry(dir, publicDirs) {
138
138
  publicDirs.forEach(function (dirname) {
139
139
  var publicComponent = (0, fsUtils_1.bigCamelize)(dirname);
140
140
  publicComponents.push(publicComponent);
141
- imports.push("import " + publicComponent + ", * as " + publicComponent + "Module from './" + dirname + "'");
142
- constInternalComponents.push("export const _" + publicComponent + "Component = " + publicComponent + "Module._" + publicComponent + "Component || {}");
143
- plugins.push(publicComponent + ".install && app.use(" + publicComponent + ")");
144
- cssImports.push("import './" + dirname + "/style'");
145
- lessImports.push("import './" + dirname + "/style/less'");
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
+ lessImports.push("import './".concat(dirname, "/style/less'"));
146
146
  });
147
- install = "\nfunction install(app) {\n " + plugins.join('\n ') + "\n}\n";
148
- indexTemplate = imports.join('\n') + "\n\n" + constInternalComponents.join('\n') + "\n\n" + install + "\nexport {\n install,\n " + publicComponents.join(',\n ') + "\n}\n\nexport default {\n install,\n " + publicComponents.join(',\n ') + "\n}\n";
149
- styleTemplate = cssImports.join('\n') + "\n";
150
- umdTemplate = imports.join('\n') + "\n\n" + cssImports.join('\n') + "\n\n" + install + "\nexport {\n install,\n " + publicComponents.join(',\n ') + "\n}\n\nexport default {\n install,\n " + publicComponents.join(',\n ') + "\n}\n";
151
- lessTemplate = lessImports.join('\n') + "\n";
147
+ install = "\nfunction install(app) {\n ".concat(plugins.join('\n '), "\n}\n");
148
+ 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");
149
+ styleTemplate = "".concat(cssImports.join('\n'), "\n");
150
+ 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");
151
+ lessTemplate = "".concat(lessImports.join('\n'), "\n");
152
152
  return [4 /*yield*/, Promise.all([
153
153
  (0, fs_extra_1.writeFile)((0, path_1.resolve)(dir, 'index.js'), indexTemplate, 'utf-8'),
154
154
  (0, fs_extra_1.writeFile)((0, path_1.resolve)(dir, 'umdIndex.js'), umdTemplate, 'utf-8'),
@@ -177,15 +177,15 @@ function compileCommonJSEntry(dir, publicDirs) {
177
177
  publicDirs.forEach(function (dirname) {
178
178
  var publicComponent = (0, fsUtils_1.bigCamelize)(dirname);
179
179
  publicComponents.push(publicComponent);
180
- requires.push("var " + publicComponent + " = require('./" + dirname + "')['default']");
181
- plugins.push(publicComponent + ".install && app.use(" + publicComponent + ")");
182
- cssRequires.push("require('./" + dirname + "/style')");
183
- lessRequires.push("require('./" + dirname + "/style/less')");
180
+ requires.push("var ".concat(publicComponent, " = require('./").concat(dirname, "')['default']"));
181
+ plugins.push("".concat(publicComponent, ".install && app.use(").concat(publicComponent, ")"));
182
+ cssRequires.push("require('./".concat(dirname, "/style')"));
183
+ lessRequires.push("require('./".concat(dirname, "/style/less')"));
184
184
  });
185
- install = "\nfunction install(app) {\n " + plugins.join('\n ') + "\n}\n";
186
- indexTemplate = requires.join('\n') + "\n\n" + install + "\n\nmodule.exports = {\n install,\n " + publicComponents.join(',\n ') + "\n}\n";
187
- styleTemplate = cssRequires.join('\n') + "\n";
188
- lessTemplate = lessRequires.join('\n') + "\n";
185
+ install = "\nfunction install(app) {\n ".concat(plugins.join('\n '), "\n}\n");
186
+ indexTemplate = "".concat(requires.join('\n'), "\n\n").concat(install, "\n\nmodule.exports = {\n install,\n ").concat(publicComponents.join(',\n '), "\n}\n");
187
+ styleTemplate = "".concat(cssRequires.join('\n'), "\n");
188
+ lessTemplate = "".concat(lessRequires.join('\n'), "\n");
189
189
  return [4 /*yield*/, Promise.all([
190
190
  (0, fs_extra_1.writeFile)((0, path_1.resolve)(dir, 'index.js'), indexTemplate, 'utf-8'),
191
191
  (0, fs_extra_1.writeFile)((0, path_1.resolve)(dir, 'style.js'), styleTemplate, 'utf-8'),
@@ -82,13 +82,13 @@ exports.getExampleRoutePath = getExampleRoutePath;
82
82
  function getComponentDocsRoutePath(componentDocsPath) {
83
83
  var _a;
84
84
  var _b = __read((_a = componentDocsPath.match(COMPONENT_DOCS_RE)) !== null && _a !== void 0 ? _a : [], 3), routePath = _b[1], language = _b[2];
85
- return "/" + language + "/" + routePath;
85
+ return "/".concat(language, "/").concat(routePath);
86
86
  }
87
87
  exports.getComponentDocsRoutePath = getComponentDocsRoutePath;
88
88
  function getRootDocsRoutePath(rootDocsPath) {
89
89
  var _a;
90
90
  var _b = __read((_a = rootDocsPath.match(ROOT_DOCS_RE)) !== null && _a !== void 0 ? _a : [], 3), routePath = _b[1], language = _b[2];
91
- return "/" + language + "/" + routePath;
91
+ return "/".concat(language, "/").concat(routePath);
92
92
  }
93
93
  exports.getRootDocsRoutePath = getRootDocsRoutePath;
94
94
  function findExamplePaths() {
@@ -161,8 +161,8 @@ function buildMobileSiteRoutes() {
161
161
  case 0: return [4 /*yield*/, findExamplePaths()];
162
162
  case 1:
163
163
  examplePaths = _a.sent();
164
- routes = examplePaths.map(function (examplePath) { return "\n {\n path: '" + getExampleRoutePath(examplePath) + "',\n // @ts-ignore\n component: () => import('" + examplePath + "')\n }"; });
165
- source = "export default [ " + routes.join(',') + "\n]";
164
+ routes = examplePaths.map(function (examplePath) { return "\n {\n path: '".concat(getExampleRoutePath(examplePath), "',\n // @ts-ignore\n component: () => import('").concat(examplePath, "')\n }"); });
165
+ source = "export default [ ".concat(routes.join(','), "\n]");
166
166
  return [4 /*yield*/, (0, fsUtils_1.outputFileSyncOnChange)(constant_1.SITE_MOBILE_ROUTES, source)];
167
167
  case 2:
168
168
  _a.sent();
@@ -180,9 +180,9 @@ function buildPcSiteRoutes() {
180
180
  case 0: return [4 /*yield*/, Promise.all([findComponentDocsPaths(), findRootDocsPaths()])];
181
181
  case 1:
182
182
  _a = __read.apply(void 0, [_b.sent(), 2]), componentDocsPaths = _a[0], rootDocsPaths = _a[1];
183
- componentDocsRoutes = componentDocsPaths.map(function (componentDocsPath) { return "\n {\n path: '" + getComponentDocsRoutePath(componentDocsPath) + "',\n // @ts-ignore\n component: () => import('" + componentDocsPath + "')\n }"; });
184
- rootDocsRoutes = rootDocsPaths.map(function (rootDocsPath) { return "\n {\n path: '" + getRootDocsRoutePath(rootDocsPath) + "',\n // @ts-ignore\n component: () => import('" + rootDocsPath + "')\n }"; });
185
- source = "export default [ " + __spreadArray(__spreadArray([], __read(componentDocsRoutes), false), [rootDocsRoutes], false).join(',') + "\n]";
183
+ componentDocsRoutes = componentDocsPaths.map(function (componentDocsPath) { return "\n {\n path: '".concat(getComponentDocsRoutePath(componentDocsPath), "',\n // @ts-ignore\n component: () => import('").concat(componentDocsPath, "')\n }"); });
184
+ rootDocsRoutes = rootDocsPaths.map(function (rootDocsPath) { return "\n {\n path: '".concat(getRootDocsRoutePath(rootDocsPath), "',\n // @ts-ignore\n component: () => import('").concat(rootDocsPath, "')\n }"); });
185
+ source = "export default [ ".concat(__spreadArray(__spreadArray([], __read(componentDocsRoutes), false), [rootDocsRoutes], false).join(','), "\n]");
186
186
  (0, fsUtils_1.outputFileSyncOnChange)(constant_1.SITE_PC_ROUTES, source);
187
187
  return [2 /*return*/];
188
188
  }
@@ -203,7 +203,7 @@ function buildSiteEntry() {
203
203
  return __generator(this, function (_a) {
204
204
  switch (_a.label) {
205
205
  case 0:
206
- (0, varlet_config_1.getVarletConfig)();
206
+ (0, varlet_config_1.getVarletConfig)(true);
207
207
  return [4 /*yield*/, Promise.all([buildMobileSiteRoutes(), buildPcSiteRoutes(), buildSiteSource()])];
208
208
  case 1:
209
209
  _a.sent();
@@ -68,16 +68,16 @@ function extractStyleDependencies(file, code, reg, expect, self) {
68
68
  var modules = process.env.BABEL_MODULE;
69
69
  styleImports.forEach(function (styleImport) {
70
70
  var normalizedPath = normalizeStyleDependency(styleImport, reg);
71
- (0, fsUtils_1.smartAppendFileSync)(cssFile, modules === 'commonjs' ? "require('" + normalizedPath + ".css')\n" : "import '" + normalizedPath + ".css'\n");
72
- (0, fsUtils_1.smartAppendFileSync)(lessFile, modules === 'commonjs' ? "require('" + normalizedPath + "." + expect + "')\n" : "import '" + normalizedPath + "." + expect + "'\n");
71
+ (0, fsUtils_1.smartAppendFileSync)(cssFile, modules === 'commonjs' ? "require('".concat(normalizedPath, ".css')\n") : "import '".concat(normalizedPath, ".css'\n"));
72
+ (0, fsUtils_1.smartAppendFileSync)(lessFile, modules === 'commonjs' ? "require('".concat(normalizedPath, ".").concat(expect, "')\n") : "import '".concat(normalizedPath, ".").concat(expect, "'\n"));
73
73
  });
74
74
  if (self) {
75
75
  (0, fsUtils_1.smartAppendFileSync)(cssFile, modules === 'commonjs'
76
- ? "require('" + normalizeStyleDependency(base, reg) + ".css')\n"
77
- : "import '" + normalizeStyleDependency(base, reg) + ".css'\n");
76
+ ? "require('".concat(normalizeStyleDependency(base, reg), ".css')\n")
77
+ : "import '".concat(normalizeStyleDependency(base, reg), ".css'\n"));
78
78
  (0, fsUtils_1.smartAppendFileSync)(lessFile, modules === 'commonjs'
79
- ? "require('" + normalizeStyleDependency(base, reg) + "." + expect + "')\n"
80
- : "import '" + normalizeStyleDependency(base, reg) + "." + expect + "'\n");
79
+ ? "require('".concat(normalizeStyleDependency(base, reg), ".").concat(expect, "')\n")
80
+ : "import '".concat(normalizeStyleDependency(base, reg), ".").concat(expect, "'\n"));
81
81
  }
82
82
  return code.replace(reg, '');
83
83
  }
@@ -2,9 +2,9 @@ export declare const replaceDot: (s: string) => string;
2
2
  export declare const replaceUnderline: (s: string) => string;
3
3
  export declare function parseTable(table: string): string[][];
4
4
  export declare function compileTable(md: string, titleRe: RegExp): string;
5
- export declare function compileTags(table: Record<string, any>, tags: Record<string, any>, componentName: string): void;
6
- export declare function compileAttributes(table: Record<string, any>, attributes: Record<string, any>, componentName: string): void;
7
- export declare function compileWebTypes(table: Record<string, any>, webTypes: Record<string, any>, componentName: string): void;
8
- export declare function compileMD(path: string, tags: Record<string, any>, attributes: Record<string, any>, webTypes: Record<string, any>): void;
9
- export declare function compileDir(path: string, tags: Record<string, any>, attributes: Record<string, any>, webTypes: Record<string, any>): void;
5
+ export declare function compileTags(table: Record<string, any>, tags: Record<string, any>, componentName: string, varletConfig: Record<string, any>): void;
6
+ export declare function compileAttributes(table: Record<string, any>, attributes: Record<string, any>, componentName: string, varletConfig: Record<string, any>): void;
7
+ export declare function compileWebTypes(table: Record<string, any>, webTypes: Record<string, any>, componentName: string, varletConfig: Record<string, any>): void;
8
+ export declare function compileMD(path: string, tags: Record<string, any>, attributes: Record<string, any>, webTypes: Record<string, any>, varletConfig: Record<string, any>): void;
9
+ export declare function compileDir(path: string, tags: Record<string, any>, attributes: Record<string, any>, webTypes: Record<string, any>, varletConfig: Record<string, any>): void;
10
10
  export declare function compileTemplateHighlight(): Promise<void>;
@@ -43,7 +43,6 @@ var path_1 = require("path");
43
43
  var fsUtils_1 = require("../shared/fsUtils");
44
44
  var lodash_1 = require("lodash");
45
45
  var varlet_config_1 = require("../config/varlet.config");
46
- var varletConfig = (0, varlet_config_1.getVarletConfig)();
47
46
  var TABLE_HEAD_RE = /\s*\|.*\|\s*\n\s*\|.*---+\s*\|\s*\n+/;
48
47
  var TABLE_FOOT_RE = /(\|\s*$)|(\|\s*\n(?!\s*\|))/;
49
48
  var replaceDot = function (s) { return s.replace(/`/g, ''); };
@@ -84,23 +83,23 @@ function compileTable(md, titleRe) {
84
83
  return md.replace(/\\\|/g, '__varlet_axis__').trim();
85
84
  }
86
85
  exports.compileTable = compileTable;
87
- function compileTags(table, tags, componentName) {
88
- tags[(0, lodash_1.get)(varletConfig, 'namespace') + "-" + componentName] = {
86
+ function compileTags(table, tags, componentName, varletConfig) {
87
+ tags["".concat((0, lodash_1.get)(varletConfig, 'namespace'), "-").concat(componentName)] = {
89
88
  attributes: table.attributesTable.map(function (row) { return (0, exports.replaceDot)(row[0]); }),
90
89
  };
91
90
  }
92
91
  exports.compileTags = compileTags;
93
- function compileAttributes(table, attributes, componentName) {
92
+ function compileAttributes(table, attributes, componentName, varletConfig) {
94
93
  table.attributesTable.forEach(function (row) {
95
- var attrNamespace = (0, lodash_1.get)(varletConfig, 'namespace') + "-" + componentName + "/" + (0, exports.replaceDot)(row[0]);
94
+ var attrNamespace = "".concat((0, lodash_1.get)(varletConfig, 'namespace'), "-").concat(componentName, "/").concat((0, exports.replaceDot)(row[0]));
96
95
  attributes[attrNamespace] = {
97
96
  type: (0, exports.replaceUnderline)(row[2]),
98
- description: row[1] + " \u9ED8\u8BA4\u503C\uFF1A" + (0, exports.replaceDot)(row[3]),
97
+ description: "".concat(row[1], " \u9ED8\u8BA4\u503C\uFF1A").concat((0, exports.replaceDot)(row[3])),
99
98
  };
100
99
  });
101
100
  }
102
101
  exports.compileAttributes = compileAttributes;
103
- function compileWebTypes(table, webTypes, componentName) {
102
+ function compileWebTypes(table, webTypes, componentName, varletConfig) {
104
103
  var attributesTable = table.attributesTable, eventsTable = table.eventsTable, slotsTable = table.slotsTable;
105
104
  var attributes = attributesTable.map(function (row) { return ({
106
105
  name: (0, exports.replaceDot)(row[0]),
@@ -120,14 +119,14 @@ function compileWebTypes(table, webTypes, componentName) {
120
119
  description: row[1],
121
120
  }); });
122
121
  webTypes.contributions.html.tags.push({
123
- name: (0, lodash_1.get)(varletConfig, 'namespace') + "-" + componentName,
122
+ name: "".concat((0, lodash_1.get)(varletConfig, 'namespace'), "-").concat(componentName),
124
123
  attributes: attributes,
125
124
  events: events,
126
125
  slots: slots,
127
126
  });
128
127
  }
129
128
  exports.compileWebTypes = compileWebTypes;
130
- function compileMD(path, tags, attributes, webTypes) {
129
+ function compileMD(path, tags, attributes, webTypes, varletConfig) {
131
130
  if (!path.endsWith(constant_1.HL_MD)) {
132
131
  return;
133
132
  }
@@ -141,28 +140,29 @@ function compileMD(path, tags, attributes, webTypes) {
141
140
  eventsTable: eventsTable,
142
141
  slotsTable: slotsTable,
143
142
  };
144
- compileWebTypes(table, webTypes, componentName);
145
- compileTags(table, tags, componentName);
146
- compileAttributes(table, attributes, componentName);
143
+ compileWebTypes(table, webTypes, componentName, varletConfig);
144
+ compileTags(table, tags, componentName, varletConfig);
145
+ compileAttributes(table, attributes, componentName, varletConfig);
147
146
  }
148
147
  exports.compileMD = compileMD;
149
- function compileDir(path, tags, attributes, webTypes) {
148
+ function compileDir(path, tags, attributes, webTypes, varletConfig) {
150
149
  var dir = (0, fs_extra_1.readdirSync)(path);
151
150
  dir.forEach(function (filename) {
152
151
  var filePath = (0, path_1.resolve)(path, filename);
153
- (0, fsUtils_1.isDir)(filePath) && compileDir(filePath, tags, attributes, webTypes);
154
- (0, fsUtils_1.isMD)(filePath) && compileMD(filePath, tags, attributes, webTypes);
152
+ (0, fsUtils_1.isDir)(filePath) && compileDir(filePath, tags, attributes, webTypes, varletConfig);
153
+ (0, fsUtils_1.isMD)(filePath) && compileMD(filePath, tags, attributes, webTypes, varletConfig);
155
154
  });
156
155
  }
157
156
  exports.compileDir = compileDir;
158
157
  function compileTemplateHighlight() {
159
158
  return __awaiter(this, void 0, void 0, function () {
160
- var tags, attributes, webTypes;
159
+ var varletConfig, tags, attributes, webTypes;
161
160
  return __generator(this, function (_a) {
162
161
  switch (_a.label) {
163
162
  case 0: return [4 /*yield*/, (0, fs_extra_1.ensureDir)(constant_1.HL_DIR)];
164
163
  case 1:
165
164
  _a.sent();
165
+ varletConfig = (0, varlet_config_1.getVarletConfig)();
166
166
  tags = {};
167
167
  attributes = {};
168
168
  webTypes = {
@@ -177,7 +177,7 @@ function compileTemplateHighlight() {
177
177
  },
178
178
  },
179
179
  };
180
- compileDir(constant_1.SRC_DIR, tags, attributes, webTypes);
180
+ compileDir(constant_1.SRC_DIR, tags, attributes, webTypes, varletConfig);
181
181
  return [4 /*yield*/, Promise.all([
182
182
  (0, fs_extra_1.writeFile)(constant_1.HL_WEB_TYPES_JSON, JSON.stringify(webTypes, null, 2)),
183
183
  (0, fs_extra_1.writeFile)(constant_1.HL_TAGS_JSON, JSON.stringify(tags, null, 2)),
@@ -44,7 +44,7 @@ var path_1 = require("path");
44
44
  var varlet_config_1 = require("../config/varlet.config");
45
45
  var lodash_1 = require("lodash");
46
46
  function generateReference(moduleDir) {
47
- (0, fs_extra_1.writeFileSync)((0, path_1.resolve)(moduleDir, 'index.d.ts'), "export * from '" + (0, path_1.relative)(moduleDir, constant_1.TYPES_DIR) + "'\n");
47
+ (0, fs_extra_1.writeFileSync)((0, path_1.resolve)(moduleDir, 'index.d.ts'), "export * from '".concat((0, path_1.relative)(moduleDir, constant_1.TYPES_DIR), "'\n"));
48
48
  }
49
49
  exports.generateReference = generateReference;
50
50
  function compileTypes() {
@@ -67,13 +67,13 @@ function compileTypes() {
67
67
  declares = [];
68
68
  ignoreEntryDir.forEach(function (filename) {
69
69
  var componentName = filename.slice(0, filename.indexOf('.d.ts'));
70
- exports.push("export * from './" + componentName + "'");
70
+ exports.push("export * from './".concat(componentName, "'"));
71
71
  if (!componentName.startsWith(namespace)) {
72
- declares.push("" + (0, fsUtils_1.bigCamelize)(namespace) + (0, fsUtils_1.bigCamelize)(componentName) + ": typeof import('" + name + "')['_" + (0, fsUtils_1.bigCamelize)(componentName) + "Component']");
72
+ declares.push("".concat((0, fsUtils_1.bigCamelize)(namespace)).concat((0, fsUtils_1.bigCamelize)(componentName), ": typeof import('").concat(name, "')['_").concat((0, fsUtils_1.bigCamelize)(componentName), "Component']"));
73
73
  }
74
74
  });
75
- template = "import type { App } from 'vue'\n\nexport const install: (app: App) => void\n\n" + exports.join('\n') + "\n";
76
- globalTemplate = "declare module 'vue' {\n export interface GlobalComponents {\n " + declares.join('\n ') + "\n }\n}\n\nexport {}\n";
75
+ template = "import type { App } from 'vue'\n\nexport const install: (app: App) => void\n\n".concat(exports.join('\n'), "\n");
76
+ globalTemplate = "declare module 'vue' {\n export interface GlobalComponents {\n ".concat(declares.join('\n '), "\n }\n}\n\nexport {}\n");
77
77
  return [4 /*yield*/, Promise.all([
78
78
  (0, fs_extra_1.writeFile)((0, path_1.resolve)(constant_1.TYPES_DIR, 'index.d.ts'), template),
79
79
  (0, fs_extra_1.writeFile)((0, path_1.resolve)(constant_1.TYPES_DIR, 'global.d.ts'), globalTemplate),
@@ -30,7 +30,7 @@ module.exports = __assign({ moduleNameMapper: {
30
30
  '\\.(js|jsx|ts|tsx)$': 'babel-jest',
31
31
  }, collectCoverage: true, collectCoverageFrom: [
32
32
  'src/**/*.{js,jsx,ts,tsx,vue}',
33
- "!**/" + constant_1.EXAMPLE_DIR_NAME + "/**",
34
- "!**/" + constant_1.DOCS_DIR_NAME + "/**",
35
- "!**/" + constant_1.TESTS_DIR_NAME + "/**",
33
+ "!**/".concat(constant_1.EXAMPLE_DIR_NAME, "/**"),
34
+ "!**/".concat(constant_1.DOCS_DIR_NAME, "/**"),
35
+ "!**/".concat(constant_1.TESTS_DIR_NAME, "/**"),
36
36
  ], moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'vue'], transformIgnorePatterns: ['/node_modules/(?!(@varlet/cli))/'] }, getRootConfig());
@@ -1 +1 @@
1
- export declare function getVarletConfig(): Record<string, any>;
1
+ export declare function getVarletConfig(emit?: boolean): Record<string, any>;
@@ -5,7 +5,8 @@ var fs_extra_1 = require("fs-extra");
5
5
  var lodash_1 = require("lodash");
6
6
  var constant_1 = require("../shared/constant");
7
7
  var fsUtils_1 = require("../shared/fsUtils");
8
- function getVarletConfig() {
8
+ function getVarletConfig(emit) {
9
+ if (emit === void 0) { emit = false; }
9
10
  var config = {};
10
11
  if ((0, fs_extra_1.pathExistsSync)(constant_1.VARLET_CONFIG)) {
11
12
  delete require.cache[require.resolve(constant_1.VARLET_CONFIG)];
@@ -14,8 +15,10 @@ function getVarletConfig() {
14
15
  delete require.cache[require.resolve('../../varlet.default.config.js')];
15
16
  var defaultConfig = require('../../varlet.default.config.js');
16
17
  var mergedConfig = (0, lodash_1.merge)(defaultConfig, config);
17
- var source = JSON.stringify(mergedConfig, null, 2);
18
- (0, fsUtils_1.outputFileSyncOnChange)(constant_1.SITE_CONFIG, source);
18
+ if (emit) {
19
+ var source = JSON.stringify(mergedConfig, null, 2);
20
+ (0, fsUtils_1.outputFileSyncOnChange)(constant_1.SITE_CONFIG, source);
21
+ }
19
22
  return mergedConfig;
20
23
  }
21
24
  exports.getVarletConfig = getVarletConfig;
@@ -49,8 +49,8 @@ function getDevConfig(varletConfig) {
49
49
  (0, plugin_vue_jsx_1.default)(),
50
50
  (0, vite_plugin_html_1.injectHtml)({
51
51
  data: {
52
- pcTitle: (0, lodash_1.get)(varletConfig, "pc.title['" + defaultLanguage + "']"),
53
- mobileTitle: (0, lodash_1.get)(varletConfig, "mobile.title['" + defaultLanguage + "']"),
52
+ pcTitle: (0, lodash_1.get)(varletConfig, "pc.title['".concat(defaultLanguage, "']")),
53
+ mobileTitle: (0, lodash_1.get)(varletConfig, "mobile.title['".concat(defaultLanguage, "']")),
54
54
  logo: (0, lodash_1.get)(varletConfig, "logo"),
55
55
  baidu: (0, lodash_1.get)(varletConfig, "analysis.baidu", ''),
56
56
  },
@@ -86,8 +86,8 @@ function inlineCSS(fileName, dir) {
86
86
  var jsFile = (0, path_1.resolve)(dir, fileName);
87
87
  var cssCode = (0, fs_extra_1.readFileSync)(cssFile, 'utf-8');
88
88
  var jsCode = (0, fs_extra_1.readFileSync)(jsFile, 'utf-8');
89
- var injectCode = ";(function(){var style=document.createElement('style');style.type='text/css';style.rel='stylesheet';style.appendChild(document.createTextNode(`" + cssCode.replace(/\\/g, '\\\\') + "`));var head=document.querySelector('head');head.appendChild(style)})();";
90
- (0, fs_extra_1.writeFileSync)(jsFile, "" + injectCode + jsCode);
89
+ var injectCode = ";(function(){var style=document.createElement('style');style.type='text/css';style.rel='stylesheet';style.appendChild(document.createTextNode(`".concat(cssCode.replace(/\\/g, '\\\\'), "`));var head=document.querySelector('head');head.appendChild(style)})();");
90
+ (0, fs_extra_1.writeFileSync)(jsFile, "".concat(injectCode).concat(jsCode));
91
91
  (0, fs_extra_1.copyFileSync)(cssFile, (0, path_1.resolve)(constant_1.LIB_DIR, 'style.css'));
92
92
  (0, fs_extra_1.removeSync)(cssFile);
93
93
  },
@@ -104,7 +104,7 @@ function clear() {
104
104
  }
105
105
  function getUMDConfig(varletConfig) {
106
106
  var name = (0, lodash_1.get)(varletConfig, 'name');
107
- var fileName = (0, lodash_1.kebabCase)(name) + ".js";
107
+ var fileName = "".concat((0, lodash_1.kebabCase)(name), ".js");
108
108
  return {
109
109
  logLevel: 'silent',
110
110
  build: {