@bemedev/dev-utils 1.1.1 → 1.3.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 +121 -0
- package/lib/_virtual/_rolldown/runtime.cjs +1 -1
- package/lib/build-tests/addTarball.cjs +5 -1
- package/lib/build-tests/addTarball.cjs.map +1 -1
- package/lib/build-tests/addTarball.d.ts +3 -0
- package/lib/build-tests/addTarball.js +5 -1
- package/lib/build-tests/addTarball.js.map +1 -1
- package/lib/build-tests/buildPackageJson.cjs +17 -9
- package/lib/build-tests/buildPackageJson.cjs.map +1 -1
- package/lib/build-tests/buildPackageJson.d.ts +5 -0
- package/lib/build-tests/buildPackageJson.js +17 -9
- package/lib/build-tests/buildPackageJson.js.map +1 -1
- package/lib/build-tests/cleanup.cjs +3 -0
- package/lib/build-tests/cleanup.cjs.map +1 -1
- package/lib/build-tests/cleanup.d.ts +3 -0
- package/lib/build-tests/cleanup.js +3 -0
- package/lib/build-tests/cleanup.js.map +1 -1
- package/lib/build-tests/cli/cli.cjs +6 -0
- package/lib/build-tests/cli/cli.cjs.map +1 -1
- package/lib/build-tests/cli/cli.d.ts +6 -0
- package/lib/build-tests/cli/cli.js +6 -0
- package/lib/build-tests/cli/cli.js.map +1 -1
- package/lib/build-tests/cli/index.cjs.map +1 -1
- package/lib/build-tests/cli/post.cjs +3 -0
- package/lib/build-tests/cli/post.cjs.map +1 -1
- package/lib/build-tests/cli/post.d.ts +3 -0
- package/lib/build-tests/cli/post.js +3 -0
- package/lib/build-tests/cli/post.js.map +1 -1
- package/lib/build-tests/cli/pre.cjs +3 -0
- package/lib/build-tests/cli/pre.cjs.map +1 -1
- package/lib/build-tests/cli/pre.d.ts +3 -0
- package/lib/build-tests/cli/pre.js +3 -0
- package/lib/build-tests/cli/pre.js.map +1 -1
- package/lib/build-tests/cli/test.cjs +3 -0
- package/lib/build-tests/cli/test.cjs.map +1 -1
- package/lib/build-tests/cli/test.d.ts +3 -0
- package/lib/build-tests/cli/test.js +3 -0
- package/lib/build-tests/cli/test.js.map +1 -1
- package/lib/build-tests/constants.cjs +42 -0
- package/lib/build-tests/constants.cjs.map +1 -1
- package/lib/build-tests/constants.d.ts +42 -0
- package/lib/build-tests/constants.js +42 -0
- package/lib/build-tests/constants.js.map +1 -1
- package/lib/build-tests/getRelativePath.cjs +7 -0
- package/lib/build-tests/getRelativePath.cjs.map +1 -1
- package/lib/build-tests/getRelativePath.d.ts +7 -0
- package/lib/build-tests/getRelativePath.js +7 -0
- package/lib/build-tests/getRelativePath.js.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.cjs +5 -0
- package/lib/build-tests/getTypescriptOutdir.cjs.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.d.ts +5 -0
- package/lib/build-tests/getTypescriptOutdir.js +5 -0
- package/lib/build-tests/getTypescriptOutdir.js.map +1 -1
- package/lib/build-tests/import.cjs +9 -0
- package/lib/build-tests/import.cjs.map +1 -1
- package/lib/build-tests/import.d.ts +9 -0
- package/lib/build-tests/import.js +9 -0
- package/lib/build-tests/import.js.map +1 -1
- package/lib/build-tests/imports/create.cjs +7 -0
- package/lib/build-tests/imports/create.cjs.map +1 -1
- package/lib/build-tests/imports/create.d.ts +13 -0
- package/lib/build-tests/imports/create.js +7 -0
- package/lib/build-tests/imports/create.js.map +1 -1
- package/lib/build-tests/imports/helper.cjs +9 -0
- package/lib/build-tests/imports/helper.cjs.map +1 -1
- package/lib/build-tests/imports/helper.d.ts +12 -0
- package/lib/build-tests/imports/helper.js +9 -0
- package/lib/build-tests/imports/helper.js.map +1 -1
- package/lib/build-tests/pack.cjs +7 -1
- package/lib/build-tests/pack.cjs.map +1 -1
- package/lib/build-tests/pack.d.ts +5 -0
- package/lib/build-tests/pack.js +7 -1
- package/lib/build-tests/pack.js.map +1 -1
- package/lib/plugins/hmr.cjs +72 -0
- package/lib/plugins/hmr.cjs.map +1 -0
- package/lib/plugins/hmr.d.ts +22 -0
- package/lib/plugins/hmr.js +71 -0
- package/lib/plugins/hmr.js.map +1 -0
- package/lib/plugins/index.cjs +5 -0
- package/lib/plugins/index.d.ts +2 -0
- package/lib/plugins/index.js +3 -0
- package/lib/plugins/suppressWarnings.cjs +37 -0
- package/lib/plugins/suppressWarnings.cjs.map +1 -0
- package/lib/plugins/suppressWarnings.d.ts +12 -0
- package/lib/plugins/suppressWarnings.js +36 -0
- package/lib/plugins/suppressWarnings.js.map +1 -0
- package/lib/rolldown-config/config.cjs +13 -5
- package/lib/rolldown-config/config.cjs.map +1 -1
- package/lib/rolldown-config/config.d.ts +7 -0
- package/lib/rolldown-config/config.js +13 -5
- package/lib/rolldown-config/config.js.map +1 -1
- package/lib/rolldown-config/constants.cjs +15 -0
- package/lib/rolldown-config/constants.cjs.map +1 -1
- package/lib/rolldown-config/constants.d.ts +15 -0
- package/lib/rolldown-config/constants.js +15 -0
- package/lib/rolldown-config/constants.js.map +1 -1
- package/lib/rolldown-config/helpers.cjs +16 -1
- package/lib/rolldown-config/helpers.cjs.map +1 -1
- package/lib/rolldown-config/helpers.d.ts +14 -0
- package/lib/rolldown-config/helpers.js +16 -1
- package/lib/rolldown-config/helpers.js.map +1 -1
- package/lib/rolldown-config/input.cjs +8 -0
- package/lib/rolldown-config/input.cjs.map +1 -1
- package/lib/rolldown-config/input.d.ts +8 -0
- package/lib/rolldown-config/input.js +8 -0
- package/lib/rolldown-config/input.js.map +1 -1
- package/lib/rolldown-config/output.cjs +8 -0
- package/lib/rolldown-config/output.cjs.map +1 -1
- package/lib/rolldown-config/output.d.ts +8 -0
- package/lib/rolldown-config/output.js +8 -0
- package/lib/rolldown-config/output.js.map +1 -1
- package/lib/rolldown-config/plugins/circulars.cjs +5 -5
- package/lib/rolldown-config/plugins/circulars.cjs.map +1 -1
- package/lib/rolldown-config/plugins/circulars.d.ts +10 -6
- package/lib/rolldown-config/plugins/circulars.js +5 -5
- package/lib/rolldown-config/plugins/circulars.js.map +1 -1
- package/lib/rolldown-config/plugins/clean.cjs +10 -1
- package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
- package/lib/rolldown-config/plugins/clean.d.ts +10 -0
- package/lib/rolldown-config/plugins/clean.js +10 -1
- package/lib/rolldown-config/plugins/clean.js.map +1 -1
- package/lib/rolldown-config/plugins/externals.cjs +4 -3
- package/lib/rolldown-config/plugins/externals.cjs.map +1 -1
- package/lib/rolldown-config/plugins/externals.d.ts +7 -3
- package/lib/rolldown-config/plugins/externals.js +4 -3
- package/lib/rolldown-config/plugins/externals.js.map +1 -1
- package/lib/rolldown-config/plugins/index.cjs +6 -0
- package/lib/rolldown-config/plugins/index.cjs.map +1 -1
- package/lib/rolldown-config/plugins/index.d.ts +6 -0
- package/lib/rolldown-config/plugins/index.js +6 -0
- package/lib/rolldown-config/plugins/index.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.cjs +7 -0
- package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.cjs +15 -0
- package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.d.ts +15 -0
- package/lib/rolldown-config/plugins/typescript.config.js +15 -0
- package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.d.ts +10 -0
- package/lib/rolldown-config/plugins/typescript.fast.cjs +9 -1
- package/lib/rolldown-config/plugins/typescript.fast.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.fast.d.ts +10 -0
- package/lib/rolldown-config/plugins/typescript.fast.js +9 -1
- package/lib/rolldown-config/plugins/typescript.fast.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.js +7 -0
- package/lib/rolldown-config/plugins/typescript.js.map +1 -1
- package/lib/rolldown-config/types.d.ts +18 -0
- package/lib/utils/array.cjs +7 -0
- package/lib/utils/array.cjs.map +1 -1
- package/lib/utils/array.d.ts +8 -0
- package/lib/utils/array.js +7 -0
- package/lib/utils/array.js.map +1 -1
- package/lib/utils/bemedev/globals/types.d.ts +20 -0
- package/lib/utils/bemedev/globals/utils/expandFn.cjs +11 -0
- package/lib/utils/bemedev/globals/utils/expandFn.cjs.map +1 -1
- package/lib/utils/bemedev/globals/utils/expandFn.d.ts +11 -0
- package/lib/utils/bemedev/globals/utils/expandFn.js +11 -0
- package/lib/utils/bemedev/globals/utils/expandFn.js.map +1 -1
- package/lib/utils/clamp.cjs +18 -0
- package/lib/utils/clamp.cjs.map +1 -0
- package/lib/utils/clamp.d.ts +10 -0
- package/lib/utils/clamp.js +17 -0
- package/lib/utils/clamp.js.map +1 -0
- package/lib/utils/identity.cjs +9 -0
- package/lib/utils/identity.cjs.map +1 -1
- package/lib/utils/identity.d.ts +9 -0
- package/lib/utils/identity.js +9 -0
- package/lib/utils/identity.js.map +1 -1
- package/lib/utils/index.cjs +2 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +2 -1
- package/lib/utils/sleep.cjs +7 -0
- package/lib/utils/sleep.cjs.map +1 -1
- package/lib/utils/sleep.d.ts +7 -0
- package/lib/utils/sleep.js +7 -0
- package/lib/utils/sleep.js.map +1 -1
- package/lib/utils/types.d.ts +17 -1
- package/lib/vitest-exclude/constants.cjs +3 -0
- package/lib/vitest-exclude/constants.cjs.map +1 -1
- package/lib/vitest-exclude/constants.d.ts +3 -0
- package/lib/vitest-exclude/constants.js +3 -0
- package/lib/vitest-exclude/constants.js.map +1 -1
- package/lib/vitest-exclude/types.d.ts +11 -0
- package/lib/vitest-exclude/vitest.cjs +25 -12
- package/lib/vitest-exclude/vitest.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.d.ts +9 -8
- package/lib/vitest-exclude/vitest.js +25 -12
- package/lib/vitest-exclude/vitest.js.map +1 -1
- package/lib/vitest-exclude/vitest.utils.cjs +30 -0
- package/lib/vitest-exclude/vitest.utils.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.utils.d.ts +30 -0
- package/lib/vitest-exclude/vitest.utils.js +30 -0
- package/lib/vitest-exclude/vitest.utils.js.map +1 -1
- package/lib/vitest-extended/acceptation.cjs +11 -2
- package/lib/vitest-extended/acceptation.cjs.map +1 -1
- package/lib/vitest-extended/acceptation.d.ts +9 -1
- package/lib/vitest-extended/acceptation.js +11 -2
- package/lib/vitest-extended/acceptation.js.map +1 -1
- package/lib/vitest-extended/createTests.cjs +34 -27
- package/lib/vitest-extended/createTests.cjs.map +1 -1
- package/lib/vitest-extended/createTests.d.ts +20 -37
- package/lib/vitest-extended/createTests.js +34 -27
- package/lib/vitest-extended/createTests.js.map +1 -1
- package/lib/vitest-extended/createTests.types.d.ts +13 -2
- package/lib/vitest-extended/done.cjs +18 -15
- package/lib/vitest-extended/done.cjs.map +1 -1
- package/lib/vitest-extended/done.d.ts +6 -5
- package/lib/vitest-extended/done.js +18 -15
- package/lib/vitest-extended/done.js.map +1 -1
- package/lib/vitest-extended/each/error.cjs +12 -0
- package/lib/vitest-extended/each/error.cjs.map +1 -1
- package/lib/vitest-extended/each/error.d.ts +12 -0
- package/lib/vitest-extended/each/error.js +12 -0
- package/lib/vitest-extended/each/error.js.map +1 -1
- package/lib/vitest-extended/each/error.types.d.ts +17 -0
- package/lib/vitest-extended/each/pass.cjs +9 -20
- package/lib/vitest-extended/each/pass.cjs.map +1 -1
- package/lib/vitest-extended/each/pass.d.ts +9 -20
- package/lib/vitest-extended/each/pass.js +9 -20
- package/lib/vitest-extended/each/pass.js.map +1 -1
- package/lib/vitest-extended/each/pass.types.d.ts +24 -0
- package/lib/vitest-extended/fakeWaiter.cjs +7 -0
- package/lib/vitest-extended/fakeWaiter.cjs.map +1 -1
- package/lib/vitest-extended/fakeWaiter.d.ts +32 -0
- package/lib/vitest-extended/fakeWaiter.js +7 -0
- package/lib/vitest-extended/fakeWaiter.js.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.cjs +11 -0
- package/lib/vitest-extended/fixtures/coverage.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.js +11 -0
- package/lib/vitest-extended/fixtures/coverage.js.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.cjs +9 -4
- package/lib/vitest-extended/fixtures/partialCall.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.js +9 -4
- package/lib/vitest-extended/fixtures/partialCall.js.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.cjs +18 -0
- package/lib/vitest-extended/fixtures/toUpper.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.js +18 -0
- package/lib/vitest-extended/fixtures/toUpper.js.map +1 -1
- package/lib/vitest-extended/fixtures/vitest.cjs +3 -0
- package/lib/vitest-extended/fixtures/vitest.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/vitest.js +3 -0
- package/lib/vitest-extended/fixtures/vitest.js.map +1 -1
- package/lib/vitest-extended/fixtures/zod.cjs +22 -0
- package/lib/vitest-extended/fixtures/zod.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/zod.js +22 -0
- package/lib/vitest-extended/fixtures/zod.js.map +1 -1
- package/lib/vitest-extended/identity.cjs +18 -0
- package/lib/vitest-extended/identity.cjs.map +1 -1
- package/lib/vitest-extended/identity.d.ts +18 -0
- package/lib/vitest-extended/identity.js +18 -0
- package/lib/vitest-extended/identity.js.map +1 -1
- package/lib/vitest-extended/isDefined.cjs +9 -0
- package/lib/vitest-extended/isDefined.cjs.map +1 -1
- package/lib/vitest-extended/isDefined.d.ts +9 -0
- package/lib/vitest-extended/isDefined.js +9 -0
- package/lib/vitest-extended/isDefined.js.map +1 -1
- package/lib/vitest-extended/isFunction.cjs +7 -0
- package/lib/vitest-extended/isFunction.cjs.map +1 -1
- package/lib/vitest-extended/isFunction.d.ts +7 -0
- package/lib/vitest-extended/isFunction.js +7 -0
- package/lib/vitest-extended/isFunction.js.map +1 -1
- package/lib/vitest-extended/project.cjs +7 -0
- package/lib/vitest-extended/project.cjs.map +1 -1
- package/lib/vitest-extended/project.d.ts +7 -0
- package/lib/vitest-extended/project.js +7 -0
- package/lib/vitest-extended/project.js.map +1 -1
- package/lib/vitest-extended/toArray.cjs +6 -0
- package/lib/vitest-extended/toArray.cjs.map +1 -1
- package/lib/vitest-extended/toArray.d.ts +6 -0
- package/lib/vitest-extended/toArray.js +6 -0
- package/lib/vitest-extended/toArray.js.map +1 -1
- package/lib/vitest-extended/toStringFlat.cjs +8 -0
- package/lib/vitest-extended/toStringFlat.cjs.map +1 -1
- package/lib/vitest-extended/toStringFlat.d.ts +8 -0
- package/lib/vitest-extended/toStringFlat.js +8 -0
- package/lib/vitest-extended/toStringFlat.js.map +1 -1
- package/lib/vitest-extended/types.d.ts +64 -0
- package/package.json +14 -9
package/lib/utils/sleep.cjs
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/utils/sleep.ts
|
|
3
|
+
/**
|
|
4
|
+
* Asynchronously pauses execution for a given number of milliseconds.
|
|
5
|
+
*
|
|
6
|
+
* @param ms - Delay duration in milliseconds.
|
|
7
|
+
*
|
|
8
|
+
* @returns A promise that resolves after the specified delay.
|
|
9
|
+
*/
|
|
3
10
|
const sleep = (ms) => {
|
|
4
11
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5
12
|
};
|
package/lib/utils/sleep.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.cjs","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"sleep.cjs","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["/**\n * Asynchronously pauses execution for a given number of milliseconds.\n *\n * @param ms - Delay duration in milliseconds.\n *\n * @returns A promise that resolves after the specified delay.\n */\nexport const sleep = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,SAAS,OAAe;CACnC,OAAO,IAAI,SAAQ,YAAW,WAAW,SAAS,EAAE,CAAC;AACvD"}
|
package/lib/utils/sleep.d.ts
CHANGED
package/lib/utils/sleep.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
//#region src/utils/sleep.ts
|
|
2
|
+
/**
|
|
3
|
+
* Asynchronously pauses execution for a given number of milliseconds.
|
|
4
|
+
*
|
|
5
|
+
* @param ms - Delay duration in milliseconds.
|
|
6
|
+
*
|
|
7
|
+
* @returns A promise that resolves after the specified delay.
|
|
8
|
+
*/
|
|
2
9
|
const sleep = (ms) => {
|
|
3
10
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
4
11
|
};
|
package/lib/utils/sleep.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.js","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"sleep.js","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["/**\n * Asynchronously pauses execution for a given number of milliseconds.\n *\n * @param ms - Delay duration in milliseconds.\n *\n * @returns A promise that resolves after the specified delay.\n */\nexport const sleep = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,SAAS,OAAe;CACnC,OAAO,IAAI,SAAQ,YAAW,WAAW,SAAS,EAAE,CAAC;AACvD"}
|
package/lib/utils/types.d.ts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
1
|
export * from './bemedev/globals/types';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a single value, array, null, or undefined into an array.
|
|
4
|
+
*
|
|
5
|
+
* @template `T` - Item type.
|
|
6
|
+
*
|
|
7
|
+
* @param value - Optional single value or array of type {@linkcode SoA}.
|
|
8
|
+
*
|
|
9
|
+
* @returns Array containing the value(s).
|
|
10
|
+
*/
|
|
11
|
+
export type ToArray_F = <T>(value?: T | T[] | ReadonlyArray<T>) => T[];
|
|
12
|
+
/**
|
|
13
|
+
* Single or Array (SoA) helper type. Represents a single value, an array of
|
|
14
|
+
* values, or a readonly array of values.
|
|
15
|
+
*
|
|
16
|
+
* @template `T` - Item type.
|
|
17
|
+
*/
|
|
18
|
+
export type SoA<T> = T | T[] | ReadonlyArray<T>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/vitest-exclude/constants.ts
|
|
3
|
+
/**
|
|
4
|
+
* Package name identifier for the exclude-coverage plugin.
|
|
5
|
+
*/
|
|
3
6
|
const name = "@bemedev/exclude-coverage";
|
|
4
7
|
//#endregion
|
|
5
8
|
exports.name = name;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","names":[],"sources":["../../src/vitest-exclude/constants.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"constants.cjs","names":[],"sources":["../../src/vitest-exclude/constants.ts"],"sourcesContent":["/**\n * Package name identifier for the exclude-coverage plugin.\n */\nexport const name = '@bemedev/exclude-coverage';\n"],"mappings":";;;;;AAGA,MAAa,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../../src/vitest-exclude/constants.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../src/vitest-exclude/constants.ts"],"sourcesContent":["/**\n * Package name identifier for the exclude-coverage plugin.\n */\nexport const name = '@bemedev/exclude-coverage';\n"],"mappings":";;;;AAGA,MAAa,OAAO"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { Plugin } from 'vitest/config';
|
|
2
|
+
/**
|
|
3
|
+
* Type helper to exclude undefined from a type.
|
|
4
|
+
*
|
|
5
|
+
* @template `T` - Base type.
|
|
6
|
+
*/
|
|
2
7
|
export type Define<T> = Exclude<T, undefined>;
|
|
8
|
+
/**
|
|
9
|
+
* Argument tuple for glob pattern configuration and exclusions.
|
|
10
|
+
*/
|
|
3
11
|
export type Args = [
|
|
4
12
|
{
|
|
5
13
|
patternTest: string | string[];
|
|
@@ -10,4 +18,7 @@ export type Args = [
|
|
|
10
18
|
ignoreCoverageFiles?: string[];
|
|
11
19
|
}
|
|
12
20
|
];
|
|
21
|
+
/**
|
|
22
|
+
* Function type creating a Vitest plugin with explicit patterns.
|
|
23
|
+
*/
|
|
13
24
|
export type WithPattern = (...args: Args) => Plugin;
|
|
@@ -3,10 +3,12 @@ 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
|
-
*
|
|
6
|
+
* Creates include arrays for test and coverage files from glob patterns.
|
|
7
7
|
*
|
|
8
|
-
* @param args
|
|
9
|
-
* @
|
|
8
|
+
* @param args - Glob patterns to ignore for test and coverage files.
|
|
9
|
+
* @param root - Optional root directory path.
|
|
10
|
+
*
|
|
11
|
+
* @returns An object with resolved `files` and `coverage` string arrays.
|
|
10
12
|
*/
|
|
11
13
|
async function create(args = {}, root) {
|
|
12
14
|
const firsts = {
|
|
@@ -15,6 +17,17 @@ async function create(args = {}, root) {
|
|
|
15
17
|
};
|
|
16
18
|
return create.withPattern(firsts, args, root);
|
|
17
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates include arrays using custom test and coverage glob patterns.
|
|
22
|
+
*
|
|
23
|
+
* @param patterns - Custom test and coverage pattern object.
|
|
24
|
+
* @param patterns.patternTest - Glob pattern for test files.
|
|
25
|
+
* @param patterns.patternCov - Glob pattern for coverage files.
|
|
26
|
+
* @param args - Ignore options for tests and coverage.
|
|
27
|
+
* @param root - Optional root directory path.
|
|
28
|
+
*
|
|
29
|
+
* @returns An object with resolved `files` and `coverage` string arrays.
|
|
30
|
+
*/
|
|
18
31
|
create.withPattern = async ({ patternTest, patternCov } = {}, { ignoreTestFiles, ignoreCoverageFiles } = {}, root) => {
|
|
19
32
|
return {
|
|
20
33
|
files: await require_vitest_exclude_vitest_utils.buildInclude(patternTest ?? require_vitest_exclude_vitest_utils.testPattern(root), ignoreTestFiles, root),
|
|
@@ -22,12 +35,11 @@ create.withPattern = async ({ patternTest, patternCov } = {}, { ignoreTestFiles,
|
|
|
22
35
|
};
|
|
23
36
|
};
|
|
24
37
|
/**
|
|
25
|
-
*
|
|
38
|
+
* Vitest plugin to configure test and coverage file inclusion via glob patterns.
|
|
39
|
+
*
|
|
40
|
+
* @param args - Globs to ignore for test and coverage files.
|
|
26
41
|
*
|
|
27
|
-
* @
|
|
28
|
-
* @param ignore Globs to exclude inside
|
|
29
|
-
* @returns A vitest config
|
|
30
|
-
* @see {@link exclude.withPattern}
|
|
42
|
+
* @returns Vitest plugin of type {@linkcode Plugin}.
|
|
31
43
|
*/
|
|
32
44
|
function exclude(args = {}) {
|
|
33
45
|
return {
|
|
@@ -61,11 +73,12 @@ function exclude(args = {}) {
|
|
|
61
73
|
};
|
|
62
74
|
}
|
|
63
75
|
/**
|
|
64
|
-
*
|
|
76
|
+
* Vitest plugin to configure test and coverage file inclusion with custom search patterns.
|
|
77
|
+
*
|
|
78
|
+
* @param patterns - Custom test and coverage glob patterns.
|
|
79
|
+
* @param ignore - Globs to exclude.
|
|
65
80
|
*
|
|
66
|
-
* @
|
|
67
|
-
* @param ignore Globs to exclude inside
|
|
68
|
-
* @returns A vitest config
|
|
81
|
+
* @returns Vitest plugin of type {@linkcode Plugin}.
|
|
69
82
|
*/
|
|
70
83
|
exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, ignoreTestFiles }) => {
|
|
71
84
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.cjs","names":["testPattern","defaultCovPattern","buildInclude"],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import type { Plugin } from 'vitest/config';\n\nimport { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"vitest.cjs","names":["testPattern","defaultCovPattern","buildInclude"],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import type { Plugin } from 'vitest/config';\n\nimport { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\n\n/**\n * Creates include arrays for test and coverage files from glob patterns.\n *\n * @param args - Glob patterns to ignore for test and coverage files.\n * @param root - Optional root directory path.\n *\n * @returns An object with resolved `files` and `coverage` string arrays.\n */\nexport async function create(args: Args[1] = {}, root?: string) {\n const firsts = {\n patternTest: testPattern(root),\n patternCov: defaultCovPattern(root),\n };\n\n return create.withPattern(firsts, args, root);\n}\n\n/**\n * Creates include arrays using custom test and coverage glob patterns.\n *\n * @param patterns - Custom test and coverage pattern object.\n * @param patterns.patternTest - Glob pattern for test files.\n * @param patterns.patternCov - Glob pattern for coverage files.\n * @param args - Ignore options for tests and coverage.\n * @param root - Optional root directory path.\n *\n * @returns An object with resolved `files` and `coverage` string arrays.\n */\ncreate.withPattern = async (\n { patternTest, patternCov }: Partial<Args[0]> = {},\n { ignoreTestFiles, ignoreCoverageFiles }: Args[1] = {},\n root?: string,\n) => {\n const files = await buildInclude(\n patternTest ?? testPattern(root),\n ignoreTestFiles,\n root,\n );\n const coverage = await buildInclude(\n patternCov ?? defaultCovPattern(root),\n ignoreCoverageFiles,\n root,\n );\n return { files, coverage };\n};\n\n/**\n * Vitest plugin to configure test and coverage file inclusion via glob patterns.\n *\n * @param args - Globs to ignore for test and coverage files.\n *\n * @returns Vitest plugin of type {@linkcode Plugin}.\n */\nexport function exclude(args: Args[1] = {}) {\n return {\n name,\n config: async options => {\n const root = options?.root ?? process.cwd();\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const patternCov = defaultCovPattern(root);\n const patternTest = testPattern(root);\n\n const { ignoreCoverageFiles, ignoreTestFiles } = args;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: { ...coverage, include: all.coverage },\n },\n };\n },\n } as Plugin;\n}\n\n/**\n * Vitest plugin to configure test and coverage file inclusion with custom search patterns.\n *\n * @param patterns - Custom test and coverage glob patterns.\n * @param ignore - Globs to exclude.\n *\n * @returns Vitest plugin of type {@linkcode Plugin}.\n */\nexclude.withPattern = ((\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n) => {\n return {\n name,\n config: async options => {\n const root = options?.root ?? process.cwd();\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 root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: { ...coverage, include: all.coverage },\n },\n };\n },\n };\n}) as WithPattern;\n"],"mappings":";;;;;;;;;;;;AAkBA,eAAsB,OAAO,OAAgB,CAAC,GAAG,MAAe;CAC9D,MAAM,SAAS;EACb,aAAaA,oCAAAA,YAAY,IAAI;EAC7B,YAAYC,oCAAAA,kBAAkB,IAAI;CACpC;CAEA,OAAO,OAAO,YAAY,QAAQ,MAAM,IAAI;AAC9C;;;;;;;;;;;;AAaA,OAAO,cAAc,OACnB,EAAE,aAAa,eAAiC,CAAC,GACjD,EAAE,iBAAiB,wBAAiC,CAAC,GACrD,SACG;CAWH,OAAO;EAAE,OAAA,MAVWC,oCAAAA,aAClB,eAAeF,oCAAAA,YAAY,IAAI,GAC/B,iBACA,IACF;EAMgB,UAAA,MALOE,oCAAAA,aACrB,cAAcD,oCAAAA,kBAAkB,IAAI,GACpC,qBACA,IACF;CACyB;AAC3B;;;;;;;;AASA,SAAgB,QAAQ,OAAgB,CAAC,GAAG;CAC1C,OAAO;EACL,MAAA,iCAAA;EACA,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,IAAI;GAC1C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,aAAaA,oCAAAA,kBAAkB,IAAI;GACzC,MAAM,cAAcD,oCAAAA,YAAY,IAAI;GAEpC,MAAM,EAAE,qBAAqB,oBAAoB;GAEjD,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;GAAW,GAC1B;IAAE;IAAqB;GAAgB,GACvC,IACF;GAEA,OAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MAAE,GAAG;MAAU,SAAS,IAAI;KAAS;IACjD;GACF;EACF;CACF;AACF;;;;;;;;;AAUA,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACpB;CACH,OAAO;EACL,MAAA,iCAAA;EACA,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,IAAI;GAC1C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;GAAW,GAC1B;IAAE;IAAqB;GAAgB,GACvC,IACF;GAEA,OAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MAAE,GAAG;MAAU,SAAS,IAAI;KAAS;IACjD;GACF;EACF;CACF;AACF"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Plugin } from 'vitest/config';
|
|
2
2
|
import type { Args, WithPattern } from './types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Creates include arrays for test and coverage files from glob patterns.
|
|
5
5
|
*
|
|
6
|
-
* @param args
|
|
7
|
-
* @
|
|
6
|
+
* @param args - Glob patterns to ignore for test and coverage files.
|
|
7
|
+
* @param root - Optional root directory path.
|
|
8
|
+
*
|
|
9
|
+
* @returns An object with resolved `files` and `coverage` string arrays.
|
|
8
10
|
*/
|
|
9
11
|
export declare function create(args?: Args[1], root?: string): Promise<{
|
|
10
12
|
files: string[];
|
|
@@ -17,12 +19,11 @@ export declare namespace create {
|
|
|
17
19
|
}>;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
|
-
*
|
|
22
|
+
* Vitest plugin to configure test and coverage file inclusion via glob patterns.
|
|
23
|
+
*
|
|
24
|
+
* @param args - Globs to ignore for test and coverage files.
|
|
21
25
|
*
|
|
22
|
-
* @
|
|
23
|
-
* @param ignore Globs to exclude inside
|
|
24
|
-
* @returns A vitest config
|
|
25
|
-
* @see {@link exclude.withPattern}
|
|
26
|
+
* @returns Vitest plugin of type {@linkcode Plugin}.
|
|
26
27
|
*/
|
|
27
28
|
export declare function exclude(args?: Args[1]): Plugin;
|
|
28
29
|
export declare namespace exclude {
|
|
@@ -2,10 +2,12 @@ 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
|
-
*
|
|
5
|
+
* Creates include arrays for test and coverage files from glob patterns.
|
|
6
6
|
*
|
|
7
|
-
* @param args
|
|
8
|
-
* @
|
|
7
|
+
* @param args - Glob patterns to ignore for test and coverage files.
|
|
8
|
+
* @param root - Optional root directory path.
|
|
9
|
+
*
|
|
10
|
+
* @returns An object with resolved `files` and `coverage` string arrays.
|
|
9
11
|
*/
|
|
10
12
|
async function create(args = {}, root) {
|
|
11
13
|
const firsts = {
|
|
@@ -14,6 +16,17 @@ async function create(args = {}, root) {
|
|
|
14
16
|
};
|
|
15
17
|
return create.withPattern(firsts, args, root);
|
|
16
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates include arrays using custom test and coverage glob patterns.
|
|
21
|
+
*
|
|
22
|
+
* @param patterns - Custom test and coverage pattern object.
|
|
23
|
+
* @param patterns.patternTest - Glob pattern for test files.
|
|
24
|
+
* @param patterns.patternCov - Glob pattern for coverage files.
|
|
25
|
+
* @param args - Ignore options for tests and coverage.
|
|
26
|
+
* @param root - Optional root directory path.
|
|
27
|
+
*
|
|
28
|
+
* @returns An object with resolved `files` and `coverage` string arrays.
|
|
29
|
+
*/
|
|
17
30
|
create.withPattern = async ({ patternTest, patternCov } = {}, { ignoreTestFiles, ignoreCoverageFiles } = {}, root) => {
|
|
18
31
|
return {
|
|
19
32
|
files: await buildInclude(patternTest ?? testPattern(root), ignoreTestFiles, root),
|
|
@@ -21,12 +34,11 @@ create.withPattern = async ({ patternTest, patternCov } = {}, { ignoreTestFiles,
|
|
|
21
34
|
};
|
|
22
35
|
};
|
|
23
36
|
/**
|
|
24
|
-
*
|
|
37
|
+
* Vitest plugin to configure test and coverage file inclusion via glob patterns.
|
|
38
|
+
*
|
|
39
|
+
* @param args - Globs to ignore for test and coverage files.
|
|
25
40
|
*
|
|
26
|
-
* @
|
|
27
|
-
* @param ignore Globs to exclude inside
|
|
28
|
-
* @returns A vitest config
|
|
29
|
-
* @see {@link exclude.withPattern}
|
|
41
|
+
* @returns Vitest plugin of type {@linkcode Plugin}.
|
|
30
42
|
*/
|
|
31
43
|
function exclude(args = {}) {
|
|
32
44
|
return {
|
|
@@ -60,11 +72,12 @@ function exclude(args = {}) {
|
|
|
60
72
|
};
|
|
61
73
|
}
|
|
62
74
|
/**
|
|
63
|
-
*
|
|
75
|
+
* Vitest plugin to configure test and coverage file inclusion with custom search patterns.
|
|
76
|
+
*
|
|
77
|
+
* @param patterns - Custom test and coverage glob patterns.
|
|
78
|
+
* @param ignore - Globs to exclude.
|
|
64
79
|
*
|
|
65
|
-
* @
|
|
66
|
-
* @param ignore Globs to exclude inside
|
|
67
|
-
* @returns A vitest config
|
|
80
|
+
* @returns Vitest plugin of type {@linkcode Plugin}.
|
|
68
81
|
*/
|
|
69
82
|
exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, ignoreTestFiles }) => {
|
|
70
83
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.js","names":[],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import type { Plugin } from 'vitest/config';\n\nimport { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"vitest.js","names":[],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import type { Plugin } from 'vitest/config';\n\nimport { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\n\n/**\n * Creates include arrays for test and coverage files from glob patterns.\n *\n * @param args - Glob patterns to ignore for test and coverage files.\n * @param root - Optional root directory path.\n *\n * @returns An object with resolved `files` and `coverage` string arrays.\n */\nexport async function create(args: Args[1] = {}, root?: string) {\n const firsts = {\n patternTest: testPattern(root),\n patternCov: defaultCovPattern(root),\n };\n\n return create.withPattern(firsts, args, root);\n}\n\n/**\n * Creates include arrays using custom test and coverage glob patterns.\n *\n * @param patterns - Custom test and coverage pattern object.\n * @param patterns.patternTest - Glob pattern for test files.\n * @param patterns.patternCov - Glob pattern for coverage files.\n * @param args - Ignore options for tests and coverage.\n * @param root - Optional root directory path.\n *\n * @returns An object with resolved `files` and `coverage` string arrays.\n */\ncreate.withPattern = async (\n { patternTest, patternCov }: Partial<Args[0]> = {},\n { ignoreTestFiles, ignoreCoverageFiles }: Args[1] = {},\n root?: string,\n) => {\n const files = await buildInclude(\n patternTest ?? testPattern(root),\n ignoreTestFiles,\n root,\n );\n const coverage = await buildInclude(\n patternCov ?? defaultCovPattern(root),\n ignoreCoverageFiles,\n root,\n );\n return { files, coverage };\n};\n\n/**\n * Vitest plugin to configure test and coverage file inclusion via glob patterns.\n *\n * @param args - Globs to ignore for test and coverage files.\n *\n * @returns Vitest plugin of type {@linkcode Plugin}.\n */\nexport function exclude(args: Args[1] = {}) {\n return {\n name,\n config: async options => {\n const root = options?.root ?? process.cwd();\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const patternCov = defaultCovPattern(root);\n const patternTest = testPattern(root);\n\n const { ignoreCoverageFiles, ignoreTestFiles } = args;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: { ...coverage, include: all.coverage },\n },\n };\n },\n } as Plugin;\n}\n\n/**\n * Vitest plugin to configure test and coverage file inclusion with custom search patterns.\n *\n * @param patterns - Custom test and coverage glob patterns.\n * @param ignore - Globs to exclude.\n *\n * @returns Vitest plugin of type {@linkcode Plugin}.\n */\nexclude.withPattern = ((\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n) => {\n return {\n name,\n config: async options => {\n const root = options?.root ?? process.cwd();\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 root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: { ...coverage, include: all.coverage },\n },\n };\n },\n };\n}) as WithPattern;\n"],"mappings":";;;;;;;;;;;AAkBA,eAAsB,OAAO,OAAgB,CAAC,GAAG,MAAe;CAC9D,MAAM,SAAS;EACb,aAAa,YAAY,IAAI;EAC7B,YAAY,kBAAkB,IAAI;CACpC;CAEA,OAAO,OAAO,YAAY,QAAQ,MAAM,IAAI;AAC9C;;;;;;;;;;;;AAaA,OAAO,cAAc,OACnB,EAAE,aAAa,eAAiC,CAAC,GACjD,EAAE,iBAAiB,wBAAiC,CAAC,GACrD,SACG;CAWH,OAAO;EAAE,OAAA,MAVW,aAClB,eAAe,YAAY,IAAI,GAC/B,iBACA,IACF;EAMgB,UAAA,MALO,aACrB,cAAc,kBAAkB,IAAI,GACpC,qBACA,IACF;CACyB;AAC3B;;;;;;;;AASA,SAAgB,QAAQ,OAAgB,CAAC,GAAG;CAC1C,OAAO;EACL;EACA,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,IAAI;GAC1C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,aAAa,kBAAkB,IAAI;GACzC,MAAM,cAAc,YAAY,IAAI;GAEpC,MAAM,EAAE,qBAAqB,oBAAoB;GAEjD,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;GAAW,GAC1B;IAAE;IAAqB;GAAgB,GACvC,IACF;GAEA,OAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MAAE,GAAG;MAAU,SAAS,IAAI;KAAS;IACjD;GACF;EACF;CACF;AACF;;;;;;;;;AAUA,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACpB;CACH,OAAO;EACL;EACA,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,IAAI;GAC1C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;GAAW,GAC1B;IAAE;IAAqB;GAAgB,GACvC,IACF;GAEA,OAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MAAE,GAAG;MAAU,SAAS,IAAI;KAAS;IACjD;GACF;EACF;CACF;AACF"}
|
|
@@ -3,20 +3,50 @@ let fs = require("fs");
|
|
|
3
3
|
let path = require("path");
|
|
4
4
|
let glob = require("glob");
|
|
5
5
|
//#region src/vitest-exclude/vitest.utils.ts
|
|
6
|
+
/**
|
|
7
|
+
* Checks if a `src` directory exists at the specified project root.
|
|
8
|
+
*
|
|
9
|
+
* @param root - Root directory path, defaults to `process.cwd()`.
|
|
10
|
+
*
|
|
11
|
+
* @returns `true` if `src` exists, otherwise `false`.
|
|
12
|
+
*/
|
|
6
13
|
const hasSrc = (root = process.cwd()) => {
|
|
7
14
|
return (0, fs.existsSync)((0, path.join)(root, "src"));
|
|
8
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Computes default coverage glob patterns based on directory structure.
|
|
18
|
+
*
|
|
19
|
+
* @param root - Optional root directory path.
|
|
20
|
+
*
|
|
21
|
+
* @returns Coverage glob pattern string.
|
|
22
|
+
*/
|
|
9
23
|
const defaultCovPattern = (root) => {
|
|
10
24
|
/* v8 ignore next */
|
|
11
25
|
return `${hasSrc(root) ? "src/" : ""}**/*.t{s,sx}`;
|
|
12
26
|
};
|
|
13
27
|
const mapper = (str) => str.replace(/\\/g, "/");
|
|
28
|
+
/**
|
|
29
|
+
* Resolves glob matches and normalizes file path separators.
|
|
30
|
+
*
|
|
31
|
+
* @param pattern - Glob pattern(s) to match.
|
|
32
|
+
* @param ignore - Optional array of patterns to ignore.
|
|
33
|
+
* @param root - Root working directory.
|
|
34
|
+
*
|
|
35
|
+
* @returns Array of normalized matched file paths.
|
|
36
|
+
*/
|
|
14
37
|
const buildInclude = async (pattern, ignore, root = process.cwd()) => {
|
|
15
38
|
return (await (0, glob.glob)(pattern, {
|
|
16
39
|
ignore,
|
|
17
40
|
cwd: root
|
|
18
41
|
})).map(mapper).sort();
|
|
19
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Computes default test glob patterns based on directory structure.
|
|
45
|
+
*
|
|
46
|
+
* @param root - Optional root directory path.
|
|
47
|
+
*
|
|
48
|
+
* @returns Test glob pattern string.
|
|
49
|
+
*/
|
|
20
50
|
const testPattern = (root) => {
|
|
21
51
|
/* v8 ignore next */
|
|
22
52
|
return `${hasSrc(root) ? "src/" : ""}**/*.{test,spec}.{ts,js,tsx,jsx}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.utils.cjs","names":[],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'node:path';\n\nimport { glob } from 'glob';\n\nexport const hasSrc = (root = process.cwd()) => {\n return existsSync(join(root, 'src'));\n};\n\nexport const defaultCovPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.t{s,sx}`;\n};\n\nconst mapper = (str: string) => str.replace(/\\\\/g, '/');\nexport const buildInclude = async (\n pattern: string | string[],\n ignore?: string[],\n root = process.cwd(),\n) => {\n const include = await glob(pattern, { ignore, cwd: root });\n\n return include.map(mapper).sort();\n};\n\nexport const testPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.{test,spec}.{ts,js,tsx,jsx}`;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vitest.utils.cjs","names":["existsSync","join"],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'node:path';\n\nimport { glob } from 'glob';\n\n/**\n * Checks if a `src` directory exists at the specified project root.\n *\n * @param root - Root directory path, defaults to `process.cwd()`.\n *\n * @returns `true` if `src` exists, otherwise `false`.\n */\nexport const hasSrc = (root = process.cwd()) => {\n return existsSync(join(root, 'src'));\n};\n\n/**\n * Computes default coverage glob patterns based on directory structure.\n *\n * @param root - Optional root directory path.\n *\n * @returns Coverage glob pattern string.\n */\nexport const defaultCovPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.t{s,sx}`;\n};\n\nconst mapper = (str: string) => str.replace(/\\\\/g, '/');\n\n/**\n * Resolves glob matches and normalizes file path separators.\n *\n * @param pattern - Glob pattern(s) to match.\n * @param ignore - Optional array of patterns to ignore.\n * @param root - Root working directory.\n *\n * @returns Array of normalized matched file paths.\n */\nexport const buildInclude = async (\n pattern: string | string[],\n ignore?: string[],\n root = process.cwd(),\n) => {\n const include = await glob(pattern, { ignore, cwd: root });\n\n return include.map(mapper).sort();\n};\n\n/**\n * Computes default test glob patterns based on directory structure.\n *\n * @param root - Optional root directory path.\n *\n * @returns Test glob pattern string.\n */\nexport const testPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.{test,spec}.{ts,js,tsx,jsx}`;\n};\n"],"mappings":";;;;;;;;;;;;AAYA,MAAa,UAAU,OAAO,QAAQ,IAAI,MAAM;CAC9C,QAAA,GAAOA,GAAAA,WAAAA,EAAAA,GAAWC,KAAAA,KAAAA,CAAK,MAAM,KAAK,CAAC;AACrC;;;;;;;;AASA,MAAa,qBAAqB,SAAkB;;CAGlD,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B;AAEA,MAAM,UAAU,QAAgB,IAAI,QAAQ,OAAO,GAAG;;;;;;;;;;AAWtD,MAAa,eAAe,OAC1B,SACA,QACA,OAAO,QAAQ,IAAI,MAChB;CAGH,QAAO,OAAA,GAFe,KAAA,KAAA,CAAK,SAAS;EAAE;EAAQ,KAAK;CAAK,CAAC,EAAA,CAE1C,IAAI,MAAM,CAAC,CAAC,KAAK;AAClC;;;;;;;;AASA,MAAa,eAAe,SAAkB;;CAG5C,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B"}
|
|
@@ -1,4 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a `src` directory exists at the specified project root.
|
|
3
|
+
*
|
|
4
|
+
* @param root - Root directory path, defaults to `process.cwd()`.
|
|
5
|
+
*
|
|
6
|
+
* @returns `true` if `src` exists, otherwise `false`.
|
|
7
|
+
*/
|
|
1
8
|
export declare const hasSrc: (root?: string) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Computes default coverage glob patterns based on directory structure.
|
|
11
|
+
*
|
|
12
|
+
* @param root - Optional root directory path.
|
|
13
|
+
*
|
|
14
|
+
* @returns Coverage glob pattern string.
|
|
15
|
+
*/
|
|
2
16
|
export declare const defaultCovPattern: (root?: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Resolves glob matches and normalizes file path separators.
|
|
19
|
+
*
|
|
20
|
+
* @param pattern - Glob pattern(s) to match.
|
|
21
|
+
* @param ignore - Optional array of patterns to ignore.
|
|
22
|
+
* @param root - Root working directory.
|
|
23
|
+
*
|
|
24
|
+
* @returns Array of normalized matched file paths.
|
|
25
|
+
*/
|
|
3
26
|
export declare const buildInclude: (pattern: string | string[], ignore?: string[], root?: string) => Promise<string[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Computes default test glob patterns based on directory structure.
|
|
29
|
+
*
|
|
30
|
+
* @param root - Optional root directory path.
|
|
31
|
+
*
|
|
32
|
+
* @returns Test glob pattern string.
|
|
33
|
+
*/
|
|
4
34
|
export declare const testPattern: (root?: string) => string;
|
|
@@ -2,20 +2,50 @@ import { existsSync } from "fs";
|
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
import { glob } from "glob";
|
|
4
4
|
//#region src/vitest-exclude/vitest.utils.ts
|
|
5
|
+
/**
|
|
6
|
+
* Checks if a `src` directory exists at the specified project root.
|
|
7
|
+
*
|
|
8
|
+
* @param root - Root directory path, defaults to `process.cwd()`.
|
|
9
|
+
*
|
|
10
|
+
* @returns `true` if `src` exists, otherwise `false`.
|
|
11
|
+
*/
|
|
5
12
|
const hasSrc = (root = process.cwd()) => {
|
|
6
13
|
return existsSync(join(root, "src"));
|
|
7
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Computes default coverage glob patterns based on directory structure.
|
|
17
|
+
*
|
|
18
|
+
* @param root - Optional root directory path.
|
|
19
|
+
*
|
|
20
|
+
* @returns Coverage glob pattern string.
|
|
21
|
+
*/
|
|
8
22
|
const defaultCovPattern = (root) => {
|
|
9
23
|
/* v8 ignore next */
|
|
10
24
|
return `${hasSrc(root) ? "src/" : ""}**/*.t{s,sx}`;
|
|
11
25
|
};
|
|
12
26
|
const mapper = (str) => str.replace(/\\/g, "/");
|
|
27
|
+
/**
|
|
28
|
+
* Resolves glob matches and normalizes file path separators.
|
|
29
|
+
*
|
|
30
|
+
* @param pattern - Glob pattern(s) to match.
|
|
31
|
+
* @param ignore - Optional array of patterns to ignore.
|
|
32
|
+
* @param root - Root working directory.
|
|
33
|
+
*
|
|
34
|
+
* @returns Array of normalized matched file paths.
|
|
35
|
+
*/
|
|
13
36
|
const buildInclude = async (pattern, ignore, root = process.cwd()) => {
|
|
14
37
|
return (await glob(pattern, {
|
|
15
38
|
ignore,
|
|
16
39
|
cwd: root
|
|
17
40
|
})).map(mapper).sort();
|
|
18
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Computes default test glob patterns based on directory structure.
|
|
44
|
+
*
|
|
45
|
+
* @param root - Optional root directory path.
|
|
46
|
+
*
|
|
47
|
+
* @returns Test glob pattern string.
|
|
48
|
+
*/
|
|
19
49
|
const testPattern = (root) => {
|
|
20
50
|
/* v8 ignore next */
|
|
21
51
|
return `${hasSrc(root) ? "src/" : ""}**/*.{test,spec}.{ts,js,tsx,jsx}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.utils.js","names":[],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'node:path';\n\nimport { glob } from 'glob';\n\nexport const hasSrc = (root = process.cwd()) => {\n return existsSync(join(root, 'src'));\n};\n\nexport const defaultCovPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.t{s,sx}`;\n};\n\nconst mapper = (str: string) => str.replace(/\\\\/g, '/');\nexport const buildInclude = async (\n pattern: string | string[],\n ignore?: string[],\n root = process.cwd(),\n) => {\n const include = await glob(pattern, { ignore, cwd: root });\n\n return include.map(mapper).sort();\n};\n\nexport const testPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.{test,spec}.{ts,js,tsx,jsx}`;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vitest.utils.js","names":[],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'node:path';\n\nimport { glob } from 'glob';\n\n/**\n * Checks if a `src` directory exists at the specified project root.\n *\n * @param root - Root directory path, defaults to `process.cwd()`.\n *\n * @returns `true` if `src` exists, otherwise `false`.\n */\nexport const hasSrc = (root = process.cwd()) => {\n return existsSync(join(root, 'src'));\n};\n\n/**\n * Computes default coverage glob patterns based on directory structure.\n *\n * @param root - Optional root directory path.\n *\n * @returns Coverage glob pattern string.\n */\nexport const defaultCovPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.t{s,sx}`;\n};\n\nconst mapper = (str: string) => str.replace(/\\\\/g, '/');\n\n/**\n * Resolves glob matches and normalizes file path separators.\n *\n * @param pattern - Glob pattern(s) to match.\n * @param ignore - Optional array of patterns to ignore.\n * @param root - Root working directory.\n *\n * @returns Array of normalized matched file paths.\n */\nexport const buildInclude = async (\n pattern: string | string[],\n ignore?: string[],\n root = process.cwd(),\n) => {\n const include = await glob(pattern, { ignore, cwd: root });\n\n return include.map(mapper).sort();\n};\n\n/**\n * Computes default test glob patterns based on directory structure.\n *\n * @param root - Optional root directory path.\n *\n * @returns Test glob pattern string.\n */\nexport const testPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.{test,spec}.{ts,js,tsx,jsx}`;\n};\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,UAAU,OAAO,QAAQ,IAAI,MAAM;CAC9C,OAAO,WAAW,KAAK,MAAM,KAAK,CAAC;AACrC;;;;;;;;AASA,MAAa,qBAAqB,SAAkB;;CAGlD,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B;AAEA,MAAM,UAAU,QAAgB,IAAI,QAAQ,OAAO,GAAG;;;;;;;;;;AAWtD,MAAa,eAAe,OAC1B,SACA,QACA,OAAO,QAAQ,IAAI,MAChB;CAGH,QAAO,MAFe,KAAK,SAAS;EAAE;EAAQ,KAAK;CAAK,CAAC,EAAA,CAE1C,IAAI,MAAM,CAAC,CAAC,KAAK;AAClC;;;;;;;;AASA,MAAa,eAAe,SAAkB;;CAG5C,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B"}
|
|
@@ -2,16 +2,25 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_vitest_extended_isFunction = require("./isFunction.cjs");
|
|
3
3
|
let vitest = require("vitest");
|
|
4
4
|
//#region src/vitest-extended/acceptation.ts
|
|
5
|
+
/**
|
|
6
|
+
* Creates baseline definition and function type tests for a given function.
|
|
7
|
+
*
|
|
8
|
+
* @param f - Target function to test of type {@linkcode Fn}.
|
|
9
|
+
* @param _name - Optional custom name for test assertions.
|
|
10
|
+
*/
|
|
5
11
|
const useTestFunctionAcceptation = (f, _name) => {
|
|
6
12
|
const name = _name ?? f.name;
|
|
7
13
|
(0, vitest.test)(`#01 => ${name} is defined`, () => {
|
|
8
14
|
(0, vitest.expect)(f).toBeDefined();
|
|
9
15
|
});
|
|
10
16
|
(0, vitest.test)(`#02 => ${name} is a function`, () => {
|
|
11
|
-
|
|
17
|
+
const check = require_vitest_extended_isFunction.isFunction(f);
|
|
18
|
+
(0, vitest.expect)(check).toBe(true);
|
|
12
19
|
});
|
|
13
20
|
};
|
|
14
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Alias for {@linkcode useTestFunctionAcceptation}.
|
|
23
|
+
*/
|
|
15
24
|
const useTFA = useTestFunctionAcceptation;
|
|
16
25
|
//#endregion
|
|
17
26
|
exports.useTFA = useTFA;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acceptation.cjs","names":["isFunction"],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { isFunction } from './isFunction';\n\nexport const useTestFunctionAcceptation = (f: Fn, _name?: string) => {\n const name = _name ?? f.name;\n\n test(`#01 => ${name} is defined`, () => {\n expect(f).toBeDefined();\n });\n test(`#02 => ${name} is a function`, () => {\n const check = isFunction(f);\n expect(check).toBe(true);\n });\n};\n\n
|
|
1
|
+
{"version":3,"file":"acceptation.cjs","names":["isFunction"],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { isFunction } from './isFunction';\n\n/**\n * Creates baseline definition and function type tests for a given function.\n *\n * @param f - Target function to test of type {@linkcode Fn}.\n * @param _name - Optional custom name for test assertions.\n */\nexport const useTestFunctionAcceptation = (f: Fn, _name?: string) => {\n const name = _name ?? f.name;\n\n test(`#01 => ${name} is defined`, () => {\n expect(f).toBeDefined();\n });\n test(`#02 => ${name} is a function`, () => {\n const check = isFunction(f);\n expect(check).toBe(true);\n });\n};\n\n/**\n * Alias for {@linkcode useTestFunctionAcceptation}.\n */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":";;;;;;;;;;AAWA,MAAa,8BAA8B,GAAO,UAAmB;CACnE,MAAM,OAAO,SAAS,EAAE;CAExB,CAAA,GAAA,OAAA,KAAA,CAAK,UAAU,KAAK,oBAAoB;EACtC,CAAA,GAAA,OAAA,OAAA,CAAO,CAAC,CAAC,CAAC,YAAY;CACxB,CAAC;CACD,CAAA,GAAA,OAAA,KAAA,CAAK,UAAU,KAAK,uBAAuB;EACzC,MAAM,QAAQA,mCAAAA,WAAW,CAAC;EAC1B,CAAA,GAAA,OAAA,OAAA,CAAO,KAAK,CAAC,CAAC,KAAK,IAAI;CACzB,CAAC;AACH;;;;AAKA,MAAa,SAAS"}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { Fn } from '../utils/bemedev/globals/types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates baseline definition and function type tests for a given function.
|
|
4
|
+
*
|
|
5
|
+
* @param f - Target function to test of type {@linkcode Fn}.
|
|
6
|
+
* @param _name - Optional custom name for test assertions.
|
|
7
|
+
*/
|
|
2
8
|
export declare const useTestFunctionAcceptation: (f: Fn, _name?: string) => void;
|
|
3
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Alias for {@linkcode useTestFunctionAcceptation}.
|
|
11
|
+
*/
|
|
4
12
|
export declare const useTFA: (f: Fn, _name?: string) => void;
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import { isFunction } from "./isFunction.js";
|
|
2
2
|
import { expect, test } from "vitest";
|
|
3
3
|
//#region src/vitest-extended/acceptation.ts
|
|
4
|
+
/**
|
|
5
|
+
* Creates baseline definition and function type tests for a given function.
|
|
6
|
+
*
|
|
7
|
+
* @param f - Target function to test of type {@linkcode Fn}.
|
|
8
|
+
* @param _name - Optional custom name for test assertions.
|
|
9
|
+
*/
|
|
4
10
|
const useTestFunctionAcceptation = (f, _name) => {
|
|
5
11
|
const name = _name ?? f.name;
|
|
6
12
|
test(`#01 => ${name} is defined`, () => {
|
|
7
13
|
expect(f).toBeDefined();
|
|
8
14
|
});
|
|
9
15
|
test(`#02 => ${name} is a function`, () => {
|
|
10
|
-
|
|
16
|
+
const check = isFunction(f);
|
|
17
|
+
expect(check).toBe(true);
|
|
11
18
|
});
|
|
12
19
|
};
|
|
13
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Alias for {@linkcode useTestFunctionAcceptation}.
|
|
22
|
+
*/
|
|
14
23
|
const useTFA = useTestFunctionAcceptation;
|
|
15
24
|
//#endregion
|
|
16
25
|
export { useTFA, useTestFunctionAcceptation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acceptation.js","names":[],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { isFunction } from './isFunction';\n\nexport const useTestFunctionAcceptation = (f: Fn, _name?: string) => {\n const name = _name ?? f.name;\n\n test(`#01 => ${name} is defined`, () => {\n expect(f).toBeDefined();\n });\n test(`#02 => ${name} is a function`, () => {\n const check = isFunction(f);\n expect(check).toBe(true);\n });\n};\n\n
|
|
1
|
+
{"version":3,"file":"acceptation.js","names":[],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { isFunction } from './isFunction';\n\n/**\n * Creates baseline definition and function type tests for a given function.\n *\n * @param f - Target function to test of type {@linkcode Fn}.\n * @param _name - Optional custom name for test assertions.\n */\nexport const useTestFunctionAcceptation = (f: Fn, _name?: string) => {\n const name = _name ?? f.name;\n\n test(`#01 => ${name} is defined`, () => {\n expect(f).toBeDefined();\n });\n test(`#02 => ${name} is a function`, () => {\n const check = isFunction(f);\n expect(check).toBe(true);\n });\n};\n\n/**\n * Alias for {@linkcode useTestFunctionAcceptation}.\n */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":";;;;;;;;;AAWA,MAAa,8BAA8B,GAAO,UAAmB;CACnE,MAAM,OAAO,SAAS,EAAE;CAExB,KAAK,UAAU,KAAK,oBAAoB;EACtC,OAAO,CAAC,CAAC,CAAC,YAAY;CACxB,CAAC;CACD,KAAK,UAAU,KAAK,uBAAuB;EACzC,MAAM,QAAQ,WAAW,CAAC;EAC1B,OAAO,KAAK,CAAC,CAAC,KAAK,IAAI;CACzB,CAAC;AACH;;;;AAKA,MAAa,SAAS"}
|