@varlet/cli 2.14.2 → 2.15.0-alpha.1692990022445
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.md +7 -2
- package/README.zh-CN.md +7 -2
- package/lib/node/bin.js +16 -17
- package/lib/node/commands/test.d.ts +7 -0
- package/lib/node/commands/test.js +16 -0
- package/lib/node/config/vitest.config.d.ts +2 -0
- package/lib/node/config/vitest.config.js +22 -0
- package/lib/node/index.d.ts +1 -1
- package/lib/node/index.js +1 -1
- package/lib/node/shared/constant.d.ts +1 -1
- package/lib/node/shared/constant.js +1 -2
- package/package.json +12 -12
- package/template/generators/base/README.md +6 -2
- package/template/generators/base/package.json +7 -4
- package/cjs/jest.config.cjs +0 -38
- package/cjs/jest.media.mock.cjs +0 -1
- package/cjs/jest.style.mock.cjs +0 -1
- package/lib/node/commands/jest.d.ts +0 -7
- package/lib/node/commands/jest.js +0 -27
package/README.md
CHANGED
|
@@ -170,8 +170,13 @@ varlet-cli test
|
|
|
170
170
|
```shell
|
|
171
171
|
# playground-ignore
|
|
172
172
|
varlet-cli test -w
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
#### Execute unit tests and report coverage
|
|
176
|
+
|
|
177
|
+
```shell
|
|
178
|
+
# playground-ignore
|
|
179
|
+
varlet-cli test -cov
|
|
175
180
|
```
|
|
176
181
|
|
|
177
182
|
#### Lint the code
|
package/README.zh-CN.md
CHANGED
package/lib/node/bin.js
CHANGED
|
@@ -87,15 +87,14 @@ program
|
|
|
87
87
|
return create(options);
|
|
88
88
|
});
|
|
89
89
|
program
|
|
90
|
-
.command('
|
|
91
|
-
.description('Run
|
|
90
|
+
.command('test')
|
|
91
|
+
.description('Run test in work directory')
|
|
92
92
|
.option('-w, --watch', 'Watch files for changes and rerun tests related to changed files')
|
|
93
|
-
.option('-wa, --watchAll', 'Watch files for changes and rerun all tests when something changes')
|
|
94
93
|
.option('-c, --component <componentName>', 'Test a specific component')
|
|
95
|
-
.option('-
|
|
96
|
-
.action(async (
|
|
97
|
-
const {
|
|
98
|
-
return
|
|
94
|
+
.option('-cov, --coverage', 'Generate the coverage')
|
|
95
|
+
.action(async (options) => {
|
|
96
|
+
const { test } = await import('./commands/test.js');
|
|
97
|
+
return test(options);
|
|
99
98
|
});
|
|
100
99
|
program
|
|
101
100
|
.command('gen')
|
|
@@ -104,40 +103,40 @@ program
|
|
|
104
103
|
.option('-s, --sfc', 'Generate files in sfc format')
|
|
105
104
|
.option('-t, --tsx', 'Generate files in tsx format')
|
|
106
105
|
.option('-l, --locale', 'Generator internationalized files')
|
|
107
|
-
.action(async (
|
|
106
|
+
.action(async (options) => {
|
|
108
107
|
const { gen } = await import('./commands/gen.js');
|
|
109
|
-
return gen(
|
|
108
|
+
return gen(options);
|
|
110
109
|
});
|
|
111
110
|
program
|
|
112
111
|
.command('changelog')
|
|
113
112
|
.option('-rc --releaseCount <releaseCount>', 'Release count')
|
|
114
113
|
.option('-f --file <file>', 'Changelog filename')
|
|
115
114
|
.description('Generate changelog')
|
|
116
|
-
.action(async (
|
|
115
|
+
.action(async (options) => {
|
|
117
116
|
const { changelog } = await import('./commands/changelog.js');
|
|
118
|
-
return changelog(
|
|
117
|
+
return changelog(options);
|
|
119
118
|
});
|
|
120
119
|
program
|
|
121
120
|
.command('release')
|
|
122
121
|
.option('-r --remote <remote>', 'Remote name')
|
|
123
122
|
.description('Release all packages and generate changelogs')
|
|
124
|
-
.action(async (
|
|
123
|
+
.action(async (options) => {
|
|
125
124
|
const { release } = await import('./commands/release.js');
|
|
126
|
-
return release(
|
|
125
|
+
return release(options);
|
|
127
126
|
});
|
|
128
127
|
program
|
|
129
128
|
.command('commit-lint <gitParams>')
|
|
130
129
|
.description('Lint commit message')
|
|
131
|
-
.action(async (
|
|
130
|
+
.action(async (options) => {
|
|
132
131
|
const { commitLint } = await import('./commands/commitLint.js');
|
|
133
|
-
return commitLint(
|
|
132
|
+
return commitLint(options);
|
|
134
133
|
});
|
|
135
134
|
program
|
|
136
135
|
.command('checklist <gitParams>')
|
|
137
136
|
.description('Display a checklist for confirmation')
|
|
138
|
-
.action(async (
|
|
137
|
+
.action(async (options) => {
|
|
139
138
|
const { checklist } = await import('./commands/checklist.js');
|
|
140
|
-
return checklist(
|
|
139
|
+
return checklist(options);
|
|
141
140
|
});
|
|
142
141
|
program.on('command:*', async ([cmd]) => {
|
|
143
142
|
const { default: logger } = await import('./shared/logger.js');
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import execa from 'execa';
|
|
2
|
+
import { VITEST_CONFIG } from '../shared/constant.js';
|
|
3
|
+
export async function test({ component, watch, coverage }) {
|
|
4
|
+
process.env.NODE_ENV = 'test';
|
|
5
|
+
const args = ['--config', VITEST_CONFIG];
|
|
6
|
+
if (!watch) {
|
|
7
|
+
args.unshift('run');
|
|
8
|
+
}
|
|
9
|
+
if (coverage) {
|
|
10
|
+
args.push('--coverage');
|
|
11
|
+
}
|
|
12
|
+
if (component) {
|
|
13
|
+
args.push('--dir', `src/${component.trim()}`);
|
|
14
|
+
}
|
|
15
|
+
await execa('vitest', args, { stdin: 'inherit', stdout: 'inherit', stderr: 'inherit' });
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import vue from '@vitejs/plugin-vue';
|
|
2
|
+
import jsx from '@vitejs/plugin-vue-jsx';
|
|
3
|
+
import { defineConfig } from 'vitest/config';
|
|
4
|
+
import { VITE_RESOLVE_EXTENSIONS } from '../shared/constant.js';
|
|
5
|
+
import { cpus } from 'os';
|
|
6
|
+
const cpuNum = Math.max(cpus().length - 1, 1);
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
resolve: {
|
|
9
|
+
extensions: VITE_RESOLVE_EXTENSIONS,
|
|
10
|
+
},
|
|
11
|
+
plugins: [vue(), jsx()],
|
|
12
|
+
test: {
|
|
13
|
+
environment: 'jsdom',
|
|
14
|
+
coverage: {
|
|
15
|
+
provider: 'istanbul',
|
|
16
|
+
exclude: ['**/example/**', '**/__tests__/**'],
|
|
17
|
+
},
|
|
18
|
+
globals: true,
|
|
19
|
+
experimentalVmThreads: true,
|
|
20
|
+
experimentalVmWorkerMemoryLimit: Math.min((1 / cpuNum) * 2, 0.2),
|
|
21
|
+
},
|
|
22
|
+
});
|
package/lib/node/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export * from './commands/build.js';
|
|
|
5
5
|
export * from './commands/compile.js';
|
|
6
6
|
export * from './commands/commitLint.js';
|
|
7
7
|
export * from './commands/gen.js';
|
|
8
|
-
export * from './commands/
|
|
8
|
+
export * from './commands/test.js';
|
|
9
9
|
export * from './commands/create.js';
|
|
10
10
|
export * from './commands/lint.js';
|
|
11
11
|
export * from './commands/changelog.js';
|
package/lib/node/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export * from './commands/build.js';
|
|
|
5
5
|
export * from './commands/compile.js';
|
|
6
6
|
export * from './commands/commitLint.js';
|
|
7
7
|
export * from './commands/gen.js';
|
|
8
|
-
export * from './commands/
|
|
8
|
+
export * from './commands/test.js';
|
|
9
9
|
export * from './commands/create.js';
|
|
10
10
|
export * from './commands/lint.js';
|
|
11
11
|
export * from './commands/changelog.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const dirname: string;
|
|
2
2
|
export declare const CWD: string;
|
|
3
3
|
export declare const VARLET_CONFIG: string;
|
|
4
|
+
export declare const VITEST_CONFIG: string;
|
|
4
5
|
export declare const SRC_DIR: string;
|
|
5
6
|
export declare const ES_DIR: string;
|
|
6
7
|
export declare const LIB_DIR: string;
|
|
@@ -48,4 +49,3 @@ export declare const ICONS_PNG_DIR: string;
|
|
|
48
49
|
export declare const ICONS_FONTS_DIR: string;
|
|
49
50
|
export declare const ICONS_SVG_DIR: string;
|
|
50
51
|
export declare const EXTENSION_ENTRY: string;
|
|
51
|
-
export declare const JEST_CONFIG: string;
|
|
@@ -3,6 +3,7 @@ import { getDirname } from './fsUtils.js';
|
|
|
3
3
|
export const dirname = getDirname(import.meta.url);
|
|
4
4
|
export const CWD = process.cwd();
|
|
5
5
|
export const VARLET_CONFIG = resolve(CWD, 'varlet.config.mjs');
|
|
6
|
+
export const VITEST_CONFIG = resolve(dirname, '../config/vitest.config.js');
|
|
6
7
|
export const SRC_DIR = resolve(CWD, 'src');
|
|
7
8
|
export const ES_DIR = resolve(CWD, 'es');
|
|
8
9
|
export const LIB_DIR = resolve(CWD, 'lib');
|
|
@@ -54,5 +55,3 @@ export const ICONS_FONTS_DIR = resolve(ICONS_DIST_DIR, 'fonts');
|
|
|
54
55
|
export const ICONS_SVG_DIR = resolve(CWD, 'svg');
|
|
55
56
|
// extension
|
|
56
57
|
export const EXTENSION_ENTRY = resolve(CWD, 'src/extension.ts');
|
|
57
|
-
// jest
|
|
58
|
-
export const JEST_CONFIG = resolve(dirname, '../../../cjs/jest.config.cjs');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0-alpha.1692990022445",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cli of varlet",
|
|
6
6
|
"bin": {
|
|
@@ -45,8 +45,7 @@
|
|
|
45
45
|
"@vue/babel-plugin-jsx": "1.1.4",
|
|
46
46
|
"@vue/compiler-sfc": "3.3.4",
|
|
47
47
|
"@vue/runtime-core": "3.3.4",
|
|
48
|
-
"
|
|
49
|
-
"babel-jest": "^29.5.0",
|
|
48
|
+
"vitest": "0.34.3",
|
|
50
49
|
"chokidar": "^3.5.2",
|
|
51
50
|
"commander": "^8.3.0",
|
|
52
51
|
"conventional-changelog": "^3.1.25",
|
|
@@ -56,8 +55,6 @@
|
|
|
56
55
|
"glob": "^7.2.0",
|
|
57
56
|
"hash-sum": "^2.0.0",
|
|
58
57
|
"inquirer": "^9.1.4",
|
|
59
|
-
"jest": "^29.5.0",
|
|
60
|
-
"jest-environment-jsdom": "^29.5.0",
|
|
61
58
|
"less": "^3.12.2",
|
|
62
59
|
"lodash-es": "^4.17.21",
|
|
63
60
|
"markdown-it": "^12.2.3",
|
|
@@ -70,8 +67,8 @@
|
|
|
70
67
|
"vite": "4.3.5",
|
|
71
68
|
"vue": "3.3.4",
|
|
72
69
|
"webfont": "^9.0.0",
|
|
73
|
-
"@varlet/
|
|
74
|
-
"@varlet/
|
|
70
|
+
"@varlet/shared": "2.15.0-alpha.1692990022445",
|
|
71
|
+
"@varlet/vite-plugins": "2.15.0-alpha.1692990022445"
|
|
75
72
|
},
|
|
76
73
|
"devDependencies": {
|
|
77
74
|
"@types/babel__core": "^7.20.1",
|
|
@@ -86,19 +83,22 @@
|
|
|
86
83
|
"@types/semver": "^7.3.9",
|
|
87
84
|
"@types/sharp": "0.31.1",
|
|
88
85
|
"rimraf": "^5.0.1",
|
|
89
|
-
"@varlet/
|
|
90
|
-
"@varlet/
|
|
86
|
+
"@varlet/touch-emulator": "2.15.0-alpha.1692990022445",
|
|
87
|
+
"@varlet/icons": "2.15.0-alpha.1692990022445"
|
|
91
88
|
},
|
|
92
89
|
"peerDependencies": {
|
|
93
90
|
"@vue/runtime-core": "3.3.4",
|
|
94
|
-
"@vue/test-utils": "2.
|
|
91
|
+
"@vue/test-utils": "2.4.1",
|
|
92
|
+
"@vitest/coverage-istanbul": "0.34.3",
|
|
93
|
+
"vitest": "0.34.3",
|
|
94
|
+
"jsdom": "22.1.0",
|
|
95
95
|
"clipboard": "^2.0.6",
|
|
96
96
|
"live-server": "^1.2.1",
|
|
97
97
|
"lodash-es": "^4.17.21",
|
|
98
98
|
"vue": "3.3.4",
|
|
99
99
|
"vue-router": "4.2.0",
|
|
100
|
-
"@varlet/icons": "2.
|
|
101
|
-
"@varlet/touch-emulator": "2.
|
|
100
|
+
"@varlet/icons": "2.15.0-alpha.1692990022445",
|
|
101
|
+
"@varlet/touch-emulator": "2.15.0-alpha.1692990022445"
|
|
102
102
|
},
|
|
103
103
|
"scripts": {
|
|
104
104
|
"dev": "tsc --watch",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"lint": "varlet-cli lint",
|
|
29
29
|
"changelog": "varlet-cli changelog",
|
|
30
30
|
"release": "pnpm compile && varlet-cli release",
|
|
31
|
-
"test": "varlet-cli
|
|
32
|
-
"test:watch": "varlet-cli
|
|
33
|
-
"test:
|
|
31
|
+
"test": "varlet-cli test",
|
|
32
|
+
"test:watch": "varlet-cli test -w",
|
|
33
|
+
"test:coverage": "varlet-cli test -cov",
|
|
34
34
|
"create": "varlet-cli create"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
@@ -42,8 +42,11 @@
|
|
|
42
42
|
"@varlet/icons": "workspace:*",
|
|
43
43
|
"@varlet/touch-emulator": "workspace:*",
|
|
44
44
|
"@varlet/shared": "workspace:*",
|
|
45
|
-
"@vue/test-utils": "2.
|
|
45
|
+
"@vue/test-utils": "2.4.1",
|
|
46
46
|
"@vue/runtime-core": "3.3.4",
|
|
47
|
+
"@vitest/coverage-istanbul": "0.34.3",
|
|
48
|
+
"jsdom": "22.1.0",
|
|
49
|
+
"vitest": "0.34.3",
|
|
47
50
|
"clipboard": "^2.0.6",
|
|
48
51
|
"eslint": "^8.43.0",
|
|
49
52
|
"lint-staged": "^10.5.0",
|
package/cjs/jest.config.cjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const { resolve } = require('path')
|
|
2
|
-
const { pathExistsSync } = require('fs-extra')
|
|
3
|
-
|
|
4
|
-
const JEST_MEDIA_MOCK = resolve(__dirname, 'jest.media.mock.cjs')
|
|
5
|
-
const JEST_STYLE_MOCK = resolve(__dirname, 'jest.style.mock.cjs')
|
|
6
|
-
|
|
7
|
-
function getRootConfig() {
|
|
8
|
-
const file = resolve(process.cwd(), 'jest.config.js')
|
|
9
|
-
|
|
10
|
-
if (pathExistsSync(file)) {
|
|
11
|
-
delete require.cache[require.resolve(file)]
|
|
12
|
-
return require(file)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return {}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
module.exports = {
|
|
19
|
-
testEnvironment: 'jsdom',
|
|
20
|
-
coverageProvider: 'v8',
|
|
21
|
-
testEnvironmentOptions: {
|
|
22
|
-
customExportConditions: ['node', 'node-addons'],
|
|
23
|
-
},
|
|
24
|
-
moduleNameMapper: {
|
|
25
|
-
'^@config$': '<rootDir>/.varlet/site.config.json',
|
|
26
|
-
'\\.(css|less)$': JEST_STYLE_MOCK,
|
|
27
|
-
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': JEST_MEDIA_MOCK,
|
|
28
|
-
},
|
|
29
|
-
transform: {
|
|
30
|
-
'\\.(vue)$': '@vue/vue3-jest',
|
|
31
|
-
'\\.(js|jsx|ts|tsx)$': 'babel-jest',
|
|
32
|
-
},
|
|
33
|
-
collectCoverage: true,
|
|
34
|
-
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx,vue}', `!**/example/**`, `!**/docs/**`, `!**/__tests__/**`],
|
|
35
|
-
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'vue'],
|
|
36
|
-
transformIgnorePatterns: [],
|
|
37
|
-
...getRootConfig(),
|
|
38
|
-
}
|
package/cjs/jest.media.mock.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = {}
|
package/cjs/jest.style.mock.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = {}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import logger from '../shared/logger.js';
|
|
2
|
-
import jestModule from 'jest';
|
|
3
|
-
import { CWD, JEST_CONFIG } from '../shared/constant.js';
|
|
4
|
-
import { buildSiteEntry } from '../compiler/compileSiteEntry.js';
|
|
5
|
-
const { runCLI } = jestModule;
|
|
6
|
-
export async function jest(cmd) {
|
|
7
|
-
process.env.NODE_ENV = 'test';
|
|
8
|
-
const config = {
|
|
9
|
-
rootDir: CWD,
|
|
10
|
-
watch: cmd.watch,
|
|
11
|
-
watchAll: cmd.watchAll,
|
|
12
|
-
clearCache: cmd.clearCache,
|
|
13
|
-
config: JEST_CONFIG,
|
|
14
|
-
testRegex: cmd.component && `${cmd.component}/__tests__/.*.spec.[jt]s?$`,
|
|
15
|
-
};
|
|
16
|
-
await buildSiteEntry(false);
|
|
17
|
-
try {
|
|
18
|
-
const response = await runCLI(config, [CWD]);
|
|
19
|
-
if (!response.results.success && !cmd.watch) {
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
catch (e) {
|
|
24
|
-
logger.error(e.toString());
|
|
25
|
-
process.exit(1);
|
|
26
|
-
}
|
|
27
|
-
}
|