@bemedev/dev-utils 0.8.3 → 1.0.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 +8 -19
- package/lib/build-tests/addTarball.cjs.map +1 -1
- package/lib/build-tests/addTarball.d.ts +1 -1
- package/lib/build-tests/addTarball.js.map +1 -1
- package/lib/build-tests/buildPackageJson.cjs.map +1 -1
- package/lib/build-tests/buildPackageJson.d.ts +3 -3
- package/lib/build-tests/buildPackageJson.js.map +1 -1
- package/lib/build-tests/cleanup.cjs.map +1 -1
- package/lib/build-tests/cleanup.d.ts +1 -1
- package/lib/build-tests/cleanup.js.map +1 -1
- package/lib/build-tests/cli/cli.cjs +0 -1
- package/lib/build-tests/cli/cli.cjs.map +1 -1
- package/lib/build-tests/cli/cli.d.ts +1 -51
- package/lib/build-tests/cli/cli.js.map +1 -1
- package/lib/build-tests/cli/index.cjs +0 -1
- package/lib/build-tests/cli/index.cjs.map +1 -1
- package/lib/build-tests/cli/index.d.ts +0 -1
- package/lib/build-tests/cli/index.js.map +1 -1
- package/lib/build-tests/cli/post.cjs +0 -1
- package/lib/build-tests/cli/post.cjs.map +1 -1
- package/lib/build-tests/cli/post.d.ts +1 -5
- package/lib/build-tests/cli/post.js.map +1 -1
- package/lib/build-tests/cli/pre.cjs +0 -1
- package/lib/build-tests/cli/pre.cjs.map +1 -1
- package/lib/build-tests/cli/pre.d.ts +1 -5
- package/lib/build-tests/cli/pre.js.map +1 -1
- package/lib/build-tests/cli/test.cjs.map +1 -1
- package/lib/build-tests/cli/test.d.ts +1 -15
- package/lib/build-tests/cli/test.js.map +1 -1
- package/lib/build-tests/constants.cjs.map +1 -1
- package/lib/build-tests/constants.d.ts +1 -1
- package/lib/build-tests/constants.js.map +1 -1
- package/lib/build-tests/getRelativePath.cjs +0 -1
- package/lib/build-tests/getRelativePath.cjs.map +1 -1
- package/lib/build-tests/getRelativePath.d.ts +1 -1
- package/lib/build-tests/getRelativePath.js.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.cjs.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.d.ts +1 -1
- package/lib/build-tests/getTypescriptOutdir.js.map +1 -1
- package/lib/build-tests/import.cjs.map +1 -1
- package/lib/build-tests/import.d.ts +2 -2
- package/lib/build-tests/import.js.map +1 -1
- package/lib/build-tests/imports/create.cjs +0 -1
- package/lib/build-tests/imports/create.cjs.map +1 -1
- package/lib/build-tests/imports/create.d.ts +3 -3
- package/lib/build-tests/imports/create.js.map +1 -1
- package/lib/build-tests/imports/helper.cjs +0 -1
- package/lib/build-tests/imports/helper.cjs.map +1 -1
- package/lib/build-tests/imports/helper.d.ts +3 -7
- package/lib/build-tests/imports/helper.js.map +1 -1
- package/lib/build-tests/imports/index.d.ts +1 -1
- package/lib/build-tests/index.d.ts +5 -5
- package/lib/build-tests/pack.cjs.map +1 -1
- package/lib/build-tests/pack.d.ts +1 -1
- package/lib/build-tests/pack.js.map +1 -1
- package/lib/rolldown-config/config.cjs +6 -11
- package/lib/rolldown-config/config.cjs.map +1 -1
- package/lib/rolldown-config/config.d.ts +1 -1
- package/lib/rolldown-config/config.js +1 -5
- package/lib/rolldown-config/config.js.map +1 -1
- package/lib/rolldown-config/constants.cjs.map +1 -1
- package/lib/rolldown-config/constants.d.ts +5 -5
- package/lib/rolldown-config/constants.js.map +1 -1
- package/lib/rolldown-config/helpers.cjs +0 -1
- package/lib/rolldown-config/helpers.cjs.map +1 -1
- package/lib/rolldown-config/helpers.d.ts +2 -2
- package/lib/rolldown-config/helpers.js.map +1 -1
- package/lib/rolldown-config/index.d.ts +3 -3
- package/lib/rolldown-config/input.cjs +1 -2
- package/lib/rolldown-config/input.cjs.map +1 -1
- package/lib/rolldown-config/input.d.ts +1 -1
- package/lib/rolldown-config/input.js +1 -1
- package/lib/rolldown-config/input.js.map +1 -1
- package/lib/rolldown-config/output.cjs.map +1 -1
- package/lib/rolldown-config/output.d.ts +1 -15
- package/lib/rolldown-config/output.js.map +1 -1
- package/lib/rolldown-config/plugins/circulars.cjs +6 -5
- package/lib/rolldown-config/plugins/circulars.cjs.map +1 -1
- package/lib/rolldown-config/plugins/circulars.d.ts +9 -7
- package/lib/rolldown-config/plugins/circulars.js +5 -3
- package/lib/rolldown-config/plugins/circulars.js.map +1 -1
- package/lib/rolldown-config/plugins/clean.cjs +4 -9
- package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
- package/lib/rolldown-config/plugins/clean.d.ts +4 -13
- package/lib/rolldown-config/plugins/clean.js +4 -7
- package/lib/rolldown-config/plugins/clean.js.map +1 -1
- package/lib/rolldown-config/plugins/externals.cjs +1 -1
- package/lib/rolldown-config/plugins/externals.cjs.map +1 -1
- package/lib/rolldown-config/plugins/externals.d.ts +7 -6
- package/lib/rolldown-config/plugins/externals.js +1 -0
- package/lib/rolldown-config/plugins/externals.js.map +1 -1
- package/lib/rolldown-config/plugins/index.cjs +1 -8
- package/lib/rolldown-config/plugins/index.cjs.map +1 -1
- package/lib/rolldown-config/plugins/index.d.ts +2 -27
- package/lib/rolldown-config/plugins/index.js +0 -6
- package/lib/rolldown-config/plugins/index.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.cjs +45 -33
- package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.cjs +39 -46
- package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.d.ts +4 -2
- package/lib/rolldown-config/plugins/typescript.config.js +41 -47
- package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.d.ts +6 -6
- package/lib/rolldown-config/plugins/typescript.js +44 -30
- package/lib/rolldown-config/plugins/typescript.js.map +1 -1
- package/lib/rolldown-config/types.d.ts +13 -13
- package/lib/{rolldown-config/utils.cjs → utils/array.cjs} +2 -2
- package/lib/utils/array.cjs.map +1 -0
- package/lib/utils/array.d.ts +2 -0
- package/lib/{rolldown-config/utils.js → utils/array.js} +2 -2
- package/lib/utils/array.js.map +1 -0
- package/lib/utils/identity.d.ts +1 -1
- package/lib/utils/index.cjs +2 -0
- package/lib/utils/index.d.ts +4 -3
- package/lib/utils/index.js +2 -1
- package/lib/utils/sleep.cjs.map +1 -1
- package/lib/utils/sleep.d.ts +1 -1
- package/lib/utils/sleep.js.map +1 -1
- package/lib/utils/types.d.ts +5 -1
- package/lib/vitest-exclude/index.d.ts +1 -1
- package/lib/vitest-exclude/types.d.ts +8 -11
- package/lib/vitest-exclude/vitest.cjs +6 -9
- package/lib/vitest-exclude/vitest.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.d.ts +15 -30
- package/lib/vitest-exclude/vitest.js +6 -9
- package/lib/vitest-exclude/vitest.js.map +1 -1
- package/lib/vitest-exclude/vitest.utils.cjs +1 -2
- package/lib/vitest-exclude/vitest.utils.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.utils.d.ts +2 -2
- package/lib/vitest-exclude/vitest.utils.js +1 -1
- package/lib/vitest-exclude/vitest.utils.js.map +1 -1
- package/lib/vitest-extended/acceptation.cjs +1 -5
- package/lib/vitest-extended/acceptation.cjs.map +1 -1
- package/lib/vitest-extended/acceptation.d.ts +3 -7
- package/lib/vitest-extended/acceptation.js +1 -4
- package/lib/vitest-extended/acceptation.js.map +1 -1
- package/lib/vitest-extended/bemedev/globals/types.d.ts +4 -1
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.cjs +4 -3
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.cjs.map +1 -1
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.d.ts +10 -9
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.js +4 -3
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.js.map +1 -1
- package/lib/vitest-extended/createTests.cjs +22 -24
- package/lib/vitest-extended/createTests.cjs.map +1 -1
- package/lib/vitest-extended/createTests.d.ts +34 -56
- package/lib/vitest-extended/createTests.js +22 -23
- package/lib/vitest-extended/createTests.js.map +1 -1
- package/lib/vitest-extended/createTests.types.d.ts +10 -6
- package/lib/vitest-extended/done.cjs +6 -4
- package/lib/vitest-extended/done.cjs.map +1 -1
- package/lib/vitest-extended/done.d.ts +8 -13
- package/lib/vitest-extended/done.js +6 -3
- package/lib/vitest-extended/done.js.map +1 -1
- package/lib/vitest-extended/each/error.cjs +0 -1
- package/lib/vitest-extended/each/error.cjs.map +1 -1
- package/lib/vitest-extended/each/error.d.ts +1 -1
- package/lib/vitest-extended/each/error.js.map +1 -1
- package/lib/vitest-extended/each/error.types.d.ts +10 -4
- package/lib/vitest-extended/each/index.d.ts +2 -2
- package/lib/vitest-extended/each/pass.cjs +13 -16
- package/lib/vitest-extended/each/pass.cjs.map +1 -1
- package/lib/vitest-extended/each/pass.d.ts +26 -28
- package/lib/vitest-extended/each/pass.js +13 -15
- package/lib/vitest-extended/each/pass.js.map +1 -1
- package/lib/vitest-extended/each/pass.types.d.ts +18 -6
- package/lib/vitest-extended/fakeWaiter.cjs.map +1 -1
- package/lib/vitest-extended/fakeWaiter.d.ts +3 -3
- package/lib/vitest-extended/fakeWaiter.js.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.js.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.cjs +2 -2
- package/lib/vitest-extended/fixtures/partialCall.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.js +2 -2
- package/lib/vitest-extended/fixtures/partialCall.js.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.js.map +1 -1
- package/lib/vitest-extended/fixtures/zod.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/zod.js.map +1 -1
- package/lib/vitest-extended/identity.cjs +0 -1
- package/lib/vitest-extended/identity.cjs.map +1 -1
- package/lib/vitest-extended/identity.d.ts +2 -2
- package/lib/vitest-extended/identity.js.map +1 -1
- package/lib/vitest-extended/index.d.ts +6 -6
- package/lib/vitest-extended/isDefined.cjs.map +1 -1
- package/lib/vitest-extended/isDefined.d.ts +1 -1
- package/lib/vitest-extended/isDefined.js.map +1 -1
- package/lib/vitest-extended/isFunction.cjs.map +1 -1
- package/lib/vitest-extended/isFunction.d.ts +1 -1
- package/lib/vitest-extended/isFunction.js.map +1 -1
- package/lib/vitest-extended/toArray.cjs.map +1 -1
- package/lib/vitest-extended/toArray.d.ts +1 -1
- package/lib/vitest-extended/toArray.js.map +1 -1
- package/lib/vitest-extended/toStringFlat.cjs.map +1 -1
- package/lib/vitest-extended/toStringFlat.d.ts +1 -1
- package/lib/vitest-extended/toStringFlat.js.map +1 -1
- package/lib/vitest-extended/types.d.ts +40 -42
- package/package.json +14 -10
- package/lib/rolldown-config/plugins/alias.cjs +0 -17
- package/lib/rolldown-config/plugins/alias.cjs.map +0 -1
- package/lib/rolldown-config/plugins/alias.d.ts +0 -25
- package/lib/rolldown-config/plugins/alias.js +0 -14
- package/lib/rolldown-config/plugins/alias.js.map +0 -1
- package/lib/rolldown-config/plugins/tsPaths.cjs +0 -17
- package/lib/rolldown-config/plugins/tsPaths.cjs.map +0 -1
- package/lib/rolldown-config/plugins/tsPaths.d.ts +0 -9
- package/lib/rolldown-config/plugins/tsPaths.js +0 -14
- package/lib/rolldown-config/plugins/tsPaths.js.map +0 -1
- package/lib/rolldown-config/utils.cjs.map +0 -1
- package/lib/rolldown-config/utils.d.ts +0 -2
- package/lib/rolldown-config/utils.js.map +0 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { toArray } from "
|
|
1
|
+
import { toArray } from "../../utils/array.js";
|
|
2
2
|
import "../constants.js";
|
|
3
|
-
import { readTsConfig } from "./typescript.config.js";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
3
|
+
import { findConfigFile, readTsConfig } from "./typescript.config.js";
|
|
4
|
+
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
5
|
+
import { basename, dirname, join, relative } from "path";
|
|
6
|
+
import { globSync } from "glob";
|
|
7
|
+
import { transformSync } from "oxc-transform";
|
|
6
8
|
import { replaceTscAliasPaths } from "tsc-alias";
|
|
7
9
|
//#region src/rolldown-config/plugins/typescript.ts
|
|
8
10
|
const typescript = ({ exclude, include, declarationMap, dir } = {}) => {
|
|
@@ -18,34 +20,46 @@ const typescript = ({ exclude, include, declarationMap, dir } = {}) => {
|
|
|
18
20
|
async handler() {
|
|
19
21
|
if (done) return;
|
|
20
22
|
const cwd = process.cwd();
|
|
21
|
-
const tsconfigPath =
|
|
23
|
+
const tsconfigPath = findConfigFile(cwd, "tsconfig.json");
|
|
22
24
|
const configFile = readTsConfig(tsconfigPath);
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
const outDir = configFile.compilerOptions.outDir ?? dir ?? "lib";
|
|
26
|
+
const rootDir = configFile.compilerOptions.rootDir ?? join(cwd, "src");
|
|
27
|
+
let files;
|
|
28
|
+
if (include && Object.keys(include).length > 0) files = Object.values(include);
|
|
29
|
+
else files = globSync(join(rootDir, "**/*.{ts,tsx,cts,mts}"), { ignore: toArray(exclude) });
|
|
30
|
+
files = files.filter((file) => !file.endsWith(".d.ts") && !file.endsWith(".d.cts") && !file.endsWith(".d.mts"));
|
|
31
|
+
const errors = [];
|
|
32
|
+
for (const file of files) try {
|
|
33
|
+
const result = transformSync(file, readFileSync(file, "utf-8"), {
|
|
34
|
+
typescript: { declaration: { sourcemap: !!declarationMap } },
|
|
35
|
+
sourcemap: !!declarationMap
|
|
36
|
+
});
|
|
37
|
+
if (result.errors && result.errors.length > 0) errors.push(...result.errors);
|
|
38
|
+
const relativePath = relative(rootDir, file);
|
|
39
|
+
let dtsName = relativePath;
|
|
40
|
+
if (relativePath.endsWith(".tsx")) dtsName = relativePath.slice(0, -4) + ".d.ts";
|
|
41
|
+
else if (relativePath.endsWith(".ts")) dtsName = relativePath.slice(0, -3) + ".d.ts";
|
|
42
|
+
else if (relativePath.endsWith(".cts")) dtsName = relativePath.slice(0, -4) + ".d.cts";
|
|
43
|
+
else if (relativePath.endsWith(".mts")) dtsName = relativePath.slice(0, -4) + ".d.mts";
|
|
44
|
+
const outPath = join(outDir, dtsName);
|
|
45
|
+
const outMapPath = outPath + ".map";
|
|
46
|
+
mkdirSync(dirname(outPath), { recursive: true });
|
|
47
|
+
let dtsCode = result.declaration ?? "";
|
|
48
|
+
if (declarationMap && result.declarationMap) {
|
|
49
|
+
dtsCode += `\n//# sourceMappingURL=${basename(dtsName)}.map\n`;
|
|
50
|
+
writeFileSync(outMapPath, JSON.stringify(result.declarationMap), "utf-8");
|
|
36
51
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (errors.length > 0) console.error(ts.formatDiagnosticsWithColorAndContext(errors, host));
|
|
52
|
+
writeFileSync(outPath, dtsCode, "utf-8");
|
|
53
|
+
} catch (err) {
|
|
54
|
+
console.error(`[bemedev-dts] Failed to process ${file}:`, err);
|
|
55
|
+
}
|
|
56
|
+
if (errors.length > 0) {
|
|
57
|
+
console.error(`[bemedev-dts] Generation completed with errors:`);
|
|
58
|
+
for (const err of errors) {
|
|
59
|
+
console.error(`Error in ${err.filename || "unknown file"}: ${err.message}`);
|
|
60
|
+
if (err.codeframe) console.error(err.codeframe);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
49
63
|
await replaceTscAliasPaths({
|
|
50
64
|
configFile: tsconfigPath,
|
|
51
65
|
outDir
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"typescript.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, dirname, join, relative } from 'node:path';\n\nimport { globSync } from 'glob';\nimport { transformSync } from 'oxc-transform';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { findConfigFile, readTsConfig } from './typescript.config';\n\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\nexport const typescript = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = findConfigFile(cwd, 'tsconfig.json')!;\n\n const configFile = readTsConfig(tsconfigPath);\n const outDir =\n configFile.compilerOptions.outDir ?? dir ?? DEFAULT_DIR;\n const rootDir =\n configFile.compilerOptions.rootDir ?? join(cwd, 'src');\n\n let files: string[];\n if (include && Object.keys(include).length > 0) {\n files = Object.values(include);\n } else {\n files = globSync(join(rootDir, '**/*.{ts,tsx,cts,mts}'), {\n ignore: toArray(exclude),\n });\n }\n\n files = files.filter(\n file =>\n !file.endsWith('.d.ts') &&\n !file.endsWith('.d.cts') &&\n !file.endsWith('.d.mts'),\n );\n\n const errors: any[] = [];\n\n for (const file of files) {\n try {\n const content = readFileSync(file, 'utf-8');\n const result = transformSync(file, content, {\n typescript: { declaration: { sourcemap: !!declarationMap } },\n sourcemap: !!declarationMap,\n });\n\n if (result.errors && result.errors.length > 0) {\n errors.push(...result.errors);\n }\n\n // Compute output path relative to rootDir\n const relativePath = relative(rootDir, file);\n let dtsName = relativePath;\n if (relativePath.endsWith('.tsx')) {\n dtsName = relativePath.slice(0, -4) + '.d.ts';\n } else if (relativePath.endsWith('.ts')) {\n dtsName = relativePath.slice(0, -3) + '.d.ts';\n } else if (relativePath.endsWith('.cts')) {\n dtsName = relativePath.slice(0, -4) + '.d.cts';\n } else if (relativePath.endsWith('.mts')) {\n dtsName = relativePath.slice(0, -4) + '.d.mts';\n }\n\n const outPath = join(outDir, dtsName);\n const outMapPath = outPath + '.map';\n\n // Ensure output directory exists\n mkdirSync(dirname(outPath), { recursive: true });\n\n let dtsCode = result.declaration ?? '';\n if (declarationMap && result.declarationMap) {\n dtsCode += `\\n//# sourceMappingURL=${basename(dtsName)}.map\\n`;\n writeFileSync(\n outMapPath,\n JSON.stringify(result.declarationMap),\n 'utf-8',\n );\n }\n\n writeFileSync(outPath, dtsCode, 'utf-8');\n } catch (err: any) {\n console.error(`[bemedev-dts] Failed to process ${file}:`, err);\n }\n }\n\n if (errors.length > 0) {\n console.error(`[bemedev-dts] Generation completed with errors:`);\n for (const err of errors) {\n console.error(\n `Error in ${err.filename || 'unknown file'}: ${err.message}`,\n );\n if (err.codeframe) {\n console.error(err.codeframe);\n }\n }\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;;;AAoBA,MAAa,cAAc,EACzB,SACA,SACA,gBACA,QACS,CAAC,MAA4B;CACtC,IAAI,OAAO;CAEX,OAAO;EACL,MAAM;EACN,QAAQ,MAAM;GAIZ,KAAK,WAAW,CAAC,GAHA,QAAQ,KAAK,QAAQ,CAAC,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,MAElB,GAAG,oBAAoB;GAClD,OAAO;EACT;EACA,aAAa;GACX,OAAO;GACP,MAAM,UAAU;IACd,IAAI,MAAM;IACV,MAAM,MAAM,QAAQ,IAAI;IAExB,MAAM,eAAe,eAAe,KAAK,eAAe;IAExD,MAAM,aAAa,aAAa,YAAY;IAC5C,MAAM,SACJ,WAAW,gBAAgB,UAAU,OAAA;IACvC,MAAM,UACJ,WAAW,gBAAgB,WAAW,KAAK,KAAK,KAAK;IAEvD,IAAI;IACJ,IAAI,WAAW,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,GAC3C,QAAQ,OAAO,OAAO,OAAO;SAE7B,QAAQ,SAAS,KAAK,SAAS,uBAAuB,GAAG,EACvD,QAAQ,QAAQ,OAAO,EACzB,CAAC;IAGH,QAAQ,MAAM,QACZ,SACE,CAAC,KAAK,SAAS,OAAO,KACtB,CAAC,KAAK,SAAS,QAAQ,KACvB,CAAC,KAAK,SAAS,QAAQ,CAC3B;IAEA,MAAM,SAAgB,CAAC;IAEvB,KAAK,MAAM,QAAQ,OACjB,IAAI;KAEF,MAAM,SAAS,cAAc,MADb,aAAa,MAAM,OACM,GAAG;MAC1C,YAAY,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,eAAe,EAAE;MAC3D,WAAW,CAAC,CAAC;KACf,CAAC;KAED,IAAI,OAAO,UAAU,OAAO,OAAO,SAAS,GAC1C,OAAO,KAAK,GAAG,OAAO,MAAM;KAI9B,MAAM,eAAe,SAAS,SAAS,IAAI;KAC3C,IAAI,UAAU;KACd,IAAI,aAAa,SAAS,MAAM,GAC9B,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,KAAK,GACpC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,MAAM,GACrC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;UACjC,IAAI,aAAa,SAAS,MAAM,GACrC,UAAU,aAAa,MAAM,GAAG,EAAE,IAAI;KAGxC,MAAM,UAAU,KAAK,QAAQ,OAAO;KACpC,MAAM,aAAa,UAAU;KAG7B,UAAU,QAAQ,OAAO,GAAG,EAAE,WAAW,KAAK,CAAC;KAE/C,IAAI,UAAU,OAAO,eAAe;KACpC,IAAI,kBAAkB,OAAO,gBAAgB;MAC3C,WAAW,0BAA0B,SAAS,OAAO,EAAE;MACvD,cACE,YACA,KAAK,UAAU,OAAO,cAAc,GACpC,OACF;KACF;KAEA,cAAc,SAAS,SAAS,OAAO;IACzC,SAAS,KAAU;KACjB,QAAQ,MAAM,mCAAmC,KAAK,IAAI,GAAG;IAC/D;IAGF,IAAI,OAAO,SAAS,GAAG;KACrB,QAAQ,MAAM,iDAAiD;KAC/D,KAAK,MAAM,OAAO,QAAQ;MACxB,QAAQ,MACN,YAAY,IAAI,YAAY,eAAe,IAAI,IAAI,SACrD;MACA,IAAI,IAAI,WACN,QAAQ,MAAM,IAAI,SAAS;KAE/B;IACF;IAEA,MAAM,qBAAqB;KAAE,YAAY;KAAc;IAAO,CAAC;IAE/D,OAAO;IACP,QAAQ,IAAI,yBAAyB;GACvC;EACF;CACF;AACF"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type { RolldownPluginOption, RolldownOptions } from
|
|
1
|
+
import type { RolldownPluginOption, RolldownOptions } from "rolldown";
|
|
2
2
|
export type { RolldownOptions };
|
|
3
|
-
import type { PLUGIN_BUILDERS } from
|
|
3
|
+
import type { PLUGIN_BUILDERS } from "./plugins";
|
|
4
4
|
export type ToArray_F = <T>(value?: T | T[]) => T[];
|
|
5
5
|
export type Params = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
circularDeps?: string | string[];
|
|
7
|
+
excludesTS?: string | string[];
|
|
8
|
+
ignoresJS?: string | string[];
|
|
9
|
+
externals?: string | string[];
|
|
10
|
+
dir?: string;
|
|
11
|
+
sourcemap?: boolean;
|
|
12
|
+
declarationMap?: boolean;
|
|
13
|
+
plugins?: (RolldownPluginOption | keyof typeof PLUGIN_BUILDERS)[];
|
|
14
14
|
};
|
|
15
15
|
export type BuildInput_F = (...ignores: string[]) => Record<string, string>;
|
|
16
16
|
export type Config_F = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
(additionals?: Params): RolldownOptions;
|
|
18
|
+
bemedev: (additionals?: Params) => RolldownOptions;
|
|
19
|
+
default: (additionals?: Params) => RolldownOptions;
|
|
20
20
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/
|
|
2
|
+
//#region src/utils/array.ts
|
|
3
3
|
const toArray = (value) => {
|
|
4
4
|
if (value === void 0 || value === null) return [];
|
|
5
5
|
if (Array.isArray(value)) return value;
|
|
@@ -8,4 +8,4 @@ const toArray = (value) => {
|
|
|
8
8
|
//#endregion
|
|
9
9
|
exports.toArray = toArray;
|
|
10
10
|
|
|
11
|
-
//# sourceMappingURL=
|
|
11
|
+
//# sourceMappingURL=array.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.cjs","names":[],"sources":["../../src/utils/array.ts"],"sourcesContent":["import type { ToArray_F } from './types';\n\nexport const toArray: ToArray_F = value => {\n const check1 = value === undefined || value === null;\n\n if (check1) return [];\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n"],"mappings":";;AAEA,MAAa,WAAqB,UAAS;CAGzC,IAFe,UAAU,KAAA,KAAa,UAAU,MAEpC,OAAO,CAAC;CACpB,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO;CAEjC,OAAO,CAAC,KAAK;AACf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/utils/array.ts
|
|
2
2
|
const toArray = (value) => {
|
|
3
3
|
if (value === void 0 || value === null) return [];
|
|
4
4
|
if (Array.isArray(value)) return value;
|
|
@@ -7,4 +7,4 @@ const toArray = (value) => {
|
|
|
7
7
|
//#endregion
|
|
8
8
|
export { toArray };
|
|
9
9
|
|
|
10
|
-
//# sourceMappingURL=
|
|
10
|
+
//# sourceMappingURL=array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.js","names":[],"sources":["../../src/utils/array.ts"],"sourcesContent":["import type { ToArray_F } from './types';\n\nexport const toArray: ToArray_F = value => {\n const check1 = value === undefined || value === null;\n\n if (check1) return [];\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n"],"mappings":";AAEA,MAAa,WAAqB,UAAS;CAGzC,IAFe,UAAU,KAAA,KAAa,UAAU,MAEpC,OAAO,CAAC;CACpB,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO;CAEjC,OAAO,CAAC,KAAK;AACf"}
|
package/lib/utils/identity.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const identity:
|
|
1
|
+
export declare const identity: unknown;
|
package/lib/utils/index.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_utils_sleep = require("./sleep.cjs");
|
|
3
3
|
const require_utils_identity = require("./identity.cjs");
|
|
4
|
+
const require_utils_array = require("./array.cjs");
|
|
4
5
|
exports.identity = require_utils_identity.identity;
|
|
5
6
|
exports.sleep = require_utils_sleep.sleep;
|
|
7
|
+
exports.toArray = require_utils_array.toArray;
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./identity";
|
|
2
|
+
export * from "./sleep";
|
|
3
|
+
export * from "./types";
|
|
4
|
+
export * from "./array";
|
package/lib/utils/index.js
CHANGED
package/lib/utils/sleep.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.cjs","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["export const sleep = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"],"mappings":";;AAAA,MAAa,SAAS,OAAe;
|
|
1
|
+
{"version":3,"file":"sleep.cjs","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["export const sleep = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"],"mappings":";;AAAA,MAAa,SAAS,OAAe;CACnC,OAAO,IAAI,SAAQ,YAAW,WAAW,SAAS,EAAE,CAAC;AACvD"}
|
package/lib/utils/sleep.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const sleep:
|
|
1
|
+
export declare const sleep: unknown;
|
package/lib/utils/sleep.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.js","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["export const sleep = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"],"mappings":";AAAA,MAAa,SAAS,OAAe;
|
|
1
|
+
{"version":3,"file":"sleep.js","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["export const sleep = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"],"mappings":";AAAA,MAAa,SAAS,OAAe;CACnC,OAAO,IAAI,SAAQ,YAAW,WAAW,SAAS,EAAE,CAAC;AACvD"}
|
package/lib/utils/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./vitest";
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import type { Plugin } from
|
|
1
|
+
import type { Plugin } from "vitest/config";
|
|
2
2
|
export type Define<T> = Exclude<T, undefined>;
|
|
3
|
-
export type Args = [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ignoreCoverageFiles?: string[];
|
|
11
|
-
}
|
|
12
|
-
];
|
|
3
|
+
export type Args = [{
|
|
4
|
+
patternTest: string | string[];
|
|
5
|
+
patternCov: string | string[];
|
|
6
|
+
}, {
|
|
7
|
+
ignoreTestFiles?: string[];
|
|
8
|
+
ignoreCoverageFiles?: string[];
|
|
9
|
+
}];
|
|
13
10
|
export type WithPattern = (...args: Args) => Plugin;
|
|
@@ -6,7 +6,7 @@ const require_vitest_exclude_constants = require("./constants.cjs");
|
|
|
6
6
|
* Create includeTest and includeCoverage arrays from glob patterns
|
|
7
7
|
*
|
|
8
8
|
* @param args Globs to ignore for test and coverage files
|
|
9
|
-
* @returns
|
|
9
|
+
* @returns An object with includeTest and includeCoverage string arrays
|
|
10
10
|
*/
|
|
11
11
|
async function create(args = {}, root) {
|
|
12
12
|
const firsts = {
|
|
@@ -24,13 +24,10 @@ create.withPattern = async ({ patternTest, patternCov } = {}, { ignoreTestFiles,
|
|
|
24
24
|
/**
|
|
25
25
|
* Plugin to add files with glob patterns to vitest
|
|
26
26
|
*
|
|
27
|
-
* @
|
|
28
|
-
* @
|
|
29
|
-
*
|
|
27
|
+
* @remarks You don't have to use test.exclude. The default search pattern is : './src/**\/*.ts'
|
|
28
|
+
* @param ignore Globs to exclude inside
|
|
29
|
+
* @returns A vitest config
|
|
30
30
|
* @see {@link exclude.withPattern}
|
|
31
|
-
* @remarks
|
|
32
|
-
* You don't have to use test.exclude.
|
|
33
|
-
* The default search patter is './src/**\/*.ts'
|
|
34
31
|
*/
|
|
35
32
|
function exclude(args = {}) {
|
|
36
33
|
return {
|
|
@@ -68,8 +65,8 @@ function exclude(args = {}) {
|
|
|
68
65
|
* Plugin to add files with glob patterns to vitest
|
|
69
66
|
*
|
|
70
67
|
* @param pattern The pattern where searching files
|
|
71
|
-
* @param ignore
|
|
72
|
-
* @returns
|
|
68
|
+
* @param ignore Globs to exclude inside
|
|
69
|
+
* @returns A vitest config
|
|
73
70
|
*/
|
|
74
71
|
exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, ignoreTestFiles }) => {
|
|
75
72
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.cjs","names":["testPattern","defaultCovPattern","buildInclude"],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\
|
|
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 * 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] = {}, root?: string) {\n const firsts = {\n patternTest: testPattern(root),\n patternCov: defaultCovPattern(root),\n };\n\n return create.withPattern(firsts, args, root);\n}\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 * Plugin to add files with glob patterns to vitest\n *\n * @remarks You don't have to use test.exclude. The default search pattern is : './src/**\\/*.ts'\n * @param ignore Globs to exclude inside\n * @returns A vitest config\n * @see {@link exclude.withPattern}\n */\nexport function exclude(args: Args[1] = {}) {\n return {\n name,\n enforce: 'pre',\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 * 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) => {\n return {\n name,\n enforce: 'pre',\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":";;;;;;;;;;AAgBA,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;AAEA,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;;;;;;;;;AAUA,SAAgB,QAAQ,OAAgB,CAAC,GAAG;CAC1C,OAAO;EACL,MAAA,iCAAA;EACA,SAAS;EACT,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;;;;;;;;AASA,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACpB;CACH,OAAO;EACL,MAAA,iCAAA;EACA,SAAS;EACT,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,33 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Plugin } from "vitest/config";
|
|
2
|
+
import type { Args } from "./types";
|
|
3
3
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export declare function create(args?: Args[1], root?: string)
|
|
10
|
-
files: string[];
|
|
11
|
-
coverage: string[];
|
|
12
|
-
}>;
|
|
13
|
-
export declare namespace create {
|
|
14
|
-
var withPattern: ({ patternTest, patternCov }?: Partial<Args[0]>, { ignoreTestFiles, ignoreCoverageFiles }?: Args[1], root?: string) => Promise<{
|
|
15
|
-
files: string[];
|
|
16
|
-
coverage: string[];
|
|
17
|
-
}>;
|
|
18
|
-
}
|
|
4
|
+
* Create includeTest and includeCoverage arrays from glob patterns
|
|
5
|
+
*
|
|
6
|
+
* @param args Globs to ignore for test and coverage files
|
|
7
|
+
* @returns An object with includeTest and includeCoverage string arrays
|
|
8
|
+
*/
|
|
9
|
+
export declare function create(args?: Args[1], root?: string);
|
|
19
10
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* You don't have to use test.exclude.
|
|
28
|
-
* The default search patter is './src/**\/*.ts'
|
|
29
|
-
*/
|
|
11
|
+
* Plugin to add files with glob patterns to vitest
|
|
12
|
+
*
|
|
13
|
+
* @remarks You don't have to use test.exclude. The default search pattern is : './src/**\/*.ts'
|
|
14
|
+
* @param ignore Globs to exclude inside
|
|
15
|
+
* @returns A vitest config
|
|
16
|
+
* @see {@link exclude.withPattern}
|
|
17
|
+
*/
|
|
30
18
|
export declare function exclude(args?: Args[1]): Plugin;
|
|
31
|
-
export declare namespace exclude {
|
|
32
|
-
var withPattern: WithPattern;
|
|
33
|
-
}
|
|
@@ -5,7 +5,7 @@ import { name } from "./constants.js";
|
|
|
5
5
|
* Create includeTest and includeCoverage arrays from glob patterns
|
|
6
6
|
*
|
|
7
7
|
* @param args Globs to ignore for test and coverage files
|
|
8
|
-
* @returns
|
|
8
|
+
* @returns An object with includeTest and includeCoverage string arrays
|
|
9
9
|
*/
|
|
10
10
|
async function create(args = {}, root) {
|
|
11
11
|
const firsts = {
|
|
@@ -23,13 +23,10 @@ create.withPattern = async ({ patternTest, patternCov } = {}, { ignoreTestFiles,
|
|
|
23
23
|
/**
|
|
24
24
|
* Plugin to add files with glob patterns to vitest
|
|
25
25
|
*
|
|
26
|
-
* @
|
|
27
|
-
* @
|
|
28
|
-
*
|
|
26
|
+
* @remarks You don't have to use test.exclude. The default search pattern is : './src/**\/*.ts'
|
|
27
|
+
* @param ignore Globs to exclude inside
|
|
28
|
+
* @returns A vitest config
|
|
29
29
|
* @see {@link exclude.withPattern}
|
|
30
|
-
* @remarks
|
|
31
|
-
* You don't have to use test.exclude.
|
|
32
|
-
* The default search patter is './src/**\/*.ts'
|
|
33
30
|
*/
|
|
34
31
|
function exclude(args = {}) {
|
|
35
32
|
return {
|
|
@@ -67,8 +64,8 @@ function exclude(args = {}) {
|
|
|
67
64
|
* Plugin to add files with glob patterns to vitest
|
|
68
65
|
*
|
|
69
66
|
* @param pattern The pattern where searching files
|
|
70
|
-
* @param ignore
|
|
71
|
-
* @returns
|
|
67
|
+
* @param ignore Globs to exclude inside
|
|
68
|
+
* @returns A vitest config
|
|
72
69
|
*/
|
|
73
70
|
exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, ignoreTestFiles }) => {
|
|
74
71
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.js","names":[],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\
|
|
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 * 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] = {}, root?: string) {\n const firsts = {\n patternTest: testPattern(root),\n patternCov: defaultCovPattern(root),\n };\n\n return create.withPattern(firsts, args, root);\n}\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 * Plugin to add files with glob patterns to vitest\n *\n * @remarks You don't have to use test.exclude. The default search pattern is : './src/**\\/*.ts'\n * @param ignore Globs to exclude inside\n * @returns A vitest config\n * @see {@link exclude.withPattern}\n */\nexport function exclude(args: Args[1] = {}) {\n return {\n name,\n enforce: 'pre',\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 * 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) => {\n return {\n name,\n enforce: 'pre',\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":";;;;;;;;;AAgBA,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;AAEA,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;;;;;;;;;AAUA,SAAgB,QAAQ,OAAgB,CAAC,GAAG;CAC1C,OAAO;EACL;EACA,SAAS;EACT,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;;;;;;;;AASA,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACpB;CACH,OAAO;EACL;EACA,SAAS;EACT,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,8 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
2
|
let fs = require("fs");
|
|
4
|
-
let glob = require("glob");
|
|
5
3
|
let path = require("path");
|
|
4
|
+
let glob = require("glob");
|
|
6
5
|
//#region src/vitest-exclude/vitest.utils.ts
|
|
7
6
|
const hasSrc = (root = process.cwd()) => {
|
|
8
7
|
return (0, fs.existsSync)((0, path.join)(root, "src"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.utils.cjs","names":[],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport {
|
|
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":";;;;;AAKA,MAAa,UAAU,OAAO,QAAQ,IAAI,MAAM;CAC9C,QAAA,GAAA,GAAA,WAAA,EAAA,GAAA,KAAA,KAAA,CAAuB,MAAM,KAAK,CAAC;AACrC;AAEA,MAAa,qBAAqB,SAAkB;;CAGlD,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B;AAEA,MAAM,UAAU,QAAgB,IAAI,QAAQ,OAAO,GAAG;AACtD,MAAa,eAAe,OAC1B,SACA,QACA,OAAO,QAAQ,IAAI,MAChB;CAGH,QAAO,OAAA,GAAA,KAAA,KAAA,CAFoB,SAAS;EAAE;EAAQ,KAAK;CAAK,CAAC,EAAA,CAE1C,IAAI,MAAM,CAAC,CAAC,KAAK;AAClC;AAEA,MAAa,eAAe,SAAkB;;CAG5C,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const hasSrc:
|
|
1
|
+
export declare const hasSrc: unknown;
|
|
2
2
|
export declare const defaultCovPattern: (root?: string) => string;
|
|
3
|
-
export declare const buildInclude:
|
|
3
|
+
export declare const buildInclude: unknown;
|
|
4
4
|
export declare const testPattern: (root?: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.utils.js","names":[],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport {
|
|
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":";;;;AAKA,MAAa,UAAU,OAAO,QAAQ,IAAI,MAAM;CAC9C,OAAO,WAAW,KAAK,MAAM,KAAK,CAAC;AACrC;AAEA,MAAa,qBAAqB,SAAkB;;CAGlD,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B;AAEA,MAAM,UAAU,QAAgB,IAAI,QAAQ,OAAO,GAAG;AACtD,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;AAEA,MAAa,eAAe,SAAkB;;CAG5C,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
2
|
const require_vitest_extended_isFunction = require("./isFunction.cjs");
|
|
4
3
|
let vitest = require("vitest");
|
|
5
4
|
//#region src/vitest-extended/acceptation.ts
|
|
@@ -12,10 +11,7 @@ const useTestFunctionAcceptation = (f, _name) => {
|
|
|
12
11
|
(0, vitest.expect)(require_vitest_extended_isFunction.isFunction(f)).toBe(true);
|
|
13
12
|
});
|
|
14
13
|
};
|
|
15
|
-
/**
|
|
16
|
-
* For test only
|
|
17
|
-
* useTestFunctionAcceptation
|
|
18
|
-
*/
|
|
14
|
+
/** For test only useTestFunctionAcceptation */
|
|
19
15
|
const useTFA = useTestFunctionAcceptation;
|
|
20
16
|
//#endregion
|
|
21
17
|
exports.useTFA = useTFA;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acceptation.cjs","names":["isFunction"],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import
|
|
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 './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/** For test only useTestFunctionAcceptation */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":";;;;AAKA,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;EAEzC,CAAA,GAAA,OAAA,OAAA,CADcA,mCAAAA,WAAW,CACd,CAAC,CAAC,CAAC,KAAK,IAAI;CACzB,CAAC;AACH;;AAGA,MAAa,SAAS"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* For test only
|
|
5
|
-
* useTestFunctionAcceptation
|
|
6
|
-
*/
|
|
7
|
-
export declare const useTFA: (f: Fn, _name?: string) => void;
|
|
1
|
+
export declare const useTestFunctionAcceptation: unknown;
|
|
2
|
+
/** For test only useTestFunctionAcceptation */
|
|
3
|
+
export declare const useTFA: unknown;
|
|
@@ -10,10 +10,7 @@ const useTestFunctionAcceptation = (f, _name) => {
|
|
|
10
10
|
expect(isFunction(f)).toBe(true);
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
14
|
-
* For test only
|
|
15
|
-
* useTestFunctionAcceptation
|
|
16
|
-
*/
|
|
13
|
+
/** For test only useTestFunctionAcceptation */
|
|
17
14
|
const useTFA = useTestFunctionAcceptation;
|
|
18
15
|
//#endregion
|
|
19
16
|
export { useTFA, useTestFunctionAcceptation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acceptation.js","names":[],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"acceptation.js","names":[],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport type { Fn } from './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/** For test only useTestFunctionAcceptation */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":";;;AAKA,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;EAEzC,OADc,WAAW,CACd,CAAC,CAAC,CAAC,KAAK,IAAI;CACzB,CAAC;AACH;;AAGA,MAAa,SAAS"}
|
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
/**
|
|
4
4
|
* _unknown variable - Auto-generated expression
|
|
5
5
|
*
|
|
6
|
-
* ⚠️ WARNING: This expression is auto-generated and should not be
|
|
7
|
-
* Any manual changes will be overwritten during the next
|
|
6
|
+
* ⚠️ WARNING: This expression is auto-generated and should not be
|
|
7
|
+
* modified. Any manual changes will be overwritten during the next
|
|
8
|
+
* generation.
|
|
8
9
|
*
|
|
10
|
+
* @author chlbri (bri_lvi@icloud.com)
|
|
9
11
|
* @generated
|
|
10
12
|
* @readonly
|
|
11
|
-
* @author chlbri (bri_lvi@icloud.com)
|
|
12
13
|
*/
|
|
13
14
|
const _unknown = (value) => value;
|
|
14
15
|
//#endregion
|