poku 4.2.0 → 4.2.1-canary.0e540bb2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -278,7 +278,7 @@ To see the detailed documentation, please visit the [**Documentation**](https://
278
278
 
279
279
  ## Security Policy
280
280
 
281
- [![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/work flow/status/wellwelwel/poku/ci_codeql.yml?event=push&label=&branch=main&logo=github&logoColor=white&color=f368e0)](https://github.com/wellwelwel/poku/actions/workflows/ci_codeql.yml?query=branch%3Amain)
281
+ [![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_codeql.yml?event=push&label=&branch=main&logo=github&logoColor=white&color=f368e0)](https://github.com/wellwelwel/poku/actions/workflows/ci_codeql.yml?query=branch%3Amain)
282
282
 
283
283
  Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/SECURITY.md).
284
284
 
package/lib/bin/index.js CHANGED
@@ -12,7 +12,6 @@ const options_js_1 = require("../parsers/options.js");
12
12
  const format_js_1 = require("../services/format.js");
13
13
  const write_js_1 = require("../services/write.js");
14
14
  (async () => {
15
-
16
15
  if ((0, get_arg_js_1.hasArg)('version') || (0, get_arg_js_1.hasArg)('v', '-')) {
17
16
  (0, write_js_1.log)(poku_js_1.VERSION);
18
17
  return;
@@ -38,10 +37,8 @@ const write_js_1 = require("../services/write.js");
38
37
  (0, get_arg_js_1.getArg)('r', '-') ??
39
38
  poku_js_1.GLOBAL.configsFromFile.reporter ??
40
39
  'poku';
41
-
42
40
  const denoAllow = (0, get_arg_js_1.argToArray)('denoAllow') ?? configsFromFile?.deno?.allow;
43
41
  const denoDeny = (0, get_arg_js_1.argToArray)('denoDeny') ?? configsFromFile?.deno?.deny;
44
-
45
42
  const quiet = (0, get_arg_js_1.hasArg)('quiet') || (0, get_arg_js_1.hasArg)('q', '-') || configsFromFile?.quiet;
46
43
  const debug = (0, get_arg_js_1.hasArg)('debug') || (0, get_arg_js_1.hasArg)('d', '-') || configsFromFile?.debug;
47
44
  const failFast = (0, get_arg_js_1.hasArg)('failFast') || configsFromFile?.failFast;
package/lib/bin/watch.js CHANGED
@@ -88,6 +88,11 @@ const startWatch = async (dirs) => {
88
88
  }
89
89
  (0, write_js_1.hr)();
90
90
  (0, write_js_1.log)(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
91
+ node_process_1.default.on('SIGTERM', () => {
92
+ for (const watcher of watchers)
93
+ watcher.stop();
94
+ node_process_1.default.exit(0);
95
+ });
91
96
  node_process_1.default.stdin.setEncoding('utf8');
92
97
  node_process_1.default.stdin.on('data', listenStdin);
93
98
  };
@@ -17,7 +17,7 @@ exports.results = {
17
17
  skipped: 0,
18
18
  todo: 0,
19
19
  };
20
- exports.VERSION = '4.2.0';
20
+ exports.VERSION = '4.2.1-canary.0e540bb2';
21
21
  exports.deepOptions = [];
22
22
  exports.GLOBAL = {
23
23
  cwd: (0, node_process_1.cwd)(),
@@ -9,7 +9,6 @@ const reporter_js_1 = require("../../services/reporter.js");
9
9
  const run_tests_js_1 = require("../../services/run-tests.js");
10
10
  const exit_js_1 = require("../helpers/exit.js");
11
11
  const list_files_js_1 = require("../helpers/list-files.js");
12
-
13
12
  const onSigint = () => {
14
13
  node_process_1.stdout.write('\u001B[?25h');
15
14
  };
@@ -8,7 +8,7 @@ import type { Control, EachOptions } from '../../@types/each.js';
8
8
  * import { beforeEach } from 'poku';
9
9
  *
10
10
  * const before = beforeEach(() => {
11
- *
11
+ * // prepare
12
12
  * };
13
13
  *
14
14
  * before.pause();
@@ -26,7 +26,7 @@ export declare const beforeEach: (callback: () => unknown, options?: EachOptions
26
26
  * import { afterEach } from 'poku';
27
27
  *
28
28
  * const after = afterEach(() => {
29
- *
29
+ * // cleanup
30
30
  * };
31
31
  *
32
32
  * after.pause();
@@ -11,7 +11,7 @@ const each_js_1 = require("../../configs/each.js");
11
11
  * import { beforeEach } from 'poku';
12
12
  *
13
13
  * const before = beforeEach(() => {
14
- *
14
+ * // prepare
15
15
  * };
16
16
  *
17
17
  * before.pause();
@@ -46,7 +46,7 @@ exports.beforeEach = beforeEach;
46
46
  * import { afterEach } from 'poku';
47
47
  *
48
48
  * const after = afterEach(() => {
49
- *
49
+ * // cleanup
50
50
  * };
51
51
  *
52
52
  * after.pause();
@@ -31,56 +31,51 @@ const envFilter = node_process_1.env.FILTER?.trim()
31
31
  ? new RegExp((0, exports.escapeRegExp)(node_process_1.env.FILTER), 'i')
32
32
  : undefined;
33
33
  const getAllFilesInner = async (dirPath, files, filter, exclude) => {
34
- let entries;
35
- let isFullPath = false;
36
34
  try {
37
35
  const stat = await (0, promises_1.stat)(dirPath);
38
36
  if (stat.isFile()) {
39
- isFullPath = true;
40
- entries = [(0, exports.sanitizePath)(dirPath)];
41
- }
42
- else
43
- entries = await (0, promises_1.readdir)((0, exports.sanitizePath)(dirPath), { withFileTypes: true });
44
- }
45
- catch (error) {
46
- console.error(error);
47
- process.exit(1);
48
- }
49
- await Promise.all(entries.map(async (entry) => {
50
- if (isFullPath) {
51
- const fullPath = entry;
37
+ const fullPath = (0, exports.sanitizePath)(dirPath);
52
38
  if (fullPath.indexOf('node_modules') !== -1 ||
53
39
  fullPath.indexOf('.git/') !== -1)
54
- return;
40
+ return files;
55
41
  if (poku_js_1.states?.isSinglePath) {
56
42
  files.add(fullPath);
57
- return;
43
+ return files;
58
44
  }
59
45
  if (exclude)
60
46
  for (const pattern of exclude)
61
47
  if (pattern.test(fullPath))
62
- return;
48
+ return files;
63
49
  if (filter.test(fullPath))
64
50
  files.add(fullPath);
65
- return;
51
+ return files;
66
52
  }
67
- const dirent = entry;
68
- const fullPath = (0, node_path_1.join)(dirPath, dirent.name);
69
- if (fullPath.indexOf('node_modules') !== -1 ||
70
- fullPath.indexOf('.git/') !== -1)
71
- return;
72
- if (exclude)
73
- for (const pattern of exclude)
74
- if (pattern.test(fullPath))
75
- return;
76
- if (dirent.isFile()) {
77
- if (filter.test(fullPath))
78
- files.add(fullPath);
53
+ const entries = await (0, promises_1.readdir)((0, exports.sanitizePath)(dirPath), {
54
+ withFileTypes: true,
55
+ });
56
+ const subdirs = [];
57
+ for (const entry of entries) {
58
+ if (entry.name === 'node_modules' || entry.name === '.git')
59
+ continue;
60
+ const fullPath = (0, node_path_1.join)(dirPath, entry.name);
61
+ if (exclude?.some((pattern) => pattern.test(fullPath)))
62
+ continue;
63
+ if (entry.isFile()) {
64
+ if (filter.test(fullPath))
65
+ files.add(fullPath);
66
+ }
67
+ else if (entry.isDirectory()) {
68
+ subdirs.push(getAllFilesInner(fullPath, files, filter, exclude));
69
+ }
79
70
  }
80
- else if (dirent.isDirectory())
81
- await getAllFilesInner(fullPath, files, filter, exclude);
82
- }));
83
- return files;
71
+ if (subdirs.length > 0)
72
+ await Promise.all(subdirs);
73
+ return files;
74
+ }
75
+ catch (error) {
76
+ console.error(error);
77
+ process.exit(1);
78
+ }
84
79
  };
85
80
  const getAllFiles = (dirPath, files = new Set(), configs) => {
86
81
  const filter = envFilter ??
@@ -21,11 +21,11 @@ const isAlpha = (code) => (code >= charCode.upperA && code <= charCode.upperZ) |
21
21
  (code >= charCode.lowerA && code <= charCode.lowerZ);
22
22
  const isDigit = (code) => code >= charCode.zero && code <= charCode.nine;
23
23
  const findPathStart = (line) => {
24
-
24
+ // "file://"
25
25
  const protoIndex = line.indexOf(FILE_PROTOCOL);
26
26
  if (protoIndex !== -1)
27
27
  return protoIndex + FILE_PROTOCOL_LENGTH;
28
-
28
+ // Unix absolute path
29
29
  const slashIndex = line.indexOf('/');
30
30
  if (slashIndex === 0)
31
31
  return 0;
@@ -33,7 +33,7 @@ const findPathStart = (line) => {
33
33
  (line.charCodeAt(slashIndex - 1) === charCode.space ||
34
34
  line.charCodeAt(slashIndex - 1) === charCode.openParen))
35
35
  return slashIndex;
36
-
36
+ // Windows absolute path
37
37
  const length = line.length;
38
38
  for (let i = 0; i < length - 2; i++) {
39
39
  if (isAlpha(line.charCodeAt(i)) &&
@@ -21,7 +21,7 @@ const runner = (filename) => {
21
21
  : [];
22
22
  return ['deno', 'run', ...denoAllow, ...denoDeny];
23
23
  }
24
-
24
+ // Node.js
25
25
  const ext = (0, node_path_1.extname)(filename);
26
26
  return ext === '.ts' || ext === '.mts' || ext === '.cts'
27
27
  ? ['node', '--import=tsx']
@@ -2,11 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parserOutput = exports.serialize = void 0;
4
4
  const poku_js_1 = require("../configs/poku.js");
5
- const regex = {
6
- ansi: /\x1b\[0m/,
7
- skip: /\x1b\[94m\x1b\[1m◯/g,
8
- todo: /\x1b\[96m\x1b\[1m●/g,
9
- };
5
+ const SKIP_MARKER = '\x1b[94m\x1b[1m◯';
6
+ const TODO_MARKER = '\x1b[96m\x1b[1m●';
7
+ const ANSI_RESET = '\x1b[0m';
10
8
  const serialize = (value) => {
11
9
  if (typeof value === 'undefined' ||
12
10
  typeof value === 'function' ||
@@ -27,26 +25,27 @@ const serialize = (value) => {
27
25
  exports.serialize = serialize;
28
26
  const parserOutput = (options) => {
29
27
  const { output, result } = options;
30
- const hasSkip = output.match(regex.skip);
31
- if (hasSkip)
32
- poku_js_1.results.skipped += hasSkip.length;
33
- const hasTodo = output.match(regex.todo);
34
- if (hasTodo)
35
- poku_js_1.results.todo += hasTodo.length;
36
28
  const pad = ' ';
37
29
  const isDebugOrFailed = poku_js_1.GLOBAL.configs.debug || !result;
38
- const splittedOutput = output.split('\n');
39
30
  const outputs = [];
40
- for (const line of splittedOutput) {
41
- if (!line || line.trim().length === 0)
42
- continue;
43
- if (!isDebugOrFailed) {
44
- if (line.indexOf('Exited with code') !== -1)
45
- continue;
46
- if (!regex.ansi.test(line))
47
- continue;
31
+ let offset = 0;
32
+ while (offset < output.length) {
33
+ const nextNewline = output.indexOf('\n', offset);
34
+ const lineEnd = nextNewline === -1 ? output.length : nextNewline;
35
+ if (lineEnd > offset) {
36
+ const line = output.substring(offset, lineEnd);
37
+ if (line.includes(SKIP_MARKER))
38
+ poku_js_1.results.skipped++;
39
+ if (line.includes(TODO_MARKER))
40
+ poku_js_1.results.todo++;
41
+ if (line.trim().length > 0) {
42
+ if (isDebugOrFailed ||
43
+ (line.indexOf('Exited with code') === -1 && line.includes(ANSI_RESET))) {
44
+ outputs.push(`${pad}${line}`);
45
+ }
46
+ }
48
47
  }
49
- outputs.push(`${pad}${line}`);
48
+ offset = lineEnd + 1;
50
49
  }
51
50
  if (outputs.length === 0)
52
51
  return;
@@ -32,8 +32,12 @@ const runTestFile = async (path) => {
32
32
  const file = (0, node_path_1.relative)(cwd, path);
33
33
  const showLogs = !configs.quiet;
34
34
  const outputChunks = [];
35
+ let outputSize = 0;
35
36
  const stdOut = (data) => {
36
- outputChunks.push(data);
37
+ if (outputSize < 10_485_760) {
38
+ outputChunks.push(data);
39
+ outputSize += data.length;
40
+ }
37
41
  };
38
42
  const start = (0, node_process_1.hrtime)();
39
43
  let end;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poku",
3
- "version": "4.2.0",
3
+ "version": "4.2.1-canary.0e540bb2",
4
4
  "description": "🐷 Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.",
5
5
  "main": "./lib/modules/index.js",
6
6
  "exports": {
@@ -37,26 +37,21 @@
37
37
  "test": "tsx src/bin/index.ts test/unit test/integration test/e2e",
38
38
  "test:bun": "bun src/bin/index.ts test/unit test/integration test/e2e",
39
39
  "test:deno": "deno run -A src/bin/index.ts --denoAllow=all test/unit test/integration test/e2e",
40
- "pretest:coverage": "tsx tools/build/c8-file.ts",
41
- "test:coverage": "c8 --experimental-monocart npm test",
42
- "posttest:coverage": "rm -rf ./.nycrc.json",
40
+ "test:coverage": "npm test -- -c=.c8.ts",
43
41
  "test:docker:node": "bun test/ci.test.ts",
44
- "clear": "rm -rf lib ci coverage .temp test-src test-tests",
45
- "prebuild": "npm run clear",
46
- "build": "tsc && cd test && tsc",
47
- "postbuild": "tsx tools/compatibility/comments.ts && tsx tools/build/version.ts && cp test/__fixtures__/e2e/server/package.json ci/test/__fixtures__/e2e/server/package.json && rm -f ./lib/@types/*.js ./lib/bin/*.ts && chmod +x lib/bin/index.js",
48
- "lint": "biome lint --error-on-warnings && prettier --check .",
49
- "lint:fix": "biome lint --write && prettier --write .github/workflows/*.yml . && npm --prefix website run lint:fix",
50
- "update": "pu && npm i && npm update && (npm audit fix || true)",
51
- "postupdate": "npm run lint:fix",
42
+ "build": "bash scripts/build.sh",
43
+ "lint": "bash scripts/lint.sh",
44
+ "lint:fix": "bash scripts/lint-fix.sh",
45
+ "update": "bash scripts/update.sh",
52
46
  "benchmark": "npm --prefix benchmark start"
53
47
  },
54
48
  "devDependencies": {
55
49
  "@biomejs/biome": "^2.4.10",
56
50
  "@ianvs/prettier-plugin-sort-imports": "^4.7.1",
51
+ "@pokujs/c8": "^1.0.2",
57
52
  "@pokujs/docker": "^1.0.0",
58
53
  "@types/node": "^25.5.0",
59
- "c8": "^11.0.0",
54
+ "concurrently": "^9.2.1",
60
55
  "jsonc.min": "^1.1.2",
61
56
  "monocart-coverage-reports": "^2.12.9",
62
57
  "packages-update": "^2.0.0",
@@ -64,9 +59,6 @@
64
59
  "tsx": "^4.21.0",
65
60
  "typescript": "^6.0.2"
66
61
  },
67
- "overrides": {
68
- "yargs": "^18.0.0"
69
- },
70
62
  "keywords": [
71
63
  "🐷",
72
64
  "test",
@@ -1 +0,0 @@
1
- export declare const runtimeVersion: number;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runtimeVersion = void 0;
4
- const node_process_1 = require("node:process");
5
- const poku_js_1 = require("../configs/poku.js");
6
- exports.runtimeVersion = (() => {
7
- if (poku_js_1.GLOBAL.runtime === 'bun')
8
- return Number(Bun.version.split('.')[0]);
9
- if (poku_js_1.GLOBAL.runtime === 'deno')
10
- return Number(Deno.version.deno.split('.')[0]);
11
- return Number(node_process_1.version.replace('v', '').split('.')[0]);
12
- })();