@varlet/cli 2.0.0 → 2.0.1-alpha.1665643639034

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
@@ -42,7 +42,7 @@ Also refer to `@varlet/ui` [varlet.config.js](https://github.com/varletjs/varlet
42
42
  | -- | -------------- | -------- | ---------- |
43
43
  | `name` | The full name of the component library, which will be used as the package name | _string_ | `Varlet` |
44
44
  | `namespace` | Component library namespace, which will be used as a component prefix | _string_ | `var` |
45
- | `host` | Development server host | _number_ | `localhost` |
45
+ | `host` | Development server host | _string_ | `localhost` |
46
46
  | `port` | Development server port | _number_ | `8080` |
47
47
  | `title` | The title of the component library in the documentation | _string_ | `VARLET` |
48
48
  | `logo` | The logo of the component library in the documentation | _string_ | `-` |
package/README.md CHANGED
@@ -40,7 +40,7 @@ varlet-cli gen
40
40
  | ----- | -------------- | -------- | ---------- |
41
41
  | `name` | 组件库全名,会作为包名 | _string_ | `Varlet` |
42
42
  | `namespace` | 组件库命名空间, 会作为组件前缀 | _string_ | `var` |
43
- | `host` | 开发服务器主机 | _number_ | `localhost` |
43
+ | `host` | 开发服务器主机 | _string_ | `localhost` |
44
44
  | `port` | 开发服务器端口 | _number_ | `8080` |
45
45
  | `title` | 文档中组件库的标题 | _string_ | `VARLET` |
46
46
  | `logo` | 文档中组件库的logo | _string_ | `-` |
package/lib/bin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/lib/bin.js ADDED
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __read = (this && this.__read) || function (o, n) {
4
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
5
+ if (!m) return o;
6
+ var i = m.call(o), r, ar = [], e;
7
+ try {
8
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
9
+ }
10
+ catch (error) { e = { error: error }; }
11
+ finally {
12
+ try {
13
+ if (r && !r.done && (m = i["return"])) m.call(i);
14
+ }
15
+ finally { if (e) throw e.error; }
16
+ }
17
+ return ar;
18
+ };
19
+ var __importDefault = (this && this.__importDefault) || function (mod) {
20
+ return (mod && mod.__esModule) ? mod : { "default": mod };
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ var logger_1 = __importDefault(require("./shared/logger"));
24
+ var commander_1 = require("commander");
25
+ var dev_1 = require("./commands/dev");
26
+ var build_1 = require("./commands/build");
27
+ var vite_1 = require("./commands/vite");
28
+ var compile_1 = require("./commands/compile");
29
+ var create_1 = require("./commands/create");
30
+ var jest_1 = require("./commands/jest");
31
+ var lint_1 = require("./commands/lint");
32
+ var gen_1 = require("./commands/gen");
33
+ var preview_1 = require("./commands/preview");
34
+ var changelog_1 = require("./commands/changelog");
35
+ var release_1 = require("./commands/release");
36
+ var commitLint_1 = require("./commands/commitLint");
37
+ var program = new commander_1.Command();
38
+ program.version("varlet-cli ".concat(require('../package.json').version)).usage('<command> [options]');
39
+ program
40
+ .command('dev')
41
+ .option('-f --force', 'Force dep pre-optimization regardless of whether deps have changed')
42
+ .description('Run varlet development environment')
43
+ .action(dev_1.dev);
44
+ program.command('build').description('Build varlet site for production').action(build_1.build);
45
+ program
46
+ .command('build:vite')
47
+ .description('Use vite build app for production')
48
+ .action(function () { return (0, vite_1.vite)('build'); });
49
+ program
50
+ .command('dev:vite')
51
+ .description('Use vite start server for development')
52
+ .action(function () { return (0, vite_1.vite)('dev'); });
53
+ program.command('preview').description('Preview varlet site for production').action(preview_1.preview);
54
+ program
55
+ .command('compile')
56
+ .description('Compile varlet components library code')
57
+ .option('-nu, --noUmd', 'Do not compile umd target code')
58
+ .action(compile_1.compile);
59
+ program.command('lint').description('Lint code').action(lint_1.lint);
60
+ program
61
+ .command('create')
62
+ .description('Create a component directory')
63
+ .option('-n, --name <componentName>', 'Component name')
64
+ .option('-s, --sfc', 'Generate files in sfc format')
65
+ .option('-t, --tsx', 'Generate files in tsx format')
66
+ .option('-l, --locale', 'Generator internationalized files')
67
+ .action(create_1.create);
68
+ program
69
+ .command('jest')
70
+ .description('Run Jest in work directory')
71
+ .option('-w, --watch', 'Watch files for changes and rerun tests related to changed files')
72
+ .option('-wa, --watchAll', 'Watch files for changes and rerun all tests when something changes')
73
+ .option('-c, --component <componentName>', 'Test a specific component')
74
+ .option('-cc --clearCache', 'Clear test cache')
75
+ .action(jest_1.jest);
76
+ program
77
+ .command('gen')
78
+ .description('Generate cli application')
79
+ .option('-n, --name <applicationName>', 'Application name')
80
+ .option('-s, --sfc', 'Generate files in sfc format')
81
+ .option('-t, --tsx', 'Generate files in tsx format')
82
+ .option('-l, --locale', 'Generator internationalized files')
83
+ .action(gen_1.gen);
84
+ program
85
+ .command('changelog')
86
+ .option('-rc --releaseCount <releaseCount>', 'Release count')
87
+ .option('-f --file <file>', 'Changelog filename')
88
+ .description('Generate changelog')
89
+ .action(changelog_1.changelog);
90
+ program
91
+ .command('release')
92
+ .option('-r --remote <remote>', 'Remote name')
93
+ .description('Release all packages and generate changelogs')
94
+ .action(release_1.release);
95
+ program.command('commit-lint <gitParams>').description('Lint commit message').action(commitLint_1.commitLint);
96
+ program.on('command:*', function (_a) {
97
+ var _b = __read(_a, 1), cmd = _b[0];
98
+ program.outputHelp();
99
+ logger_1.default.error("\nUnknown command ".concat(cmd, ".\n"));
100
+ process.exitCode = 1;
101
+ });
102
+ program.parse();
@@ -199,70 +199,68 @@ function release(options) {
199
199
  return __generator(this, function (_b) {
200
200
  switch (_b.label) {
201
201
  case 0:
202
- _b.trys.push([0, 14, , 15]);
202
+ _b.trys.push([0, 13, , 14]);
203
203
  currentVersion = require((0, path_1.resolve)(constant_1.CWD, 'package.json')).version;
204
204
  if (!currentVersion) {
205
205
  logger_1.default.error('Your package is missing the version field');
206
206
  return [2 /*return*/];
207
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
208
  return [4 /*yield*/, confirmRegistry()];
215
- case 2:
209
+ case 1:
210
+ // if (!(await isWorktreeEmpty())) {
211
+ // logger.error('Git worktree is not empty, please commit changed')
212
+ // return
213
+ // }
216
214
  if (!(_b.sent())) {
217
215
  return [2 /*return*/];
218
216
  }
219
217
  return [4 /*yield*/, getReleaseType()];
220
- case 3:
218
+ case 2:
221
219
  type = _b.sent();
222
220
  isPreRelease = type.startsWith('pre');
223
221
  expectVersion = semver_1.default.inc(currentVersion, type, "alpha.".concat(Date.now()));
224
222
  expectVersion = isPreRelease ? expectVersion.slice(0, -2) : expectVersion;
225
223
  return [4 /*yield*/, confirmVersion(currentVersion, expectVersion)];
226
- case 4:
224
+ case 3:
227
225
  if (!(_b.sent())) {
228
226
  return [2 /*return*/];
229
227
  }
230
228
  updateVersion(expectVersion);
231
229
  return [4 /*yield*/, publish(isPreRelease)];
232
- case 5:
230
+ case 4:
233
231
  _b.sent();
234
- if (!!isPreRelease) return [3 /*break*/, 8];
232
+ if (!!isPreRelease) return [3 /*break*/, 7];
235
233
  return [4 /*yield*/, (0, changelog_1.changelog)()];
236
- case 6:
234
+ case 5:
237
235
  _b.sent();
238
236
  return [4 /*yield*/, pushGit(expectVersion, options.remote)];
239
- case 7:
237
+ case 6:
240
238
  _b.sent();
239
+ _b.label = 7;
240
+ case 7:
241
+ logger_1.default.success("Release version ".concat(expectVersion, " successfully!"));
242
+ if (!isPreRelease) return [3 /*break*/, 12];
241
243
  _b.label = 8;
242
244
  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]);
245
+ _b.trys.push([8, 11, , 12]);
248
246
  return [4 /*yield*/, (0, execa_1.default)('git', ['restore', '**/package.json'])];
249
- case 10:
247
+ case 9:
250
248
  _b.sent();
251
249
  return [4 /*yield*/, (0, execa_1.default)('git', ['restore', 'package.json'])];
252
- case 11:
250
+ case 10:
253
251
  _b.sent();
254
- return [3 /*break*/, 13];
255
- case 12:
252
+ return [3 /*break*/, 12];
253
+ case 11:
256
254
  _a = _b.sent();
257
255
  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:
256
+ return [3 /*break*/, 12];
257
+ case 12: return [3 /*break*/, 14];
258
+ case 13:
261
259
  error_1 = _b.sent();
262
260
  logger_1.default.error(error_1.toString());
263
261
  process.exit(1);
264
- return [3 /*break*/, 15];
265
- case 15: return [2 /*return*/];
262
+ return [3 /*break*/, 14];
263
+ case 14: return [2 /*return*/];
266
264
  }
267
265
  });
268
266
  });
