@varlet/cli 1.27.5 → 1.27.7-alpha.1651056904329
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/lib/commands/release.js +96 -42
- package/lib/compiler/compileSiteEntry.d.ts +5 -5
- package/lib/compiler/compileSiteEntry.js +23 -78
- package/lib/shared/fsUtils.d.ts +1 -0
- package/lib/shared/fsUtils.js +18 -1
- package/package.json +6 -6
- package/site/components/code-example/CodeExample.vue +34 -3
- package/site/utils.ts +4 -0
- package/varlet.default.config.js +1 -1
package/lib/commands/release.js
CHANGED
|
@@ -128,13 +128,78 @@ function updateVersion(version) {
|
|
|
128
128
|
(0, fs_extra_1.writeFileSync)(file, JSON.stringify(config, null, 2));
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
+
function confirmRegistry() {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
133
|
+
var registry, name, ret;
|
|
134
|
+
return __generator(this, function (_a) {
|
|
135
|
+
switch (_a.label) {
|
|
136
|
+
case 0: return [4 /*yield*/, (0, execa_1.default)('npm', ['config', 'get', 'registry'])];
|
|
137
|
+
case 1:
|
|
138
|
+
registry = (_a.sent()).stdout;
|
|
139
|
+
name = 'Registry confirm';
|
|
140
|
+
return [4 /*yield*/, inquirer_1.default.prompt([
|
|
141
|
+
{
|
|
142
|
+
name: name,
|
|
143
|
+
type: 'confirm',
|
|
144
|
+
message: "Current registry is: ".concat(registry),
|
|
145
|
+
},
|
|
146
|
+
])];
|
|
147
|
+
case 2:
|
|
148
|
+
ret = _a.sent();
|
|
149
|
+
return [2 /*return*/, ret[name]];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function confirmVersion(currentVersion, expectVersion) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
156
|
+
var name, ret;
|
|
157
|
+
return __generator(this, function (_a) {
|
|
158
|
+
switch (_a.label) {
|
|
159
|
+
case 0:
|
|
160
|
+
name = 'Version confirm';
|
|
161
|
+
return [4 /*yield*/, inquirer_1.default.prompt([
|
|
162
|
+
{
|
|
163
|
+
name: name,
|
|
164
|
+
type: 'confirm',
|
|
165
|
+
message: "All packages version ".concat(currentVersion, " -> ").concat(expectVersion, ":"),
|
|
166
|
+
},
|
|
167
|
+
])];
|
|
168
|
+
case 1:
|
|
169
|
+
ret = _a.sent();
|
|
170
|
+
return [2 /*return*/, ret[name]];
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function getReleaseType() {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
+
var name, ret;
|
|
178
|
+
return __generator(this, function (_a) {
|
|
179
|
+
switch (_a.label) {
|
|
180
|
+
case 0:
|
|
181
|
+
name = 'Please select release type';
|
|
182
|
+
return [4 /*yield*/, inquirer_1.default.prompt([
|
|
183
|
+
{
|
|
184
|
+
name: name,
|
|
185
|
+
type: 'list',
|
|
186
|
+
choices: releaseTypes,
|
|
187
|
+
},
|
|
188
|
+
])];
|
|
189
|
+
case 1:
|
|
190
|
+
ret = _a.sent();
|
|
191
|
+
return [2 /*return*/, ret[name]];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
}
|
|
131
196
|
function release(cmd) {
|
|
132
197
|
return __awaiter(this, void 0, void 0, function () {
|
|
133
|
-
var currentVersion,
|
|
198
|
+
var currentVersion, type, isPreRelease, expectVersion, _a, error_1;
|
|
134
199
|
return __generator(this, function (_b) {
|
|
135
200
|
switch (_b.label) {
|
|
136
201
|
case 0:
|
|
137
|
-
_b.trys.push([0,
|
|
202
|
+
_b.trys.push([0, 14, , 15]);
|
|
138
203
|
currentVersion = require((0, path_1.resolve)(constant_1.CWD, 'package.json')).version;
|
|
139
204
|
if (!currentVersion) {
|
|
140
205
|
logger_1.default.error('Your package is missing the version field');
|
|
@@ -146,68 +211,57 @@ function release(cmd) {
|
|
|
146
211
|
logger_1.default.error('Git worktree is not empty, please commit changed');
|
|
147
212
|
return [2 /*return*/];
|
|
148
213
|
}
|
|
149
|
-
|
|
150
|
-
return [4 /*yield*/, inquirer_1.default.prompt([
|
|
151
|
-
{
|
|
152
|
-
name: name_1,
|
|
153
|
-
type: 'list',
|
|
154
|
-
choices: releaseTypes,
|
|
155
|
-
},
|
|
156
|
-
])];
|
|
214
|
+
return [4 /*yield*/, confirmRegistry()];
|
|
157
215
|
case 2:
|
|
158
|
-
|
|
159
|
-
|
|
216
|
+
if (!(_b.sent())) {
|
|
217
|
+
return [2 /*return*/];
|
|
218
|
+
}
|
|
219
|
+
return [4 /*yield*/, getReleaseType()];
|
|
220
|
+
case 3:
|
|
221
|
+
type = _b.sent();
|
|
160
222
|
isPreRelease = type.startsWith('pre');
|
|
161
223
|
expectVersion = semver_1.default.inc(currentVersion, type, "alpha.".concat(Date.now()));
|
|
162
224
|
expectVersion = isPreRelease ? expectVersion.slice(0, -2) : expectVersion;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
name: name_1,
|
|
167
|
-
type: 'confirm',
|
|
168
|
-
message: "All packages version ".concat(currentVersion, " -> ").concat(expectVersion, ":"),
|
|
169
|
-
},
|
|
170
|
-
])];
|
|
171
|
-
case 3:
|
|
172
|
-
confirm_1 = _b.sent();
|
|
173
|
-
if (!confirm_1[name_1]) {
|
|
225
|
+
return [4 /*yield*/, confirmVersion(currentVersion, expectVersion)];
|
|
226
|
+
case 4:
|
|
227
|
+
if (!(_b.sent())) {
|
|
174
228
|
return [2 /*return*/];
|
|
175
229
|
}
|
|
176
230
|
updateVersion(expectVersion);
|
|
177
|
-
if (!!isPreRelease) return [3 /*break*/,
|
|
231
|
+
if (!!isPreRelease) return [3 /*break*/, 7];
|
|
178
232
|
return [4 /*yield*/, (0, changelog_1.changelog)()];
|
|
179
|
-
case
|
|
233
|
+
case 5:
|
|
180
234
|
_b.sent();
|
|
181
235
|
return [4 /*yield*/, pushGit(expectVersion, cmd.remote)];
|
|
182
|
-
case
|
|
236
|
+
case 6:
|
|
183
237
|
_b.sent();
|
|
184
|
-
_b.label =
|
|
185
|
-
case
|
|
186
|
-
case
|
|
238
|
+
_b.label = 7;
|
|
239
|
+
case 7: return [4 /*yield*/, publish(isPreRelease)];
|
|
240
|
+
case 8:
|
|
187
241
|
_b.sent();
|
|
188
242
|
logger_1.default.success("Release version ".concat(expectVersion, " successfully!"));
|
|
189
|
-
if (!isPreRelease) return [3 /*break*/,
|
|
190
|
-
_b.label =
|
|
191
|
-
case 8:
|
|
192
|
-
_b.trys.push([8, 11, , 12]);
|
|
193
|
-
return [4 /*yield*/, (0, execa_1.default)('git', ['restore', '**/package.json'])];
|
|
243
|
+
if (!isPreRelease) return [3 /*break*/, 13];
|
|
244
|
+
_b.label = 9;
|
|
194
245
|
case 9:
|
|
195
|
-
_b.
|
|
196
|
-
return [4 /*yield*/, (0, execa_1.default)('git', ['restore', 'package.json'])];
|
|
246
|
+
_b.trys.push([9, 12, , 13]);
|
|
247
|
+
return [4 /*yield*/, (0, execa_1.default)('git', ['restore', '**/package.json'])];
|
|
197
248
|
case 10:
|
|
198
249
|
_b.sent();
|
|
199
|
-
return [
|
|
250
|
+
return [4 /*yield*/, (0, execa_1.default)('git', ['restore', 'package.json'])];
|
|
200
251
|
case 11:
|
|
252
|
+
_b.sent();
|
|
253
|
+
return [3 /*break*/, 13];
|
|
254
|
+
case 12:
|
|
201
255
|
_a = _b.sent();
|
|
202
256
|
logger_1.default.error('Restore package.json has failed, please restore manually');
|
|
203
|
-
return [3 /*break*/,
|
|
204
|
-
case
|
|
205
|
-
case
|
|
257
|
+
return [3 /*break*/, 13];
|
|
258
|
+
case 13: return [3 /*break*/, 15];
|
|
259
|
+
case 14:
|
|
206
260
|
error_1 = _b.sent();
|
|
207
261
|
logger_1.default.error(error_1.toString());
|
|
208
262
|
process.exit(1);
|
|
209
|
-
return [3 /*break*/,
|
|
210
|
-
case
|
|
263
|
+
return [3 /*break*/, 15];
|
|
264
|
+
case 15: return [2 /*return*/];
|
|
211
265
|
}
|
|
212
266
|
});
|
|
213
267
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare function getExampleRoutePath(examplePath: string): string;
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
2
|
+
export declare function getComponentDocRoutePath(componentDocsPath: string): string;
|
|
3
|
+
export declare function getRootDocRoutePath(rootDocsPath: string): string;
|
|
4
|
+
export declare function findExamples(): Promise<string[]>;
|
|
5
|
+
export declare function findComponentDocs(): Promise<string[]>;
|
|
6
|
+
export declare function findRootDocs(): Promise<string[]>;
|
|
7
7
|
export declare function buildMobileSiteRoutes(): Promise<void>;
|
|
8
8
|
export declare function buildPcSiteRoutes(): Promise<void>;
|
|
9
9
|
export declare function buildSiteSource(): Promise<void>;
|
|
@@ -60,15 +60,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
60
60
|
}
|
|
61
61
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
62
62
|
};
|
|
63
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
64
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
65
|
-
};
|
|
66
63
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
|
-
exports.buildSiteEntry = exports.buildSiteSource = exports.buildPcSiteRoutes = exports.buildMobileSiteRoutes = exports.
|
|
68
|
-
var slash_1 = __importDefault(require("slash"));
|
|
64
|
+
exports.buildSiteEntry = exports.buildSiteSource = exports.buildPcSiteRoutes = exports.buildMobileSiteRoutes = exports.findRootDocs = exports.findComponentDocs = exports.findExamples = exports.getRootDocRoutePath = exports.getComponentDocRoutePath = exports.getExampleRoutePath = void 0;
|
|
69
65
|
var constant_1 = require("../shared/constant");
|
|
70
66
|
var fs_extra_1 = require("fs-extra");
|
|
71
|
-
var path_1 = require("path");
|
|
72
67
|
var fsUtils_1 = require("../shared/fsUtils");
|
|
73
68
|
var varlet_config_1 = require("../config/varlet.config");
|
|
74
69
|
var EXAMPLE_COMPONENT_NAME_RE = /\/([-\w]+)\/example\/index.vue/;
|
|
@@ -79,89 +74,39 @@ function getExampleRoutePath(examplePath) {
|
|
|
79
74
|
return '/' + ((_a = examplePath.match(EXAMPLE_COMPONENT_NAME_RE)) === null || _a === void 0 ? void 0 : _a[1]);
|
|
80
75
|
}
|
|
81
76
|
exports.getExampleRoutePath = getExampleRoutePath;
|
|
82
|
-
function
|
|
77
|
+
function getComponentDocRoutePath(componentDocsPath) {
|
|
83
78
|
var _a;
|
|
84
79
|
var _b = __read((_a = componentDocsPath.match(COMPONENT_DOCS_RE)) !== null && _a !== void 0 ? _a : [], 3), routePath = _b[1], language = _b[2];
|
|
85
80
|
return "/".concat(language, "/").concat(routePath);
|
|
86
81
|
}
|
|
87
|
-
exports.
|
|
88
|
-
function
|
|
82
|
+
exports.getComponentDocRoutePath = getComponentDocRoutePath;
|
|
83
|
+
function getRootDocRoutePath(rootDocsPath) {
|
|
89
84
|
var _a;
|
|
90
85
|
var _b = __read((_a = rootDocsPath.match(ROOT_DOCS_RE)) !== null && _a !== void 0 ? _a : [], 3), routePath = _b[1], language = _b[2];
|
|
91
86
|
return "/".concat(language, "/").concat(routePath);
|
|
92
87
|
}
|
|
93
|
-
exports.
|
|
94
|
-
function
|
|
95
|
-
return
|
|
96
|
-
var dir, buildPath, existPath, slashPath;
|
|
97
|
-
return __generator(this, function (_a) {
|
|
98
|
-
switch (_a.label) {
|
|
99
|
-
case 0: return [4 /*yield*/, (0, fs_extra_1.readdir)(constant_1.SRC_DIR)];
|
|
100
|
-
case 1:
|
|
101
|
-
dir = _a.sent();
|
|
102
|
-
buildPath = function (filename) { return (0, path_1.resolve)(constant_1.SRC_DIR, filename, constant_1.EXAMPLE_DIR_NAME, constant_1.EXAMPLE_DIR_INDEX); };
|
|
103
|
-
existPath = function (filename) { return (0, fs_extra_1.pathExistsSync)(buildPath(filename)); };
|
|
104
|
-
slashPath = function (filename) { return (0, slash_1.default)(buildPath(filename)); };
|
|
105
|
-
return [2 /*return*/, dir.filter(existPath).map(slashPath)];
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
88
|
+
exports.getRootDocRoutePath = getRootDocRoutePath;
|
|
89
|
+
function findExamples() {
|
|
90
|
+
return (0, fsUtils_1.glob)("".concat(constant_1.SRC_DIR, "/**/").concat(constant_1.EXAMPLE_DIR_NAME, "/").concat(constant_1.EXAMPLE_DIR_INDEX));
|
|
109
91
|
}
|
|
110
|
-
exports.
|
|
111
|
-
function
|
|
112
|
-
return
|
|
113
|
-
var dir, buildPath, existPath, collectRoutePath;
|
|
114
|
-
return __generator(this, function (_a) {
|
|
115
|
-
switch (_a.label) {
|
|
116
|
-
case 0: return [4 /*yield*/, (0, fs_extra_1.readdir)(constant_1.SRC_DIR)];
|
|
117
|
-
case 1:
|
|
118
|
-
dir = _a.sent();
|
|
119
|
-
buildPath = function (filename) { return (0, path_1.resolve)(constant_1.SRC_DIR, filename, constant_1.DOCS_DIR_NAME); };
|
|
120
|
-
existPath = function (filename) { return (0, fs_extra_1.pathExistsSync)(buildPath(filename)); };
|
|
121
|
-
collectRoutePath = function (routePaths, filename) {
|
|
122
|
-
var dirPath = buildPath(filename);
|
|
123
|
-
(0, fs_extra_1.readdirSync)(dirPath).forEach(function (mdName) {
|
|
124
|
-
var path = (0, path_1.resolve)(dirPath, mdName);
|
|
125
|
-
(0, fsUtils_1.isMD)(path) && routePaths.push((0, slash_1.default)(path));
|
|
126
|
-
});
|
|
127
|
-
return routePaths;
|
|
128
|
-
};
|
|
129
|
-
return [2 /*return*/, dir.filter(existPath).reduce(collectRoutePath, [])];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
});
|
|
92
|
+
exports.findExamples = findExamples;
|
|
93
|
+
function findComponentDocs() {
|
|
94
|
+
return (0, fsUtils_1.glob)("".concat(constant_1.SRC_DIR, "/**/").concat(constant_1.DOCS_DIR_NAME, "/*.md"));
|
|
133
95
|
}
|
|
134
|
-
exports.
|
|
135
|
-
function
|
|
136
|
-
return
|
|
137
|
-
var dir, buildPath, existPath, slashPath;
|
|
138
|
-
return __generator(this, function (_a) {
|
|
139
|
-
switch (_a.label) {
|
|
140
|
-
case 0:
|
|
141
|
-
if (!(0, fs_extra_1.pathExistsSync)(constant_1.ROOT_DOCS_DIR)) {
|
|
142
|
-
return [2 /*return*/, []];
|
|
143
|
-
}
|
|
144
|
-
return [4 /*yield*/, (0, fs_extra_1.readdir)(constant_1.ROOT_DOCS_DIR)];
|
|
145
|
-
case 1:
|
|
146
|
-
dir = _a.sent();
|
|
147
|
-
buildPath = function (filename) { return (0, path_1.resolve)(constant_1.ROOT_DOCS_DIR, filename); };
|
|
148
|
-
existPath = function (filename) { return (0, fsUtils_1.isMD)(buildPath(filename)); };
|
|
149
|
-
slashPath = function (filename) { return (0, slash_1.default)(buildPath(filename)); };
|
|
150
|
-
return [2 /*return*/, dir.filter(existPath).map(slashPath)];
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
});
|
|
96
|
+
exports.findComponentDocs = findComponentDocs;
|
|
97
|
+
function findRootDocs() {
|
|
98
|
+
return (0, fsUtils_1.glob)("".concat(constant_1.ROOT_DOCS_DIR, "/*.md"));
|
|
154
99
|
}
|
|
155
|
-
exports.
|
|
100
|
+
exports.findRootDocs = findRootDocs;
|
|
156
101
|
function buildMobileSiteRoutes() {
|
|
157
102
|
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
-
var
|
|
103
|
+
var examples, routes, source;
|
|
159
104
|
return __generator(this, function (_a) {
|
|
160
105
|
switch (_a.label) {
|
|
161
|
-
case 0: return [4 /*yield*/,
|
|
106
|
+
case 0: return [4 /*yield*/, findExamples()];
|
|
162
107
|
case 1:
|
|
163
|
-
|
|
164
|
-
routes =
|
|
108
|
+
examples = _a.sent();
|
|
109
|
+
routes = examples.map(function (example) { return "\n {\n path: '".concat(getExampleRoutePath(example), "',\n // @ts-ignore\n component: () => import('").concat(example, "')\n }"); });
|
|
165
110
|
source = "export default [ ".concat(routes.join(','), "\n]");
|
|
166
111
|
return [4 /*yield*/, (0, fsUtils_1.outputFileSyncOnChange)(constant_1.SITE_MOBILE_ROUTES, source)];
|
|
167
112
|
case 2:
|
|
@@ -174,14 +119,14 @@ function buildMobileSiteRoutes() {
|
|
|
174
119
|
exports.buildMobileSiteRoutes = buildMobileSiteRoutes;
|
|
175
120
|
function buildPcSiteRoutes() {
|
|
176
121
|
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
-
var _a,
|
|
122
|
+
var _a, componentDocs, rootDocs, componentDocsRoutes, rootDocsRoutes, source;
|
|
178
123
|
return __generator(this, function (_b) {
|
|
179
124
|
switch (_b.label) {
|
|
180
|
-
case 0: return [4 /*yield*/, Promise.all([
|
|
125
|
+
case 0: return [4 /*yield*/, Promise.all([findComponentDocs(), findRootDocs()])];
|
|
181
126
|
case 1:
|
|
182
|
-
_a = __read.apply(void 0, [_b.sent(), 2]),
|
|
183
|
-
componentDocsRoutes =
|
|
184
|
-
rootDocsRoutes =
|
|
127
|
+
_a = __read.apply(void 0, [_b.sent(), 2]), componentDocs = _a[0], rootDocs = _a[1];
|
|
128
|
+
componentDocsRoutes = componentDocs.map(function (componentDoc) { return "\n {\n path: '".concat(getComponentDocRoutePath(componentDoc), "',\n // @ts-ignore\n component: () => import('").concat(componentDoc, "')\n }"); });
|
|
129
|
+
rootDocsRoutes = rootDocs.map(function (rootDoc) { return "\n {\n path: '".concat(getRootDocRoutePath(rootDoc), "',\n // @ts-ignore\n component: () => import('").concat(rootDoc, "')\n }"); });
|
|
185
130
|
source = "export default [ ".concat(__spreadArray(__spreadArray([], __read(componentDocsRoutes), false), [rootDocsRoutes], false).join(','), "\n]");
|
|
186
131
|
(0, fsUtils_1.outputFileSyncOnChange)(constant_1.SITE_PC_ROUTES, source);
|
|
187
132
|
return [2 /*return*/];
|
package/lib/shared/fsUtils.d.ts
CHANGED
|
@@ -13,3 +13,4 @@ export declare const bigCamelize: (s: string) => string;
|
|
|
13
13
|
export declare const camelize: (s: string) => string;
|
|
14
14
|
export declare function smartAppendFileSync(file: string, code: string): void;
|
|
15
15
|
export declare function outputFileSyncOnChange(path: string, code: string): void;
|
|
16
|
+
export declare function glob(pattern: string): Promise<string[]>;
|
package/lib/shared/fsUtils.js
CHANGED
|
@@ -35,11 +35,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
38
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.outputFileSyncOnChange = exports.smartAppendFileSync = exports.camelize = exports.bigCamelize = exports.replaceExt = exports.isPublicDir = exports.isLess = exports.isScript = exports.isDTS = exports.isTSX = exports.isJSX = exports.isSFC = exports.isDir = exports.isMD = exports.getPublicDirs = void 0;
|
|
42
|
+
exports.glob = exports.outputFileSyncOnChange = exports.smartAppendFileSync = exports.camelize = exports.bigCamelize = exports.replaceExt = exports.isPublicDir = exports.isLess = exports.isScript = exports.isDTS = exports.isTSX = exports.isJSX = exports.isSFC = exports.isDir = exports.isMD = exports.getPublicDirs = void 0;
|
|
40
43
|
var path_1 = require("path");
|
|
41
44
|
var fs_extra_1 = require("fs-extra");
|
|
42
45
|
var constant_1 = require("./constant");
|
|
46
|
+
var glob_1 = __importDefault(require("glob"));
|
|
43
47
|
function getPublicDirs() {
|
|
44
48
|
return __awaiter(this, void 0, void 0, function () {
|
|
45
49
|
var srcDir;
|
|
@@ -97,3 +101,16 @@ function outputFileSyncOnChange(path, code) {
|
|
|
97
101
|
}
|
|
98
102
|
}
|
|
99
103
|
exports.outputFileSyncOnChange = outputFileSyncOnChange;
|
|
104
|
+
function glob(pattern) {
|
|
105
|
+
return new Promise(function (resolve, reject) {
|
|
106
|
+
(0, glob_1.default)(pattern, function (err, files) {
|
|
107
|
+
if (err) {
|
|
108
|
+
reject(err);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
resolve(files);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
exports.glob = glob;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "1.27.
|
|
3
|
+
"version": "1.27.7-alpha.1651056904329",
|
|
4
4
|
"description": "cli of varlet",
|
|
5
5
|
"bin": {
|
|
6
6
|
"varlet-cli": "./lib/index.js"
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"@babel/helper-plugin-utils": "^7.14.5",
|
|
34
34
|
"@babel/preset-env": "^7.14.8",
|
|
35
35
|
"@babel/preset-typescript": "^7.14.5",
|
|
36
|
-
"@varlet/icons": "1.27.
|
|
37
|
-
"@varlet/markdown-vite-plugin": "1.27.
|
|
38
|
-
"@varlet/touch-emulator": "1.27.
|
|
36
|
+
"@varlet/icons": "1.27.7-alpha.1651056904329",
|
|
37
|
+
"@varlet/markdown-vite-plugin": "1.27.7-alpha.1651056904329",
|
|
38
|
+
"@varlet/touch-emulator": "1.27.7-alpha.1651056904329",
|
|
39
39
|
"@vitejs/plugin-vue": "2.2.0",
|
|
40
40
|
"@vitejs/plugin-vue-jsx": "1.3.5",
|
|
41
41
|
"@vue/babel-plugin-jsx": "1.1.1",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"slash": "^3.0.0",
|
|
61
61
|
"ts-jest": "^26.5.1",
|
|
62
62
|
"typescript": "^4.4.4",
|
|
63
|
-
"vite": "2.
|
|
63
|
+
"vite": "2.9.5",
|
|
64
64
|
"vite-plugin-html": "^2.1.0",
|
|
65
65
|
"vue": "3.2.25",
|
|
66
66
|
"vue-jest": "^5.0.0-alpha.8"
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@types/semver": "^7.3.9"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"@varlet/touch-emulator": "1.27.
|
|
78
|
+
"@varlet/touch-emulator": "1.27.7-alpha.1651056904329",
|
|
79
79
|
"@vue/test-utils": "^2.0.0-rc.6",
|
|
80
80
|
"clipboard": "^2.0.6",
|
|
81
81
|
"live-server": "^1.2.1",
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
>
|
|
15
15
|
<var-site-icon name="content-copy" size="18" />
|
|
16
16
|
</var-site-button>
|
|
17
|
+
|
|
18
|
+
<var-site-button text round @click="toPlayground" v-if="playground">
|
|
19
|
+
<var-site-icon name="code-json" size="18" />
|
|
20
|
+
</var-site-button>
|
|
17
21
|
</div>
|
|
18
22
|
<div
|
|
19
23
|
:id="`clip-target-${cid}`"
|
|
@@ -38,7 +42,7 @@ import config from '@config'
|
|
|
38
42
|
import { defineComponent, nextTick, ref, onMounted } from 'vue'
|
|
39
43
|
import { doubleRaf } from '../utils/elements'
|
|
40
44
|
import { get } from 'lodash-es'
|
|
41
|
-
import { getPCLocationInfo } from '../../utils'
|
|
45
|
+
import { getPCLocationInfo, utoa } from '../../utils'
|
|
42
46
|
import type { Ref } from 'vue'
|
|
43
47
|
|
|
44
48
|
let clipId = 0
|
|
@@ -50,13 +54,20 @@ export default defineComponent({
|
|
|
50
54
|
[Button.name]: Button,
|
|
51
55
|
[Icon.name]: Icon
|
|
52
56
|
},
|
|
53
|
-
|
|
57
|
+
props: {
|
|
58
|
+
playgroundIgnore: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: false
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
setup(props) {
|
|
54
64
|
const code: Ref<HTMLElement | null> = ref(null)
|
|
55
65
|
const cid: Ref<number> = ref(clipId++)
|
|
56
66
|
const fold: Ref = ref(get(config, 'pc.fold'))
|
|
57
67
|
const disabledFold: Ref<boolean> = ref(false)
|
|
58
68
|
const clipboard: Ref = ref(get(config, 'pc.clipboard', {}))
|
|
59
69
|
const height: Ref<number> = ref(-1)
|
|
70
|
+
const playground: Ref<string | undefined> = ref(!props.playgroundIgnore ? get(config, 'pc.header.playground') : undefined )
|
|
60
71
|
let timer: any = null
|
|
61
72
|
|
|
62
73
|
const toggle = async () => {
|
|
@@ -82,6 +93,24 @@ export default defineComponent({
|
|
|
82
93
|
}
|
|
83
94
|
}
|
|
84
95
|
|
|
96
|
+
const toPlayground = () => {
|
|
97
|
+
const scriptStart = '<script setup>\n'
|
|
98
|
+
const scriptEnd = '<\/script>'
|
|
99
|
+
const injectImport = 'import { installVarletUI } from \'./varlet-repl-plugin.js\'\n'
|
|
100
|
+
const injectCall = '\ninstallVarletUI()\n'
|
|
101
|
+
let codeText = code.value?.innerText ?? ''
|
|
102
|
+
|
|
103
|
+
if (codeText.includes(scriptStart)) {
|
|
104
|
+
codeText = codeText.replace(scriptStart, `${scriptStart}${injectImport}`)
|
|
105
|
+
codeText = codeText.replace(scriptEnd, `${injectCall}${scriptEnd}`)
|
|
106
|
+
} else {
|
|
107
|
+
codeText = `${scriptStart}${injectImport}${injectCall}<\/script>\n\n${codeText}`
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const file = { 'App.vue': codeText }
|
|
111
|
+
window.open(`${playground.value}/#${utoa(JSON.stringify(file))}`)
|
|
112
|
+
}
|
|
113
|
+
|
|
85
114
|
onMounted(() => {
|
|
86
115
|
const trigger = new Clipboard(`#clip-trigger-${cid.value}`)
|
|
87
116
|
|
|
@@ -101,7 +130,9 @@ export default defineComponent({
|
|
|
101
130
|
fold,
|
|
102
131
|
disabledFold,
|
|
103
132
|
clipboard,
|
|
104
|
-
|
|
133
|
+
playground,
|
|
134
|
+
toggle,
|
|
135
|
+
toPlayground
|
|
105
136
|
}
|
|
106
137
|
}
|
|
107
138
|
})
|
package/site/utils.ts
CHANGED
package/varlet.default.config.js
CHANGED