@varlet/cli 1.27.6 → 1.27.7-alpha.1650880107793

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/LICENCE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 varlet
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -128,13 +128,78 @@ function updateVersion(version) {
128
128
  (0, fs_extra_1.writeFileSync)(file, JSON.stringify(config, null, 2));
129
129
  });
130
130
  }
131
+ function confirmRegistry() {
132
+ return __awaiter(this, void 0, void 0, function () {
133
+ var registry, name, ret;
134
+ return __generator(this, function (_a) {
135
+ switch (_a.label) {
136
+ case 0: return [4 /*yield*/, (0, execa_1.default)('npm', ['config', 'get', 'registry'])];
137
+ case 1:
138
+ registry = (_a.sent()).stdout;
139
+ name = 'Registry confirm';
140
+ return [4 /*yield*/, inquirer_1.default.prompt([
141
+ {
142
+ name: name,
143
+ type: 'confirm',
144
+ message: "Current registry is: ".concat(registry),
145
+ },
146
+ ])];
147
+ case 2:
148
+ ret = _a.sent();
149
+ return [2 /*return*/, ret[name]];
150
+ }
151
+ });
152
+ });
153
+ }
154
+ function confirmVersion(currentVersion, expectVersion) {
155
+ return __awaiter(this, void 0, void 0, function () {
156
+ var name, ret;
157
+ return __generator(this, function (_a) {
158
+ switch (_a.label) {
159
+ case 0:
160
+ name = 'Version confirm';
161
+ return [4 /*yield*/, inquirer_1.default.prompt([
162
+ {
163
+ name: name,
164
+ type: 'confirm',
165
+ message: "All packages version ".concat(currentVersion, " -> ").concat(expectVersion, ":"),
166
+ },
167
+ ])];
168
+ case 1:
169
+ ret = _a.sent();
170
+ return [2 /*return*/, ret[name]];
171
+ }
172
+ });
173
+ });
174
+ }
175
+ function getReleaseType() {
176
+ return __awaiter(this, void 0, void 0, function () {
177
+ var name, ret;
178
+ return __generator(this, function (_a) {
179
+ switch (_a.label) {
180
+ case 0:
181
+ name = 'Please select release type';
182
+ return [4 /*yield*/, inquirer_1.default.prompt([
183
+ {
184
+ name: name,
185
+ type: 'list',
186
+ choices: releaseTypes,
187
+ },
188
+ ])];
189
+ case 1:
190
+ ret = _a.sent();
191
+ return [2 /*return*/, ret[name]];
192
+ }
193
+ });
194
+ });
195
+ }
131
196
  function release(cmd) {
132
197
  return __awaiter(this, void 0, void 0, function () {
133
- var currentVersion, name_1, ret, type, isPreRelease, expectVersion, confirm_1, _a, error_1;
198
+ var currentVersion, type, isPreRelease, expectVersion, _a, error_1;
134
199
  return __generator(this, function (_b) {
135
200
  switch (_b.label) {
136
201
  case 0:
137
- _b.trys.push([0, 13, , 14]);
202
+ _b.trys.push([0, 14, , 15]);
138
203
  currentVersion = require((0, path_1.resolve)(constant_1.CWD, 'package.json')).version;
139
204
  if (!currentVersion) {
140
205
  logger_1.default.error('Your package is missing the version field');
@@ -146,68 +211,57 @@ function release(cmd) {
146
211
  logger_1.default.error('Git worktree is not empty, please commit changed');
147
212
  return [2 /*return*/];
148
213
  }
149
- name_1 = 'Please select release type';
150
- return [4 /*yield*/, inquirer_1.default.prompt([
151
- {
152
- name: name_1,
153
- type: 'list',
154
- choices: releaseTypes,
155
- },
156
- ])];
214
+ return [4 /*yield*/, confirmRegistry()];
157
215
  case 2:
158
- ret = _b.sent();
159
- type = ret[name_1];
216
+ if (!(_b.sent())) {
217
+ return [2 /*return*/];
218
+ }
219
+ return [4 /*yield*/, getReleaseType()];
220
+ case 3:
221
+ type = _b.sent();
160
222
  isPreRelease = type.startsWith('pre');
161
223
  expectVersion = semver_1.default.inc(currentVersion, type, "alpha.".concat(Date.now()));
162
224
  expectVersion = isPreRelease ? expectVersion.slice(0, -2) : expectVersion;
163
- name_1 = 'version confirm';
164
- return [4 /*yield*/, inquirer_1.default.prompt([
165
- {
166
- name: name_1,
167
- type: 'confirm',
168
- message: "All packages version ".concat(currentVersion, " -> ").concat(expectVersion, ":"),
169
- },
170
- ])];
171
- case 3:
172
- confirm_1 = _b.sent();
173
- if (!confirm_1[name_1]) {
225
+ return [4 /*yield*/, confirmVersion(currentVersion, expectVersion)];
226
+ case 4:
227
+ if (!(_b.sent())) {
174
228
  return [2 /*return*/];
175
229
  }
176
230
  updateVersion(expectVersion);
177
- if (!!isPreRelease) return [3 /*break*/, 6];
231
+ if (!!isPreRelease) return [3 /*break*/, 7];
178
232
  return [4 /*yield*/, (0, changelog_1.changelog)()];
179
- case 4:
233
+ case 5:
180
234
  _b.sent();
181
235
  return [4 /*yield*/, pushGit(expectVersion, cmd.remote)];
182
- case 5:
236
+ case 6:
183
237
  _b.sent();
184
- _b.label = 6;
185
- case 6: return [4 /*yield*/, publish(isPreRelease)];
186
- case 7:
238
+ _b.label = 7;
239
+ case 7: return [4 /*yield*/, publish(isPreRelease)];
240
+ case 8:
187
241
  _b.sent();
188
242
  logger_1.default.success("Release version ".concat(expectVersion, " successfully!"));
189
- if (!isPreRelease) return [3 /*break*/, 12];
190
- _b.label = 8;
191
- case 8:
192
- _b.trys.push([8, 11, , 12]);
193
- return [4 /*yield*/, (0, execa_1.default)('git', ['restore', '**/package.json'])];
243
+ if (!isPreRelease) return [3 /*break*/, 13];
244
+ _b.label = 9;
194
245
  case 9:
195
- _b.sent();
196
- return [4 /*yield*/, (0, execa_1.default)('git', ['restore', 'package.json'])];
246
+ _b.trys.push([9, 12, , 13]);
247
+ return [4 /*yield*/, (0, execa_1.default)('git', ['restore', '**/package.json'])];
197
248
  case 10:
198
249
  _b.sent();
199
- return [3 /*break*/, 12];
250
+ return [4 /*yield*/, (0, execa_1.default)('git', ['restore', 'package.json'])];
200
251
  case 11:
252
+ _b.sent();
253
+ return [3 /*break*/, 13];
254
+ case 12:
201
255
  _a = _b.sent();
202
256
  logger_1.default.error('Restore package.json has failed, please restore manually');
203
- return [3 /*break*/, 12];
204
- case 12: return [3 /*break*/, 14];
205
- case 13:
257
+ return [3 /*break*/, 13];
258
+ case 13: return [3 /*break*/, 15];
259
+ case 14:
206
260
  error_1 = _b.sent();
207
261
  logger_1.default.error(error_1.toString());
208
262
  process.exit(1);
209
- return [3 /*break*/, 14];
210
- case 14: return [2 /*return*/];
263
+ return [3 /*break*/, 15];
264
+ case 15: return [2 /*return*/];
211
265
  }
212
266
  });
213
267
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "1.27.6",
3
+ "version": "1.27.7-alpha.1650880107793",
4
4
  "description": "cli of varlet",
5
5
  "bin": {
6
6
  "varlet-cli": "./lib/index.js"
@@ -27,19 +27,15 @@
27
27
  "bugs": {
28
28
  "url": "https://github.com/varletjs/varlet/issues"
29
29
  },
30
- "scripts": {
31
- "dev": "tsc --watch",
32
- "build": "tsc"
33
- },
34
30
  "gitHead": "ee9c3866bedad96c86365b0f9888a3a6bb781b1f",
35
31
  "dependencies": {
36
32
  "@babel/core": "^7.14.8",
37
33
  "@babel/helper-plugin-utils": "^7.14.5",
38
34
  "@babel/preset-env": "^7.14.8",
39
35
  "@babel/preset-typescript": "^7.14.5",
40
- "@varlet/icons": "workspace:*",
41
- "@varlet/markdown-vite-plugin": "workspace:*",
42
- "@varlet/touch-emulator": "workspace:*",
36
+ "@varlet/icons": "1.27.7-alpha.1650880107793",
37
+ "@varlet/markdown-vite-plugin": "1.27.7-alpha.1650880107793",
38
+ "@varlet/touch-emulator": "1.27.7-alpha.1650880107793",
43
39
  "@vitejs/plugin-vue": "2.2.0",
44
40
  "@vitejs/plugin-vue-jsx": "1.3.5",
45
41
  "@vue/babel-plugin-jsx": "1.1.1",
@@ -79,7 +75,7 @@
79
75
  "@types/semver": "^7.3.9"
80
76
  },
81
77
  "peerDependencies": {
82
- "@varlet/touch-emulator": "workspace:*",
78
+ "@varlet/touch-emulator": "1.27.7-alpha.1650880107793",
83
79
  "@vue/test-utils": "^2.0.0-rc.6",
84
80
  "clipboard": "^2.0.6",
85
81
  "live-server": "^1.2.1",
@@ -87,5 +83,10 @@
87
83
  "vue": "3.2.25",
88
84
  "@vue/runtime-core": "3.2.16",
89
85
  "vue-router": "4.0.12"
90
- }
86
+ },
87
+ "scripts": {
88
+ "dev": "tsc --watch",
89
+ "build": "tsc"
90
+ },
91
+ "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-mobile-cell-hover` |\n| `color-pc-language-active` |\n| `color-pc-language-active-background` |\n| `color-mobile-language-active` |\n| `color-mobile-language-active-background` |\n| `color-hl-background` |\n| `color-hl-code` |\n| `color-hl-border` |\n| `color-hl-group-a` |\n| `color-hl-group-b` |\n| `color-hl-group-c` |\n| `color-hl-group-d` |\n| `color-hl-group-e` |\n| `color-hl-group-f` |\n| `color-hl-group-g` |\n| `color-hl-group-h` |\n| `color-hl-group-i` |\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/varletjs/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 playground: null,\n github: 'https://github.com/varletjs/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```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`simple-git-hooks`,`lint-staged` 配合 `eslint`,`stylelint`,`varlet-cli commit-lint` 做commit前的检查,`package.json` 配置如下\n\n```json\n{\n \"simple-git-hooks\": {\n \"pre-commit\": \"pnpm exec lint-staged --allow-empty --concurrent false\",\n \"commit-msg\": \"npx --no-install varlet-cli commit-lint $1\"\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挂载钩子\n\n```shell\nnpx simple-git-hooks\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\n1. `npm` 的仓库源必须指向 `npm` 官方镜像\n2. 执行 `npm login` 进行登录\n\n### Contributors\n\n<a href=\"https://github.com/varletjs/varlet/graphs/contributors\">\n <img src=\"https://contrib.rocks/image?repo=haoziqaq/varlet\" />\n</a>"
91
92
  }