@bemedev/dev-utils 1.0.1 → 1.0.2

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.
Files changed (83) hide show
  1. package/README.md +30 -5
  2. package/lib/build-tests/addTarball.d.ts +1 -1
  3. package/lib/build-tests/buildPackageJson.d.ts +3 -3
  4. package/lib/build-tests/cleanup.d.ts +1 -1
  5. package/lib/build-tests/cli/cli.d.ts +51 -1
  6. package/lib/build-tests/cli/index.d.ts +1 -0
  7. package/lib/build-tests/cli/post.d.ts +5 -1
  8. package/lib/build-tests/cli/pre.d.ts +5 -1
  9. package/lib/build-tests/cli/test.d.ts +15 -1
  10. package/lib/build-tests/constants.d.ts +1 -1
  11. package/lib/build-tests/getRelativePath.d.ts +1 -1
  12. package/lib/build-tests/getTypescriptOutdir.d.ts +1 -1
  13. package/lib/build-tests/import.d.ts +2 -2
  14. package/lib/build-tests/imports/create.d.ts +3 -3
  15. package/lib/build-tests/imports/helper.d.ts +7 -3
  16. package/lib/build-tests/imports/index.d.ts +1 -1
  17. package/lib/build-tests/index.d.ts +5 -5
  18. package/lib/build-tests/pack.d.ts +1 -1
  19. package/lib/rolldown-config/config.d.ts +1 -1
  20. package/lib/rolldown-config/constants.d.ts +5 -5
  21. package/lib/rolldown-config/helpers.d.ts +2 -2
  22. package/lib/rolldown-config/index.d.ts +3 -3
  23. package/lib/rolldown-config/input.d.ts +1 -1
  24. package/lib/rolldown-config/output.d.ts +15 -1
  25. package/lib/rolldown-config/plugins/circulars.d.ts +9 -9
  26. package/lib/rolldown-config/plugins/clean.cjs +3 -1
  27. package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
  28. package/lib/rolldown-config/plugins/clean.d.ts +13 -4
  29. package/lib/rolldown-config/plugins/clean.js +4 -2
  30. package/lib/rolldown-config/plugins/clean.js.map +1 -1
  31. package/lib/rolldown-config/plugins/externals.d.ts +7 -7
  32. package/lib/rolldown-config/plugins/index.d.ts +23 -2
  33. package/lib/rolldown-config/plugins/typescript.cjs +29 -41
  34. package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
  35. package/lib/rolldown-config/plugins/typescript.config.cjs +46 -39
  36. package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
  37. package/lib/rolldown-config/plugins/typescript.config.d.ts +2 -4
  38. package/lib/rolldown-config/plugins/typescript.config.js +47 -41
  39. package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
  40. package/lib/rolldown-config/plugins/typescript.d.ts +6 -6
  41. package/lib/rolldown-config/plugins/typescript.js +29 -43
  42. package/lib/rolldown-config/plugins/typescript.js.map +1 -1
  43. package/lib/rolldown-config/types.d.ts +13 -13
  44. package/lib/utils/array.d.ts +1 -1
  45. package/lib/utils/identity.d.ts +1 -1
  46. package/lib/utils/index.d.ts +4 -4
  47. package/lib/utils/sleep.d.ts +1 -1
  48. package/lib/utils/types.d.ts +1 -4
  49. package/lib/vitest-exclude/index.d.ts +1 -1
  50. package/lib/vitest-exclude/types.d.ts +11 -8
  51. package/lib/vitest-exclude/vitest.cjs +0 -2
  52. package/lib/vitest-exclude/vitest.cjs.map +1 -1
  53. package/lib/vitest-exclude/vitest.d.ts +27 -15
  54. package/lib/vitest-exclude/vitest.js +0 -2
  55. package/lib/vitest-exclude/vitest.js.map +1 -1
  56. package/lib/vitest-exclude/vitest.utils.d.ts +2 -2
  57. package/lib/vitest-extended/acceptation.d.ts +3 -2
  58. package/lib/vitest-extended/bemedev/globals/types.d.ts +1 -4
  59. package/lib/vitest-extended/bemedev/globals/utils/_unknown.d.ts +10 -10
  60. package/lib/vitest-extended/createTests.d.ts +55 -34
  61. package/lib/vitest-extended/createTests.types.d.ts +6 -10
  62. package/lib/vitest-extended/done.d.ts +14 -8
  63. package/lib/vitest-extended/each/error.d.ts +1 -1
  64. package/lib/vitest-extended/each/error.types.d.ts +4 -10
  65. package/lib/vitest-extended/each/index.d.ts +2 -2
  66. package/lib/vitest-extended/each/pass.d.ts +26 -26
  67. package/lib/vitest-extended/each/pass.types.d.ts +6 -18
  68. package/lib/vitest-extended/fakeWaiter.d.ts +3 -3
  69. package/lib/vitest-extended/identity.d.ts +2 -2
  70. package/lib/vitest-extended/index.cjs +2 -0
  71. package/lib/vitest-extended/index.d.ts +7 -6
  72. package/lib/vitest-extended/index.js +2 -1
  73. package/lib/vitest-extended/isDefined.d.ts +1 -1
  74. package/lib/vitest-extended/isFunction.d.ts +1 -1
  75. package/lib/vitest-extended/project.cjs +23 -0
  76. package/lib/vitest-extended/project.cjs.map +1 -0
  77. package/lib/vitest-extended/project.d.ts +2 -0
  78. package/lib/vitest-extended/project.js +22 -0
  79. package/lib/vitest-extended/project.js.map +1 -0
  80. package/lib/vitest-extended/toArray.d.ts +1 -1
  81. package/lib/vitest-extended/toStringFlat.d.ts +1 -1
  82. package/lib/vitest-extended/types.d.ts +38 -40
  83. package/package.json +3 -7
