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.
- package/README.md +17 -15
- package/lib/@types/background-process.d.ts +1 -7
- package/lib/@types/poku.d.ts +2 -8
- package/lib/bin/help.js +9 -19
- package/lib/bin/index.js +75 -98
- package/lib/bin/watch.js +11 -10
- package/lib/builders/assert.js +1 -8
- package/lib/configs/files.js +2 -2
- package/lib/configs/poku.d.ts +11 -0
- package/lib/configs/poku.js +13 -2
- package/lib/modules/essentials/poku.js +10 -35
- package/lib/modules/helpers/create-service.js +19 -20
- package/lib/modules/helpers/describe.js +17 -9
- package/lib/modules/helpers/each.js +1 -1
- package/lib/modules/helpers/env.js +2 -2
- package/lib/modules/helpers/exit.js +8 -8
- package/lib/modules/helpers/it/core.js +11 -8
- package/lib/modules/helpers/list-files.js +29 -20
- package/lib/modules/helpers/log.js +1 -1
- package/lib/modules/helpers/modifiers.js +12 -7
- package/lib/modules/helpers/skip.js +3 -3
- package/lib/modules/helpers/wait-for.js +6 -6
- package/lib/parsers/assert.js +2 -3
- package/lib/parsers/callback.d.ts +2 -0
- package/lib/parsers/callback.js +21 -0
- package/lib/parsers/find-file-from-stack.js +3 -4
- package/lib/parsers/get-arg.d.ts +0 -2
- package/lib/parsers/get-arg.js +10 -19
- package/lib/parsers/get-runner.d.ts +1 -2
- package/lib/parsers/get-runner.js +9 -16
- package/lib/parsers/get-runtime.d.ts +2 -4
- package/lib/parsers/get-runtime.js +5 -10
- package/lib/parsers/options.js +12 -8
- package/lib/parsers/output.d.ts +0 -4
- package/lib/parsers/output.js +5 -10
- package/lib/polyfills/deno.mjs +5 -7
- package/lib/polyfills/os.js +3 -6
- package/lib/services/assert.js +15 -18
- package/lib/services/container.js +5 -5
- package/lib/services/each.d.ts +2 -3
- package/lib/services/each.js +17 -17
- package/lib/services/enforce.d.ts +1 -0
- package/lib/services/enforce.js +131 -0
- package/lib/services/env.js +1 -2
- package/lib/services/format.js +3 -3
- package/lib/services/map-tests.js +5 -6
- package/lib/services/run-test-file.d.ts +1 -2
- package/lib/services/run-test-file.js +12 -20
- package/lib/services/run-tests.d.ts +1 -3
- package/lib/services/run-tests.js +52 -94
- package/lib/services/watch.js +5 -5
- package/lib/services/write.d.ts +2 -4
- package/lib/services/write.js +7 -7
- package/package.json +18 -23
- package/lib/bin/enforce.js +0 -53
- package/lib/parsers/to-dynamic-case.d.ts +0 -1
- package/lib/parsers/to-dynamic-case.js +0 -13
- package/lib/polyfills/fs.d.ts +0 -4
- package/lib/polyfills/fs.js +0 -8
- package/lib/polyfills/object.d.ts +0 -12
- 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
|
-
[](https://www.npmjs.com/package/poku)
|
|
8
|
+
[](https://www.npmjs.com/package/poku/v/3.0.0-rc.0)
|
|
9
|
+
[](https://www.npmjs.com/package/poku/v/3.0.0-rc.0)
|
|
10
10
|
[](https://github.com/wellwelwel/poku/tree/main/.nycrc)<br />
|
|
11
11
|
[](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-linux.yml?query=branch%3Amain)
|
|
12
12
|
[](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> โข </span>๐ [Documentation](https://poku.io/docs
|
|
17
|
+
๐ท [Website](https://poku.io/)<span> โข </span>๐ [Documentation](https://poku.io/docs)<span> โข </span>๐งช [Examples](https://poku.io/docs/category/examples)<span> โข </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
|
-
|
|
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 **
|
|
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 {};
|
package/lib/@types/poku.d.ts
CHANGED
|
@@ -31,13 +31,7 @@ export type Configs = {
|
|
|
31
31
|
*
|
|
32
32
|
* @default false
|
|
33
33
|
*/
|
|
34
|
-
|
|
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
|
|
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 =
|
|
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.
|
|
88
|
-
write_js_1.
|
|
89
|
-
write_js_1.
|
|
90
|
-
write_js_1.
|
|
91
|
-
write_js_1.
|
|
92
|
-
write_js_1.
|
|
93
|
-
write_js_1.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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 = (
|
|
47
|
-
const denoDeny = (
|
|
48
|
-
const denoCJS = (
|
|
49
|
-
(
|
|
50
|
-
((
|
|
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
|
|
53
|
-
const
|
|
54
|
-
const
|
|
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)('
|
|
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) ?
|
|
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)('
|
|
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.
|
|
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.
|
|
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.
|
|
84
|
-
write_js_1.
|
|
85
|
-
write_js_1.
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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 ||
|
|
95
|
-
const ports =
|
|
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 ||
|
|
99
|
-
const ranges =
|
|
100
|
-
|
|
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 ||
|
|
110
|
-
const PIDs =
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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.
|
|
153
|
-
write_js_1.
|
|
154
|
-
console.dir(
|
|
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
|
|
158
|
-
if (watchMode)
|
|
159
|
-
|
|
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
|
|
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)('
|
|
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
|
|
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,
|
|
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
|
-
...
|
|
58
|
-
concurrency:
|
|
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
|
|
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.
|
|
85
|
-
write_js_1.
|
|
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
|
};
|
package/lib/builders/assert.js
CHANGED
|
@@ -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',
|
package/lib/configs/files.js
CHANGED
|
@@ -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);
|
package/lib/configs/poku.d.ts
CHANGED
|
@@ -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
|
+
};
|
package/lib/configs/poku.js
CHANGED
|
@@ -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 = '
|
|
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
|
+
};
|