poku 1.20.2 → 1.21.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024-current Weslley Araújo ([@wellwelwel](https://github.com/wellwelwel)).
3
+ Copyright (c) 2024-current Weslley Araújo (@wellwelwel)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -12,6 +12,10 @@ Enjoying **Poku**? Give him a star to show your support 🌟
12
12
  [![GitHub Workflow Status (with event)][ci-osx-image]][ci-osx-url]
13
13
  [![GitHub Workflow Status (with event)][ci-windows-image]][ci-windows-url]
14
14
 
15
+ ---
16
+
17
+ 🐷 [Documentation](https://poku.io)<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>🧪 [Examples](https://poku.io/docs/category/examples)<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>🔬 [Compare the Most Popular Test Runners](https://poku.io/docs/comparing)
18
+
15
19
  </div>
16
20
 
17
21
  ---
@@ -22,7 +26,7 @@ Enjoying **Poku**? Give him a star to show your support 🌟
22
26
 
23
27
  <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> No configurations<br />
24
28
  <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><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 />
25
- <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><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 />
29
+ <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><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 />
26
30
 
27
31
  <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Easier and Less Verbose<br />
28
32
  <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> [**Node.js**][node-version-url] familiar **API**<br />
@@ -134,11 +138,9 @@ deno run npm:poku
134
138
  </tr>
135
139
  </table>
136
140
 
137
- - That's it 🎉
141
+ > Try the flag `--parallel` to run tests in parallel.
138
142
 
139
- ---
140
-
141
- 🐷 [**Documentation**](https://poku.io)<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>🧪 [**Examples**](https://poku.io/docs/category/examples)<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>🔬 [**Compare the Most Popular Test Runners**](https://poku.io/docs/comparing)
143
+ - That's it 🎉
142
144
 
143
145
  ---
144
146
 
@@ -246,5 +248,5 @@ Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/
246
248
  [coverage-url]: https://app.codecov.io/github/wellwelwel/poku
247
249
  [downloads-image]: https://img.shields.io/npm/dt/poku.svg?logo=npm&logoColor=white&color=1e90ff
248
250
  [downloads-url]: https://www.npmjs.com/package/poku
249
- [license-url]: https://licenses.dev/npm/poku
250
- [license-image]: https://licenses.dev/b/npm/poku
251
+ [license-url]: https://github.com/wellwelwel/poku/blob/main/LICENSE
252
+ [license-image]: https://img.shields.io/npm/l/poku?maxAge=2592000&color=9c88ff
package/lib/bin/index.js CHANGED
@@ -87,58 +87,89 @@ if (debug) {
87
87
  write_js_1.Write.log(`${(0, format_js_1.format)('…').info().italic()} ${(0, format_js_1.format)('Options').bold()}`);
88
88
  console.dir(options, { depth: null, colors: true });
89
89
  }
90
- Promise.all(tasks).then(() => {
91
- (0, poku_js_1.poku)(dirs, options).then(() => {
92
- if (watchMode) {
93
- const executing = new Set();
94
- const interval = Number((0, get_arg_js_1.getArg)('watch-interval')) || 1500;
95
- const resultsClear = () => {
96
- files_js_1.fileResults.success.clear();
97
- files_js_1.fileResults.fail.clear();
98
- };
99
- node_process_1.default.removeListener('SIGINT', poku_js_1.onSigint);
100
- resultsClear();
101
- (0, map_tests_js_1.mapTests)('.', dirs, options.filter, options.exclude).then((mappedTests) => {
102
- for (const mappedTest of Array.from(mappedTests.keys())) {
103
- (0, watch_js_1.watch)(mappedTest, (file, event) => {
90
+ const watchers = new Set();
91
+ const executing = new Set();
92
+ const interval = Number((0, get_arg_js_1.getArg)('watch-interval')) || 1500;
93
+ let isRunning = false;
94
+ const listenStdin = (input) => {
95
+ if (isRunning || executing.size > 0) {
96
+ return;
97
+ }
98
+ if (String(input).trim() === 'rs') {
99
+ for (const watcher of watchers) {
100
+ watcher.stop();
101
+ }
102
+ watchers.clear();
103
+ resultsClear();
104
+ startTests();
105
+ }
106
+ };
107
+ const resultsClear = () => {
108
+ files_js_1.fileResults.success.clear();
109
+ files_js_1.fileResults.fail.clear();
110
+ };
111
+ const startTests = () => {
112
+ if (isRunning || executing.size > 0) {
113
+ return;
114
+ }
115
+ isRunning = true;
116
+ Promise.all(tasks).then(() => {
117
+ (0, poku_js_1.poku)(dirs, options)
118
+ .then(() => {
119
+ if (watchMode) {
120
+ node_process_1.default.stdin.removeListener('data', listenStdin);
121
+ node_process_1.default.removeListener('SIGINT', poku_js_1.onSigint);
122
+ resultsClear();
123
+ (0, map_tests_js_1.mapTests)('.', dirs, options.filter, options.exclude).then((mappedTests) => {
124
+ for (const mappedTest of Array.from(mappedTests.keys())) {
125
+ const currentWatcher = (0, watch_js_1.watch)(mappedTest, (file, event) => {
126
+ if (event === 'change') {
127
+ const filePath = (0, map_tests_js_1.normalizePath)(file);
128
+ if (executing.has(filePath)) {
129
+ return;
130
+ }
131
+ executing.add(filePath);
132
+ resultsClear();
133
+ const tests = mappedTests.get(filePath);
134
+ if (!tests) {
135
+ return;
136
+ }
137
+ (0, poku_js_1.poku)(Array.from(tests), options).then(() => {
138
+ setTimeout(() => {
139
+ executing.delete(filePath);
140
+ }, interval);
141
+ });
142
+ }
143
+ });
144
+ currentWatcher.then((watcher) => watchers.add(watcher));
145
+ }
146
+ });
147
+ for (const dir of dirs) {
148
+ const currentWatcher = (0, watch_js_1.watch)(dir, (file, event) => {
104
149
  if (event === 'change') {
105
- const filePath = (0, map_tests_js_1.normalizePath)(file);
106
- if (executing.has(filePath)) {
150
+ if (executing.has(file)) {
107
151
  return;
108
152
  }
109
- executing.add(filePath);
153
+ executing.add(file);
110
154
  resultsClear();
111
- const tests = mappedTests.get(filePath);
112
- if (!tests) {
113
- return;
114
- }
115
- (0, poku_js_1.poku)(Array.from(tests), options).then(() => {
155
+ (0, poku_js_1.poku)(file, options).then(() => {
116
156
  setTimeout(() => {
117
- executing.delete(filePath);
157
+ executing.delete(file);
118
158
  }, interval);
119
159
  });
120
160
  }
121
161
  });
162
+ currentWatcher.then((watcher) => watchers.add(watcher));
122
163
  }
123
- });
124
- for (const dir of dirs) {
125
- (0, watch_js_1.watch)(dir, (file, event) => {
126
- if (event === 'change') {
127
- if (executing.has(file)) {
128
- return;
129
- }
130
- executing.add(file);
131
- resultsClear();
132
- (0, poku_js_1.poku)(file, options).then(() => {
133
- setTimeout(() => {
134
- executing.delete(file);
135
- }, interval);
136
- });
137
- }
138
- });
164
+ write_js_1.Write.hr();
165
+ write_js_1.Write.log(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
166
+ node_process_1.default.stdin.setEncoding('utf-8');
167
+ node_process_1.default.stdin.on('data', listenStdin);
139
168
  }
140
- write_js_1.Write.hr();
141
- write_js_1.Write.log(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
142
- }
169
+ })
170
+ .finally(() => {
171
+ isRunning = false;
172
+ });
143
173
  });
144
- });
174
+ };
175
+ startTests();
@@ -36,13 +36,11 @@ const isFile = (fullPath) => __awaiter(void 0, void 0, void 0, function* () { re
36
36
  exports.isFile = isFile;
37
37
  const escapeRegExp = (string) => string.replace(regex.safeRegExp, '\\$&');
38
38
  exports.escapeRegExp = escapeRegExp;
39
- /* c8 ignore next 3 */
40
39
  const envFilter = ((_a = node_process_1.env.FILTER) === null || _a === void 0 ? void 0 : _a.trim())
41
40
  ? new RegExp((0, exports.escapeRegExp)(node_process_1.env.FILTER), 'i')
42
41
  : undefined;
43
42
  const getAllFiles = (dirPath_1, ...args_1) => __awaiter(void 0, [dirPath_1, ...args_1], void 0, function* (dirPath, files = new Set(), configs) {
44
43
  const currentFiles = yield (0, fs_js_1.readdir)((0, exports.sanitizePath)(dirPath));
45
- /* c8 ignore next 3 */
46
44
  const filter = envFilter
47
45
  ? envFilter
48
46
  : (configs === null || configs === void 0 ? void 0 : configs.filter) instanceof RegExp
@@ -62,8 +60,8 @@ const getAllFiles = (dirPath_1, ...args_1) => __awaiter(void 0, [dirPath_1, ...a
62
60
  return;
63
61
  }
64
62
  if (exclude) {
65
- for (let i = 0; i < exclude.length; i++) {
66
- if (exclude[i].test(fullPath)) {
63
+ for (const pattern of exclude) {
64
+ if (pattern.test(fullPath)) {
67
65
  return;
68
66
  }
69
67
  }
@@ -1,4 +1 @@
1
- /**
2
- * Allows testing CJS files with `require` and `exports` in Deno.
3
- */
4
1
  export {};
@@ -1,13 +1,13 @@
1
- import { createRequire } from "node:module";
2
- import process from "node:process";
3
- import { resolve, normalize } from "node:path";
1
+ import process from 'node:process';
2
+ import { createRequire } from 'node:module';
3
+ import { resolve, normalize } from 'node:path';
4
4
  const file = process.env?.FILE;
5
5
  if (!file) {
6
- process.exit(1);
6
+ process.exit(1);
7
7
  }
8
8
  const cwd = process.cwd();
9
- const targetPath = resolve(cwd, "");
9
+ const targetPath = resolve(cwd, '');
10
10
  const filePath = resolve(targetPath, file);
11
11
  globalThis.require = createRequire(targetPath);
12
- globalThis.exports = {};
12
+ globalThis.exports = Object.create(null);
13
13
  require(normalize(filePath));
@@ -1,5 +1,5 @@
1
1
  import type { WatchCallback } from '../@types/watch.js';
2
- declare class Watcher {
2
+ export declare class Watcher {
3
3
  private rootDir;
4
4
  private files;
5
5
  private fileWatchers;
@@ -15,4 +15,3 @@ declare class Watcher {
15
15
  private unwatchDirectories;
16
16
  }
17
17
  export declare const watch: (path: string, callback: WatchCallback) => Promise<Watcher>;
18
- export {};
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.watch = void 0;
12
+ exports.watch = exports.Watcher = void 0;
13
13
  const node_fs_1 = require("fs");
14
14
  const node_path_1 = require("path");
15
15
  const fs_js_1 = require("../polyfills/fs.js");
@@ -111,6 +111,7 @@ class Watcher {
111
111
  }
112
112
  }
113
113
  }
114
+ exports.Watcher = Watcher;
114
115
  /* c8 ignore next */ // ?
115
116
  const watch = (path, callback) => __awaiter(void 0, void 0, void 0, function* () {
116
117
  const watcher = new Watcher(path, callback);
@@ -1,5 +1,5 @@
1
1
  import type { Formatter } from '../services/format.js';
2
- export declare class Write {
3
- static log(data: string | Uint8Array | Formatter): void;
4
- static hr(): void;
5
- }
2
+ export declare const Write: {
3
+ readonly log: (data: string | Uint8Array | Formatter) => void;
4
+ readonly hr: () => void;
5
+ };
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Write = void 0;
4
4
  const node_process_1 = require("process");
5
- class Write {
6
- static log(data) {
5
+ exports.Write = {
6
+ log: (data) => {
7
7
  node_process_1.stdout.write(`${String(data)}\n`);
8
- }
9
- static hr() {
8
+ },
9
+ hr: () => {
10
10
  const line = '⎯'.repeat(node_process_1.stdout.columns - 10 || 40);
11
- this.log(`\n\x1b[2m\x1b[90m${line}\x1b[0m\n`);
12
- }
13
- }
14
- exports.Write = Write;
11
+ exports.Write.log(`\n\x1b[2m\x1b[90m${line}\x1b[0m\n`);
12
+ },
13
+ /* c8 ignore next */ // ?
14
+ };
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "poku",
3
- "version": "1.20.2",
3
+ "version": "1.21.0",
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
  "license": "MIT",
7
+ "type": "commonjs",
7
8
  "bin": {
8
9
  "poku": "./lib/bin/index.js"
9
10
  },
@@ -16,9 +17,11 @@
16
17
  "url": "https://github.com/wellwelwel/poku/issues"
17
18
  },
18
19
  "author": "https://github.com/wellwelwel",
19
- "files": [
20
- "lib"
21
- ],
20
+ "funding": {
21
+ "type": "github",
22
+ "url": "https://github.com/sponsors/wellwelwel"
23
+ },
24
+ "files": ["lib"],
22
25
  "engines": {
23
26
  "node": ">=6.0.0",
24
27
  "bun": ">=1.0.0",
@@ -46,31 +49,22 @@
46
49
  "prebuild": "npm run clear",
47
50
  "build": "tsc && tsc -p tsconfig.test.json",
48
51
  "postbuild": "tsx tools/compatibility/node.ts && shx cp fixtures/server/package.json ci/fixtures/server/package.json && npm run build:deno && shx chmod +x lib/bin/index.js",
49
- "build:deno": "esbuild src/polyfills/deno.mts --outfile=lib/polyfills/deno.mjs --format=esm",
50
- "eslint:check": "eslint . --ext .js,.ts",
51
- "eslint:fix": "eslint . --fix --config .eslintrc.json",
52
- "lint:check": "npm run eslint:check && npm run prettier:check",
53
- "lint:fix": "npm run eslint:fix && npm run prettier:fix",
54
- "prettier:check": "prettier --check .",
55
- "prettier:fix": "prettier --write .github/workflows/*.yml .",
52
+ "build:deno": "tsc -p tsconfig.mjs.json",
53
+ "postbuild:deno": "tsx tools/build/check-deno-polyfill.ts",
54
+ "lint:check": "npx @biomejs/biome lint && npx @biomejs/biome format",
55
+ "lint:fix": "npx @biomejs/biome lint --write && npx @biomejs/biome format --write",
56
56
  "update": "pu minor && npm i && npm audit fix",
57
57
  "postupdate": "npm run lint:fix",
58
58
  "benchmark": "cd benchmark && npm ci && npm start"
59
59
  },
60
60
  "devDependencies": {
61
+ "@biomejs/biome": "1.8.3",
61
62
  "@types/node": "^20.14.9",
62
- "@typescript-eslint/eslint-plugin": "^7.14.1",
63
- "@typescript-eslint/parser": "^7.14.1",
64
63
  "c8": "^10.1.2",
65
- "esbuild": "^0.22.0",
66
- "eslint": "^8.57.0",
67
- "eslint-config-prettier": "^9.1.0",
68
- "eslint-plugin-prettier": "^5.1.3",
69
64
  "packages-update": "^2.0.0",
70
- "prettier": "^3.3.2",
71
65
  "shx": "^0.3.4",
72
66
  "tsx": "4.16.0",
73
- "typescript": "^5.5.2"
67
+ "typescript": "^5.5.3"
74
68
  },
75
69
  "keywords": [
76
70
  "🐷",
@@ -94,7 +88,6 @@
94
88
  "queuing",
95
89
  "run",
96
90
  "cli",
97
- "cli-app",
98
91
  "unit",
99
92
  "integration",
100
93
  "e2e",
@@ -132,7 +125,6 @@
132
125
  "expect",
133
126
  "framework",
134
127
  "tool",
135
- "tools",
136
128
  "runtime",
137
129
  "poku",
138
130
  "pokujs"