@@ -1 +1,43 @@
1
- export declare function getVarletConfig(emit?: boolean): Record<string, any>;
1
+ interface VarletConfig {
2
+ /**
3
+ * @default `Varlet`
4
+ * UI library name.
5
+ */
6
+ name?: string;
7
+ /**
8
+ * @default `var`
9
+ * Component class name preffix
10
+ */
11
+ namespace?: string;
12
+ /**
13
+ * @default `localhost`
14
+ * Local dev server host
15
+ */
16
+ host?: string;
17
+ /**
18
+ * @default `8080`
19
+ * Local dev server protcol
20
+ */
21
+ port?: number;
22
+ logo?: string;
23
+ defaultLanguage?: 'zh-CN' | 'en-US';
24
+ /**
25
+ * @default `false`
26
+ * Show mobile component on the right.
27
+ */
28
+ useMobile?: boolean;
29
+ lightTheme?: Record<string, string>;
30
+ darkTheme?: Record<string, string>;
31
+ highlight?: {
32
+ style: string;
33
+ };
34
+ analysis?: {
35
+ baidu: string;
36
+ };
37
+ pc?: Record<string, any>;
38
+ mobile?: Record<string, any>;
39
+ moduleCompatible?: Record<string, string>;
40
+ }
41
+ export declare const defineConfig: (conf: VarletConfig) => VarletConfig;
42
+ export declare function getVarletConfig(emit?: boolean): any;
43
+ export {};
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getVarletConfig = void 0;
3
+ exports.getVarletConfig = exports.defineConfig = void 0;
4
4
  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
