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.
Files changed (73) hide show
  1. package/README.md +7 -4
  2. package/lib/@types/list-files.d.ts +0 -4
  3. package/lib/@types/poku.d.ts +69 -2
  4. package/lib/bin/help.js +13 -9
  5. package/lib/bin/index.js +73 -68
  6. package/lib/bin/watch.js +12 -11
  7. package/lib/builders/reporter.d.ts +2 -0
  8. package/lib/builders/reporter.js +11 -0
  9. package/lib/configs/poku.d.ts +74 -3
  10. package/lib/configs/poku.js +18 -5
  11. package/lib/modules/essentials/poku.js +21 -19
  12. package/lib/modules/essentials/strict.js +3 -2
  13. package/lib/modules/helpers/create-service.js +7 -6
  14. package/lib/modules/helpers/describe.js +20 -18
  15. package/lib/modules/helpers/exit.js +8 -41
  16. package/lib/modules/helpers/get-pids.js +2 -2
  17. package/lib/modules/helpers/it/core.d.ts +2 -2
  18. package/lib/modules/helpers/it/core.js +20 -23
  19. package/lib/modules/helpers/kill.js +2 -2
  20. package/lib/modules/helpers/list-files.js +2 -2
  21. package/lib/modules/helpers/log.js +1 -1
  22. package/lib/modules/helpers/modifiers.js +14 -9
  23. package/lib/modules/helpers/skip.js +2 -9
  24. package/lib/modules/helpers/test.d.ts +2 -2
  25. package/lib/parsers/callback.d.ts +2 -0
  26. package/lib/parsers/callback.js +21 -0
  27. package/lib/parsers/get-arg.d.ts +0 -2
  28. package/lib/parsers/get-arg.js +3 -9
  29. package/lib/parsers/get-runner.d.ts +1 -3
  30. package/lib/parsers/get-runner.js +9 -10
  31. package/lib/parsers/get-runtime.d.ts +0 -1
  32. package/lib/parsers/get-runtime.js +16 -5
  33. package/lib/parsers/options.js +7 -2
  34. package/lib/parsers/os.d.ts +1 -0
  35. package/lib/parsers/os.js +5 -0
  36. package/lib/parsers/output.d.ts +0 -4
  37. package/lib/parsers/output.js +4 -9
  38. package/lib/parsers/runtime-version.d.ts +1 -0
  39. package/lib/parsers/runtime-version.js +12 -0
  40. package/lib/parsers/time.d.ts +1 -1
  41. package/lib/parsers/time.js +1 -4
  42. package/lib/services/assert.js +8 -69
  43. package/lib/services/container.js +14 -16
  44. package/lib/services/each.d.ts +2 -3
  45. package/lib/services/each.js +16 -15
  46. package/lib/services/enforce.d.ts +1 -0
  47. package/lib/services/enforce.js +131 -0
  48. package/lib/services/format.d.ts +1 -2
  49. package/lib/services/format.js +1 -19
  50. package/lib/services/reporter.d.ts +2 -0
  51. package/lib/services/reporter.js +17 -0
  52. package/lib/services/reporters/classic.d.ts +2 -0
  53. package/lib/services/reporters/classic.js +48 -0
  54. package/lib/services/reporters/compact.d.ts +2 -0
  55. package/lib/services/reporters/compact.js +41 -0
  56. package/lib/services/reporters/dot.d.ts +2 -0
  57. package/lib/services/reporters/dot.js +31 -0
  58. package/lib/services/reporters/focus.d.ts +2 -0
  59. package/lib/services/reporters/focus.js +36 -0
  60. package/lib/services/reporters/poku.d.ts +6 -0
  61. package/lib/services/reporters/poku.js +176 -0
  62. package/lib/services/reporters/verbose.d.ts +2 -0
  63. package/lib/services/reporters/verbose.js +19 -0
  64. package/lib/services/run-test-file.d.ts +1 -2
  65. package/lib/services/run-test-file.js +44 -26
  66. package/lib/services/run-tests.d.ts +1 -2
  67. package/lib/services/run-tests.js +14 -18
  68. package/lib/services/write.d.ts +2 -4
  69. package/lib/services/write.js +7 -7
  70. package/package.json +5 -6
  71. package/lib/bin/enforce.js +0 -48
  72. package/lib/configs/files.d.ts +0 -5
  73. 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