@@ -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 * 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
+ {"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 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 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,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,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,4 +1,4 @@
1
- export declare const hasSrc: unknown;
1
+ export declare const hasSrc: (root?: string) => boolean;
2
2
  export declare const defaultCovPattern: (root?: string) => string;
3
- export declare const buildInclude: unknown;
3
+ export declare const buildInclude: (pattern: string | string[], ignore?: string[], root?: string) => Promise<string[]>;
4
4
  export declare const testPattern: (root?: string) => string;
@@ -1,3 +1,4 @@
1
- export declare const useTestFunctionAcceptation: unknown;
1
+ import type { Fn } from './bemedev/globals/types';
2
+ export declare const useTestFunctionAcceptation: (f: Fn, _name?: string) => void;
2
3
  /** For test only useTestFunctionAcceptation */
3
- export declare const useTFA: unknown;
4
+ export declare const useTFA: (f: Fn, _name?: string) => void;
@@ -1,6 +1,3 @@
1
- export type Fn<
2
- Args extends any[] = any[],
3
- R = any
4
- > = (...args: Args) => R;
1
+ export type Fn<Args extends any[] = any[], R = any> = (...args: Args) => R;
5
2
  export type RuA = readonly unknown[];
6
3
  export type Undefiny<T> = T | undefined | null;
@@ -1,12 +1,12 @@
1
1
  /**
2
- * _unknown variable - Auto-generated expression
3
- *
4
- * ⚠️ WARNING: This expression is auto-generated and should not be
5
- * modified. Any manual changes will be overwritten during the next
6
- * generation.
7
- *
8
- * @author chlbri (bri_lvi@icloud.com)
9
- * @generated
10
- * @readonly
11
- */
2
+ * _unknown variable - Auto-generated expression
3
+ *
4
+ * ⚠️ WARNING: This expression is auto-generated and should not be
5
+ * modified. Any manual changes will be overwritten during the next
6
+ * generation.
7
+ *
8
+ * @author chlbri (bri_lvi@icloud.com)
9
+ * @generated
10
+ * @readonly
11
+ */
12
12
  export declare const _unknown: <T>(value?: unknown) => T;
@@ -1,36 +1,57 @@
1
- import type { _CreateTests_F } from "./createTests.types";
1
+ import type { Fn } from './bemedev/globals/types';
2
+ import type { _CreateTests_F } from './createTests.types';
2
3
  export type { _CreateTests_F };
3
4
  /**
4
- * Creates tests for function in a better way NB : We use strict-equality,
5
- * {@link useEach|see}
6
- *
7
- * @example
8
- * // ./add.ts
9
- * *export const add = (args: string[]) => args.reduce(
10
- * (acc, value) => {
11
- * acc+=value
12
- * return acc;
13
- * },
14
- * 0)
15
- *
16
- *
17
- * // .add.test.ts
18
- * *import { createTests } from '@bemedev/vitest-extended';
19
- * *import { add } from './add';
20
- *
21
- * *const useTests = createTests(add)
22
- *
23
- * *useTests(
24
- * {
25
- * invite: 'For : 1,2,3,4,5,6,7,8,9',
26
- * parameters: [[1, 2, 3, 4, 5, 6, 7, 8, 9]], // like this!
27
- * }
28
- * )
29
- *
30
- * @param library The test library
31
- * @param f The function to test
32
- * @param *
33
- * @returns A test.each like function to tests many cases NB: If the first
34
- * argument is an array, wrap the value in another array,
35
- */
36
- export declare const createTests: unknown;
5
+ * Creates tests for function in a better way NB : We use strict-equality,
6
+ * {@link useEach|see}
7
+ *
8
+ * @example
9
+ * // ./add.ts
10
+ * *export const add = (args: string[]) => args.reduce(
11
+ * (acc, value) => {
12
+ * acc+=value
13
+ * return acc;
14
+ * },
15
+ * 0)
16
+ *
17
+ *
18
+ * // .add.test.ts
19
+ * *import { createTests } from '@bemedev/vitest-extended';
20
+ * *import { add } from './add';
21
+ *
22
+ * *const useTests = createTests(add)
23
+ *
24
+ * *useTests(
25
+ * {
26
+ * invite: 'For : 1,2,3,4,5,6,7,8,9',
27
+ * parameters: [[1, 2, 3, 4, 5, 6, 7, 8, 9]], // like this!
28
+ * }
29
+ * )
30
+ *
31
+ * @param library The test library
32
+ * @param f The function to test
33
+ * @param *
34
+ * @returns A test.each like function to tests many cases NB: If the first
35
+ * argument is an array, wrap the value in another array,
36
+ */
37
+ export declare const createTests: {
38
+ <F0 extends any[], F1, F2 = F1>(func: Fn<F0, F1>, args?: {
39
+ transform?: Fn<[Awaited<F1>], F2>;
40
+ toError?: Fn<F0, string | undefined>;
41
+ }): {
42
+ acceptation: () => void;
43
+ success: (...cases: import("./types").TestArgs<Fn<F0, F2>>) => () => void;
44
+ fails: (...cases: import("./types").TestErrors<Fn<F0, F2>>) => () => void;
45
+ };
46
+ withImplementation<F0 extends any[], F1, F2 = F1>(f: Fn<NoInfer<F0>, NoInfer<F1>>, { instanciation, name, transform, toError, }: {
47
+ instanciation: () => Promise<Fn<F0, F1>> | Fn<F0, F1>;
48
+ name: string;
49
+ transform?: Fn<[Awaited<F1>], F2>;
50
+ toError?: Fn<F0, string | undefined>;
51
+ }): {
52
+ acceptation: () => void;
53
+ success: (...cases: import("./types").TestArgs<Fn<F0, F2>>) => () => void;
54
+ fails: (...cases: import("./types").TestErrors<Fn<F0, F2>>) => () => void;
55
+ };
56
+ withoutImplementation: /*elided*/ any;
57
+ };
@@ -1,13 +1,9 @@
1
- import type { Fn } from "./bemedev/globals/types";
2
- import type { TestArgs, TestErrors } from "./types";
1
+ import type { Fn } from './bemedev/globals/types';
2
+ import type { TestArgs, TestErrors } from './types';
3
3
  type ReturnR<F extends Fn> = {
4
- acceptation: () => void;
5
- success: (...cases: TestArgs<F>) => () => void;
6
- fails: (...cases: TestErrors<F>) => () => void;
4
+ acceptation: () => void;
5
+ success: (...cases: TestArgs<F>) => () => void;
6
+ fails: (...cases: TestErrors<F>) => () => void;
7
7
  };
8
- export type _CreateTests_F = <
9
- F0 extends any[],
10
- F1,
11
- F2 = F1
12
- >(func: Fn<F0, F1>, transform?: Fn<[Awaited<F1>], F2>, toError?: Fn<F0, string | undefined>, name?: string) => ReturnR<Fn<F0, F2>>;
8
+ export type _CreateTests_F = <F0 extends any[], F1, F2 = F1>(func: Fn<F0, F1>, transform?: Fn<[Awaited<F1>], F2>, toError?: Fn<F0, string | undefined>, name?: string) => ReturnR<Fn<F0, F2>>;
13
9
  export {};
@@ -1,9 +1,15 @@
1
+ import { type TestOptions } from 'vitest';
2
+ import type { TestDoneFunction } from './types';
1
3
  /**
2
- * Build a test with a done function with a timeout
3
- *
4
- * @param invite The description of the test
5
- * @param fn Where you can test, Don't async this function
6
- * @param options Options for the test like TestAPI from vitest
7
- * @returns A vitest test
8
- */
9
- export declare const doneTest: unknown;
4
+ * Build a test with a done function with a timeout
5
+ *
6
+ * @param invite The description of the test
7
+ * @param fn Where you can test, Don't async this function
8
+ * @param options Options for the test like TestAPI from vitest
9
+ * @returns A vitest test
10
+ */
11
+ export declare const doneTest: {
12
+ (invite: string, fn: TestDoneFunction, options?: number | TestOptions): void;
13
+ fails(invite: string, fn: TestDoneFunction, options?: number | TestOptions): void;
14
+ concurrent(invite: string, fn: TestDoneFunction, options?: number | TestOptions): void;
15
+ };
@@ -1,3 +1,3 @@
1
- import type { _UseErrorEach_F, UseErrorEach_F } from "./error.types";
1
+ import type { _UseErrorEach_F, UseErrorEach_F } from './error.types';
2
2
  export declare const useErrorAsyncEachCases: _UseErrorEach_F;
3
3
  export declare const useErrorAsyncEach: UseErrorEach_F;
@@ -1,11 +1,5 @@
1
- import type { Fn } from "../bemedev/globals/types";
2
- import type { Identity, NextFn, TestErrors } from "../types";
1
+ import type { Fn } from '../bemedev/globals/types';
2
+ import type { Identity, NextFn, TestErrors } from '../types';
3
3
  export type ToError_F<F extends Fn> = (...params: Parameters<F>) => string | undefined;
4
- export type _UseErrorEach_F = <
5
- F extends Fn,
6
- T extends NextFn<F> = Identity<F>
7
- >(f: F, transform?: T, toError?: ToError_F<F>, ...cases: TestErrors<F>) => void;
8
- export type UseErrorEach_F = <
9
- F extends Fn,
10
- T extends NextFn<F> = Identity<F>
11
- >(f: F, transform?: T, toError?: ToError_F<F>) => Fn<TestErrors<F>, void>;
4
+ export type _UseErrorEach_F = <F extends Fn, T extends NextFn<F> = Identity<F>>(f: F, transform?: T, toError?: ToError_F<F>, ...cases: TestErrors<F>) => void;
5
+ export type UseErrorEach_F = <F extends Fn, T extends NextFn<F> = Identity<F>>(f: F, transform?: T, toError?: ToError_F<F>) => Fn<TestErrors<F>, void>;
@@ -1,2 +1,2 @@
1
- export * from "./error";
2
- export * from "./pass";
1
+ export * from './error';
2
+ export * from './pass';
@@ -1,30 +1,30 @@
1
- import type { UseAsyncEach_F, UseEach_F } from "./pass.types";
1
+ import type { UseAsyncEach_F, UseEach_F } from './pass.types';
2
2
  /**
3
- * A better version of **test.each**
4
- *
5
- * Type parameters
6
- *
7
- * @type A Parameters of the function, extends Array type
8
- * @type R ReturnType of the function
9
- * @param func The function to test
10
- * @param cases The cases to test, The invite is the first arguments. It's
11
- * an array of Array.
12
- *
13
- * - #1 The first arg is the invite of the test
14
- * - #2 The second arg is the parameters to to pass to the function. It's
15
- * an array (param array).
16
- * - #3 The third arg is the expected result
17
- *
18
- * Example: For a function like **_(arg1: string)=>any**_, the second arg
19
- * with be : **_[string]**_
20
- * @if R are not provided, the return is a function to test with TestArgs arguments
21
- *
22
- * @else It tests every cases provided
23
- */
3
+ * A better version of **test.each**
4
+ *
5
+ * Type parameters
6
+ *
7
+ * @type A Parameters of the function, extends Array type
8
+ * @type R ReturnType of the function
9
+ * @param func The function to test
10
+ * @param cases The cases to test, The invite is the first arguments. It's
11
+ * an array of Array.
12
+ *
13
+ * - #1 The first arg is the invite of the test
14
+ * - #2 The second arg is the parameters to to pass to the function. It's
15
+ * an array (param array).
16
+ * - #3 The third arg is the expected result
17
+ *
18
+ * Example: For a function like **_(arg1: string)=>any**_, the second arg
19
+ * with be : **_[string]**_
20
+ * @if R are not provided, the return is a function to test with TestArgs arguments
21
+ *
22
+ * @else It tests every cases provided
23
+ */
24
24
  export declare const useEach: UseEach_F;
25
25
  /**
26
- * Same as _**useEach**_
27
- *
28
- * But for async functions
29
- */
26
+ * Same as _**useEach**_
27
+ *
28
+ * But for async functions
29
+ */
30
30
  export declare const useEachAsync: UseAsyncEach_F;
@@ -1,18 +1,6 @@
1
- import type { Fn } from "../bemedev/globals/types";
2
- import type { ChainedFn, Identity, NextFn, TestArgs } from "../types";
3
- export type _UseEach_F = <
4
- F extends Fn,
5
- T extends NextFn<F> = Identity<F>
6
- >(f: F, transform?: T, ...cases: TestArgs<ChainedFn<F, T>>) => void;
7
- export type UseEach_F = <
8
- F extends Fn,
9
- T extends NextFn<F> = Identity<F>
10
- >(f: F, transform?: T) => (...cases: TestArgs<ChainedFn<F, T>>) => void;
11
- export type _UseAsyncEach_F = <
12
- F extends Fn<any, Promise<any>>,
13
- T extends NextFn<F> = Identity<F>
14
- >(f: F, transform?: T, ...cases: TestArgs<ChainedFn<F, T>>) => void;
15
- export type UseAsyncEach_F = <
16
- F extends Fn<any, Promise<any>>,
17
- T extends NextFn<F> = Identity<F>
18
- >(f: F, transform?: T) => (...cases: TestArgs<ChainedFn<F, T>>) => void;
1
+ import type { Fn } from '../bemedev/globals/types';
2
+ import type { ChainedFn, Identity, NextFn, TestArgs } from '../types';
3
+ export type _UseEach_F = <F extends Fn, T extends NextFn<F> = Identity<F>>(f: F, transform?: T, ...cases: TestArgs<ChainedFn<F, T>>) => void;
4
+ export type UseEach_F = <F extends Fn, T extends NextFn<F> = Identity<F>>(f: F, transform?: T) => (...cases: TestArgs<ChainedFn<F, T>>) => void;
5
+ export type _UseAsyncEach_F = <F extends Fn<any, Promise<any>>, T extends NextFn<F> = Identity<F>>(f: F, transform?: T, ...cases: TestArgs<ChainedFn<F, T>>) => void;
6
+ export type UseAsyncEach_F = <F extends Fn<any, Promise<any>>, T extends NextFn<F> = Identity<F>>(f: F, transform?: T) => (...cases: TestArgs<ChainedFn<F, T>>) => void;
@@ -1,9 +1,9 @@
1
- import type { VitestUtils } from "vitest";
1
+ import type { VitestUtils } from 'vitest';
2
2
  export type FakeWaiter1_F = (vi: VitestUtils) => (ms?: number, times?: number) => Promise<void>;
3
3
  export type FakeWaiter2_F = (vi: VitestUtils, ms?: number) => (index: number, times?: number) => [string, () => Promise<void>];
4
4
  export type FakeWaiter3_F = (vi: VitestUtils) => (index: number, ms?: number, times?: number) => [string, () => Promise<void>];
5
5
  export type FakeWaiter = FakeWaiter1_F & {
6
- withDefaultDelay: FakeWaiter2_F;
7
- all: FakeWaiter3_F;
6
+ withDefaultDelay: FakeWaiter2_F;
7
+ all: FakeWaiter3_F;
8
8
  };
9
9
  export declare const createFakeWaiter: FakeWaiter;
@@ -1,2 +1,2 @@
1
- export declare const identity: unknown;
2
- export declare const defaultEquality: unknown;
1
+ export declare const identity: <T>(value: T) => T;
2
+ export declare const defaultEquality: (value: any, expected: any) => void;
@@ -1,4 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_vitest_extended_project = require("./project.cjs");
2
3
  const require_vitest_extended_acceptation = require("./acceptation.cjs");
3
4
  const require_vitest_extended_each_error = require("./each/error.cjs");
4
5
  const require_vitest_extended_each_pass = require("./each/pass.cjs");
@@ -8,6 +9,7 @@ require("./each/index.cjs");
8
9
  const require_vitest_extended_fakeWaiter = require("./fakeWaiter.cjs");
9
10
  exports.createFakeWaiter = require_vitest_extended_fakeWaiter.createFakeWaiter;
10
11
  exports.createTests = require_vitest_extended_createTests.createTests;
12
+ exports.defineProject = require_vitest_extended_project.defineProject;
11
13
  exports.doneTest = require_vitest_extended_done.doneTest;
12
14
  exports.useEach = require_vitest_extended_each_pass.useEach;
13
15
  exports.useEachAsync = require_vitest_extended_each_pass.useEachAsync;
@@ -1,6 +1,7 @@
1
- export * from "./acceptation";
2
- export * from "./createTests";
3
- export * from "./done";
4
- export * from "./each";
5
- export * from "./fakeWaiter";
6
- export * from "./types";
1
+ export * from './acceptation';
2
+ export * from './createTests';
3
+ export * from './done';
4
+ export * from './each';
5
+ export * from './fakeWaiter';
6
+ export * from './types';
7
+ export * from './project';
@@ -1,3 +1,4 @@
1
+ import { defineProject } from "./project.js";
1
2
  import { useTFA, useTestFunctionAcceptation } from "./acceptation.js";
2
3
  import { useErrorAsyncEach, useErrorAsyncEachCases } from "./each/error.js";
3
4
  import { useEach, useEachAsync } from "./each/pass.js";
@@ -5,4 +6,4 @@ import { createTests } from "./createTests.js";
5
6
  import { doneTest } from "./done.js";
6
7
  import "./each/index.js";
7
8
  import { createFakeWaiter } from "./fakeWaiter.js";
8
- export { createFakeWaiter, createTests, doneTest, useEach, useEachAsync, useErrorAsyncEach, useErrorAsyncEachCases, useTFA, useTestFunctionAcceptation };
9
+ export { createFakeWaiter, createTests, defineProject, doneTest, useEach, useEachAsync, useErrorAsyncEach, useErrorAsyncEachCases, useTFA, useTestFunctionAcceptation };
@@ -1,3 +1,3 @@
1
- import type { Undefiny } from "./bemedev/globals/types";
1
+ import type { Undefiny } from './bemedev/globals/types';
2
2
  export type { Undefiny };
3
3
  export declare const isDefined: <T>(value?: Undefiny<T>) => value is T;
@@ -1 +1 @@
1
- export declare function isFunction(arg: any);
1
+ export declare function isFunction(arg: any): boolean;
@@ -0,0 +1,23 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let vitest_config = require("vitest/config");
3
+ //#region src/vitest-extended/project.ts
4
+ const defineProject = (conf) => {
5
+ const _env = conf.test?.env ?? {};
6
+ return (0, vitest_config.defineConfig)({
7
+ resolve: { tsconfigPaths: true },
8
+ ...conf,
9
+ test: {
10
+ globals: true,
11
+ logHeapUsage: false,
12
+ env: {
13
+ NODE_ENV: "test",
14
+ ..._env
15
+ },
16
+ ...conf.test
17
+ }
18
+ });
19
+ };
20
+ //#endregion
21
+ exports.defineProject = defineProject;
22
+
23
+ //# sourceMappingURL=project.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.cjs","names":[],"sources":["../../src/vitest-extended/project.ts"],"sourcesContent":["import { defineConfig, type UserWorkspaceConfig } from 'vitest/config';\n\nexport const defineProject = (conf: UserWorkspaceConfig) => {\n const _env = conf.test?.env ?? {};\n\n return defineConfig({\n resolve: { tsconfigPaths: true },\n ...conf,\n test: {\n globals: true,\n logHeapUsage: false,\n env: { NODE_ENV: 'test', ..._env },\n ...conf.test,\n },\n });\n};\n"],"mappings":";;;AAEA,MAAa,iBAAiB,SAA8B;CAC1D,MAAM,OAAO,KAAK,MAAM,OAAO,CAAC;CAEhC,QAAA,GAAA,cAAA,aAAA,CAAoB;EAClB,SAAS,EAAE,eAAe,KAAK;EAC/B,GAAG;EACH,MAAM;GACJ,SAAS;GACT,cAAc;GACd,KAAK;IAAE,UAAU;IAAQ,GAAG;GAAK;GACjC,GAAG,KAAK;EACV;CACF,CAAC;AACH"}
@@ -0,0 +1,2 @@
1
+ import { type UserWorkspaceConfig } from 'vitest/config';
2
+ export declare const defineProject: (conf: UserWorkspaceConfig) => import("vite").UserConfig;
@@ -0,0 +1,22 @@
1
+ import { defineConfig } from "vitest/config";
2
+ //#region src/vitest-extended/project.ts
3
+ const defineProject = (conf) => {
4
+ const _env = conf.test?.env ?? {};
5
+ return defineConfig({
6
+ resolve: { tsconfigPaths: true },
7
+ ...conf,
8
+ test: {
9
+ globals: true,
10
+ logHeapUsage: false,
11
+ env: {
12
+ NODE_ENV: "test",
13
+ ..._env
14
+ },
15
+ ...conf.test
16
+ }
17
+ });
18
+ };
19
+ //#endregion
20
+ export { defineProject };
21
+
22
+ //# sourceMappingURL=project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.js","names":[],"sources":["../../src/vitest-extended/project.ts"],"sourcesContent":["import { defineConfig, type UserWorkspaceConfig } from 'vitest/config';\n\nexport const defineProject = (conf: UserWorkspaceConfig) => {\n const _env = conf.test?.env ?? {};\n\n return defineConfig({\n resolve: { tsconfigPaths: true },\n ...conf,\n test: {\n globals: true,\n logHeapUsage: false,\n env: { NODE_ENV: 'test', ..._env },\n ...conf.test,\n },\n });\n};\n"],"mappings":";;AAEA,MAAa,iBAAiB,SAA8B;CAC1D,MAAM,OAAO,KAAK,MAAM,OAAO,CAAC;CAEhC,OAAO,aAAa;EAClB,SAAS,EAAE,eAAe,KAAK;EAC/B,GAAG;EACH,MAAM;GACJ,SAAS;GACT,cAAc;GACd,KAAK;IAAE,UAAU;IAAQ,GAAG;GAAK;GACjC,GAAG,KAAK;EACV;CACF,CAAC;AACH"}
@@ -1,3 +1,3 @@
1
- import type { ToArrayVitest_F, ToArray_F } from "./types";
1
+ import type { ToArrayVitest_F, ToArray_F } from './types';
2
2
  export declare const toArrayVitest: ToArrayVitest_F;
3
3
  export declare const toArray: ToArray_F;
@@ -1,2 +1,2 @@
1
- import { type Fn } from "./bemedev/globals/types";
1
+ import { type Fn } from './bemedev/globals/types';
2
2
  export declare const toStringFlat: Fn<[value: number, len: number], string>;
@@ -1,62 +1,60 @@
1
- import type { Fn, RuA } from "./bemedev/globals/types";
1
+ import type { Fn, RuA } from './bemedev/globals/types';
2
2
  export type { Fn, RuA };
3
3
  type ReR<F extends Fn> = Awaited<ReturnType<F>>;
4
4
  type TestFn<F extends Fn> = Fn<[ReR<F>, ReR<F>], void>;
5
- type LengthOf<T> = T extends readonly any[] ? T["length"] : never;
6
- export type SimpleParams<
7
- F extends Fn,
8
- P extends RuA = Parameters<F>
9
- > = LengthOf<P> extends 0 ? {
10
- parameters?: never;
5
+ type LengthOf<T> = T extends readonly any[] ? T['length'] : never;
6
+ export type SimpleParams<F extends Fn, P extends RuA = Parameters<F>> = LengthOf<P> extends 0 ? {
7
+ parameters?: never;
11
8
  } : 1 extends LengthOf<P> ? undefined extends P[0] ? {
12
- parameters?: P | P[0];
9
+ parameters?: P | P[0];
13
10
  } : 0 extends LengthOf<P> ? {
14
- parameters?: P | P[0];
11
+ parameters?: P | P[0];
15
12
  } : {
16
- parameters: P | P[0];
13
+ parameters: P | P[0];
17
14
  } : {
18
- parameters: P;
15
+ parameters: P;
19
16
  };
20
17
  export type TestArgs<F extends Fn> = ({
21
- invite: string;
22
- expected: ReR<F>;
23
- /** Optional test function for specific cases */
24
- test?: TestFn<F>;
18
+ invite: string;
19
+ expected: ReR<F>;
20
+ /** Optional test function for specific cases */
21
+ test?: TestFn<F>;
25
22
  } & SimpleParams<F>)[];
26
- export type TestArgs2<F extends Fn> = [invite: string, parameters: Parameters<F>, expected: ReR<F>, test?: TestFn<F>][];
23
+ export type TestArgs2<F extends Fn> = [
24
+ invite: string,
25
+ parameters: Parameters<F>,
26
+ expected: ReR<F>,
27
+ /** Optional test function for specific cases */
28
+ test?: TestFn<F>
29
+ ][];
27
30
  export type TestErrors<F extends Fn> = ({
28
- invite: string;
29
- error?: string;
31
+ invite: string;
32
+ error?: string;
30
33
  } & SimpleParams<F>)[];
31
- export type TestErrors2<F extends Fn> = [invite: string, parameters: Parameters<F>, error?: string][];
34
+ export type TestErrors2<F extends Fn> = [
35
+ invite: string,
36
+ parameters: Parameters<F>,
37
+ error?: string
38
+ ][];
32
39
  export interface ToArray_F {
33
- <T>(obj: any): T[];
34
- generic: <T>(obj: T) => T[];
40
+ <T>(obj: any): T[];
41
+ generic: <T>(obj: T) => T[];
35
42
  }
36
43
  export interface ToArrayVitest_F {
37
- <F extends Fn>(params: TestArgs<F>): TestArgs2<F>;
38
- error: <F extends Fn>(params: TestErrors<F>) => TestErrors2<F>;
44
+ <F extends Fn>(params: TestArgs<F>): TestArgs2<F>;
45
+ error: <F extends Fn>(params: TestErrors<F>) => TestErrors2<F>;
39
46
  }
40
- export type TestReturn<
41
- F extends Fn,
42
- A extends TestArgs<F>
43
- > = LengthOf<A> extends 0 ? Fn<TestArgs<F>, void> : void;
47
+ export type TestReturn<F extends Fn, A extends TestArgs<F>> = LengthOf<A> extends 0 ? Fn<TestArgs<F>, void> : void;
44
48
  export type TestDoneFunction = Fn<[context: () => boolean], void>;
45
49
  export type ToCreateTestsWithImplementation_F = <F extends Fn>(f: F, implementation: {
46
- instanciation: () => Promise<F> | F;
47
- name: string;
50
+ instanciation: () => Promise<F> | F;
51
+ name: string;
48
52
  }) => (...cases: TestArgs<F>) => void;
49
53
  export type FakeWaiter_F = (params: {
50
- ms?: number;
51
- times?: number;
52
- fake: boolean;
54
+ ms?: number;
55
+ times?: number;
56
+ fake: boolean;
53
57
  }) => Promise<void>;
54
- export type NextFn<
55
- F extends Fn,
56
- R = any
57
- > = Fn<[ReturnType<F>], R>;
58
+ export type NextFn<F extends Fn, R = any> = Fn<[ReturnType<F>], R>;
58
59
  export type Identity<F extends Fn> = Fn<[ReturnType<F>], ReturnType<F>>;
59
- export type ChainedFn<
60
- F extends Fn,
61
- T extends NextFn<F>
62
- > = Fn<Parameters<F>, ReR<T>>;
60
+ export type ChainedFn<F extends Fn, T extends NextFn<F>> = Fn<Parameters<F>, ReR<T>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemedev/dev-utils",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
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",
@@ -86,14 +86,13 @@
86
86
  }
87
87
  ],