+ var defineConfig = function (conf) { return conf; };
9
+ exports.defineConfig = defineConfig;
8
10
  function getVarletConfig(emit) {
9
11
  if (emit === void 0) { emit = false; }
10
12
  var config = {};
package/lib/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ export { defineConfig } from './config/varlet.config';
package/lib/index.js CHANGED
@@ -1,102 +1,5 @@
1
- #!/usr/bin/env node
2
1
  "use strict";
3
- var __read = (this && this.__read) || function (o, n) {
4
- var m = typeof Symbol === "function" && o[Symbol.iterator];
5
- if (!m) return o;
6
- var i = m.call(o), r, ar = [], e;
7
- try {
8
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
9
- }
10
- catch (error) { e = { error: error }; }
11
- finally {
12
- try {
13
- if (r && !r.done && (m = i["return"])) m.call(i);
14
- }
15
- finally { if (e) throw e.error; }
16
- }
17
- return ar;
18
- };
19
- var __importDefault = (this && this.__importDefault) || function (mod) {
20
- return (mod && mod.__esModule) ? mod : { "default": mod };
21
- };
22
2
  Object.defineProperty(exports, "__esModule", { value: true });
23
- var logger_1 = __importDefault(require("./shared/logger"));
24
- var commander_1 = require("commander");
25
- var dev_1 = require("./commands/dev");
26
- var build_1 = require("./commands/build");
27
- var vite_1 = require("./commands/vite");
28
- var compile_1 = require("./commands/compile");
29
- var create_1 = require("./commands/create");
30
- var jest_1 = require("./commands/jest");
31
- var lint_1 = require("./commands/lint");
32
- var gen_1 = require("./commands/gen");
33
- var preview_1 = require("./commands/preview");
34
- var changelog_1 = require("./commands/changelog");
35
- var release_1 = require("./commands/release");
36
- var commitLint_1 = require("./commands/commitLint");
37
- var program = new commander_1.Command();
38
- program.version("varlet-cli ".concat(require('../package.json').version)).usage('<command> [options]');
39
- program
40
- .command('dev')
41
- .option('-f --force', 'Force dep pre-optimization regardless of whether deps have changed')
42
- .description('Run varlet development environment')
43
- .action(dev_1.dev);
44
- program.command('build').description('Build varlet site for production').action(build_1.build);
45
- program
46
- .command('build:vite')
47
- .description('Use vite build app for production')
48
- .action(function () { return (0, vite_1.vite)('build'); });
49
- program
50
- .command('dev:vite')
51
- .description('Use vite start server for development')
52
- .action(function () { return (0, vite_1.vite)('dev'); });
53
- program.command('preview').description('Preview varlet site for production').action(preview_1.preview);
54
- program
55
- .command('compile')
56
- .description('Compile varlet components library code')
57
- .option('-nu, --noUmd', 'Do not compile umd target code')
58
- .action(compile_1.compile);
59
- program.command('lint').description('Lint code').action(lint_1.lint);
60
- program
61
- .command('create')
62
- .description('Create a component directory')
63
- .option('-n, --name <componentName>', 'Component name')
64
- .option('-s, --sfc', 'Generate files in sfc format')
65
- .option('-t, --tsx', 'Generate files in tsx format')
66
- .option('-l, --locale', 'Generator internationalized files')
67
- .action(create_1.create);
68
- program
69
- .command('jest')
70
- .description('Run Jest in work directory')
71
- .option('-w, --watch', 'Watch files for changes and rerun tests related to changed files')
72
- .option('-wa, --watchAll', 'Watch files for changes and rerun all tests when something changes')
73
- .option('-c, --component <componentName>', 'Test a specific component')
74
- .option('-cc --clearCache', 'Clear test cache')
75
- .action(jest_1.jest);
76
- program
77
- .command('gen')
78
- .description('Generate cli application')
79
- .option('-n, --name <applicationName>', 'Application name')
80
- .option('-s, --sfc', 'Generate files in sfc format')
81
- .option('-t, --tsx', 'Generate files in tsx format')
82
- .option('-l, --locale', 'Generator internationalized files')
83
- .action(gen_1.gen);
84
- program
85
- .command('changelog')
86
- .option('-rc --releaseCount <releaseCount>', 'Release count')
87
- .option('-f --file <file>', 'Changelog filename')
88
- .description('Generate changelog')
89
- .action(changelog_1.changelog);
90
- program
91
- .command('release')
92
- .option('-r --remote <remote>', 'Remote name')
93
- .description('Release all packages and generate changelogs')
94
- .action(release_1.release);
95
- program.command('commit-lint <gitParams>').description('Lint commit message').action(commitLint_1.commitLint);
96
- program.on('command:*', function (_a) {
97
- var _b = __read(_a, 1), cmd = _b[0];
98
- program.outputHelp();
99
- logger_1.default.error("\nUnknown command ".concat(cmd, ".\n"));
100
- process.exitCode = 1;
101
- });
102
- program.parse();
3
+ exports.defineConfig = void 0;
4
+ var varlet_config_1 = require("./config/varlet.config");
5
+ Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return varlet_config_1.defineConfig; } });
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "2.0.0",
3
+ "version": "2.0.1-alpha.1665643639034",
4
4
  "description": "cli of varlet",
