@varlet/cli 1.24.2 → 1.24.3-alpha.1640882119459

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.
@@ -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
 
@@ -40,6 +40,7 @@
40
40
  "@varlet/eslint-config": "workspace:*",
41
41
  "@varlet/stylelint-config": "workspace:*",
42
42
  "@vue/test-utils": "2.0.0-rc.6",
43
+ "typescript": "^4.4.4",
43
44
  "vue-router": "4.0.12",
44
45
  "vue": "3.2.16",
45
46
  "live-server": "^1.2.1",
@@ -81,7 +82,8 @@
81
82
  "site/**",
82
83
  "coverage/**",
83
84
  "public/**",
84
- "highlight/**"
85
+ "highlight/**",
86
+ ".varlet/**"
85
87
  ]
86
88
  },
87
89
  "browserslist": [
@@ -49,6 +49,9 @@ 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'));
@@ -92,6 +95,7 @@ function gen(name) {
92
95
  _a.sent();
93
96
  removeFiles(dest);
94
97
  syncVersion(name);
98
+ generateGitIgnore(name);
95
99
  logger_1.default.success('Application generated successfully!');
96
100
  logger_1.default.info(" cd ".concat(name, "\n yarn\n yarn dev"));
97
101
  logger_1.default.success("=======================\n Good luck have fun\n======================= ");
@@ -76,14 +76,19 @@ function publish(preRelease) {
76
76
  return [4 /*yield*/, (0, execa_1.default)('pnpm', args)];
77
77
  case 1:
78
78
  ret = _a.sent();
79
- s.succeed('Publish all packages successfully');
80
- ret.stdout && logger_1.default.info(ret.stdout);
79
+ if (ret.stderr) {
80
+ throw new Error(ret.stderr);
81
+ }
82
+ else {
83
+ ret.stdout && logger_1.default.info(ret.stdout);
84
+ s.succeed('Publish all packages successfully');
85
+ }
81
86
  return [2 /*return*/];
82
87
  }
83
88
  });
84
89
  });
85
90
  }
86
- function pushGit(version, message) {
91
+ function pushGit(version) {
87
92
  return __awaiter(this, void 0, void 0, function () {
88
93
  var s, ret;
89
94
  return __generator(this, function (_a) {
@@ -93,17 +98,22 @@ function pushGit(version, message) {
93
98
  return [4 /*yield*/, (0, execa_1.default)('git', ['add', '.'])];
94
99
  case 1:
95
100
  _a.sent();
96
- return [4 /*yield*/, (0, execa_1.default)('git', ['commit', '-m', message])];
101
+ return [4 /*yield*/, (0, execa_1.default)('git', ['commit', '-m', "v".concat(version)])];
97
102
  case 2:
98
103
  _a.sent();
99
- return [4 /*yield*/, (0, execa_1.default)('git', ['tag', version])];
104
+ return [4 /*yield*/, (0, execa_1.default)('git', ['tag', "v".concat(version)])];
100
105
  case 3:
101
106
  _a.sent();
102
107
  return [4 /*yield*/, (0, execa_1.default)('git', ['push'])];
103
108
  case 4:
104
109
  ret = _a.sent();
105
110
  s.succeed('Push remote repository successfully');
106
- ret.stdout && logger_1.default.info(ret.stdout);
111
+ if (ret.stderr) {
112
+ throw new Error(ret.stderr);
113
+ }
114
+ else {
115
+ ret.stdout && logger_1.default.info(ret.stdout);
116
+ }
107
117
  return [2 /*return*/];
108
118
  }
109
119
  });
@@ -124,11 +134,11 @@ function updateVersion(version) {
124
134
  }
125
135
  function release() {
126
136
  return __awaiter(this, void 0, void 0, function () {
127
- var currentVersion, name_1, ret, type, isPreRelease, expectVersion, confirm_1, packageJsonMaps, error_1;
137
+ var currentVersion, name_1, ret, type, isPreRelease, expectVersion, confirm_1, packageJsonMaps, e_1, error_1;
128
138
  return __generator(this, function (_a) {
129
139
  switch (_a.label) {
130
140
  case 0:
131
- _a.trys.push([0, 10, , 11]);
141
+ _a.trys.push([0, 12, , 13]);
132
142
  currentVersion = require((0, path_1.resolve)(constant_1.CWD, 'package.json')).version;
133
143
  if (!currentVersion) {
134
144
  logger_1.default.error('Your package is missing the version field');
@@ -172,30 +182,39 @@ function release() {
172
182
  return [4 /*yield*/, (0, changelog_1.changelog)()];
173
183
  case 4:
174
184
  _a.sent();
175
- return [4 /*yield*/, pushGit(expectVersion, "v".concat(expectVersion))];
185
+ return [4 /*yield*/, pushGit(expectVersion)];
176
186
  case 5:
177
187
  _a.sent();
178
188
  _a.label = 6;
179
189
  case 6: return [4 /*yield*/, publish(isPreRelease)];
180
190
  case 7:
181
191
  _a.sent();
182
- if (!isPreRelease) return [3 /*break*/, 9];
192
+ if (!isPreRelease) return [3 /*break*/, 11];
183
193
  packageJsonMaps.forEach(function (_a) {
184
194
  var file = _a.file, content = _a.content;
185
195
  return (0, fs_extra_1.writeFileSync)(file, content);
186
196
  });
187
- return [4 /*yield*/, (0, execa_1.default)('git', ['restore', '**/package.json'])];
197
+ _a.label = 8;
188
198
  case 8:
189
- _a.sent();
190
- _a.label = 9;
199
+ _a.trys.push([8, 10, , 11]);
200
+ return [4 /*yield*/, (0, execa_1.default)('git', ['restore', '**/package.json'])
201
+ // eslint-disable-next-line no-empty
202
+ ];
191
203
  case 9:
192
- logger_1.default.success("Release version ".concat(expectVersion, " successfully!"));
204
+ _a.sent();
193
205
  return [3 /*break*/, 11];
194
206
  case 10:
207
+ e_1 = _a.sent();
208
+ return [3 /*break*/, 11];
209
+ case 11:
210
+ logger_1.default.success("Release version ".concat(expectVersion, " successfully!"));
211
+ return [3 /*break*/, 13];
212
+ case 12:
195
213
  error_1 = _a.sent();
196
214
  logger_1.default.error(error_1.toString());
197
- return [3 /*break*/, 11];
198
- case 11: return [2 /*return*/];
215
+ process.exit(1);
216
+ return [3 /*break*/, 13];
217
+ case 13: return [2 /*return*/];
199
218
  }
200
219
  });
201
220
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "1.24.2",
3
+ "version": "1.24.3-alpha.1640882119459",
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",
33
- "@varlet/markdown-vite-plugin": "1.24.2",
34
- "@varlet/touch-emulator": "1.24.2",
32
+ "@varlet/icons": "1.24.3-alpha.1640882119459",
33
+ "@varlet/markdown-vite-plugin": "1.24.3-alpha.1640882119459",
34
+ "@varlet/touch-emulator": "1.24.3-alpha.1640882119459",
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",
76
+ "@varlet/touch-emulator": "1.24.3-alpha.1640882119459",
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
  }