poku 1.17.1 → 1.19.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 (74) hide show
  1. package/README.md +20 -20
  2. package/lib/@types/container.d.ts +120 -0
  3. package/lib/@types/each.d.ts +16 -0
  4. package/lib/@types/processes.d.ts +34 -0
  5. package/lib/@types/watch.d.ts +1 -0
  6. package/lib/bin/index.js +115 -119
  7. package/lib/configs/each.d.ts +1 -11
  8. package/lib/configs/each.js +0 -2
  9. package/lib/configs/files.js +0 -2
  10. package/lib/configs/indentation.js +0 -2
  11. package/lib/configs/poku.d.ts +4 -0
  12. package/lib/configs/poku.js +7 -0
  13. package/lib/helpers/find-file.js +1 -2
  14. package/lib/helpers/format.d.ts +18 -11
  15. package/lib/helpers/format.js +59 -20
  16. package/lib/helpers/get-arg.js +2 -5
  17. package/lib/helpers/get-runtime.d.ts +1 -1
  18. package/lib/helpers/get-runtime.js +3 -8
  19. package/lib/helpers/hr.js +4 -8
  20. package/lib/helpers/logs.d.ts +2 -1
  21. package/lib/helpers/logs.js +4 -8
  22. package/lib/helpers/parse-assertion.js +24 -24
  23. package/lib/helpers/runner.js +3 -6
  24. package/lib/helpers/time.js +1 -1
  25. package/lib/index.d.ts +4 -0
  26. package/lib/index.js +6 -1
  27. package/lib/modules/assert-promise.d.ts +19 -20
  28. package/lib/modules/assert-promise.js +4 -1
  29. package/lib/modules/assert.d.ts +19 -20
  30. package/lib/modules/assert.js +4 -1
  31. package/lib/modules/container.d.ts +6 -0
  32. package/lib/modules/container.js +16 -0
  33. package/lib/modules/create-service.js +9 -5
  34. package/lib/modules/describe.js +10 -18
  35. package/lib/modules/each.d.ts +2 -8
  36. package/lib/modules/each.js +2 -2
  37. package/lib/modules/exit.js +8 -10
  38. package/lib/modules/it.js +12 -17
  39. package/lib/modules/list-files-sync.d.ts +3 -0
  40. package/lib/modules/list-files-sync.js +6 -6
  41. package/lib/modules/list-files.d.ts +1 -1
  42. package/lib/modules/list-files.js +7 -11
  43. package/lib/modules/log.js +1 -1
  44. package/lib/modules/poku.d.ts +1 -0
  45. package/lib/modules/poku.js +12 -11
  46. package/lib/modules/processes.js +1 -1
  47. package/lib/modules/test.js +12 -15
  48. package/lib/modules/wait-for.d.ts +9 -0
  49. package/lib/modules/wait-for.js +78 -0
  50. package/lib/polyfills/deno.d.mts +3 -0
  51. package/lib/polyfills/fs.d.ts +0 -2
  52. package/lib/polyfills/fs.js +2 -4
  53. package/lib/polyfills/object.d.ts +2 -8
  54. package/lib/polyfills/object.js +0 -2
  55. package/lib/polyfills/pad.js +0 -2
  56. package/lib/services/container.d.ts +32 -0
  57. package/lib/services/container.js +128 -0
  58. package/lib/services/each.js +23 -9
  59. package/lib/services/map-tests.d.ts +3 -1
  60. package/lib/services/map-tests.js +85 -21
  61. package/lib/services/pid.js +3 -4
  62. package/lib/services/run-test-file.js +10 -10
  63. package/lib/services/run-tests.d.ts +0 -4
  64. package/lib/services/run-tests.js +30 -30
  65. package/lib/services/watch.d.ts +1 -1
  66. package/lib/services/watch.js +4 -6
  67. package/package.json +8 -8
  68. package/lib/@types/assert.js +0 -4
  69. package/lib/@types/background-process.js +0 -4
  70. package/lib/@types/code.js +0 -4
  71. package/lib/@types/describe.js +0 -4
  72. package/lib/@types/list-files.js +0 -4
  73. package/lib/@types/poku.js +0 -4
  74. package/lib/@types/runner.js +0 -4
