poku 2.7.1 → 3.0.0-rc.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 +5 -6
- package/lib/@types/background-process.d.ts +1 -7
- package/lib/@types/poku.d.ts +2 -8
- package/lib/bin/enforce.js +1 -6
- package/lib/bin/help.js +1 -11
- package/lib/bin/index.js +35 -55
- package/lib/bin/watch.js +3 -3
- package/lib/builders/assert.js +1 -8
- package/lib/configs/poku.d.ts +3 -0
- package/lib/configs/poku.js +6 -2
- package/lib/modules/essentials/poku.js +6 -31
- package/lib/modules/helpers/create-service.js +19 -20
- package/lib/modules/helpers/describe.js +4 -4
- package/lib/modules/helpers/each.js +1 -1
- package/lib/modules/helpers/env.js +2 -2
- package/lib/modules/helpers/it/core.js +2 -2
- package/lib/modules/helpers/list-files.js +29 -20
- package/lib/modules/helpers/skip.js +2 -2
- package/lib/modules/helpers/wait-for.js +6 -6
- package/lib/parsers/assert.js +2 -3
- package/lib/parsers/find-file-from-stack.js +3 -4
- package/lib/parsers/get-arg.js +7 -10
- package/lib/parsers/get-runner.js +5 -13
- package/lib/parsers/get-runtime.d.ts +2 -4
- package/lib/parsers/get-runtime.js +5 -10
- package/lib/parsers/options.js +5 -6
- package/lib/parsers/output.js +4 -4
- package/lib/polyfills/deno.mjs +5 -7
- package/lib/polyfills/os.js +3 -6
- package/lib/services/assert.js +9 -9
- package/lib/services/container.js +3 -3
- package/lib/services/each.js +3 -3
- package/lib/services/env.js +1 -2
- package/lib/services/map-tests.js +5 -6
- package/lib/services/run-test-file.js +5 -12
- package/lib/services/run-tests.d.ts +0 -1
- package/lib/services/run-tests.js +48 -85
- package/lib/services/watch.js +5 -5
- package/package.json +17 -22
- 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
|
@@ -18,6 +18,10 @@ Enjoying **Poku**? Give him a star to show your support 🌟
|
|
|
18
18
|
|
|
19
19
|
</div>
|
|
20
20
|
|
|
21
|
+
> [!IMPORTANT]
|
|
22
|
+
>
|
|
23
|
+
> [**Version 3**](https://github.com/wellwelwel/poku/issues/801) is on its way! You can already try it by installing the Release Candidate with `poku@rc` 💡
|
|
24
|
+
|
|
21
25
|
---
|
|
22
26
|
|
|
23
27
|
## Why does Poku exist?
|
|
@@ -26,7 +30,6 @@ Enjoying **Poku**? Give him a star to show your support 🌟
|
|
|
26
30
|
|
|
27
31
|
</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
32
|
</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
33
|
<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
34
|
<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
35
|
<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** ✨
|
|
@@ -118,7 +121,7 @@ npx poku
|
|
|
118
121
|
<td width="400">
|
|
119
122
|
|
|
120
123
|
```bash
|
|
121
|
-
|
|
124
|
+
bun poku
|
|
122
125
|
```
|
|
123
126
|
|
|
124
127
|
</td>
|
|
@@ -213,10 +216,6 @@ deno run npm:poku
|
|
|
213
216
|
<td width="280"><a href="https://poku.io/docs/documentation/poku/options/watch">watch</a></td>
|
|
214
217
|
<td width="770">🍿 Watch for changes and re-run related test files.</td>
|
|
215
218
|
</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
219
|
<tr>
|
|
221
220
|
<td><a href="https://poku.io/docs/documentation/poku/options/debug">debug</a></td>
|
|
222
221
|
<td>🕵🏻 Shows all logs.</td>
|
|
@@ -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/enforce.js
CHANGED
|
@@ -6,11 +6,9 @@ const write_js_1 = require("../services/write.js");
|
|
|
6
6
|
const format_js_1 = require("../services/format.js");
|
|
7
7
|
const checkFlags = () => {
|
|
8
8
|
const allowedFlags = new Set([
|
|
9
|
-
'--bun',
|
|
10
9
|
'--concurrency',
|
|
11
10
|
'--config',
|
|
12
11
|
'--debug',
|
|
13
|
-
'--deno',
|
|
14
12
|
'--denoAllow',
|
|
15
13
|
'--denoCjs',
|
|
16
14
|
'--denoDeny',
|
|
@@ -22,16 +20,13 @@ const checkFlags = () => {
|
|
|
22
20
|
'--killPid',
|
|
23
21
|
'--killPort',
|
|
24
22
|
'--killRange',
|
|
25
|
-
'--node',
|
|
26
23
|
'--only',
|
|
27
|
-
'--parallel',
|
|
28
|
-
'--platform',
|
|
29
24
|
'--quiet',
|
|
25
|
+
'--sequential',
|
|
30
26
|
'--watch',
|
|
31
27
|
'--watchInterval',
|
|
32
28
|
'-c',
|
|
33
29
|
'-d',
|
|
34
|
-
'-p',
|
|
35
30
|
'-q',
|
|
36
31
|
'-w',
|
|
37
32
|
'-x',
|
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,11 +27,9 @@ 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.'],
|
|
@@ -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')}).
|
package/lib/bin/index.js
CHANGED
|
@@ -4,7 +4,6 @@ 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");
|
|
@@ -12,7 +11,6 @@ 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");
|
|
14
13
|
(async () => {
|
|
15
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
16
14
|
if ((0, get_arg_js_1.hasArg)('version') || (0, get_arg_js_1.hasArg)('v', '-')) {
|
|
17
15
|
const { VERSION } = require('../configs/poku.js');
|
|
18
16
|
write_js_1.Write.log(VERSION);
|
|
@@ -26,44 +24,38 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
26
24
|
const enforce = (0, get_arg_js_1.hasArg)('enforce') || (0, get_arg_js_1.hasArg)('x', '-');
|
|
27
25
|
const configFile = (0, get_arg_js_1.getArg)('config') || (0, get_arg_js_1.getArg)('c', '-');
|
|
28
26
|
const defaultConfigs = await (0, options_js_1.getConfigs)(configFile);
|
|
29
|
-
const dirs = (()
|
|
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');
|
|
27
|
+
const dirs = (0, get_arg_js_1.getPaths)('-') ??
|
|
28
|
+
(defaultConfigs?.include
|
|
29
|
+
? Array.prototype.concat(defaultConfigs?.include)
|
|
30
|
+
: ['.']);
|
|
31
|
+
const filter = (0, get_arg_js_1.getArg)('filter') ?? defaultConfigs?.filter;
|
|
32
|
+
const exclude = (0, get_arg_js_1.getArg)('exclude') ?? defaultConfigs?.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') ?? defaultConfigs?.deno?.allow;
|
|
38
|
+
const denoDeny = (0, get_arg_js_1.argToArray)('denoDeny') ?? defaultConfigs?.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
|
+
defaultConfigs?.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', '-') || defaultConfigs?.quiet;
|
|
47
|
+
const debug = (0, get_arg_js_1.hasArg)('debug') || (0, get_arg_js_1.hasArg)('d', '-') || defaultConfigs?.debug;
|
|
48
|
+
const failFast = (0, get_arg_js_1.hasArg)('failFast') || defaultConfigs?.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) ? defaultConfigs
|
|
53
|
+
return Number.isNaN(value) ? defaultConfigs?.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
61
|
write_js_1.Write.hr();
|
|
@@ -91,13 +83,13 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
91
83
|
}
|
|
92
84
|
const tasks = [];
|
|
93
85
|
|
|
94
|
-
if (killPort ||
|
|
95
|
-
const ports =
|
|
86
|
+
if (killPort || defaultConfigs?.kill?.port) {
|
|
87
|
+
const ports = killPort?.split(',').map(Number) || defaultConfigs?.kill?.port || [];
|
|
96
88
|
tasks.push(kill_js_1.kill.port(ports));
|
|
97
89
|
}
|
|
98
|
-
if (killRange ||
|
|
99
|
-
const ranges =
|
|
100
|
-
|
|
90
|
+
if (killRange || defaultConfigs?.kill?.range) {
|
|
91
|
+
const ranges = killRange?.split(',') ||
|
|
92
|
+
defaultConfigs?.kill?.range?.map((range) => `${range[0]}-${range[1]}`) ||
|
|
101
93
|
[];
|
|
102
94
|
for (const range of ranges) {
|
|
103
95
|
const ports = range.split('-').map(Number);
|
|
@@ -106,32 +98,20 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
106
98
|
tasks.push(kill_js_1.kill.range(startsAt, endsAt));
|
|
107
99
|
}
|
|
108
100
|
}
|
|
109
|
-
if (killPID ||
|
|
110
|
-
const PIDs =
|
|
101
|
+
if (killPID || defaultConfigs?.kill?.pid) {
|
|
102
|
+
const PIDs = killPID?.split(',').map(Number) || defaultConfigs?.kill?.pid || [];
|
|
111
103
|
tasks.push(kill_js_1.kill.pid(PIDs));
|
|
112
104
|
}
|
|
113
105
|
|
|
114
|
-
if (hasEnvFile ||
|
|
115
|
-
const envFilePath = (
|
|
106
|
+
if (hasEnvFile || defaultConfigs?.envFile) {
|
|
107
|
+
const envFilePath = (0, get_arg_js_1.getArg)('envFile') ?? defaultConfigs?.envFile;
|
|
116
108
|
tasks.push((0, env_js_1.envFile)(envFilePath));
|
|
117
109
|
}
|
|
118
110
|
const options = {
|
|
119
|
-
|
|
120
|
-
platform: (0, get_runtime_js_1.platformIsValid)(platform)
|
|
121
|
-
? platform
|
|
122
|
-
: (0, get_arg_js_1.hasArg)('node')
|
|
123
|
-
? 'node'
|
|
124
|
-
: (0, get_arg_js_1.hasArg)('bun')
|
|
125
|
-
? 'bun'
|
|
126
|
-
: (0, get_arg_js_1.hasArg)('deno')
|
|
127
|
-
? 'deno'
|
|
128
|
-
: (0, get_runtime_js_1.platformIsValid)(defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.platform)
|
|
129
|
-
? defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.platform
|
|
130
|
-
: undefined,
|
|
131
111
|
filter: typeof filter === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(filter)) : filter,
|
|
132
112
|
exclude: typeof exclude === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(exclude)) : exclude,
|
|
133
|
-
parallel,
|
|
134
113
|
concurrency,
|
|
114
|
+
sequential,
|
|
135
115
|
quiet,
|
|
136
116
|
debug,
|
|
137
117
|
failFast,
|
|
@@ -144,7 +124,7 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
144
124
|
beforeEach: 'beforeEach' in defaultConfigs ? defaultConfigs.beforeEach : undefined,
|
|
145
125
|
afterEach: 'afterEach' in defaultConfigs ? defaultConfigs.afterEach : undefined,
|
|
146
126
|
};
|
|
147
|
-
if (debug ||
|
|
127
|
+
if (debug || defaultConfigs?.debug) {
|
|
148
128
|
write_js_1.Write.hr();
|
|
149
129
|
write_js_1.Write.log(`${(0, format_js_1.format)(' Debug Enabled ').bg('brightBlue')}\n`);
|
|
150
130
|
write_js_1.Write.log(`${(0, format_js_1.format)('…').info().italic()} ${(0, format_js_1.format)('Paths').bold()}`);
|
package/lib/bin/watch.js
CHANGED
|
@@ -17,7 +17,7 @@ const startWatch = async (dirs, options) => {
|
|
|
17
17
|
let isRunning = false;
|
|
18
18
|
const watchers = new Set();
|
|
19
19
|
const executing = new Set();
|
|
20
|
-
const interval = Number((0, get_arg_js_1.getArg)('
|
|
20
|
+
const interval = Number((0, get_arg_js_1.getArg)('watchInterval')) || 1500;
|
|
21
21
|
const setIsRunning = (value) => {
|
|
22
22
|
isRunning = value;
|
|
23
23
|
};
|
|
@@ -42,7 +42,6 @@ const startWatch = async (dirs, options) => {
|
|
|
42
42
|
const mappedTests = await (0, map_tests_js_1.mapTests)('.', dirs, options.filter, options.exclude);
|
|
43
43
|
for (const mappedTest of Array.from(mappedTests.keys())) {
|
|
44
44
|
const currentWatcher = (0, watch_js_1.watch)(mappedTest, async (file, event) => {
|
|
45
|
-
var _a;
|
|
46
45
|
if (event === 'change') {
|
|
47
46
|
const filePath = (0, map_tests_js_1.normalizePath)(file);
|
|
48
47
|
if (executing.has(filePath) || isRunning || executing.size > 0)
|
|
@@ -55,7 +54,8 @@ const startWatch = async (dirs, options) => {
|
|
|
55
54
|
return;
|
|
56
55
|
await (0, poku_js_1.poku)(Array.from(tests), {
|
|
57
56
|
...options,
|
|
58
|
-
concurrency:
|
|
57
|
+
concurrency: options.concurrency ??
|
|
58
|
+
Math.max(Math.floor((0, os_js_1.availableParallelism)() / 2), 1),
|
|
59
59
|
});
|
|
60
60
|
setTimeout(() => {
|
|
61
61
|
executing.delete(filePath);
|
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/poku.d.ts
CHANGED
package/lib/configs/poku.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
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.0';
|
|
11
12
|
exports.deepOptions = [];
|
|
13
|
+
exports.GLOBAL = {
|
|
14
|
+
cwd: (0, node_process_1.cwd)(),
|
|
15
|
+
};
|
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.onSigint = void 0;
|
|
7
7
|
exports.poku = poku;
|
|
8
8
|
const node_process_1 = __importDefault(require("process"));
|
|
9
|
-
const run_tests_js_1 = require("../../services/run-tests.js");
|
|
10
9
|
const write_js_1 = require("../../services/write.js");
|
|
11
10
|
const exit_js_1 = require("../helpers/exit.js");
|
|
12
11
|
const format_js_1 = require("../../services/format.js");
|
|
13
12
|
const output_js_1 = require("../../parsers/output.js");
|
|
14
13
|
const files_js_1 = require("../../configs/files.js");
|
|
14
|
+
const run_tests_js_1 = require("../../services/run-tests.js");
|
|
15
15
|
|
|
16
16
|
const onSigint = () => node_process_1.default.stdout.write('\u001B[?25h');
|
|
17
17
|
exports.onSigint = onSigint;
|
|
@@ -22,42 +22,17 @@ async function poku(targetPaths, configs) {
|
|
|
22
22
|
const start = node_process_1.default.hrtime();
|
|
23
23
|
const dirs = Array.prototype.concat(targetPaths);
|
|
24
24
|
const showLogs = !(0, output_js_1.isQuiet)(configs);
|
|
25
|
-
|
|
26
|
-
if (!(configs === null || configs === void 0 ? void 0 : configs.parallel)) {
|
|
27
|
-
for (const dir of dirs) {
|
|
28
|
-
const result = await (0, run_tests_js_1.runTests)(dir, configs);
|
|
29
|
-
if (!result) {
|
|
30
|
-
code = 1;
|
|
31
|
-
if (configs === null || configs === void 0 ? void 0 : configs.failFast)
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (configs === null || configs === void 0 ? void 0 : configs.noExit)
|
|
36
|
-
return code;
|
|
37
|
-
const end = node_process_1.default.hrtime(start);
|
|
38
|
-
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
|
|
39
|
-
files_js_1.finalResults.time = total;
|
|
40
|
-
showLogs && (0, format_js_1.showTestResults)();
|
|
41
|
-
(0, exit_js_1.exit)(code, configs === null || configs === void 0 ? void 0 : configs.quiet);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
25
|
if (showLogs) {
|
|
46
26
|
write_js_1.Write.hr();
|
|
47
|
-
write_js_1.Write.log(`${(0, format_js_1.format)('Running
|
|
27
|
+
write_js_1.Write.log(`${(0, format_js_1.format)('Running Tests').bold()}\n`);
|
|
48
28
|
}
|
|
49
29
|
try {
|
|
50
|
-
const promises = dirs.map(async (dir) =>
|
|
51
|
-
const result = await (0, run_tests_js_1.runTestsParallel)(dir, configs);
|
|
52
|
-
if (!result && (configs === null || configs === void 0 ? void 0 : configs.failFast))
|
|
53
|
-
throw new Error('quiet');
|
|
54
|
-
return result;
|
|
55
|
-
});
|
|
30
|
+
const promises = dirs.map(async (dir) => await (0, run_tests_js_1.runTests)(dir, configs));
|
|
56
31
|
const concurrency = await Promise.all(promises);
|
|
57
32
|
if (concurrency.some((result) => !result))
|
|
58
33
|
code = 1;
|
|
59
34
|
}
|
|
60
|
-
catch
|
|
35
|
+
catch {
|
|
61
36
|
}
|
|
62
37
|
finally {
|
|
63
38
|
const end = node_process_1.default.hrtime(start);
|
|
@@ -65,7 +40,7 @@ async function poku(targetPaths, configs) {
|
|
|
65
40
|
files_js_1.finalResults.time = total;
|
|
66
41
|
}
|
|
67
42
|
showLogs && (0, format_js_1.showTestResults)();
|
|
68
|
-
if (configs
|
|
43
|
+
if (configs?.noExit)
|
|
69
44
|
return code;
|
|
70
|
-
(0, exit_js_1.exit)(code, configs
|
|
45
|
+
(0, exit_js_1.exit)(code, configs?.quiet);
|
|
71
46
|
}
|
|
@@ -18,8 +18,8 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
|
|
|
18
18
|
const service = (0, node_child_process_1.spawn)(runtime, args, {
|
|
19
19
|
stdio: ['inherit', 'pipe', 'pipe'],
|
|
20
20
|
env: node_process_1.default.env,
|
|
21
|
-
timeout: options
|
|
22
|
-
cwd:
|
|
21
|
+
timeout: options?.timeout,
|
|
22
|
+
cwd: options?.cwd ? (0, list_files_js_1.sanitizePath)((0, node_path_1.normalize)(options.cwd)) : undefined,
|
|
23
23
|
shell: get_runner_js_1.isWindows,
|
|
24
24
|
detached: !get_runner_js_1.isWindows,
|
|
25
25
|
windowsHide: get_runner_js_1.isWindows,
|
|
@@ -36,7 +36,7 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
|
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
if (['bun', 'deno'].includes(runtime) ||
|
|
39
|
-
['bun', 'deno'].includes(String(options
|
|
39
|
+
['bun', 'deno'].includes(String(options?.runner)))
|
|
40
40
|
node_process_1.default.kill(PID);
|
|
41
41
|
else
|
|
42
42
|
node_process_1.default.kill(-PID, 'SIGKILL');
|
|
@@ -52,37 +52,37 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
|
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
catch
|
|
55
|
+
catch {
|
|
56
56
|
resolve(undefined);
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
runningProcesses.set(PID, { end, port: portBackup });
|
|
61
61
|
service.stdout.on('data', (data) => {
|
|
62
|
-
if (!isResolved && typeof
|
|
62
|
+
if (!isResolved && typeof options?.startAfter !== 'number') {
|
|
63
63
|
const stringData = JSON.stringify(String(data));
|
|
64
|
-
if (typeof
|
|
65
|
-
(typeof
|
|
66
|
-
stringData.includes(options
|
|
64
|
+
if (typeof options?.startAfter === 'undefined' ||
|
|
65
|
+
(typeof options?.startAfter === 'string' &&
|
|
66
|
+
stringData.includes(options?.startAfter))) {
|
|
67
67
|
resolve({ end });
|
|
68
68
|
clearTimeout(timeout);
|
|
69
69
|
isResolved = true;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
options?.verbose && write_js_1.Write.log(data);
|
|
73
73
|
});
|
|
74
74
|
service.stderr.on('data', (data) => {
|
|
75
|
-
if (!isResolved && typeof
|
|
75
|
+
if (!isResolved && typeof options?.startAfter !== 'number') {
|
|
76
76
|
const stringData = JSON.stringify(String(data));
|
|
77
|
-
if (typeof
|
|
78
|
-
(typeof
|
|
79
|
-
stringData.includes(options
|
|
77
|
+
if (typeof options?.startAfter === 'undefined' ||
|
|
78
|
+
(typeof options?.startAfter === 'string' &&
|
|
79
|
+
stringData.includes(options?.startAfter))) {
|
|
80
80
|
resolve({ end });
|
|
81
81
|
clearTimeout(timeout);
|
|
82
82
|
isResolved = true;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
options?.verbose && write_js_1.Write.log(data);
|
|
86
86
|
});
|
|
87
87
|
service.on('error', (err) => {
|
|
88
88
|
end(portBackup);
|
|
@@ -97,8 +97,8 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
|
|
|
97
97
|
end(portBackup);
|
|
98
98
|
reject(`createService: Timeout\nFile: ${file}`);
|
|
99
99
|
}
|
|
100
|
-
},
|
|
101
|
-
if (typeof
|
|
100
|
+
}, options?.timeout || 60000);
|
|
101
|
+
if (typeof options?.startAfter === 'number')
|
|
102
102
|
setTimeout(() => {
|
|
103
103
|
if (!isResolved) {
|
|
104
104
|
resolve({ end });
|
|
@@ -107,11 +107,11 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
|
|
|
107
107
|
}
|
|
108
108
|
}, options.startAfter);
|
|
109
109
|
}
|
|
110
|
-
catch
|
|
110
|
+
catch { }
|
|
111
111
|
});
|
|
112
112
|
/** Starts a file in a background process (useful for servers, APIs, etc.) */
|
|
113
113
|
const startService = async (file, options) => {
|
|
114
|
-
const runtimeOptions = (0, get_runner_js_1.runner)(file
|
|
114
|
+
const runtimeOptions = (0, get_runner_js_1.runner)(file);
|
|
115
115
|
const runtime = runtimeOptions.shift();
|
|
116
116
|
const runtimeArgs = [...runtimeOptions, file];
|
|
117
117
|
return await backgroundProcess(runtime, runtimeArgs, (0, node_path_1.normalize)((0, list_files_js_1.sanitizePath)(file)), options);
|
|
@@ -126,8 +126,7 @@ exports.startService = startService;
|
|
|
126
126
|
* By default it uses **npm**, but you can costumize it using the `runner` option.
|
|
127
127
|
*/
|
|
128
128
|
const startScript = async (script, options) => {
|
|
129
|
-
|
|
130
|
-
const runner = (_a = options === null || options === void 0 ? void 0 : options.runner) !== null && _a !== void 0 ? _a : 'npm';
|
|
129
|
+
const runner = options?.runner ?? 'npm';
|
|
131
130
|
const runtimeOptions = (0, get_runner_js_1.scriptRunner)(runner);
|
|
132
131
|
const runtime = runtimeOptions.shift();
|
|
133
132
|
const runtimeArgs = [...runtimeOptions, script];
|
|
@@ -12,8 +12,8 @@ async function describeBase(arg1, arg2) {
|
|
|
12
12
|
let title;
|
|
13
13
|
let cb;
|
|
14
14
|
let options;
|
|
15
|
-
const isPoku = typeof
|
|
16
|
-
const FILE = node_process_1.env.
|
|
15
|
+
const isPoku = typeof node_process_1.env?.FILE === 'string' && node_process_1.env?.FILE.length > 0;
|
|
16
|
+
const FILE = node_process_1.env.POKU_FILE;
|
|
17
17
|
if (typeof arg1 === 'string') {
|
|
18
18
|
title = arg1;
|
|
19
19
|
if (typeof arg2 === 'function')
|
|
@@ -27,8 +27,8 @@ async function describeBase(arg1, arg2) {
|
|
|
27
27
|
}
|
|
28
28
|
if (title) {
|
|
29
29
|
indentation_js_1.indentation.hasDescribe = true;
|
|
30
|
-
const { background, icon } = options
|
|
31
|
-
const message = `${cb ? (0, format_js_1.format)('◌').dim() : (icon
|
|
30
|
+
const { background, icon } = options ?? {};
|
|
31
|
+
const message = `${cb ? (0, format_js_1.format)('◌').dim() : (icon ?? '☰')} ${cb ? (0, format_js_1.format)(isPoku ? `${title} › ${(0, format_js_1.format)(`${FILE}`).italic().gray()}` : title).dim() : (0, format_js_1.format)(title).bold()}`;
|
|
32
32
|
const noBackground = !background;
|
|
33
33
|
if (noBackground)
|
|
34
34
|
write_js_1.Write.log((0, format_js_1.format)(message).bold());
|
|
@@ -20,7 +20,7 @@ const each_js_1 = require("../../configs/each.js");
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
const beforeEach = (callback, options) => {
|
|
23
|
-
|
|
23
|
+
options?.immediate && callback();
|
|
24
24
|
each_js_1.each.before.cb = () => {
|
|
25
25
|
if (each_js_1.each.before.status)
|
|
26
26
|
return callback();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.envFile = void 0;
|
|
4
4
|
const node_process_1 = require("process");
|
|
5
|
-
const
|
|
5
|
+
const promises_1 = require("fs/promises");
|
|
6
6
|
const list_files_js_1 = require("./list-files.js");
|
|
7
7
|
const env_js_1 = require("../../services/env.js");
|
|
8
8
|
const regex = {
|
|
@@ -11,7 +11,7 @@ const regex = {
|
|
|
11
11
|
/** Reads an environment file and sets the environment variables. */
|
|
12
12
|
const envFile = async (filePath = '.env') => {
|
|
13
13
|
const mapEnv = new Map();
|
|
14
|
-
const env = await (0,
|
|
14
|
+
const env = await (0, promises_1.readFile)((0, list_files_js_1.sanitizePath)(filePath), 'utf8');
|
|
15
15
|
const lines = env
|
|
16
16
|
.split('\n')
|
|
17
17
|
.map((line) => (0, env_js_1.removeComments)(line.trim()))
|
|
@@ -13,8 +13,8 @@ async function itBase(...args) {
|
|
|
13
13
|
try {
|
|
14
14
|
let message;
|
|
15
15
|
let cb;
|
|
16
|
-
const isPoku = typeof
|
|
17
|
-
const FILE = node_process_1.env.
|
|
16
|
+
const isPoku = typeof node_process_1.env?.POKU_FILE === 'string' && node_process_1.env?.POKU_FILE.length > 0;
|
|
17
|
+
const FILE = node_process_1.env.POKU_FILE;
|
|
18
18
|
if (typeof args[0] === 'string') {
|
|
19
19
|
message = args[0];
|
|
20
20
|
cb = args[1];
|