@bemedev/dev-utils 0.3.2 → 0.5.0
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 +60 -3
- package/lib/rolldown-config/config.cjs +3 -4
- package/lib/rolldown-config/config.cjs.map +1 -1
- package/lib/rolldown-config/config.js +2 -2
- package/lib/rolldown-config/config.js.map +1 -1
- package/lib/vitest-exclude/index.cjs +1 -0
- package/lib/vitest-exclude/index.js +2 -2
- package/lib/vitest-exclude/vitest.cjs +29 -4
- package/lib/vitest-exclude/vitest.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.d.ts +16 -0
- package/lib/vitest-exclude/vitest.js +29 -5
- package/lib/vitest-exclude/vitest.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -31,13 +31,16 @@ yarn add @bemedev/dev-utils
|
|
|
31
31
|
|
|
32
32
|
## Usage
|
|
33
33
|
|
|
34
|
-
Each module is available as a dedicated sub-path export — there is no
|
|
35
|
-
|
|
34
|
+
Each module is available as a dedicated sub-path export — there is no root
|
|
35
|
+
barrel export:
|
|
36
36
|
|
|
37
37
|
```typescript
|
|
38
38
|
import { createAlias, aliasTs } from '@bemedev/dev-utils/vitest-alias';
|
|
39
39
|
import { exclude } from '@bemedev/dev-utils/vitest-exclude';
|
|
40
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
createTests,
|
|
42
|
+
createFakeWaiter,
|
|
43
|
+
} from '@bemedev/dev-utils/vitest-extended';
|
|
41
44
|
import { defineConfig } from '@bemedev/dev-utils/rolldown';
|
|
42
45
|
import { addTarball, cleanup } from '@bemedev/dev-utils/build-tests';
|
|
43
46
|
```
|
|
@@ -167,6 +170,60 @@ exclude.withPattern(
|
|
|
167
170
|
|
|
168
171
|
---
|
|
169
172
|
|
|
173
|
+
### `create(args?)`
|
|
174
|
+
|
|
175
|
+
Plain async function (not a plugin) that resolves glob patterns and returns
|
|
176
|
+
`{ files, coverage }` string arrays using the default patterns.
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import { create } from '@bemedev/dev-utils/vitest-exclude';
|
|
180
|
+
|
|
181
|
+
const { files, coverage } = await create({
|
|
182
|
+
ignoreTestFiles: ['src/fixtures/**'],
|
|
183
|
+
ignoreCoverageFiles: ['src/**/*.types.ts'],
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Parameters (`args`)**
|
|
188
|
+
|
|
189
|
+
| Property | Type | Description |
|
|
190
|
+
| --------------------- | ----------------------- | -------------------------------------------- |
|
|
191
|
+
| `ignoreTestFiles` | `string[] \| undefined` | Glob patterns to exclude from test discovery |
|
|
192
|
+
| `ignoreCoverageFiles` | `string[] \| undefined` | Glob patterns to exclude from coverage |
|
|
193
|
+
|
|
194
|
+
**Returns** `Promise<{ files: string[]; coverage: string[] }>`.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
### `create.withPattern(patterns, args)`
|
|
199
|
+
|
|
200
|
+
Same as `create`, but accepts custom glob patterns for both test and
|
|
201
|
+
coverage discovery.
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
import { create } from '@bemedev/dev-utils/vitest-exclude';
|
|
205
|
+
|
|
206
|
+
const { files, coverage } = await create.withPattern(
|
|
207
|
+
{
|
|
208
|
+
patternTest: 'tests/**/*.test.ts',
|
|
209
|
+
patternCov: 'src/**/*.ts',
|
|
210
|
+
},
|
|
211
|
+
{ ignoreTestFiles: ['tests/fixtures/**'] },
|
|
212
|
+
);
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Parameters**
|
|
216
|
+
|
|
217
|
+
| Name | Type | Description |
|
|
218
|
+
| ------------- | -------------------- | ----------------------------------- |
|
|
219
|
+
| `patternTest` | `string \| string[]` | Glob(s) for test file discovery |
|
|
220
|
+
| `patternCov` | `string \| string[]` | Glob(s) for coverage file discovery |
|
|
221
|
+
| `args` | same as `create` | Optional ignore lists |
|
|
222
|
+
|
|
223
|
+
**Returns** `Promise<{ files: string[]; coverage: string[] }>`.
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
170
227
|
## `vitestExtended`
|
|
171
228
|
|
|
172
229
|
Extended helpers for writing structured, type-safe Vitest tests.
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
const require_rolldown_config_utils = require("./utils.cjs");
|
|
4
4
|
const require_rolldown_config_output = require("./output.cjs");
|
|
5
5
|
const require_rolldown_config_constants = require("./constants.cjs");
|
|
6
6
|
const require_rolldown_config_input = require("./input.cjs");
|
|
7
7
|
const require_rolldown_config_plugins_index = require("./plugins/index.cjs");
|
|
8
|
-
let path = require("path");
|
|
9
|
-
path = require_runtime.__toESM(path);
|
|
10
8
|
let rolldown = require("rolldown");
|
|
9
|
+
let rolldown_plugins = require("rolldown/plugins");
|
|
11
10
|
//#region src/rolldown-config/config.ts
|
|
12
11
|
const defineConfig = (additionals) => {
|
|
13
12
|
return defineConfig.default(additionals);
|
|
@@ -42,6 +41,7 @@ const producePlugins = ({ circularDeps, ignoresJS, dir = "lib", sourcemap = fals
|
|
|
42
41
|
unordered.circulars(),
|
|
43
42
|
unordered.externals(),
|
|
44
43
|
unordered.typescript(),
|
|
44
|
+
(0, rolldown_plugins.esmExternalRequirePlugin)(),
|
|
45
45
|
unordered.clean()
|
|
46
46
|
];
|
|
47
47
|
return plugins ? plugins.map((p) => {
|
|
@@ -62,7 +62,6 @@ defineConfig.default = ({ dir = "lib", sourcemap = false, ...rest } = {}) => {
|
|
|
62
62
|
}),
|
|
63
63
|
external,
|
|
64
64
|
output,
|
|
65
|
-
transform: { inject: { require: path.default.resolve("./require.js") } },
|
|
66
65
|
platform: "node"
|
|
67
66
|
});
|
|
68
67
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs","names":["buildInput","toArray","DEFAULT_EXCLUDE","PLUGIN_BUILDERS","buildOutput","DEFAULT_CIRCULAR_DEPS"],"sources":["../../src/rolldown-config/config.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"config.cjs","names":["buildInput","toArray","DEFAULT_EXCLUDE","PLUGIN_BUILDERS","buildOutput","DEFAULT_CIRCULAR_DEPS"],"sources":["../../src/rolldown-config/config.ts"],"sourcesContent":["import { defineConfig as _defineConfig } from 'rolldown';\nimport { esmExternalRequirePlugin } from 'rolldown/plugins';\nimport {\n DEFAULT_CIRCULAR_DEPS,\n DEFAULT_DIR,\n DEFAULT_EXCLUDE,\n} from './constants';\nimport { buildInput } from './input';\nimport { buildOutput } from './output';\nimport { PLUGIN_BUILDERS } from './plugins';\nimport type { Config_F, Params } from './types';\nimport { toArray } from './utils';\n\nexport const defineConfig: Config_F = additionals => {\n return defineConfig.default(additionals);\n};\n\nconst producePlugins = ({\n circularDeps,\n ignoresJS,\n dir = DEFAULT_DIR,\n sourcemap = false,\n excludesTS,\n declarationMap,\n plugins,\n}: Params = {}) => {\n const include = buildInput(...toArray(excludesTS));\n const exclude = DEFAULT_EXCLUDE.concat(toArray(excludesTS));\n const unordered = {\n alias: () => PLUGIN_BUILDERS.alias(),\n typescript: () =>\n PLUGIN_BUILDERS.typescript({\n include,\n exclude,\n declarationMap,\n dir,\n }),\n circulars: () =>\n PLUGIN_BUILDERS.circulars({\n exclude: circularDeps,\n }),\n externals: () =>\n PLUGIN_BUILDERS.externals({\n // exclude peerDependencies and dependencies\n optDeps: false,\n builtinsPrefix: 'strip',\n include: excludesTS,\n }),\n tsPaths: () => PLUGIN_BUILDERS.tsPaths({ colors: true }),\n clean: () =>\n PLUGIN_BUILDERS.clean({\n ignoresJS,\n sourcemap,\n dir,\n }),\n };\n\n const defaultOrdered = () => [\n unordered.alias(),\n unordered.tsPaths(),\n unordered.circulars(),\n unordered.externals(),\n unordered.typescript(),\n esmExternalRequirePlugin(),\n unordered.clean(),\n ];\n\n return plugins\n ? plugins\n .map(p => {\n if (typeof p === 'string') return unordered[p]();\n return p;\n })\n .filter(p => !!p)\n : defaultOrdered();\n};\n\ndefineConfig.default = ({\n dir = DEFAULT_DIR,\n sourcemap = false,\n ...rest\n}: Params = {}) => {\n const input = buildInput();\n const external = rest.externals;\n const output = buildOutput(dir, sourcemap);\n\n const plugins = producePlugins({\n dir,\n sourcemap,\n ...rest,\n });\n\n return _defineConfig({\n input,\n plugins,\n external,\n output,\n platform: 'node',\n });\n};\n\ndefineConfig.bemedev = additionals => {\n // #region constants\n const circularDeps = DEFAULT_CIRCULAR_DEPS.concat(\n toArray(additionals?.circularDeps),\n );\n const ignoresJS = toArray(additionals?.ignoresJS).concat(\n DEFAULT_CIRCULAR_DEPS,\n );\n\n const excludesTS = DEFAULT_EXCLUDE.concat(\n toArray(additionals?.excludesTS),\n );\n const _sourcemap = additionals?.sourcemap;\n const sourcemap = _sourcemap === undefined || _sourcemap === true;\n // #endregion\n\n return defineConfig.default({\n ...additionals,\n circularDeps,\n excludesTS,\n ignoresJS,\n sourcemap,\n });\n};\n"],"mappings":";;;;;;;;;;AAaA,MAAa,gBAAyB,gBAAe;AACnD,QAAO,aAAa,QAAQ,YAAY;;AAG1C,MAAM,kBAAkB,EACtB,cACA,WACA,MAAA,OACA,YAAY,OACZ,YACA,gBACA,YACU,EAAE,KAAK;CACjB,MAAM,UAAUA,8BAAAA,WAAW,GAAGC,8BAAAA,QAAQ,WAAW,CAAC;CAClD,MAAM,UAAUC,kCAAAA,gBAAgB,OAAOD,8BAAAA,QAAQ,WAAW,CAAC;CAC3D,MAAM,YAAY;EAChB,aAAaE,sCAAAA,gBAAgB,OAAO;EACpC,kBACEA,sCAAAA,gBAAgB,WAAW;GACzB;GACA;GACA;GACA;GACD,CAAC;EACJ,iBACEA,sCAAAA,gBAAgB,UAAU,EACxB,SAAS,cACV,CAAC;EACJ,iBACEA,sCAAAA,gBAAgB,UAAU;GAExB,SAAS;GACT,gBAAgB;GAChB,SAAS;GACV,CAAC;EACJ,eAAeA,sCAAAA,gBAAgB,QAAQ,EAAE,QAAQ,MAAM,CAAC;EACxD,aACEA,sCAAAA,gBAAgB,MAAM;GACpB;GACA;GACA;GACD,CAAC;EACL;CAED,MAAM,uBAAuB;EAC3B,UAAU,OAAO;EACjB,UAAU,SAAS;EACnB,UAAU,WAAW;EACrB,UAAU,WAAW;EACrB,UAAU,YAAY;kDACI;EAC1B,UAAU,OAAO;EAClB;AAED,QAAO,UACH,QACG,KAAI,MAAK;AACR,MAAI,OAAO,MAAM,SAAU,QAAO,UAAU,IAAI;AAChD,SAAO;GACP,CACD,QAAO,MAAK,CAAC,CAAC,EAAE,GACnB,gBAAgB;;AAGtB,aAAa,WAAW,EACtB,MAAA,OACA,YAAY,OACZ,GAAG,SACO,EAAE,KAAK;CACjB,MAAM,QAAQH,8BAAAA,YAAY;CAC1B,MAAM,WAAW,KAAK;CACtB,MAAM,SAASI,+BAAAA,YAAY,KAAK,UAAU;AAQ1C,SAAA,GAAA,SAAA,cAAqB;EACnB;EACA,SARc,eAAe;GAC7B;GACA;GACA,GAAG;GACJ,CAAC;EAKA;EACA;EACA,UAAU;EACX,CAAC;;AAGJ,aAAa,WAAU,gBAAe;CAEpC,MAAM,eAAeC,kCAAAA,sBAAsB,OACzCJ,8BAAAA,QAAQ,aAAa,aAAa,CACnC;CACD,MAAM,YAAYA,8BAAAA,QAAQ,aAAa,UAAU,CAAC,OAChDI,kCAAAA,sBACD;CAED,MAAM,aAAaH,kCAAAA,gBAAgB,OACjCD,8BAAAA,QAAQ,aAAa,WAAW,CACjC;CACD,MAAM,aAAa,aAAa;CAChC,MAAM,YAAY,eAAe,KAAA,KAAa,eAAe;AAG7D,QAAO,aAAa,QAAQ;EAC1B,GAAG;EACH;EACA;EACA;EACA;EACD,CAAC"}
|
|
@@ -3,8 +3,8 @@ import { buildOutput } from "./output.js";
|
|
|
3
3
|
import { DEFAULT_CIRCULAR_DEPS, DEFAULT_EXCLUDE } from "./constants.js";
|
|
4
4
|
import { buildInput } from "./input.js";
|
|
5
5
|
import { PLUGIN_BUILDERS } from "./plugins/index.js";
|
|
6
|
-
import path from "path";
|
|
7
6
|
import { defineConfig as defineConfig$1 } from "rolldown";
|
|
7
|
+
import { esmExternalRequirePlugin } from "rolldown/plugins";
|
|
8
8
|
//#region src/rolldown-config/config.ts
|
|
9
9
|
const defineConfig = (additionals) => {
|
|
10
10
|
return defineConfig.default(additionals);
|
|
@@ -39,6 +39,7 @@ const producePlugins = ({ circularDeps, ignoresJS, dir = "lib", sourcemap = fals
|
|
|
39
39
|
unordered.circulars(),
|
|
40
40
|
unordered.externals(),
|
|
41
41
|
unordered.typescript(),
|
|
42
|
+
esmExternalRequirePlugin(),
|
|
42
43
|
unordered.clean()
|
|
43
44
|
];
|
|
44
45
|
return plugins ? plugins.map((p) => {
|
|
@@ -59,7 +60,6 @@ defineConfig.default = ({ dir = "lib", sourcemap = false, ...rest } = {}) => {
|
|
|
59
60
|
}),
|
|
60
61
|
external,
|
|
61
62
|
output,
|
|
62
|
-
transform: { inject: { require: path.resolve("./require.js") } },
|
|
63
63
|
platform: "node"
|
|
64
64
|
});
|
|
65
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["_defineConfig"],"sources":["../../src/rolldown-config/config.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"config.js","names":["_defineConfig"],"sources":["../../src/rolldown-config/config.ts"],"sourcesContent":["import { defineConfig as _defineConfig } from 'rolldown';\nimport { esmExternalRequirePlugin } from 'rolldown/plugins';\nimport {\n DEFAULT_CIRCULAR_DEPS,\n DEFAULT_DIR,\n DEFAULT_EXCLUDE,\n} from './constants';\nimport { buildInput } from './input';\nimport { buildOutput } from './output';\nimport { PLUGIN_BUILDERS } from './plugins';\nimport type { Config_F, Params } from './types';\nimport { toArray } from './utils';\n\nexport const defineConfig: Config_F = additionals => {\n return defineConfig.default(additionals);\n};\n\nconst producePlugins = ({\n circularDeps,\n ignoresJS,\n dir = DEFAULT_DIR,\n sourcemap = false,\n excludesTS,\n declarationMap,\n plugins,\n}: Params = {}) => {\n const include = buildInput(...toArray(excludesTS));\n const exclude = DEFAULT_EXCLUDE.concat(toArray(excludesTS));\n const unordered = {\n alias: () => PLUGIN_BUILDERS.alias(),\n typescript: () =>\n PLUGIN_BUILDERS.typescript({\n include,\n exclude,\n declarationMap,\n dir,\n }),\n circulars: () =>\n PLUGIN_BUILDERS.circulars({\n exclude: circularDeps,\n }),\n externals: () =>\n PLUGIN_BUILDERS.externals({\n // exclude peerDependencies and dependencies\n optDeps: false,\n builtinsPrefix: 'strip',\n include: excludesTS,\n }),\n tsPaths: () => PLUGIN_BUILDERS.tsPaths({ colors: true }),\n clean: () =>\n PLUGIN_BUILDERS.clean({\n ignoresJS,\n sourcemap,\n dir,\n }),\n };\n\n const defaultOrdered = () => [\n unordered.alias(),\n unordered.tsPaths(),\n unordered.circulars(),\n unordered.externals(),\n unordered.typescript(),\n esmExternalRequirePlugin(),\n unordered.clean(),\n ];\n\n return plugins\n ? plugins\n .map(p => {\n if (typeof p === 'string') return unordered[p]();\n return p;\n })\n .filter(p => !!p)\n : defaultOrdered();\n};\n\ndefineConfig.default = ({\n dir = DEFAULT_DIR,\n sourcemap = false,\n ...rest\n}: Params = {}) => {\n const input = buildInput();\n const external = rest.externals;\n const output = buildOutput(dir, sourcemap);\n\n const plugins = producePlugins({\n dir,\n sourcemap,\n ...rest,\n });\n\n return _defineConfig({\n input,\n plugins,\n external,\n output,\n platform: 'node',\n });\n};\n\ndefineConfig.bemedev = additionals => {\n // #region constants\n const circularDeps = DEFAULT_CIRCULAR_DEPS.concat(\n toArray(additionals?.circularDeps),\n );\n const ignoresJS = toArray(additionals?.ignoresJS).concat(\n DEFAULT_CIRCULAR_DEPS,\n );\n\n const excludesTS = DEFAULT_EXCLUDE.concat(\n toArray(additionals?.excludesTS),\n );\n const _sourcemap = additionals?.sourcemap;\n const sourcemap = _sourcemap === undefined || _sourcemap === true;\n // #endregion\n\n return defineConfig.default({\n ...additionals,\n circularDeps,\n excludesTS,\n ignoresJS,\n sourcemap,\n });\n};\n"],"mappings":";;;;;;;;AAaA,MAAa,gBAAyB,gBAAe;AACnD,QAAO,aAAa,QAAQ,YAAY;;AAG1C,MAAM,kBAAkB,EACtB,cACA,WACA,MAAA,OACA,YAAY,OACZ,YACA,gBACA,YACU,EAAE,KAAK;CACjB,MAAM,UAAU,WAAW,GAAG,QAAQ,WAAW,CAAC;CAClD,MAAM,UAAU,gBAAgB,OAAO,QAAQ,WAAW,CAAC;CAC3D,MAAM,YAAY;EAChB,aAAa,gBAAgB,OAAO;EACpC,kBACE,gBAAgB,WAAW;GACzB;GACA;GACA;GACA;GACD,CAAC;EACJ,iBACE,gBAAgB,UAAU,EACxB,SAAS,cACV,CAAC;EACJ,iBACE,gBAAgB,UAAU;GAExB,SAAS;GACT,gBAAgB;GAChB,SAAS;GACV,CAAC;EACJ,eAAe,gBAAgB,QAAQ,EAAE,QAAQ,MAAM,CAAC;EACxD,aACE,gBAAgB,MAAM;GACpB;GACA;GACA;GACD,CAAC;EACL;CAED,MAAM,uBAAuB;EAC3B,UAAU,OAAO;EACjB,UAAU,SAAS;EACnB,UAAU,WAAW;EACrB,UAAU,WAAW;EACrB,UAAU,YAAY;EACtB,0BAA0B;EAC1B,UAAU,OAAO;EAClB;AAED,QAAO,UACH,QACG,KAAI,MAAK;AACR,MAAI,OAAO,MAAM,SAAU,QAAO,UAAU,IAAI;AAChD,SAAO;GACP,CACD,QAAO,MAAK,CAAC,CAAC,EAAE,GACnB,gBAAgB;;AAGtB,aAAa,WAAW,EACtB,MAAA,OACA,YAAY,OACZ,GAAG,SACO,EAAE,KAAK;CACjB,MAAM,QAAQ,YAAY;CAC1B,MAAM,WAAW,KAAK;CACtB,MAAM,SAAS,YAAY,KAAK,UAAU;AAQ1C,QAAOA,eAAc;EACnB;EACA,SARc,eAAe;GAC7B;GACA;GACA,GAAG;GACJ,CAAC;EAKA;EACA;EACA,UAAU;EACX,CAAC;;AAGJ,aAAa,WAAU,gBAAe;CAEpC,MAAM,eAAe,sBAAsB,OACzC,QAAQ,aAAa,aAAa,CACnC;CACD,MAAM,YAAY,QAAQ,aAAa,UAAU,CAAC,OAChD,sBACD;CAED,MAAM,aAAa,gBAAgB,OACjC,QAAQ,aAAa,WAAW,CACjC;CACD,MAAM,aAAa,aAAa;CAChC,MAAM,YAAY,eAAe,KAAA,KAAa,eAAe;AAG7D,QAAO,aAAa,QAAQ;EAC1B,GAAG;EACH;EACA;EACA;EACA;EACD,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { exclude } from "./vitest.js";
|
|
2
|
-
export { exclude };
|
|
1
|
+
import { create, exclude } from "./vitest.js";
|
|
2
|
+
export { create, exclude };
|
|
@@ -3,6 +3,25 @@ const require_vitest_exclude_vitest_utils = require("./vitest.utils.cjs");
|
|
|
3
3
|
const require_vitest_exclude_constants = require("./constants.cjs");
|
|
4
4
|
//#region src/vitest-exclude/vitest.ts
|
|
5
5
|
/**
|
|
6
|
+
* Create includeTest and includeCoverage arrays from glob patterns
|
|
7
|
+
*
|
|
8
|
+
* @param args Globs to ignore for test and coverage files
|
|
9
|
+
* @returns an object with includeTest and includeCoverage string arrays
|
|
10
|
+
*/
|
|
11
|
+
async function create(args = {}) {
|
|
12
|
+
const firsts = {
|
|
13
|
+
patternTest: require_vitest_exclude_vitest_utils.testPattern(),
|
|
14
|
+
patternCov: require_vitest_exclude_vitest_utils.defaultCovPattern()
|
|
15
|
+
};
|
|
16
|
+
return create.withPattern(firsts, args);
|
|
17
|
+
}
|
|
18
|
+
create.withPattern = async ({ patternTest = require_vitest_exclude_vitest_utils.testPattern(), patternCov = require_vitest_exclude_vitest_utils.defaultCovPattern() } = {}, { ignoreTestFiles, ignoreCoverageFiles } = {}) => {
|
|
19
|
+
return {
|
|
20
|
+
files: await require_vitest_exclude_vitest_utils.buildInclude(patternTest, ignoreTestFiles),
|
|
21
|
+
coverage: await require_vitest_exclude_vitest_utils.buildInclude(patternCov, ignoreCoverageFiles)
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
6
25
|
* Plugin to add files with glob patterns to vitest
|
|
7
26
|
*
|
|
8
27
|
* @param ignore globs to exclude inside
|
|
@@ -35,16 +54,21 @@ exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, igno
|
|
|
35
54
|
config: async (options) => {
|
|
36
55
|
const testConfig = options?.test;
|
|
37
56
|
const coverage = options?.test?.coverage;
|
|
38
|
-
const
|
|
39
|
-
|
|
57
|
+
const all = await create.withPattern({
|
|
58
|
+
patternTest,
|
|
59
|
+
patternCov
|
|
60
|
+
}, {
|
|
61
|
+
ignoreCoverageFiles,
|
|
62
|
+
ignoreTestFiles
|
|
63
|
+
});
|
|
40
64
|
return {
|
|
41
65
|
...options,
|
|
42
66
|
test: {
|
|
43
67
|
...testConfig,
|
|
44
|
-
include:
|
|
68
|
+
include: all.files,
|
|
45
69
|
coverage: {
|
|
46
70
|
...coverage,
|
|
47
|
-
include:
|
|
71
|
+
include: all.coverage
|
|
48
72
|
}
|
|
49
73
|
}
|
|
50
74
|
};
|
|
@@ -52,6 +76,7 @@ exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, igno
|
|
|
52
76
|
};
|
|
53
77
|
});
|
|
54
78
|
//#endregion
|
|
79
|
+
exports.create = create;
|
|
55
80
|
exports.exclude = exclude;
|
|
56
81
|
|
|
57
82
|
//# sourceMappingURL=vitest.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.cjs","names":["
|
|
1
|
+
{"version":3,"file":"vitest.cjs","names":["testPattern","defaultCovPattern","buildInclude"],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import { name } from './constants';\nimport type { Args, Plugin, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\n\n/**\n * Create includeTest and includeCoverage arrays from glob patterns\n *\n * @param args Globs to ignore for test and coverage files\n * @returns an object with includeTest and includeCoverage string arrays\n */\nexport async function create(args: Args[1] = {}) {\n const firsts = {\n patternTest: testPattern(),\n patternCov: defaultCovPattern(),\n };\n\n return create.withPattern(firsts, args);\n}\n\ncreate.withPattern = async (\n {\n patternTest = testPattern(),\n patternCov = defaultCovPattern(),\n }: Partial<Args[0]> = {},\n { ignoreTestFiles, ignoreCoverageFiles }: Args[1] = {},\n) => {\n const files = await buildInclude(patternTest, ignoreTestFiles);\n const coverage = await buildInclude(patternCov, ignoreCoverageFiles);\n return { files, coverage };\n};\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @param ignore globs to exclude inside\n * @returns a vitest config\n *\n * @see {@link exclude.withPattern}\n * @remarks\n * You don't have to use test.exclude.\n * The default search patter is './src/**\\/*.ts'\n */\nexport function exclude(args: Args[1] = {}) {\n const patternCov = defaultCovPattern();\n const patternTest = testPattern();\n return exclude.withPattern({ patternCov, patternTest }, args);\n}\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @param pattern The pattern where searching files\n * @param ignore globs to exclude inside\n * @returns a vitest config\n */\nexclude.withPattern = ((\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n): Plugin => {\n return {\n name,\n enforce: 'pre',\n config: async options => {\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: {\n ...coverage,\n include: all.coverage,\n },\n },\n };\n },\n };\n}) as WithPattern;\n"],"mappings":";;;;;;;;;;AAcA,eAAsB,OAAO,OAAgB,EAAE,EAAE;CAC/C,MAAM,SAAS;EACb,aAAaA,oCAAAA,aAAa;EAC1B,YAAYC,oCAAAA,mBAAmB;EAChC;AAED,QAAO,OAAO,YAAY,QAAQ,KAAK;;AAGzC,OAAO,cAAc,OACnB,EACE,cAAcD,oCAAAA,aAAa,EAC3B,aAAaC,oCAAAA,mBAAmB,KACZ,EAAE,EACxB,EAAE,iBAAiB,wBAAiC,EAAE,KACnD;AAGH,QAAO;EAAE,OAFK,MAAMC,oCAAAA,aAAa,aAAa,gBAAgB;EAE9C,UADC,MAAMA,oCAAAA,aAAa,YAAY,oBAAoB;EAC1C;;;;;;;;;;;;;AAc5B,SAAgB,QAAQ,OAAgB,EAAE,EAAE;CAC1C,MAAM,aAAaD,oCAAAA,mBAAmB;CACtC,MAAM,cAAcD,oCAAAA,aAAa;AACjC,QAAO,QAAQ,YAAY;EAAE;EAAY;EAAa,EAAE,KAAK;;;;;;;;;AAU/D,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACZ;AACX,QAAO;EACL,MAAA,iCAAA;EACA,SAAS;EACT,QAAQ,OAAM,YAAW;GACvB,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;IAAY,EAC3B;IAAE;IAAqB;IAAiB,CACzC;AAED,UAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MACR,GAAG;MACH,SAAS,IAAI;MACd;KACF;IACF;;EAEJ"}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import type { Args, WithPattern } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Create includeTest and includeCoverage arrays from glob patterns
|
|
4
|
+
*
|
|
5
|
+
* @param args Globs to ignore for test and coverage files
|
|
6
|
+
* @returns an object with includeTest and includeCoverage string arrays
|
|
7
|
+
*/
|
|
8
|
+
export declare function create(args?: Args[1]): Promise<{
|
|
9
|
+
files: string[];
|
|
10
|
+
coverage: string[];
|
|
11
|
+
}>;
|
|
12
|
+
export declare namespace create {
|
|
13
|
+
var withPattern: ({ patternTest, patternCov, }?: Partial<Args[0]>, { ignoreTestFiles, ignoreCoverageFiles }?: Args[1]) => Promise<{
|
|
14
|
+
files: string[];
|
|
15
|
+
coverage: string[];
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
2
18
|
/**
|
|
3
19
|
* Plugin to add files with glob patterns to vitest
|
|
4
20
|
*
|
|
@@ -2,6 +2,25 @@ import { buildInclude, defaultCovPattern, testPattern } from "./vitest.utils.js"
|
|
|
2
2
|
import { name } from "./constants.js";
|
|
3
3
|
//#region src/vitest-exclude/vitest.ts
|
|
4
4
|
/**
|
|
5
|
+
* Create includeTest and includeCoverage arrays from glob patterns
|
|
6
|
+
*
|
|
7
|
+
* @param args Globs to ignore for test and coverage files
|
|
8
|
+
* @returns an object with includeTest and includeCoverage string arrays
|
|
9
|
+
*/
|
|
10
|
+
async function create(args = {}) {
|
|
11
|
+
const firsts = {
|
|
12
|
+
patternTest: testPattern(),
|
|
13
|
+
patternCov: defaultCovPattern()
|
|
14
|
+
};
|
|
15
|
+
return create.withPattern(firsts, args);
|
|
16
|
+
}
|
|
17
|
+
create.withPattern = async ({ patternTest = testPattern(), patternCov = defaultCovPattern() } = {}, { ignoreTestFiles, ignoreCoverageFiles } = {}) => {
|
|
18
|
+
return {
|
|
19
|
+
files: await buildInclude(patternTest, ignoreTestFiles),
|
|
20
|
+
coverage: await buildInclude(patternCov, ignoreCoverageFiles)
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
5
24
|
* Plugin to add files with glob patterns to vitest
|
|
6
25
|
*
|
|
7
26
|
* @param ignore globs to exclude inside
|
|
@@ -34,16 +53,21 @@ exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, igno
|
|
|
34
53
|
config: async (options) => {
|
|
35
54
|
const testConfig = options?.test;
|
|
36
55
|
const coverage = options?.test?.coverage;
|
|
37
|
-
const
|
|
38
|
-
|
|
56
|
+
const all = await create.withPattern({
|
|
57
|
+
patternTest,
|
|
58
|
+
patternCov
|
|
59
|
+
}, {
|
|
60
|
+
ignoreCoverageFiles,
|
|
61
|
+
ignoreTestFiles
|
|
62
|
+
});
|
|
39
63
|
return {
|
|
40
64
|
...options,
|
|
41
65
|
test: {
|
|
42
66
|
...testConfig,
|
|
43
|
-
include:
|
|
67
|
+
include: all.files,
|
|
44
68
|
coverage: {
|
|
45
69
|
...coverage,
|
|
46
|
-
include:
|
|
70
|
+
include: all.coverage
|
|
47
71
|
}
|
|
48
72
|
}
|
|
49
73
|
};
|
|
@@ -51,6 +75,6 @@ exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, igno
|
|
|
51
75
|
};
|
|
52
76
|
});
|
|
53
77
|
//#endregion
|
|
54
|
-
export { exclude };
|
|
78
|
+
export { create, exclude };
|
|
55
79
|
|
|
56
80
|
//# sourceMappingURL=vitest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.js","names":[],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import { name } from './constants';\nimport type { Args, Plugin, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @param ignore globs to exclude inside\n * @returns a vitest config\n *\n * @see {@link exclude.withPattern}\n * @remarks\n * You don't have to use test.exclude.\n * The default search patter is './src/**\\/*.ts'\n */\nexport function exclude(args: Args[1] = {}) {\n const patternCov = defaultCovPattern();\n const patternTest = testPattern();\n return exclude.withPattern({ patternCov, patternTest }, args);\n}\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @param pattern The pattern where searching files\n * @param ignore globs to exclude inside\n * @returns a vitest config\n */\nexclude.withPattern = ((\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n): Plugin => {\n return {\n name,\n enforce: 'pre',\n config: async options => {\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const
|
|
1
|
+
{"version":3,"file":"vitest.js","names":[],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import { name } from './constants';\nimport type { Args, Plugin, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\n\n/**\n * Create includeTest and includeCoverage arrays from glob patterns\n *\n * @param args Globs to ignore for test and coverage files\n * @returns an object with includeTest and includeCoverage string arrays\n */\nexport async function create(args: Args[1] = {}) {\n const firsts = {\n patternTest: testPattern(),\n patternCov: defaultCovPattern(),\n };\n\n return create.withPattern(firsts, args);\n}\n\ncreate.withPattern = async (\n {\n patternTest = testPattern(),\n patternCov = defaultCovPattern(),\n }: Partial<Args[0]> = {},\n { ignoreTestFiles, ignoreCoverageFiles }: Args[1] = {},\n) => {\n const files = await buildInclude(patternTest, ignoreTestFiles);\n const coverage = await buildInclude(patternCov, ignoreCoverageFiles);\n return { files, coverage };\n};\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @param ignore globs to exclude inside\n * @returns a vitest config\n *\n * @see {@link exclude.withPattern}\n * @remarks\n * You don't have to use test.exclude.\n * The default search patter is './src/**\\/*.ts'\n */\nexport function exclude(args: Args[1] = {}) {\n const patternCov = defaultCovPattern();\n const patternTest = testPattern();\n return exclude.withPattern({ patternCov, patternTest }, args);\n}\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @param pattern The pattern where searching files\n * @param ignore globs to exclude inside\n * @returns a vitest config\n */\nexclude.withPattern = ((\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n): Plugin => {\n return {\n name,\n enforce: 'pre',\n config: async options => {\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: {\n ...coverage,\n include: all.coverage,\n },\n },\n };\n },\n };\n}) as WithPattern;\n"],"mappings":";;;;;;;;;AAcA,eAAsB,OAAO,OAAgB,EAAE,EAAE;CAC/C,MAAM,SAAS;EACb,aAAa,aAAa;EAC1B,YAAY,mBAAmB;EAChC;AAED,QAAO,OAAO,YAAY,QAAQ,KAAK;;AAGzC,OAAO,cAAc,OACnB,EACE,cAAc,aAAa,EAC3B,aAAa,mBAAmB,KACZ,EAAE,EACxB,EAAE,iBAAiB,wBAAiC,EAAE,KACnD;AAGH,QAAO;EAAE,OAFK,MAAM,aAAa,aAAa,gBAAgB;EAE9C,UADC,MAAM,aAAa,YAAY,oBAAoB;EAC1C;;;;;;;;;;;;;AAc5B,SAAgB,QAAQ,OAAgB,EAAE,EAAE;CAC1C,MAAM,aAAa,mBAAmB;CACtC,MAAM,cAAc,aAAa;AACjC,QAAO,QAAQ,YAAY;EAAE;EAAY;EAAa,EAAE,KAAK;;;;;;;;;AAU/D,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACZ;AACX,QAAO;EACL;EACA,SAAS;EACT,QAAQ,OAAM,YAAW;GACvB,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;IAAY,EAC3B;IAAE;IAAqB;IAAiB,CACzC;AAED,UAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MACR,GAAG;MACH,SAAS,IAAI;MACd;KACF;IACF;;EAEJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemedev/dev-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A collection of utilities for Node.js development, including build tools, testing utilities, and configuration management.",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "bri_lvi@icloud.com",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"@bemedev/basifun": "0.5.3",
|
|
134
134
|
"@size-limit/file": "^12.0.1",
|
|
135
135
|
"@types/edit-json-file": "^1.7.4",
|
|
136
|
-
"@types/node": "^25.5.
|
|
136
|
+
"@types/node": "^25.5.1",
|
|
137
137
|
"@types/shelljs": "^0.10.0",
|
|
138
138
|
"@vitest/coverage-v8": "3.2.4",
|
|
139
139
|
"@vitest/ui": "3.2.4",
|
|
@@ -142,11 +142,11 @@
|
|
|
142
142
|
"is-in-ci": "^2.0.0",
|
|
143
143
|
"jsdom": "^29.0.1",
|
|
144
144
|
"onchange": "^7.1.0",
|
|
145
|
-
"oxfmt": "^0.
|
|
146
|
-
"oxlint": "^1.
|
|
145
|
+
"oxfmt": "^0.43.0",
|
|
146
|
+
"oxlint": "^1.58.0",
|
|
147
147
|
"prettier": "^3.8.1",
|
|
148
148
|
"pretty-quick": "^4.2.2",
|
|
149
|
-
"rolldown": "1.0.0-rc.
|
|
149
|
+
"rolldown": "1.0.0-rc.13",
|
|
150
150
|
"rxjs": "^7.8.2",
|
|
151
151
|
"size-limit": "^12.0.1",
|
|
152
152
|
"solid-js": "^1.9.12",
|