poku 3.0.0-rc.0 โ 3.0.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 +7 -4
- package/lib/@types/list-files.d.ts +0 -4
- package/lib/@types/poku.d.ts +69 -2
- package/lib/bin/help.js +13 -9
- package/lib/bin/index.js +73 -68
- package/lib/bin/watch.js +12 -11
- package/lib/builders/reporter.d.ts +2 -0
- package/lib/builders/reporter.js +11 -0
- package/lib/configs/poku.d.ts +74 -3
- package/lib/configs/poku.js +18 -5
- package/lib/modules/essentials/poku.js +21 -19
- package/lib/modules/essentials/strict.js +3 -2
- package/lib/modules/helpers/create-service.js +7 -6
- package/lib/modules/helpers/describe.js +20 -18
- package/lib/modules/helpers/exit.js +8 -41
- package/lib/modules/helpers/get-pids.js +2 -2
- package/lib/modules/helpers/it/core.d.ts +2 -2
- package/lib/modules/helpers/it/core.js +20 -23
- package/lib/modules/helpers/kill.js +2 -2
- package/lib/modules/helpers/list-files.js +2 -2
- package/lib/modules/helpers/log.js +1 -1
- package/lib/modules/helpers/modifiers.js +14 -9
- package/lib/modules/helpers/skip.js +2 -9
- package/lib/modules/helpers/test.d.ts +2 -2
- package/lib/parsers/callback.d.ts +2 -0
- package/lib/parsers/callback.js +21 -0
- package/lib/parsers/get-arg.d.ts +0 -2
- package/lib/parsers/get-arg.js +3 -9
- package/lib/parsers/get-runner.d.ts +1 -3
- package/lib/parsers/get-runner.js +9 -10
- package/lib/parsers/get-runtime.d.ts +0 -1
- package/lib/parsers/get-runtime.js +16 -5
- package/lib/parsers/options.js +7 -2
- package/lib/parsers/os.d.ts +1 -0
- package/lib/parsers/os.js +5 -0
- package/lib/parsers/output.d.ts +0 -4
- package/lib/parsers/output.js +4 -9
- package/lib/parsers/runtime-version.d.ts +1 -0
- package/lib/parsers/runtime-version.js +12 -0
- package/lib/parsers/time.d.ts +1 -1
- package/lib/parsers/time.js +1 -4
- package/lib/services/assert.js +8 -69
- package/lib/services/container.js +14 -16
- package/lib/services/each.d.ts +2 -3
- package/lib/services/each.js +16 -15
- package/lib/services/enforce.d.ts +1 -0
- package/lib/services/enforce.js +131 -0
- package/lib/services/format.d.ts +1 -2
- package/lib/services/format.js +1 -19
- package/lib/services/reporter.d.ts +2 -0
- package/lib/services/reporter.js +17 -0
- package/lib/services/reporters/classic.d.ts +2 -0
- package/lib/services/reporters/classic.js +48 -0
- package/lib/services/reporters/compact.d.ts +2 -0
- package/lib/services/reporters/compact.js +41 -0
- package/lib/services/reporters/dot.d.ts +2 -0
- package/lib/services/reporters/dot.js +31 -0
- package/lib/services/reporters/focus.d.ts +2 -0
- package/lib/services/reporters/focus.js +36 -0
- package/lib/services/reporters/poku.d.ts +6 -0
- package/lib/services/reporters/poku.js +176 -0
- package/lib/services/reporters/verbose.d.ts +2 -0
- package/lib/services/reporters/verbose.js +19 -0
- package/lib/services/run-test-file.d.ts +1 -2
- package/lib/services/run-test-file.js +44 -26
- package/lib/services/run-tests.d.ts +1 -2
- package/lib/services/run-tests.js +14 -18
- package/lib/services/write.d.ts +2 -4
- package/lib/services/write.js +7 -7
- package/package.json +5 -6
- package/lib/bin/enforce.js +0 -48
- package/lib/configs/files.d.ts +0 -5
- package/lib/configs/files.js +0 -9
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
Enjoying **Poku**? Give him a star to show your support ๐
|
|
7
7
|
|
|
8
|
-
[](https://www.npmjs.com/package/poku)
|
|
9
9
|
[](https://www.npmjs.com/package/poku)
|
|
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)
|
|
@@ -14,13 +14,16 @@ 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
21
|
> [!IMPORTANT]
|
|
22
22
|
>
|
|
23
|
-
>
|
|
23
|
+
> **Poku `v3`** is here! ๐
|
|
24
|
+
>
|
|
25
|
+
> - To check out what's changed, follow the [**Issue #801**](https://github.com/wellwelwel/poku/issues/801).
|
|
26
|
+
> - For `v2` documentation, see the [**previous version's 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 />
|
|
24
27
|
|
|
25
28
|
---
|
|
26
29
|
|
|
@@ -247,7 +250,7 @@ To see the detailed documentation, please visit the [**Documentation**](https://
|
|
|
247
250
|
- [Avoiding conflicts in environments with multiple platforms installed](https://poku.io/docs/tutorials/cross-platform#recommendations).
|
|
248
251
|
- [Properly running asynchronous tests on the same file](https://poku.io/docs/examples/promises).
|
|
249
252
|
- [Using **Poku** without installing on **Deno** and alternatives to **JSR**](https://github.com/wellwelwel/poku/discussions/565).
|
|
250
|
-
- [Migrating from version **
|
|
253
|
+
- [Migrating from version **2.x** to version **3.x** (_rc_)](https://github.com/wellwelwel/poku/issues/801).
|
|
251
254
|
|
|
252
255
|
---
|
|
253
256
|
|
package/lib/@types/poku.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import type { AssertionError } from "assert";
|
|
2
|
+
import type { results } from '../configs/poku.js';
|
|
1
3
|
import type { Configs as ListFilesConfigs } from './list-files.js';
|
|
4
|
+
import type { ProcessAssertionOptions } from './assert.js';
|
|
5
|
+
import type { DescribeOptions } from './describe.js';
|
|
6
|
+
type CustomString = string & NonNullable<unknown>;
|
|
2
7
|
export type DenoOptions = {
|
|
3
8
|
allow?: string[];
|
|
4
9
|
deny?: string[];
|
|
5
10
|
cjs?: boolean | string[];
|
|
6
11
|
};
|
|
7
12
|
export type Runtime = 'node' | 'bun' | 'deno';
|
|
13
|
+
export type Reporter = 'poku' | 'focus' | 'dot' | 'verbose' | 'compact' | 'classic' | CustomString;
|
|
8
14
|
export type Configs = {
|
|
9
15
|
/**
|
|
10
16
|
* By setting `true`, **Poku** won't exit the process and will return the exit code (`0` or `1`).
|
|
@@ -44,6 +50,10 @@ export type Configs = {
|
|
|
44
50
|
* @default (availableParallelism() || cpus().lenght) - 1
|
|
45
51
|
*/
|
|
46
52
|
concurrency?: number;
|
|
53
|
+
/**
|
|
54
|
+
* @default "poku"
|
|
55
|
+
*/
|
|
56
|
+
reporter?: Reporter;
|
|
47
57
|
/**
|
|
48
58
|
* You can use this option to run a **callback** or a **file** before each test file on your suite.
|
|
49
59
|
*
|
|
@@ -74,9 +84,11 @@ export type Configs = {
|
|
|
74
84
|
afterEach?: () => unknown | Promise<unknown>;
|
|
75
85
|
deno?: DenoOptions;
|
|
76
86
|
} & ListFilesConfigs;
|
|
77
|
-
export type
|
|
78
|
-
time: string;
|
|
87
|
+
export type Timespan = {
|
|
79
88
|
started: Date;
|
|
89
|
+
finished: Date;
|
|
90
|
+
/** Calculation from `process.hrtime()`. */
|
|
91
|
+
duration: number;
|
|
80
92
|
};
|
|
81
93
|
export type States = {
|
|
82
94
|
isSinglePath?: boolean;
|
|
@@ -101,4 +113,59 @@ export type ConfigJSONFile = {
|
|
|
101
113
|
exclude?: string;
|
|
102
114
|
} & Omit<Configs, 'beforeEach' | 'afterEach' | 'noExit' | 'filter' | 'exclude'> & cliConfigs;
|
|
103
115
|
export type ConfigFile = Omit<Configs, 'noExit'> & cliConfigs;
|
|
116
|
+
type Results = {
|
|
117
|
+
code: number;
|
|
118
|
+
timespan: Timespan;
|
|
119
|
+
results: typeof results;
|
|
120
|
+
};
|
|
121
|
+
type Path = {
|
|
122
|
+
absolute: string;
|
|
123
|
+
relative: string;
|
|
124
|
+
};
|
|
125
|
+
export type ReporterPlugin = (configs?: Configs) => {
|
|
126
|
+
onRunStart: () => void;
|
|
127
|
+
onDescribeAsTitle: (title: string, options: DescribeOptions) => void;
|
|
128
|
+
onDescribeStart: (options: {
|
|
129
|
+
title?: string;
|
|
130
|
+
}) => void;
|
|
131
|
+
onDescribeEnd: (options: {
|
|
132
|
+
title?: string;
|
|
133
|
+
duration: number;
|
|
134
|
+
}) => void;
|
|
135
|
+
onItStart: (options: {
|
|
136
|
+
title?: string;
|
|
137
|
+
}) => void;
|
|
138
|
+
onItEnd: (options: {
|
|
139
|
+
title?: string;
|
|
140
|
+
duration: number;
|
|
141
|
+
}) => void;
|
|
142
|
+
onAssertionSuccess: (options: {
|
|
143
|
+
message: string;
|
|
144
|
+
}) => void;
|
|
145
|
+
onAssertionFailure: (options: {
|
|
146
|
+
assertOptions: ProcessAssertionOptions;
|
|
147
|
+
error: AssertionError;
|
|
148
|
+
}) => void;
|
|
149
|
+
onSkipFile: (options: {
|
|
150
|
+
message: string;
|
|
151
|
+
}) => void;
|
|
152
|
+
onSkipModifier: (options: {
|
|
153
|
+
message: string;
|
|
154
|
+
}) => void;
|
|
155
|
+
onTodoModifier: (options: {
|
|
156
|
+
message: string;
|
|
157
|
+
}) => void;
|
|
158
|
+
onFileStart: (options: {
|
|
159
|
+
path: Path;
|
|
160
|
+
}) => void;
|
|
161
|
+
onFileResult: (options: {
|
|
162
|
+
status: boolean;
|
|
163
|
+
path: Path;
|
|
164
|
+
duration: number;
|
|
165
|
+
output?: string;
|
|
166
|
+
}) => void;
|
|
167
|
+
onRunResult: (options: Results) => void;
|
|
168
|
+
onExit: (options: Results) => void;
|
|
169
|
+
};
|
|
170
|
+
export type ReporterEvents = Partial<ReturnType<ReporterPlugin>>;
|
|
104
171
|
export {};
|
package/lib/bin/help.js
CHANGED
|
@@ -27,6 +27,10 @@ const summary = [
|
|
|
27
27
|
['--killPort', 'Terminate the specified ports.'],
|
|
28
28
|
['--killRange', 'Terminate the specified port ranges.'],
|
|
29
29
|
['--listFiles', 'Display all the files returned in the terminal.'],
|
|
30
|
+
[
|
|
31
|
+
'--reporter, -r',
|
|
32
|
+
'Specify the reporter: poku, dot, compact, focus, verbose, classic.',
|
|
33
|
+
],
|
|
30
34
|
['--only', 'Enable selective execution of tests.'],
|
|
31
35
|
['--quiet, -q', 'Run tests with no logs.'],
|
|
32
36
|
['--sequential', 'Run tests files sequentially.'],
|
|
@@ -35,7 +39,7 @@ const summary = [
|
|
|
35
39
|
['--watchInterval', 'Set an interval for watch events.'],
|
|
36
40
|
];
|
|
37
41
|
const sortedSummary = summary.sort(([a], [b]) => a.localeCompare(b));
|
|
38
|
-
const largeEndPad =
|
|
42
|
+
const largeEndPad = Math.max(...summary.map(([start]) => start.length));
|
|
39
43
|
const header = `
|
|
40
44
|
๐ท ${(0, format_js_1.format)(' Poku โ CLI Usage ').bg('brightMagenta')}
|
|
41
45
|
|
|
@@ -68,18 +72,18 @@ ${sortedSummary
|
|
|
68
72
|
${u('https://poku.io/docs/tutorials/cross-platform')}
|
|
69
73
|
`;
|
|
70
74
|
const footer = `
|
|
71
|
-
${b('Documentation:')} ${u('https://poku.io')}
|
|
75
|
+
${b('Documentation:')} ${u('https://poku.io/docs')}
|
|
72
76
|
|
|
73
77
|
${bullet} ${b('Poku')} is made with ${b('love')} and ${b('care')} in every detail.
|
|
74
78
|
${bullet} Give him a ${b('star')} to show your support ๐
|
|
75
79
|
`;
|
|
76
80
|
const help = () => {
|
|
77
|
-
write_js_1.
|
|
78
|
-
write_js_1.
|
|
79
|
-
write_js_1.
|
|
80
|
-
write_js_1.
|
|
81
|
-
write_js_1.
|
|
82
|
-
write_js_1.
|
|
83
|
-
write_js_1.
|
|
81
|
+
(0, write_js_1.hr)();
|
|
82
|
+
(0, write_js_1.log)(header.trim());
|
|
83
|
+
(0, write_js_1.hr)();
|
|
84
|
+
(0, write_js_1.log)(main.trim());
|
|
85
|
+
(0, write_js_1.hr)();
|
|
86
|
+
(0, write_js_1.log)(footer.trim());
|
|
87
|
+
(0, write_js_1.hr)();
|
|
84
88
|
};
|
|
85
89
|
exports.help = help;
|
package/lib/bin/index.js
CHANGED
|
@@ -3,62 +3,67 @@
|
|
|
3
3
|
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
|
-
const
|
|
6
|
+
const poku_js_1 = require("../configs/poku.js");
|
|
7
7
|
const format_js_1 = require("../services/format.js");
|
|
8
8
|
const kill_js_1 = require("../modules/helpers/kill.js");
|
|
9
9
|
const env_js_1 = require("../modules/helpers/env.js");
|
|
10
|
-
const
|
|
10
|
+
const poku_js_2 = require("../modules/essentials/poku.js");
|
|
11
11
|
const write_js_1 = require("../services/write.js");
|
|
12
12
|
const options_js_1 = require("../parsers/options.js");
|
|
13
|
+
const poku_js_3 = require("../configs/poku.js");
|
|
13
14
|
(async () => {
|
|
15
|
+
|
|
14
16
|
if ((0, get_arg_js_1.hasArg)('version') || (0, get_arg_js_1.hasArg)('v', '-')) {
|
|
15
|
-
|
|
16
|
-
write_js_1.Write.log(VERSION);
|
|
17
|
+
(0, write_js_1.log)(poku_js_3.VERSION);
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
20
|
if ((0, get_arg_js_1.hasArg)('help') || (0, get_arg_js_1.hasArg)('h', '-')) {
|
|
20
|
-
|
|
21
|
-
help();
|
|
21
|
+
require('./help.js').help();
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
const enforce = (0, get_arg_js_1.hasArg)('enforce') || (0, get_arg_js_1.hasArg)('x', '-');
|
|
25
25
|
const configFile = (0, get_arg_js_1.getArg)('config') || (0, get_arg_js_1.getArg)('c', '-');
|
|
26
|
-
|
|
26
|
+
poku_js_3.GLOBAL.configsFromFile = await (0, options_js_1.getConfigs)(configFile);
|
|
27
|
+
const { configsFromFile } = poku_js_3.GLOBAL;
|
|
27
28
|
const dirs = (0, get_arg_js_1.getPaths)('-') ??
|
|
28
|
-
(
|
|
29
|
-
? Array.prototype.concat(
|
|
29
|
+
(configsFromFile?.include
|
|
30
|
+
? Array.prototype.concat(configsFromFile?.include)
|
|
30
31
|
: ['.']);
|
|
31
|
-
const filter = (0, get_arg_js_1.getArg)('filter') ??
|
|
32
|
-
const exclude = (0, get_arg_js_1.getArg)('exclude') ??
|
|
32
|
+
const filter = (0, get_arg_js_1.getArg)('filter') ?? configsFromFile?.filter;
|
|
33
|
+
const exclude = (0, get_arg_js_1.getArg)('exclude') ?? configsFromFile?.exclude;
|
|
33
34
|
const killPort = (0, get_arg_js_1.getArg)('killPort');
|
|
34
35
|
const killRange = (0, get_arg_js_1.getArg)('killRange');
|
|
35
36
|
const killPID = (0, get_arg_js_1.getArg)('killPid');
|
|
37
|
+
const reporter = (0, get_arg_js_1.getArg)('reporter') ??
|
|
38
|
+
(0, get_arg_js_1.getArg)('r', '-') ??
|
|
39
|
+
poku_js_3.GLOBAL.configsFromFile.reporter ??
|
|
40
|
+
'poku';
|
|
36
41
|
|
|
37
|
-
const denoAllow = (0, get_arg_js_1.argToArray)('denoAllow') ??
|
|
38
|
-
const denoDeny = (0, get_arg_js_1.argToArray)('denoDeny') ??
|
|
42
|
+
const denoAllow = (0, get_arg_js_1.argToArray)('denoAllow') ?? configsFromFile?.deno?.allow;
|
|
43
|
+
const denoDeny = (0, get_arg_js_1.argToArray)('denoDeny') ?? configsFromFile?.deno?.deny;
|
|
39
44
|
const denoCJS = (0, get_arg_js_1.getArg)('denoCjs')
|
|
40
45
|
?.split(',')
|
|
41
46
|
.map((a) => a.trim())
|
|
42
47
|
.filter((a) => a) ||
|
|
43
48
|
(0, get_arg_js_1.hasArg)('denoCjs') ||
|
|
44
|
-
|
|
49
|
+
configsFromFile?.deno?.cjs;
|
|
45
50
|
|
|
46
|
-
const quiet = (0, get_arg_js_1.hasArg)('quiet') || (0, get_arg_js_1.hasArg)('q', '-') ||
|
|
47
|
-
const debug = (0, get_arg_js_1.hasArg)('debug') || (0, get_arg_js_1.hasArg)('d', '-') ||
|
|
48
|
-
const failFast = (0, get_arg_js_1.hasArg)('failFast') ||
|
|
51
|
+
const quiet = (0, get_arg_js_1.hasArg)('quiet') || (0, get_arg_js_1.hasArg)('q', '-') || configsFromFile?.quiet;
|
|
52
|
+
const debug = (0, get_arg_js_1.hasArg)('debug') || (0, get_arg_js_1.hasArg)('d', '-') || configsFromFile?.debug;
|
|
53
|
+
const failFast = (0, get_arg_js_1.hasArg)('failFast') || configsFromFile?.failFast;
|
|
49
54
|
const watchMode = (0, get_arg_js_1.hasArg)('watch') || (0, get_arg_js_1.hasArg)('w', '-');
|
|
50
55
|
const hasEnvFile = (0, get_arg_js_1.hasArg)('envFile');
|
|
51
56
|
const concurrency = (() => {
|
|
52
57
|
const value = Number((0, get_arg_js_1.getArg)('concurrency'));
|
|
53
|
-
return Number.isNaN(value) ?
|
|
58
|
+
return Number.isNaN(value) ? configsFromFile?.concurrency : value;
|
|
54
59
|
})();
|
|
55
60
|
const sequential = (0, get_arg_js_1.hasArg)('sequential');
|
|
56
61
|
if (dirs.length === 1)
|
|
57
|
-
|
|
62
|
+
poku_js_1.states.isSinglePath = true;
|
|
58
63
|
if ((0, get_arg_js_1.hasArg)('listFiles')) {
|
|
59
64
|
const { listFiles } = require('../modules/helpers/list-files.js');
|
|
60
65
|
const files = [];
|
|
61
|
-
write_js_1.
|
|
66
|
+
(0, write_js_1.hr)();
|
|
62
67
|
for (const dir of dirs)
|
|
63
68
|
files.push(...(await listFiles(dir, {
|
|
64
69
|
filter: typeof filter === 'string'
|
|
@@ -68,28 +73,48 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
68
73
|
? new RegExp((0, list_files_js_1.escapeRegExp)(exclude))
|
|
69
74
|
: exclude,
|
|
70
75
|
})));
|
|
71
|
-
write_js_1.
|
|
76
|
+
(0, write_js_1.log)(files
|
|
72
77
|
.sort()
|
|
73
78
|
.map((file) => `${(0, format_js_1.format)('-').dim()} ${file}`)
|
|
74
79
|
.join('\n'));
|
|
75
|
-
write_js_1.
|
|
76
|
-
write_js_1.
|
|
77
|
-
write_js_1.
|
|
80
|
+
(0, write_js_1.hr)();
|
|
81
|
+
(0, write_js_1.log)(`Total test files: ${(0, format_js_1.format)(String(files.length)).bold()}`);
|
|
82
|
+
(0, write_js_1.hr)();
|
|
78
83
|
return;
|
|
79
84
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
poku_js_3.GLOBAL.configFile = configFile;
|
|
86
|
+
poku_js_3.GLOBAL.configs = {
|
|
87
|
+
filter: typeof filter === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(filter)) : filter,
|
|
88
|
+
exclude: typeof exclude === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(exclude)) : exclude,
|
|
89
|
+
concurrency,
|
|
90
|
+
sequential,
|
|
91
|
+
quiet,
|
|
92
|
+
debug,
|
|
93
|
+
failFast,
|
|
94
|
+
deno: {
|
|
95
|
+
allow: denoAllow,
|
|
96
|
+
deny: denoDeny,
|
|
97
|
+
cjs: denoCJS,
|
|
98
|
+
},
|
|
99
|
+
noExit: watchMode,
|
|
100
|
+
reporter,
|
|
101
|
+
beforeEach: 'beforeEach' in configsFromFile ? configsFromFile.beforeEach : undefined,
|
|
102
|
+
afterEach: 'afterEach' in configsFromFile ? configsFromFile.afterEach : undefined,
|
|
103
|
+
};
|
|
84
104
|
const tasks = [];
|
|
105
|
+
if (hasEnvFile || configsFromFile?.envFile) {
|
|
106
|
+
poku_js_3.GLOBAL.envFile = (0, get_arg_js_1.getArg)('envFile') ?? configsFromFile?.envFile ?? '.env';
|
|
107
|
+
}
|
|
108
|
+
if (enforce)
|
|
109
|
+
require('../services/enforce.js').enforce();
|
|
85
110
|
|
|
86
|
-
if (killPort ||
|
|
87
|
-
const ports = killPort?.split(',').map(Number) ||
|
|
111
|
+
if (killPort || configsFromFile?.kill?.port) {
|
|
112
|
+
const ports = killPort?.split(',').map(Number) || configsFromFile?.kill?.port || [];
|
|
88
113
|
tasks.push(kill_js_1.kill.port(ports));
|
|
89
114
|
}
|
|
90
|
-
if (killRange ||
|
|
115
|
+
if (killRange || configsFromFile?.kill?.range) {
|
|
91
116
|
const ranges = killRange?.split(',') ||
|
|
92
|
-
|
|
117
|
+
configsFromFile?.kill?.range?.map((range) => `${range[0]}-${range[1]}`) ||
|
|
93
118
|
[];
|
|
94
119
|
for (const range of ranges) {
|
|
95
120
|
const ports = range.split('-').map(Number);
|
|
@@ -98,45 +123,25 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
98
123
|
tasks.push(kill_js_1.kill.range(startsAt, endsAt));
|
|
99
124
|
}
|
|
100
125
|
}
|
|
101
|
-
if (killPID ||
|
|
102
|
-
const PIDs = killPID?.split(',').map(Number) ||
|
|
126
|
+
if (killPID || configsFromFile?.kill?.pid) {
|
|
127
|
+
const PIDs = killPID?.split(',').map(Number) || configsFromFile?.kill?.pid || [];
|
|
103
128
|
tasks.push(kill_js_1.kill.pid(PIDs));
|
|
104
129
|
}
|
|
105
130
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
debug,
|
|
117
|
-
failFast,
|
|
118
|
-
deno: {
|
|
119
|
-
allow: denoAllow,
|
|
120
|
-
deny: denoDeny,
|
|
121
|
-
cjs: denoCJS,
|
|
122
|
-
},
|
|
123
|
-
noExit: watchMode,
|
|
124
|
-
beforeEach: 'beforeEach' in defaultConfigs ? defaultConfigs.beforeEach : undefined,
|
|
125
|
-
afterEach: 'afterEach' in defaultConfigs ? defaultConfigs.afterEach : undefined,
|
|
126
|
-
};
|
|
127
|
-
if (debug || defaultConfigs?.debug) {
|
|
128
|
-
write_js_1.Write.hr();
|
|
129
|
-
write_js_1.Write.log(`${(0, format_js_1.format)(' Debug Enabled ').bg('brightBlue')}\n`);
|
|
130
|
-
write_js_1.Write.log(`${(0, format_js_1.format)('โฆ').info().italic()} ${(0, format_js_1.format)('Paths').bold()}`);
|
|
131
|
-
console.table(dirs);
|
|
132
|
-
write_js_1.Write.log('\n');
|
|
133
|
-
write_js_1.Write.log(`${(0, format_js_1.format)('โฆ').info().italic()} ${(0, format_js_1.format)('Options').bold()}`);
|
|
134
|
-
console.dir(options, { depth: null, colors: true });
|
|
131
|
+
poku_js_3.GLOBAL.envFile && tasks.push((0, env_js_1.envFile)(poku_js_3.GLOBAL.envFile));
|
|
132
|
+
if (debug || configsFromFile?.debug) {
|
|
133
|
+
(0, write_js_1.hr)();
|
|
134
|
+
(0, write_js_1.log)(`${(0, format_js_1.format)(' Debug Enabled ').bg('brightBlue')}\n`);
|
|
135
|
+
(0, write_js_1.log)(`${(0, format_js_1.format)('โฆ').info().italic()} ${(0, format_js_1.format)('Options').bold()}`);
|
|
136
|
+
console.dir(poku_js_3.GLOBAL.configs, {
|
|
137
|
+
depth: Number.POSITIVE_INFINITY,
|
|
138
|
+
colors: true,
|
|
139
|
+
});
|
|
140
|
+
(0, write_js_1.log)(`\n${(0, format_js_1.format)('๐ก')} To list all test files, run: ${(0, format_js_1.format)('poku --listFiles').bold()}`);
|
|
135
141
|
}
|
|
136
142
|
await Promise.all(tasks);
|
|
137
|
-
await (0,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
await startWatch(dirs
|
|
141
|
-
}
|
|
143
|
+
await (0, poku_js_2.poku)(dirs);
|
|
144
|
+
|
|
145
|
+
if (watchMode)
|
|
146
|
+
await require('./watch.js').startWatch(dirs);
|
|
142
147
|
})();
|
package/lib/bin/watch.js
CHANGED
|
@@ -11,10 +11,12 @@ const write_js_1 = require("../services/write.js");
|
|
|
11
11
|
const node_process_1 = __importDefault(require("process"));
|
|
12
12
|
const format_js_1 = require("../services/format.js");
|
|
13
13
|
const get_arg_js_1 = require("../parsers/get-arg.js");
|
|
14
|
-
const files_js_1 = require("../configs/files.js");
|
|
15
14
|
const os_js_1 = require("../polyfills/os.js");
|
|
16
|
-
const
|
|
15
|
+
const poku_js_2 = require("../configs/poku.js");
|
|
16
|
+
const poku_js_3 = require("../services/reporters/poku.js");
|
|
17
|
+
const startWatch = async (dirs) => {
|
|
17
18
|
let isRunning = false;
|
|
19
|
+
const { configs } = poku_js_2.GLOBAL;
|
|
18
20
|
const watchers = new Set();
|
|
19
21
|
const executing = new Set();
|
|
20
22
|
const interval = Number((0, get_arg_js_1.getArg)('watchInterval')) || 1500;
|
|
@@ -22,8 +24,7 @@ const startWatch = async (dirs, options) => {
|
|
|
22
24
|
isRunning = value;
|
|
23
25
|
};
|
|
24
26
|
const resultsClear = () => {
|
|
25
|
-
|
|
26
|
-
files_js_1.fileResults.fail.clear();
|
|
27
|
+
poku_js_3.errors.length = 0;
|
|
27
28
|
};
|
|
28
29
|
const listenStdin = async (input) => {
|
|
29
30
|
if (isRunning || executing.size > 0)
|
|
@@ -33,13 +34,13 @@ 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, configs.filter, 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
46
|
if (event === 'change') {
|
|
@@ -53,8 +54,8 @@ const startWatch = async (dirs, options) => {
|
|
|
53
54
|
if (!tests)
|
|
54
55
|
return;
|
|
55
56
|
await (0, poku_js_1.poku)(Array.from(tests), {
|
|
56
|
-
...
|
|
57
|
-
concurrency:
|
|
57
|
+
...configs,
|
|
58
|
+
concurrency: configs.concurrency ??
|
|
58
59
|
Math.max(Math.floor((0, os_js_1.availableParallelism)() / 2), 1),
|
|
59
60
|
});
|
|
60
61
|
setTimeout(() => {
|
|
@@ -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
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createReporter = void 0;
|
|
4
|
+
const poku_js_1 = require("../services/reporters/poku.js");
|
|
5
|
+
const createReporter = (events) => {
|
|
6
|
+
return () => ({
|
|
7
|
+
...poku_js_1.poku,
|
|
8
|
+
...events,
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
exports.createReporter = createReporter;
|
package/lib/configs/poku.d.ts
CHANGED
|
@@ -1,11 +1,82 @@
|
|
|
1
|
+
import type { Timespan, States } from '../@types/poku.js';
|
|
2
|
+
import type { ConfigFile, ConfigJSONFile, Configs, Runtime } from '../@types/poku.js';
|
|
3
|
+
export declare const states: States;
|
|
4
|
+
export declare const timespan: Timespan;
|
|
1
5
|
export declare const results: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
6
|
+
passed: number;
|
|
7
|
+
failed: number;
|
|
8
|
+
skipped: number;
|
|
5
9
|
todo: number;
|
|
6
10
|
};
|
|
7
11
|
export declare const VERSION = "";
|
|
8
12
|
export declare const deepOptions: string[];
|
|
9
13
|
export declare const GLOBAL: {
|
|
10
14
|
cwd: string;
|
|
15
|
+
configs: Configs;
|
|
16
|
+
configFile: string | undefined;
|
|
17
|
+
configsFromFile: ConfigFile | ConfigJSONFile;
|
|
18
|
+
reporter: {
|
|
19
|
+
onRunStart: () => void;
|
|
20
|
+
onDescribeAsTitle: (title: string, options: import("../@types/describe.js").DescribeOptions) => void;
|
|
21
|
+
onDescribeStart: (options: {
|
|
22
|
+
title?: string;
|
|
23
|
+
}) => void;
|
|
24
|
+
onDescribeEnd: (options: {
|
|
25
|
+
title?: string;
|
|
26
|
+
duration: number;
|
|
27
|
+
}) => void;
|
|
28
|
+
onItStart: (options: {
|
|
29
|
+
title?: string;
|
|
30
|
+
}) => void;
|
|
31
|
+
onItEnd: (options: {
|
|
32
|
+
title?: string;
|
|
33
|
+
duration: number;
|
|
34
|
+
}) => void;
|
|
35
|
+
onAssertionSuccess: (options: {
|
|
36
|
+
message: string;
|
|
37
|
+
}) => void;
|
|
38
|
+
onAssertionFailure: (options: {
|
|
39
|
+
assertOptions: import("../@types/assert.js").ProcessAssertionOptions;
|
|
40
|
+
error: import("assert").AssertionError;
|
|
41
|
+
}) => void;
|
|
42
|
+
onSkipFile: (options: {
|
|
43
|
+
message: string;
|
|
44
|
+
}) => void;
|
|
45
|
+
onSkipModifier: (options: {
|
|
46
|
+
message: string;
|
|
47
|
+
}) => void;
|
|
48
|
+
onTodoModifier: (options: {
|
|
49
|
+
message: string;
|
|
50
|
+
}) => void;
|
|
51
|
+
onFileStart: (options: {
|
|
52
|
+
path: {
|
|
53
|
+
absolute: string;
|
|
54
|
+
relative: string;
|
|
55
|
+
};
|
|
56
|
+
}) => void;
|
|
57
|
+
onFileResult: (options: {
|
|
58
|
+
status: boolean;
|
|
59
|
+
path: {
|
|
60
|
+
absolute: string;
|
|
61
|
+
relative: string;
|
|
62
|
+
};
|
|
63
|
+
duration: number;
|
|
64
|
+
output?: string;
|
|
65
|
+
}) => void;
|
|
66
|
+
onRunResult: (options: {
|
|
67
|
+
code: number;
|
|
68
|
+
timespan: Timespan;
|
|
69
|
+
results: typeof results;
|
|
70
|
+
}) => void;
|
|
71
|
+
onExit: (options: {
|
|
72
|
+
code: number;
|
|
73
|
+
timespan: Timespan;
|
|
74
|
+
results: typeof results;
|
|
75
|
+
}) => void;
|
|
76
|
+
};
|
|
77
|
+
isPoku: boolean;
|
|
78
|
+
FILE: string | undefined;
|
|
79
|
+
envFile: string | undefined;
|
|
80
|
+
runtime: Runtime;
|
|
81
|
+
runAsOnly: boolean;
|
|
11
82
|
};
|
package/lib/configs/poku.js
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GLOBAL = exports.deepOptions = exports.VERSION = exports.results = void 0;
|
|
3
|
+
exports.GLOBAL = exports.deepOptions = exports.VERSION = exports.results = exports.timespan = exports.states = void 0;
|
|
4
4
|
const node_process_1 = require("process");
|
|
5
|
+
const reporter_js_1 = require("../services/reporter.js");
|
|
6
|
+
const get_runtime_js_1 = require("../parsers/get-runtime.js");
|
|
7
|
+
exports.states = Object.create(null);
|
|
8
|
+
exports.timespan = Object.create(null);
|
|
5
9
|
exports.results = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
passed: 0,
|
|
11
|
+
failed: 0,
|
|
12
|
+
skipped: 0,
|
|
9
13
|
todo: 0,
|
|
10
14
|
};
|
|
11
|
-
exports.VERSION = '3.0.0
|
|
15
|
+
exports.VERSION = '3.0.0';
|
|
12
16
|
exports.deepOptions = [];
|
|
13
17
|
exports.GLOBAL = {
|
|
14
18
|
cwd: (0, node_process_1.cwd)(),
|
|
19
|
+
configs: Object.create(null),
|
|
20
|
+
configFile: undefined,
|
|
21
|
+
configsFromFile: Object.create(null),
|
|
22
|
+
reporter: reporter_js_1.reporter[node_process_1.env.POKU_REPORTER || 'poku'](),
|
|
23
|
+
isPoku: typeof node_process_1.env.POKU_FILE === 'string' && node_process_1.env.POKU_FILE.length > 0,
|
|
24
|
+
FILE: node_process_1.env.POKU_FILE,
|
|
25
|
+
envFile: undefined,
|
|
26
|
+
runtime: (node_process_1.env.POKU_RUNTIME || (0, get_runtime_js_1.getRuntime)()),
|
|
27
|
+
runAsOnly: false,
|
|
15
28
|
};
|