@bemedev/dev-utils 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -0
- package/lib/build-tests/addTarball.cjs +1 -1
- package/lib/build-tests/addTarball.cjs.map +1 -1
- package/lib/build-tests/addTarball.js +2 -2
- package/lib/build-tests/addTarball.js.map +1 -1
- package/lib/build-tests/buildPackageJson.cjs +4 -1
- package/lib/build-tests/buildPackageJson.cjs.map +1 -1
- package/lib/build-tests/buildPackageJson.d.ts +1 -2
- package/lib/build-tests/buildPackageJson.js +4 -1
- package/lib/build-tests/buildPackageJson.js.map +1 -1
- package/lib/build-tests/constants.cjs +3 -10
- package/lib/build-tests/constants.cjs.map +1 -1
- package/lib/build-tests/constants.d.ts +1 -7
- package/lib/build-tests/constants.js +3 -9
- package/lib/build-tests/constants.js.map +1 -1
- package/lib/build-tests/import.cjs +11 -0
- package/lib/build-tests/import.cjs.map +1 -0
- package/lib/build-tests/import.d.ts +4 -0
- package/lib/build-tests/import.js +10 -0
- package/lib/build-tests/import.js.map +1 -0
- package/lib/build-tests/index.cjs +4 -0
- package/lib/build-tests/index.d.ts +3 -0
- package/lib/build-tests/index.js +3 -1
- package/lib/build-tests/types.d.ts +1 -0
- package/lib/utils/identity.cjs +7 -0
- package/lib/utils/identity.cjs.map +1 -0
- package/lib/utils/identity.d.ts +1 -0
- package/lib/utils/identity.js +6 -0
- package/lib/utils/identity.js.map +1 -0
- package/lib/utils/index.cjs +2 -0
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +2 -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 +6 -2
package/README.md
CHANGED
|
@@ -170,6 +170,60 @@ exclude.withPattern(
|
|
|
170
170
|
|
|
171
171
|
---
|
|
172
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
|
+
|
|
173
227
|
## `vitestExtended`
|
|
174
228
|
|
|
175
229
|
Extended helpers for writing structured, type-safe Vitest tests.
|
|
@@ -11,7 +11,7 @@ sort_keys = require_runtime.__toESM(sort_keys);
|
|
|
11
11
|
//#region src/build-tests/addTarball.ts
|
|
12
12
|
const addTarball = async () => {
|
|
13
13
|
const packed = `${require_build_tests_constants.FILE_ORIGIN}:${await require_build_tests_pack.pack()}`;
|
|
14
|
-
shelljs.default.exec(`pnpm add -D ${require_build_tests_constants.
|
|
14
|
+
shelljs.default.exec(`pnpm add -D ${require_build_tests_constants.THIS1}@${packed}`);
|
|
15
15
|
const file = (0, edit_json_file.default)(require_build_tests_constants.PACKAGE_PATH);
|
|
16
16
|
const devDeps = (0, sort_keys.default)(file.get(require_build_tests_constants.devKey));
|
|
17
17
|
file.set(require_build_tests_constants.devKey, devDeps);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addTarball.cjs","names":["FILE_ORIGIN","pack","
|
|
1
|
+
{"version":3,"file":"addTarball.cjs","names":["FILE_ORIGIN","pack","THIS1","PACKAGE_PATH","devKey"],"sources":["../../src/build-tests/addTarball.ts"],"sourcesContent":["import editJsonFile from 'edit-json-file';\nimport sh from 'shelljs';\nimport sortKeys from 'sort-keys';\nimport { devKey, FILE_ORIGIN, PACKAGE_PATH, THIS1 } from './constants';\nimport { pack } from './pack';\n\nexport const addTarball = async () => {\n // #region Install the tarball\n const _packed = await pack();\n const packed = `${FILE_ORIGIN}:${_packed}`;\n sh.exec(`pnpm add -D ${THIS1}@${packed}`);\n // #endregion\n\n const file = editJsonFile(PACKAGE_PATH);\n const devDeps = sortKeys(file.get(devKey));\n file.set(devKey, devDeps);\n file.save();\n};\n"],"mappings":";;;;;;;;;;;AAMA,MAAa,aAAa,YAAY;CAGpC,MAAM,SAAS,GAAGA,8BAAAA,YAAY,GADd,MAAMC,yBAAAA,MAAM;AAE5B,SAAA,QAAG,KAAK,eAAeC,8BAAAA,MAAM,GAAG,SAAS;CAGzC,MAAM,QAAA,GAAA,eAAA,SAAoBC,8BAAAA,aAAa;CACvC,MAAM,WAAA,GAAA,UAAA,SAAmB,KAAK,IAAIC,8BAAAA,OAAO,CAAC;AAC1C,MAAK,IAAIA,8BAAAA,QAAQ,QAAQ;AACzB,MAAK,MAAM"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FILE_ORIGIN, PACKAGE_PATH,
|
|
1
|
+
import { FILE_ORIGIN, PACKAGE_PATH, THIS1, devKey } from "./constants.js";
|
|
2
2
|
import { pack } from "./pack.js";
|
|
3
3
|
import sh from "shelljs";
|
|
4
4
|
import editJsonFile from "edit-json-file";
|
|
@@ -6,7 +6,7 @@ import sortKeys from "sort-keys";
|
|
|
6
6
|
//#region src/build-tests/addTarball.ts
|
|
7
7
|
const addTarball = async () => {
|
|
8
8
|
const packed = `${FILE_ORIGIN}:${await pack()}`;
|
|
9
|
-
sh.exec(`pnpm add -D ${
|
|
9
|
+
sh.exec(`pnpm add -D ${THIS1}@${packed}`);
|
|
10
10
|
const file = editJsonFile(PACKAGE_PATH);
|
|
11
11
|
const devDeps = sortKeys(file.get(devKey));
|
|
12
12
|
file.set(devKey, devDeps);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addTarball.js","names":[],"sources":["../../src/build-tests/addTarball.ts"],"sourcesContent":["import editJsonFile from 'edit-json-file';\nimport sh from 'shelljs';\nimport sortKeys from 'sort-keys';\nimport { devKey, FILE_ORIGIN, PACKAGE_PATH,
|
|
1
|
+
{"version":3,"file":"addTarball.js","names":[],"sources":["../../src/build-tests/addTarball.ts"],"sourcesContent":["import editJsonFile from 'edit-json-file';\nimport sh from 'shelljs';\nimport sortKeys from 'sort-keys';\nimport { devKey, FILE_ORIGIN, PACKAGE_PATH, THIS1 } from './constants';\nimport { pack } from './pack';\n\nexport const addTarball = async () => {\n // #region Install the tarball\n const _packed = await pack();\n const packed = `${FILE_ORIGIN}:${_packed}`;\n sh.exec(`pnpm add -D ${THIS1}@${packed}`);\n // #endregion\n\n const file = editJsonFile(PACKAGE_PATH);\n const devDeps = sortKeys(file.get(devKey));\n file.set(devKey, devDeps);\n file.save();\n};\n"],"mappings":";;;;;;AAMA,MAAa,aAAa,YAAY;CAGpC,MAAM,SAAS,GAAG,YAAY,GADd,MAAM,MAAM;AAE5B,IAAG,KAAK,eAAe,MAAM,GAAG,SAAS;CAGzC,MAAM,OAAO,aAAa,aAAa;CACvC,MAAM,UAAU,SAAS,KAAK,IAAI,OAAO,CAAC;AAC1C,MAAK,IAAI,QAAQ,QAAQ;AACzB,MAAK,MAAM"}
|
|
@@ -32,7 +32,10 @@ const buildPackageJson = () => {
|
|
|
32
32
|
file.set(require_build_tests_constants.EXPORT_KEY, transformedExports);
|
|
33
33
|
}
|
|
34
34
|
const bin1 = file.get("bin");
|
|
35
|
-
if (bin1) {
|
|
35
|
+
if (bin1) if (typeof bin1 === "string") {
|
|
36
|
+
const bin2 = replaceLib(bin1);
|
|
37
|
+
file.set("bin", bin2);
|
|
38
|
+
} else {
|
|
36
39
|
const bin3 = (0, sort_keys.default)(Object.entries(bin1).reduce((acc, [key, value]) => {
|
|
37
40
|
acc[key] = replaceLib(value);
|
|
38
41
|
return acc;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildPackageJson.cjs","names":["getTypescriptOutdir","EXPORT_KEY"],"sources":["../../src/build-tests/buildPackageJson.ts"],"sourcesContent":["import type { Fn } from '#utils/types';\nimport editJsonFile from 'edit-json-file';\nimport sortKeys from 'sort-keys';\nimport { BIN_KEY, EXPORT_KEY, EXPORT_KEYS } from './constants';\nimport { getTypescriptOutdir } from './getTypescriptOutdir';\n\ntype BuldPackageJson_F = Fn
|
|
1
|
+
{"version":3,"file":"buildPackageJson.cjs","names":["getTypescriptOutdir","EXPORT_KEY"],"sources":["../../src/build-tests/buildPackageJson.ts"],"sourcesContent":["import type { Fn } from '#utils/types';\nimport editJsonFile from 'edit-json-file';\nimport sortKeys from 'sort-keys';\nimport { BIN_KEY, EXPORT_KEY, EXPORT_KEYS } from './constants';\nimport { getTypescriptOutdir } from './getTypescriptOutdir';\n\ntype BuldPackageJson_F = Fn<[], { packageJson: object; outDir: string }>;\n\nexport const buildPackageJson: BuldPackageJson_F = () => {\n const file = editJsonFile('./package.json');\n const outDir = getTypescriptOutdir();\n const lib = `${outDir}/`;\n const replaceLib = (str: string) => str.replace(lib, '');\n\n // #region Set export values\n EXPORT_KEYS.forEach(key => {\n const value = file.get(key);\n if (value) {\n const transformed = replaceLib(value);\n file.set(key, transformed);\n }\n });\n // #endregion\n\n // #region Set Export key\n const valueExports = file.get(EXPORT_KEY);\n\n if (valueExports) {\n const transformedExports = Object.entries(valueExports).reduce(\n (acc, [key, value]) => {\n const entries = Object.entries(value as any);\n const _value = entries.reduce((acc, [key, value]) => {\n acc[key] = replaceLib(value as any);\n return acc;\n }, {} as any);\n acc[key] = key.includes('package.json') ? value : _value;\n return acc;\n },\n {} as any,\n );\n\n file.set(EXPORT_KEY, transformedExports);\n }\n // #endregion\n\n // #region Set bin\n const bin1 = file.get(BIN_KEY) as\n | Record<string, string>\n | undefined\n | string;\n\n if (bin1) {\n if (typeof bin1 === 'string') {\n const bin2 = replaceLib(bin1);\n file.set(BIN_KEY, bin2);\n } else {\n const bin2 = Object.entries(bin1).reduce((acc, [key, value]) => {\n acc[key] = replaceLib(value);\n return acc;\n }, {} as any);\n\n const bin3 = sortKeys(bin2);\n file.set(BIN_KEY, bin3);\n }\n }\n // #endregion\n\n // #region Unset some props\n file.unset('files');\n file.unset('scripts');\n file.unset('devDependencies');\n // #endregion\n\n const packageJson = file.get();\n return { packageJson, outDir };\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,yBAA4C;CACvD,MAAM,QAAA,GAAA,eAAA,SAAoB,iBAAiB;CAC3C,MAAM,SAASA,wCAAAA,qBAAqB;CACpC,MAAM,MAAM,GAAG,OAAO;CACtB,MAAM,cAAc,QAAgB,IAAI,QAAQ,KAAK,GAAG;AAGxD,+BAAA,YAAY,SAAQ,QAAO;EACzB,MAAM,QAAQ,KAAK,IAAI,IAAI;AAC3B,MAAI,OAAO;GACT,MAAM,cAAc,WAAW,MAAM;AACrC,QAAK,IAAI,KAAK,YAAY;;GAE5B;CAIF,MAAM,eAAe,KAAK,IAAIC,8BAAAA,WAAW;AAEzC,KAAI,cAAc;EAChB,MAAM,qBAAqB,OAAO,QAAQ,aAAa,CAAC,QACrD,KAAK,CAAC,KAAK,WAAW;GAErB,MAAM,SADU,OAAO,QAAQ,MAAa,CACrB,QAAQ,KAAK,CAAC,KAAK,WAAW;AACnD,QAAI,OAAO,WAAW,MAAa;AACnC,WAAO;MACN,EAAE,CAAQ;AACb,OAAI,OAAO,IAAI,SAAS,eAAe,GAAG,QAAQ;AAClD,UAAO;KAET,EAAE,CACH;AAED,OAAK,IAAIA,8BAAAA,YAAY,mBAAmB;;CAK1C,MAAM,OAAO,KAAK,IAAA,MAAY;AAK9B,KAAI,KACF,KAAI,OAAO,SAAS,UAAU;EAC5B,MAAM,OAAO,WAAW,KAAK;AAC7B,OAAK,IAAA,OAAa,KAAK;QAClB;EAML,MAAM,QAAA,GAAA,UAAA,SALO,OAAO,QAAQ,KAAK,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;AAC9D,OAAI,OAAO,WAAW,MAAM;AAC5B,UAAO;KACN,EAAE,CAAQ,CAEc;AAC3B,OAAK,IAAA,OAAa,KAAK;;AAM3B,MAAK,MAAM,QAAQ;AACnB,MAAK,MAAM,UAAU;AACrB,MAAK,MAAM,kBAAkB;AAI7B,QAAO;EAAE,aADW,KAAK,KAAK;EACR;EAAQ"}
|
|
@@ -28,7 +28,10 @@ const buildPackageJson = () => {
|
|
|
28
28
|
file.set(EXPORT_KEY, transformedExports);
|
|
29
29
|
}
|
|
30
30
|
const bin1 = file.get("bin");
|
|
31
|
-
if (bin1) {
|
|
31
|
+
if (bin1) if (typeof bin1 === "string") {
|
|
32
|
+
const bin2 = replaceLib(bin1);
|
|
33
|
+
file.set("bin", bin2);
|
|
34
|
+
} else {
|
|
32
35
|
const bin3 = sortKeys(Object.entries(bin1).reduce((acc, [key, value]) => {
|
|
33
36
|
acc[key] = replaceLib(value);
|
|
34
37
|
return acc;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildPackageJson.js","names":[],"sources":["../../src/build-tests/buildPackageJson.ts"],"sourcesContent":["import type { Fn } from '#utils/types';\nimport editJsonFile from 'edit-json-file';\nimport sortKeys from 'sort-keys';\nimport { BIN_KEY, EXPORT_KEY, EXPORT_KEYS } from './constants';\nimport { getTypescriptOutdir } from './getTypescriptOutdir';\n\ntype BuldPackageJson_F = Fn
|
|
1
|
+
{"version":3,"file":"buildPackageJson.js","names":[],"sources":["../../src/build-tests/buildPackageJson.ts"],"sourcesContent":["import type { Fn } from '#utils/types';\nimport editJsonFile from 'edit-json-file';\nimport sortKeys from 'sort-keys';\nimport { BIN_KEY, EXPORT_KEY, EXPORT_KEYS } from './constants';\nimport { getTypescriptOutdir } from './getTypescriptOutdir';\n\ntype BuldPackageJson_F = Fn<[], { packageJson: object; outDir: string }>;\n\nexport const buildPackageJson: BuldPackageJson_F = () => {\n const file = editJsonFile('./package.json');\n const outDir = getTypescriptOutdir();\n const lib = `${outDir}/`;\n const replaceLib = (str: string) => str.replace(lib, '');\n\n // #region Set export values\n EXPORT_KEYS.forEach(key => {\n const value = file.get(key);\n if (value) {\n const transformed = replaceLib(value);\n file.set(key, transformed);\n }\n });\n // #endregion\n\n // #region Set Export key\n const valueExports = file.get(EXPORT_KEY);\n\n if (valueExports) {\n const transformedExports = Object.entries(valueExports).reduce(\n (acc, [key, value]) => {\n const entries = Object.entries(value as any);\n const _value = entries.reduce((acc, [key, value]) => {\n acc[key] = replaceLib(value as any);\n return acc;\n }, {} as any);\n acc[key] = key.includes('package.json') ? value : _value;\n return acc;\n },\n {} as any,\n );\n\n file.set(EXPORT_KEY, transformedExports);\n }\n // #endregion\n\n // #region Set bin\n const bin1 = file.get(BIN_KEY) as\n | Record<string, string>\n | undefined\n | string;\n\n if (bin1) {\n if (typeof bin1 === 'string') {\n const bin2 = replaceLib(bin1);\n file.set(BIN_KEY, bin2);\n } else {\n const bin2 = Object.entries(bin1).reduce((acc, [key, value]) => {\n acc[key] = replaceLib(value);\n return acc;\n }, {} as any);\n\n const bin3 = sortKeys(bin2);\n file.set(BIN_KEY, bin3);\n }\n }\n // #endregion\n\n // #region Unset some props\n file.unset('files');\n file.unset('scripts');\n file.unset('devDependencies');\n // #endregion\n\n const packageJson = file.get();\n return { packageJson, outDir };\n};\n"],"mappings":";;;;;AAQA,MAAa,yBAA4C;CACvD,MAAM,OAAO,aAAa,iBAAiB;CAC3C,MAAM,SAAS,qBAAqB;CACpC,MAAM,MAAM,GAAG,OAAO;CACtB,MAAM,cAAc,QAAgB,IAAI,QAAQ,KAAK,GAAG;AAGxD,aAAY,SAAQ,QAAO;EACzB,MAAM,QAAQ,KAAK,IAAI,IAAI;AAC3B,MAAI,OAAO;GACT,MAAM,cAAc,WAAW,MAAM;AACrC,QAAK,IAAI,KAAK,YAAY;;GAE5B;CAIF,MAAM,eAAe,KAAK,IAAI,WAAW;AAEzC,KAAI,cAAc;EAChB,MAAM,qBAAqB,OAAO,QAAQ,aAAa,CAAC,QACrD,KAAK,CAAC,KAAK,WAAW;GAErB,MAAM,SADU,OAAO,QAAQ,MAAa,CACrB,QAAQ,KAAK,CAAC,KAAK,WAAW;AACnD,QAAI,OAAO,WAAW,MAAa;AACnC,WAAO;MACN,EAAE,CAAQ;AACb,OAAI,OAAO,IAAI,SAAS,eAAe,GAAG,QAAQ;AAClD,UAAO;KAET,EAAE,CACH;AAED,OAAK,IAAI,YAAY,mBAAmB;;CAK1C,MAAM,OAAO,KAAK,IAAA,MAAY;AAK9B,KAAI,KACF,KAAI,OAAO,SAAS,UAAU;EAC5B,MAAM,OAAO,WAAW,KAAK;AAC7B,OAAK,IAAA,OAAa,KAAK;QAClB;EAML,MAAM,OAAO,SALA,OAAO,QAAQ,KAAK,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;AAC9D,OAAI,OAAO,WAAW,MAAM;AAC5B,UAAO;KACN,EAAE,CAAQ,CAEc;AAC3B,OAAK,IAAA,OAAa,KAAK;;AAM3B,MAAK,MAAM,QAAQ;AACnB,MAAK,MAAM,UAAU;AACrB,MAAK,MAAM,kBAAkB;AAI7B,QAAO;EAAE,aADW,KAAK,KAAK;EACR;EAAQ"}
|
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
//#region src/build-tests/constants.ts
|
|
3
3
|
const FILE_ORIGIN = "file";
|
|
4
4
|
const devKey = "devDependencies";
|
|
5
|
-
const
|
|
5
|
+
const THIS1 = "this-gen-1";
|
|
6
6
|
const EXPORT_KEYS = [
|
|
7
7
|
"main",
|
|
8
8
|
"typings",
|
|
@@ -16,27 +16,20 @@ const TS_PATH = "./tsconfig.json";
|
|
|
16
16
|
const PACKAGE_PATH = "./package.json";
|
|
17
17
|
const TARBALL_FOLDER = ".pack";
|
|
18
18
|
const TARBALL_EXTENSION = ".tgz";
|
|
19
|
-
const TEARDOWN_COMMAND = `pnpm remove ${
|
|
20
|
-
const FIXTURES = {
|
|
21
|
-
true: "true",
|
|
22
|
-
false: "false",
|
|
23
|
-
recursive: "TEST_RECURSIVE",
|
|
24
|
-
vitest: "VITEST_VSCODE"
|
|
25
|
-
};
|
|
19
|
+
const TEARDOWN_COMMAND = `pnpm remove ${THIS1}`;
|
|
26
20
|
//#endregion
|
|
27
21
|
exports.BIN_KEY = BIN_KEY;
|
|
28
22
|
exports.DOT = DOT;
|
|
29
23
|
exports.EXPORT_KEY = EXPORT_KEY;
|
|
30
24
|
exports.EXPORT_KEYS = EXPORT_KEYS;
|
|
31
25
|
exports.FILE_ORIGIN = FILE_ORIGIN;
|
|
32
|
-
exports.FIXTURES = FIXTURES;
|
|
33
26
|
exports.PACKAGE_PATH = PACKAGE_PATH;
|
|
34
27
|
exports.PATH_OUT_DIR = PATH_OUT_DIR;
|
|
35
28
|
exports.TARBALL_EXTENSION = TARBALL_EXTENSION;
|
|
36
29
|
exports.TARBALL_FOLDER = TARBALL_FOLDER;
|
|
37
30
|
exports.TEARDOWN_COMMAND = TEARDOWN_COMMAND;
|
|
31
|
+
exports.THIS1 = THIS1;
|
|
38
32
|
exports.TS_PATH = TS_PATH;
|
|
39
33
|
exports.devKey = devKey;
|
|
40
|
-
exports.this1 = this1;
|
|
41
34
|
|
|
42
35
|
//# sourceMappingURL=constants.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","names":[],"sources":["../../src/build-tests/constants.ts"],"sourcesContent":["export const FILE_ORIGIN = 'file';\nexport const devKey = 'devDependencies';\nexport const
|
|
1
|
+
{"version":3,"file":"constants.cjs","names":[],"sources":["../../src/build-tests/constants.ts"],"sourcesContent":["export const FILE_ORIGIN = 'file';\nexport const devKey = 'devDependencies';\nexport const THIS1 = 'this-gen-1';\nexport const EXPORT_KEYS = ['main', 'typings', 'module'] as const;\nexport const EXPORT_KEY = 'exports';\nexport const PATH_OUT_DIR = 'compilerOptions.outDir';\nexport const DOT = './';\nexport const BIN_KEY = 'bin';\nexport const TS_PATH = './tsconfig.json';\nexport const PACKAGE_PATH = './package.json';\nexport const TARBALL_FOLDER = '.pack';\nexport const TARBALL_EXTENSION = '.tgz';\nexport const TEARDOWN_COMMAND = `pnpm remove ${THIS1}`;\n\n// export const FIXTURES = {\n// true: 'true',\n// false: 'false',\n// recursive: 'TEST_RECURSIVE',\n// vitest: 'VITEST_VSCODE',\n// } as const;\n"],"mappings":";;AAAA,MAAa,cAAc;AAC3B,MAAa,SAAS;AACtB,MAAa,QAAQ;AACrB,MAAa,cAAc;CAAC;CAAQ;CAAW;CAAS;AACxD,MAAa,aAAa;AAC1B,MAAa,eAAe;AAC5B,MAAa,MAAM;AACnB,MAAa,UAAU;AACvB,MAAa,UAAU;AACvB,MAAa,eAAe;AAC5B,MAAa,iBAAiB;AAC9B,MAAa,oBAAoB;AACjC,MAAa,mBAAmB,eAAe"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const FILE_ORIGIN = "file";
|
|
2
2
|
export declare const devKey = "devDependencies";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const THIS1 = "this-gen-1";
|
|
4
4
|
export declare const EXPORT_KEYS: readonly ["main", "typings", "module"];
|
|
5
5
|
export declare const EXPORT_KEY = "exports";
|
|
6
6
|
export declare const PATH_OUT_DIR = "compilerOptions.outDir";
|
|
@@ -11,9 +11,3 @@ export declare const PACKAGE_PATH = "./package.json";
|
|
|
11
11
|
export declare const TARBALL_FOLDER = ".pack";
|
|
12
12
|
export declare const TARBALL_EXTENSION = ".tgz";
|
|
13
13
|
export declare const TEARDOWN_COMMAND = "pnpm remove this-gen-1";
|
|
14
|
-
export declare const FIXTURES: {
|
|
15
|
-
readonly true: "true";
|
|
16
|
-
readonly false: "false";
|
|
17
|
-
readonly recursive: "TEST_RECURSIVE";
|
|
18
|
-
readonly vitest: "VITEST_VSCODE";
|
|
19
|
-
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/build-tests/constants.ts
|
|
2
2
|
const FILE_ORIGIN = "file";
|
|
3
3
|
const devKey = "devDependencies";
|
|
4
|
-
const
|
|
4
|
+
const THIS1 = "this-gen-1";
|
|
5
5
|
const EXPORT_KEYS = [
|
|
6
6
|
"main",
|
|
7
7
|
"typings",
|
|
@@ -15,14 +15,8 @@ const TS_PATH = "./tsconfig.json";
|
|
|
15
15
|
const PACKAGE_PATH = "./package.json";
|
|
16
16
|
const TARBALL_FOLDER = ".pack";
|
|
17
17
|
const TARBALL_EXTENSION = ".tgz";
|
|
18
|
-
const TEARDOWN_COMMAND = `pnpm remove ${
|
|
19
|
-
const FIXTURES = {
|
|
20
|
-
true: "true",
|
|
21
|
-
false: "false",
|
|
22
|
-
recursive: "TEST_RECURSIVE",
|
|
23
|
-
vitest: "VITEST_VSCODE"
|
|
24
|
-
};
|
|
18
|
+
const TEARDOWN_COMMAND = `pnpm remove ${THIS1}`;
|
|
25
19
|
//#endregion
|
|
26
|
-
export { BIN_KEY, DOT, EXPORT_KEY, EXPORT_KEYS, FILE_ORIGIN,
|
|
20
|
+
export { BIN_KEY, DOT, EXPORT_KEY, EXPORT_KEYS, FILE_ORIGIN, PACKAGE_PATH, PATH_OUT_DIR, TARBALL_EXTENSION, TARBALL_FOLDER, TEARDOWN_COMMAND, THIS1, TS_PATH, devKey };
|
|
27
21
|
|
|
28
22
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../../src/build-tests/constants.ts"],"sourcesContent":["export const FILE_ORIGIN = 'file';\nexport const devKey = 'devDependencies';\nexport const
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../src/build-tests/constants.ts"],"sourcesContent":["export const FILE_ORIGIN = 'file';\nexport const devKey = 'devDependencies';\nexport const THIS1 = 'this-gen-1';\nexport const EXPORT_KEYS = ['main', 'typings', 'module'] as const;\nexport const EXPORT_KEY = 'exports';\nexport const PATH_OUT_DIR = 'compilerOptions.outDir';\nexport const DOT = './';\nexport const BIN_KEY = 'bin';\nexport const TS_PATH = './tsconfig.json';\nexport const PACKAGE_PATH = './package.json';\nexport const TARBALL_FOLDER = '.pack';\nexport const TARBALL_EXTENSION = '.tgz';\nexport const TEARDOWN_COMMAND = `pnpm remove ${THIS1}`;\n\n// export const FIXTURES = {\n// true: 'true',\n// false: 'false',\n// recursive: 'TEST_RECURSIVE',\n// vitest: 'VITEST_VSCODE',\n// } as const;\n"],"mappings":";AAAA,MAAa,cAAc;AAC3B,MAAa,SAAS;AACtB,MAAa,QAAQ;AACrB,MAAa,cAAc;CAAC;CAAQ;CAAW;CAAS;AACxD,MAAa,aAAa;AAC1B,MAAa,eAAe;AAC5B,MAAa,MAAM;AACnB,MAAa,UAAU;AACvB,MAAa,UAAU;AACvB,MAAa,eAAe;AAC5B,MAAa,iBAAiB;AAC9B,MAAa,oBAAoB;AACjC,MAAa,mBAAmB,eAAe"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils_identity = require("../utils/identity.cjs");
|
|
3
|
+
const require_build_tests_constants = require("./constants.cjs");
|
|
4
|
+
//#region src/build-tests/import.ts
|
|
5
|
+
const customImport = async (fn = require_utils_identity.identity) => {
|
|
6
|
+
return fn(await import(require_build_tests_constants.THIS1));
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.customImport = customImport;
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=import.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.cjs","names":["identity","THIS1"],"sources":["../../src/build-tests/import.ts"],"sourcesContent":["import { identity } from '#utils';\nimport { THIS1 } from './constants';\nimport type { IndexImport } from './types';\n\ntype CustomImport_F = <T = IndexImport>(\n fn?: (out: any) => T,\n) => Promise<T>;\n\nexport const customImport: CustomImport_F = async (fn = identity) => {\n const out = await import(THIS1);\n const out2 = fn(out);\n return out2;\n};\n"],"mappings":";;;;AAQA,MAAa,eAA+B,OAAO,KAAKA,uBAAAA,aAAa;AAGnE,QADa,GADD,MAAM,OAAOC,8BAAAA,OACL"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { identity } from "../utils/identity.js";
|
|
2
|
+
import { THIS1 } from "./constants.js";
|
|
3
|
+
//#region src/build-tests/import.ts
|
|
4
|
+
const customImport = async (fn = identity) => {
|
|
5
|
+
return fn(await import(THIS1));
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { customImport };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=import.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.js","names":[],"sources":["../../src/build-tests/import.ts"],"sourcesContent":["import { identity } from '#utils';\nimport { THIS1 } from './constants';\nimport type { IndexImport } from './types';\n\ntype CustomImport_F = <T = IndexImport>(\n fn?: (out: any) => T,\n) => Promise<T>;\n\nexport const customImport: CustomImport_F = async (fn = identity) => {\n const out = await import(THIS1);\n const out2 = fn(out);\n return out2;\n};\n"],"mappings":";;;AAQA,MAAa,eAA+B,OAAO,KAAK,aAAa;AAGnE,QADa,GADD,MAAM,OAAO,OACL"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_build_tests_constants = require("./constants.cjs");
|
|
2
3
|
const require_build_tests_addTarball = require("./addTarball.cjs");
|
|
3
4
|
const require_build_tests_cleanup = require("./cleanup.cjs");
|
|
5
|
+
const require_build_tests_import = require("./import.cjs");
|
|
6
|
+
exports.THIS1 = require_build_tests_constants.THIS1;
|
|
4
7
|
exports.addTarball = require_build_tests_addTarball.addTarball;
|
|
5
8
|
exports.cleanup = require_build_tests_cleanup.cleanup;
|
|
9
|
+
exports.customImport = require_build_tests_import.customImport;
|
package/lib/build-tests/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type IndexImport = any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.cjs","names":[],"sources":["../../src/utils/identity.ts"],"sourcesContent":["export const identity = <T>(x: T) => x;\n"],"mappings":";;AAAA,MAAa,YAAe,MAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const identity: <T>(x: T) => T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","names":[],"sources":["../../src/utils/identity.ts"],"sourcesContent":["export const identity = <T>(x: T) => x;\n"],"mappings":";AAAA,MAAa,YAAe,MAAS"}
|
package/lib/utils/index.cjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_utils_sleep = require("./sleep.cjs");
|
|
3
|
+
const require_utils_identity = require("./identity.cjs");
|
|
4
|
+
exports.identity = require_utils_identity.identity;
|
|
3
5
|
exports.sleep = require_utils_sleep.sleep;
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -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.1",
|
|
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",
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"import": "./lib/rolldown-config/index.js",
|
|
23
23
|
"require": "./lib/rolldown-config/index.cjs"
|
|
24
24
|
},
|
|
25
|
+
"./utils": {
|
|
26
|
+
"import": "./lib/utils/index.js",
|
|
27
|
+
"require": "./lib/utils/index.cjs"
|
|
28
|
+
},
|
|
25
29
|
"./vitest-alias": {
|
|
26
30
|
"import": "./lib/vitest-alias/index.js",
|
|
27
31
|
"require": "./lib/vitest-alias/index.cjs"
|
|
@@ -133,7 +137,7 @@
|
|
|
133
137
|
"@bemedev/basifun": "0.5.3",
|
|
134
138
|
"@size-limit/file": "^12.0.1",
|
|
135
139
|
"@types/edit-json-file": "^1.7.4",
|
|
136
|
-
"@types/node": "^25.5.
|
|
140
|
+
"@types/node": "^25.5.2",
|
|
137
141
|
"@types/shelljs": "^0.10.0",
|
|
138
142
|
"@vitest/coverage-v8": "3.2.4",
|
|
139
143
|
"@vitest/ui": "3.2.4",
|