5
5
  "bin": {
6
- "varlet-cli": "./lib/index.js"
6
+ "varlet-cli": "./lib/bin.js"
7
7
  },
8
+ "main": "./lib/index.js",
9
+ "module": "./lib/index.js",
8
10
  "keywords": [
9
11
  "cli",
10
12
  "varlet"
@@ -32,10 +34,10 @@
32
34
  "@babel/helper-plugin-utils": "^7.14.5",
33
35
  "@babel/preset-env": "^7.14.8",
34
36
  "@babel/preset-typescript": "^7.14.5",
35
- "@varlet/icons": "2.0.0",
36
- "@varlet/markdown-vite-plugin": "2.0.0",
37
- "@varlet/shared": "2.0.0",
38
- "@varlet/touch-emulator": "2.0.0",
37
+ "@varlet/icons": "2.0.1-alpha.1665643639034",
38
+ "@varlet/markdown-vite-plugin": "2.0.1-alpha.1665643639034",
39
+ "@varlet/shared": "2.0.1-alpha.1665643639034",
40
+ "@varlet/touch-emulator": "2.0.1-alpha.1665643639034",
39
41
  "@vitejs/plugin-vue": "3.0.1",
40
42
  "@vitejs/plugin-vue-jsx": "2.0.0",
41
43
  "@vue/babel-plugin-jsx": "1.1.1",
@@ -80,7 +82,7 @@
80
82
  "@types/semver": "^7.3.9"
81
83
  },
