@varlet/cli 1.23.0 → 1.23.4-alpha.1

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.23.3](https://github.com/haoziqaq/varlet/compare/v1.23.2...v1.23.3) (2021-11-20)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **cli/jest:** add watchAll mode ([84ebb4e](https://github.com/haoziqaq/varlet/commit/84ebb4efe823cb9d7f22995d429b82d8fc3e05c8))
12
+
13
+
14
+
15
+
16
+
6
17
  # [1.23.0](https://github.com/haoziqaq/varlet/compare/v1.22.10...v1.23.0) (2021-11-19)
7
18
 
8
19
 
package/README.en-US.md CHANGED
@@ -202,6 +202,8 @@ varlet-cli test
202
202
 
203
203
  ```shell
204
204
  varlet-cli test -w
205
+ or
206
+ varlet-cli test -wa
205
207
  ```
206
208
 
207
209
  #### Lint code
package/README.md CHANGED
@@ -197,6 +197,8 @@ varlet-cli test
197
197
 
198
198
  ```shell
199
199
  varlet-cli test -w
200
+ or
201
+ varlet-cli test -wa
200
202
  ```
201
203
 
202
204
  #### 检查代码
@@ -7,6 +7,7 @@ node_modules
7
7
  .DS_Store
8
8
 
9
9
  site
10
+ lib
10
11
  es
11
12
  umd
12
13
  coverage
@@ -47,7 +47,9 @@ yarn test
47
47
  #### Run unit test in watch mode
48
48
 
49
49
  ```shell
50
- yarn test:watch
50
+ yarn test:watch
51
+ or
52
+ yarn test:watchAll
51
53
  ```
52
54
 
53
55
  #### Quickly create a component folder
@@ -2,6 +2,7 @@
2
2
  "name": "basic-ui",
3
3
  "version": "0.0.0",
4
4
  "description": "A basic components library",
5
+ "main": "lib/index.js",
5
6
  "module": "es/index.js",
6
7
  "typings": "types/index.d.ts",
7
8
  "vetur": {
@@ -27,7 +28,8 @@
27
28
  "genAllLog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
28
29
  "release": "yarn compile && release-it",
29
30
  "test": "varlet-cli jest",
30
- "test:watch": "varlet-cli jest -w"
31
+ "test:watch": "varlet-cli jest -w",
32
+ "test:watchAll": "varlet-cli jest -wa"
31
33
  },
32
34
  "peerDependencies": {
33
35
  "vue": "^3.2.0"
@@ -63,6 +65,7 @@
63
65
  "eslintConfig": {
64
66
  "root": true,
65
67
  "ignorePatterns": [
68
+ "lib/**",
66
69
  "es/**",
67
70
  "umd/**",
68
71
  "site/**",
@@ -79,6 +82,7 @@
79
82
  "@varlet/stylelint-config"
80
83
  ],
81
84
  "ignoreFiles": [
85
+ "lib/**",
82
86
  "es/**",
83
87
  "umd/**",
84
88
  "site/**",
@@ -7,6 +7,7 @@ node_modules
7
7
  .DS_Store
8
8
 
9
9
  site
10
+ lib
10
11
  es
11
12
  umd
12
13
  coverage
@@ -47,7 +47,9 @@ yarn test
47
47
  #### Run unit test in watch mode
48
48
 
49
49
  ```shell
50
- yarn test:watch
50
+ yarn test:watch
51
+ or
52
+ yarn test:watchAll
51
53
  ```
52
54
 
53
55
  #### Quickly create a component folder
@@ -2,6 +2,7 @@
2
2
  "name": "basic-ui",
3
3
  "version": "0.0.0",
4
4
  "description": "A basic components library",
5
+ "main": "lib/index.js",
5
6
  "module": "es/index.js",
6
7
  "typings": "types/index.d.ts",
7
8
  "vetur": {
@@ -27,7 +28,8 @@
27
28
  "genAllLog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
28
29
  "release": "yarn compile && release-it",
29
30
  "test": "varlet-cli jest",
30
- "test:watch": "varlet-cli jest -w"
31
+ "test:watch": "varlet-cli jest -w",
32
+ "test:watchAll": "varlet-cli jest -wa"
31
33
  },
32
34
  "peerDependencies": {
33
35
  "vue": "^3.2.0"
@@ -63,6 +65,7 @@
63
65
  "eslintConfig": {
64
66
  "root": true,
65
67
  "ignorePatterns": [
68
+ "lib/**",
66
69
  "es/**",
67
70
  "umd/**",
68
71
  "site/**",
@@ -79,6 +82,7 @@
79
82
  "@varlet/stylelint-config"
80
83
  ],
81
84
  "ignoreFiles": [
85
+ "lib/**",
82
86
  "es/**",
83
87
  "umd/**",
84
88
  "site/**",
@@ -1,4 +1,4 @@
1
- export declare function removeDir(): Promise<[void, void, void]>;
1
+ export declare function removeDir(): Promise<[void, void, void, void]>;
2
2
  export declare function runTask(taskName: string, task: () => any): Promise<void>;
3
3
  export declare function compile(cmd: {
4
4
  noUmd: boolean;
@@ -48,7 +48,7 @@ var compileModule_1 = require("../compiler/compileModule");
48
48
  var compileTemplateHighlight_1 = require("../compiler/compileTemplateHighlight");
49
49
  var compileTypes_1 = require("../compiler/compileTypes");
50
50
  function removeDir() {
51
- return Promise.all([(0, fs_extra_1.remove)(constant_1.ES_DIR), (0, fs_extra_1.remove)(constant_1.HL_DIR), (0, fs_extra_1.remove)(constant_1.UMD_DIR)]);
51
+ return Promise.all([(0, fs_extra_1.remove)(constant_1.ES_DIR), (0, fs_extra_1.remove)(constant_1.LIB_DIR), (0, fs_extra_1.remove)(constant_1.HL_DIR), (0, fs_extra_1.remove)(constant_1.UMD_DIR)]);
52
52
  }
53
53
  exports.removeDir = removeDir;
54
54
  function runTask(taskName, task) {
@@ -87,20 +87,22 @@ function compile(cmd) {
87
87
  return [4 /*yield*/, removeDir()];
88
88
  case 1:
89
89
  _b.sent();
90
- return [4 /*yield*/, Promise.all([
91
- runTask('types', compileTypes_1.compileTypes),
92
- runTask('template highlight', compileTemplateHighlight_1.compileTemplateHighlight),
93
- runTask('module', compileModule_1.compileModule),
94
- ])];
90
+ return [4 /*yield*/, Promise.all([runTask('types', compileTypes_1.compileTypes), runTask('template highlight', compileTemplateHighlight_1.compileTemplateHighlight)])];
95
91
  case 2:
92
+ _b.sent();
93
+ return [4 /*yield*/, runTask('module', compileModule_1.compileModule)];
94
+ case 3:
95
+ _b.sent();
96
+ return [4 /*yield*/, runTask('commonjs', function () { return (0, compileModule_1.compileModule)('commonjs'); })];
97
+ case 4:
96
98
  _b.sent();
97
99
  _a = !cmd.noUmd;
98
- if (!_a) return [3 /*break*/, 4];
100
+ if (!_a) return [3 /*break*/, 6];
99
101
  return [4 /*yield*/, runTask('umd', function () { return (0, compileModule_1.compileModule)('umd'); })];
100
- case 3:
102
+ case 5:
101
103
  _a = (_b.sent());
102
- _b.label = 4;
103
- case 4:
104
+ _b.label = 6;
105
+ case 6:
104
106
  _a;
105
107
  return [2 /*return*/];
106
108
  }
@@ -54,7 +54,7 @@ function syncVersion(name) {
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
56
  pkg.devDependencies['@varlet/cli'] = "^" + cliPkg.version;
57
- pkg.files = ['es', 'umd', 'highlight', 'types', 'README.md'];
57
+ pkg.files = ['es', 'lib', 'umd', 'highlight', 'types', 'README.md'];
58
58
  (0, fs_extra_1.writeFileSync)(file, JSON.stringify(pkg, null, 2));
59
59
  }
60
60
  function gen(name) {
@@ -1,5 +1,8 @@
1
- export declare function jest(cmd: {
1
+ interface JestCommandOptions {
2
2
  watch?: boolean;
3
+ watchAll?: boolean;
3
4
  component?: string;
4
5
  clearCache?: boolean;
5
- }): Promise<void>;
6
+ }
7
+ export declare function jest(cmd: JestCommandOptions): Promise<void>;
8
+ export {};
@@ -53,6 +53,7 @@ function jest(cmd) {
53
53
  config = {
54
54
  rootDir: constant_1.CWD,
55
55
  watch: cmd.watch,
56
+ watchAll: cmd.watchAll,
56
57
  clearCache: cmd.clearCache,
57
58
  config: constant_1.JEST_CONFIG,
58
59
  testRegex: cmd.component && cmd.component + "/__tests__/.*.spec.[jt]s?$",
@@ -1,4 +1,4 @@
1
1
  export declare function compileUMD(): Promise<void>;
2
2
  export declare function compileDir(dir: string): Promise<void>;
3
3
  export declare function compileFile(file: string): Promise<void>;
4
- export declare function compileModule(modules?: string | boolean): Promise<void>;
4
+ export declare function compileModule(modules?: 'umd' | 'commonjs' | boolean): Promise<void>;
@@ -127,23 +127,26 @@ exports.compileFile = compileFile;
127
127
  function compileModule(modules) {
128
128
  if (modules === void 0) { modules = false; }
129
129
  return __awaiter(this, void 0, void 0, function () {
130
- var moduleDir, _a, _b;
131
- return __generator(this, function (_c) {
132
- switch (_c.label) {
130
+ var dest, moduleDir, publicDirs;
131
+ return __generator(this, function (_a) {
132
+ switch (_a.label) {
133
133
  case 0:
134
134
  if (!(modules === 'umd')) return [3 /*break*/, 2];
135
135
  return [4 /*yield*/, compileUMD()];
136
136
  case 1:
137
- _c.sent();
137
+ _a.sent();
138
138
  return [2 /*return*/];
139
- case 2: return [4 /*yield*/, (0, fs_extra_1.copy)(constant_1.SRC_DIR, constant_1.ES_DIR)];
139
+ case 2:
140
+ process.env.BABEL_MODULE = modules === 'commonjs' ? 'commonjs' : 'module';
141
+ dest = modules === 'commonjs' ? constant_1.LIB_DIR : constant_1.ES_DIR;
142
+ return [4 /*yield*/, (0, fs_extra_1.copy)(constant_1.SRC_DIR, dest)];
140
143
  case 3:
141
- _c.sent();
144
+ _a.sent();
142
145
  return [4 /*yield*/, (0, fs_extra_1.readdir)(constant_1.ES_DIR)];
143
146
  case 4:
144
- moduleDir = _c.sent();
147
+ moduleDir = _a.sent();
145
148
  return [4 /*yield*/, Promise.all(moduleDir.map(function (filename) {
146
- var file = (0, path_1.resolve)(constant_1.ES_DIR, filename);
149
+ var file = (0, path_1.resolve)(dest, filename);
147
150
  if ((0, fsUtils_1.isDir)(file)) {
148
151
  (0, fs_extra_1.ensureFileSync)((0, path_1.resolve)(file, './style/index.js'));
149
152
  (0, fs_extra_1.ensureFileSync)((0, path_1.resolve)(file, './style/less.js'));
@@ -151,13 +154,13 @@ function compileModule(modules) {
151
154
  return (0, fsUtils_1.isDir)(file) ? compileDir(file) : null;
152
155
  }))];
153
156
  case 5:
154
- _c.sent();
155
- _a = compileScript_1.compileLibraryEntry;
156
- _b = [constant_1.ES_DIR];
157
+ _a.sent();
157
158
  return [4 /*yield*/, (0, fsUtils_1.getPublicDirs)()];
158
- case 6: return [4 /*yield*/, _a.apply(void 0, _b.concat([_c.sent()]))];
159
+ case 6:
160
+ publicDirs = _a.sent();
161
+ return [4 /*yield*/, (modules === 'commonjs' ? (0, compileScript_1.compileCommonJSEntry)(dest, publicDirs) : (0, compileScript_1.compileESEntry)(dest, publicDirs))];
159
162
  case 7:
160
- _c.sent();
163
+ _a.sent();
161
164
  return [2 /*return*/];
162
165
  }
163
166
  });
@@ -8,4 +8,5 @@ export declare const replaceJSXExt: (script: string) => string;
8
8
  export declare const replaceTSXExt: (script: string) => string;
9
9
  export declare function compileScript(script: string, file: string): Promise<void>;
10
10
  export declare function compileScriptFile(file: string): Promise<void>;
11
- export declare function compileLibraryEntry(dir: string, publicDirs: string[]): Promise<void>;
11
+ export declare function compileESEntry(dir: string, publicDirs: string[]): Promise<void>;
12
+ export declare function compileCommonJSEntry(dir: string, publicDirs: string[]): Promise<void>;
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.compileLibraryEntry = exports.compileScriptFile = exports.compileScript = exports.replaceTSXExt = exports.replaceJSXExt = exports.replaceTSExt = exports.replaceVueExt = exports.IMPORT_TSX_PATH_RE = exports.IMPORT_JSX_PATH_RE = exports.IMPORT_TS_PATH_RE = exports.IMPORT_VUE_PATH_RE = void 0;
39
+ exports.compileCommonJSEntry = exports.compileESEntry = exports.compileScriptFile = exports.compileScript = exports.replaceTSXExt = exports.replaceJSXExt = exports.replaceTSExt = exports.replaceVueExt = exports.IMPORT_TSX_PATH_RE = exports.IMPORT_JSX_PATH_RE = exports.IMPORT_TS_PATH_RE = exports.IMPORT_VUE_PATH_RE = void 0;
40
40
  var core_1 = require("@babel/core");
41
41
  var fsUtils_1 = require("../shared/fsUtils");
42
42
  var fs_extra_1 = require("fs-extra");
@@ -57,7 +57,7 @@ var replaceTSXExt = function (script) { return script.replace(exports.IMPORT_TSX
57
57
  exports.replaceTSXExt = replaceTSXExt;
58
58
  function compileScript(script, file) {
59
59
  return __awaiter(this, void 0, void 0, function () {
60
- var code;
60
+ var code, modules;
61
61
  return __generator(this, function (_a) {
62
62
  switch (_a.label) {
63
63
  case 0: return [4 /*yield*/, (0, core_1.transformAsync)(script, {
@@ -65,8 +65,9 @@ function compileScript(script, file) {
65
65
  })];
66
66
  case 1:
67
67
  code = (_a.sent()).code;
68
- code = (0, compileStyle_1.extractStyleDependencies)(file, code, compileStyle_1.IMPORT_CSS_RE, 'css', false);
69
- code = (0, compileStyle_1.extractStyleDependencies)(file, code, compileStyle_1.IMPORT_LESS_RE, 'less', false);
68
+ modules = process.env.BABEL_MODULE;
69
+ code = (0, compileStyle_1.extractStyleDependencies)(file, code, modules === 'commonjs' ? compileStyle_1.REQUIRE_CSS_RE : compileStyle_1.IMPORT_CSS_RE, 'css', false);
70
+ code = (0, compileStyle_1.extractStyleDependencies)(file, code, modules === 'commonjs' ? compileStyle_1.REQUIRE_LESS_RE : compileStyle_1.IMPORT_LESS_RE, 'less', false);
70
71
  code = (0, exports.replaceVueExt)(code);
71
72
  code = (0, exports.replaceTSXExt)(code);
72
73
  code = (0, exports.replaceJSXExt)(code);
@@ -95,7 +96,7 @@ function compileScriptFile(file) {
95
96
  });
96
97
  }
97
98
  exports.compileScriptFile = compileScriptFile;
98
- function compileLibraryEntry(dir, publicDirs) {
99
+ function compileESEntry(dir, publicDirs) {
99
100
  return __awaiter(this, void 0, void 0, function () {
100
101
  var imports, plugins, constInternalComponents, cssImports, lessImports, publicComponents, install, indexTemplate, styleTemplate, umdTemplate, lessTemplate;
101
102
  return __generator(this, function (_a) {
@@ -134,4 +135,40 @@ function compileLibraryEntry(dir, publicDirs) {
134
135
  });
135
136
  });
136
137
  }
137
- exports.compileLibraryEntry = compileLibraryEntry;
138
+ exports.compileESEntry = compileESEntry;
139
+ function compileCommonJSEntry(dir, publicDirs) {
140
+ return __awaiter(this, void 0, void 0, function () {
141
+ var requires, plugins, cssRequires, lessRequires, publicComponents, install, indexTemplate, styleTemplate, lessTemplate;
142
+ return __generator(this, function (_a) {
143
+ switch (_a.label) {
144
+ case 0:
145
+ requires = [];
146
+ plugins = [];
147
+ cssRequires = [];
148
+ lessRequires = [];
149
+ publicComponents = [];
150
+ publicDirs.forEach(function (dirname) {
151
+ var publicComponent = (0, fsUtils_1.bigCamelize)(dirname);
152
+ publicComponents.push(publicComponent);
153
+ requires.push("const " + publicComponent + " = require('./" + dirname + "')");
154
+ plugins.push(publicComponent + ".install && app.use(" + publicComponent + ")");
155
+ cssRequires.push("require('./" + dirname + "/style')");
156
+ lessRequires.push("require('./" + dirname + "/style/less')");
157
+ });
158
+ install = "\nfunction install(app) {\n " + plugins.join('\n ') + "\n}\n";
159
+ indexTemplate = requires.join('\n') + "\n\n" + install + "\n\nmodule.exports = {\n install,\n " + publicComponents.join(',\n ') + "\n}\n";
160
+ styleTemplate = cssRequires.join('\n') + "\n";
161
+ lessTemplate = lessRequires.join('\n') + "\n";
162
+ return [4 /*yield*/, Promise.all([
163
+ (0, fs_extra_1.writeFile)((0, path_1.resolve)(dir, 'index.js'), indexTemplate, 'utf-8'),
164
+ (0, fs_extra_1.writeFile)((0, path_1.resolve)(dir, 'style.js'), styleTemplate, 'utf-8'),
165
+ (0, fs_extra_1.writeFile)((0, path_1.resolve)(dir, 'less.js'), lessTemplate, 'utf-8'),
166
+ ])];
167
+ case 1:
168
+ _a.sent();
169
+ return [2 /*return*/];
170
+ }
171
+ });
172
+ });
173
+ }
174
+ exports.compileCommonJSEntry = compileCommonJSEntry;
@@ -2,6 +2,8 @@ export declare const EMPTY_SPACE_RE: RegExp;
2
2
  export declare const EMPTY_LINE_RE: RegExp;
3
3
  export declare const IMPORT_CSS_RE: RegExp;
4
4
  export declare const IMPORT_LESS_RE: RegExp;
5
+ export declare const REQUIRE_CSS_RE: RegExp;
6
+ export declare const REQUIRE_LESS_RE: RegExp;
5
7
  export declare const STYLE_IMPORT_RE: RegExp;
6
8
  export declare const clearEmptyLine: (s: string) => string;
7
9
  export declare function normalizeStyleDependency(styleImport: string, reg: RegExp): string;
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.compileLess = exports.extractStyleDependencies = exports.normalizeStyleDependency = exports.clearEmptyLine = exports.STYLE_IMPORT_RE = exports.IMPORT_LESS_RE = exports.IMPORT_CSS_RE = exports.EMPTY_LINE_RE = exports.EMPTY_SPACE_RE = void 0;
39
+ exports.compileLess = exports.extractStyleDependencies = exports.normalizeStyleDependency = exports.clearEmptyLine = exports.STYLE_IMPORT_RE = exports.REQUIRE_LESS_RE = exports.REQUIRE_CSS_RE = exports.IMPORT_LESS_RE = exports.IMPORT_CSS_RE = exports.EMPTY_LINE_RE = exports.EMPTY_SPACE_RE = void 0;
40
40
  var fs_extra_1 = require("fs-extra");
41
41
  var less_1 = require("less");
42
42
  var fsUtils_1 = require("../shared/fsUtils");
@@ -45,6 +45,8 @@ exports.EMPTY_SPACE_RE = /[\s]+/g;
45
45
  exports.EMPTY_LINE_RE = /[\n\r]*/g;
46
46
  exports.IMPORT_CSS_RE = /(?<!['"`])import\s+['"](\.{1,2}\/.+\.css)['"]\s*;?(?!\s*['"`])/g;
47
47
  exports.IMPORT_LESS_RE = /(?<!['"`])import\s+['"](\.{1,2}\/.+\.less)['"]\s*;?(?!\s*['"`])/g;
48
+ exports.REQUIRE_CSS_RE = /(?<!['"`])require\(\s*['"](\.{1,2}\/.+\.css)['"]\s*\);?(?!\s*['"`])/g;
49
+ exports.REQUIRE_LESS_RE = /(?<!['"`])require\(\s*['"](\.{1,2}\/.+\.less)['"]\s*\);?(?!\s*['"`])/g;
48
50
  exports.STYLE_IMPORT_RE = /@import\s+['"](.+)['"]\s*;/g;
49
51
  var clearEmptyLine = function (s) { return s.replace(exports.EMPTY_LINE_RE, '').replace(exports.EMPTY_SPACE_RE, ' '); };
50
52
  exports.clearEmptyLine = clearEmptyLine;
@@ -63,14 +65,19 @@ function extractStyleDependencies(file, code, reg, expect, self) {
63
65
  var styleImports = (_a = code.match(reg)) !== null && _a !== void 0 ? _a : [];
64
66
  var cssFile = (0, path_1.resolve)(dir, './style/index.js');
65
67
  var lessFile = (0, path_1.resolve)(dir, './style/less.js');
68
+ var modules = process.env.BABEL_MODULE;
66
69
  styleImports.forEach(function (styleImport) {
67
70
  var normalizedPath = normalizeStyleDependency(styleImport, reg);
68
- (0, fsUtils_1.smartAppendFileSync)(cssFile, "import '" + normalizedPath + ".css'\n");
69
- (0, fsUtils_1.smartAppendFileSync)(lessFile, "import '" + normalizedPath + "." + expect + "'\n");
71
+ (0, fsUtils_1.smartAppendFileSync)(cssFile, modules === 'commonjs' ? "require('" + normalizedPath + ".css')\n" : "import '" + normalizedPath + ".css'\n");
72
+ (0, fsUtils_1.smartAppendFileSync)(lessFile, modules === 'commonjs' ? "require('" + normalizedPath + "." + expect + "')\n" : "import '" + normalizedPath + "." + expect + "'\n");
70
73
  });
71
74
  if (self) {
72
- (0, fsUtils_1.smartAppendFileSync)(cssFile, "import '" + normalizeStyleDependency(base, reg) + ".css'\n");
73
- (0, fsUtils_1.smartAppendFileSync)(lessFile, "import '" + normalizeStyleDependency(base, reg) + "." + expect + "'\n");
75
+ (0, fsUtils_1.smartAppendFileSync)(cssFile, modules === 'commonjs'
76
+ ? "require('" + normalizeStyleDependency(base, reg) + ".css')\n"
77
+ : "import '" + normalizeStyleDependency(base, reg) + ".css'\n");
78
+ (0, fsUtils_1.smartAppendFileSync)(lessFile, modules === 'commonjs'
79
+ ? "require('" + normalizeStyleDependency(base, reg) + "." + expect + "')\n"
80
+ : "import '" + normalizeStyleDependency(base, reg) + "." + expect + "'\n");
74
81
  }
75
82
  return code.replace(reg, '');
76
83
  }
@@ -5,13 +5,13 @@ module.exports = function (api, options) {
5
5
  if (api) {
6
6
  api.cache.never();
7
7
  }
8
- var isTest = process.env.NODE_ENV === 'test';
8
+ var isCommonJS = process.env.NODE_ENV === 'test' || process.env.BABEL_MODULE === 'commonjs';
9
9
  return {
10
10
  presets: [
11
11
  [
12
12
  require.resolve('@babel/preset-env'),
13
13
  {
14
- modules: isTest ? 'commonjs' : false,
14
+ modules: isCommonJS ? 'commonjs' : false,
15
15
  loose: options.loose,
16
16
  },
17
17
  ],
package/lib/index.js CHANGED
@@ -49,7 +49,8 @@ program.command('create <name>').description('Create a component directory').act
49
49
  program
50
50
  .command('jest')
51
51
  .description('Run Jest in work directory')
52
- .option('-w, --watch', 'Watch files change auto jest')
52
+ .option('-w, --watch', 'Watch files for changes and rerun tests related to changed files')
53
+ .option('-wa, --watchAll', 'Watch files for changes and rerun all tests when something changes')
53
54
  .option('-c, --component <componentName>', 'Test a specific component')
54
55
  .option('-cc --clearCache', 'Clear test cache')
55
56
  .action(jest_1.jest);
@@ -2,6 +2,7 @@ export declare const CWD: string;
2
2
  export declare const VARLET_CONFIG: string;
3
3
  export declare const SRC_DIR: string;
4
4
  export declare const ES_DIR: string;
5
+ export declare const LIB_DIR: string;
5
6
  export declare const UMD_DIR: string;
6
7
  export declare const TYPES_DIR: string;
7
8
  export declare const ROOT_DOCS_DIR: string;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JEST_STYLE_MOCK = exports.JEST_MEDIA_MOCK = exports.JEST_CONFIG = exports.HL_WEB_TYPES_JSON = exports.HL_ATTRIBUTES_JSON = exports.HL_TAGS_JSON = exports.HL_DIR = exports.HL_MD = exports.HL_TITLE_SLOTS_RE = exports.HL_TITLE_EVENTS_RE = exports.HL_TITLE_ATTRIBUTES_RE = exports.HL_API_RE = exports.HL_COMPONENT_NAME_RE = exports.SITE_CONFIG = exports.SITE_MOBILE_ROUTES = exports.SITE_PC_ROUTES = exports.SITE_DIR = exports.SITE_PUBLIC_PATH = exports.SITE_OUTPUT_PATH = exports.SITE = exports.CLI_PACKAGE_JSON = exports.UI_PACKAGE_JSON = exports.GENERATORS_DIR = exports.TESTS_DIR_NAME = exports.EXAMPLE_DIR_INDEX = exports.DOCS_DIR_NAME = exports.EXAMPLE_LOCALE_DIR_NAME = exports.EXAMPLE_DIR_NAME = exports.STYLE_DIR_NAME = exports.PUBLIC_DIR_INDEXES = exports.SCRIPTS_EXTENSIONS = exports.VITE_RESOLVE_EXTENSIONS = exports.ESLINT_EXTENSIONS = exports.ROOT_DOCS_DIR = exports.TYPES_DIR = exports.UMD_DIR = exports.ES_DIR = exports.SRC_DIR = exports.VARLET_CONFIG = exports.CWD = void 0;
3
+ exports.JEST_STYLE_MOCK = exports.JEST_MEDIA_MOCK = exports.JEST_CONFIG = exports.HL_WEB_TYPES_JSON = exports.HL_ATTRIBUTES_JSON = exports.HL_TAGS_JSON = exports.HL_DIR = exports.HL_MD = exports.HL_TITLE_SLOTS_RE = exports.HL_TITLE_EVENTS_RE = exports.HL_TITLE_ATTRIBUTES_RE = exports.HL_API_RE = exports.HL_COMPONENT_NAME_RE = exports.SITE_CONFIG = exports.SITE_MOBILE_ROUTES = exports.SITE_PC_ROUTES = exports.SITE_DIR = exports.SITE_PUBLIC_PATH = exports.SITE_OUTPUT_PATH = exports.SITE = exports.CLI_PACKAGE_JSON = exports.UI_PACKAGE_JSON = exports.GENERATORS_DIR = exports.TESTS_DIR_NAME = exports.EXAMPLE_DIR_INDEX = exports.DOCS_DIR_NAME = exports.EXAMPLE_LOCALE_DIR_NAME = exports.EXAMPLE_DIR_NAME = exports.STYLE_DIR_NAME = exports.PUBLIC_DIR_INDEXES = exports.SCRIPTS_EXTENSIONS = exports.VITE_RESOLVE_EXTENSIONS = exports.ESLINT_EXTENSIONS = exports.ROOT_DOCS_DIR = exports.TYPES_DIR = exports.UMD_DIR = exports.LIB_DIR = exports.ES_DIR = exports.SRC_DIR = exports.VARLET_CONFIG = exports.CWD = void 0;
4
4
  var path_1 = require("path");
5
5
  exports.CWD = process.cwd();
6
6
  exports.VARLET_CONFIG = (0, path_1.resolve)(exports.CWD, 'varlet.config.js');
7
7
  exports.SRC_DIR = (0, path_1.resolve)(exports.CWD, 'src');
8
8
  exports.ES_DIR = (0, path_1.resolve)(exports.CWD, 'es');
9
+ exports.LIB_DIR = (0, path_1.resolve)(exports.CWD, 'lib');
9
10
  exports.UMD_DIR = (0, path_1.resolve)(exports.CWD, 'umd');
10
11
  exports.TYPES_DIR = (0, path_1.resolve)(exports.CWD, 'types');
11
12
  exports.ROOT_DOCS_DIR = (0, path_1.resolve)(exports.CWD, 'docs');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "1.23.0",
3
+ "version": "1.23.4-alpha.1+2a8848a6",
4
4
  "description": "cli of varlet",
5
5
  "bin": {
6
6
  "varlet-cli": "./lib/index.js"
@@ -31,7 +31,7 @@
31
31
  "dev": "tsc --watch",
32
32
  "build": "tsc"
33
33
  },
34
- "gitHead": "6ed02c99899e1c2d716c303be1a860b0ed2feff5",
34
+ "gitHead": "2a8848a6f064aa91d56875ba467c46da79589a79",
35
35
  "dependencies": {
36
36
  "@babel/core": "^7.14.8",
37
37
  "@babel/preset-env": "^7.14.8",