@varlet/cli 1.24.2-alpha.1640872052259 → 1.24.3-alpha.1640877804572

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 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 `yarn` as a package management tool. First, make sure that `yarn` is installed and added to the system environment variables.
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
- yarn global add @varlet/cli
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
- yarn
30
- yarn dev
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`, `commitlint` to check before commit,
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
- ### Release code
379
+ #### Note before release
377
380
 
378
- Use `release-it` and `conventional-changelog` for code release and update log generation.
379
- The configuration of `package.json` is as follows
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
- ```json
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
- - 1.The registry of npm and yarn must set to the official npm mirror
408
- - 2.Both npm and yarn must execute the login command for user login
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
- 帮助用户直接进入组件本身的开发,这里推荐使用`yarn`作为包管理工具,首先确保安装了`yarn`并且添加到系统环境变量中去,这里不展开介绍`yarn`的安装和配置方法。
21
+ 帮助用户直接进入组件本身的开发,推荐使用`pnpm`作为包管理工具。
21
22
 
22
23
  ```shell
23
24
  # 安装命令行工具
24
- yarn global add @varlet/cli
25
+ pnpm add @varlet/cli -g
25
26
  # 使用gen命令生成项目
26
27
  varlet-cli gen 项目名
27
28
  cd 项目名
28
- yarn
29
- yarn dev
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`,`commitlint`做commit前的检查,`package.json`配置如下
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
- 使用`release-it`和`conventional-changelog`进行代码发布和更新日志的生成,`package.json`配置如下
376
+ - 1.npm的仓库源必须指向npm官方镜像
377
+ - 2.执行npm login进行登录
373
378
 
374
- ```json
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
- - 1.npm和yarn的仓库源必须指向npm官方镜像
401
- - 2.npm和yarn都必须执行login命令进行用户登录
381
+ <a href="https://github.com/haoziqaq/varlet/graphs/contributors">
382
+ <img src="https://contrib.rocks/image?repo=haoziqaq/varlet" />
383
+ </a>
@@ -1,4 +1,4 @@
1
1
  #!/bin/sh
2
2
  . "$(dirname "$0")/_/husky.sh"
3
3
 
4
- npx --no-install commitlint --edit $1
4
+ npx --no-install varlet-cli commit-lint $1
@@ -8,8 +8,8 @@
8
8
  ### Quickstart
9
9
 
10
10
  ```shell
11
- yarn
12
- yarn dev
11
+ pnpm install
12
+ pnpm dev
13
13
  ```
14
14
 
15
15
  ### Commands
@@ -17,72 +17,66 @@ yarn dev
17
17
  #### Start the development server
18
18
 
19
19
  ```shell
20
- yarn dev
20
+ pnpm dev
21
21
  ```
22
22
 
23
23
  #### Build documentation site
24
24
 
25
25
  ```shell
26
- yarn build
26
+ pnpm build
27
27
  ```
28
28
 
29
29
  #### Building component libraries
30
30
 
31
31
  ```shell
32
- yarn compile
32
+ pnpm compile
33
33
  ```
34
34
 
35
35
  #### Lint code
36
36
 
37
37
  ```shell
38
- yarn lint
38
+ pnpm lint
39
39
  ```
40
40
 
41
41
  #### Run unit test
42
42
 
43
43
  ```shell
44
- yarn test
44
+ pnpm test
45
45
  ```
46
46
 
47
47
  #### Run unit test in watch mode
48
48
 
49
49
  ```shell
50
- yarn test:watch
50
+ pnpm test:watch
51
51
  or
52
- yarn test:watchAll
52
+ pnpm test:watchAll
53
53
  ```
54
54
 
55
55
  #### Quickly create a component folder
56
56
 
57
57
  ```shell
58
- yarn run create <componentName>
58
+ pnpm run create <componentName>
59
59
  ```
60
60
 
61
61
  #### Mount git hook
62
62
 
63
63
  ```shell
64
- yarn husky
64
+ pnpm husky
65
65
  ```
66
66
 
67
67
  #### Generate changelog
68
68
 
69
69
  ```shell