package/README.md CHANGED
@@ -3,19 +3,19 @@
3
3
  [deno-version-url]: https://github.com/denoland/deno
4
4
  [typescript-url]: https://github.com/microsoft/TypeScript
5
5
  [ci-linux-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-linux.yml?query=branch%3Amain
6
- [ci-linux-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-linux.yml?event=push&style=flat-square&label=&branch=main&logo=ubuntu&logoColor=white
6
+ [ci-linux-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-linux.yml?event=push&label=&branch=main&logo=ubuntu&logoColor=white
7
7
  [ci-osx-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-osx.yml?query=branch%3Amain
8
- [ci-osx-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-osx.yml?event=push&style=flat-square&label=&branch=main&logo=apple&logoColor=white
8
+ [ci-osx-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-osx.yml?event=push&label=&branch=main&logo=apple&logoColor=white
9
9
  [ci-windows-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-windows.yml?query=branch%3Amain
10
- [ci-windows-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-windows.yml?event=push&style=flat-square&label=&branch=main&logo=windows&logoColor=white
10
+ [ci-windows-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-windows.yml?event=push&label=&branch=main&logo=windows&logoColor=white
11
11
  [ql-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_codeql.yml?query=branch%3Amain
12
- [ql-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_codeql.yml?event=push&style=flat-square&label=&branch=main&logo=github&logoColor=white
13
- [coverage-image]: https://img.shields.io/codecov/c/github/wellwelwel/poku?style=flat-square&label=Coverage
12
+ [ql-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_codeql.yml?event=push&label=&branch=main&logo=github&logoColor=white
13
+ [coverage-image]: https://img.shields.io/codecov/c/github/wellwelwel/poku
14
14
  [coverage-url]: https://app.codecov.io/github/wellwelwel/poku
15
- [downloads-image]: https://img.shields.io/npm/dt/poku.svg?style=flat-square&label=Downloads&logo=npm&logoColor=white&color=1e90ff
15
+ [downloads-image]: https://img.shields.io/npm/dt/poku.svg?logo=npm&logoColor=white&color=1e90ff
16
16
  [downloads-url]: https://www.npmjs.com/package/poku
17
- [license-url]: https://github.com/wellwelwel/poku/blob/main/LICENSE
18
- [license-image]: https://img.shields.io/npm/l/poku.svg?maxAge=2592000&color=9c88ff&style=flat-square&label=License
17
+ [license-url]: https://licenses.dev/npm/poku
18
+ [license-image]: https://licenses.dev/b/npm/poku
19
19
 
20
20
  <div align="center">
21
21
  <img width="125" height="125" alt="Logo" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/poku.svg">
@@ -40,15 +40,14 @@ Enjoying **Poku**? Give him a star to show your support 🌟
40
40
  **Poku** makes testing easy and takes on the testers' difficulties to _let you focus on your tests_:
41
41
 
42
42
  <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> No configurations<br />
43
- <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Auto detect **ESM** and **CJS**<br />
44
- <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Auto detect **Typescript** files<br />
43
+ <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><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 />
45
44
  <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><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] _(6+)_, [**Bun**][bun-version-url] and [**Deno**][deno-version-url]<br />
46
45
 
47
46
  <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Easier and Less Verbose<br />
48
47
  <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> [**Node.js**][node-version-url] familiar **API**<br />
49
48
  <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Instantly re-run related tests in `watch` mode<br />
50
49
  <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Run **CJS** (**CommonJS**) files directly with [**Deno**][deno-version-url]<br />
51
- <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Easily handle, **servers**, **services**, **processes**, and **ports**<br />
50
+ <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Easily handle **containers**, **servers**, **services**, **processes**, and **ports**<br />
52
51
 
53
52
  <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Safety and Reliability<br />
54
53
  <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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 />
@@ -168,19 +167,20 @@ deno run npm:poku
168
167
 
169
168
  ### Essentials
170
169
 
171
- - [**poku**](https://poku.io/docs/category/poku) _(test runner)_
170
+ - [**poku**](https://poku.io/docs/category/-poku) _(test runner)_
172
171
  - [**assert**](https://poku.io/docs/documentation/assert) _(test assertion)_
173
172
 
174
173
  ### Helpers
175
174
 
176
- - [**test**](https://poku.io/docs/documentation/helpers/test)
177
- , [**describe**](https://poku.io/docs/documentation/helpers/describe) and [**it**](https://poku.io/docs/documentation/helpers/it) _(organize, group, and isolate tests)_
175
+ - [**test**](https://poku.io/docs/documentation/helpers/test), [**describe**](https://poku.io/docs/documentation/helpers/describe) and [**it**](https://poku.io/docs/documentation/helpers/it) _(organize, group, and isolate tests)_
178
176
  - [**watch**](https://poku.io/docs/documentation/poku/options/watch) _(watch for changes and re-run related test files)_
179
- - [**beforeEach**](https://poku.io/docs/category/beforeeach-and-aftereach) and [**afterEach**](https://poku.io/docs/category/beforeeach-and-aftereach) _(hooks for test setup and teardown)_
180
- - [**startScript**](https://poku.io/docs/documentation/startScript) _(run **package.json** scripts in background)_
181
- - [**startService**](https://poku.io/docs/documentation/startService) _(run files in background)_
182
- - [**kill**](https://poku.io/docs/documentation/processes/kill) _(terminate ports, port ranges, and PIDs)_
183
- - [**getPIDs**](https://poku.io/docs/documentation/processes/get-pids) _(debug processes IDs using ports and port ranges)_
177
+ - [**beforeEach**](https://poku.io/docs/category/-before-and-after-each) and [**afterEach**](https://poku.io/docs/category/-before-and-after-each) _(hooks for test setup and teardown)_
178
+ - [**docker**](https://poku.io/docs/documentation/helpers/containers) _(build, start, compose, stop, remove, and test containers)_
179
+ - [**startScript**](https://poku.io/docs/documentation/helpers/startScript) _(run **package.json** scripts in background)_
180
+ - [**startService**](https://poku.io/docs/documentation/helpers/startService) _(run files in background)_
181
+ - [**kill**](https://poku.io/docs/documentation/helpers/processes/kill) _(terminate ports, port ranges, and PIDs)_
182
+ - [**waitForPort**](https://poku.io/docs/documentation/helpers/processes/wait-for-port) _(wait for specified ports to become active)_
183
+ - [**getPIDs**](https://poku.io/docs/documentation/helpers/processes/get-pids) _(debug processes IDs using ports and port ranges)_
184
184
  - _and much more_ 👇🏻
185
185
 
186
186
  ---
@@ -238,7 +238,7 @@ Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/
238
238
 
239
239
  ## Acknowledgements
240
240
 
241
- [![Contributors](https://img.shields.io/github/contributors/wellwelwel/poku?style=flat-square)](https://github.com/wellwelwel/poku/graphs/contributors)
241
+ [![Contributors](https://img.shields.io/github/contributors/wellwelwel/poku)](https://github.com/wellwelwel/poku/graphs/contributors)
242
242
 
243
243
  [![Contributors](https://opencollective.com/poku/contributors.svg?width=890&button=false)](https://github.com/wellwelwel/poku/graphs/contributors)
244
244
 
@@ -0,0 +1,120 @@
1
+ export type DockerfileConfigs = {
2
+ /**
3
+ * Specifies the imange name
4
+ *
5
+ * E.g., `"name"`, `"name:tag"`.
6
+ */
7
+ tagName: string;
8
+ /**
9
+ * Specifies the container name.
10
+ */
11
+ containerName: string;
12
+ /**
13
+ * Specifies the **Dockerfile** path
14
+ *
15
+ * ---
16
+ *
17
+ * @default "./Dockerfile"
18
+ */
19
+ file?: string;
20
+ /**
21
+ * Specifies the context path of the Dockerfile
22
+ *
23
+ * - It's different from `cwd`.
24
+ *
25
+ * ---
26
+ *
27
+ * @default "."
28
+ */
29
+ context?: string;
30
+ /**
31
+ * Specifies the ports to expose.
32
+ *
33
+ * E.g., `"6000:6000"`, `"8080:80"`, `"127.0.0.1:3306:3306"`.
34
+ */
35
+ ports?: string[];
36
+ /**
37
+ * Specifies the container environments variables.
38
+ *
39
+ * E.g, `"VAR1"`, `"VAR1=value1"`
40
+ */
41
+ environments?: string[];
42
+ /**
43
+ * Specifies a `.env` path to **Dockerfile**.
44
+ */
45
+ envFile?: string;
46
+ /**
47
+ * Forces the image build without cache.
48
+ */
49
+ cache?: boolean;
50
+ /**
51
+ * Doesn't run the container in the background and returns the container's process exit result (boolean).
52
+ *
53
+ * - Set to `false` to test whether a container was executed and finished successfully.
54
+ *
55
+ * ---
56
+ *
57
+ * @default true
58
+ */
59
+ detach?: boolean;
60
+ /**
61
+ * Defines the root directory where the process will run.
62
+ *
63
+ * ---
64
+ *
65
+ * @default "."
66
+ */
67
+ cwd?: string;
68
+ /**
69
+ * Show logs from **Docker** in real time.
70
+ */
71
+ verbose?: boolean;
72
+ };
73
+ export type DockerComposeConfigs = {
74
+ /**
75
+ * Specifies the **docker-compose.yml** path
76
+ *
77
+ * ---
78
+ *
79
+ * @default "./docker-compose.yml"
80
+ */
81
+ file?: string;
82
+ /**
83
+ * Specifies the project name.
84
+ */
85
+ projectName?: string;
86
+ /**
87
+ * Specifies a `.env` path to **docker-compose.yml**.
88
+ */
89
+ envFile?: string;
90
+ /**
91
+ * Defines the root directory where the process will run.
92
+ *
93
+ * ---
94
+ *
95
+ * @default "."
96
+ */
97
+ cwd?: string;
98
+ /**
99
+ * Forces the images (**Dockerfile**) to be rebuilt.
100
+ */
101
+ build?: boolean;
102
+ /**
103
+ * Starts only a specific **docker-compose.yml** service.
104
+ */
105
+ serviceName?: string;
106
+ /**
107
+ * Doesn't run the container in the background and returns the container's process exit result (boolean).
108
+ *
109
+ * - Set to `false` to test whether a container was executed and finished successfully.
110
+ *
111
+ * ---
112
+ *
113
+ * @default true
114
+ */
115
+ detach?: boolean;
116
+ /**
117
+ * Show logs from **Docker** in real time.
118
+ */
119
+ verbose?: boolean;
120
+ };
@@ -0,0 +1,16 @@
1
+ export type Control = {
2
+ pause: () => void;
3
+ continue: () => void;
4
+ reset: () => void;
5
+ };
6
+ export type EachConfigs = {
7
+ status: boolean;
8
+ assert?: boolean;
9
+ test?: boolean;
10
+ cb?: () => unknown | Promise<unknown>;
11
+ };
12
+ export type EachOptions = {
13
+ immediate?: boolean;
14
+ test?: boolean;
15
+ assert?: boolean;
16
+ };
@@ -0,0 +1,34 @@
1
+ export type WaitForPortOptions = {
2
+ /**
3
+ * Retry interval in milliseconds
4
+ *
5
+ * ---
6
+ *
7
+ * @default 100
8
+ */
9
+ interval?: number;
10
+ /**
11
+ * Timeout in milliseconds
12
+ *
13
+ * ---
14
+ *
15
+ * @default 60000
16
+ */
17
+ timeout?: number;
18
+ /**
19
+ * Delays both the start and end by the defined milliseconds.
20
+ *
21
+ * ---
22
+ *
23
+ * @default 0
24
+ */
25
+ delay?: number;
26
+ /**
27
+ * Host to check the port on.
28
+ *
29
+ * ---
30
+ *
31
+ * @default "localhost"
32
+ */
33
+ host?: string;
34
+ };
@@ -0,0 +1 @@
1
+ export type WatchCallback = (file: string, event: string) => void;
package/lib/bin/index.js CHANGED
@@ -1,16 +1,11 @@
1
1
  #! /usr/bin/env node
2
2
  "use strict";
3
- /* c8 ignore start */
4
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
- return new (P || (P = Promise))(function (resolve, reject) {
7
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10
- step((generator = generator.apply(thisArg, _arguments || [])).next());
11
- });
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
12
5
  };
6
+ var _a;
13
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
+ const node_process_1 = __importDefault(require("process"));
14
9
  const list_files_js_1 = require("../modules/list-files.js");
15
10
  const get_arg_js_1 = require("../helpers/get-arg.js");
16
11
  const files_js_1 = require("../configs/files.js");
@@ -22,123 +17,124 @@ const map_tests_js_1 = require("../services/map-tests.js");
22
17
  const watch_js_1 = require("../services/watch.js");
23
18
  const poku_js_1 = require("../modules/poku.js");
24
19
  const processes_js_1 = require("../modules/processes.js");
25
- (() => __awaiter(void 0, void 0, void 0, function* () {
26
- var _a;
27
- const dirs = (() => {
28
- const includeArg = (0, get_arg_js_1.getArg)('include');
29
- if (includeArg !== undefined)
30
- return includeArg.split(',');
31
- const lastParam = (0, get_arg_js_1.getLastParam)();
32
- if (lastParam !== undefined)
33
- return lastParam.split(',');
34
- return ['.'];
35
- })();
36
- const platform = (0, get_arg_js_1.getArg)('platform');
37
- const filter = (0, get_arg_js_1.getArg)('filter');
38
- const exclude = (0, get_arg_js_1.getArg)('exclude');
39
- const killPort = (0, get_arg_js_1.getArg)('kill-port');
40
- const killRange = (0, get_arg_js_1.getArg)('kill-range');
41
- const killPID = (0, get_arg_js_1.getArg)('kill-pid');
42
- const denoAllow = (0, get_arg_js_1.argToArray)('deno-allow');
43
- const denoDeny = (0, get_arg_js_1.argToArray)('deno-deny');
44
- const denoCJS = ((_a = (0, get_arg_js_1.getArg)('deno-cjs')) === null || _a === void 0 ? void 0 : _a.split(',').map((a) => a.trim()).filter((a) => a)) || (0, get_arg_js_1.hasArg)('deno-cjs');
45
- const parallel = (0, get_arg_js_1.hasArg)('parallel');
46
- const quiet = (0, get_arg_js_1.hasArg)('quiet');
47
- const debug = (0, get_arg_js_1.hasArg)('debug');
48
- const failFast = (0, get_arg_js_1.hasArg)('fail-fast');
49
- const watchMode = (0, get_arg_js_1.hasArg)('watch');
50
- const concurrency = parallel
51
- ? Number((0, get_arg_js_1.getArg)('concurrency')) || undefined
52
- : undefined;
53
- if (killPort) {
54
- const ports = killPort.split(',').map(Number);
55
- yield processes_js_1.kill.port(ports);
56
- }
57
- if (killRange) {
58
- const ranges = killRange.split(',');
59
- for (const range of ranges) {
60
- const ports = range.split('-').map(Number);
61
- const startsAt = ports[0];
62
- const endsAt = ports[1];
63
- yield processes_js_1.kill.range(startsAt, endsAt);
64
- }
65
- }
66
- if (killPID) {
67
- const PIDs = killPID.split(',').map(Number);
68
- yield processes_js_1.kill.pid(PIDs);
20
+ const dirs = (() => {
21
+ const includeArg = (0, get_arg_js_1.getArg)('include');
22
+ if (includeArg !== undefined)
23
+ return includeArg.split(',');
24
+ const lastParam = (0, get_arg_js_1.getLastParam)();
25
+ if (lastParam !== undefined)
26
+ return lastParam.split(',');
27
+ return ['.'];
28
+ })();
29
+ const platform = (0, get_arg_js_1.getArg)('platform');
30
+ const filter = (0, get_arg_js_1.getArg)('filter');
31
+ const exclude = (0, get_arg_js_1.getArg)('exclude');
32
+ const killPort = (0, get_arg_js_1.getArg)('kill-port');
33
+ const killRange = (0, get_arg_js_1.getArg)('kill-range');
34
+ const killPID = (0, get_arg_js_1.getArg)('kill-pid');
35
+ const denoAllow = (0, get_arg_js_1.argToArray)('deno-allow');
36
+ const denoDeny = (0, get_arg_js_1.argToArray)('deno-deny');
37
+ const denoCJS = ((_a = (0, get_arg_js_1.getArg)('deno-cjs')) === null || _a === void 0 ? void 0 : _a.split(',').map((a) => a.trim()).filter((a) => a)) || (0, get_arg_js_1.hasArg)('deno-cjs');
38
+ const parallel = (0, get_arg_js_1.hasArg)('parallel');
39
+ const quiet = (0, get_arg_js_1.hasArg)('quiet');
40
+ const debug = (0, get_arg_js_1.hasArg)('debug');
41
+ const failFast = (0, get_arg_js_1.hasArg)('fail-fast');
42
+ const watchMode = (0, get_arg_js_1.hasArg)('watch');
43
+ const concurrency = parallel
44
+ ? Number((0, get_arg_js_1.getArg)('concurrency')) || undefined
45
+ : undefined;
46
+ const tasks = [];
47
+ if (killPort) {
48
+ const ports = killPort.split(',').map(Number);
49
+ tasks.push(processes_js_1.kill.port(ports));
50
+ }
51
+ if (killRange) {
52
+ const ranges = killRange.split(',');
53
+ for (const range of ranges) {
54
+ const ports = range.split('-').map(Number);
55
+ const startsAt = ports[0];
56
+ const endsAt = ports[1];
57
+ tasks.push(processes_js_1.kill.range(startsAt, endsAt));
69
58
  }
70
- const options = {
71
- platform: (0, get_runtime_js_1.platformIsValid)(platform) ? platform : undefined,
72
- filter: filter ? new RegExp((0, list_files_js_1.escapeRegExp)(filter)) : undefined,
73
- exclude: exclude ? new RegExp((0, list_files_js_1.escapeRegExp)(exclude)) : undefined,
74
- parallel,
75
- quiet,
76
- debug,
77
- failFast,
78
- concurrency,
79
- noExit: watchMode,
80
- deno: {
81
- allow: denoAllow,
82
- deny: denoDeny,
83
- cjs: denoCJS,
84
- },
85
- };
86
- if (debug) {
87
- (0, hr_js_1.hr)();
88
- (0, logs_js_1.write)(`${format_js_1.format.bg(104, 'Debug Enabled')}\n`);
89
- (0, logs_js_1.write)(`${format_js_1.format.italic(format_js_1.format.info('…'))} ${format_js_1.format.bold('Paths')}`);
90
- console.table(dirs);
91
- (0, logs_js_1.write)('\n');
92
- (0, logs_js_1.write)(`${format_js_1.format.italic(format_js_1.format.info('…'))} ${format_js_1.format.bold('Options')}`);
93
- console.dir(options, { depth: null, colors: true });
94
- }
95
- yield (0, poku_js_1.poku)(dirs, options);
96
- if (watchMode) {
97
- const executing = new Set();
98
- const interval = Number((0, get_arg_js_1.getArg)('watch-interval')) || 1500;
99
- const resultsClear = () => {
100
- files_js_1.fileResults.success.clear();
101
- files_js_1.fileResults.fail.clear();
102
- };
103
- resultsClear();
104
- (0, map_tests_js_1.mapTests)('.', dirs).then((mappedTests) => [
105
- Array.from(mappedTests.keys()).forEach((mappedTest) => {
106
- (0, watch_js_1.watch)(mappedTest, (file, event) => {
59
+ }
60
+ if (killPID) {
61
+ const PIDs = killPID.split(',').map(Number);
62
+ tasks.push(processes_js_1.kill.pid(PIDs));
63
+ }
64
+ const options = {
65
+ platform: (0, get_runtime_js_1.platformIsValid)(platform) ? platform : undefined,
66
+ filter: filter ? new RegExp((0, list_files_js_1.escapeRegExp)(filter)) : undefined,
67
+ exclude: exclude ? new RegExp((0, list_files_js_1.escapeRegExp)(exclude)) : undefined,
68
+ parallel,
69
+ quiet,
70
+ debug,
71
+ failFast,
72
+ concurrency,
73
+ noExit: watchMode,
74
+ deno: {
75
+ allow: denoAllow,
76
+ deny: denoDeny,
77
+ cjs: denoCJS,
78
+ },
79
+ };
80
+ if (debug) {
81
+ (0, hr_js_1.hr)();
82
+ (0, logs_js_1.write)(`${(0, format_js_1.format)(' Debug Enabled ').bg('brightBlue')}\n`);
83
+ (0, logs_js_1.write)(`${(0, format_js_1.format)('…').info().italic()} ${(0, format_js_1.format)('Paths').bold()}`);
84
+ console.table(dirs);
85
+ (0, logs_js_1.write)('\n');
86
+ (0, logs_js_1.write)(`${(0, format_js_1.format)('…').info().italic()} ${(0, format_js_1.format)('Options').bold()}`);
87
+ console.dir(options, { depth: null, colors: true });
88
+ }
89
+ Promise.all(tasks).then(() => {
90
+ (0, poku_js_1.poku)(dirs, options).then(() => {
91
+ if (watchMode) {
92
+ const executing = new Set();
93
+ const interval = Number((0, get_arg_js_1.getArg)('watch-interval')) || 1500;
94
+ const resultsClear = () => {
95
+ files_js_1.fileResults.success.clear();
96
+ files_js_1.fileResults.fail.clear();
97
+ };
98
+ node_process_1.default.removeListener('SIGINT', poku_js_1.onSigint);
99
+ resultsClear();
100
+ (0, map_tests_js_1.mapTests)('.', dirs, options.filter, options.exclude).then((mappedTests) => {
101
+ Array.from(mappedTests.keys()).forEach((mappedTest) => {
102
+ (0, watch_js_1.watch)(mappedTest, (file, event) => {
103
+ if (event === 'change') {
104
+ const filePath = (0, map_tests_js_1.normalizePath)(file);
105
+ if (executing.has(filePath))
106
+ return;
107
+ executing.add(filePath);
108
+ resultsClear();
109
+ const tests = mappedTests.get(filePath);
110
+ if (!tests)
111
+ return;
112
+ (0, poku_js_1.poku)(Array.from(tests), options).then(() => {
113
+ setTimeout(() => {
114
+ executing.delete(filePath);
115
+ }, interval);
116
+ });
117
+ }
118
+ });
119
+ });
120
+ });
121
+ dirs.forEach((dir) => {
122
+ (0, watch_js_1.watch)(dir, (file, event) => {
107
123
  if (event === 'change') {
108
- const filePath = (0, map_tests_js_1.normalizePath)(file);
109
- if (executing.has(filePath))
124
+ if (executing.has(file))
110
125
  return;
111
- executing.add(filePath);
126
+ executing.add(file);
112
127
  resultsClear();
113
- const tests = mappedTests.get(filePath);
114
- if (!tests)
115
- return;
116
- (0, poku_js_1.poku)(tests, options).then(() => {
128
+ (0, poku_js_1.poku)(file, options).then(() => {
117
129
  setTimeout(() => {
118
- executing.delete(filePath);
130
+ executing.delete(file);
119
131
  }, interval);
120
132
  });
121
133
  }
122
134
  });
123
- }),
124
- ]);
125
- dirs.forEach((dir) => {
126
- (0, watch_js_1.watch)(dir, (file, event) => {
127
- if (event === 'change') {
128
- if (executing.has(file))
129
- return;
130
- executing.add(file);
131
- resultsClear();
132
- (0, poku_js_1.poku)(file, options).then(() => {
133
- setTimeout(() => {
134
- executing.delete(file);
135
- }, interval);
136
- });
137
- }
138
135
  });
139
- });
140
- (0, hr_js_1.hr)();
141
- (0, logs_js_1.write)(`Watching: ${dirs.join(', ')}`);
142
- }
143
- }))();
144
- /* c8 ignore stop */
136
+ (0, hr_js_1.hr)();
137
+ (0, logs_js_1.write)(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
138
+ }
139
+ });
140
+ });
@@ -1,14 +1,4 @@
1
- export type Control = {
2
- pause: () => void;
3
- continue: () => void;
4
- reset: () => void;
5
- };
6
- export type EachConfigs = {
7
- status: boolean;
8
- assert?: boolean;
9
- test?: boolean;
10
- cb?: () => unknown | Promise<unknown>;
11
- };
1
+ import type { EachConfigs } from '../@types/each.js';
12
2
  export declare const each: {
13
3
  before: EachConfigs;
14
4
  after: EachConfigs;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- /* c8 ignore start */
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.each = void 0;
5
4
  exports.each = {
@@ -16,4 +15,3 @@ exports.each = {
16
15
  test: true,
17
16
  },
18
17
  };
19
- /* c8 ignore stop */
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- /* c8 ignore start */
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.finalResults = exports.fileResults = void 0;
5
4
  exports.fileResults = {
@@ -7,4 +6,3 @@ exports.fileResults = {
7
6
  fail: new Map(),
8
7
  };
9
8
  exports.finalResults = {};
10
- /* c8 ignore stop */
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- /* c8 ignore start */
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.indentation = void 0;
5
4
  exports.indentation = {
@@ -9,4 +8,3 @@ exports.indentation = {
9
8
  hasTest: false,
10
9
  hasIt: false,
11
10
  };
12
- /* c8 ignore stop */
@@ -0,0 +1,4 @@
1
+ export declare const results: {
2
+ success: number;
3
+ fail: number;
4
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.results = void 0;
4
+ exports.results = {
5
+ success: 0,
6
+ fail: 0,
7
+ };
@@ -2,10 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findFile = void 0;
4
4
  /* c8 ignore start */
5
- const node_os_1 = require("os");
6
5
  const findFile = (error) => {
7
6
  var _a;
8
- const stackLines = ((_a = error.stack) === null || _a === void 0 ? void 0 : _a.split(node_os_1.EOL)) || [];
7
+ const stackLines = ((_a = error.stack) === null || _a === void 0 ? void 0 : _a.split('\n')) || [];
9
8
  let file = '';
10
9
  const basePath = 'poku/lib/';
11
10
  for (const line of stackLines) {
@@ -15,15 +15,22 @@ export declare const backgroundColor: {
15
15
  readonly brightMagenta: 105;
16
16
  readonly brightCyan: 106;
17
17
  };
18
- export declare const format: {
19
- counter: (current: number, total: number, pad?: string) => string;
20
- dim: (value: string) => string;
21
- bold: (value: string) => string;
22
- underline: (value: string) => string;
23
- info: (value: string) => string;
24
- italic: (value: string) => string;
25
- success: (value: string) => string;
26
- fail: (value: string) => string;
27
- bg: (bg: number, text: string) => string;
28
- };
18
+ export declare class Formatter {
19
+ private parts;
20
+ private text;
21
+ constructor(text: string);
22
+ static create(text: string): Formatter;
23
+ counter(current: number, total: number, pad?: string): this;
24
+ dim(): this;
25
+ bold(): this;
26
+ underline(): this;
27
+ info(): this;
28
+ italic(): this;
29
+ success(): this;
30
+ fail(): this;
31
+ gray(): this;
32
+ bg(color: keyof typeof backgroundColor): this;
33
+ [Symbol.toPrimitive](): string;
34
+ }
35
+ export declare const format: (text: string) => Formatter;
29
36
  export declare const getLargestStringLength: (arr: string[]) => number;