@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.
- package/README.en-US.md +32 -52
- package/README.md +32 -50
- package/generators/base/.husky/commit-msg +1 -1
- package/generators/base/package.json +20 -26
- package/lib/commands/changelog.d.ts +6 -0
- package/lib/commands/changelog.js +27 -0
- package/lib/commands/commitLint.d.ts +1 -0
- package/lib/commands/commitLint.js +21 -0
- package/lib/commands/compile.js +3 -3
- package/lib/commands/create.js +9 -10
- package/lib/commands/dev.js +2 -2
- package/lib/commands/gen.js +8 -4
- package/lib/commands/jest.js +1 -1
- package/lib/commands/release.d.ts +1 -0
- package/lib/commands/release.js +203 -0
- package/lib/compiler/compileSFC.js +5 -5
- package/lib/compiler/compileScript.js +19 -19
- package/lib/compiler/compileSiteEntry.js +8 -8
- package/lib/compiler/compileStyle.js +6 -6
- package/lib/compiler/compileTemplateHighlight.d.ts +5 -5
- package/lib/compiler/compileTemplateHighlight.js +17 -17
- package/lib/compiler/compileTypes.js +5 -5
- package/lib/config/jest.config.js +3 -3
- package/lib/config/varlet.config.d.ts +1 -1
- package/lib/config/varlet.config.js +6 -3
- package/lib/config/vite.config.js +5 -5
- package/lib/index.js +13 -2
- package/package.json +30 -37
- package/site/components/utils/elements.ts +0 -1
- package/site/index.html +3 -0
- package/site/mobile.html +3 -0
- package/generators/base/.gitignore +0 -14
- package/generators/base/commitlint.config.js +0 -3
- package/site/.DS_Store +0 -0
- package/site/components/.DS_Store +0 -0
package/README.en-US.md
CHANGED
|
@@ -13,21 +13,21 @@ The out-of-the-box `Vue3 component library` rapid prototyping tool provides a se
|
|
|
13
13
|
- 7.Out-of-the-box code publishing tool, publish to npm and github, and automatically generate a change log
|
|
14
14
|
- 8.Support `Typescript`
|
|
15
15
|
- 9.Support `Dark Mode`
|
|
16
|
+
- 10.Based on `pnpm`
|
|
16
17
|
|
|
17
18
|
### Quickstart
|
|
18
19
|
|
|
19
20
|
`@varlet/cli` has built-in `single file component (sfc)` and `tsx, jsx` two styles of component library project templates, which can be directly generated by the `gen` command.
|
|
20
|
-
To help users directly enter the development of the component itself, it is recommended to use `
|
|
21
|
-
The installation and configuration methods of `yarn` are not introduced here.
|
|
21
|
+
To help users directly enter the development of the component itself, it is recommended to use `pnpm` as a package management tool.
|
|
22
22
|
|
|
23
23
|
```shell
|
|
24
24
|
# Install command line tools
|
|
25
|
-
|
|
25
|
+
pnpm add @varlet/cli -g
|
|
26
26
|
# Use the gen command to generate the project
|
|
27
27
|
varlet-cli gen projectName
|
|
28
28
|
cd projectName
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
pnpm install
|
|
30
|
+
pnpm dev
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
Then by simply modifying some basic information of the component library template,
|
|
@@ -238,6 +238,24 @@ varlet-cli test -wa
|
|
|
238
238
|
varlet-cli lint
|
|
239
239
|
```
|
|
240
240
|
|
|
241
|
+
#### Lint commit message
|
|
242
|
+
|
|
243
|
+
```shell
|
|
244
|
+
varlet-cli commit-lint
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
#### Generate changelog
|
|
248
|
+
|
|
249
|
+
```shell
|
|
250
|
+
varlet-cli changelog
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
#### Release component library
|
|
254
|
+
|
|
255
|
+
```shell
|
|
256
|
+
varlet-cli release
|
|
257
|
+
```
|
|
258
|
+
|
|
241
259
|
#### Quickly create a component folder
|
|
242
260
|
|
|
243
261
|
```shell
|
|
@@ -282,19 +300,13 @@ module.exports = {
|
|
|
282
300
|
|
|
283
301
|
#### git-hook
|
|
284
302
|
|
|
285
|
-
`husky`, `lint-staged` cooperate with `eslint`, `stylelint`, `
|
|
303
|
+
`husky`, `lint-staged` cooperate with `eslint`, `stylelint`, `varlet-cli commit-lint` to check before commit,
|
|
286
304
|
`package.json` configuration is as follows
|
|
287
305
|
|
|
288
306
|
```json
|
|
289
307
|
{
|
|
290
308
|
"scripts": {
|
|
291
|
-
"prepare": "husky install"
|
|
292
|
-
"commit": "git-cz"
|
|
293
|
-
},
|
|
294
|
-
"config": {
|
|
295
|
-
"commitizen": {
|
|
296
|
-
"path": "cz-conventional-changelog"
|
|
297
|
-
}
|
|
309
|
+
"prepare": "husky install"
|
|
298
310
|
},
|
|
299
311
|
"lint-staged": {
|
|
300
312
|
"*.{ts,tsx,js,vue,less}": "prettier --write",
|
|
@@ -331,15 +343,6 @@ module.exports = {
|
|
|
331
343
|
}
|
|
332
344
|
```
|
|
333
345
|
|
|
334
|
-
create `commitlint.config.js`
|
|
335
|
-
|
|
336
|
-
```js
|
|
337
|
-
// commitlint.config.js
|
|
338
|
-
module.exports = {
|
|
339
|
-
extends: ['@commitlint/config-conventional'],
|
|
340
|
-
}
|
|
341
|
-
```
|
|
342
|
-
|
|
343
346
|
create `.prettierignore`
|
|
344
347
|
|
|
345
348
|
```text
|
|
@@ -373,36 +376,13 @@ create `tsconfig.json`
|
|
|
373
376
|
}
|
|
374
377
|
```
|
|
375
378
|
|
|
376
|
-
|
|
379
|
+
#### Note before release
|
|
377
380
|
|
|
378
|
-
|
|
379
|
-
The
|
|
381
|
+
- 1.The registry of npm must set to the official npm mirror
|
|
382
|
+
- 2.The npm must execute the login command for user login
|
|
380
383
|
|
|
381
|
-
|
|
382
|
-
{
|
|
383
|
-
"scripts": {
|
|
384
|
-
"genlog": "conventional-changelog -p angular -i CHANGELOG.md -s",
|
|
385
|
-
"genAllLog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
|
386
|
-
"release": "yarn compile && release-it"
|
|
387
|
-
},
|
|
388
|
-
"release-it": {
|
|
389
|
-
"git": {
|
|
390
|
-
"changelog": "git log --pretty=format:\"* %s (%h)\" ${from}...${to}",
|
|
391
|
-
"tagName": "v${version}",
|
|
392
|
-
"commitMessage": "chore: release ${version}",
|
|
393
|
-
"requireCleanWorkingDir": false
|
|
394
|
-
},
|
|
395
|
-
"plugins": {
|
|
396
|
-
"@release-it/conventional-changelog": {
|
|
397
|
-
"preset": "angular",
|
|
398
|
-
"infile": "CHANGELOG.md"
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
#### Note before release
|
|
384
|
+
### Contributors
|
|
406
385
|
|
|
407
|
-
|
|
408
|
-
|
|
386
|
+
<a href="https://github.com/haoziqaq/varlet/graphs/contributors">
|
|
387
|
+
<img src="https://contrib.rocks/image?repo=haoziqaq/varlet" />
|
|
388
|
+
</a>
|
package/README.md
CHANGED
|
@@ -13,20 +13,21 @@
|
|
|
13
13
|
- 7.开箱即用的代码发布工具,发布到npm和github,并自动生成更新日志
|
|
14
14
|
- 8.支持`Typescript`
|
|
15
15
|
- 9.支持`暗黑模式`
|
|
16
|
+
- 10.基于`pnpm`
|
|
16
17
|
|
|
17
18
|
### 快速开始
|
|
18
19
|
|
|
19
20
|
`@varlet/cli`内置了`单文件组件(sfc)`和`tsx, jsx`两种风格的组件库项目模板,可以通过`gen`命令直接生成。
|
|
20
|
-
|
|
21
|
+
帮助用户直接进入组件本身的开发,推荐使用`pnpm`作为包管理工具。
|
|
21
22
|
|
|
22
23
|
```shell
|
|
23
24
|
# 安装命令行工具
|
|
24
|
-
|
|
25
|
+
pnpm add @varlet/cli -g
|
|
25
26
|
# 使用gen命令生成项目
|
|
26
27
|
varlet-cli gen 项目名
|
|
27
28
|
cd 项目名
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
pnpm install
|
|
30
|
+
pnpm dev
|
|
30
31
|
```
|
|
31
32
|
|
|
32
33
|
然后通过简单修改一些组件库模板的基础信息,就可以开始组件库的开发了
|
|
@@ -233,6 +234,24 @@ varlet-cli test -wa
|
|
|
233
234
|
varlet-cli lint
|
|
234
235
|
```
|
|
235
236
|
|
|
237
|
+
#### 校验提交信息
|
|
238
|
+
|
|
239
|
+
```shell
|
|
240
|
+
varlet-cli commit-lint
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
#### 生成更新日志
|
|
244
|
+
|
|
245
|
+
```shell
|
|
246
|
+
varlet-cli changelog
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### 发布组件库
|
|
250
|
+
|
|
251
|
+
```shell
|
|
252
|
+
varlet-cli release
|
|
253
|
+
```
|
|
254
|
+
|
|
236
255
|
#### 快速创建一个组件文件夹
|
|
237
256
|
|
|
238
257
|
```shell
|
|
@@ -277,18 +296,12 @@ module.exports = {
|
|
|
277
296
|
|
|
278
297
|
#### git-hook
|
|
279
298
|
|
|
280
|
-
`husky`,`lint-staged`配合`eslint`,`stylelint`,`
|
|
299
|
+
`husky`,`lint-staged`配合`eslint`,`stylelint`,`varlet-cli commit-lint`做commit前的检查,`package.json`配置如下
|
|
281
300
|
|
|
282
301
|
```json
|
|
283
302
|
{
|
|
284
303
|
"scripts": {
|
|
285
|
-
"prepare": "husky install"
|
|
286
|
-
"commit": "git-cz"
|
|
287
|
-
},
|
|
288
|
-
"config": {
|
|
289
|
-
"commitizen": {
|
|
290
|
-
"path": "cz-conventional-changelog"
|
|
291
|
-
}
|
|
304
|
+
"prepare": "husky install"
|
|
292
305
|
},
|
|
293
306
|
"lint-staged": {
|
|
294
307
|
"*.{ts,tsx,js,vue,less}": "prettier --write",
|
|
@@ -325,15 +338,6 @@ module.exports = {
|
|
|
325
338
|
}
|
|
326
339
|
```
|
|
327
340
|
|
|
328
|
-
创建`commitlint.config.js`
|
|
329
|
-
|
|
330
|
-
```js
|
|
331
|
-
// commitlint.config.js
|
|
332
|
-
module.exports = {
|
|
333
|
-
extends: ['@commitlint/config-conventional'],
|
|
334
|
-
}
|
|
335
|
-
```
|
|
336
|
-
|
|
337
341
|
创建`.prettierignore`
|
|
338
342
|
|
|
339
343
|
```text
|
|
@@ -367,35 +371,13 @@ src/*/__tests__/**
|
|
|
367
371
|
}
|
|
368
372
|
```
|
|
369
373
|
|
|
370
|
-
|
|
374
|
+
#### 发布前注意
|
|
371
375
|
|
|
372
|
-
|
|
376
|
+
- 1.npm的仓库源必须指向npm官方镜像
|
|
377
|
+
- 2.执行npm login进行登录
|
|
373
378
|
|
|
374
|
-
|
|
375
|
-
{
|
|
376
|
-
"scripts": {
|
|
377
|
-
"genlog": "conventional-changelog -p angular -i CHANGELOG.md -s",
|
|
378
|
-
"genAllLog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
|
379
|
-
"release": "yarn compile && release-it"
|
|
380
|
-
},
|
|
381
|
-
"release-it": {
|
|
382
|
-
"git": {
|
|
383
|
-
"changelog": "git log --pretty=format:\"* %s (%h)\" ${from}...${to}",
|
|
384
|
-
"tagName": "v${version}",
|
|
385
|
-
"commitMessage": "chore: release ${version}",
|
|
386
|
-
"requireCleanWorkingDir": false
|
|
387
|
-
},
|
|
388
|
-
"plugins": {
|
|
389
|
-
"@release-it/conventional-changelog": {
|
|
390
|
-
"preset": "angular",
|
|
391
|
-
"infile": "CHANGELOG.md"
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
#### 发布前注意
|
|
379
|
+
### Contributors
|
|
399
380
|
|
|
400
|
-
|
|
401
|
-
|
|
381
|
+
<a href="https://github.com/haoziqaq/varlet/graphs/contributors">
|
|
382
|
+
<img src="https://contrib.rocks/image?repo=haoziqaq/varlet" />
|
|
383
|
+
</a>
|
|
@@ -17,16 +17,15 @@
|
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"scripts": {
|
|
19
19
|
"husky": "husky install",
|
|
20
|
-
"
|
|
20
|
+
"preinstall": "npx only-allow pnpm",
|
|
21
21
|
"dev": "varlet-cli dev",
|
|
22
22
|
"build": "varlet-cli build",
|
|
23
23
|
"preview": "varlet-cli preview",
|
|
24
24
|
"compile": "varlet-cli compile",
|
|
25
25
|
"create": "varlet-cli create",
|
|
26
26
|
"lint": "varlet-cli lint",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"release": "yarn compile && release-it",
|
|
27
|
+
"changelog": "varlet-cli changelog",
|
|
28
|
+
"release": "pnpm compile && varlet-cli release",
|
|
30
29
|
"test": "varlet-cli jest",
|
|
31
30
|
"test:watch": "varlet-cli jest -w",
|
|
32
31
|
"test:watchAll": "varlet-cli jest -wa"
|
|
@@ -35,27 +34,21 @@
|
|
|
35
34
|
"vue": "^3.2.0"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
|
-
"@varlet/cli": "
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
"config": {
|
|
56
|
-
"commitizen": {
|
|
57
|
-
"path": "cz-conventional-changelog"
|
|
58
|
-
}
|
|
37
|
+
"@varlet/cli": "workspace:*",
|
|
38
|
+
"@varlet/touch-emulator": "workspace:*",
|
|
39
|
+
"@varlet/icons": "workspace:*",
|
|
40
|
+
"@varlet/eslint-config": "workspace:*",
|
|
41
|
+
"@varlet/stylelint-config": "workspace:*",
|
|
42
|
+
"@vue/test-utils": "2.0.0-rc.6",
|
|
43
|
+
"vue-router": "4.0.12",
|
|
44
|
+
"vue": "3.2.16",
|
|
45
|
+
"live-server": "^1.2.1",
|
|
46
|
+
"prettier": "^2.3.2",
|
|
47
|
+
"stylelint": "^13.13.1",
|
|
48
|
+
"eslint": "^7.30.0",
|
|
49
|
+
"lint-staged": "^10.5.0",
|
|
50
|
+
"lodash-es": "^4.17.21",
|
|
51
|
+
"clipboard": "^2.0.6"
|
|
59
52
|
},
|
|
60
53
|
"lint-staged": {
|
|
61
54
|
"*.{ts,tsx,js,vue,less}": "prettier --write",
|
|
@@ -94,5 +87,6 @@
|
|
|
94
87
|
"browserslist": [
|
|
95
88
|
"Chrome >= 51",
|
|
96
89
|
"iOS >= 10"
|
|
97
|
-
]
|
|
90
|
+
],
|
|
91
|
+
"packageManager": "pnpm@6.24.3"
|
|
98
92
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.changelog = void 0;
|
|
7
|
+
var ora_1 = __importDefault(require("ora"));
|
|
8
|
+
var conventional_changelog_1 = __importDefault(require("conventional-changelog"));
|
|
9
|
+
var fs_extra_1 = require("fs-extra");
|
|
10
|
+
var path_1 = require("path");
|
|
11
|
+
var constant_1 = require("../shared/constant");
|
|
12
|
+
function changelog(_a) {
|
|
13
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.releaseCount, releaseCount = _c === void 0 ? 0 : _c, _d = _b.file, file = _d === void 0 ? 'CHANGELOG.md' : _d;
|
|
14
|
+
var s = (0, ora_1.default)().start("Generating changelog");
|
|
15
|
+
return new Promise(function (resolve) {
|
|
16
|
+
(0, conventional_changelog_1.default)({
|
|
17
|
+
preset: 'angular',
|
|
18
|
+
releaseCount: releaseCount,
|
|
19
|
+
})
|
|
20
|
+
.pipe((0, fs_extra_1.createWriteStream)((0, path_1.resolve)(constant_1.CWD, file)))
|
|
21
|
+
.on('close', function () {
|
|
22
|
+
s.succeed("Changelog generated success!");
|
|
23
|
+
resolve();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.changelog = changelog;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function commitLint(gitParams: string): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.commitLint = void 0;
|
|
7
|
+
var logger_1 = __importDefault(require("../shared/logger"));
|
|
8
|
+
var semver_1 = __importDefault(require("semver"));
|
|
9
|
+
function isVersion(message) {
|
|
10
|
+
return message.startsWith('v') && semver_1.default.valid(message.slice(1));
|
|
11
|
+
}
|
|
12
|
+
function commitLint(gitParams) {
|
|
13
|
+
var message = require('fs').readFileSync(gitParams, 'utf-8').trim();
|
|
14
|
+
var COMMIT_MESSAGE_RE = /^(revert|fix|feat|docs|perf|test|types|style|build|chore|release|refactor)(\(.+\))?: (.|\n)+/;
|
|
15
|
+
if (!isVersion(message) && !COMMIT_MESSAGE_RE.test(message)) {
|
|
16
|
+
logger_1.default.error("Commit message invalid");
|
|
17
|
+
logger_1.default.warning("The rules for commit messages are as follows\n\nExample:\n\nfeat: added a new feature\nfeat(ui/button): added a new feature in the ui/button scope\n\nfix: fixed a bug\nfix(ui/button): fixed a bug in the ui/button scope\n\ndocs: fixed an error in the documentation\ndocs(ui/button): fixed a documentation error in the ui/button scope\n\nAllowed types:\n- fix\n- feat\n- docs\n- perf\n- test\n- types\n- style\n- build\n- chore\n- release\n- refactor\n\nCommit message reference: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y\n\u53C2\u8003\u962E\u4E00\u5CF0Commit message\u7F16\u5199\u6307\u5357: https://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html");
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.commitLint = commitLint;
|
package/lib/commands/compile.js
CHANGED
|
@@ -57,18 +57,18 @@ function runTask(taskName, task) {
|
|
|
57
57
|
return __generator(this, function (_a) {
|
|
58
58
|
switch (_a.label) {
|
|
59
59
|
case 0:
|
|
60
|
-
s = (0, ora_1.default)().start("Compiling "
|
|
60
|
+
s = (0, ora_1.default)().start("Compiling ".concat(taskName));
|
|
61
61
|
_a.label = 1;
|
|
62
62
|
case 1:
|
|
63
63
|
_a.trys.push([1, 3, , 4]);
|
|
64
64
|
return [4 /*yield*/, task()];
|
|
65
65
|
case 2:
|
|
66
66
|
_a.sent();
|
|
67
|
-
s.succeed("Compilation "
|
|
67
|
+
s.succeed("Compilation ".concat(taskName, " completed!"));
|
|
68
68
|
return [3 /*break*/, 4];
|
|
69
69
|
case 3:
|
|
70
70
|
e_1 = _a.sent();
|
|
71
|
-
s.fail("Compilation "
|
|
71
|
+
s.fail("Compilation ".concat(taskName, " failed!"));
|
|
72
72
|
logger_1.default.error(e_1.toString());
|
|
73
73
|
return [3 /*break*/, 4];
|
|
74
74
|
case 4: return [2 /*return*/];
|
package/lib/commands/create.js
CHANGED
|
@@ -47,19 +47,18 @@ var path_1 = require("path");
|
|
|
47
47
|
var constant_1 = require("../shared/constant");
|
|
48
48
|
var varlet_config_1 = require("../config/varlet.config");
|
|
49
49
|
var lodash_1 = require("lodash");
|
|
50
|
-
var varletConfig = (0, varlet_config_1.getVarletConfig)();
|
|
51
50
|
function create(name) {
|
|
52
51
|
return __awaiter(this, void 0, void 0, function () {
|
|
53
52
|
var namespace, bigCamelizeName, vueTemplate, indexTemplate, testsTemplate, exampleTemplate, localeIndexTemplate, localTemplate, componentDir, testsDir, exampleDir, exampleLocalDir, docsDir;
|
|
54
53
|
return __generator(this, function (_a) {
|
|
55
54
|
switch (_a.label) {
|
|
56
55
|
case 0:
|
|
57
|
-
namespace = (0, lodash_1.get)(
|
|
56
|
+
namespace = (0, lodash_1.get)((0, varlet_config_1.getVarletConfig)(), 'namespace');
|
|
58
57
|
bigCamelizeName = (0, fsUtils_1.bigCamelize)(name);
|
|
59
|
-
vueTemplate = "<template>\n <div class=\""
|
|
60
|
-
indexTemplate = "import "
|
|
61
|
-
testsTemplate = "import example from '../example'\nimport "
|
|
62
|
-
exampleTemplate = "<template>\n <app-type></app-type>\n <"
|
|
58
|
+
vueTemplate = "<template>\n <div class=\"".concat(namespace, "-").concat(name, "\"></div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from 'vue'\n\nexport default defineComponent({\n name: '").concat((0, fsUtils_1.bigCamelize)(namespace)).concat(bigCamelizeName, "'\n})\n</script>\n\n<style lang=\"less\">\n.").concat(namespace, "-").concat(name, " {\n display: flex;\n}\n</style>\n");
|
|
59
|
+
indexTemplate = "import ".concat(bigCamelizeName, " from './").concat(bigCamelizeName, ".vue'\nimport type { App } from 'vue'\n\n").concat(bigCamelizeName, ".install = function(app: App) {\n app.component(").concat(bigCamelizeName, ".name, ").concat(bigCamelizeName, ")\n}\n\nexport const _").concat(bigCamelizeName, "Component = ").concat(bigCamelizeName, "\n\nexport default ").concat(bigCamelizeName, "\n");
|
|
60
|
+
testsTemplate = "import example from '../example'\nimport ".concat(bigCamelizeName, " from '..'\nimport { createApp } from 'vue'\nimport { mount } from '@vue/test-utils'\n\ntest('test ").concat(name, " example', () => {\n const wrapper = mount(example)\n expect(wrapper.html()).toMatchSnapshot()\n})\n\ntest('test ").concat(name, " plugin', () => {\n const app = createApp({}).use(").concat(bigCamelizeName, ")\n expect(app.component(").concat(bigCamelizeName, ".name)).toBeTruthy()\n})\n");
|
|
61
|
+
exampleTemplate = "<template>\n <app-type></app-type>\n <".concat(namespace, "-").concat(name, "/>\n</template>\n\n<script>\nimport ").concat(bigCamelizeName, " from '..'\nimport AppType from '@varlet/cli/site/mobile/components/AppType'\nimport { watchLang } from '@varlet/cli/site/utils'\nimport { use, pack } from './locale'\n\nexport default {\n name: '").concat(bigCamelizeName, "Example',\n components: {\n [").concat(bigCamelizeName, ".name]: ").concat(bigCamelizeName, ",\n AppType\n },\n setup() {\n\n watchLang(use)\n\n return {\n pack\n }\n }\n}\n</script>\n");
|
|
63
62
|
localeIndexTemplate = "// lib\nimport _zhCN from '../../../locale/zh-CN'\nimport _enCN from '../../../locale/en-US'\n// mobile example doc\nimport zhCN from './zh-CN'\nimport enUS from './en-US'\nimport { useLocale, add as _add, use as _use } from '../../../locale'\n\nconst { add, use: exampleUse, pack, packs, merge } = useLocale()\n\nconst use = (lang: string) => {\n _use(lang)\n exampleUse(lang)\n}\n\nexport { add, pack, packs, merge, use }\n\n// lib\n_add('zh-CN', _zhCN)\n_add('en-US', _enCN)\n// mobile example doc\nadd('zh-CN', zhCN as any)\nadd('en-US', enUS as any)\n";
|
|
64
63
|
localTemplate = "export default {\n\n}\n";
|
|
65
64
|
componentDir = (0, path_1.resolve)(constant_1.SRC_DIR, name);
|
|
@@ -72,7 +71,7 @@ function create(name) {
|
|
|
72
71
|
return [2 /*return*/];
|
|
73
72
|
}
|
|
74
73
|
return [4 /*yield*/, Promise.all([
|
|
75
|
-
(0, fs_extra_1.outputFile)((0, path_1.resolve)(componentDir, bigCamelizeName
|
|
74
|
+
(0, fs_extra_1.outputFile)((0, path_1.resolve)(componentDir, "".concat(bigCamelizeName, ".vue")), vueTemplate),
|
|
76
75
|
(0, fs_extra_1.outputFile)((0, path_1.resolve)(componentDir, 'index.ts'), indexTemplate),
|
|
77
76
|
(0, fs_extra_1.outputFile)((0, path_1.resolve)(testsDir, 'index.spec.js'), testsTemplate),
|
|
78
77
|
(0, fs_extra_1.outputFile)((0, path_1.resolve)(exampleDir, 'index.vue'), exampleTemplate),
|
|
@@ -84,14 +83,14 @@ function create(name) {
|
|
|
84
83
|
])];
|
|
85
84
|
case 1:
|
|
86
85
|
_a.sent();
|
|
87
|
-
logger_1.default.success("Create "
|
|
86
|
+
logger_1.default.success("Create ".concat(name, " success!"));
|
|
88
87
|
logger_1.default.success("----------------------------");
|
|
89
|
-
logger_1.default.success(name
|
|
88
|
+
logger_1.default.success("".concat(name, "/"));
|
|
90
89
|
logger_1.default.success("|- __tests__/ # Unit test folder");
|
|
91
90
|
logger_1.default.success("|- docs/ # Internationalized document folder");
|
|
92
91
|
logger_1.default.success("|- example/ # Mobile phone example code");
|
|
93
92
|
logger_1.default.success("|- example/locale # Example locale");
|
|
94
|
-
logger_1.default.success("|- "
|
|
93
|
+
logger_1.default.success("|- ".concat(bigCamelizeName, ".vue # Sfc component, You can also use jsx or tsx"));
|
|
95
94
|
logger_1.default.success("|- index.ts # Component entry, the folder where the file exists will be exposed to the user");
|
|
96
95
|
return [2 /*return*/];
|
|
97
96
|
}
|
package/lib/commands/dev.js
CHANGED
|
@@ -58,7 +58,7 @@ function startServer(force) {
|
|
|
58
58
|
switch (_c.label) {
|
|
59
59
|
case 0:
|
|
60
60
|
isRestart = Boolean(server);
|
|
61
|
-
logger_1.default.info((isRestart ? 'Res' : 'S'
|
|
61
|
+
logger_1.default.info("".concat(isRestart ? 'Res' : 'S', "tarting server..."));
|
|
62
62
|
// close all instance
|
|
63
63
|
_a = server;
|
|
64
64
|
if (!_a)
|
|
@@ -99,7 +99,7 @@ function startServer(force) {
|
|
|
99
99
|
watcher = chokidar_1.default.watch(constant_1.VARLET_CONFIG);
|
|
100
100
|
watcher.on('change', function () { return startServer(force); });
|
|
101
101
|
}
|
|
102
|
-
logger_1.default.success("\n"
|
|
102
|
+
logger_1.default.success("\n".concat(isRestart ? 'Res' : 'S', "tart successfully!!!"));
|
|
103
103
|
return [2 /*return*/];
|
|
104
104
|
}
|
|
105
105
|
});
|
package/lib/commands/gen.js
CHANGED
|
@@ -53,8 +53,12 @@ function syncVersion(name) {
|
|
|
53
53
|
var file = (0, path_1.resolve)(constant_1.CWD, name, 'package.json');
|
|
54
54
|
var pkg = JSON.parse((0, fs_extra_1.readFileSync)(file, 'utf-8'));
|
|
55
55
|
var cliPkg = JSON.parse((0, fs_extra_1.readFileSync)(constant_1.CLI_PACKAGE_JSON, 'utf-8'));
|
|
56
|
-
pkg.devDependencies
|
|
57
|
-
|
|
56
|
+
Object.keys(pkg.devDependencies).forEach(function (key) {
|
|
57
|
+
if (key.startsWith('@varlet')) {
|
|
58
|
+
pkg.devDependencies[key] = "^".concat(cliPkg.version);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
pkg.files = ['es', 'lib', 'umd', 'highlight', 'types'];
|
|
58
62
|
(0, fs_extra_1.writeFileSync)(file, JSON.stringify(pkg, null, 2));
|
|
59
63
|
}
|
|
60
64
|
function gen(name) {
|
|
@@ -65,7 +69,7 @@ function gen(name) {
|
|
|
65
69
|
case 0:
|
|
66
70
|
dest = (0, path_1.resolve)(constant_1.CWD, name);
|
|
67
71
|
if ((0, fs_extra_1.pathExistsSync)(dest)) {
|
|
68
|
-
logger_1.default.warning(name
|
|
72
|
+
logger_1.default.warning("".concat(name, " already exists and cannot be recreated..."));
|
|
69
73
|
return [2 /*return*/];
|
|
70
74
|
}
|
|
71
75
|
return [4 /*yield*/, inquirer_1.default.prompt([
|
|
@@ -89,7 +93,7 @@ function gen(name) {
|
|
|
89
93
|
removeFiles(dest);
|
|
90
94
|
syncVersion(name);
|
|
91
95
|
logger_1.default.success('Application generated successfully!');
|
|
92
|
-
logger_1.default.info(" cd "
|
|
96
|
+
logger_1.default.info(" cd ".concat(name, "\n yarn\n yarn dev"));
|
|
93
97
|
logger_1.default.success("=======================\n Good luck have fun\n======================= ");
|
|
94
98
|
return [2 /*return*/];
|
|
95
99
|
}
|
package/lib/commands/jest.js
CHANGED
|
@@ -56,7 +56,7 @@ function jest(cmd) {
|
|
|
56
56
|
watchAll: cmd.watchAll,
|
|
57
57
|
clearCache: cmd.clearCache,
|
|
58
58
|
config: constant_1.JEST_CONFIG,
|
|
59
|
-
testRegex: cmd.component && cmd.component
|
|
59
|
+
testRegex: cmd.component && "".concat(cmd.component, "/__tests__/.*.spec.[jt]s?$"),
|
|
60
60
|
};
|
|
61
61
|
_a.label = 1;
|
|
62
62
|
case 1:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function release(): Promise<void>;
|