@varlet/cli 2.0.5 → 2.1.0-alpha.1666877950844
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} +2 -2
- package/lib/node/bin.js +122 -0
- package/lib/{commands → node/commands}/build.d.ts +1 -1
- package/lib/node/commands/build.js +15 -0
- package/lib/{commands → node/commands}/changelog.d.ts +6 -6
- package/lib/node/commands/changelog.js +20 -0
- package/lib/{commands → node/commands}/commitLint.d.ts +1 -1
- package/lib/node/commands/commitLint.js +45 -0
- package/lib/{commands → node/commands}/compile.d.ts +7 -7
- package/lib/node/commands/compile.js +35 -0
- package/lib/{commands → node/commands}/create.d.ts +8 -8
- package/lib/node/commands/create.js +91 -0
- package/lib/{commands → node/commands}/dev.d.ts +5 -5
- package/lib/node/commands/dev.js +38 -0
- package/lib/{commands → node/commands}/gen.d.ts +8 -8
- package/lib/node/commands/gen.js +75 -0
- package/lib/{commands → node/commands}/jest.d.ts +8 -8
- package/lib/node/commands/jest.js +27 -0
- package/lib/{commands → node/commands}/lint.d.ts +1 -1
- package/lib/node/commands/lint.js +41 -0
- package/lib/{commands → node/commands}/preview.d.ts +1 -1
- package/lib/node/commands/preview.js +18 -0
- package/lib/{commands → node/commands}/release.d.ts +5 -5
- package/lib/node/commands/release.js +146 -0
- package/lib/{commands → node/commands}/vite.d.ts +3 -3
- package/lib/node/commands/vite.js +13 -0
- package/lib/{compiler → node/compiler}/compileModule.d.ts +5 -5
- package/lib/node/compiler/compileModule.js +74 -0
- package/lib/{compiler → node/compiler}/compileSFC.d.ts +2 -2
- package/lib/node/compiler/compileSFC.js +79 -0
- package/lib/{compiler → node/compiler}/compileScript.d.ts +17 -17
- package/lib/node/compiler/compileScript.js +141 -0
- package/lib/{compiler → node/compiler}/compileSiteEntry.d.ts +13 -13
- package/lib/node/compiler/compileSiteEntry.js +128 -0
- package/lib/{compiler → node/compiler}/compileStyle.d.ts +11 -11
- package/lib/node/compiler/compileStyle.js +39 -0
- package/lib/{compiler → node/compiler}/compileTemplateHighlight.d.ts +10 -10
- package/lib/node/compiler/compileTemplateHighlight.js +133 -0
- package/lib/{compiler → node/compiler}/compileTypes.d.ts +2 -2
- package/lib/node/compiler/compileTypes.js +45 -0
- package/lib/{config → node/config}/varlet.config.d.ts +45 -44
- 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 +42 -43
- package/lib/node/shared/constant.js +47 -0
- package/lib/{shared → node/shared}/fsUtils.d.ts +13 -12
- package/lib/node/shared/fsUtils.js +48 -0
- package/lib/{shared → node/shared}/logger.d.ts +8 -8
- package/lib/node/shared/logger.js +18 -0
- package/package.json +22 -19
- package/{preset.js → preset.cjs} +1 -1
- package/site/components/button/index.ts +10 -10
- package/site/components/cell/index.ts +10 -10
- package/site/components/code-example/CodeExample.vue +2 -1
- package/site/components/code-example/codeExample.less +41 -41
- package/site/components/code-example/index.ts +10 -10
- package/site/components/context/zIndex.ts +20 -20
- package/site/components/icon/icon.less +26 -26
- package/site/components/icon/index.ts +10 -10
- package/site/components/icon/props.ts +24 -24
- package/site/components/loading/index.ts +10 -10
- package/site/components/progress/index.ts +10 -10
- package/site/components/snackbar/snackbar.less +135 -135
- package/site/components/styles/common.less +64 -64
- package/site/components/styles/elevation.less +126 -126
- package/site/components/styles/var.less +27 -27
- package/site/components/utils/components.ts +1 -4
- package/site/components/utils/elements.ts +1 -1
- package/site/index.html +49 -49
- package/site/mobile/App.vue +27 -26
- package/site/mobile/components/AppHome.vue +2 -1
- package/site/mobile/components/app-bar/index.ts +10 -10
- package/site/mobile/components/app-bar/props.ts +25 -25
- package/site/mobile.html +41 -41
- package/site/module.d.ts +5 -5
- package/site/pc/App.vue +2 -1
- package/site/pc/Layout.vue +2 -1
- package/site/pc/components/AppHeader.vue +4 -2
- package/site/pc/pages/index/index.vue +8 -4
- package/site/tsconfig.json +11 -11
- package/site/useProgress.ts +2 -1
- package/site/utils.ts +6 -137
- 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 -270
- 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
package/lib/commands/preview.js
DELETED
|
@@ -1,74 +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.preview = void 0;
|
|
43
|
-
var logger_1 = __importDefault(require("../shared/logger"));
|
|
44
|
-
var execa_1 = __importDefault(require("execa"));
|
|
45
|
-
var constant_1 = require("../shared/constant");
|
|
46
|
-
var fs_extra_1 = require("fs-extra");
|
|
47
|
-
function preview() {
|
|
48
|
-
var _a;
|
|
49
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
-
var e_1;
|
|
51
|
-
return __generator(this, function (_b) {
|
|
52
|
-
switch (_b.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
if (!(0, fs_extra_1.pathExistsSync)(constant_1.SITE_OUTPUT_PATH)) {
|
|
55
|
-
logger_1.default.warning('Cannot find the site folder, you must first run the build command to build the document site');
|
|
56
|
-
return [2 /*return*/];
|
|
57
|
-
}
|
|
58
|
-
_b.label = 1;
|
|
59
|
-
case 1:
|
|
60
|
-
_b.trys.push([1, 3, , 4]);
|
|
61
|
-
return [4 /*yield*/, ((_a = execa_1.default.command('live-server --port=5500', { cwd: constant_1.SITE_OUTPUT_PATH }).stdout) === null || _a === void 0 ? void 0 : _a.pipe(process.stdout))];
|
|
62
|
-
case 2:
|
|
63
|
-
_b.sent();
|
|
64
|
-
return [3 /*break*/, 4];
|
|
65
|
-
case 3:
|
|
66
|
-
e_1 = _b.sent();
|
|
67
|
-
logger_1.default.error(e_1.toString());
|
|
68
|
-
return [3 /*break*/, 4];
|
|
69
|
-
case 4: return [2 /*return*/];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
exports.preview = preview;
|
package/lib/commands/release.js
DELETED
|
@@ -1,270 +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.release = void 0;
|
|
43
|
-
var ora_1 = __importDefault(require("ora"));
|
|
44
|
-
var execa_1 = __importDefault(require("execa"));
|
|
45
|
-
var logger_1 = __importDefault(require("../shared/logger"));
|
|
46
|
-
var semver_1 = __importDefault(require("semver"));
|
|
47
|
-
var glob_1 = __importDefault(require("glob"));
|
|
48
|
-
var inquirer_1 = require("inquirer");
|
|
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
|
-
if (ret.stderr && ret.stderr.includes('npm ERR!')) {
|
|
80
|
-
throw new Error('\n' + ret.stderr);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
s.succeed('Publish all packages successfully');
|
|
84
|
-
ret.stdout && logger_1.default.info(ret.stdout);
|
|
85
|
-
}
|
|
86
|
-
return [2 /*return*/];
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
function pushGit(version, remote) {
|
|
92
|
-
if (remote === void 0) { remote = 'origin'; }
|
|
93
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
-
var s, ret;
|
|
95
|
-
return __generator(this, function (_a) {
|
|
96
|
-
switch (_a.label) {
|
|
97
|
-
case 0:
|
|
98
|
-
s = (0, ora_1.default)().start('Pushing to remote git repository');
|
|
99
|
-
return [4 /*yield*/, (0, execa_1.default)('git', ['add', '.'])];
|
|
100
|
-
case 1:
|
|
101
|
-
_a.sent();
|
|
102
|
-
return [4 /*yield*/, (0, execa_1.default)('git', ['commit', '-m', "v".concat(version)])];
|
|
103
|
-
case 2:
|
|
104
|
-
_a.sent();
|
|
105
|
-
return [4 /*yield*/, (0, execa_1.default)('git', ['tag', "v".concat(version)])];
|
|
106
|
-
case 3:
|
|
107
|
-
_a.sent();
|
|
108
|
-
return [4 /*yield*/, (0, execa_1.default)('git', ['push', remote, "v".concat(version)])];
|
|
109
|
-
case 4:
|
|
110
|
-
_a.sent();
|
|
111
|
-
return [4 /*yield*/, (0, execa_1.default)('git', ['push'])];
|
|
112
|
-
case 5:
|
|
113
|
-
ret = _a.sent();
|
|
114
|
-
s.succeed('Push remote repository successfully');
|
|
115
|
-
ret.stdout && logger_1.default.info(ret.stdout);
|
|
116
|
-
return [2 /*return*/];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
function updateVersion(version) {
|
|
122
|
-
var packageJsons = glob_1.default.sync('packages/*/package.json');
|
|
123
|
-
packageJsons.push('package.json');
|
|
124
|
-
packageJsons.forEach(function (path) {
|
|
125
|
-
var file = (0, path_1.resolve)(constant_1.CWD, path);
|
|
126
|
-
var config = require(file);
|
|
127
|
-
config.version = version;
|
|
128
|
-
(0, fs_extra_1.writeFileSync)(file, JSON.stringify(config, null, 2));
|
|
129
|
-
});
|
|
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*/, (0, inquirer_1.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*/, (0, inquirer_1.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*/, (0, inquirer_1.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
|
-
}
|
|
196
|
-
function release(options) {
|
|
197
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
-
var currentVersion, type, isPreRelease, expectVersion, _a, error_1;
|
|
199
|
-
return __generator(this, function (_b) {
|
|
200
|
-
switch (_b.label) {
|
|
201
|
-
case 0:
|
|
202
|
-
_b.trys.push([0, 14, , 15]);
|
|
203
|
-
currentVersion = require((0, path_1.resolve)(constant_1.CWD, 'package.json')).version;
|
|
204
|
-
if (!currentVersion) {
|
|
205
|
-
logger_1.default.error('Your package is missing the version field');
|
|
206
|
-
return [2 /*return*/];
|
|
207
|
-
}
|
|
208
|
-
return [4 /*yield*/, isWorktreeEmpty()];
|
|
209
|
-
case 1:
|
|
210
|
-
if (!(_b.sent())) {
|
|
211
|
-
logger_1.default.error('Git worktree is not empty, please commit changed');
|
|
212
|
-
return [2 /*return*/];
|
|
213
|
-
}
|
|
214
|
-
return [4 /*yield*/, confirmRegistry()];
|
|
215
|
-
case 2:
|
|
216
|
-
if (!(_b.sent())) {
|
|
217
|
-
return [2 /*return*/];
|
|
218
|
-
}
|
|
219
|
-
return [4 /*yield*/, getReleaseType()];
|
|
220
|
-
case 3:
|
|
221
|
-
type = _b.sent();
|
|
222
|
-
isPreRelease = type.startsWith('pre');
|
|
223
|
-
expectVersion = semver_1.default.inc(currentVersion, type, "alpha.".concat(Date.now()));
|
|
224
|
-
expectVersion = isPreRelease ? expectVersion.slice(0, -2) : expectVersion;
|
|
225
|
-
return [4 /*yield*/, confirmVersion(currentVersion, expectVersion)];
|
|
226
|
-
case 4:
|
|
227
|
-
if (!(_b.sent())) {
|
|
228
|
-
return [2 /*return*/];
|
|
229
|
-
}
|
|
230
|
-
updateVersion(expectVersion);
|
|
231
|
-
return [4 /*yield*/, publish(isPreRelease)];
|
|
232
|
-
case 5:
|
|
233
|
-
_b.sent();
|
|
234
|
-
if (!!isPreRelease) return [3 /*break*/, 8];
|
|
235
|
-
return [4 /*yield*/, (0, changelog_1.changelog)()];
|
|
236
|
-
case 6:
|
|
237
|
-
_b.sent();
|
|
238
|
-
return [4 /*yield*/, pushGit(expectVersion, options.remote)];
|
|
239
|
-
case 7:
|
|
240
|
-
_b.sent();
|
|
241
|
-
_b.label = 8;
|
|
242
|
-
case 8:
|
|
243
|
-
logger_1.default.success("Release version ".concat(expectVersion, " successfully!"));
|
|
244
|
-
if (!isPreRelease) return [3 /*break*/, 13];
|
|
245
|
-
_b.label = 9;
|
|
246
|
-
case 9:
|
|
247
|
-
_b.trys.push([9, 12, , 13]);
|
|
248
|
-
return [4 /*yield*/, (0, execa_1.default)('git', ['restore', '**/package.json'])];
|
|
249
|
-
case 10:
|
|
250
|
-
_b.sent();
|
|
251
|
-
return [4 /*yield*/, (0, execa_1.default)('git', ['restore', 'package.json'])];
|
|
252
|
-
case 11:
|
|
253
|
-
_b.sent();
|
|
254
|
-
return [3 /*break*/, 13];
|
|
255
|
-
case 12:
|
|
256
|
-
_a = _b.sent();
|
|
257
|
-
logger_1.default.error('Restore package.json has failed, please restore manually');
|
|
258
|
-
return [3 /*break*/, 13];
|
|
259
|
-
case 13: return [3 /*break*/, 15];
|
|
260
|
-
case 14:
|
|
261
|
-
error_1 = _b.sent();
|
|
262
|
-
logger_1.default.error(error_1.toString());
|
|
263
|
-
process.exit(1);
|
|
264
|
-
return [3 /*break*/, 15];
|
|
265
|
-
case 15: return [2 /*return*/];
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
exports.release = release;
|
package/lib/commands/vite.js
DELETED
|
@@ -1,69 +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.vite = void 0;
|
|
43
|
-
var plugin_vue_1 = __importDefault(require("@vitejs/plugin-vue"));
|
|
44
|
-
var plugin_vue_jsx_1 = __importDefault(require("@vitejs/plugin-vue-jsx"));
|
|
45
|
-
var vite_1 = require("vite");
|
|
46
|
-
function vite(mode) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
-
var run, result;
|
|
49
|
-
return __generator(this, function (_a) {
|
|
50
|
-
switch (_a.label) {
|
|
51
|
-
case 0:
|
|
52
|
-
run = mode === 'build' ? vite_1.build : vite_1.createServer;
|
|
53
|
-
return [4 /*yield*/, run({
|
|
54
|
-
plugins: [(0, plugin_vue_1.default)(), (0, plugin_vue_jsx_1.default)()],
|
|
55
|
-
})];
|
|
56
|
-
case 1:
|
|
57
|
-
result = _a.sent();
|
|
58
|
-
if (!(mode === 'dev')) return [3 /*break*/, 3];
|
|
59
|
-
return [4 /*yield*/, result.listen()];
|
|
60
|
-
case 2:
|
|
61
|
-
_a.sent();
|
|
62
|
-
result.printUrls();
|
|
63
|
-
_a.label = 3;
|
|
64
|
-
case 3: return [2 /*return*/];
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
exports.vite = vite;
|
|
@@ -1,190 +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.compileModule = exports.compileFile = exports.compileDir = exports.compileESMBundle = exports.compileUMD = void 0;
|
|
40
|
-
var vite_1 = require("vite");
|
|
41
|
-
var path_1 = require("path");
|
|
42
|
-
var fs_extra_1 = require("fs-extra");
|
|
43
|
-
var constant_1 = require("../shared/constant");
|
|
44
|
-
var fsUtils_1 = require("../shared/fsUtils");
|
|
45
|
-
var compileSFC_1 = require("./compileSFC");
|
|
46
|
-
var compileScript_1 = require("./compileScript");
|
|
47
|
-
var compileStyle_1 = require("./compileStyle");
|
|
48
|
-
var vite_config_1 = require("../config/vite.config");
|
|
49
|
-
var varlet_config_1 = require("../config/varlet.config");
|
|
50
|
-
var compileTypes_1 = require("./compileTypes");
|
|
51
|
-
function compileUMD() {
|
|
52
|
-
return new Promise(function (resolve, reject) {
|
|
53
|
-
var config = (0, vite_config_1.getUMDConfig)((0, varlet_config_1.getVarletConfig)());
|
|
54
|
-
(0, vite_1.build)(config)
|
|
55
|
-
.then(function () { return resolve(); })
|
|
56
|
-
.catch(reject);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
exports.compileUMD = compileUMD;
|
|
60
|
-
function compileESMBundle() {
|
|
61
|
-
return new Promise(function (resolve, reject) {
|
|
62
|
-
var config = (0, vite_config_1.getESMBundleConfig)((0, varlet_config_1.getVarletConfig)());
|
|
63
|
-
(0, vite_1.build)(config)
|
|
64
|
-
.then(function () { return resolve(); })
|
|
65
|
-
.catch(reject);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
exports.compileESMBundle = compileESMBundle;
|
|
69
|
-
function compileDir(dir) {
|
|
70
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
-
var dirs;
|
|
72
|
-
return __generator(this, function (_a) {
|
|
73
|
-
switch (_a.label) {
|
|
74
|
-
case 0: return [4 /*yield*/, (0, fs_extra_1.readdir)(dir)];
|
|
75
|
-
case 1:
|
|
76
|
-
dirs = _a.sent();
|
|
77
|
-
return [4 /*yield*/, Promise.all(dirs.map(function (filename) {
|
|
78
|
-
var file = (0, path_1.resolve)(dir, filename);
|
|
79
|
-
[constant_1.TESTS_DIR_NAME, constant_1.EXAMPLE_DIR_NAME, constant_1.DOCS_DIR_NAME].includes(filename) && (0, fs_extra_1.removeSync)(file);
|
|
80
|
-
if ((0, fsUtils_1.isDTS)(file) || filename === constant_1.STYLE_DIR_NAME) {
|
|
81
|
-
return Promise.resolve();
|
|
82
|
-
}
|
|
83
|
-
return compileFile(file);
|
|
84
|
-
}))];
|
|
85
|
-
case 2:
|
|
86
|
-
_a.sent();
|
|
87
|
-
return [2 /*return*/];
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
exports.compileDir = compileDir;
|
|
93
|
-
function compileFile(file) {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
-
var _a, _b, _c, _d;
|
|
96
|
-
return __generator(this, function (_e) {
|
|
97
|
-
switch (_e.label) {
|
|
98
|
-
case 0:
|
|
99
|
-
_a = (0, fsUtils_1.isSFC)(file);
|
|
100
|
-
if (!_a) return [3 /*break*/, 2];
|
|
101
|
-
return [4 /*yield*/, (0, compileSFC_1.compileSFC)(file)];
|
|
102
|
-
case 1:
|
|
103
|
-
_a = (_e.sent());
|
|
104
|
-
_e.label = 2;
|
|
105
|
-
case 2:
|
|
106
|
-
_a;
|
|
107
|
-
_b = (0, fsUtils_1.isScript)(file);
|
|
108
|
-
if (!_b) return [3 /*break*/, 4];
|
|
109
|
-
return [4 /*yield*/, (0, compileScript_1.compileScriptFile)(file)];
|
|
110
|
-
case 3:
|
|
111
|
-
_b = (_e.sent());
|
|
112
|
-
_e.label = 4;
|
|
113
|
-
case 4:
|
|
114
|
-
_b;
|
|
115
|
-
_c = (0, fsUtils_1.isLess)(file);
|
|
116
|
-
if (!_c) return [3 /*break*/, 6];
|
|
117
|
-
return [4 /*yield*/, (0, compileStyle_1.compileLess)(file)];
|
|
118
|
-
case 5:
|
|
119
|
-
_c = (_e.sent());
|
|
120
|
-
_e.label = 6;
|
|
121
|
-
case 6:
|
|
122
|
-
_c;
|
|
123
|
-
_d = (0, fsUtils_1.isDir)(file);
|
|
124
|
-
if (!_d) return [3 /*break*/, 8];
|
|
125
|
-
return [4 /*yield*/, compileDir(file)];
|
|
126
|
-
case 7:
|
|
127
|
-
_d = (_e.sent());
|
|
128
|
-
_e.label = 8;
|
|
129
|
-
case 8:
|
|
130
|
-
_d;
|
|
131
|
-
return [2 /*return*/];
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
exports.compileFile = compileFile;
|
|
137
|
-
function compileModule(modules) {
|
|
138
|
-
if (modules === void 0) { modules = false; }
|
|
139
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
140
|
-
var dest, moduleDir, publicDirs;
|
|
141
|
-
return __generator(this, function (_a) {
|
|
142
|
-
switch (_a.label) {
|
|
143
|
-
case 0:
|
|
144
|
-
if (!(modules === 'umd')) return [3 /*break*/, 2];
|
|
145
|
-
return [4 /*yield*/, compileUMD()];
|
|
146
|
-
case 1:
|
|
147
|
-
_a.sent();
|
|
148
|
-
return [2 /*return*/];
|
|
149
|
-
case 2:
|
|
150
|
-
if (!(modules === 'esm-bundle')) return [3 /*break*/, 4];
|
|
151
|
-
return [4 /*yield*/, compileESMBundle()];
|
|
152
|
-
case 3:
|
|
153
|
-
_a.sent();
|
|
154
|
-
return [2 /*return*/];
|
|
155
|
-
case 4:
|
|
156
|
-
process.env.BABEL_MODULE = modules === 'commonjs' ? 'commonjs' : 'module';
|
|
157
|
-
dest = modules === 'commonjs' ? constant_1.LIB_DIR : constant_1.ES_DIR;
|
|
158
|
-
return [4 /*yield*/, (0, fs_extra_1.copy)(constant_1.SRC_DIR, dest)];
|
|
159
|
-
case 5:
|
|
160
|
-
_a.sent();
|
|
161
|
-
return [4 /*yield*/, (0, fs_extra_1.readdir)(dest)];
|
|
162
|
-
case 6:
|
|
163
|
-
moduleDir = _a.sent();
|
|
164
|
-
return [4 /*yield*/, Promise.all(moduleDir.map(function (filename) {
|
|
165
|
-
var file = (0, path_1.resolve)(dest, filename);
|
|
166
|
-
(0, fsUtils_1.isDir)(file) && (0, fs_extra_1.ensureFileSync)((0, path_1.resolve)(file, './style/index.js'));
|
|
167
|
-
return (0, fsUtils_1.isDir)(file) ? compileDir(file) : null;
|
|
168
|
-
}))];
|
|
169
|
-
case 7:
|
|
170
|
-
_a.sent();
|
|
171
|
-
return [4 /*yield*/, (0, fsUtils_1.getPublicDirs)()];
|
|
172
|
-
case 8:
|
|
173
|
-
publicDirs = _a.sent();
|
|
174
|
-
if (!(modules === 'commonjs')) return [3 /*break*/, 10];
|
|
175
|
-
return [4 /*yield*/, (0, compileScript_1.compileCommonJSEntry)(dest, publicDirs)];
|
|
176
|
-
case 9:
|
|
177
|
-
_a.sent();
|
|
178
|
-
return [3 /*break*/, 12];
|
|
179
|
-
case 10: return [4 /*yield*/, (0, compileScript_1.compileESEntry)(dest, publicDirs)];
|
|
180
|
-
case 11:
|
|
181
|
-
_a.sent();
|
|
182
|
-
_a.label = 12;
|
|
183
|
-
case 12:
|
|
184
|
-
(0, compileTypes_1.generateReference)(dest);
|
|
185
|
-
return [2 /*return*/];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
exports.compileModule = compileModule;
|