82
84
  "peerDependencies": {
83
- "@varlet/touch-emulator": "2.0.0",
85
+ "@varlet/touch-emulator": "2.0.1-alpha.1665643639034",
84
86
  "@vue/runtime-core": "3.2.16",
85
87
  "@vue/test-utils": "^2.0.2",
86
88
  "clipboard": "^2.0.6",
@@ -19,11 +19,8 @@
19
19
  "es/**/style/*",
20
20
  "lib/**/style/*",
21
21
  "es/style.js",
22
- "es/less.js",
23
22
  "lib/style.js",
24
- "lib/less.js",
25
- "*.css",
26
- "*.less"
23
+ "*.css"
27
24
  ],
28
25
  "scripts": {
29
26
  "preinstall": "npx only-allow pnpm",
@@ -1,4 +1,6 @@
1
- module.exports = {
1
+ const { defineConfig } = require('@varlet/cli')
2
+
3
+ module.exports = defineConfig({
2
4
  logo: './logo.svg',
3
5
  useMobile: true,
4
6
  pc: {
@@ -41,5 +43,5 @@ module.exports = {
41
43
  i18n: null,
42
44
  darkMode: null,
43
45
  },
44
- },
45
- }
46
+ }
47
+ })
@@ -19,11 +19,8 @@
19
19
  "es/**/style/*",
20
20
  "lib/**/style/*",
21
21
  "es/style.js",
22
- "es/less.js",
23
22
  "lib/style.js",
24
- "lib/less.js",
25
- "*.css",
26
- "*.less"
23
+ "*.css"
27
24
  ],
28
25
  "scripts": {
29
26
  "preinstall": "npx only-allow pnpm",
@@ -1,4 +1,6 @@
1
- module.exports = {
1
+ const { defineConfig } = require('@varlet/cli')
2
+
3
+ module.exports = defineConfig({
2
4
  logo: './logo.svg',
3
5
  useMobile: true,
4
6
  pc: {
@@ -44,4 +46,4 @@ module.exports = {
44
46
  darkMode: null,
45
47
  },
46
48
  },
47
- }
49
+ })