poku 2.3.0 → 2.4.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/lib/bin/index.js CHANGED
@@ -1,10 +1,6 @@
1
1
  #! /usr/bin/env node
2
2
  "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
3
  Object.defineProperty(exports, "__esModule", { value: true });
7
- const node_process_1 = __importDefault(require("process"));
8
4
  const list_files_js_1 = require("../modules/helpers/list-files.js");
9
5
  const get_arg_js_1 = require("../parsers/get-arg.js");
10
6
  const files_js_1 = require("../configs/files.js");
@@ -12,14 +8,16 @@ const get_runtime_js_1 = require("../parsers/get-runtime.js");
12
8
  const format_js_1 = require("../services/format.js");
13
9
  const kill_js_1 = require("../modules/helpers/kill.js");
14
10
  const env_js_1 = require("../modules/helpers/env.js");
15
- const map_tests_js_1 = require("../services/map-tests.js");
16
- const watch_js_1 = require("../services/watch.js");
17
11
  const poku_js_1 = require("../modules/essentials/poku.js");
18
12
  const write_js_1 = require("../services/write.js");
19
13
  const options_js_1 = require("../parsers/options.js");
20
- const cpus_js_1 = require("../polyfills/cpus.js");
21
14
  (async () => {
22
15
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
16
+ if ((0, get_arg_js_1.hasArg)('version') || (0, get_arg_js_1.hasArg)('v', '-')) {
17
+ const { VERSION } = require('../configs/poku.js');
18
+ write_js_1.Write.log(VERSION);
19
+ return;
20
+ }
23
21
  const configFile = (0, get_arg_js_1.getArg)('config') || (0, get_arg_js_1.getArg)('c', '-');
24
22
  const defaultConfigs = await (0, options_js_1.getConfigs)(configFile);
25
23
  const dirs = (() => {
@@ -62,6 +60,27 @@ const cpus_js_1 = require("../polyfills/cpus.js");
62
60
  if (dirs.length === 1) {
63
61
  files_js_1.states.isSinglePath = true;
64
62
  }
63
+ if ((0, get_arg_js_1.hasArg)('list-files')) {
64
+ const { listFiles } = require('../modules/helpers/list-files.js');
65
+ let total = 0;
66
+ write_js_1.Write.hr();
67
+ for (const dir of dirs) {
68
+ const files = await listFiles(dir, {
69
+ filter: typeof filter === 'string'
70
+ ? new RegExp((0, list_files_js_1.escapeRegExp)(filter))
71
+ : filter,
72
+ exclude: typeof exclude === 'string'
73
+ ? new RegExp((0, list_files_js_1.escapeRegExp)(exclude))
74
+ : exclude,
75
+ });
76
+ total += files.length;
77
+ write_js_1.Write.log(files.map((file) => `${(0, format_js_1.format)('-').dim()} ${file}`).join('\n'));
78
+ }
79
+ write_js_1.Write.hr();
80
+ write_js_1.Write.log(`Total test files: ${(0, format_js_1.format)(String(total)).bold()}`);
81
+ write_js_1.Write.hr();
82
+ return;
83
+ }
65
84
  const tasks = [];
66
85
 
67
86
  if (killPort || ((_j = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _j === void 0 ? void 0 : _j.port)) {
@@ -126,97 +145,10 @@ const cpus_js_1 = require("../polyfills/cpus.js");
126
145
  write_js_1.Write.log(`${(0, format_js_1.format)('…').info().italic()} ${(0, format_js_1.format)('Options').bold()}`);
127
146
  console.dir(options, { depth: null, colors: true });
128
147
  }
129
- const watchers = new Set();
130
- const executing = new Set();
131
- const interval = Number((0, get_arg_js_1.getArg)('watch-interval')) || 1500;
132
- let isRunning = false;
133
-
134
- const listenStdin = (input) => {
135
- if (isRunning || executing.size > 0) {
136
- return;
137
- }
138
- if (String(input).trim() === 'rs') {
139
- for (const watcher of watchers) {
140
- watcher.stop();
141
- }
142
- watchers.clear();
143
- resultsClear();
144
- startTests();
145
- }
146
- };
147
-
148
- const resultsClear = () => {
149
- files_js_1.fileResults.success.clear();
150
- files_js_1.fileResults.fail.clear();
151
- };
152
- const startTests = () => {
153
- if (isRunning || executing.size > 0) {
154
- return;
155
- }
156
- isRunning = true;
157
- Promise.all(tasks).then(() => {
158
- (0, poku_js_1.poku)(dirs, options)
159
- .then(() => {
160
- if (watchMode) {
161
-
162
- node_process_1.default.stdin.removeListener('data', listenStdin);
163
- node_process_1.default.removeListener('SIGINT', poku_js_1.onSigint);
164
- resultsClear();
165
- (0, map_tests_js_1.mapTests)('.', dirs, options.filter, options.exclude).then((mappedTests) => {
166
- for (const mappedTest of Array.from(mappedTests.keys())) {
167
- const currentWatcher = (0, watch_js_1.watch)(mappedTest, (file, event) => {
168
- if (event === 'change') {
169
- const filePath = (0, map_tests_js_1.normalizePath)(file);
170
- if (executing.has(filePath)) {
171
- return;
172
- }
173
- executing.add(filePath);
174
- resultsClear();
175
- const tests = mappedTests.get(filePath);
176
- if (!tests) {
177
- return;
178
- }
179
- (0, poku_js_1.poku)(Array.from(tests), {
180
- ...options,
181
- concurrency: concurrency !== null && concurrency !== void 0 ? concurrency : Math.max(Math.floor((0, cpus_js_1.availableParallelism)() / 2), 1),
182
- }).then(() => {
183
- setTimeout(() => {
184
- executing.delete(filePath);
185
- }, interval);
186
- });
187
- }
188
- });
189
- currentWatcher.then((watcher) => watchers.add(watcher));
190
- }
191
- });
192
- for (const dir of dirs) {
193
- const currentWatcher = (0, watch_js_1.watch)(dir, (file, event) => {
194
- if (event === 'change') {
195
- if (executing.has(file)) {
196
- return;
197
- }
198
- executing.add(file);
199
- resultsClear();
200
- (0, poku_js_1.poku)(file, options).then(() => {
201
- setTimeout(() => {
202
- executing.delete(file);
203
- }, interval);
204
- });
205
- }
206
- });
207
- currentWatcher.then((watcher) => watchers.add(watcher));
208
- }
209
- write_js_1.Write.hr();
210
- write_js_1.Write.log(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
211
-
212
- node_process_1.default.stdin.setEncoding('utf-8');
213
- node_process_1.default.stdin.on('data', listenStdin);
214
- }
215
- })
216
- .finally(() => {
217
- isRunning = false;
218
- });
219
- });
220
- };
221
- startTests();
148
+ await Promise.all(tasks);
149
+ await (0, poku_js_1.poku)(dirs, options);
150
+ if (watchMode) {
151
+ const { startWatch } = require('./watch.js');
152
+ await startWatch(dirs, options);
153
+ }
222
154
  })();
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.startWatch = void 0;
7
+ const map_tests_js_1 = require("../services/map-tests.js");
8
+ const watch_js_1 = require("../services/watch.js");
9
+ const poku_js_1 = require("../modules/essentials/poku.js");
10
+ const write_js_1 = require("../services/write.js");
11
+ const node_process_1 = __importDefault(require("process"));
12
+ const format_js_1 = require("../services/format.js");
13
+ const get_arg_js_1 = require("../parsers/get-arg.js");
14
+ const files_js_1 = require("../configs/files.js");
15
+ const cpus_js_1 = require("../polyfills/cpus.js");
16
+ const startWatch = async (dirs, options) => {
17
+ let isRunning = false;
18
+ const watchers = new Set();
19
+ const executing = new Set();
20
+ const interval = Number((0, get_arg_js_1.getArg)('watch-interval')) || 1500;
21
+ const setIsRunning = (value) => {
22
+ isRunning = value;
23
+ };
24
+ const resultsClear = () => {
25
+ files_js_1.fileResults.success.clear();
26
+ files_js_1.fileResults.fail.clear();
27
+ };
28
+ const listenStdin = async (input) => {
29
+ if (isRunning || executing.size > 0) {
30
+ return;
31
+ }
32
+ if (String(input).trim() === 'rs') {
33
+ for (const watcher of watchers) {
34
+ watcher.stop();
35
+ }
36
+ watchers.clear();
37
+ resultsClear();
38
+ await (0, poku_js_1.poku)(dirs, options);
39
+ }
40
+ };
41
+ node_process_1.default.stdin.removeListener('data', listenStdin);
42
+ node_process_1.default.removeListener('SIGINT', poku_js_1.onSigint);
43
+ resultsClear();
44
+ const mappedTests = await (0, map_tests_js_1.mapTests)('.', dirs, options.filter, options.exclude);
45
+ for (const mappedTest of Array.from(mappedTests.keys())) {
46
+ const currentWatcher = (0, watch_js_1.watch)(mappedTest, async (file, event) => {
47
+ var _a;
48
+ if (event === 'change') {
49
+ const filePath = (0, map_tests_js_1.normalizePath)(file);
50
+ if (executing.has(filePath) || isRunning || executing.size > 0) {
51
+ return;
52
+ }
53
+ setIsRunning(true);
54
+ executing.add(filePath);
55
+ resultsClear();
56
+ const tests = mappedTests.get(filePath);
57
+ if (!tests) {
58
+ return;
59
+ }
60
+ await (0, poku_js_1.poku)(Array.from(tests), {
61
+ ...options,
62
+ concurrency: (_a = options.concurrency) !== null && _a !== void 0 ? _a : Math.max(Math.floor((0, cpus_js_1.availableParallelism)() / 2), 1),
63
+ });
64
+ setTimeout(() => {
65
+ executing.delete(filePath);
66
+ setIsRunning(false);
67
+ }, interval);
68
+ }
69
+ });
70
+ currentWatcher.then((watcher) => watchers.add(watcher));
71
+ }
72
+ for (const dir of dirs) {
73
+ const currentWatcher = (0, watch_js_1.watch)(dir, (file, event) => {
74
+ if (event === 'change') {
75
+ if (executing.has(file) || isRunning || executing.size > 0) {
76
+ return;
77
+ }
78
+ setIsRunning(true);
79
+ executing.add(file);
80
+ resultsClear();
81
+ (0, poku_js_1.poku)(file, options).then(() => {
82
+ setTimeout(() => {
83
+ executing.delete(file);
84
+ setIsRunning(false);
85
+ }, interval);
86
+ });
87
+ }
88
+ });
89
+ currentWatcher.then((watcher) => watchers.add(watcher));
90
+ }
91
+ write_js_1.Write.hr();
92
+ write_js_1.Write.log(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
93
+ node_process_1.default.stdin.setEncoding('utf-8');
94
+ node_process_1.default.stdin.on('data', listenStdin);
95
+ };
96
+ exports.startWatch = startWatch;
@@ -4,3 +4,4 @@ export declare const results: {
4
4
  skip: number;
5
5
  todo: number;
6
6
  };
7
+ export declare const VERSION = "";
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.results = void 0;
3
+ exports.VERSION = exports.results = void 0;
4
4
  exports.results = {
5
5
  success: 0,
6
6
  fail: 0,
7
7
  skip: 0,
8
8
  todo: 0,
9
9
  };
10
+ exports.VERSION = '2.4.0';
@@ -1,2 +1,2 @@
1
1
  /** By default **Poku** only shows outputs generated from itself. This helper allows you to use an alternative to `console.log` with **Poku**. */
2
- export declare const log: (message: string) => void;
2
+ export declare const log: (...args: unknown[]) => void;
@@ -1,7 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.log = void 0;
4
+ const assert_js_1 = require("../../parsers/assert.js");
4
5
  const write_js_1 = require("../../services/write.js");
5
6
  /** By default **Poku** only shows outputs generated from itself. This helper allows you to use an alternative to `console.log` with **Poku**. */
6
- const log = (message) => write_js_1.Write.log(`\x1b[0m${message}\x1b[0m`);
7
+ const log = (...args) => {
8
+ const parsedMessages = args
9
+ .map((arg) => (0, assert_js_1.parseResultType)(arg))
10
+ .join(' ')
11
+ .split('\n')
12
+ .map((line) => `\x1b[0m${line}\x1b[0m`)
13
+ .join('\n');
14
+ write_js_1.Write.log(parsedMessages);
15
+ };
7
16
  exports.log = log;
@@ -16,6 +16,7 @@ export { getPIDs } from './helpers/get-pids.js';
16
16
  export { exit } from './helpers/exit.js';
17
17
  export { log } from './helpers/log.js';
18
18
  export { listFiles } from './helpers/list-files.js';
19
+ export { VERSION as version } from '../configs/poku.js';
19
20
  export type { Code } from '../@types/code.js';
20
21
  export type { Configs } from '../@types/poku.js';
21
22
  export type { DockerComposeConfigs, DockerfileConfigs, } from '../@types/container.js';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defineConfig = exports.listFiles = exports.log = exports.exit = exports.getPIDs = exports.kill = exports.sleep = exports.waitForPort = exports.waitForExpectedResult = exports.startService = exports.startScript = exports.docker = exports.afterEach = exports.beforeEach = exports.skip = exports.envFile = exports.it = exports.describe = exports.test = exports.strict = exports.assert = exports.poku = void 0;
3
+ exports.defineConfig = exports.version = exports.listFiles = exports.log = exports.exit = exports.getPIDs = exports.kill = exports.sleep = exports.waitForPort = exports.waitForExpectedResult = exports.startService = exports.startScript = exports.docker = exports.afterEach = exports.beforeEach = exports.skip = exports.envFile = exports.it = exports.describe = exports.test = exports.strict = exports.assert = exports.poku = void 0;
4
4
  var poku_js_1 = require("./essentials/poku.js");
5
5
  Object.defineProperty(exports, "poku", { enumerable: true, get: function () { return poku_js_1.poku; } });
6
6
  var assert_js_1 = require("./essentials/assert.js");
@@ -39,6 +39,8 @@ var log_js_1 = require("./helpers/log.js");
39
39
  Object.defineProperty(exports, "log", { enumerable: true, get: function () { return log_js_1.log; } });
40
40
  var list_files_js_1 = require("./helpers/list-files.js");
41
41
  Object.defineProperty(exports, "listFiles", { enumerable: true, get: function () { return list_files_js_1.listFiles; } });
42
+ var poku_js_2 = require("../configs/poku.js");
43
+ Object.defineProperty(exports, "version", { enumerable: true, get: function () { return poku_js_2.VERSION; } });
42
44
  /** 🐷 Auxiliary function to define the `poku` configurations */
43
45
  const defineConfig = (options) => options;
44
46
  exports.defineConfig = defineConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poku",
3
- "version": "2.3.0",
3
+ "version": "2.4.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",
@@ -51,7 +51,7 @@
51
51
  "clear": "rm -rf lib ci coverage .temp test-src test-tests",
52
52
  "prebuild": "npm run clear",
53
53
  "build": "tsc && tsc -p tsconfig.test.json",
54
- "postbuild": "tsx tools/compatibility/node.ts && tsx tools/compatibility/comments.ts && cp fixtures/server/package.json ci/fixtures/server/package.json && rm -f ./lib/@types/*.js ./lib/bin/*.ts && npm run build:deno && chmod +x lib/bin/index.js",
54
+ "postbuild": "tsx tools/compatibility/node.ts && tsx tools/compatibility/comments.ts && tsx tools/build/version.ts && cp fixtures/server/package.json ci/fixtures/server/package.json && rm -f ./lib/@types/*.js ./lib/bin/*.ts && npm run build:deno && chmod +x lib/bin/index.js",
55
55
  "build:deno": "tsc -p tsconfig.mjs.json",
56
56
  "postbuild:deno": "tsx tools/build/check-deno-polyfill.ts",
57
57
  "lint": "npx @biomejs/biome lint && prettier --check .",
@@ -62,13 +62,13 @@
62
62
  },
63
63
  "devDependencies": {
64
64
  "@biomejs/biome": "1.8.3",
65
- "@types/node": "^22.0.0",
65
+ "@types/node": "^22.0.2",
66
66
  "c8": "^10.1.2",
67
67
  "jsonc.min": "^1.0.0",
68
68
  "monocart-coverage-reports": "^2.10.0",
69
69
  "packages-update": "^2.0.0",
70
70
  "prettier": "^3.3.3",
71
- "tsx": "4.16.3",
71
+ "tsx": "4.16.5",
72
72
  "typescript": "^5.5.4"
73
73
  },
74
74
  "keywords": [