70
- yarn genlog
70
+ pnpm changelog
71
71
  ```
72
72
 
73
- #### Generate all changelog
74
-
75
- ```shell
76
- yarn genAllLog
77
- ```
78
-
79
- #### Publish
73
+ #### Release
80
74
 
81
75
  tips:
82
- - 1.The registry of npm and yarn must be the official source of npm
83
- - 2.Both npm and yarn must be logged in
76
+ - 1.The registry of npm must be the official source of npm
77
+ - 2.The npm must be logged in
84
78
 
85
79
  ```shell
86
- yarn release
80
+ pnpm release
87
81
  ```
88
82
 
@@ -17,16 +17,15 @@
17
17
  "license": "MIT",
18
18
  "scripts": {
19
19
  "husky": "husky install",
20
- "commit": "git-cz",
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
- "genlog": "conventional-changelog -p angular -i CHANGELOG.md -s",
28
- "genAllLog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
29
- "release": "pnpm 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"
@@ -36,26 +35,21 @@
36
35
  },
37
36
  "devDependencies": {
38
37
  "@varlet/cli": "workspace:*",
39
- "vue": "3.2.16"
40
- },
41
- "release-it": {
42
- "git": {
43
- "changelog": "git log --pretty=format:\"* %s (%h)\" ${from}...${to}",
44
- "tagName": "v${version}",
45
- "commitMessage": "chore: release ${version}",
46
- "requireCleanWorkingDir": false
47
- },
48
- "plugins": {
49
- "@release-it/conventional-changelog": {
50
- "preset": "angular",
51
- "infile": "CHANGELOG.md"
52
- }
53
- }
54
- },
55
- "config": {
56
- "commitizen": {
57
- "path": "cz-conventional-changelog"
58
- }
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
+ "typescript": "^4.4.4",
44
+ "vue-router": "4.0.12",
45
+ "vue": "3.2.16",
46
+ "live-server": "^1.2.1",
47
+ "prettier": "^2.3.2",
48
+ "stylelint": "^13.13.1",
49
+ "eslint": "^7.30.0",
50
+ "lint-staged": "^10.5.0",
51
+ "lodash-es": "^4.17.21",
52
+ "clipboard": "^2.0.6"
59
53
  },
60
54
  "lint-staged": {
61
55
  "*.{ts,tsx,js,vue,less}": "prettier --write",
@@ -88,11 +82,13 @@
88
82
  "site/**",
89
83
  "coverage/**",
90
84
  "public/**",
91
- "highlight/**"
85
+ "highlight/**",
86
+ ".varlet/**"
92
87
  ]
93
88
  },
94
89
  "browserslist": [
95
90
  "Chrome >= 51",
96
91
  "iOS >= 10"
97
- ]
92
+ ],
93
+ "packageManager": "pnpm@6.24.3"
98
94
  }
@@ -47,14 +47,13 @@ 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)(varletConfig, 'namespace');
56
+ namespace = (0, lodash_1.get)((0, varlet_config_1.getVarletConfig)(), 'namespace');
58
57
  bigCamelizeName = (0, fsUtils_1.bigCamelize)(name);
59
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");
60
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");
@@ -49,12 +49,19 @@ function removeFiles(dest) {
49
49
  var files = ['es', 'lib', 'umd', 'highlight', 'types/index.d.ts', '.varlet', 'node_modules'];
50
50
  files.forEach(function (filename) { return (0, fs_extra_1.removeSync)((0, path_1.resolve)(dest, filename)); });
51
51
  }
52
+ function generateGitIgnore(name) {
53
+ (0, fs_extra_1.writeFileSync)((0, path_1.resolve)(constant_1.CWD, name, '.gitignore'), "node_modules\n\n.varlet\n.idea\n.vscode\n*.log\n.DS_Store\n\nsite\nlib\nes\numd\ncoverage\nhighlight");
54
+ }
52
55
  function syncVersion(name) {
53
56
  var file = (0, path_1.resolve)(constant_1.CWD, name, 'package.json');
54
57
  var pkg = JSON.parse((0, fs_extra_1.readFileSync)(file, 'utf-8'));
55
58
  var cliPkg = JSON.parse((0, fs_extra_1.readFileSync)(constant_1.CLI_PACKAGE_JSON, 'utf-8'));
56
- pkg.devDependencies['@varlet/cli'] = "^".concat(cliPkg.version);
57
- pkg.files = ['es', 'lib', 'umd', 'highlight', 'types', 'README.md'];
59
+ Object.keys(pkg.devDependencies).forEach(function (key) {
60
+ if (key.startsWith('@varlet')) {
61
+ pkg.devDependencies[key] = "^".concat(cliPkg.version);
62
+ }
63
+ });
64
+ pkg.files = ['es', 'lib', 'umd', 'highlight', 'types'];
58
65
  (0, fs_extra_1.writeFileSync)(file, JSON.stringify(pkg, null, 2));
59
66
  }
60
67
  function gen(name) {
@@ -88,6 +95,7 @@ function gen(name) {
88
95
  _a.sent();
89
96
  removeFiles(dest);
90
97
  syncVersion(name);
98
+ generateGitIgnore(name);
91
99
  logger_1.default.success('Application generated successfully!');
92
100
  logger_1.default.info(" cd ".concat(name, "\n yarn\n yarn dev"));
93
101
  logger_1.default.success("=======================\n Good luck have fun\n======================= ");
@@ -83,7 +83,7 @@ function publish(preRelease) {
83
83
  });
84
84
  });
85
85
  }
86
- function pushGit(version, message) {
86
+ function pushGit(version) {
87
87
  return __awaiter(this, void 0, void 0, function () {
88
88
  var s, ret;
89
89
  return __generator(this, function (_a) {
@@ -93,10 +93,10 @@ function pushGit(version, message) {
93
93
  return [4 /*yield*/, (0, execa_1.default)('git', ['add', '.'])];
94
94
  case 1:
95
95
  _a.sent();
96
- return [4 /*yield*/, (0, execa_1.default)('git', ['commit', '-m', message])];
96
+ return [4 /*yield*/, (0, execa_1.default)('git', ['commit', '-m', "v".concat(version)])];
97
97
  case 2:
98
98
  _a.sent();
99
- return [4 /*yield*/, (0, execa_1.default)('git', ['tag', version])];
99
+ return [4 /*yield*/, (0, execa_1.default)('git', ['tag', "v".concat(version)])];
100
100
  case 3:
101
101
  _a.sent();
102
102
  return [4 /*yield*/, (0, execa_1.default)('git', ['push'])];
@@ -172,7 +172,7 @@ function release() {
172
172
  return [4 /*yield*/, (0, changelog_1.changelog)()];
173
173
  case 4:
174
174
  _a.sent();
175
- return [4 /*yield*/, pushGit(expectVersion, "v".concat(expectVersion))];
175
+ return [4 /*yield*/, pushGit(expectVersion)];
176
176
  case 5:
177
177
  _a.sent();
178
178
  _a.label = 6;
@@ -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();
@@ -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,13 +83,13 @@ 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) {
86
+ function compileTags(table, tags, componentName, varletConfig) {
88
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
94
  var attrNamespace = "".concat((0, lodash_1.get)(varletConfig, 'namespace'), "-").concat(componentName, "/").concat((0, exports.replaceDot)(row[0]));
96
95
  attributes[attrNamespace] = {
@@ -100,7 +99,7 @@ function compileAttributes(table, attributes, componentName) {
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]),
@@ -127,7 +126,7 @@ function compileWebTypes(table, webTypes, componentName) {
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)),
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "1.24.2-alpha.1640872052259",
3
+ "version": "1.24.3-alpha.1640877804572",
4
4
  "description": "cli of varlet",
5
5
  "bin": {
6
6
  "varlet-cli": "./lib/index.js"
@@ -29,9 +29,9 @@
29
29
  },
30
30
  "gitHead": "ee9c3866bedad96c86365b0f9888a3a6bb781b1f",
31
31
  "dependencies": {
32
- "@varlet/icons": "1.24.2-alpha.1640872052259",
33
- "@varlet/markdown-vite-plugin": "1.24.2-alpha.1640872052259",
34
- "@varlet/touch-emulator": "1.24.2-alpha.1640872052259",
32
+ "@varlet/icons": "1.24.3-alpha.1640877804572",
33
+ "@varlet/markdown-vite-plugin": "1.24.3-alpha.1640877804572",
34
+ "@varlet/touch-emulator": "1.24.3-alpha.1640877804572",
35
35
  "@babel/core": "^7.14.8",
36
36
  "@babel/preset-env": "^7.14.8",
37
37
  "@babel/preset-typescript": "^7.14.5",
@@ -73,7 +73,7 @@
73
73
  "@types/lodash-es": "^4.17.5"
74
74
  },
75
75
  "peerDependencies": {
76
- "@varlet/touch-emulator": "1.24.2-alpha.1640872052259",
76
+ "@varlet/touch-emulator": "1.24.3-alpha.1640877804572",
77
77
  "@vue/test-utils": "^2.0.0-rc.6",
78
78
  "vue": "3.2.16",
79
79
  "vue-router": "4.0.12",
@@ -84,5 +84,6 @@
84
84
  "scripts": {
85
85
  "dev": "tsc --watch",
86
86
  "build": "tsc"
87
- }
87
+ },
88
+ "readme": "# @varlet/cli\n\n开箱即用的`Vue3组件库`快速成型工具,提供了一系列命令和工具去解决组件库开发上的问题\n\n### 特性\n\n- 1.开箱即用的组件库开发环境\n- 2.开箱即用的组件库编译工具,支持导出`esm`和`umd`两种模块代码\n- 3.基于配置文件的组件库文档站点,支持百度统计和主题定制\n- 4.支持`单文件组件(sfc)`和`tsx,jsx`两种风格的组件库编写风格\n- 5.开箱即用的代码检查工具\n- 6.开箱即用的单元测试工具\n- 7.开箱即用的代码发布工具,发布到npm和github,并自动生成更新日志\n- 8.支持`Typescript`\n- 9.支持`暗黑模式`\n- 10.基于`pnpm`\n\n### 快速开始\n\n`@varlet/cli`内置了`单文件组件(sfc)`和`tsx, jsx`两种风格的组件库项目模板,可以通过`gen`命令直接生成。\n帮助用户直接进入组件本身的开发,推荐使用`pnpm`作为包管理工具。\n\n```shell\n# 安装命令行工具\npnpm add @varlet/cli -g\n# 使用gen命令生成项目\nvarlet-cli gen 项目名\ncd 项目名\npnpm install\npnpm dev\n```\n\n然后通过简单修改一些组件库模板的基础信息,就可以开始组件库的开发了\n\n## 高级定制\n\n### 配置文件\n\n项目根目录下的`varlet.config.js`用来管理整个组件库项目的具体细节\n\n| 参数 | 说明 | 类型 | 默认值 |\n| ----- | -------------- | -------- | ---------- |\n| `host` | 开发服务器主机 | _number_ | `localhost` |\n| `port` | 开发服务器端口 | _number_ | `8080` |\n| `name` | 组件库全名\t| _string_ | `Varlet` |\n| `namespace` | 组件库命名空间, 会作为组件前缀 | _string_ | `var` |\n| `title` | 文档中组件库的标题 | _string_ | `VARLET` |\n| `logo` | 文档中组件库的logo | _string_ | `-` |\n| `defaultLanguage` | 文档默认语言 | _string_ | `zh-CN` |\n| `useMobile` | 是否显示右侧手机预览 | _boolean_ | `false` |\n| `themes` | 文档主题 | _SiteThemes_ | `-` |\n| `darkThemes` | 暗黑模式文档主题 | _SiteThemes_ | `-` |\n| `highlight` | 文档代码片段样式相关 | _SiteHighlight_ | `-` |\n| `analysis` | 文档统计相关 | _SiteAnalysis_ | `-` |\n| `pc` | pc端文档结构配置 | _SitePC_ | `-` |\n| `mobile` | mobile端文档结构配置 | _SiteMobile_ | `-` |\n| `moduleCompatible` | 模块兼容配置 | _Record<string, string>_ | `-` |\n\n#### 模块适配对象\n\n一些外部依赖可能需要进行模块语法的适配,以达到可以正确编译到`commonjs`和`esmodule`的目的,例如`dayjs`的`esmodule`写法是\n\n```js\nimport dayjs from 'dayjs/esm'\n```\n\n而为了构建`commonjs`时的写法是\n\n```js\nimport * as dayjs from 'dayjs'\n```\n\n在项目中我们拥抱`esmodule`模块使用第一种写法,并做如下配置进行适配\n\n```js\n// varlet.config.js\nmodule.exports = {\n moduleCompatible: {\n \"import dayjs from 'dayjs/esm'\\n\": \"import * as dayjs from 'dayjs'\\n\"\n }\n}\n```\n\n#### SiteThemes\n\n主题变量相关,由于默认的主题变量可能时常修改,以`varlet`官方文档的主题为准\n\n| 参数 |\n| ----- |\n| `color-body` |\n| `color-bar` |\n| `color-sub-bar` |\n| `color-text` |\n| `color-sub-text` |\n| `color-border` |\n| `color-shadow` |\n| `color-introduce-border` |\n| `color-primary` |\n| `color-link` |\n| `color-type` |\n| `color-progress` |\n| `color-progress-track` |\n| `color-side-bar` |\n| `color-side-bar-active-background` |\n| `color-app-bar` |\n| `color-nav-button-hover-background` |\n| `color-pc-language-active` |\n| `color-pc-language-active-background` |\n| `color-mobile-cell-hover` |\n| `color-mobile-language-active` |\n| `color-mobile-language-active-background` |\n\n#### SiteHighlight\n\n代码片段高亮,基于[highlight.js](https://highlightjs.org/)\n\n| 参数 | 说明 | 类型 | 默认值 |\n| ----- | -------------- | -------- | ---------- |\n| `style` | highlight的css地址 | _string_ | `-` |\n\n#### SiteAnalysis\n\n统计埋点相关\n\n| 参数 | 说明 | 类型 | 默认值 |\n| ----- | -------------- | -------- | ---------- |\n| `baidu` | 百度统计脚本地址 | _string_ | `-` |\n\n#### SitePC, SiteMobile\n\n文档结构部分相关,示例配置如下\n\n```js\nmodule.exports = {\n pc: {\n redirect: '/home',\n title: {\n 'zh-CN': '一个组件库',\n },\n header: {\n darkMode: null,\n i18n: null,\n github: 'https://github.com/haoziqaq/varlet',\n },\n menu: [\n {\n text: {\n 'zh-CN': '开发指南',\n },\n // 侧边栏菜单目录\n type: 1,\n },\n {\n text: {\n 'zh-CN': '基本介绍',\n },\n doc: 'home',\n // 索引项目根目录下的md文档\n type: 3,\n },\n {\n text: {\n 'zh-CN': '基础组件',\n },\n type: 1,\n },\n {\n text: {\n 'zh-CN': 'Button 按钮',\n },\n doc: 'button',\n // 索引组件根目录下的md文档\n type: 2,\n },\n ],\n },\n mobile: {\n redirect: '/home',\n title: {\n 'zh-CN': '一个组件库',\n },\n header: {\n darkMode: null,\n i18n: null,\n github: 'https://github.com/haoziqaq/varlet',\n },\n },\n}\n```\n\n### 命令相关\n\n#### 启动开发服务器\n\n```shell\nvarlet-cli dev\n```\n\n#### 构建文档站点\n\n```shell\nvarlet-cli build\n```\n\n#### 预览文档站点\n\n```shell\nvarlet-cli preview\n```\n\n#### 构建组件库代码\n\n```shell\nvarlet-cli compile\n```\n\n#### 执行所有的单元测试\n\n```shell\nvarlet-cli test\n```\n\n#### 以watch模式执行单元测试\n\n```shell\nvarlet-cli test -w\nor\nvarlet-cli test -wa\n```\n\n#### 检查代码\n\n```shell\nvarlet-cli lint\n```\n\n#### 校验提交信息\n\n```shell\nvarlet-cli commit-lint\n```\n\n#### 生成更新日志\n\n```shell\nvarlet-cli changelog\n```\n\n#### 发布组件库\n\n```shell\nvarlet-cli release\n```\n\n#### 快速创建一个组件文件夹\n\n```shell\nvarlet-cli create <componentName>\n```\n\n#### 生成一个项目模板\n```shell\nvarlet-cli gen <projectName>\n```\n\n### babel\n\n对`babel`进行配置,首先在`package.json`中指定目标浏览器\n\n```json\n{\n \"browserslist\": [\n \"Chrome >= 51\",\n \"iOS >= 10\"\n ]\n}\n```\n\n创建`babel.config,js`\n\n```js\n// babel.config.js\nmodule.exports = {\n presets: [\n [\n '@varlet/cli/preset',\n {\n loose: process.env.NODE_ENV === 'compile',\n },\n ],\n ],\n}\n```\n\n### git和npm\n\n#### git-hook\n\n`husky`,`lint-staged`配合`eslint`,`stylelint`,`varlet-cli commit-lint`做commit前的检查,`package.json`配置如下\n\n```json\n{\n \"scripts\": {\n \"prepare\": \"husky install\"\n },\n \"lint-staged\": {\n \"*.{ts,tsx,js,vue,less}\": \"prettier --write\",\n \"*.{ts,tsx,js,vue}\": \"eslint --fix\",\n \"*.{vue,css,less}\": \"stylelint --fix\"\n },\n \"eslintConfig\": {\n \"root\": true,\n \"ignorePatterns\": [\n \"es/**\",\n \"umd/**\",\n \"site/**\",\n \"public/**\",\n \"src/*/__tests__/**\",\n \".varlet/**\"\n ],\n \"extends\": [\n \"@varlet\"\n ]\n },\n \"stylelint\": {\n \"extends\": [\n \"@varlet/stylelint-config\"\n ],\n \"ignoreFiles\": [\n \"es/**\",\n \"umd/**\",\n \"site/**\",\n \"coverage/**\",\n \"public/**\",\n \"highlight/**\"\n ]\n }\n}\n```\n\n创建`.prettierignore`\n\n```text\n// .prettierignore\ncoverage/**\nes/**\numd/**\nsite/**\npublic/**\nsrc/*/__tests__/**\n*.md\n```\n\n### typescript\n\n创建`tsconfig.json`\n\n```json\n{\n \"compilerOptions\": {\n \"strict\": true,\n \"downlevelIteration\": true,\n \"declaration\": true,\n \"skipLibCheck\": true,\n \"esModuleInterop\": true,\n \"allowJs\": true,\n \"lib\": [\"esnext\", \"dom\"],\n \"allowSyntheticDefaultImports\": true,\n \"jsx\": \"preserve\"\n }\n}\n```\n\n#### 发布前注意\n\n- 1.npm的仓库源必须指向npm官方镜像\n- 2.执行npm login进行登录\n\n### Contributors\n\n<a href=\"https://github.com/haoziqaq/varlet/graphs/contributors\">\n <img src=\"https://contrib.rocks/image?repo=haoziqaq/varlet\" />\n</a>"
88
89
  }
package/site/index.html CHANGED
@@ -9,6 +9,9 @@
9
9
  <link href="<%= logo %>" rel="icon" type="image/png" />
10
10
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
11
11
  name="viewport" />
12
+ <meta property="og:title" content="<%= pcTitle %>" />
13
+ <meta property="og:type" content="website" />
14
+ <meta property="og:image" content="<%= logo %>" />
12
15
  <style>
13
16
  @font-face {
14
17
  font-family: "Roboto";
package/site/mobile.html CHANGED
@@ -9,6 +9,9 @@
9
9
  <link href="<%= logo %>" rel="icon" type="image/png" />
10
10
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
11
11
  name="viewport" />
12
+ <meta property="og:title" content="<%= mobileTitle %>" />
13
+ <meta property="og:type" content="website" />
14
+ <meta property="og:image" content="<%= logo %>" />
12
15
  <style>
13
16
  @font-face {
14
17
  font-family: "Roboto";
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- extends: ['@commitlint/config-conventional'],
3
- }