poku 2.7.1 โ†’ 3.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +17 -15
  2. package/lib/@types/background-process.d.ts +1 -7
  3. package/lib/@types/poku.d.ts +2 -8
  4. package/lib/bin/help.js +9 -19
  5. package/lib/bin/index.js +75 -98
  6. package/lib/bin/watch.js +11 -10
  7. package/lib/builders/assert.js +1 -8
  8. package/lib/configs/files.js +2 -2
  9. package/lib/configs/poku.d.ts +11 -0
  10. package/lib/configs/poku.js +13 -2
  11. package/lib/modules/essentials/poku.js +10 -35
  12. package/lib/modules/helpers/create-service.js +19 -20
  13. package/lib/modules/helpers/describe.js +17 -9
  14. package/lib/modules/helpers/each.js +1 -1
  15. package/lib/modules/helpers/env.js +2 -2
  16. package/lib/modules/helpers/exit.js +8 -8
  17. package/lib/modules/helpers/it/core.js +11 -8
  18. package/lib/modules/helpers/list-files.js +29 -20
  19. package/lib/modules/helpers/log.js +1 -1
  20. package/lib/modules/helpers/modifiers.js +12 -7
  21. package/lib/modules/helpers/skip.js +3 -3
  22. package/lib/modules/helpers/wait-for.js +6 -6
  23. package/lib/parsers/assert.js +2 -3
  24. package/lib/parsers/callback.d.ts +2 -0
  25. package/lib/parsers/callback.js +21 -0
  26. package/lib/parsers/find-file-from-stack.js +3 -4
  27. package/lib/parsers/get-arg.d.ts +0 -2
  28. package/lib/parsers/get-arg.js +10 -19
  29. package/lib/parsers/get-runner.d.ts +1 -2
  30. package/lib/parsers/get-runner.js +9 -16
  31. package/lib/parsers/get-runtime.d.ts +2 -4
  32. package/lib/parsers/get-runtime.js +5 -10
  33. package/lib/parsers/options.js +12 -8
  34. package/lib/parsers/output.d.ts +0 -4
  35. package/lib/parsers/output.js +5 -10
  36. package/lib/polyfills/deno.mjs +5 -7
  37. package/lib/polyfills/os.js +3 -6
  38. package/lib/services/assert.js +15 -18
  39. package/lib/services/container.js +5 -5
  40. package/lib/services/each.d.ts +2 -3
  41. package/lib/services/each.js +17 -17
  42. package/lib/services/enforce.d.ts +1 -0
  43. package/lib/services/enforce.js +131 -0
  44. package/lib/services/env.js +1 -2
  45. package/lib/services/format.js +3 -3
  46. package/lib/services/map-tests.js +5 -6
  47. package/lib/services/run-test-file.d.ts +1 -2
  48. package/lib/services/run-test-file.js +12 -20
  49. package/lib/services/run-tests.d.ts +1 -3
  50. package/lib/services/run-tests.js +52 -94
  51. package/lib/services/watch.js +5 -5
  52. package/lib/services/write.d.ts +2 -4
  53. package/lib/services/write.js +7 -7
  54. package/package.json +18 -23
  55. package/lib/bin/enforce.js +0 -53
  56. package/lib/parsers/to-dynamic-case.d.ts +0 -1
  57. package/lib/parsers/to-dynamic-case.js +0 -13
  58. package/lib/polyfills/fs.d.ts +0 -4
  59. package/lib/polyfills/fs.js +0 -8
  60. package/lib/polyfills/object.d.ts +0 -12
  61. package/lib/polyfills/object.js +0 -24
package/README.md CHANGED
@@ -5,8 +5,8 @@
5
5
 
6
6
  Enjoying **Poku**? Give him a star to show your support ๐ŸŒŸ
7
7
 
