@bemedev/dev-utils 1.3.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +67 -90
  2. package/lib/build-tests/buildPackageJson.cjs.map +1 -1
  3. package/lib/build-tests/buildPackageJson.js.map +1 -1
  4. package/lib/build-tests/cli/test.cjs.map +1 -1
  5. package/lib/build-tests/cli/test.js.map +1 -1
  6. package/lib/build-tests/getTypescriptOutdir.cjs.map +1 -1
  7. package/lib/build-tests/getTypescriptOutdir.js.map +1 -1
  8. package/lib/build-tests/imports/create.cjs.map +1 -1
  9. package/lib/build-tests/imports/create.js.map +1 -1
  10. package/lib/build-tests/imports/helper.cjs.map +1 -1
  11. package/lib/build-tests/imports/helper.js.map +1 -1
  12. package/lib/plugins/hmr.cjs +15 -9
  13. package/lib/plugins/hmr.cjs.map +1 -1
  14. package/lib/plugins/hmr.d.ts +8 -5
  15. package/lib/plugins/hmr.js +15 -9
  16. package/lib/plugins/hmr.js.map +1 -1
  17. package/lib/plugins/suppressWarnings.cjs.map +1 -1
  18. package/lib/plugins/suppressWarnings.js.map +1 -1
  19. package/lib/rolldown-config/config.cjs.map +1 -1
  20. package/lib/rolldown-config/config.js.map +1 -1
  21. package/lib/rolldown-config/helpers.cjs.map +1 -1
  22. package/lib/rolldown-config/helpers.js.map +1 -1
  23. package/lib/rolldown-config/input.cjs.map +1 -1
  24. package/lib/rolldown-config/input.js.map +1 -1
  25. package/lib/rolldown-config/plugins/circulars.cjs.map +1 -1
  26. package/lib/rolldown-config/plugins/circulars.js.map +1 -1
  27. package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
  28. package/lib/rolldown-config/plugins/clean.js.map +1 -1
  29. package/lib/rolldown-config/plugins/externals.cjs.map +1 -1
  30. package/lib/rolldown-config/plugins/externals.js.map +1 -1
  31. package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
  32. package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
  33. package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
  34. package/lib/rolldown-config/plugins/typescript.fast.cjs.map +1 -1
  35. package/lib/rolldown-config/plugins/typescript.fast.js.map +1 -1
  36. package/lib/rolldown-config/plugins/typescript.js.map +1 -1
  37. package/lib/utils/bemedev/globals/utils/expandFn.cjs.map +1 -1
  38. package/lib/utils/bemedev/globals/utils/expandFn.js.map +1 -1
  39. package/lib/vitest-exclude/vitest.cjs.map +1 -1
  40. package/lib/vitest-exclude/vitest.js.map +1 -1
  41. package/lib/vitest-extended/createTests.cjs.map +1 -1
  42. package/lib/vitest-extended/createTests.js.map +1 -1
  43. package/lib/vitest-extended/done.cjs.map +1 -1
  44. package/lib/vitest-extended/done.js.map +1 -1
  45. package/lib/vitest-extended/each/error.cjs.map +1 -1
  46. package/lib/vitest-extended/each/error.js.map +1 -1
  47. package/lib/vitest-extended/each/pass.cjs.map +1 -1
  48. package/lib/vitest-extended/each/pass.js.map +1 -1
  49. package/lib/vitest-extended/fakeWaiter.cjs.map +1 -1
  50. package/lib/vitest-extended/fakeWaiter.js.map +1 -1
  51. package/lib/vitest-extended/fixtures/partialCall.cjs.map +1 -1
  52. package/lib/vitest-extended/fixtures/partialCall.js.map +1 -1
  53. package/lib/vitest-extended/isFunction.cjs.map +1 -1
  54. package/lib/vitest-extended/isFunction.js.map +1 -1
  55. package/package.json +1 -1
package/README.md CHANGED
@@ -1,12 +1,11 @@
1
1
  # @bemedev/dev-utils
2
2
 
3
- A collection of utilities for Node.js development, including build tools,
4
- testing utilities, and configuration management.
3
+ A collection of utilities for Node.js development, including build tools, testing
4
+ utilities, and configuration management.
5
5
 
6
6
  ## HOTFIX fix for version 1.0.*
7
7
 
8
- > It doesn't type declarations well, if you're not put directly the output
9
- > type
8
+ > It doesn't type declarations well, if you're not put directly the output type
10
9
 
11
10
  ## Modules
12
11
 
