poku 2.0.0 โ†’ 2.2.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.
package/README.md CHANGED
@@ -5,16 +5,16 @@
5
5
 
6
6
  Enjoying **Poku**? Give him a star to show your support ๐ŸŒŸ
7
7
 
8
- [![NPM Downloads](https://img.shields.io/npm/dt/poku.svg?logo=npm&logoColor=white&color=1e90ff)](https://www.npmjs.com/package/poku)
9
- [![Coverage](https://img.shields.io/codecov/c/github/wellwelwel/poku)](https://app.codecov.io/github/wellwelwel/poku)
10
- [![License](https://img.shields.io/npm/l/poku?maxAge=2592000&color=9c88ff)](https://github.com/wellwelwel/poku/blob/main/LICENSE)<br />
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=white)](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-linux.yml?query=branch%3Amain)
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=white)](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-osx.yml?query=branch%3Amain)
13
- [![GitHub Workflow Status (Windows)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-windows.yml?event=push&label=&branch=main&logo=iterm2&logoColor=white)](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-windows.yml?query=branch%3Amain)
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/dt/poku.svg?label=&logo=npm&logoColor=white&color=45aaf2)](https://www.npmjs.com/package/poku)
10
+ [![Coverage](https://img.shields.io/codecov/c/github/wellwelwel/poku?label=&logo=codecov&logoColor=white&color=98cc00)](https://app.codecov.io/github/wellwelwel/poku)<br />
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
+ [![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)
13
+ [![GitHub Workflow Status (Windows)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-windows.yml?event=push&label=&branch=main&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAxMjggMTI4IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjx0aXRsZT5XaW5kb3dzIDExPC90aXRsZT48cGF0aCBmaWxsPSIjODg5N2E5IiBkPSJNMTI2IDEuNjM3bC02NyA5LjgzNHY0OS44MzFsNjctLjUzNHpNMS42NDcgNjYuNzA5bC4wMDMgNDIuNDA0IDUwLjc5MSA2Ljk4My0uMDQtNDkuMDU3em01Ni44Mi42OGwuMDk0IDQ5LjQ2NSA2Ny4zNzYgOS41MDkuMDE2LTU4Ljg2M3pNMS42MSAxOS4yOTdsLjA0NyA0Mi4zODMgNTAuNzkxLS4yODktLjAyMy00OS4wMTZ6Ij48L3BhdGg+PC9zdmc+&color=dfe4ea)](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-windows.yml?query=branch%3Amain)
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>๐Ÿง‘๐Ÿปโ€๐ŸŽ“ [Quick Tutorials](https://poku.io/docs/category/quick-tutorials)
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)
18
18
 
19
19
  </div>
20
20
 
@@ -22,19 +22,14 @@ Enjoying **Poku**? Give him a star to show your support ๐ŸŒŸ
22
22
 
23
23
  ## Why does Poku exist?
24
24
 
25
- ๐Ÿ’ก **Poku** makes testing easy and brings the [native **JavaScript** syntax back to tests](https://poku.io/docs/philosophy#javascript-essence-for-tests-), letting you to write tests intuitively.
25
+ ๐Ÿ’ก **Poku** is a cross-platform test runner that brings the [**JavaScript** essence back to testing](https://poku.io/docs/philosophy#javascript-essence-for-tests-).
26
26
 
27
- <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> _No configurations_<br />
28
- <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 />
29
- <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], [**Bun**][bun-version-url], and [**Deno**][deno-version-url]<br />
30
-
31
- <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 />
32
- <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 />
33
- <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**, **processes**, and **ports**<br />
34
-
35
- <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> _Safety and Reliability_<br />
36
- <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 />
37
- <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"> **Performant** and **lightweight**<br />
27
+ </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
+ </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
+ <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
+ <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
+ <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 **containers** โœจ
38
33
 
39
34
  ---
40
35
 
@@ -42,45 +37,20 @@ Enjoying **Poku**? Give him a star to show your support ๐ŸŒŸ
42
37
 
43
38
  ### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Install
44
39
 
45
- <table>
46
- <tr>
47
- <td><blockquote><i>Node.js</i></blockquote></td>
48
- <td><blockquote><i>TypeScript (Node.js)</i></blockquote></td>
49
- <td><blockquote><i>Bun</i></blockquote></td>
50
- <td><blockquote><i>Deno</i></blockquote></td>
51
- </tr>
52
- <tr>
53
- <td width="400">
54
-
55
40
  ```bash
41
+ # Node.js
56
42
  npm i -D poku
57
- ```
58
43
 
59
- </td>
60
- <td width="400">
61
-
62
- ```bash
44
+ # TypeScript (Node.js)
63
45
  npm i -D poku tsx
64
- ```
65
-
66
- </td>
67
- <td width="400">
68
46
 
69
- ```bash
47
+ # Bun
70
48
  bun add -d poku
71
- ```
72
49
 
73
- </td>
74
- <td width="400">
75
-
76
- ```bash
50
+ # Deno
77
51
  deno add npm:poku
78
52
  ```
79
53
 
80
- </td>
81
- </tr>
82
- </table>
83
-
84
54
  ---
85
55
 
86
56
  ### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Test
@@ -143,16 +113,12 @@ deno run npm:poku
143
113
 
144
114
  ## Features
145
115
 
146
- ### Essentials
116
+ ### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Essentials
147
117
 
148
118
  <table>
149
119
  <tr>
150
- <th width="250">Name</th>
151
- <th width="800">Description</th>
152
- </tr>
153
- <tr>
154
- <td><a href="https://poku.io/docs/category/-poku">poku</a></td>
155
- <td>๐Ÿงช Test runner.</td>
120
+ <td width="280"><a href="https://poku.io/docs/category/-poku">poku</a></td>
121
+ <td width="770">๐Ÿงช Test runner.</td>
156
122
  </tr>
157
123
  <tr>
158
124
  <td><a href="https://poku.io/docs/documentation/assert">assert</a></td>
@@ -164,16 +130,12 @@ deno run npm:poku
164
130
  </tr>
165
131
  </table>
166
132
 
167
- ### Helpers
133
+ ### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Helpers
168
134
 
169
135
  <table>
170
136
  <tr>
171
- <th width="250">Name</th>
172
- <th width="800">Description</th>
173
- </tr>
174
- <tr>
175
- <td><a href="https://poku.io/docs/documentation/helpers/test">test</a> โ€ข <a href="https://poku.io/docs/documentation/helpers/describe">describe</a> โ€ข <a href="https://poku.io/docs/documentation/helpers/it">it</a></td>
176
- <td>๐Ÿคน๐Ÿปโ€โ™€๏ธ Organize, group, and isolate tests.</td>
137
+ <td width="250"><a href="https://poku.io/docs/documentation/helpers/test">test</a> โ€ข <a href="https://poku.io/docs/documentation/helpers/describe">describe</a> โ€ข <a href="https://poku.io/docs/documentation/helpers/it">it</a></td>
138
+ <td width="800">๐Ÿคน๐Ÿปโ€โ™€๏ธ Organize, group, and isolate tests.</td>
177
139
  </tr>
178
140
  <tr>
179
141
  <td><a href="https://poku.io/docs/documentation/helpers/env">envFile</a></td>
@@ -217,16 +179,12 @@ deno run npm:poku
217
179
  </tr>
218
180
  </table>
219
181
 
220
- ### Common Options
182
+ ### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Common Options
221
183
 
222
184
  <table>
223
185
  <tr>
224
- <th width="250">Name</th>
225
- <th width="800">Description</th>
226
- </tr>
227
- <tr>
228
- <td><a href="https://poku.io/docs/documentation/poku/options/watch">watch</a></td>
229
- <td>๐Ÿฟ Watch for changes and re-run related test files.</td>
186
+ <td width="280"><a href="https://poku.io/docs/documentation/poku/options/watch">watch</a></td>
187
+ <td width="770">๐Ÿฟ Watch for changes and re-run related test files.</td>
230
188
  </tr>
231
189
  <tr>
232
190
  <td><a href="https://poku.io/docs/documentation/poku/options/parallel">parallel</a></td>
@@ -236,6 +194,10 @@ deno run npm:poku
236
194
  <td><a href="https://poku.io/docs/documentation/poku/options/debug">debug</a></td>
237
195
  <td>๐Ÿ•ต๐Ÿป Shows all logs.</td>
238
196
  </tr>
197
+ <tr>
198
+ <td><a href="https://poku.io/docs/documentation/poku/config-files">config</a></td>
199
+ <td>โš™๏ธ Customize your Poku options in a config file.</td>
200
+ </tr>
239
201
  </table>
240
202
 
241
203
  > _and much more_ ๐Ÿ‘‡๐Ÿป
@@ -258,21 +220,8 @@ To see the detailed documentation, please visit the [**Documentation**](https://
258
220
 
259
221
  - [Avoiding conflicts in environments with multiple platforms installed](https://poku.io/docs/tutorials/cross-platform#recommendations).
260
222
  - [Properly running asynchronous tests on the same file](https://poku.io/docs/examples/promises).
261
- - [Migrating to version **2.x**](https://github.com/wellwelwel/poku/issues/533).
262
-
263
- ---
264
-
265
- ## Contributing
266
-
267
- See the [**Contributing Guide**](https://github.com/wellwelwel/poku/blob/main/CONTRIBUTING.md) and please follow our [**Code of Conduct**](https://github.com/wellwelwel/poku/blob/main/CODE_OF_CONDUCT.md) ๐Ÿš€
268
-
269
- ---
270
-
271
- ## Security Policy
272
-
273
- [![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_codeql.yml?event=push&label=&branch=main&logo=github&logoColor=white)](https://github.com/wellwelwel/poku/actions/workflows/ci_codeql.yml?query=branch%3Amain)
274
-
275
- Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/SECURITY.md).
223
+ - [Migrating from version **1.x** to version **2.x**](https://github.com/wellwelwel/poku/issues/533).
224
+ - [Using **Poku** with **Deno** and approaches to **JSR**](https://github.com/wellwelwel/poku/discussions/565).
276
225
 
277
226
  ---
278
227
 
@@ -282,9 +231,9 @@ Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/
282
231
 
283
232
  **Poku** is [continuously tested](https://github.com/wellwelwel/poku/blob/main/.github/workflows/ci_benchmark.yml) to ensure the following expectations for basic usage:
284
233
 
285
- - **~4x** faster than [**Jest**](https://github.com/jestjs/jest) (v29.7.0)
286
- - **~3x** faster than [**Vitest**](https://github.com/vitest-dev/vitest) (v1.6.0)
287
- - **~1x** faster than [**Mocha**](https://github.com/mochajs/mocha) (v10.4.0) + [**Chai**](https://github.com/chaijs/chai) (v5.1.1)
234
+ - \>=**4x** faster than [**Jest**](https://github.com/jestjs/jest) (v29.7.0)
235
+ - \>=**3x** faster than [**Vitest**](https://github.com/vitest-dev/vitest) (v1.6.0)
236
+ - \>=**1x** faster than [**Mocha**](https://github.com/mochajs/mocha) (v10.4.0) + [**Chai**](https://github.com/chaijs/chai) (v5.1.1)
288
237
 
289
238
  > You can see how the tests are run and compared in the [benchmark](https://github.com/wellwelwel/poku/tree/main/benchmark) directory.
290
239
 
@@ -302,27 +251,32 @@ Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/
302
251
 
303
252
  ---
304
253
 
305
- ### Limitations
254
+ ## Security Policy
255
+
256
+ [![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_codeql.yml?event=push&label=&branch=main&logo=github&logoColor=white&color=f368e0)](https://github.com/wellwelwel/poku/actions/workflows/ci_codeql.yml?query=branch%3Amain)
257
+
258
+ Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/SECURITY.md).
259
+
260
+ ---
261
+
262
+ ## Contributing
306
263
 
307
- - Although it has no external dependencies, **Poku** is not _all-in-one_, so it doesn't have integrated features such as _mocks_, _spies_, _coverage reports_, etc., where you can use your favorite packages or native solutions.
308
- - See a [mock example](https://poku.io/docs/category/mock).
309
- - **Poku** doesn't render components (such as **Angular**, **React**, etc.).
310
- - See an [_end-to-end_ test example](https://poku.io/docs/examples/browser/react).
311
- - Our community is gradually building up.
264
+ See the [**Contributing Guide**](https://github.com/wellwelwel/poku/blob/main/CONTRIBUTING.md) and please follow our [**Code of Conduct**](https://github.com/wellwelwel/poku/blob/main/CODE_OF_CONDUCT.md) ๐Ÿš€
312
265
 
313
266
  ---
314
267
 
315
268
  ## Acknowledgements
316
269
 
317
- [![Contributors](https://img.shields.io/github/contributors/wellwelwel/poku)](https://github.com/wellwelwel/poku/graphs/contributors)
270
+ [![Contributors](https://img.shields.io/github/contributors/wellwelwel/poku?color=9c88ff)](https://github.com/wellwelwel/poku/graphs/contributors)
318
271
 
319
- [![Contributors](https://opencollective.com/poku/contributors.svg?width=890&button=false)](https://github.com/wellwelwel/poku/graphs/contributors)
272
+ [![Contributors](https://opencollective.com/poku/contributors.svg?width=890&button=false)](https://opencollective.com/poku/contributors.svg?button=false)
320
273
 
321
274
  ---
322
275
 
323
276
  ## License
324
277
 
325
- **Poku** is under the [**MIT License**](https://github.com/wellwelwel/poku/blob/main/LICENSE).
278
+ **Poku** is under the [**MIT License**](https://github.com/wellwelwel/poku/blob/main/LICENSE).<br />
279
+ Copyright ยฉ 2024-present [Weslley Araรบjo](https://github.com/wellwelwel) and **Poku** [contributors](https://github.com/wellwelwel/poku/graphs/contributors).
326
280
 
327
281
  [node-version-url]: https://github.com/nodejs/node
328
282
  [bun-version-url]: https://github.com/oven-sh/bun
@@ -2,7 +2,7 @@ export type Configs = {
2
2
  /**
3
3
  * Filter by path to match only the files that should be performed.
4
4
  *
5
- * @default /\.test\./i
5
+ * @default /\.(test|spec)\./i
6
6
  */
7
7
  filter?: RegExp;
8
8
  /**
@@ -83,3 +83,24 @@ export type FinalResults = {
83
83
  time: string;
84
84
  started: Date;
85
85
  };
86
+ type cliConfigs = {
87
+ /** By default, **Poku** searches for _`.test.`_ and `.spec.` files, but you can customize it. */
88
+ include?: string | string[];
89
+ /** Reads an environment file and sets the environment variables. */
90
+ envFile?: string;
91
+ /** Terminates the specified ports, port ranges and process IDs. */
92
+ kill?: {
93
+ /** Terminates the specified ports before running the test suite. */
94
+ port?: [number];
95
+ /** Terminates the specified port range before running the test suite. */
96
+ range?: [number, number][];
97
+ /** Terminates the specified processes before running the test suite. */
98
+ pid?: [number];
99
+ };
100
+ };
101
+ export type ConfigJSONFile = {
102
+ filter?: string;
103
+ exclude?: string;
104
+ } & Omit<Configs, 'beforeEach' | 'afterEach' | 'noExit' | 'filter' | 'exclude'> & cliConfigs;
105
+ export type ConfigFile = Omit<Configs, 'noExit'> & cliConfigs;
106
+ export {};
package/lib/bin/index.js CHANGED
@@ -3,7 +3,6 @@
3
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
- var _a;
7
6
  Object.defineProperty(exports, "__esModule", { value: true });
8
7
  const node_process_1 = __importDefault(require("process"));
9
8
  const list_files_js_1 = require("../modules/helpers/list-files.js");
@@ -17,165 +16,190 @@ const map_tests_js_1 = require("../services/map-tests.js");
17
16
  const watch_js_1 = require("../services/watch.js");
18
17
  const poku_js_1 = require("../modules/essentials/poku.js");
19
18
  const write_js_1 = require("../services/write.js");
20
- const dirs = (() => {
21
- const includeArg = (0, get_arg_js_1.getArg)('include');
22
- if (includeArg !== undefined) {
23
- return includeArg.split(',');
19
+ const options_js_1 = require("../parsers/options.js");
20
+ (async () => {
21
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
22
+ const configFile = (0, get_arg_js_1.getArg)('config') || (0, get_arg_js_1.getArg)('c', '-');
23
+ const defaultConfigs = await (0, options_js_1.getConfigs)(configFile);
24
+ const dirs = (() => {
25
+ var _a;
26
+ const includeArg = (0, get_arg_js_1.getArg)('include'); // deprecated
27
+ if (includeArg !== undefined) {
28
+ return includeArg.split(',');
29
+ }
30
+ return ((_a = (0, get_arg_js_1.getPaths)('-')) !== null && _a !== void 0 ? _a : ((defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.include)
31
+ ? Array.prototype.concat(defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.include)
32
+ : ['.']));
33
+ })();
34
+ const platform = (0, get_arg_js_1.getArg)('platform');
35
+ const filter = (_a = (0, get_arg_js_1.getArg)('filter')) !== null && _a !== void 0 ? _a : defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.filter;
36
+ const exclude = (_b = (0, get_arg_js_1.getArg)('exclude')) !== null && _b !== void 0 ? _b : defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.exclude;
37
+ const killPort = (0, get_arg_js_1.getArg)('kill-port');
38
+ const killRange = (0, get_arg_js_1.getArg)('kill-range');
39
+ const killPID = (0, get_arg_js_1.getArg)('kill-pid');
40
+ const denoAllow = (_c = (0, get_arg_js_1.argToArray)('deno-allow')) !== null && _c !== void 0 ? _c : (_d = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _d === void 0 ? void 0 : _d.allow;
41
+ const denoDeny = (_e = (0, get_arg_js_1.argToArray)('deno-deny')) !== null && _e !== void 0 ? _e : (_f = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _f === void 0 ? void 0 : _f.deny;
42
+ const denoCJS = ((_g = (0, get_arg_js_1.getArg)('deno-cjs')) === null || _g === void 0 ? void 0 : _g.split(',').map((a) => a.trim()).filter((a) => a)) ||
43
+ (0, get_arg_js_1.hasArg)('deno-cjs') ||
44
+ ((_h = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _h === void 0 ? void 0 : _h.cjs);
45
+ 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);
46
+ 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);
47
+ 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);
48
+ const failFast = (0, get_arg_js_1.hasArg)('fail-fast') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.failFast);
49
+ const watchMode = (0, get_arg_js_1.hasArg)('watch') || (0, get_arg_js_1.hasArg)('w', '-');
50
+ const hasEnvFile = (0, get_arg_js_1.hasArg)('env-file');
51
+ const concurrency = (() => {
52
+ if (!(parallel || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel))) {
53
+ return undefined;
54
+ }
55
+ const value = Number((0, get_arg_js_1.getArg)('concurrency'));
56
+ return Number.isNaN(value) ? defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.concurrency : value;
57
+ })();
58
+ const tasks = [];
59
+ if (killPort || ((_j = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _j === void 0 ? void 0 : _j.port)) {
60
+ 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) || [];
61
+ tasks.push(kill_js_1.kill.port(ports));
24
62
  }
25
- const lastParam = (0, get_arg_js_1.getLastParam)();
26
- if (lastParam !== undefined) {
27
- return lastParam.split(',');
63
+ if (killRange || ((_l = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _l === void 0 ? void 0 : _l.range)) {
64
+ const ranges = (killRange === null || killRange === void 0 ? void 0 : killRange.split(',')) ||
65
+ ((_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]}`)) ||
66
+ [];
67
+ for (const range of ranges) {
68
+ const ports = range.split('-').map(Number);
69
+ const startsAt = ports[0];
70
+ const endsAt = ports[1];
71
+ tasks.push(kill_js_1.kill.range(startsAt, endsAt));
72
+ }
28
73
  }
29
- return ['.'];
30
- })();
31
- const platform = (0, get_arg_js_1.getArg)('platform');
32
- const filter = (0, get_arg_js_1.getArg)('filter');
33
- const exclude = (0, get_arg_js_1.getArg)('exclude');
34
- const killPort = (0, get_arg_js_1.getArg)('kill-port');
35
- const killRange = (0, get_arg_js_1.getArg)('kill-range');
36
- const killPID = (0, get_arg_js_1.getArg)('kill-pid');
37
- const denoAllow = (0, get_arg_js_1.argToArray)('deno-allow');
38
- const denoDeny = (0, get_arg_js_1.argToArray)('deno-deny');
39
- 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');
40
- const parallel = (0, get_arg_js_1.hasArg)('parallel');
41
- const quiet = (0, get_arg_js_1.hasArg)('quiet');
42
- const debug = (0, get_arg_js_1.hasArg)('debug');
43
- const failFast = (0, get_arg_js_1.hasArg)('fail-fast');
44
- const watchMode = (0, get_arg_js_1.hasArg)('watch');
45
- const hasEnvFile = (0, get_arg_js_1.hasArg)('env-file');
46
- const concurrency = parallel
47
- ? Number((0, get_arg_js_1.getArg)('concurrency')) || undefined
48
- : undefined;
49
- const tasks = [];
50
- if (killPort) {
51
- const ports = killPort.split(',').map(Number);
52
- tasks.push(kill_js_1.kill.port(ports));
53
- }
54
- if (killRange) {
55
- const ranges = killRange.split(',');
56
- for (const range of ranges) {
57
- const ports = range.split('-').map(Number);
58
- const startsAt = ports[0];
59
- const endsAt = ports[1];
60
- tasks.push(kill_js_1.kill.range(startsAt, endsAt));
74
+ if (killPID || ((_p = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _p === void 0 ? void 0 : _p.pid)) {
75
+ 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) || [];
76
+ tasks.push(kill_js_1.kill.pid(PIDs));
61
77
  }
62
- }
63
- if (killPID) {
64
- const PIDs = killPID.split(',').map(Number);
65
- tasks.push(kill_js_1.kill.pid(PIDs));
66
- }
67
- if (hasEnvFile) {
68
- const envFilePath = (0, get_arg_js_1.getArg)('env-file');
69
- tasks.push((0, env_js_1.envFile)(envFilePath));
70
- }
71
- const options = {
72
- platform: (0, get_runtime_js_1.platformIsValid)(platform) ? platform : undefined,
73
- filter: filter ? new RegExp((0, list_files_js_1.escapeRegExp)(filter)) : undefined,
74
- exclude: exclude ? new RegExp((0, list_files_js_1.escapeRegExp)(exclude)) : undefined,
75
- parallel,
76
- quiet,
77
- debug,
78
- failFast,
79
- concurrency,
80
- noExit: watchMode,
81
- deno: {
82
- allow: denoAllow,
83
- deny: denoDeny,
84
- cjs: denoCJS,
85
- },
86
- };
87
- if (debug) {
88
- write_js_1.Write.hr();
89
- write_js_1.Write.log(`${(0, format_js_1.format)(' Debug Enabled ').bg('brightBlue')}\n`);
90
- write_js_1.Write.log(`${(0, format_js_1.format)('โ€ฆ').info().italic()} ${(0, format_js_1.format)('Paths').bold()}`);
91
- console.table(dirs);
92
- write_js_1.Write.log('\n');
93
- write_js_1.Write.log(`${(0, format_js_1.format)('โ€ฆ').info().italic()} ${(0, format_js_1.format)('Options').bold()}`);
94
- console.dir(options, { depth: null, colors: true });
95
- }
96
- const watchers = new Set();
97
- const executing = new Set();
98
- const interval = Number((0, get_arg_js_1.getArg)('watch-interval')) || 1500;
99
- let isRunning = false;
100
- const listenStdin = (input) => {
101
- if (isRunning || executing.size > 0) {
102
- return;
78
+ if (hasEnvFile || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.envFile)) {
79
+ const envFilePath = (_r = (0, get_arg_js_1.getArg)('env-file')) !== null && _r !== void 0 ? _r : defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.envFile;
80
+ tasks.push((0, env_js_1.envFile)(envFilePath));
103
81
  }
104
- if (String(input).trim() === 'rs') {
105
- for (const watcher of watchers) {
106
- watcher.stop();
107
- }
108
- watchers.clear();
109
- resultsClear();
110
- startTests();
82
+ const options = {
83
+ platform: (0, get_runtime_js_1.platformIsValid)(platform)
84
+ ? platform
85
+ : (0, get_arg_js_1.hasArg)('node')
86
+ ? 'node'
87
+ : (0, get_arg_js_1.hasArg)('bun')
88
+ ? 'bun'
89
+ : (0, get_arg_js_1.hasArg)('deno')
90
+ ? 'deno'
91
+ : (0, get_runtime_js_1.platformIsValid)(defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.platform)
92
+ ? defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.platform
93
+ : undefined,
94
+ filter: typeof filter === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(filter)) : filter,
95
+ exclude: typeof exclude === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(exclude)) : exclude,
96
+ parallel,
97
+ concurrency,
98
+ quiet,
99
+ debug,
100
+ failFast,
101
+ deno: {
102
+ allow: denoAllow,
103
+ deny: denoDeny,
104
+ cjs: denoCJS,
105
+ },
106
+ noExit: watchMode,
107
+ beforeEach: 'beforeEach' in defaultConfigs ? defaultConfigs.beforeEach : undefined,
108
+ afterEach: 'afterEach' in defaultConfigs ? defaultConfigs.afterEach : undefined,
109
+ };
110
+ if (debug || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.debug)) {
111
+ write_js_1.Write.hr();
112
+ write_js_1.Write.log(`${(0, format_js_1.format)(' Debug Enabled ').bg('brightBlue')}\n`);
113
+ write_js_1.Write.log(`${(0, format_js_1.format)('โ€ฆ').info().italic()} ${(0, format_js_1.format)('Paths').bold()}`);
114
+ console.table(dirs);
115
+ write_js_1.Write.log('\n');
116
+ write_js_1.Write.log(`${(0, format_js_1.format)('โ€ฆ').info().italic()} ${(0, format_js_1.format)('Options').bold()}`);
117
+ console.dir(options, { depth: null, colors: true });
111
118
  }
112
- };
113
- const resultsClear = () => {
114
- files_js_1.fileResults.success.clear();
115
- files_js_1.fileResults.fail.clear();
116
- };
117
- const startTests = () => {
118
- if (isRunning || executing.size > 0) {
119
- return;
120
- }
121
- isRunning = true;
122
- Promise.all(tasks).then(() => {
123
- (0, poku_js_1.poku)(dirs, options)
124
- .then(() => {
125
- if (watchMode) {
126
- node_process_1.default.stdin.removeListener('data', listenStdin);
127
- node_process_1.default.removeListener('SIGINT', poku_js_1.onSigint);
128
- resultsClear();
129
- (0, map_tests_js_1.mapTests)('.', dirs, options.filter, options.exclude).then((mappedTests) => {
130
- for (const mappedTest of Array.from(mappedTests.keys())) {
131
- const currentWatcher = (0, watch_js_1.watch)(mappedTest, (file, event) => {
119
+ const watchers = new Set();
120
+ const executing = new Set();
121
+ const interval = Number((0, get_arg_js_1.getArg)('watch-interval')) || 1500;
122
+ let isRunning = false;
123
+ const listenStdin = (input) => {
124
+ if (isRunning || executing.size > 0) {
125
+ return;
126
+ }
127
+ if (String(input).trim() === 'rs') {
128
+ for (const watcher of watchers) {
129
+ watcher.stop();
130
+ }
131
+ watchers.clear();
132
+ resultsClear();
133
+ startTests();
134
+ }
135
+ };
136
+ const resultsClear = () => {
137
+ files_js_1.fileResults.success.clear();
138
+ files_js_1.fileResults.fail.clear();
139
+ };
140
+ const startTests = () => {
141
+ if (isRunning || executing.size > 0) {
142
+ return;
143
+ }
144
+ isRunning = true;
145
+ Promise.all(tasks).then(() => {
146
+ (0, poku_js_1.poku)(dirs, options)
147
+ .then(() => {
148
+ if (watchMode) {
149
+ node_process_1.default.stdin.removeListener('data', listenStdin);
150
+ node_process_1.default.removeListener('SIGINT', poku_js_1.onSigint);
151
+ resultsClear();
152
+ (0, map_tests_js_1.mapTests)('.', dirs, options.filter, options.exclude).then((mappedTests) => {
153
+ for (const mappedTest of Array.from(mappedTests.keys())) {
154
+ const currentWatcher = (0, watch_js_1.watch)(mappedTest, (file, event) => {
155
+ if (event === 'change') {
156
+ const filePath = (0, map_tests_js_1.normalizePath)(file);
157
+ if (executing.has(filePath)) {
158
+ return;
159
+ }
160
+ executing.add(filePath);
161
+ resultsClear();
162
+ const tests = mappedTests.get(filePath);
163
+ if (!tests) {
164
+ return;
165
+ }
166
+ (0, poku_js_1.poku)(Array.from(tests), options).then(() => {
167
+ setTimeout(() => {
168
+ executing.delete(filePath);
169
+ }, interval);
170
+ });
171
+ }
172
+ });
173
+ currentWatcher.then((watcher) => watchers.add(watcher));
174
+ }
175
+ });
176
+ for (const dir of dirs) {
177
+ const currentWatcher = (0, watch_js_1.watch)(dir, (file, event) => {
132
178
  if (event === 'change') {
133
- const filePath = (0, map_tests_js_1.normalizePath)(file);
134
- if (executing.has(filePath)) {
179
+ if (executing.has(file)) {
135
180
  return;
136
181
  }
137
- executing.add(filePath);
182
+ executing.add(file);
138
183
  resultsClear();
139
- const tests = mappedTests.get(filePath);
140
- if (!tests) {
141
- return;
142
- }
143
- (0, poku_js_1.poku)(Array.from(tests), options).then(() => {
184
+ (0, poku_js_1.poku)(file, options).then(() => {
144
185
  setTimeout(() => {
145
- executing.delete(filePath);
186
+ executing.delete(file);
146
187
  }, interval);
147
188
  });
148
189
  }
149
190
  });
150
191
  currentWatcher.then((watcher) => watchers.add(watcher));
151
192
  }
152
- });
153
- for (const dir of dirs) {
154
- const currentWatcher = (0, watch_js_1.watch)(dir, (file, event) => {
155
- if (event === 'change') {
156
- if (executing.has(file)) {
157
- return;
158
- }
159
- executing.add(file);
160
- resultsClear();
161
- (0, poku_js_1.poku)(file, options).then(() => {
162
- setTimeout(() => {
163
- executing.delete(file);
164
- }, interval);
165
- });
166
- }
167
- });
168
- currentWatcher.then((watcher) => watchers.add(watcher));
193
+ write_js_1.Write.hr();
194
+ write_js_1.Write.log(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
195
+ node_process_1.default.stdin.setEncoding('utf-8');
196
+ node_process_1.default.stdin.on('data', listenStdin);
169
197
  }
170
- write_js_1.Write.hr();
171
- write_js_1.Write.log(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
172
- node_process_1.default.stdin.setEncoding('utf-8');
173
- node_process_1.default.stdin.on('data', listenStdin);
174
- }
175
- })
176
- .finally(() => {
177
- isRunning = false;
198
+ })
199
+ .finally(() => {
200
+ isRunning = false;
201
+ });
178
202
  });
179
- });
180
- };
181
- startTests();
203
+ };
204
+ startTests();
205
+ })();
@@ -1,4 +1,4 @@
1
1
  export declare function it(message: string, cb: () => Promise<unknown>): Promise<void>;
2
- export declare function it(message: string, cb: () => unknown): Promise<void>;
2
+ export declare function it(message: string, cb: () => unknown): void;
3
3
  export declare function it(cb: () => Promise<unknown>): Promise<void>;
4
4
  export declare function it(cb: () => unknown): void;
@@ -1,4 +1,4 @@
1
1
  export declare function test(message: string, cb: () => Promise<unknown>): Promise<void>;
2
- export declare function test(message: string, cb: () => unknown): Promise<void>;
2
+ export declare function test(message: string, cb: () => unknown): void;
3
3
  export declare function test(cb: () => Promise<unknown>): Promise<void>;
4
4
  export declare function test(cb: () => unknown): void;
@@ -1,3 +1,4 @@
1
+ import type { ConfigFile } from '../@types/poku.js';
1
2
  export { poku } from './essentials/poku.js';
2
3
  export { assert } from './essentials/assert.js';
3
4
  export { strict } from './essentials/strict.js';
@@ -21,3 +22,5 @@ export type { DockerComposeConfigs, DockerfileConfigs, } from '../@types/contain
21
22
  export type { StartServiceOptions, StartScriptOptions, } from '../@types/background-process.js';
22
23
  export type { WaitForExpectedResultOptions, WaitForPortOptions, } from '../@types/wait-for.js';
23
24
  export type { Configs as ListFilesConfigs } from '../@types/list-files.js';
25
+ /** ๐Ÿท Auxiliary function to define the `poku` configurations */
26
+ export declare const defineConfig: (options: ConfigFile) => ConfigFile;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listFiles = exports.log = exports.exit = exports.getPIDs = exports.kill = exports.sleep = exports.waitForPort = exports.waitForExpectedResult = exports.startService = exports.startScript = exports.docker = exports.afterEach = exports.beforeEach = exports.skip = exports.envFile = exports.it = exports.describe = exports.test = exports.strict = exports.assert = exports.poku = void 0;
3
+ exports.defineConfig = exports.listFiles = exports.log = exports.exit = exports.getPIDs = exports.kill = exports.sleep = exports.waitForPort = exports.waitForExpectedResult = exports.startService = exports.startScript = exports.docker = exports.afterEach = exports.beforeEach = exports.skip = exports.envFile = exports.it = exports.describe = exports.test = exports.strict = exports.assert = exports.poku = void 0;
4
4
  var poku_js_1 = require("./essentials/poku.js");
5
5
  Object.defineProperty(exports, "poku", { enumerable: true, get: function () { return poku_js_1.poku; } });
6
6
  var assert_js_1 = require("./essentials/assert.js");
@@ -39,3 +39,6 @@ var log_js_1 = require("./helpers/log.js");
39
39
  Object.defineProperty(exports, "log", { enumerable: true, get: function () { return log_js_1.log; } });
40
40
  var list_files_js_1 = require("./helpers/list-files.js");
41
41
  Object.defineProperty(exports, "listFiles", { enumerable: true, get: function () { return list_files_js_1.listFiles; } });
42
+ /** ๐Ÿท Auxiliary function to define the `poku` configurations */
43
+ const defineConfig = (options) => options;
44
+ exports.defineConfig = defineConfig;
@@ -32,9 +32,9 @@ const parseResultType = (type) => {
32
32
  }
33
33
  return (0, object_js_1.fromEntries)((0, object_js_1.entries)(value).map(([key, val]) => [key, recurse(val)]));
34
34
  }
35
+ /* c8 ignore stop */
35
36
  return value;
36
37
  };
37
- /* c8 ignore stop */
38
38
  const result = recurse(type);
39
39
  return typeof result === 'string' ? result : JSON.stringify(result, null, 2);
40
40
  };
@@ -1,41 +1,4 @@
1
- /**
2
- * Gets the value of an argument.
3
- *
4
- * ---
5
- *
6
- * CLI arguments examples:
7
- *
8
- * ```sh
9
- * command --arg=some # 'some'
10
- * command --arg="" # ''
11
- * command --arg # undefined
12
- * ```
13
- */
14
1
  export declare const getArg: (arg: string, prefix?: string, baseArgs?: string[]) => string | undefined;
15
- /**
16
- * Checks if an argument exists.
17
- *
18
- * ---
19
- *
20
- * CLI arguments examples:
21
- *
22
- * ```sh
23
- * command --arg # true
24
- * command # false
25
- * ```
26
- */
27
2
  export declare const hasArg: (arg: string, prefix?: string, baseArgs?: string[]) => boolean;
28
- /**
29
- * Gets the last param/value.
30
- *
31
- * CLI arguments examples:
32
- *
33
- * ```sh
34
- * command --arg --arg2=some value # 'value'
35
- * command value # 'value'
36
- * command # undefined
37
- * command --arg # undefined
38
- * ```
39
- */
40
- export declare const getLastParam: (prefix?: string, baseArgs?: string[]) => string | undefined;
3
+ export declare const getPaths: (prefix?: string, baseArgs?: string[]) => string[] | undefined;
41
4
  export declare const argToArray: (arg: string, prefix?: string, baseArgs?: string[]) => string[] | undefined;
@@ -1,23 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.argToArray = exports.getLastParam = exports.hasArg = exports.getArg = void 0;
3
+ exports.argToArray = exports.getPaths = exports.hasArg = exports.getArg = void 0;
4
4
  /* c8 ignore next */ // ?
5
5
  const node_process_1 = require("process");
6
6
  const [, , ...processArgs] = node_process_1.argv;
7
7
  const regexQuotes = /''|""/;
8
- /**
9
- * Gets the value of an argument.
10
- *
11
- * ---
12
- *
13
- * CLI arguments examples:
14
- *
15
- * ```sh
16
- * command --arg=some # 'some'
17
- * command --arg="" # ''
18
- * command --arg # undefined
19
- * ```
20
- */
21
8
  const getArg = (arg, prefix = '--', baseArgs = processArgs) => {
22
9
  const argPattern = `${prefix}${arg}=`;
23
10
  const argValue = baseArgs.find((a) => a.startsWith(argPattern));
@@ -27,43 +14,26 @@ const getArg = (arg, prefix = '--', baseArgs = processArgs) => {
27
14
  return argValue.slice(argPattern.length).replace(regexQuotes, '');
28
15
  };
29
16
  exports.getArg = getArg;
30
- /**
31
- * Checks if an argument exists.
32
- *
33
- * ---
34
- *
35
- * CLI arguments examples:
36
- *
37
- * ```sh
38
- * command --arg # true
39
- * command # false
40
- * ```
41
- */
42
17
  const hasArg = (arg, prefix = '--', baseArgs = processArgs) => {
43
18
  const argPattern = `${prefix}${arg}`;
44
19
  return baseArgs.some((a) => a.startsWith(argPattern));
45
20
  };
46
21
  exports.hasArg = hasArg;
47
- /**
48
- * Gets the last param/value.
49
- *
50
- * CLI arguments examples:
51
- *
52
- * ```sh
53
- * command --arg --arg2=some value # 'value'
54
- * command value # 'value'
55
- * command # undefined
56
- * command --arg # undefined
57
- * ```
58
- */
59
- const getLastParam = (prefix = '--', baseArgs = processArgs) => {
60
- const lastArg = baseArgs[baseArgs.length - 1];
61
- if (!lastArg || lastArg.startsWith(prefix)) {
62
- return undefined;
22
+ const getPaths = (prefix = '--', baseArgs = processArgs) => {
23
+ let hasPaths = false;
24
+ const paths = [];
25
+ for (const arg of baseArgs) {
26
+ if (!arg.startsWith(prefix)) {
27
+ hasPaths = true;
28
+ const parts = arg.split(',');
29
+ for (const part of parts) {
30
+ paths.push(part);
31
+ }
32
+ }
63
33
  }
64
- return lastArg;
34
+ return hasPaths ? paths : undefined;
65
35
  };
66
- exports.getLastParam = getLastParam;
36
+ exports.getPaths = getPaths;
67
37
  /* c8 ignore next */ // ?
68
38
  const argToArray = (arg, prefix = '--', baseArgs = processArgs) => {
69
39
  const hasArgument = (0, exports.hasArg)(arg, prefix, baseArgs);
@@ -0,0 +1,2 @@
1
+ import type { ConfigFile, ConfigJSONFile } from '../@types/poku.js';
2
+ export declare const getConfigs: (customPath?: string) => Promise<ConfigFile | ConfigJSONFile>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getConfigs = void 0;
27
+ const node_process_1 = require("process");
28
+ const node_path_1 = require("path");
29
+ const fs_js_1 = require("../polyfills/fs.js");
30
+ const jsonc_js_1 = require("../polyfills/jsonc.js");
31
+ const processCWD = (0, node_process_1.cwd)();
32
+ /* c8 ignore next */ // ?
33
+ const getConfigs = async (customPath) => {
34
+ const expectedFiles = customPath
35
+ ? [customPath]
36
+ : new Set([
37
+ 'poku.config.js',
38
+ 'poku.config.cjs',
39
+ '.pokurc.json',
40
+ '.pokurc.jsonc',
41
+ ]);
42
+ for (const file of expectedFiles) {
43
+ const filePath = (0, node_path_1.join)(processCWD, file);
44
+ try {
45
+ if (filePath.endsWith('.js') || filePath.endsWith('.cjs')) {
46
+ /* c8 ignore next */ // ?
47
+ return (await Promise.resolve(`${(0, node_path_1.normalize)(filePath)}`).then(s => __importStar(require(s))));
48
+ }
49
+ const configsFile = await (0, fs_js_1.readFile)(filePath, 'utf-8');
50
+ return jsonc_js_1.JSONC.parse(configsFile);
51
+ }
52
+ catch (_a) { }
53
+ }
54
+ return {};
55
+ };
56
+ exports.getConfigs = getConfigs;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Adapted from https://github.com/wellwelwel/jsonc.min
3
+ */
4
+ declare class JsoncProcessor {
5
+ toJSON(content: string): string;
6
+ parse<T = unknown>(text: string): T;
7
+ }
8
+ export declare const JSONC: JsoncProcessor;
9
+ export {};
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JSONC = void 0;
4
+ /**
5
+ * Adapted from https://github.com/wellwelwel/jsonc.min
6
+ */
7
+ class JsoncProcessor {
8
+ toJSON(content) {
9
+ const length = content.length;
10
+ let inBlockComment = false;
11
+ let inString = false;
12
+ let skipChar = false;
13
+ let result = '';
14
+ for (let i = 0; i < length; i++) {
15
+ const char = content[i];
16
+ if (skipChar) {
17
+ skipChar = false;
18
+ continue;
19
+ }
20
+ if (inBlockComment) {
21
+ if (char === '*' && content[i + 1] === '/') {
22
+ inBlockComment = false;
23
+ skipChar = true;
24
+ }
25
+ continue;
26
+ }
27
+ if (inString) {
28
+ if (char === '"' && content[i - 1] !== '\\') {
29
+ inString = false;
30
+ }
31
+ result += char;
32
+ continue;
33
+ }
34
+ if (char === '"') {
35
+ inString = true;
36
+ result += char;
37
+ continue;
38
+ }
39
+ if (char === '/' && content[i + 1] === '*') {
40
+ inBlockComment = true;
41
+ skipChar = true;
42
+ continue;
43
+ }
44
+ if (char === '/' && content[i + 1] === '/') {
45
+ while (i < length && content[i] !== '\n') {
46
+ i++;
47
+ }
48
+ continue;
49
+ }
50
+ result += char;
51
+ }
52
+ return result;
53
+ }
54
+ parse(text) {
55
+ const cleanContent = this.toJSON(text);
56
+ return JSON.parse(cleanContent);
57
+ }
58
+ }
59
+ exports.JSONC = new JsoncProcessor();
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "poku",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "๐Ÿท Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.",
5
5
  "main": "./lib/modules/index.js",
6
6
  "license": "MIT",
7
- "type": "commonjs",
8
7
  "bin": {
9
8
  "poku": "./lib/bin/index.js"
10
9
  },
@@ -34,12 +33,12 @@
34
33
  "test": "npm run test:parallel && npm run test:sequential",
35
34
  "test:bun": "npm run test:bun:parallel && npm run test:bun:sequential",
36
35
  "test:deno": "npm run test:deno:parallel && npm run test:deno:sequential",
37
- "test:sequential": "tsx src/bin/index.ts --include=test/unit,test/integration,test/e2e",
38
- "test:parallel": "tsx src/bin/index.ts --parallel --include=test/unit,test/integration,test/e2e",
39
- "test:bun:sequential": "bun src/bin/index.ts --platform=bun --include=test/unit,test/integration,test/e2e",
40
- "test:bun:parallel": "bun src/bin/index.ts --platform=bun --parallel --include=test/unit,test/integration,test/e2e",
41
- "test:deno:sequential": "tsx src/bin/index.ts --platform=deno --deno-allow=all --deno-cjs --include=ci/test/unit,ci/test/integration,ci/test/e2e",
42
- "test:deno:parallel": "tsx src/bin/index.ts --platform=deno --deno-allow=all --deno-cjs --parallel --include=ci/test/unit,ci/test/integration,ci/test/e2e",
36
+ "test:sequential": "tsx src/bin/index.ts test/unit test/integration test/e2e",
37
+ "test:parallel": "tsx src/bin/index.ts -p test/unit test/integration test/e2e",
38
+ "test:bun:sequential": "bun src/bin/index.ts --bun test/unit test/integration test/e2e",
39
+ "test:bun:parallel": "bun src/bin/index.ts --bun -p test/unit test/integration test/e2e",
40
+ "test:deno:sequential": "tsx src/bin/index.ts --deno --deno-allow=all --deno-cjs ci/test/unit ci/test/integration ci/test/e2e",
41
+ "test:deno:parallel": "tsx src/bin/index.ts --deno --deno-allow=all --deno-cjs -p ci/test/unit ci/test/integration ci/test/e2e",
43
42
  "test:c8": "c8 tsx test/c8.test.ts",
44
43
  "test:ci": "tsx test/ci.test.ts",
45
44
  "test:ci:node": "FILTER='node-' npm run test:ci",
@@ -47,26 +46,24 @@
47
46
  "test:ci:deno": "FILTER='deno-' npm run test:ci",
48
47
  "predocker:deno": "docker compose -f test/docker/playground/deno/docker-compose.yml down",
49
48
  "docker:deno": "docker compose -f test/docker/playground/deno/docker-compose.yml up --build",
50
- "clear": "rm -rf lib ci coverage",
49
+ "clear": "rm -rf lib ci coverage .temp test-src test-tests",
51
50
  "prebuild": "npm run clear",
52
51
  "build": "tsc && tsc -p tsconfig.test.json",
53
52
  "postbuild": "tsx tools/compatibility/node.ts && cp fixtures/server/package.json ci/fixtures/server/package.json && npm run build:deno && chmod +x lib/bin/index.js",
54
53
  "build:deno": "tsc -p tsconfig.mjs.json",
55
54
  "postbuild:deno": "tsx tools/build/check-deno-polyfill.ts",
56
- "prettier:check": "prettier --check .",
57
- "prettier:fix": "prettier --write .github/workflows/*.yml .",
58
- "lint:check": "npx @biomejs/biome lint && npm run prettier:check",
59
- "lint:fix": "npx @biomejs/biome lint --write && npm run prettier:fix",
55
+ "lint": "npx @biomejs/biome lint && prettier --check .",
56
+ "lint:fix": "npx @biomejs/biome lint --write && prettier --write .github/workflows/*.yml .",
60
57
  "update": "pu minor && npm i && npm audit fix",
61
58
  "postupdate": "npm run lint:fix",
62
59
  "benchmark": "cd benchmark && npm ci && npm start"
63
60
  },
64
61
  "devDependencies": {
65
62
  "@biomejs/biome": "1.8.3",
66
- "@types/node": "^20.14.10",
63
+ "@types/node": "^20.14.11",
67
64
  "c8": "^10.1.2",
68
65
  "packages-update": "^2.0.0",
69
- "prettier": "^3.3.2",
66
+ "prettier": "^3.3.3",
70
67
  "tsx": "4.16.2",
71
68
  "typescript": "^5.5.3"
72
69
  },
@@ -117,9 +114,8 @@
117
114
  "esmodules",
118
115
  "esm",
119
116
  "mjs",
120
- "framework",
121
- "tool",
122
117
  "runtime",
123
- "poku"
118
+ "poku",
119
+ "pokujs"
124
120
  ]
125
121
  }