88
88
  "dependencies": {
89
+ "@typescript/typescript6": "^6.0.2",
89
90
  "cmd-ts": "^0.15.0",
90
91
  "edit-json-file": "^1.8.1",
91
92
  "glob": "^13.0.6",
92
93
  "oxc-transform": "^0.139.0",
93
94
  "rollup-plugin-circular-dependencies": "^2.0.1",
94
95
  "rollup-plugin-node-externals": "^9.0.1",
95
- "rollup-plugin-tsc-alias": "^1.1.4",
96
- "rollup-plugin-tsconfig-paths": "^1.5.2",
97
96
  "shelljs": "^0.10.0",
98
97
  "sort-keys": "^6.0.1",
99
98
  "tsc-alias": "^1.9.1"
@@ -107,16 +106,13 @@
107
106
  "@types/shelljs": "^0.10.0",
108
107
  "@vitest/ui": "4.1.10",
109
108
  "rolldown": "^1.1.5",
110
- "typescript": "^7.0.2",
109
+ "unplugin-dts": "^1.0.3",
111
110
  "vitest": "4.1.10",
112
111
  "zod": "^4.4.3",
113
112
  "zx": "^8.8.5"
114
113
  },
115
114
  "peerDependencies": {
116
- "@vitest/coverage-v8": "4.1.10",
117
- "@vitest/ui": "4.1.10",
118
115
  "rolldown": "^1.1.5",
119
- "typescript": "^7.0.2",
120
116
  "vitest": "4.1.10"
121
117
  },
122
118
  "scripts": {