- [![NPM Downloads](https://img.shields.io/npm/v/poku.svg?label=&color=70a1ff&logo=npm&logoColor=white)](https://www.npmjs.com/package/poku)
8
+ [![NPM Version](https://img.shields.io/npm/v/poku.svg?label=&color=70a1ff&logo=npm&logoColor=white)](https://www.npmjs.com/package/poku)
9
9
  [![NPM Downloads](https://img.shields.io/npm/dm/poku.svg?label=&logo=npm&logoColor=white&color=45aaf2)](https://www.npmjs.com/package/poku)
10
10
  [![Coverage](https://img.shields.io/codecov/c/github/wellwelwel/poku?label=&logo=codecov&logoColor=white&color=98cc00)](https://github.com/wellwelwel/poku/tree/main/.nycrc)<br />
11
11
  [![GitHub Workflow Status (Linux)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-linux.yml?event=push&label=&branch=main&logo=ubuntu&logoColor=8897a9&color=dfe4ea)](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-linux.yml?query=branch%3Amain)
@@ -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>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿ“˜ [Documentation](https://poku.io/docs/category/documentation)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿงช [Examples](https://poku.io/docs/category/examples)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿง‘๐Ÿปโ€๐ŸŽ“ [Tutorials](https://poku.io/docs/category/quick-tutorials)
17
+ ๐Ÿท [Website](https://poku.io/)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿ“˜ [Documentation](https://poku.io/docs)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿงช [Examples](https://poku.io/docs/category/examples)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿง‘๐Ÿปโ€๐ŸŽ“ [Tutorials](https://poku.io/docs/category/quick-tutorials)
18
18
 
19
19
  </div>
20
20
 
21
21
  > [!IMPORTANT]
22
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` ๐Ÿ’ก
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 **1.x** to version **2.x**](https://github.com/wellwelwel/poku/issues/533).
253
+ - [Migrating from version **2.x** to version **3.x** (_rc_)](https://github.com/wellwelwel/poku/issues/801).
251
254
 
252
255
  ---
253
256
 
@@ -12,7 +12,3 @@ export type Configs = {
12
12
  */
13
13
  exclude?: RegExp | RegExp[];
14
14
  };
15
- export type FileResults = {
16
- success: Map<string, string>;
17
- fail: Map<string, string>;
18
- };
@@ -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 FinalResults = {
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 = (() => Math.max(...summary.map(([start]) => start.length)))();
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.Write.hr();
78
- write_js_1.Write.log(header.trim());
79
- write_js_1.Write.hr();
80
- write_js_1.Write.log(main.trim());
81
- write_js_1.Write.hr();
82
- write_js_1.Write.log(footer.trim());
83
- write_js_1.Write.hr();
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 files_js_1 = require("../configs/files.js");
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 poku_js_1 = require("../modules/essentials/poku.js");
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
- const { VERSION } = require('../configs/poku.js');
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
- const { help } = require('./help.js');
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
- const defaultConfigs = await (0, options_js_1.getConfigs)(configFile);
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
- (defaultConfigs?.include
29
- ? Array.prototype.concat(defaultConfigs?.include)
29
+ (configsFromFile?.include
30
+ ? Array.prototype.concat(configsFromFile?.include)
30
31
  : ['.']);
31
- const filter = (0, get_arg_js_1.getArg)('filter') ?? defaultConfigs?.filter;
32
- const exclude = (0, get_arg_js_1.getArg)('exclude') ?? defaultConfigs?.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') ?? defaultConfigs?.deno?.allow;
38
- const denoDeny = (0, get_arg_js_1.argToArray)('denoDeny') ?? defaultConfigs?.deno?.deny;
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
- defaultConfigs?.deno?.cjs;
49
+ configsFromFile?.deno?.cjs;
45
50
 
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;
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) ? defaultConfigs?.concurrency : 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
- files_js_1.states.isSinglePath = true;
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.Write.hr();
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.Write.log(files
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.Write.hr();
76
- write_js_1.Write.log(`Total test files: ${(0, format_js_1.format)(String(files.length)).bold()}`);
77
- write_js_1.Write.hr();
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
- if (enforce) {
81
- const { checkFlags } = require('./enforce.js');
82
- checkFlags();
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 || defaultConfigs?.kill?.port) {
87
- const ports = killPort?.split(',').map(Number) || defaultConfigs?.kill?.port || [];
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 || defaultConfigs?.kill?.range) {
115
+ if (killRange || configsFromFile?.kill?.range) {
91
116
  const ranges = killRange?.split(',') ||
92
- defaultConfigs?.kill?.range?.map((range) => `${range[0]}-${range[1]}`) ||
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 || defaultConfigs?.kill?.pid) {
102
- const PIDs = killPID?.split(',').map(Number) || defaultConfigs?.kill?.pid || [];
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
- if (hasEnvFile || defaultConfigs?.envFile) {
107
- const envFilePath = (0, get_arg_js_1.getArg)('envFile') ?? defaultConfigs?.envFile;
108
- tasks.push((0, env_js_1.envFile)(envFilePath));
109
- }
110
- const options = {
111
- filter: typeof filter === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(filter)) : filter,
112
- exclude: typeof exclude === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(exclude)) : exclude,
113
- concurrency,
114
- sequential,
115
- quiet,
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, poku_js_1.poku)(dirs, options);
138
- if (watchMode) {
139
- const { startWatch } = require('./watch.js');
140
- await startWatch(dirs, options);
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 startWatch = async (dirs, options) => {
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
- files_js_1.fileResults.success.clear();
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, options);
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, options.filter, options.exclude);
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
- ...options,
57
- concurrency: options.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, options).then(() => setTimeout(() => {
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.Write.hr();
85
- write_js_1.Write.log(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
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,2 @@
1
+ import type { ReporterEvents, ReporterPlugin } from '../@types/poku.js';
2
+ export declare const createReporter: (events: ReporterEvents) => ReporterPlugin;
@@ -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;
@@ -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
- success: number;
3
- fail: number;
4
- skip: number;
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
  };
@@ -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
- success: 0,
7
- fail: 0,
8
- skip: 0,
10
+ passed: 0,
11
+ failed: 0,
12
+ skipped: 0,
9
13
  todo: 0,
10
14
  };
11
- exports.VERSION = '3.0.0-rc.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
  };