8
- [![NPM Downloads](https://img.shields.io/npm/v/poku.svg?label=&color=70a1ff&logo=npm&logoColor=white)](https://www.npmjs.com/package/poku)
9
- [![NPM Downloads](https://img.shields.io/npm/dm/poku.svg?label=&logo=npm&logoColor=white&color=45aaf2)](https://www.npmjs.com/package/poku)
8
+ [![NPM Version](https://img.shields.io/npm/v/poku/rc.svg?label=&color=70a1ff&logo=npm&logoColor=white)](https://www.npmjs.com/package/poku/v/3.0.0-rc.0)
9
+ [![NPM Downloads](https://img.shields.io/npm/dm/poku.svg?label=&logo=npm&logoColor=white&color=45aaf2)](https://www.npmjs.com/package/poku/v/3.0.0-rc.0)
10
10
  [![Coverage](https://img.shields.io/codecov/c/github/wellwelwel/poku?label=&logo=codecov&logoColor=white&color=98cc00)](https://github.com/wellwelwel/poku/tree/main/.nycrc)<br />
11
11
  [![GitHub Workflow Status (Linux)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-linux.yml?event=push&label=&branch=main&logo=ubuntu&logoColor=8897a9&color=dfe4ea)](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-linux.yml?query=branch%3Amain)
12
12
  [![GitHub Workflow Status (OSX)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-osx.yml?event=push&label=&branch=main&logo=apple&logoColor=8897a9&color=dfe4ea)](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-osx.yml?query=branch%3Amain)
@@ -14,10 +14,17 @@ Enjoying **Poku**? Give him a star to show your support ๐ŸŒŸ
14
14
 
15
15
  ---
16
16
 
17
- ๐Ÿท [Website](https://poku.io/)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿ“˜ [Documentation](https://poku.io/docs/category/documentation)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿงช [Examples](https://poku.io/docs/category/examples)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿง‘๐Ÿปโ€๐ŸŽ“ [Tutorials](https://poku.io/docs/category/quick-tutorials)
17
+ ๐Ÿท [Website](https://poku.io/)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿ“˜ [Documentation](https://poku.io/docs)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿงช [Examples](https://poku.io/docs/category/examples)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿง‘๐Ÿปโ€๐ŸŽ“ [Tutorials](https://poku.io/docs/category/quick-tutorials)
18
18
 
19
19
  </div>
20
20
 
21
+ > [!IMPORTANT]
22
+ >
23
+ > **Poku** is growing and <strong>version 3</strong> is on its way! You can already try it by installing the Release Candidate with `poku@rc`.
24
+ >
25
+ > - To check out what's coming, follow the [**Issue #801**](https://github.com/wellwelwel/poku/issues/801).
26
+ > - For `v2` documentation, see the [**legacy version documentation**](https://poku.io/docs/2.x.x) and [**README**](https://github.com/wellwelwel/poku/tree/2.x.x?tab=readme-ov-file#readme).<br />
27
+
21
28
  ---
22
29
 
23
30
  ## Why does Poku exist?
@@ -26,7 +33,6 @@ Enjoying **Poku**? Give him a star to show your support ๐ŸŒŸ
26
33
 
27
34
  </span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> High **isolation** level per file<br />
28
35
  </span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> **Performant** and **lightweight**<br />
29
- <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Run **CommonJS** files directly with [**Deno**][deno-version-url]<br />
30
36
  <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Auto detect **ESM**, **CJS**, and **TypeScript** files<br />
31
37
  <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Run the **same test suite** for [**Node.js**][node-version-url], [**Bun**][bun-version-url], and [**Deno**][deno-version-url]<br />
32
38
  <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Easily handle **servers**, **processes**, **ports**, and even **containers** โœจ
@@ -43,7 +49,7 @@ Enjoying **Poku**? Give him a star to show your support ๐ŸŒŸ
43
49
 
44
50
  ```bash
45
51
  # Node.js
46
- npm i -D poku
52
+ npm i -D poku@rc
47
53
  ```
48
54
 
49
55
  </td>
@@ -51,7 +57,7 @@ npm i -D poku
51
57
 
52
58
  ```bash
53
59
  # TypeScript (Node.js)
54
- npm i -D poku tsx
60
+ npm i -D poku@rc tsx
55
61
  ```
56
62
 
57
63
  </td>
@@ -59,7 +65,7 @@ npm i -D poku tsx
59
65
 
60
66
  ```bash
61
67
  # Bun
62
- bun add -d poku
68
+ bun add -d poku@rc
63
69
  ```
64
70
 
65
71
  </td>
@@ -67,7 +73,7 @@ bun add -d poku
67
73
 
68
74
  ```bash
69
75
  # Deno (optional)
70
- deno add npm:poku
76
+ deno add npm:poku@rc
71
77
  ```
72
78
 
73
79
  </td>
@@ -118,14 +124,14 @@ npx poku
118
124
  <td width="400">
119
125
 
120
126
  ```bash
121
- bunx poku
127
+ bun poku
122
128
  ```
123
129
 
124
130
  </td>
125
131
  <td width="400">
126
132
 
127
133
  ```bash
128
- deno run npm:poku
134
+ deno run npm:poku@rc
129
135
  ```
130
136
 
131
137
  </td>
@@ -213,10 +219,6 @@ deno run npm:poku
213
219
  <td width="280"><a href="https://poku.io/docs/documentation/poku/options/watch">watch</a></td>
214
220
  <td width="770">๐Ÿฟ Watch for changes and re-run related test files.</td>
215
221
  </tr>
216
- <tr>
217
- <td><a href="https://poku.io/docs/documentation/poku/options/parallel">parallel</a></td>
218
- <td>๐Ÿƒ๐Ÿปโ€โ™€๏ธ Run tests in parallel.</td>
219
- </tr>
220
222
  <tr>
221
223
  <td><a href="https://poku.io/docs/documentation/poku/options/debug">debug</a></td>
222
224
  <td>๐Ÿ•ต๐Ÿป Shows all logs.</td>
@@ -248,7 +250,7 @@ To see the detailed documentation, please visit the [**Documentation**](https://
248
250
  - [Avoiding conflicts in environments with multiple platforms installed](https://poku.io/docs/tutorials/cross-platform#recommendations).
249
251
  - [Properly running asynchronous tests on the same file](https://poku.io/docs/examples/promises).
250
252
  - [Using **Poku** without installing on **Deno** and alternatives to **JSR**](https://github.com/wellwelwel/poku/discussions/565).
251
- - [Migrating from version **1.x** to version **2.x**](https://github.com/wellwelwel/poku/issues/533).
253
+ - [Migrating from version **2.x** to version **3.x** (_rc_)](https://github.com/wellwelwel/poku/issues/801).
252
254
 
253
255
  ---
254
256
 
@@ -1,5 +1,4 @@
1
1
  import type { Runner } from './runner.js';
2
- import type { Configs } from './poku.js';
3
2
  type BackgroundProcessOptions = {
4
3
  /**
5
4
  * - By default, it will resolve in the first console output
@@ -37,11 +36,6 @@ export type StartScriptOptions = {
37
36
  */
38
37
  readonly runner?: Runner;
39
38
  } & BackgroundProcessOptions;
40
- export type StartServiceOptions = {
41
- /**
42
- * By default, Poku will try to identify the actual platform, but you can specify it manually
43
- */
44
- readonly platform?: Configs['platform'];
45
- } & BackgroundProcessOptions;
39
+ export type StartServiceOptions = BackgroundProcessOptions;
46
40
  export type End = (port?: number | number[]) => Promise<void>;
47
41
  export {};
@@ -31,13 +31,7 @@ export type Configs = {
31
31
  *
32
32
  * @default false
33
33
  */
34
- parallel?: boolean;
35
- /**
36
- * Determines the platform for test execution.
37
- *
38
- * @default 'node'
39
- */
40
- platform?: Runtime;
34
+ sequential?: boolean;
41
35
  /**
42
36
  * Stops the tests at the first failure.
43
37
  *
@@ -47,7 +41,7 @@ export type Configs = {
47
41
  /**
48
42
  * Limits the number of tests running concurrently.
49
43
  *
50
- * @default 0
44
+ * @default (availableParallelism() || cpus().lenght) - 1
51
45
  */
52
46
  concurrency?: number;
53
47
  /**
package/lib/bin/help.js CHANGED
@@ -11,11 +11,9 @@ const options = i('[--options]');
11
11
  const paths = i('[paths]');
12
12
  const bullet = d('โ—');
13
13
  const summary = [
14
- ['--bun', 'Enforce tests to run through Bun.'],
15
14
  ['--concurrency', 'Limit the number of tests running concurrently.'],
16
15
  ['--config, -c', 'Specify a configuration file.'],
17
16
  ['--debug, -d', 'Show detailed logs.'],
18
- ['--deno', 'Enforce tests to run through Deno.'],
19
17
  ['--denoAllow', 'Allow permissions for Deno.'],
20
18
  ['--denoCjs', 'Support CommonJS in Deno.'],
21
19
  ['--denoDeny', 'Deny permissions for Deno.'],
@@ -29,17 +27,15 @@ const summary = [
29
27
  ['--killPort', 'Terminate the specified ports.'],
30
28
  ['--killRange', 'Terminate the specified port ranges.'],
31
29
  ['--listFiles', 'Display all the files returned in the terminal.'],
32
- ['--node', 'Enforce tests to run through Node.js.'],
33
30
  ['--only', 'Enable selective execution of tests.'],
34
- ['--parallel, -p', 'Run tests files in parallel.'],
35
- ['--platform', 'Enforce tests to run through a platform.'],
36
31
  ['--quiet, -q', 'Run tests with no logs.'],
32
+ ['--sequential', 'Run tests files sequentially.'],
37
33
  ['--version, -v', "Show Poku's installed version."],
38
34
  ['--watch, -w', 'Watch for test events.'],
39
35
  ['--watchInterval', 'Set an interval for watch events.'],
40
36
  ];
41
37
  const sortedSummary = summary.sort(([a], [b]) => a.localeCompare(b));
42
- const largeEndPad = (() => Math.max(...summary.map(([start]) => start.length)))();
38
+ const largeEndPad = Math.max(...summary.map(([start]) => start.length));
43
39
  const header = `
44
40
  ๐Ÿท ${(0, format_js_1.format)(' Poku โ€” CLI Usage ').bg('brightMagenta')}
45
41
 
@@ -48,12 +44,6 @@ const header = `
48
44
  poku ${options} ${paths}
49
45
  poku ${paths} ${options}
50
46
 
51
- โ€บ ${u(b('Ensuring platforms:'))}
52
-
53
- poku ${b('--node')} ${options} ${paths}
54
- poku ${b('--bun')} ${options} ${paths}
55
- poku ${b('--deno')} ${options} ${paths}
56
-
57
47
  โ€บ ${u(b('Tips:'))}
58
48
 
59
49
  ${bullet} All CLI options use camel case pattern (e.g.: ${b('--failFast')}).
@@ -84,12 +74,12 @@ ${bullet} ${b('Poku')} is made with ${b('love')} and ${b('care')} in every detai
84
74
  ${bullet} Give him a ${b('star')} to show your support ๐ŸŒŸ
85
75
  `;
86
76
  const help = () => {
87
- write_js_1.Write.hr();
88
- write_js_1.Write.log(header.trim());
89
- write_js_1.Write.hr();
90
- write_js_1.Write.log(main.trim());
91
- write_js_1.Write.hr();
92
- write_js_1.Write.log(footer.trim());
93
- write_js_1.Write.hr();
77
+ (0, write_js_1.hr)();
78
+ (0, write_js_1.log)(header.trim());
79
+ (0, write_js_1.hr)();
80
+ (0, write_js_1.log)(main.trim());
81
+ (0, write_js_1.hr)();
82
+ (0, write_js_1.log)(footer.trim());
83
+ (0, write_js_1.hr)();
94
84
  };
95
85
  exports.help = help;
package/lib/bin/index.js CHANGED
@@ -4,69 +4,61 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const list_files_js_1 = require("../modules/helpers/list-files.js");
5
5
  const get_arg_js_1 = require("../parsers/get-arg.js");
6
6
  const files_js_1 = require("../configs/files.js");
7
- const get_runtime_js_1 = require("../parsers/get-runtime.js");
8
7
  const format_js_1 = require("../services/format.js");
9
8
  const kill_js_1 = require("../modules/helpers/kill.js");
10
9
  const env_js_1 = require("../modules/helpers/env.js");
11
10
  const poku_js_1 = require("../modules/essentials/poku.js");
12
11
  const write_js_1 = require("../services/write.js");
13
12
  const options_js_1 = require("../parsers/options.js");
13
+ const poku_js_2 = require("../configs/poku.js");
14
14
  (async () => {
15
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
16
15
  if ((0, get_arg_js_1.hasArg)('version') || (0, get_arg_js_1.hasArg)('v', '-')) {
17
- const { VERSION } = require('../configs/poku.js');
18
- write_js_1.Write.log(VERSION);
16
+ (0, write_js_1.log)(poku_js_2.VERSION);
19
17
  return;
20
18
  }
21
19
  if ((0, get_arg_js_1.hasArg)('help') || (0, get_arg_js_1.hasArg)('h', '-')) {
22
- const { help } = require('./help.js');
23
- help();
20
+ require('./help.js').help();
24
21
  return;
25
22
  }
26
23
  const enforce = (0, get_arg_js_1.hasArg)('enforce') || (0, get_arg_js_1.hasArg)('x', '-');
27
24
  const configFile = (0, get_arg_js_1.getArg)('config') || (0, get_arg_js_1.getArg)('c', '-');
28
- const defaultConfigs = await (0, options_js_1.getConfigs)(configFile);
29
- const dirs = (() => {
30
- var _a;
31
-
32
- const includeArg = (0, get_arg_js_1.getArg)('include');
33
- if (includeArg !== undefined)
34
- return includeArg.split(',');
35
- return ((_a = (0, get_arg_js_1.getPaths)('-')) !== null && _a !== void 0 ? _a : ((defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.include)
36
- ? Array.prototype.concat(defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.include)
37
- : ['.']));
38
- })();
39
- const platform = (0, get_arg_js_1.getArg)('platform');
40
- const filter = (_a = (0, get_arg_js_1.getArg)('filter')) !== null && _a !== void 0 ? _a : defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.filter;
41
- const exclude = (_b = (0, get_arg_js_1.getArg)('exclude')) !== null && _b !== void 0 ? _b : defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.exclude;
42
- const killPort = (0, get_arg_js_1.getArg)('killport');
43
- const killRange = (0, get_arg_js_1.getArg)('killrange');
44
- const killPID = (0, get_arg_js_1.getArg)('killpid');
25
+ poku_js_2.GLOBAL.configsFromFile = await (0, options_js_1.getConfigs)(configFile);
26
+ const { configsFromFile } = poku_js_2.GLOBAL;
27
+ const dirs = (0, get_arg_js_1.getPaths)('-') ??
28
+ (configsFromFile?.include
29
+ ? Array.prototype.concat(configsFromFile?.include)
30
+ : ['.']);
31
+ const filter = (0, get_arg_js_1.getArg)('filter') ?? configsFromFile?.filter;
32
+ const exclude = (0, get_arg_js_1.getArg)('exclude') ?? configsFromFile?.exclude;
33
+ const killPort = (0, get_arg_js_1.getArg)('killPort');
34
+ const killRange = (0, get_arg_js_1.getArg)('killRange');
35
+ const killPID = (0, get_arg_js_1.getArg)('killPid');
45
36
 
46
- const denoAllow = (_c = (0, get_arg_js_1.argToArray)('denoallow')) !== null && _c !== void 0 ? _c : (_d = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _d === void 0 ? void 0 : _d.allow;
47
- const denoDeny = (_e = (0, get_arg_js_1.argToArray)('denodeny')) !== null && _e !== void 0 ? _e : (_f = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _f === void 0 ? void 0 : _f.deny;
48
- const denoCJS = ((_g = (0, get_arg_js_1.getArg)('denocjs')) === null || _g === void 0 ? void 0 : _g.split(',').map((a) => a.trim()).filter((a) => a)) ||
49
- (0, get_arg_js_1.hasArg)('denocjs') ||
50
- ((_h = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _h === void 0 ? void 0 : _h.cjs);
37
+ const denoAllow = (0, get_arg_js_1.argToArray)('denoAllow') ?? configsFromFile?.deno?.allow;
38
+ const denoDeny = (0, get_arg_js_1.argToArray)('denoDeny') ?? configsFromFile?.deno?.deny;
39
+ const denoCJS = (0, get_arg_js_1.getArg)('denoCjs')
40
+ ?.split(',')
41
+ .map((a) => a.trim())
42
+ .filter((a) => a) ||
43
+ (0, get_arg_js_1.hasArg)('denoCjs') ||
44
+ configsFromFile?.deno?.cjs;
51
45
 
52
- const parallel = (0, get_arg_js_1.hasArg)('parallel') || (0, get_arg_js_1.hasArg)('p', '-') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel);
53
- const quiet = (0, get_arg_js_1.hasArg)('quiet') || (0, get_arg_js_1.hasArg)('q', '-') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.quiet);
54
- const debug = (0, get_arg_js_1.hasArg)('debug') || (0, get_arg_js_1.hasArg)('d', '-') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.debug);
55
- const failFast = (0, get_arg_js_1.hasArg)('failfast') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.failFast);
46
+ const quiet = (0, get_arg_js_1.hasArg)('quiet') || (0, get_arg_js_1.hasArg)('q', '-') || configsFromFile?.quiet;
47
+ const debug = (0, get_arg_js_1.hasArg)('debug') || (0, get_arg_js_1.hasArg)('d', '-') || configsFromFile?.debug;
48
+ const failFast = (0, get_arg_js_1.hasArg)('failFast') || configsFromFile?.failFast;
56
49
  const watchMode = (0, get_arg_js_1.hasArg)('watch') || (0, get_arg_js_1.hasArg)('w', '-');
57
- const hasEnvFile = (0, get_arg_js_1.hasArg)('envfile');
50
+ const hasEnvFile = (0, get_arg_js_1.hasArg)('envFile');
58
51
  const concurrency = (() => {
59
- if (!(parallel || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel)))
60
- return;
61
52
  const value = Number((0, get_arg_js_1.getArg)('concurrency'));
62
- return Number.isNaN(value) ? defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.concurrency : value;
53
+ return Number.isNaN(value) ? configsFromFile?.concurrency : value;
63
54
  })();
55
+ const sequential = (0, get_arg_js_1.hasArg)('sequential');
64
56
  if (dirs.length === 1)
65
57
  files_js_1.states.isSinglePath = true;
66
- if ((0, get_arg_js_1.hasArg)('listfiles')) {
58
+ if ((0, get_arg_js_1.hasArg)('listFiles')) {
67
59
  const { listFiles } = require('../modules/helpers/list-files.js');
68
60
  const files = [];
69
- write_js_1.Write.hr();
61
+ (0, write_js_1.hr)();
70
62
  for (const dir of dirs)
71
63
  files.push(...(await listFiles(dir, {
72
64
  filter: typeof filter === 'string'
@@ -76,28 +68,47 @@ const options_js_1 = require("../parsers/options.js");
76
68
  ? new RegExp((0, list_files_js_1.escapeRegExp)(exclude))
77
69
  : exclude,
78
70
  })));
79
- write_js_1.Write.log(files
71
+ (0, write_js_1.log)(files
80
72
  .sort()
81
73
  .map((file) => `${(0, format_js_1.format)('-').dim()} ${file}`)
82
74
  .join('\n'));
83
- write_js_1.Write.hr();
84
- write_js_1.Write.log(`Total test files: ${(0, format_js_1.format)(String(files.length)).bold()}`);
85
- write_js_1.Write.hr();
75
+ (0, write_js_1.hr)();
76
+ (0, write_js_1.log)(`Total test files: ${(0, format_js_1.format)(String(files.length)).bold()}`);
77
+ (0, write_js_1.hr)();
86
78
  return;
87
79
  }
88
- if (enforce) {
89
- const { checkFlags } = require('./enforce.js');
90
- checkFlags();
91
- }
80
+ poku_js_2.GLOBAL.configFile = configFile;
81
+ poku_js_2.GLOBAL.configs = {
82
+ filter: typeof filter === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(filter)) : filter,
83
+ exclude: typeof exclude === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(exclude)) : exclude,
84
+ concurrency,
85
+ sequential,
86
+ quiet,
87
+ debug,
88
+ failFast,
89
+ deno: {
90
+ allow: denoAllow,
91
+ deny: denoDeny,
92
+ cjs: denoCJS,
93
+ },
94
+ noExit: watchMode,
95
+ beforeEach: 'beforeEach' in configsFromFile ? configsFromFile.beforeEach : undefined,
96
+ afterEach: 'afterEach' in configsFromFile ? configsFromFile.afterEach : undefined,
97
+ };
92
98
  const tasks = [];
99
+ if (hasEnvFile || configsFromFile?.envFile) {
100
+ poku_js_2.GLOBAL.envFile = (0, get_arg_js_1.getArg)('envFile') ?? configsFromFile?.envFile ?? '.env';
101
+ }
102
+ if (enforce)
103
+ require('../services/enforce.js').enforce();
93
104
 
94
- if (killPort || ((_j = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _j === void 0 ? void 0 : _j.port)) {
95
- const ports = (killPort === null || killPort === void 0 ? void 0 : killPort.split(',').map(Number)) || ((_k = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _k === void 0 ? void 0 : _k.port) || [];
105
+ if (killPort || configsFromFile?.kill?.port) {
106
+ const ports = killPort?.split(',').map(Number) || configsFromFile?.kill?.port || [];
96
107
  tasks.push(kill_js_1.kill.port(ports));
97
108
  }
98
- if (killRange || ((_l = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _l === void 0 ? void 0 : _l.range)) {
99
- const ranges = (killRange === null || killRange === void 0 ? void 0 : killRange.split(',')) ||
100
- ((_o = (_m = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _m === void 0 ? void 0 : _m.range) === null || _o === void 0 ? void 0 : _o.map((range) => `${range[0]}-${range[1]}`)) ||
109
+ if (killRange || configsFromFile?.kill?.range) {
110
+ const ranges = killRange?.split(',') ||
111
+ configsFromFile?.kill?.range?.map((range) => `${range[0]}-${range[1]}`) ||
101
112
  [];
102
113
  for (const range of ranges) {
103
114
  const ports = range.split('-').map(Number);
@@ -106,57 +117,23 @@ const options_js_1 = require("../parsers/options.js");
106
117
  tasks.push(kill_js_1.kill.range(startsAt, endsAt));
107
118
  }
108
119
  }
109
- if (killPID || ((_p = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _p === void 0 ? void 0 : _p.pid)) {
110
- const PIDs = (killPID === null || killPID === void 0 ? void 0 : killPID.split(',').map(Number)) || ((_q = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _q === void 0 ? void 0 : _q.pid) || [];
120
+ if (killPID || configsFromFile?.kill?.pid) {
121
+ const PIDs = killPID?.split(',').map(Number) || configsFromFile?.kill?.pid || [];
111
122
  tasks.push(kill_js_1.kill.pid(PIDs));
112
123
  }
113
124
 
114
- if (hasEnvFile || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.envFile)) {
115
- const envFilePath = (_r = (0, get_arg_js_1.getArg)('envfile')) !== null && _r !== void 0 ? _r : defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.envFile;
116
- tasks.push((0, env_js_1.envFile)(envFilePath));
117
- }
118
- const options = {
119
-
120
- platform: (0, get_runtime_js_1.platformIsValid)(platform)
121
- ? platform
122
- : (0, get_arg_js_1.hasArg)('node')
123
- ? 'node'
124
- : (0, get_arg_js_1.hasArg)('bun')
125
- ? 'bun'
126
- : (0, get_arg_js_1.hasArg)('deno')
127
- ? 'deno'
128
- : (0, get_runtime_js_1.platformIsValid)(defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.platform)
129
- ? defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.platform
130
- : undefined,
131
- filter: typeof filter === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(filter)) : filter,
132
- exclude: typeof exclude === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(exclude)) : exclude,
133
- parallel,
134
- concurrency,
135
- quiet,
136
- debug,
137
- failFast,
138
- deno: {
139
- allow: denoAllow,
140
- deny: denoDeny,
141
- cjs: denoCJS,
142
- },
143
- noExit: watchMode,
144
- beforeEach: 'beforeEach' in defaultConfigs ? defaultConfigs.beforeEach : undefined,
145
- afterEach: 'afterEach' in defaultConfigs ? defaultConfigs.afterEach : undefined,
146
- };
147
- if (debug || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.debug)) {
148
- write_js_1.Write.hr();
149
- write_js_1.Write.log(`${(0, format_js_1.format)(' Debug Enabled ').bg('brightBlue')}\n`);
150
- write_js_1.Write.log(`${(0, format_js_1.format)('โ€ฆ').info().italic()} ${(0, format_js_1.format)('Paths').bold()}`);
125
+ poku_js_2.GLOBAL.envFile && tasks.push((0, env_js_1.envFile)(poku_js_2.GLOBAL.envFile));
126
+ if (debug || configsFromFile?.debug) {
127
+ (0, write_js_1.hr)();
128
+ (0, write_js_1.log)(`${(0, format_js_1.format)(' Debug Enabled ').bg('brightBlue')}\n`);
129
+ (0, write_js_1.log)(`${(0, format_js_1.format)('โ€ฆ').info().italic()} ${(0, format_js_1.format)('Paths').bold()}`);
151
130
  console.table(dirs);
152
- write_js_1.Write.log('\n');
153
- write_js_1.Write.log(`${(0, format_js_1.format)('โ€ฆ').info().italic()} ${(0, format_js_1.format)('Options').bold()}`);
154
- console.dir(options, { depth: null, colors: true });
131
+ (0, write_js_1.log)('\n');
132
+ (0, write_js_1.log)(`${(0, format_js_1.format)('โ€ฆ').info().italic()} ${(0, format_js_1.format)('Options').bold()}`);
133
+ console.dir(poku_js_2.GLOBAL.configs, { depth: null, colors: true });
155
134
  }
156
135
  await Promise.all(tasks);
157
- await (0, poku_js_1.poku)(dirs, options);
158
- if (watchMode) {
159
- const { startWatch } = require('./watch.js');
160
- await startWatch(dirs, options);
161
- }
136
+ await (0, poku_js_1.poku)(dirs);
137
+ if (watchMode)
138
+ await require('./watch.js').startWatch(dirs);
162
139
  })();
package/lib/bin/watch.js CHANGED
@@ -13,11 +13,12 @@ const format_js_1 = require("../services/format.js");
13
13
  const get_arg_js_1 = require("../parsers/get-arg.js");
14
14
  const files_js_1 = require("../configs/files.js");
15
15
  const os_js_1 = require("../polyfills/os.js");
16
- const startWatch = async (dirs, options) => {
16
+ const poku_js_2 = require("../configs/poku.js");
17
+ const startWatch = async (dirs) => {
17
18
  let isRunning = false;
18
19
  const watchers = new Set();
19
20
  const executing = new Set();
20
- const interval = Number((0, get_arg_js_1.getArg)('watchinterval')) || 1500;
21
+ const interval = Number((0, get_arg_js_1.getArg)('watchInterval')) || 1500;
21
22
  const setIsRunning = (value) => {
22
23
  isRunning = value;
23
24
  };
@@ -33,16 +34,15 @@ const startWatch = async (dirs, options) => {
33
34
  watcher.stop();
34
35
  watchers.clear();
35
36
  resultsClear();
36
- await (0, poku_js_1.poku)(dirs, options);
37
+ await (0, poku_js_1.poku)(dirs);
37
38
  }
38
39
  };
39
40
  node_process_1.default.stdin.removeListener('data', listenStdin);
40
41
  node_process_1.default.removeListener('SIGINT', poku_js_1.onSigint);
41
42
  resultsClear();
42
- const mappedTests = await (0, map_tests_js_1.mapTests)('.', dirs, options.filter, options.exclude);
43
+ const mappedTests = await (0, map_tests_js_1.mapTests)('.', dirs, poku_js_2.GLOBAL.configs.filter, poku_js_2.GLOBAL.configs.exclude);
43
44
  for (const mappedTest of Array.from(mappedTests.keys())) {
44
45
  const currentWatcher = (0, watch_js_1.watch)(mappedTest, async (file, event) => {
45
- var _a;
46
46
  if (event === 'change') {
47
47
  const filePath = (0, map_tests_js_1.normalizePath)(file);
48
48
  if (executing.has(filePath) || isRunning || executing.size > 0)
@@ -54,8 +54,9 @@ const startWatch = async (dirs, options) => {
54
54
  if (!tests)
55
55
  return;
56
56
  await (0, poku_js_1.poku)(Array.from(tests), {
57
- ...options,
58
- concurrency: (_a = options.concurrency) !== null && _a !== void 0 ? _a : Math.max(Math.floor((0, os_js_1.availableParallelism)() / 2), 1),
57
+ ...poku_js_2.GLOBAL.configs,
58
+ concurrency: poku_js_2.GLOBAL.configs.concurrency ??
59
+ Math.max(Math.floor((0, os_js_1.availableParallelism)() / 2), 1),
59
60
  });
60
61
  setTimeout(() => {
61
62
  executing.delete(filePath);
@@ -73,7 +74,7 @@ const startWatch = async (dirs, options) => {
73
74
  setIsRunning(true);
74
75
  executing.add(file);
75
76
  resultsClear();
76
- (0, poku_js_1.poku)(file, options).then(() => setTimeout(() => {
77
+ (0, poku_js_1.poku)(file).then(() => setTimeout(() => {
77
78
  executing.delete(file);
78
79
  setIsRunning(false);
79
80
  }, interval));
@@ -81,8 +82,8 @@ const startWatch = async (dirs, options) => {
81
82
  });
82
83
  currentWatcher.then((watcher) => watchers.add(watcher));
83
84
  }
84
- write_js_1.Write.hr();
85
- write_js_1.Write.log(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
85
+ (0, write_js_1.hr)();
86
+ (0, write_js_1.log)(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
86
87
  node_process_1.default.stdin.setEncoding('utf8');
87
88
  node_process_1.default.stdin.on('data', listenStdin);
88
89
  };
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createAssert = void 0;
4
- const get_runtime_js_1 = require("../parsers/get-runtime.js");
5
4
  const assert_js_1 = require("../services/assert.js");
6
5
  const createAssert = (nodeAssert) => {
7
6
  const ok = (value, message) => (0, assert_js_1.processAssert)(() => nodeAssert.ok(value), { message });
@@ -105,10 +104,7 @@ const createAssert = (nodeAssert) => {
105
104
  });
106
105
  }
107
106
  const match = (value, regExp, message) => {
108
-
109
- if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12)
110
- throw new Error('match is available from Node.js 12 or higher');
111
- (0, assert_js_1.processAssert)(() => nodeAssert === null || nodeAssert === void 0 ? void 0 : nodeAssert.match(value, regExp), {
107
+ (0, assert_js_1.processAssert)(() => nodeAssert?.match(value, regExp), {
112
108
  message,
113
109
  actual: 'Value',
114
110
  expected: 'RegExp',
@@ -116,9 +112,6 @@ const createAssert = (nodeAssert) => {
116
112
  });
117
113
  };
118
114
  const doesNotMatch = (value, regExp, message) => {
119
-
120
- if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12)
121
- throw new Error('doesNotMatch is available from Node.js 12 or higher');
122
115
  (0, assert_js_1.processAssert)(() => nodeAssert.doesNotMatch(value, regExp), {
123
116
  message,
124
117
  actual: 'Value',
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.finalResults = exports.fileResults = exports.states = void 0;
4
- exports.states = {};
4
+ exports.states = Object.create(null);
5
5
  exports.fileResults = {
6
6
  success: new Map(),
7
7
  fail: new Map(),
8
8
  };
9
- exports.finalResults = {};
9
+ exports.finalResults = Object.create(null);
@@ -1,3 +1,4 @@
1
+ import type { ConfigFile, ConfigJSONFile, Configs } from '../@types/poku.js';
1
2
  export declare const results: {
2
3
  success: number;
3
4
  fail: number;
@@ -6,3 +7,13 @@ export declare const results: {
6
7
  };
7
8
  export declare const VERSION = "";
8
9
  export declare const deepOptions: string[];
10
+ export declare const GLOBAL: {
11
+ cwd: string;
12
+ configs: Configs;
13
+ configFile: string | undefined;
14
+ configsFromFile: ConfigFile | ConfigJSONFile;
15
+ isPoku: boolean;
16
+ FILE: string | undefined;
17
+ envFile: string | undefined;
18
+ runAsOnly: boolean;
19
+ };
@@ -1,11 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deepOptions = exports.VERSION = exports.results = void 0;
3
+ exports.GLOBAL = exports.deepOptions = exports.VERSION = exports.results = void 0;
4
+ const node_process_1 = require("process");
4
5
  exports.results = {
5
6
  success: 0,
6
7
  fail: 0,
7
8
  skip: 0,
8
9
  todo: 0,
9
10
  };
10
- exports.VERSION = '2.7.1';
11
+ exports.VERSION = '3.0.0-rc.1';
11
12
  exports.deepOptions = [];
13
+ exports.GLOBAL = {
14
+ cwd: (0, node_process_1.cwd)(),
15
+ configs: Object.create(null),
16
+ configFile: undefined,
17
+ configsFromFile: Object.create(null),
18
+ isPoku: typeof node_process_1.env?.POKU_FILE === 'string' && node_process_1.env?.POKU_FILE.length > 0,
19
+ FILE: node_process_1.env.POKU_FILE,
20
+ envFile: undefined,
21
+ runAsOnly: false,
22
+ };