@@ -19,11 +18,11 @@ testing utilities, and configuration management.
19
18
  | [`plugins`](#plugins) | Vite development helper plugins |
20
19
  | [`utils`](#utils) | Utility functions and helpers |
21
20
 
22
- > **Note (v0.8.1):** The `./vitest-alias` export has been removed. Path
23
- > alias resolution is now handled natively by Vite via `resolve.alias` with
24
- > `vite-tsconfig-paths` or the built-in `resolve.tsConfigPaths` option.
25
- > Remove any `aliasTs()` / `createAlias()` usage and configure aliases
26
- > directly in your `vite` / `vitest` config.
21
+ > **Note (v0.8.1):** The `./vitest-alias` export has been removed. Path alias
22
+ > resolution is now handled natively by Vite via `resolve.alias` with
23
+ > `vite-tsconfig-paths` or the built-in `resolve.tsConfigPaths` option. Remove any
24
+ > `aliasTs()` / `createAlias()` usage and configure aliases directly in your `vite` /
25
+ > `vitest` config.
27
26
 
28
27
  <br/>
29
28
 
@@ -43,15 +42,12 @@ yarn add @bemedev/dev-utils
43
42
 
44
43
  ## Usage
45
44
 
46
- Each module is available as a dedicated sub-path export — there is no root
47
- barrel export:
45
+ Each module is available as a dedicated sub-path export — there is no root barrel
46
+ export:
48
47
 
49
48
  ```typescript
50
49
  import { exclude } from '@bemedev/dev-utils/vitest-exclude';
51
- import {
52
- createTests,
53
- createFakeWaiter,
54
- } from '@bemedev/dev-utils/vitest-extended';
50
+ import { createTests, createFakeWaiter } from '@bemedev/dev-utils/vitest-extended';
55
51
  import { defineConfig } from '@bemedev/dev-utils/rolldown';
56
52
  import { addTarball, cleanup } from '@bemedev/dev-utils/build-tests';
57
53
  import { suppressWarnings, hmr } from '@bemedev/dev-utils/plugins';
@@ -62,14 +58,13 @@ import { clamp, toArray, identity, sleep } from '@bemedev/dev-utils/utils';
62
58
 
63
59
  ## `vitestExclude`
64
60
 
65
- Vitest plugin that uses glob patterns to dynamically build `test.include`
66
- and `coverage.include` lists — no need to maintain `test.exclude` manually.
61
+ Vitest plugin that uses glob patterns to dynamically build `test.include` and
62
+ `coverage.include` lists — no need to maintain `test.exclude` manually.
67
63
 
68
64
  ### `exclude(args?)`
69
65
 
70
66
  Uses default patterns (`src/**/*.ts` for coverage,
71
- `src/**/*.{test,spec}.{ts,js,tsx,jsx}` for tests) and applies optional
72
- ignore lists.
67
+ `src/**/*.{test,spec}.{ts,js,tsx,jsx}` for tests) and applies optional ignore lists.
73
68
 
74
69
  ```typescript
75
70
  import { exclude } from '@bemedev/dev-utils/vitest-exclude';
@@ -98,8 +93,7 @@ export default defineConfig({
98
93
 
99
94
  ### `exclude.withPattern(patterns, args)`
100
95
 
101
- Same as `exclude`, but lets you provide custom glob patterns instead of the
102
- defaults.
96
+ Same as `exclude`, but lets you provide custom glob patterns instead of the defaults.
103
97
 
104
98
  ```typescript
105
99
  exclude.withPattern(
@@ -147,8 +141,8 @@ const { files, coverage } = await create({
147
141
 
148
142
  ### `create.withPattern(patterns, args)`
149
143
 
150
- Same as `create`, but accepts custom glob patterns for both test and
151
- coverage discovery.
144
+ Same as `create`, but accepts custom glob patterns for both test and coverage
145
+ discovery.
152
146
 
153
147
  ```typescript
154
148
  import { create } from '@bemedev/dev-utils/vitest-exclude';
@@ -177,8 +171,8 @@ Extended helpers for writing structured, type-safe Vitest tests.
177
171
 
178
172
  ### `createTests(func, args?)`
179
173
 
180
- Creates a reusable test suite for a function with `acceptation`, `success`,
181
- and `fails` runners.
174
+ Creates a reusable test suite for a function with `acceptation`, `success`, and
175
+ `fails` runners.
182
176
 
183
177
  ```typescript
184
178
  import { createTests } from '@bemedev/dev-utils/vitest-extended';
@@ -225,8 +219,8 @@ describe('add', () => {
225
219
 
226
220
  ### `createTests.withImplementation(f, opts)`
227
221
 
228
- Same as `createTests` but replaces the implementation with a `vi.fn()` mock
229
- before the test suite runs.
222
+ Same as `createTests` but replaces the implementation with a `vi.fn()` mock before
223
+ the test suite runs.
230
224
 
231
225
  ```typescript
232
226
  const { acceptation, success } = createTests.withImplementation(myFn, {
@@ -248,9 +242,9 @@ const { acceptation, success } = createTests.withImplementation(myFn, {
248
242
 
249
243
  ### `doneTest(invite, fn, options?)`
250
244
 
251
- Wraps a callback-style (done-based) test into a Vitest `test`. The test
252
- passes only when `done()` is called within the timeout. Supports both sync
253
- and async test functions.
245
+ Wraps a callback-style (done-based) test into a Vitest `test`. The test passes only
246
+ when `done()` is called within the timeout. Supports both sync and async test
247
+ functions.
254
248
 
255
249
  ```typescript
256
250
  import { doneTest } from '@bemedev/dev-utils/vitest-extended';
@@ -287,8 +281,8 @@ doneTest('fires callback', done => {
287
281
 
288
282
  ### `createFakeWaiter(vi)`
289
283
 
290
- Creates a fake-timer-aware async waiter. If fake timers are active it
291
- advances them; otherwise it uses a real `sleep`.
284
+ Creates a fake-timer-aware async waiter. If fake timers are active it advances them;
285
+ otherwise it uses a real `sleep`.
292
286
 
293
287
  ```typescript
294
288
  import { createFakeWaiter } from '@bemedev/dev-utils/vitest-extended';
@@ -352,10 +346,8 @@ Same as `useEach` but awaits the function result.
352
346
  Runs async error cases using `expect(fn).rejects.toThrowError(error)`.
353
347
 
354
348
  ```typescript
355
- const runErrors = vitestExtended.useErrorAsyncEach(
356
- divide,
357
- undefined,
358
- ([_, b]) => (b === 0 ? 'Division by zero' : undefined),
349
+ const runErrors = vitestExtended.useErrorAsyncEach(divide, undefined, ([_, b]) =>
350
+ b === 0 ? 'Division by zero' : undefined,
359
351
  );
360
352
 
361
353
  runErrors(['divide by 0', [1, 0], undefined]);
@@ -365,8 +357,7 @@ runErrors(['divide by 0', [1, 0], undefined]);
365
357
 
366
358
  ### `useTestFunctionAcceptation(f, name?)` / `useTFA`
367
359
 
368
- Runs two acceptation checks: the function is defined and is actually a
369
- function.
360
+ Runs two acceptation checks: the function is defined and is actually a function.
370
361
 
371
362
  ```typescript
372
363
  vitestExtended.useTFA(myFunction, 'myFunction');
@@ -376,14 +367,13 @@ vitestExtended.useTFA(myFunction, 'myFunction');
376
367
 
377
368
  ### `defineProject(config)`
378
369
 
379
- A wrapper around Vitest's `defineProject` / `defineConfig` that injects
380
- default configurations.
370
+ A wrapper around Vitest's `defineProject` / `defineConfig` that injects default
371
+ configurations.
381
372
 
382
- > [!IMPORTANT] **HOT FIX**: Use this instead of standard `defineProject`
383
- > from `vitest/config` to automatically resolve path aliases (via
384
- > `tsconfigPaths: true`), set `globals: true`, configure
385
- > `logHeapUsage: false`, and set the `NODE_ENV` environment variable to
386
- > `'test'` by default.
373
+ > [!IMPORTANT] **HOT FIX**: Use this instead of standard `defineProject` from
374
+ > `vitest/config` to automatically resolve path aliases (via `tsconfigPaths: true`),
375
+ > set `globals: true`, configure `logHeapUsage: false`, and set the `NODE_ENV`
376
+ > environment variable to `'test'` by default.
387
377
 
388
378
  ```typescript
389
379
  import { defineProject } from '@bemedev/dev-utils/vitest-extended';
@@ -425,8 +415,7 @@ Produces a full Rolldown config with the default plugin pipeline:
425
415
  (`rollup-plugin-circular-dependency`)
426
416
  2. **externals** — marks `dependencies` and `peerDependencies` as external
427
417
  (`rollup-plugin-node-externals`)
428
- 3. **typescript** — emits `.d.ts` declarations via the TypeScript compiler
429
- API
418
+ 3. **typescript** — emits `.d.ts` declarations via the TypeScript compiler API
430
419
  4. **clean** — removes JS outputs for files that produce empty chunks
431
420
 
432
421
  ```typescript
@@ -473,31 +462,28 @@ src/fixtures/**/*.ts
473
462
  Opinionated preset that extends `defineConfig.default` with:
474
463
 
475
464
  - Sourcemaps **enabled by default**
476
- - `DEFAULT_CIRCULAR_DEPS` merged into `circularDeps` (`**/types.ts`,
477
- `**/*.types.ts`, …)
465
+ - `DEFAULT_CIRCULAR_DEPS` merged into `circularDeps` (`**/types.ts`, `**/*.types.ts`,
466
+ …)
478
467
  - `DEFAULT_EXCLUDE` merged into `excludesTS`
479
468
  - `DEFAULT_CIRCULAR_DEPS` merged into `ignoresJS`
480
469
 
481
470
  ```typescript
482
- export default defineConfig.bemedev({
483
- excludesTS: ['src/my-fixtures/**'],
484
- });
471
+ export default defineConfig.bemedev({ excludesTS: ['src/my-fixtures/**'] });
485
472
  ```
486
473
 
487
474
  ---
488
475
 
489
476
  ### `defineConfig.fast(params?)`
490
477
 
491
- A fast build configuration preset that optimizes TypeScript declaration
492
- emitting. It uses the `fast` (`typescriptFast`) plugin wrapping
493
- `oxc-transform` instead of the standard compiler API.
478
+ A fast build configuration preset that optimizes TypeScript declaration emitting. It
479
+ uses the `fast` (`typescriptFast`) plugin wrapping `oxc-transform` instead of the
480
+ standard compiler API.
494
481
 
495
482
  It runs the following plugin pipeline:
496
483
 
497
484
  1. **circulars** — warns on circular dependencies
498
485
  2. **externals** — marks `dependencies` and `peerDependencies` as external
499
- 3. **esm** — injects ESM external require helpers
500
- (`esmExternalRequirePlugin`)
486
+ 3. **esm** — injects ESM external require helpers (`esmExternalRequirePlugin`)
501
487
  4. **fast** — generates `.d.ts` files quickly using `oxc-transform`
502
488
  5. **clean** — removes empty JS chunks
503
489
 
@@ -520,8 +506,7 @@ Individual plugin factories are available for custom pipeline assembly:
520
506
  | `fast` | `fast(options?)` | `oxc-transform` + `tsc-alias`, for ONLY compilerOptions.isolatedDeclarations set to `true` |
521
507
  | `clean` | `clean(options?)` | Custom post-build JS cleanup |
522
508
 
523
- Pass plugin keys as strings in the `plugins` array to reorder or subset
524
- them:
509
+ Pass plugin keys as strings in the `plugins` array to reorder or subset them:
525
510
 
526
511
  ```typescript
527
512
  defineConfig.default({ plugins: ['externals', 'typescript'] });
@@ -531,9 +516,9 @@ defineConfig.default({ plugins: ['externals', 'typescript'] });
531
516
 
532
517
  ## `buildTests`
533
518
 
534
- CLI tooling that packs your built library as a local tarball, installs it
535
- under the alias `this-gen-1`, runs your test suite against the real
536
- distributable, then tears down.
519
+ CLI tooling that packs your built library as a local tarball, installs it under the
520
+ alias `this-gen-1`, runs your test suite against the real distributable, then tears
521
+ down.
537
522
 
538
523
  Available as a sub-path export:
539
524
 
@@ -578,8 +563,8 @@ build-tests post
578
563
 
579
564
  Programmatic API for the `pre` step:
580
565
 
581
- 1. Builds the `package.json` for the `outDir` (strips `scripts`,
582
- `devDependencies`, `files`; fixes paths)
566
+ 1. Builds the `package.json` for the `outDir` (strips `scripts`, `devDependencies`,
567
+ `files`; fixes paths)
583
568
  2. Runs `pnpm pack` into `.pack/`
584
569
  3. Installs the resulting `.tgz` as `this-gen-1` in `devDependencies`
585
570
 
@@ -608,8 +593,8 @@ cleanup();
608
593
 
609
594
  ### `customImport(fn?)`
610
595
 
611
- Dynamically imports the installed package (`this-gen-1`) and optionally
612
- transforms its exports via a mapper function.
596
+ Dynamically imports the installed package (`this-gen-1`) and optionally transforms
597
+ its exports via a mapper function.
613
598
 
614
599
  ```typescript
615
600
  import { customImport } from '@bemedev/dev-utils/build-tests';
@@ -633,8 +618,8 @@ const myFn = await customImport(mod => mod.myFn);
633
618
 
634
619
  ### `THIS1`
635
620
 
636
- Constant string `'this-gen-1'` — the package alias used by `addTarball` and
637
- `cleanup` when installing/removing the local tarball.
621
+ Constant string `'this-gen-1'` — the package alias used by `addTarball` and `cleanup`
622
+ when installing/removing the local tarball.
638
623
 
639
624
  ```typescript
640
625
  import { THIS1 } from '@bemedev/dev-utils/build-tests';
@@ -658,18 +643,16 @@ Vite plugins for development and test workflows.
658
643
 
659
644
  ### `suppressWarnings(...patterns)`
660
645
 
661
- Vite plugin that intercepts and suppresses noisy terminal stderr output
662
- (e.g., from Nitro, SSR workers, or third-party dependencies) matching
663
- specific strings or regular expressions during dev (`apply: 'serve'`).
646
+ Vite plugin that intercepts and suppresses noisy terminal stderr output (e.g., from
647
+ Nitro, SSR workers, or third-party dependencies) matching specific strings or regular
648
+ expressions during dev (`apply: 'serve'`).
664
649
 
665
650
  ```typescript
666
651
  import { suppressWarnings } from '@bemedev/dev-utils/plugins';
667
652
  import { defineConfig } from 'vite';
668
653
 
669
654
  export default defineConfig({
670
- plugins: [
671
- suppressWarnings('ExperimentalWarning', /punycode/, '[Vue warn]'),
672
- ],
655
+ plugins: [suppressWarnings('ExperimentalWarning', /punycode/, '[Vue warn]')],
673
656
  });
674
657
  ```
675
658
 
@@ -679,16 +662,14 @@ export default defineConfig({
679
662
  | ------------- | ------------------------- | --------------------------------------------------------------------- |
680
663
  | `...patterns` | `Array<string \| RegExp>` | Strings or RegExp patterns to match against stderr chunks to suppress |
681
664
 
682
- **Returns** a Vite `Plugin`
683
- (`{ name: 'suppress-logs-plugin', apply: 'serve' }`).
665
+ **Returns** a Vite `Plugin` (`{ name: 'suppress-logs-plugin', apply: 'serve' }`).
684
666
 
685
667
  ---
686
668
 
687
669
  ### `hmr(props?)`
688
670
 
689
- Vite plugin providing Hot Module Reloading (HMR) capabilities for external
690
- file paths by watching files and executing build scripts when changes are
691
- detected.
671
+ Vite plugin providing Hot Module Reloading (HMR) capabilities for external file paths
672
+ by watching files and executing mapped build scripts when changes are detected.
692
673
 
693
674
  ```typescript
694
675
  import { hmr } from '@bemedev/dev-utils/plugins';
@@ -697,8 +678,7 @@ import { defineConfig } from 'vite';
697
678
  export default defineConfig({
698
679
  plugins: [
699
680
  hmr({
700
- paths: ['../packages/*/src/**'],
701
- scripts: ['pnpm --filter ./packages/* build'],
681
+ paths: { '../packages/*/src/**': 'pnpm --filter ./packages/* build' },
702
682
  debounce: 1000,
703
683
  }),
704
684
  ],
@@ -707,11 +687,10 @@ export default defineConfig({
707
687
 
708
688
  **Parameters (`props`)**
709
689
 
710
- | Property | Type | Default | Description |
711
- | ---------- | --------------------- | ------- | ---------------------------------------------------------------------- |
712
- | `paths` | `string \| string[]` | `[]` | File path(s) to watch for changes |
713
- | `scripts` | `string \| string[]` | `[]` | Shell command(s) to execute on file changes |
714
- | `debounce` | `number \| undefined` | `500` | Cooldown interval in milliseconds to prevent build loops (500–10000ms) |
690
+ | Property | Type | Default | Description |
691
+ | ---------- | ------------------------------------ | ----------- | ---------------------------------------------------------------------- |
692
+ | `paths` | `Record<string, string \| string[]>` | `undefined` | Map of watched path patterns to command(s) to execute on file changes |
693
+ | `debounce` | `number \| undefined` | `500` | Cooldown interval in milliseconds to prevent build loops (500–10000ms) |
715
694
 
716
695
  **Returns** a Vite `Plugin` (`{ name: 'hmr-add-on' }`).
717
696
 
@@ -719,8 +698,7 @@ export default defineConfig({
719
698
 
720
699
  ## `utils`
721
700
 
722
- General development utility helpers available via the `./utils` sub-path
723
- export.
701
+ General development utility helpers available via the `./utils` sub-path export.
724
702
 
725
703
  ### `clamp(value, min, max)`
726
704
 
@@ -777,8 +755,7 @@ MIT
777
755
 
778
756
  ## CHANGELOG
779
757
 
780
- Read [CHANGELOG.md](CHANGELOG.md) for details about all changes and
781
- versions.
758
+ Read [CHANGELOG.md](CHANGELOG.md) for details about all changes and versions.
782
759
 
783
760
  <br/>
784
761
 
@@ -1 +1 @@
1
- {"version":3,"file":"buildPackageJson.cjs","names":["editJsonFile","getTypescriptOutdir","EXPORT_KEY","sortKeys"],"sources":["../../src/build-tests/buildPackageJson.ts"],"sourcesContent":["import editJsonFile from 'edit-json-file';\nimport sortKeys from 'sort-keys';\n\nimport type { Fn } from '#utils';\n\nimport { BIN_KEY, EXPORT_KEY, EXPORT_KEYS } from './constants';\nimport { getTypescriptOutdir } from './getTypescriptOutdir';\n\ntype BuldPackageJson_F = Fn<[], { packageJson: object; outDir: string }>;\n\n/**\n * Transforms `package.json` for packed distribution by adjusting paths and removing internal fields.\n *\n * @returns Object containing the modified `packageJson` and resolved `outDir`.\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":";;;;;;;;;;;;;;AAeA,MAAa,yBAA4C;CACvD,MAAM,QAAA,GAAOA,eAAAA,QAAAA,CAAa,gBAAgB;CAC1C,MAAM,SAASC,wCAAAA,oBAAoB;CACnC,MAAM,MAAM,GAAG,OAAO;CACtB,MAAM,cAAc,QAAgB,IAAI,QAAQ,KAAK,EAAE;CAGvD,8BAAA,YAAY,SAAQ,QAAO;EACzB,MAAM,QAAQ,KAAK,IAAI,GAAG;EAC1B,IAAI,OAAO;GACT,MAAM,cAAc,WAAW,KAAK;GACpC,KAAK,IAAI,KAAK,WAAW;EAC3B;CACF,CAAC;CAID,MAAM,eAAe,KAAK,IAAIC,8BAAAA,UAAU;CAExC,IAAI,cAAc;EAChB,MAAM,qBAAqB,OAAO,QAAQ,YAAY,CAAC,CAAC,QACrD,KAAK,CAAC,KAAK,WAAW;GAErB,MAAM,SADU,OAAO,QAAQ,KACV,CAAC,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;IACnD,IAAI,OAAO,WAAW,KAAY;IAClC,OAAO;GACT,GAAG,CAAC,CAAQ;GACZ,IAAI,OAAO,IAAI,SAAS,cAAc,IAAI,QAAQ;GAClD,OAAO;EACT,GACA,CAAC,CACH;EAEA,KAAK,IAAIA,8BAAAA,YAAY,kBAAkB;CACzC;CAIA,MAAM,OAAO,KAAK,IAAA,KAAW;CAK7B,IAAI,MAAM;EACR,IAAI,OAAO,SAAS,UAAU;GAC5B,MAAM,OAAO,WAAW,IAAI;GAC5B,KAAK,IAAA,OAAa,IAAI;EACxB,OAAO;GACL,MAAM,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;IAC9D,IAAI,OAAO,WAAW,KAAK;IAC3B,OAAO;GACT,GAAG,CAAC,CAAQ;GAEZ,MAAM,QAAA,GAAOC,UAAAA,QAAAA,CAAS,IAAI;GAC1B,KAAK,IAAA,OAAa,IAAI;EACxB;CACF;CAIA,KAAK,MAAM,OAAO;CAClB,KAAK,MAAM,SAAS;CACpB,KAAK,MAAM,iBAAiB;CAI5B,OAAO;EAAE,aADW,KAAK,IACN;EAAG;CAAO;AAC/B"}
1
+ {"version":3,"file":"buildPackageJson.cjs","names":["editJsonFile","getTypescriptOutdir","EXPORT_KEY","sortKeys"],"sources":["../../src/build-tests/buildPackageJson.ts"],"sourcesContent":["import editJsonFile from 'edit-json-file';\nimport sortKeys from 'sort-keys';\n\nimport type { Fn } from '#utils';\n\nimport { BIN_KEY, EXPORT_KEY, EXPORT_KEYS } from './constants';\nimport { getTypescriptOutdir } from './getTypescriptOutdir';\n\ntype BuldPackageJson_F = Fn<[], { packageJson: object; outDir: string }>;\n\n/**\n * Transforms `package.json` for packed distribution by adjusting paths and removing internal fields.\n *\n * @returns Object containing the modified `packageJson` and resolved `outDir`.\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 Record<string, string> | undefined | 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":";;;;;;;;;;;;;;AAeA,MAAa,yBAA4C;CACvD,MAAM,QAAA,GAAOA,eAAAA,QAAAA,CAAa,gBAAgB;CAC1C,MAAM,SAASC,wCAAAA,oBAAoB;CACnC,MAAM,MAAM,GAAG,OAAO;CACtB,MAAM,cAAc,QAAgB,IAAI,QAAQ,KAAK,EAAE;CAGvD,8BAAA,YAAY,SAAQ,QAAO;EACzB,MAAM,QAAQ,KAAK,IAAI,GAAG;EAC1B,IAAI,OAAO;GACT,MAAM,cAAc,WAAW,KAAK;GACpC,KAAK,IAAI,KAAK,WAAW;EAC3B;CACF,CAAC;CAID,MAAM,eAAe,KAAK,IAAIC,8BAAAA,UAAU;CAExC,IAAI,cAAc;EAChB,MAAM,qBAAqB,OAAO,QAAQ,YAAY,CAAC,CAAC,QACrD,KAAK,CAAC,KAAK,WAAW;GAErB,MAAM,SADU,OAAO,QAAQ,KACV,CAAC,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;IACnD,IAAI,OAAO,WAAW,KAAY;IAClC,OAAO;GACT,GAAG,CAAC,CAAQ;GACZ,IAAI,OAAO,IAAI,SAAS,cAAc,IAAI,QAAQ;GAClD,OAAO;EACT,GACA,CAAC,CACH;EAEA,KAAK,IAAIA,8BAAAA,YAAY,kBAAkB;CACzC;CAIA,MAAM,OAAO,KAAK,IAAA,KAAW;CAE7B,IAAI,MAAM;EACR,IAAI,OAAO,SAAS,UAAU;GAC5B,MAAM,OAAO,WAAW,IAAI;GAC5B,KAAK,IAAA,OAAa,IAAI;EACxB,OAAO;GACL,MAAM,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;IAC9D,IAAI,OAAO,WAAW,KAAK;IAC3B,OAAO;GACT,GAAG,CAAC,CAAQ;GAEZ,MAAM,QAAA,GAAOC,UAAAA,QAAAA,CAAS,IAAI;GAC1B,KAAK,IAAA,OAAa,IAAI;EACxB;CACF;CAIA,KAAK,MAAM,OAAO;CAClB,KAAK,MAAM,SAAS;CACpB,KAAK,MAAM,iBAAiB;CAI5B,OAAO;EAAE,aADW,KAAK,IACN;EAAG;CAAO;AAC/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildPackageJson.js","names":[],"sources":["../../src/build-tests/buildPackageJson.ts"],"sourcesContent":["import editJsonFile from 'edit-json-file';\nimport sortKeys from 'sort-keys';\n\nimport type { Fn } from '#utils';\n\nimport { BIN_KEY, EXPORT_KEY, EXPORT_KEYS } from './constants';\nimport { getTypescriptOutdir } from './getTypescriptOutdir';\n\ntype BuldPackageJson_F = Fn<[], { packageJson: object; outDir: string }>;\n\n/**\n * Transforms `package.json` for packed distribution by adjusting paths and removing internal fields.\n *\n * @returns Object containing the modified `packageJson` and resolved `outDir`.\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":";;;;;;;;;;AAeA,MAAa,yBAA4C;CACvD,MAAM,OAAO,aAAa,gBAAgB;CAC1C,MAAM,SAAS,oBAAoB;CACnC,MAAM,MAAM,GAAG,OAAO;CACtB,MAAM,cAAc,QAAgB,IAAI,QAAQ,KAAK,EAAE;CAGvD,YAAY,SAAQ,QAAO;EACzB,MAAM,QAAQ,KAAK,IAAI,GAAG;EAC1B,IAAI,OAAO;GACT,MAAM,cAAc,WAAW,KAAK;GACpC,KAAK,IAAI,KAAK,WAAW;EAC3B;CACF,CAAC;CAID,MAAM,eAAe,KAAK,IAAI,UAAU;CAExC,IAAI,cAAc;EAChB,MAAM,qBAAqB,OAAO,QAAQ,YAAY,CAAC,CAAC,QACrD,KAAK,CAAC,KAAK,WAAW;GAErB,MAAM,SADU,OAAO,QAAQ,KACV,CAAC,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;IACnD,IAAI,OAAO,WAAW,KAAY;IAClC,OAAO;GACT,GAAG,CAAC,CAAQ;GACZ,IAAI,OAAO,IAAI,SAAS,cAAc,IAAI,QAAQ;GAClD,OAAO;EACT,GACA,CAAC,CACH;EAEA,KAAK,IAAI,YAAY,kBAAkB;CACzC;CAIA,MAAM,OAAO,KAAK,IAAA,KAAW;CAK7B,IAAI,MAAM;EACR,IAAI,OAAO,SAAS,UAAU;GAC5B,MAAM,OAAO,WAAW,IAAI;GAC5B,KAAK,IAAA,OAAa,IAAI;EACxB,OAAO;GACL,MAAM,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;IAC9D,IAAI,OAAO,WAAW,KAAK;IAC3B,OAAO;GACT,GAAG,CAAC,CAAQ;GAEZ,MAAM,OAAO,SAAS,IAAI;GAC1B,KAAK,IAAA,OAAa,IAAI;EACxB;CACF;CAIA,KAAK,MAAM,OAAO;CAClB,KAAK,MAAM,SAAS;CACpB,KAAK,MAAM,iBAAiB;CAI5B,OAAO;EAAE,aADW,KAAK,IACN;EAAG;CAAO;AAC/B"}
1
+ {"version":3,"file":"buildPackageJson.js","names":[],"sources":["../../src/build-tests/buildPackageJson.ts"],"sourcesContent":["import editJsonFile from 'edit-json-file';\nimport sortKeys from 'sort-keys';\n\nimport type { Fn } from '#utils';\n\nimport { BIN_KEY, EXPORT_KEY, EXPORT_KEYS } from './constants';\nimport { getTypescriptOutdir } from './getTypescriptOutdir';\n\ntype BuldPackageJson_F = Fn<[], { packageJson: object; outDir: string }>;\n\n/**\n * Transforms `package.json` for packed distribution by adjusting paths and removing internal fields.\n *\n * @returns Object containing the modified `packageJson` and resolved `outDir`.\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 Record<string, string> | undefined | 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":";;;;;;;;;;AAeA,MAAa,yBAA4C;CACvD,MAAM,OAAO,aAAa,gBAAgB;CAC1C,MAAM,SAAS,oBAAoB;CACnC,MAAM,MAAM,GAAG,OAAO;CACtB,MAAM,cAAc,QAAgB,IAAI,QAAQ,KAAK,EAAE;CAGvD,YAAY,SAAQ,QAAO;EACzB,MAAM,QAAQ,KAAK,IAAI,GAAG;EAC1B,IAAI,OAAO;GACT,MAAM,cAAc,WAAW,KAAK;GACpC,KAAK,IAAI,KAAK,WAAW;EAC3B;CACF,CAAC;CAID,MAAM,eAAe,KAAK,IAAI,UAAU;CAExC,IAAI,cAAc;EAChB,MAAM,qBAAqB,OAAO,QAAQ,YAAY,CAAC,CAAC,QACrD,KAAK,CAAC,KAAK,WAAW;GAErB,MAAM,SADU,OAAO,QAAQ,KACV,CAAC,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;IACnD,IAAI,OAAO,WAAW,KAAY;IAClC,OAAO;GACT,GAAG,CAAC,CAAQ;GACZ,IAAI,OAAO,IAAI,SAAS,cAAc,IAAI,QAAQ;GAClD,OAAO;EACT,GACA,CAAC,CACH;EAEA,KAAK,IAAI,YAAY,kBAAkB;CACzC;CAIA,MAAM,OAAO,KAAK,IAAA,KAAW;CAE7B,IAAI,MAAM;EACR,IAAI,OAAO,SAAS,UAAU;GAC5B,MAAM,OAAO,WAAW,IAAI;GAC5B,KAAK,IAAA,OAAa,IAAI;EACxB,OAAO;GACL,MAAM,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;IAC9D,IAAI,OAAO,WAAW,KAAK;IAC3B,OAAO;GACT,GAAG,CAAC,CAAQ;GAEZ,MAAM,OAAO,SAAS,IAAI;GAC1B,KAAK,IAAA,OAAa,IAAI;EACxB;CACF;CAIA,KAAK,MAAM,OAAO;CAClB,KAAK,MAAM,SAAS;CACpB,KAAK,MAAM,iBAAiB;CAI5B,OAAO;EAAE,aADW,KAAK,IACN;EAAG;CAAO;AAC/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"test.cjs","names":["command","flag","addTarball","sh"],"sources":["../../../src/build-tests/cli/test.ts"],"sourcesContent":["import { command, flag } from 'cmd-ts';\nimport sh from 'shelljs';\n\nimport { addTarball } from '../addTarball';\nimport { cleanup } from '../cleanup';\n\n/**\n * CLI command to execute tests with optional lifecycle hooks (pre/post).\n */\nexport const test = command({\n name: 'test',\n\n args: {\n pretest: flag({\n description: 'The hook pretest',\n short: 'b',\n long: 'pretest',\n }),\n\n posttest: flag({\n description: 'The hook posttest',\n short: 'a',\n long: 'posttest',\n }),\n\n pre: flag({ description: 'The hook pretest', long: 'pre' }),\n\n post: flag({ description: 'The hook posttest', long: 'post' }),\n },\n\n // Ignores coverage because of recursivity\n /* v8 ignore next 11 */\n handler: async ({ pretest, posttest, pre, post }) => {\n if (pretest || pre) await addTarball();\n\n // #region Test\n const { stderr } = sh.exec('pnpm run test');\n if (!!stderr && stderr.trim() !== '') console.warn(stderr);\n // #endregion\n\n if (posttest || post) cleanup();\n },\n});\n"],"mappings":";;;;;;;;;;;AASA,MAAa,QAAA,GAAOA,OAAAA,QAAAA,CAAQ;CAC1B,MAAM;CAEN,MAAM;EACJ,UAAA,GAASC,OAAAA,KAAAA,CAAK;GACZ,aAAa;GACb,OAAO;GACP,MAAM;EACR,CAAC;EAED,WAAA,GAAUA,OAAAA,KAAAA,CAAK;GACb,aAAa;GACb,OAAO;GACP,MAAM;EACR,CAAC;EAED,MAAA,GAAKA,OAAAA,KAAAA,CAAK;GAAE,aAAa;GAAoB,MAAM;EAAM,CAAC;EAE1D,OAAA,GAAMA,OAAAA,KAAAA,CAAK;GAAE,aAAa;GAAqB,MAAM;EAAO,CAAC;CAC/D;;CAIA,SAAS,OAAO,EAAE,SAAS,UAAU,KAAK,WAAW;EACnD,IAAI,WAAW,KAAK,MAAMC,+BAAAA,WAAW;EAGrC,MAAM,EAAE,WAAWC,QAAAA,QAAG,KAAK,eAAe;EAC1C,IAAI,CAAC,CAAC,UAAU,OAAO,KAAK,MAAM,IAAI,QAAQ,KAAK,MAAM;EAGzD,IAAI,YAAY,MAAM,4BAAA,QAAQ;CAChC;AACF,CAAC"}
1
+ {"version":3,"file":"test.cjs","names":["command","flag","addTarball","sh"],"sources":["../../../src/build-tests/cli/test.ts"],"sourcesContent":["import { command, flag } from 'cmd-ts';\nimport sh from 'shelljs';\n\nimport { addTarball } from '../addTarball';\nimport { cleanup } from '../cleanup';\n\n/**\n * CLI command to execute tests with optional lifecycle hooks (pre/post).\n */\nexport const test = command({\n name: 'test',\n\n args: {\n pretest: flag({ description: 'The hook pretest', short: 'b', long: 'pretest' }),\n\n posttest: flag({\n description: 'The hook posttest',\n short: 'a',\n long: 'posttest',\n }),\n\n pre: flag({ description: 'The hook pretest', long: 'pre' }),\n\n post: flag({ description: 'The hook posttest', long: 'post' }),\n },\n\n // Ignores coverage because of recursivity\n /* v8 ignore next 11 */\n handler: async ({ pretest, posttest, pre, post }) => {\n if (pretest || pre) await addTarball();\n\n // #region Test\n const { stderr } = sh.exec('pnpm run test');\n if (!!stderr && stderr.trim() !== '') console.warn(stderr);\n // #endregion\n\n if (posttest || post) cleanup();\n },\n});\n"],"mappings":";;;;;;;;;;;AASA,MAAa,QAAA,GAAOA,OAAAA,QAAAA,CAAQ;CAC1B,MAAM;CAEN,MAAM;EACJ,UAAA,GAASC,OAAAA,KAAAA,CAAK;GAAE,aAAa;GAAoB,OAAO;GAAK,MAAM;EAAU,CAAC;EAE9E,WAAA,GAAUA,OAAAA,KAAAA,CAAK;GACb,aAAa;GACb,OAAO;GACP,MAAM;EACR,CAAC;EAED,MAAA,GAAKA,OAAAA,KAAAA,CAAK;GAAE,aAAa;GAAoB,MAAM;EAAM,CAAC;EAE1D,OAAA,GAAMA,OAAAA,KAAAA,CAAK;GAAE,aAAa;GAAqB,MAAM;EAAO,CAAC;CAC/D;;CAIA,SAAS,OAAO,EAAE,SAAS,UAAU,KAAK,WAAW;EACnD,IAAI,WAAW,KAAK,MAAMC,+BAAAA,WAAW;EAGrC,MAAM,EAAE,WAAWC,QAAAA,QAAG,KAAK,eAAe;EAC1C,IAAI,CAAC,CAAC,UAAU,OAAO,KAAK,MAAM,IAAI,QAAQ,KAAK,MAAM;EAGzD,IAAI,YAAY,MAAM,4BAAA,QAAQ;CAChC;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"test.js","names":[],"sources":["../../../src/build-tests/cli/test.ts"],"sourcesContent":["import { command, flag } from 'cmd-ts';\nimport sh from 'shelljs';\n\nimport { addTarball } from '../addTarball';\nimport { cleanup } from '../cleanup';\n\n/**\n * CLI command to execute tests with optional lifecycle hooks (pre/post).\n */\nexport const test = command({\n name: 'test',\n\n args: {\n pretest: flag({\n description: 'The hook pretest',\n short: 'b',\n long: 'pretest',\n }),\n\n posttest: flag({\n description: 'The hook posttest',\n short: 'a',\n long: 'posttest',\n }),\n\n pre: flag({ description: 'The hook pretest', long: 'pre' }),\n\n post: flag({ description: 'The hook posttest', long: 'post' }),\n },\n\n // Ignores coverage because of recursivity\n /* v8 ignore next 11 */\n handler: async ({ pretest, posttest, pre, post }) => {\n if (pretest || pre) await addTarball();\n\n // #region Test\n const { stderr } = sh.exec('pnpm run test');\n if (!!stderr && stderr.trim() !== '') console.warn(stderr);\n // #endregion\n\n if (posttest || post) cleanup();\n },\n});\n"],"mappings":";;;;;;;;AASA,MAAa,OAAO,QAAQ;CAC1B,MAAM;CAEN,MAAM;EACJ,SAAS,KAAK;GACZ,aAAa;GACb,OAAO;GACP,MAAM;EACR,CAAC;EAED,UAAU,KAAK;GACb,aAAa;GACb,OAAO;GACP,MAAM;EACR,CAAC;EAED,KAAK,KAAK;GAAE,aAAa;GAAoB,MAAM;EAAM,CAAC;EAE1D,MAAM,KAAK;GAAE,aAAa;GAAqB,MAAM;EAAO,CAAC;CAC/D;;CAIA,SAAS,OAAO,EAAE,SAAS,UAAU,KAAK,WAAW;EACnD,IAAI,WAAW,KAAK,MAAM,WAAW;EAGrC,MAAM,EAAE,WAAW,GAAG,KAAK,eAAe;EAC1C,IAAI,CAAC,CAAC,UAAU,OAAO,KAAK,MAAM,IAAI,QAAQ,KAAK,MAAM;EAGzD,IAAI,YAAY,MAAM,QAAQ;CAChC;AACF,CAAC"}
1
+ {"version":3,"file":"test.js","names":[],"sources":["../../../src/build-tests/cli/test.ts"],"sourcesContent":["import { command, flag } from 'cmd-ts';\nimport sh from 'shelljs';\n\nimport { addTarball } from '../addTarball';\nimport { cleanup } from '../cleanup';\n\n/**\n * CLI command to execute tests with optional lifecycle hooks (pre/post).\n */\nexport const test = command({\n name: 'test',\n\n args: {\n pretest: flag({ description: 'The hook pretest', short: 'b', long: 'pretest' }),\n\n posttest: flag({\n description: 'The hook posttest',\n short: 'a',\n long: 'posttest',\n }),\n\n pre: flag({ description: 'The hook pretest', long: 'pre' }),\n\n post: flag({ description: 'The hook posttest', long: 'post' }),\n },\n\n // Ignores coverage because of recursivity\n /* v8 ignore next 11 */\n handler: async ({ pretest, posttest, pre, post }) => {\n if (pretest || pre) await addTarball();\n\n // #region Test\n const { stderr } = sh.exec('pnpm run test');\n if (!!stderr && stderr.trim() !== '') console.warn(stderr);\n // #endregion\n\n if (posttest || post) cleanup();\n },\n});\n"],"mappings":";;;;;;;;AASA,MAAa,OAAO,QAAQ;CAC1B,MAAM;CAEN,MAAM;EACJ,SAAS,KAAK;GAAE,aAAa;GAAoB,OAAO;GAAK,MAAM;EAAU,CAAC;EAE9E,UAAU,KAAK;GACb,aAAa;GACb,OAAO;GACP,MAAM;EACR,CAAC;EAED,KAAK,KAAK;GAAE,aAAa;GAAoB,MAAM;EAAM,CAAC;EAE1D,MAAM,KAAK;GAAE,aAAa;GAAqB,MAAM;EAAO,CAAC;CAC/D;;CAIA,SAAS,OAAO,EAAE,SAAS,UAAU,KAAK,WAAW;EACnD,IAAI,WAAW,KAAK,MAAM,WAAW;EAGrC,MAAM,EAAE,WAAW,GAAG,KAAK,eAAe;EAC1C,IAAI,CAAC,CAAC,UAAU,OAAO,KAAK,MAAM,IAAI,QAAQ,KAAK,MAAM;EAGzD,IAAI,YAAY,MAAM,QAAQ;CAChC;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getTypescriptOutdir.cjs","names":["editJsonFile","resolve","TS_PATH"],"sources":["../../src/build-tests/getTypescriptOutdir.ts"],"sourcesContent":["import { resolve } from 'path';\n\nimport editJsonFile, { type JsonEditor } from 'edit-json-file';\n\nimport type { Fn } from '#utils/types';\n\nimport { DEFAULT_OUT_DIR, DOT, PATH_OUT_DIR, TS_PATH } from './constants';\n\ntype Fn1 = Fn<[], string>;\n\n/**\n * Resolves the TypeScript output directory specified in `tsconfig.json`.\n *\n * @returns Output directory path string without leading `./`.\n */\nexport const getTypescriptOutdir: Fn1 = () => {\n let file: JsonEditor | undefined = editJsonFile(\n resolve(process.cwd(), TS_PATH),\n );\n\n const outDir1 = file.get(PATH_OUT_DIR) ?? DEFAULT_OUT_DIR;\n /* v8 ignore next 3 */\n const outDir2 = outDir1.startsWith(DOT)\n ? outDir1.replace(DOT, '')\n : outDir1;\n\n file = undefined;\n return outDir2;\n};\n"],"mappings":";;;;;;;;;;;;AAeA,MAAa,4BAAiC;CAC5C,IAAI,QAAA,GAA+BA,eAAAA,QAAAA,EAAAA,GACjCC,KAAAA,QAAAA,CAAQ,QAAQ,IAAI,GAAGC,8BAAAA,OAAO,CAChC;CAEA,MAAM,UAAU,KAAK,IAAA,wBAAgB,KAAA;;CAErC,MAAM,UAAU,QAAQ,WAAA,IAAc,IAClC,QAAQ,QAAA,MAAa,EAAE,IACvB;CAEJ,OAAO,KAAA;CACP,OAAO;AACT"}
1
+ {"version":3,"file":"getTypescriptOutdir.cjs","names":["editJsonFile","resolve","TS_PATH"],"sources":["../../src/build-tests/getTypescriptOutdir.ts"],"sourcesContent":["import { resolve } from 'path';\n\nimport editJsonFile, { type JsonEditor } from 'edit-json-file';\n\nimport type { Fn } from '#utils/types';\n\nimport { DEFAULT_OUT_DIR, DOT, PATH_OUT_DIR, TS_PATH } from './constants';\n\ntype Fn1 = Fn<[], string>;\n\n/**\n * Resolves the TypeScript output directory specified in `tsconfig.json`.\n *\n * @returns Output directory path string without leading `./`.\n */\nexport const getTypescriptOutdir: Fn1 = () => {\n let file: JsonEditor | undefined = editJsonFile(resolve(process.cwd(), TS_PATH));\n\n const outDir1 = file.get(PATH_OUT_DIR) ?? DEFAULT_OUT_DIR;\n /* v8 ignore next 3 */\n const outDir2 = outDir1.startsWith(DOT) ? outDir1.replace(DOT, '') : outDir1;\n\n file = undefined;\n return outDir2;\n};\n"],"mappings":";;;;;;;;;;;;AAeA,MAAa,4BAAiC;CAC5C,IAAI,QAAA,GAA+BA,eAAAA,QAAAA,EAAAA,GAAaC,KAAAA,QAAAA,CAAQ,QAAQ,IAAI,GAAGC,8BAAAA,OAAO,CAAC;CAE/E,MAAM,UAAU,KAAK,IAAA,wBAAgB,KAAA;;CAErC,MAAM,UAAU,QAAQ,WAAA,IAAc,IAAI,QAAQ,QAAA,MAAa,EAAE,IAAI;CAErE,OAAO,KAAA;CACP,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"getTypescriptOutdir.js","names":[],"sources":["../../src/build-tests/getTypescriptOutdir.ts"],"sourcesContent":["import { resolve } from 'path';\n\nimport editJsonFile, { type JsonEditor } from 'edit-json-file';\n\nimport type { Fn } from '#utils/types';\n\nimport { DEFAULT_OUT_DIR, DOT, PATH_OUT_DIR, TS_PATH } from './constants';\n\ntype Fn1 = Fn<[], string>;\n\n/**\n * Resolves the TypeScript output directory specified in `tsconfig.json`.\n *\n * @returns Output directory path string without leading `./`.\n */\nexport const getTypescriptOutdir: Fn1 = () => {\n let file: JsonEditor | undefined = editJsonFile(\n resolve(process.cwd(), TS_PATH),\n );\n\n const outDir1 = file.get(PATH_OUT_DIR) ?? DEFAULT_OUT_DIR;\n /* v8 ignore next 3 */\n const outDir2 = outDir1.startsWith(DOT)\n ? outDir1.replace(DOT, '')\n : outDir1;\n\n file = undefined;\n return outDir2;\n};\n"],"mappings":";;;;;;;;;AAeA,MAAa,4BAAiC;CAC5C,IAAI,OAA+B,aACjC,QAAQ,QAAQ,IAAI,GAAG,OAAO,CAChC;CAEA,MAAM,UAAU,KAAK,IAAA,wBAAgB,KAAA;;CAErC,MAAM,UAAU,QAAQ,WAAA,IAAc,IAClC,QAAQ,QAAA,MAAa,EAAE,IACvB;CAEJ,OAAO,KAAA;CACP,OAAO;AACT"}
1
+ {"version":3,"file":"getTypescriptOutdir.js","names":[],"sources":["../../src/build-tests/getTypescriptOutdir.ts"],"sourcesContent":["import { resolve } from 'path';\n\nimport editJsonFile, { type JsonEditor } from 'edit-json-file';\n\nimport type { Fn } from '#utils/types';\n\nimport { DEFAULT_OUT_DIR, DOT, PATH_OUT_DIR, TS_PATH } from './constants';\n\ntype Fn1 = Fn<[], string>;\n\n/**\n * Resolves the TypeScript output directory specified in `tsconfig.json`.\n *\n * @returns Output directory path string without leading `./`.\n */\nexport const getTypescriptOutdir: Fn1 = () => {\n let file: JsonEditor | undefined = editJsonFile(resolve(process.cwd(), TS_PATH));\n\n const outDir1 = file.get(PATH_OUT_DIR) ?? DEFAULT_OUT_DIR;\n /* v8 ignore next 3 */\n const outDir2 = outDir1.startsWith(DOT) ? outDir1.replace(DOT, '') : outDir1;\n\n file = undefined;\n return outDir2;\n};\n"],"mappings":";;;;;;;;;AAeA,MAAa,4BAAiC;CAC5C,IAAI,OAA+B,aAAa,QAAQ,QAAQ,IAAI,GAAG,OAAO,CAAC;CAE/E,MAAM,UAAU,KAAK,IAAA,wBAAgB,KAAA;;CAErC,MAAM,UAAU,QAAQ,WAAA,IAAc,IAAI,QAAQ,QAAA,MAAa,EAAE,IAAI;CAErE,OAAO,KAAA;CACP,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"create.cjs","names":["helperFn","toStringFlat"],"sources":["../../../src/build-tests/imports/create.ts"],"sourcesContent":["import { describe, test } from 'vitest';\n\nimport { toStringFlat } from '../../vitest-extended/toStringFlat';\nimport { helperFn } from './helper';\n\n/**\n * Options defining expected exported and non-exported symbols.\n */\nexport type ImportArgs = {\n path?: string;\n FAILS?: string[];\n SUCCESS: string[];\n};\n\n/**\n * Function type creating import test suites.\n */\nexport type CreateImportTest_F = (\n args: ImportArgs,\n) => readonly [string, () => void];\n\n/**\n * Creates Vitest test suites verifying that symbols are properly exported from a module.\n *\n * @param args - Import test arguments of type {@linkcode ImportArgs}.\n *\n * @returns Tuple of test description and test runner function.\n */\nexport const createImportFnTests: CreateImportTest_F = args => {\n const path = args.path;\n const invite = `Importing from ${path ?? 'index'}`;\n const testFn = (fn: string) => helperFn({ path, fn });\n\n const fn = () => {\n describe.skipIf(args.SUCCESS.length < 1)(\n '#01 => Functions are inside the module',\n () => {\n const _index = (index: number) => {\n return toStringFlat(index + 1, args.SUCCESS.length);\n };\n\n args.SUCCESS.forEach((fn, index) => {\n test(`#${_index(index)} => should succeed with function ${fn}`, () => {\n return testFn(fn);\n });\n });\n },\n );\n\n if (!args.FAILS || args.FAILS.length < 1) return;\n\n describe('#02 => Functions are not inside the module', () => {\n const _index = (index: number) => {\n return toStringFlat(index + 1, args.FAILS!.length);\n };\n\n args.FAILS!.forEach((fn, index) => {\n test.fails(`#${_index(index)} => should fail with function ${fn}`, () => {\n return testFn(fn);\n });\n });\n });\n };\n\n return [invite, fn] as const;\n};\n"],"mappings":";;;;;;;;;;;;AA4BA,MAAa,uBAA0C,SAAQ;CAC7D,MAAM,OAAO,KAAK;CAClB,MAAM,SAAS,kBAAkB,QAAQ;CACzC,MAAM,UAAU,OAAeA,mCAAAA,SAAS;EAAE;EAAM;CAAG,CAAC;CAEpD,MAAM,WAAW;EACf,OAAA,SAAS,OAAO,KAAK,QAAQ,SAAS,CAAC,CAAC,CACtC,gDACM;GACJ,MAAM,UAAU,UAAkB;IAChC,OAAOC,qCAAAA,aAAa,QAAQ,GAAG,KAAK,QAAQ,MAAM;GACpD;GAEA,KAAK,QAAQ,SAAS,IAAI,UAAU;IAClC,CAAA,GAAA,OAAA,KAAA,CAAK,IAAI,OAAO,KAAK,EAAE,mCAAmC,YAAY;KACpE,OAAO,OAAO,EAAE;IAClB,CAAC;GACH,CAAC;EACH,CACF;EAEA,IAAI,CAAC,KAAK,SAAS,KAAK,MAAM,SAAS,GAAG;EAE1C,CAAA,GAAA,OAAA,SAAA,CAAS,oDAAoD;GAC3D,MAAM,UAAU,UAAkB;IAChC,OAAOA,qCAAAA,aAAa,QAAQ,GAAG,KAAK,MAAO,MAAM;GACnD;GAEA,KAAK,MAAO,SAAS,IAAI,UAAU;IACjC,OAAA,KAAK,MAAM,IAAI,OAAO,KAAK,EAAE,gCAAgC,YAAY;KACvE,OAAO,OAAO,EAAE;IAClB,CAAC;GACH,CAAC;EACH,CAAC;CACH;CAEA,OAAO,CAAC,QAAQ,EAAE;AACpB"}
1
+ {"version":3,"file":"create.cjs","names":["helperFn","toStringFlat"],"sources":["../../../src/build-tests/imports/create.ts"],"sourcesContent":["import { describe, test } from 'vitest';\n\nimport { toStringFlat } from '../../vitest-extended/toStringFlat';\nimport { helperFn } from './helper';\n\n/**\n * Options defining expected exported and non-exported symbols.\n */\nexport type ImportArgs = { path?: string; FAILS?: string[]; SUCCESS: string[] };\n\n/**\n * Function type creating import test suites.\n */\nexport type CreateImportTest_F = (args: ImportArgs) => readonly [string, () => void];\n\n/**\n * Creates Vitest test suites verifying that symbols are properly exported from a module.\n *\n * @param args - Import test arguments of type {@linkcode ImportArgs}.\n *\n * @returns Tuple of test description and test runner function.\n */\nexport const createImportFnTests: CreateImportTest_F = args => {\n const path = args.path;\n const invite = `Importing from ${path ?? 'index'}`;\n const testFn = (fn: string) => helperFn({ path, fn });\n\n const fn = () => {\n describe.skipIf(args.SUCCESS.length < 1)(\n '#01 => Functions are inside the module',\n () => {\n const _index = (index: number) => {\n return toStringFlat(index + 1, args.SUCCESS.length);\n };\n\n args.SUCCESS.forEach((fn, index) => {\n test(`#${_index(index)} => should succeed with function ${fn}`, () => {\n return testFn(fn);\n });\n });\n },\n );\n\n if (!args.FAILS || args.FAILS.length < 1) return;\n\n describe('#02 => Functions are not inside the module', () => {\n const _index = (index: number) => {\n return toStringFlat(index + 1, args.FAILS!.length);\n };\n\n args.FAILS!.forEach((fn, index) => {\n test.fails(`#${_index(index)} => should fail with function ${fn}`, () => {\n return testFn(fn);\n });\n });\n });\n };\n\n return [invite, fn] as const;\n};\n"],"mappings":";;;;;;;;;;;;AAsBA,MAAa,uBAA0C,SAAQ;CAC7D,MAAM,OAAO,KAAK;CAClB,MAAM,SAAS,kBAAkB,QAAQ;CACzC,MAAM,UAAU,OAAeA,mCAAAA,SAAS;EAAE;EAAM;CAAG,CAAC;CAEpD,MAAM,WAAW;EACf,OAAA,SAAS,OAAO,KAAK,QAAQ,SAAS,CAAC,CAAC,CACtC,gDACM;GACJ,MAAM,UAAU,UAAkB;IAChC,OAAOC,qCAAAA,aAAa,QAAQ,GAAG,KAAK,QAAQ,MAAM;GACpD;GAEA,KAAK,QAAQ,SAAS,IAAI,UAAU;IAClC,CAAA,GAAA,OAAA,KAAA,CAAK,IAAI,OAAO,KAAK,EAAE,mCAAmC,YAAY;KACpE,OAAO,OAAO,EAAE;IAClB,CAAC;GACH,CAAC;EACH,CACF;EAEA,IAAI,CAAC,KAAK,SAAS,KAAK,MAAM,SAAS,GAAG;EAE1C,CAAA,GAAA,OAAA,SAAA,CAAS,oDAAoD;GAC3D,MAAM,UAAU,UAAkB;IAChC,OAAOA,qCAAAA,aAAa,QAAQ,GAAG,KAAK,MAAO,MAAM;GACnD;GAEA,KAAK,MAAO,SAAS,IAAI,UAAU;IACjC,OAAA,KAAK,MAAM,IAAI,OAAO,KAAK,EAAE,gCAAgC,YAAY;KACvE,OAAO,OAAO,EAAE;IAClB,CAAC;GACH,CAAC;EACH,CAAC;CACH;CAEA,OAAO,CAAC,QAAQ,EAAE;AACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","names":[],"sources":["../../../src/build-tests/imports/create.ts"],"sourcesContent":["import { describe, test } from 'vitest';\n\nimport { toStringFlat } from '../../vitest-extended/toStringFlat';\nimport { helperFn } from './helper';\n\n/**\n * Options defining expected exported and non-exported symbols.\n */\nexport type ImportArgs = {\n path?: string;\n FAILS?: string[];\n SUCCESS: string[];\n};\n\n/**\n * Function type creating import test suites.\n */\nexport type CreateImportTest_F = (\n args: ImportArgs,\n) => readonly [string, () => void];\n\n/**\n * Creates Vitest test suites verifying that symbols are properly exported from a module.\n *\n * @param args - Import test arguments of type {@linkcode ImportArgs}.\n *\n * @returns Tuple of test description and test runner function.\n */\nexport const createImportFnTests: CreateImportTest_F = args => {\n const path = args.path;\n const invite = `Importing from ${path ?? 'index'}`;\n const testFn = (fn: string) => helperFn({ path, fn });\n\n const fn = () => {\n describe.skipIf(args.SUCCESS.length < 1)(\n '#01 => Functions are inside the module',\n () => {\n const _index = (index: number) => {\n return toStringFlat(index + 1, args.SUCCESS.length);\n };\n\n args.SUCCESS.forEach((fn, index) => {\n test(`#${_index(index)} => should succeed with function ${fn}`, () => {\n return testFn(fn);\n });\n });\n },\n );\n\n if (!args.FAILS || args.FAILS.length < 1) return;\n\n describe('#02 => Functions are not inside the module', () => {\n const _index = (index: number) => {\n return toStringFlat(index + 1, args.FAILS!.length);\n };\n\n args.FAILS!.forEach((fn, index) => {\n test.fails(`#${_index(index)} => should fail with function ${fn}`, () => {\n return testFn(fn);\n });\n });\n });\n };\n\n return [invite, fn] as const;\n};\n"],"mappings":";;;;;;;;;;;AA4BA,MAAa,uBAA0C,SAAQ;CAC7D,MAAM,OAAO,KAAK;CAClB,MAAM,SAAS,kBAAkB,QAAQ;CACzC,MAAM,UAAU,OAAe,SAAS;EAAE;EAAM;CAAG,CAAC;CAEpD,MAAM,WAAW;EACf,SAAS,OAAO,KAAK,QAAQ,SAAS,CAAC,CAAC,CACtC,gDACM;GACJ,MAAM,UAAU,UAAkB;IAChC,OAAO,aAAa,QAAQ,GAAG,KAAK,QAAQ,MAAM;GACpD;GAEA,KAAK,QAAQ,SAAS,IAAI,UAAU;IAClC,KAAK,IAAI,OAAO,KAAK,EAAE,mCAAmC,YAAY;KACpE,OAAO,OAAO,EAAE;IAClB,CAAC;GACH,CAAC;EACH,CACF;EAEA,IAAI,CAAC,KAAK,SAAS,KAAK,MAAM,SAAS,GAAG;EAE1C,SAAS,oDAAoD;GAC3D,MAAM,UAAU,UAAkB;IAChC,OAAO,aAAa,QAAQ,GAAG,KAAK,MAAO,MAAM;GACnD;GAEA,KAAK,MAAO,SAAS,IAAI,UAAU;IACjC,KAAK,MAAM,IAAI,OAAO,KAAK,EAAE,gCAAgC,YAAY;KACvE,OAAO,OAAO,EAAE;IAClB,CAAC;GACH,CAAC;EACH,CAAC;CACH;CAEA,OAAO,CAAC,QAAQ,EAAE;AACpB"}
1
+ {"version":3,"file":"create.js","names":[],"sources":["../../../src/build-tests/imports/create.ts"],"sourcesContent":["import { describe, test } from 'vitest';\n\nimport { toStringFlat } from '../../vitest-extended/toStringFlat';\nimport { helperFn } from './helper';\n\n/**\n * Options defining expected exported and non-exported symbols.\n */\nexport type ImportArgs = { path?: string; FAILS?: string[]; SUCCESS: string[] };\n\n/**\n * Function type creating import test suites.\n */\nexport type CreateImportTest_F = (args: ImportArgs) => readonly [string, () => void];\n\n/**\n * Creates Vitest test suites verifying that symbols are properly exported from a module.\n *\n * @param args - Import test arguments of type {@linkcode ImportArgs}.\n *\n * @returns Tuple of test description and test runner function.\n */\nexport const createImportFnTests: CreateImportTest_F = args => {\n const path = args.path;\n const invite = `Importing from ${path ?? 'index'}`;\n const testFn = (fn: string) => helperFn({ path, fn });\n\n const fn = () => {\n describe.skipIf(args.SUCCESS.length < 1)(\n '#01 => Functions are inside the module',\n () => {\n const _index = (index: number) => {\n return toStringFlat(index + 1, args.SUCCESS.length);\n };\n\n args.SUCCESS.forEach((fn, index) => {\n test(`#${_index(index)} => should succeed with function ${fn}`, () => {\n return testFn(fn);\n });\n });\n },\n );\n\n if (!args.FAILS || args.FAILS.length < 1) return;\n\n describe('#02 => Functions are not inside the module', () => {\n const _index = (index: number) => {\n return toStringFlat(index + 1, args.FAILS!.length);\n };\n\n args.FAILS!.forEach((fn, index) => {\n test.fails(`#${_index(index)} => should fail with function ${fn}`, () => {\n return testFn(fn);\n });\n });\n });\n };\n\n return [invite, fn] as const;\n};\n"],"mappings":";;;;;;;;;;;AAsBA,MAAa,uBAA0C,SAAQ;CAC7D,MAAM,OAAO,KAAK;CAClB,MAAM,SAAS,kBAAkB,QAAQ;CACzC,MAAM,UAAU,OAAe,SAAS;EAAE;EAAM;CAAG,CAAC;CAEpD,MAAM,WAAW;EACf,SAAS,OAAO,KAAK,QAAQ,SAAS,CAAC,CAAC,CACtC,gDACM;GACJ,MAAM,UAAU,UAAkB;IAChC,OAAO,aAAa,QAAQ,GAAG,KAAK,QAAQ,MAAM;GACpD;GAEA,KAAK,QAAQ,SAAS,IAAI,UAAU;IAClC,KAAK,IAAI,OAAO,KAAK,EAAE,mCAAmC,YAAY;KACpE,OAAO,OAAO,EAAE;IAClB,CAAC;GACH,CAAC;EACH,CACF;EAEA,IAAI,CAAC,KAAK,SAAS,KAAK,MAAM,SAAS,GAAG;EAE1C,SAAS,oDAAoD;GAC3D,MAAM,UAAU,UAAkB;IAChC,OAAO,aAAa,QAAQ,GAAG,KAAK,MAAO,MAAM;GACnD;GAEA,KAAK,MAAO,SAAS,IAAI,UAAU;IACjC,KAAK,MAAM,IAAI,OAAO,KAAK,EAAE,gCAAgC,YAAY;KACvE,OAAO,OAAO,EAAE;IAClB,CAAC;GACH,CAAC;EACH,CAAC;CACH;CAEA,OAAO,CAAC,QAAQ,EAAE;AACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"helper.cjs","names":["customImport"],"sources":["../../../src/build-tests/imports/helper.ts"],"sourcesContent":["import { expect } from 'vitest';\n\nimport type { Fn } from '../../utils/bemedev/globals/types';\nimport { customImport } from '../import';\n\n/**\n * Helper function type for verifying exported functions.\n */\nexport type Helper_F = (args: {\n path?: string;\n fn: string;\n}) => Promise<void>;\n\n/**\n * Asserts that a specified function is defined and exported from a module.\n *\n * @template | {@linkcode Fn} `T` - Expected function type.\n *\n * @param args - Options object.\n * @param args.path - Submodule path to import from.\n * @param args.fn - Named export function name.\n */\nexport const helperFn = async <T extends Fn = Fn>({\n path,\n fn,\n}: {\n path?: string;\n fn: string;\n}) => {\n const _fn = await customImport<T>({ path, fn: m => m[fn] });\n expect(_fn).toBeDefined();\n expect(_fn).toBeTypeOf('function');\n};\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAa,WAAW,OAA0B,EAChD,MACA,SAII;CACJ,MAAM,MAAM,MAAMA,2BAAAA,aAAgB;EAAE;EAAM,KAAI,MAAK,EAAE;CAAI,CAAC;CAC1D,CAAA,GAAA,OAAA,OAAA,CAAO,GAAG,CAAC,CAAC,YAAY;CACxB,CAAA,GAAA,OAAA,OAAA,CAAO,GAAG,CAAC,CAAC,WAAW,UAAU;AACnC"}
1
+ {"version":3,"file":"helper.cjs","names":["customImport"],"sources":["../../../src/build-tests/imports/helper.ts"],"sourcesContent":["import { expect } from 'vitest';\n\nimport type { Fn } from '../../utils/bemedev/globals/types';\nimport { customImport } from '../import';\n\n/**\n * Helper function type for verifying exported functions.\n */\nexport type Helper_F = (args: { path?: string; fn: string }) => Promise<void>;\n\n/**\n * Asserts that a specified function is defined and exported from a module.\n *\n * @template | {@linkcode Fn} `T` - Expected function type.\n *\n * @param args - Options object.\n * @param args.path - Submodule path to import from.\n * @param args.fn - Named export function name.\n */\nexport const helperFn = async <T extends Fn = Fn>({\n path,\n fn,\n}: {\n path?: string;\n fn: string;\n}) => {\n const _fn = await customImport<T>({ path, fn: m => m[fn] });\n expect(_fn).toBeDefined();\n expect(_fn).toBeTypeOf('function');\n};\n"],"mappings":";;;;;;;;;;;;;AAmBA,MAAa,WAAW,OAA0B,EAChD,MACA,SAII;CACJ,MAAM,MAAM,MAAMA,2BAAAA,aAAgB;EAAE;EAAM,KAAI,MAAK,EAAE;CAAI,CAAC;CAC1D,CAAA,GAAA,OAAA,OAAA,CAAO,GAAG,CAAC,CAAC,YAAY;CACxB,CAAA,GAAA,OAAA,OAAA,CAAO,GAAG,CAAC,CAAC,WAAW,UAAU;AACnC"}
@@ -1 +1 @@
1
- {"version":3,"file":"helper.js","names":[],"sources":["../../../src/build-tests/imports/helper.ts"],"sourcesContent":["import { expect } from 'vitest';\n\nimport type { Fn } from '../../utils/bemedev/globals/types';\nimport { customImport } from '../import';\n\n/**\n * Helper function type for verifying exported functions.\n */\nexport type Helper_F = (args: {\n path?: string;\n fn: string;\n}) => Promise<void>;\n\n/**\n * Asserts that a specified function is defined and exported from a module.\n *\n * @template | {@linkcode Fn} `T` - Expected function type.\n *\n * @param args - Options object.\n * @param args.path - Submodule path to import from.\n * @param args.fn - Named export function name.\n */\nexport const helperFn = async <T extends Fn = Fn>({\n path,\n fn,\n}: {\n path?: string;\n fn: string;\n}) => {\n const _fn = await customImport<T>({ path, fn: m => m[fn] });\n expect(_fn).toBeDefined();\n expect(_fn).toBeTypeOf('function');\n};\n"],"mappings":";;;;;;;;;;;;AAsBA,MAAa,WAAW,OAA0B,EAChD,MACA,SAII;CACJ,MAAM,MAAM,MAAM,aAAgB;EAAE;EAAM,KAAI,MAAK,EAAE;CAAI,CAAC;CAC1D,OAAO,GAAG,CAAC,CAAC,YAAY;CACxB,OAAO,GAAG,CAAC,CAAC,WAAW,UAAU;AACnC"}
1
+ {"version":3,"file":"helper.js","names":[],"sources":["../../../src/build-tests/imports/helper.ts"],"sourcesContent":["import { expect } from 'vitest';\n\nimport type { Fn } from '../../utils/bemedev/globals/types';\nimport { customImport } from '../import';\n\n/**\n * Helper function type for verifying exported functions.\n */\nexport type Helper_F = (args: { path?: string; fn: string }) => Promise<void>;\n\n/**\n * Asserts that a specified function is defined and exported from a module.\n *\n * @template | {@linkcode Fn} `T` - Expected function type.\n *\n * @param args - Options object.\n * @param args.path - Submodule path to import from.\n * @param args.fn - Named export function name.\n */\nexport const helperFn = async <T extends Fn = Fn>({\n path,\n fn,\n}: {\n path?: string;\n fn: string;\n}) => {\n const _fn = await customImport<T>({ path, fn: m => m[fn] });\n expect(_fn).toBeDefined();\n expect(_fn).toBeTypeOf('function');\n};\n"],"mappings":";;;;;;;;;;;;AAmBA,MAAa,WAAW,OAA0B,EAChD,MACA,SAII;CACJ,MAAM,MAAM,MAAM,aAAgB;EAAE;EAAM,KAAI,MAAK,EAAE;CAAI,CAAC;CAC1D,OAAO,GAAG,CAAC,CAAC,YAAY;CACxB,OAAO,GAAG,CAAC,CAAC,WAAW,UAAU;AACnC"}
@@ -14,7 +14,7 @@ let child_process = require("child_process");
14
14
  const normalizePath = (path$1) => path$1.replace(/\\/g, "/");
15
15
  /**
16
16
  * Vite plugin providing Hot Module Reloading (HMR) capabilities for external
17
- * file paths by watching files and executing build scripts on changes.
17
+ * file paths by watching files and executing mapped build scripts on changes.
18
18
  *
19
19
  * @param props - Configuration properties of type {@linkcode HmrPluginProps}.
20
20
  *
@@ -23,32 +23,38 @@ const normalizePath = (path$1) => path$1.replace(/\\/g, "/");
23
23
  const hmr = (props) => {
24
24
  let isBuilding = false;
25
25
  const debounce = require_utils_clamp.clamp(props?.debounce ?? 500, 500, 1e4);
26
- const paths = [];
26
+ const pathMap = /* @__PURE__ */ new Map();
27
27
  let isDev = false;
28
28
  return {
29
29
  name: "hmr-add-on",
30
30
  configResolved(config) {
31
31
  isDev = !config.isProduction;
32
32
  if (!isDev) return;
33
- const resolvedPaths = require_utils_array.toArray(props?.paths).map((p) => (0, path.isAbsolute)(p) ? p : (0, path.resolve)(config.root, p)).map(normalizePath);
34
- paths.push(...resolvedPaths);
33
+ pathMap.clear();
34
+ const rawPaths = props?.paths ?? {};
35
+ Object.entries(rawPaths).forEach(([pathKey, rawScripts]) => {
36
+ const resolved = (0, path.isAbsolute)(pathKey) ? pathKey : (0, path.resolve)(config.root, pathKey);
37
+ const normalized = normalizePath(resolved);
38
+ const scripts = require_utils_array.toArray(rawScripts);
39
+ pathMap.set(normalized, scripts);
40
+ });
35
41
  },
36
42
  configureServer(server) {
37
43
  if (!isDev) return;
38
- server.watcher.add(paths);
44
+ server.watcher.add(Array.from(pathMap.keys()));
39
45
  },
40
46
  handleHotUpdate(ctx) {
41
47
  if (!isDev) return;
42
48
  if (isBuilding) return ctx.modules;
43
49
  const normalizedFile = normalizePath(ctx.file);
44
- if (paths.some((p) => normalizedFile.includes(p))) {
50
+ const matchingScripts = /* @__PURE__ */ new Set();
51
+ for (const [watchedPath, scripts] of pathMap.entries()) if (normalizedFile.includes(watchedPath)) scripts.forEach((d) => matchingScripts.add(d));
52
+ if (matchingScripts.size > 0) {
45
53
  console.log(`\n⚡ External file modified: ${ctx.file}. Starting build...`);
46
54
  try {
47
55
  isBuilding = true;
48
- require_utils_array.toArray(props?.scripts).forEach((script) => {
49
- (0, child_process.execSync)(script, { stdio: "inherit" });
50
- });
51
56
  ctx.server.moduleGraph.invalidateAll();
57
+ matchingScripts.forEach((script) => (0, child_process.execSync)(script, { stdio: "inherit" }));
52
58
  ctx.server.ws.send({ type: "full-reload" });
53
59
  } catch (error) {
54
60
  console.error("❌ Command execution failed during HMR:", error);
@@ -1 +1 @@
1
- {"version":3,"file":"hmr.cjs","names":["path","clamp","toArray","isAbsolute","resolve"],"sources":["../../src/plugins/hmr.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport { resolve, isAbsolute } from 'path';\n\nimport { type Plugin } from 'vitest/config';\n\nimport { toArray } from '#utils/array';\nimport { clamp } from '#utils/clamp';\nimport type { SoA } from '#utils/types';\n\n/**\n * Configuration options for the HMR add-on plugin.\n */\nexport type HmrPluginProps = {\n /** Single file path or array of file paths of type {@linkcode SoA} to watch for changes. */\n paths?: SoA<string>;\n\n /** Single shell command or array of shell commands of type {@linkcode SoA} to execute when a change is detected. */\n scripts?: SoA<string>;\n\n /** Optional interval in milliseconds to wait before allowing another build. */\n debounce?: number;\n};\n\n/**\n * Normalizes backslashes in a file path to forward slashes.\n *\n * @param path - File path to normalize.\n *\n * @returns Normalized path string.\n */\nconst normalizePath = (path: string) => path.replace(/\\\\/g, '/');\n\n/**\n * Vite plugin providing Hot Module Reloading (HMR) capabilities for external\n * file paths by watching files and executing build scripts on changes.\n *\n * @param props - Configuration properties of type {@linkcode HmrPluginProps}.\n *\n * @returns A Vite plugin object of type {@linkcode Plugin}.\n */\nexport const hmr = (props?: HmrPluginProps): Plugin => {\n // Lock variable to prevent infinite build loops\n let isBuilding = false;\n const debounce = clamp(props?.debounce ?? 500, 500, 10_000);\n const paths: string[] = [];\n let isDev = false;\n\n return {\n name: 'hmr-add-on',\n\n configResolved(config) {\n isDev = !config.isProduction;\n if (!isDev) return;\n\n // Resolve relative paths based on Vite project root\n const resolvedPaths = toArray(props?.paths)\n .map(p => (isAbsolute(p) ? p : resolve(config.root, p)))\n .map(normalizePath);\n\n paths.push(...resolvedPaths);\n },\n\n configureServer(server) {\n if (!isDev) return;\n\n server.watcher.add(paths);\n },\n\n handleHotUpdate(ctx) {\n if (!isDev) return;\n\n // 1. If a build is already in progress, ignore ALL changes (prevents loops)\n if (isBuilding) return ctx.modules;\n const normalizedFile = normalizePath(ctx.file);\n const checks = paths.some(p => normalizedFile.includes(p));\n\n if (checks) {\n console.log(\n `\\n⚡ External file modified: ${ctx.file}. Starting build...`,\n );\n\n try {\n // 2. Acquire lock before starting the build\n isBuilding = true;\n const scripts = toArray(props?.scripts);\n\n scripts.forEach(script => {\n execSync(script, { stdio: 'inherit' });\n });\n\n // Invalidate module graph so Vite reads fresh built files from disk\n ctx.server.moduleGraph.invalidateAll();\n ctx.server.ws.send({ type: 'full-reload' });\n } catch (error) {\n console.error('❌ Command execution failed during HMR:', error);\n } finally {\n // 3. Once build is complete, wait for the debounce period to allow\n // Vite to ignore generated build files, then release the lock.\n setTimeout(() => {\n isBuilding = false;\n console.log(\n '✅ Build completed. Ready for subsequent changes.',\n );\n }, debounce);\n }\n }\n\n return ctx.modules;\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;AA8BA,MAAM,iBAAiB,WAAiBA,OAAK,QAAQ,OAAO,GAAG;;;;;;;;;AAU/D,MAAa,OAAO,UAAmC;CAErD,IAAI,aAAa;CACjB,MAAM,WAAWC,oBAAAA,MAAM,OAAO,YAAY,KAAK,KAAK,GAAM;CAC1D,MAAM,QAAkB,CAAC;CACzB,IAAI,QAAQ;CAEZ,OAAO;EACL,MAAM;EAEN,eAAe,QAAQ;GACrB,QAAQ,CAAC,OAAO;GAChB,IAAI,CAAC,OAAO;GAGZ,MAAM,gBAAgBC,oBAAAA,QAAQ,OAAO,KAAK,CAAC,CACxC,KAAI,OAAA,GAAMC,KAAAA,WAAAA,CAAW,CAAC,IAAI,KAAA,GAAIC,KAAAA,QAAAA,CAAQ,OAAO,MAAM,CAAC,CAAE,CAAC,CACvD,IAAI,aAAa;GAEpB,MAAM,KAAK,GAAG,aAAa;EAC7B;EAEA,gBAAgB,QAAQ;GACtB,IAAI,CAAC,OAAO;GAEZ,OAAO,QAAQ,IAAI,KAAK;EAC1B;EAEA,gBAAgB,KAAK;GACnB,IAAI,CAAC,OAAO;GAGZ,IAAI,YAAY,OAAO,IAAI;GAC3B,MAAM,iBAAiB,cAAc,IAAI,IAAI;GAG7C,IAFe,MAAM,MAAK,MAAK,eAAe,SAAS,CAAC,CAE/C,GAAG;IACV,QAAQ,IACN,+BAA+B,IAAI,KAAK,oBAC1C;IAEA,IAAI;KAEF,aAAa;KAGb,oBAFgBF,QAAQ,OAAO,OAEzB,CAAC,CAAC,SAAQ,WAAU;MACxB,CAAA,GAAA,cAAA,SAAA,CAAS,QAAQ,EAAE,OAAO,UAAU,CAAC;KACvC,CAAC;KAGD,IAAI,OAAO,YAAY,cAAc;KACrC,IAAI,OAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5C,SAAS,OAAO;KACd,QAAQ,MAAM,0CAA0C,KAAK;IAC/D,UAAU;KAGR,iBAAiB;MACf,aAAa;MACb,QAAQ,IACN,kDACF;KACF,GAAG,QAAQ;IACb;GACF;GAEA,OAAO,IAAI;EACb;CACF;AACF"}
1
+ {"version":3,"file":"hmr.cjs","names":["path","clamp","isAbsolute","resolve","toArray","execSync"],"sources":["../../src/plugins/hmr.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport { isAbsolute, resolve } from 'path';\n\nimport { type Plugin } from 'vitest/config';\n\nimport { toArray } from '#utils/array';\nimport { clamp } from '#utils/clamp';\nimport type { SoA } from '#utils/types';\n\n/**\n * Configuration options for the HMR add-on plugin.\n */\nexport type HmrPluginProps = {\n /**\n * Map of watched file/directory paths to one or many shell commands to execute\n * when changes are detected.\n * Map of watched file or directory paths to one or many shell commands of\n * type {@linkcode SoA} to execute when changes are detected.\n */\n paths?: Record<string, SoA<string>>;\n\n /** Optional interval in milliseconds to wait before allowing another build. */\n debounce?: number;\n};\n\n/**\n * Normalizes backslashes in a file path to forward slashes.\n *\n * @param path - File path to normalize.\n *\n * @returns Normalized path string.\n */\nconst normalizePath = (path: string) => path.replace(/\\\\/g, '/');\n\n/**\n * Vite plugin providing Hot Module Reloading (HMR) capabilities for external\n * file paths by watching files and executing mapped build scripts on changes.\n *\n * @param props - Configuration properties of type {@linkcode HmrPluginProps}.\n *\n * @returns A Vite plugin object of type {@linkcode Plugin}.\n */\nexport const hmr = (props?: HmrPluginProps): Plugin => {\n // Lock variable to prevent infinite build loops\n let isBuilding = false;\n const debounce = clamp(props?.debounce ?? 500, 500, 10_000);\n const pathMap = new Map<string, string[]>();\n let isDev = false;\n\n return {\n name: 'hmr-add-on',\n\n configResolved(config) {\n isDev = !config.isProduction;\n if (!isDev) return;\n\n pathMap.clear();\n const rawPaths = props?.paths ?? {};\n\n Object.entries(rawPaths).forEach(([pathKey, rawScripts]) => {\n const resolved = isAbsolute(pathKey)\n ? pathKey\n : resolve(config.root, pathKey);\n\n const normalized = normalizePath(resolved);\n const scripts = toArray(rawScripts);\n pathMap.set(normalized, scripts);\n });\n },\n\n configureServer(server) {\n if (!isDev) return;\n\n server.watcher.add(Array.from(pathMap.keys()));\n },\n\n handleHotUpdate(ctx) {\n if (!isDev) return;\n\n // 1. If a build is already in progress, ignore ALL changes (prevents loops)\n if (isBuilding) return ctx.modules;\n const normalizedFile = normalizePath(ctx.file);\n\n // Find all matching path entries for the changed file\n const matchingScripts = new Set<string>();\n for (const [watchedPath, scripts] of pathMap.entries()) {\n if (normalizedFile.includes(watchedPath)) {\n scripts.forEach(d => matchingScripts.add(d));\n }\n }\n\n if (matchingScripts.size > 0) {\n console.log(`\\n⚡ External file modified: ${ctx.file}. Starting build...`);\n\n try {\n // 2. Acquire lock before starting the build\n isBuilding = true;\n\n // Invalidate module graph so Vite reads fresh built files from disk\n ctx.server.moduleGraph.invalidateAll();\n matchingScripts.forEach(script => execSync(script, { stdio: 'inherit' }));\n ctx.server.ws.send({ type: 'full-reload' });\n } catch (error) {\n console.error('❌ Command execution failed during HMR:', error);\n } finally {\n // 3. Once build is complete, wait for the debounce period to allow\n // Vite to ignore generated build files, then release the lock.\n setTimeout(() => {\n isBuilding = false;\n console.log('✅ Build completed. Ready for subsequent changes.');\n }, debounce);\n }\n }\n\n return ctx.modules;\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAgCA,MAAM,iBAAiB,WAAiBA,OAAK,QAAQ,OAAO,GAAG;;;;;;;;;AAU/D,MAAa,OAAO,UAAmC;CAErD,IAAI,aAAa;CACjB,MAAM,WAAWC,oBAAAA,MAAM,OAAO,YAAY,KAAK,KAAK,GAAM;CAC1D,MAAM,0BAAU,IAAI,IAAsB;CAC1C,IAAI,QAAQ;CAEZ,OAAO;EACL,MAAM;EAEN,eAAe,QAAQ;GACrB,QAAQ,CAAC,OAAO;GAChB,IAAI,CAAC,OAAO;GAEZ,QAAQ,MAAM;GACd,MAAM,WAAW,OAAO,SAAS,CAAC;GAElC,OAAO,QAAQ,QAAQ,CAAC,CAAC,SAAS,CAAC,SAAS,gBAAgB;IAC1D,MAAM,YAAA,GAAWC,KAAAA,WAAAA,CAAW,OAAO,IAC/B,WAAA,GACAC,KAAAA,QAAAA,CAAQ,OAAO,MAAM,OAAO;IAEhC,MAAM,aAAa,cAAc,QAAQ;IACzC,MAAM,UAAUC,oBAAAA,QAAQ,UAAU;IAClC,QAAQ,IAAI,YAAY,OAAO;GACjC,CAAC;EACH;EAEA,gBAAgB,QAAQ;GACtB,IAAI,CAAC,OAAO;GAEZ,OAAO,QAAQ,IAAI,MAAM,KAAK,QAAQ,KAAK,CAAC,CAAC;EAC/C;EAEA,gBAAgB,KAAK;GACnB,IAAI,CAAC,OAAO;GAGZ,IAAI,YAAY,OAAO,IAAI;GAC3B,MAAM,iBAAiB,cAAc,IAAI,IAAI;GAG7C,MAAM,kCAAkB,IAAI,IAAY;GACxC,KAAK,MAAM,CAAC,aAAa,YAAY,QAAQ,QAAQ,GACnD,IAAI,eAAe,SAAS,WAAW,GACrC,QAAQ,SAAQ,MAAK,gBAAgB,IAAI,CAAC,CAAC;GAI/C,IAAI,gBAAgB,OAAO,GAAG;IAC5B,QAAQ,IAAI,+BAA+B,IAAI,KAAK,oBAAoB;IAExE,IAAI;KAEF,aAAa;KAGb,IAAI,OAAO,YAAY,cAAc;KACrC,gBAAgB,SAAQ,YAAA,GAAUC,cAAAA,SAAAA,CAAS,QAAQ,EAAE,OAAO,UAAU,CAAC,CAAC;KACxE,IAAI,OAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5C,SAAS,OAAO;KACd,QAAQ,MAAM,0CAA0C,KAAK;IAC/D,UAAU;KAGR,iBAAiB;MACf,aAAa;MACb,QAAQ,IAAI,kDAAkD;KAChE,GAAG,QAAQ;IACb;GACF;GAEA,OAAO,IAAI;EACb;CACF;AACF"}
@@ -4,16 +4,19 @@ import type { SoA } from '../utils/types';
4
4
  * Configuration options for the HMR add-on plugin.
5
5
  */
6
6
  export type HmrPluginProps = {
7
- /** Single file path or array of file paths of type {@linkcode SoA} to watch for changes. */
8
- paths?: SoA<string>;
9
- /** Single shell command or array of shell commands of type {@linkcode SoA} to execute when a change is detected. */
10
- scripts?: SoA<string>;
7
+ /**
8
+ * Map of watched file/directory paths to one or many shell commands to execute
9
+ * when changes are detected.
10
+ * Map of watched file or directory paths to one or many shell commands of
11
+ * type {@linkcode SoA} to execute when changes are detected.
12
+ */
13
+ paths?: Record<string, SoA<string>>;
11
14
  /** Optional interval in milliseconds to wait before allowing another build. */
12
15
  debounce?: number;
13
16
  };
14
17
  /**
15
18
  * Vite plugin providing Hot Module Reloading (HMR) capabilities for external
16
- * file paths by watching files and executing build scripts on changes.
19
+ * file paths by watching files and executing mapped build scripts on changes.
17
20
  *
18
21
  * @param props - Configuration properties of type {@linkcode HmrPluginProps}.
19
22
  *