You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP β†’

poku

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

poku - npm Package Compare versions

Comparing version

to
3.0.0-rc.0

import type { Runner } from './runner.js';
import type { Configs } from './poku.js';
type BackgroundProcessOptions = {

@@ -40,9 +39,4 @@ /**

} & BackgroundProcessOptions;
export type StartServiceOptions = {
/**
* By default, Poku will try to identify the actual platform, but you can specify it manually
*/
readonly platform?: Configs['platform'];
} & BackgroundProcessOptions;
export type StartServiceOptions = BackgroundProcessOptions;
export type End = (port?: number | number[]) => Promise<void>;
export {};

@@ -34,10 +34,4 @@ import type { Configs as ListFilesConfigs } from './list-files.js';

*/
parallel?: boolean;
sequential?: boolean;
/**
* Determines the platform for test execution.
*
* @default 'node'
*/
platform?: Runtime;
/**
* Stops the tests at the first failure.

@@ -51,3 +45,3 @@ *

*
* @default 0
* @default (availableParallelism() || cpus().lenght) - 1
*/

@@ -54,0 +48,0 @@ concurrency?: number;

@@ -9,7 +9,5 @@ "use strict";

const allowedFlags = new Set([
'--bun',
'--concurrency',
'--config',
'--debug',
'--deno',
'--denoAllow',

@@ -26,7 +24,5 @@ '--denoCjs',

'--killRange',
'--node',
'--only',
'--parallel',
'--platform',
'--quiet',
'--sequential',
'--watch',

@@ -36,3 +32,2 @@ '--watchInterval',

'-d',
'-p',
'-q',

@@ -39,0 +34,0 @@ '-w',

@@ -14,7 +14,5 @@ "use strict";

const summary = [
['--bun', 'Enforce tests to run through Bun.'],
['--concurrency', 'Limit the number of tests running concurrently.'],
['--config, -c', 'Specify a configuration file.'],
['--debug, -d', 'Show detailed logs.'],
['--deno', 'Enforce tests to run through Deno.'],
['--denoAllow', 'Allow permissions for Deno.'],

@@ -33,7 +31,5 @@ ['--denoCjs', 'Support CommonJS in Deno.'],

['--listFiles', 'Display all the files returned in the terminal.'],
['--node', 'Enforce tests to run through Node.js.'],
['--only', 'Enable selective execution of tests.'],
['--parallel, -p', 'Run tests files in parallel.'],
['--platform', 'Enforce tests to run through a platform.'],
['--quiet, -q', 'Run tests with no logs.'],
['--sequential', 'Run tests files sequentially.'],
['--version, -v', "Show Poku's installed version."],

@@ -53,8 +49,2 @@ ['--watch, -w', 'Watch for test events.'],

β€Ί ${u(b('Ensuring platforms:'))}
poku ${b('--node')} ${options} ${paths}
poku ${b('--bun')} ${options} ${paths}
poku ${b('--deno')} ${options} ${paths}
β€Ί ${u(b('Tips:'))}

@@ -61,0 +51,0 @@

@@ -7,3 +7,2 @@ #! /usr/bin/env node

const files_js_1 = require("../configs/files.js");
const get_runtime_js_1 = require("../parsers/get-runtime.js");
const format_js_1 = require("../services/format.js");

@@ -16,3 +15,2 @@ const kill_js_1 = require("../modules/helpers/kill.js");

(async () => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
if ((0, get_arg_js_1.hasArg)('version') || (0, get_arg_js_1.hasArg)('v', '-')) {

@@ -31,40 +29,34 @@ const { VERSION } = require('../configs/poku.js');

const defaultConfigs = await (0, options_js_1.getConfigs)(configFile);
const dirs = (() => {
var _a;
const includeArg = (0, get_arg_js_1.getArg)('include');
if (includeArg !== undefined)
return includeArg.split(',');
return ((_a = (0, get_arg_js_1.getPaths)('-')) !== null && _a !== void 0 ? _a : ((defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.include)
? Array.prototype.concat(defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.include)
: ['.']));
})();
const platform = (0, get_arg_js_1.getArg)('platform');
const filter = (_a = (0, get_arg_js_1.getArg)('filter')) !== null && _a !== void 0 ? _a : defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.filter;
const exclude = (_b = (0, get_arg_js_1.getArg)('exclude')) !== null && _b !== void 0 ? _b : defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.exclude;
const killPort = (0, get_arg_js_1.getArg)('killport');
const killRange = (0, get_arg_js_1.getArg)('killrange');
const killPID = (0, get_arg_js_1.getArg)('killpid');
const dirs = (0, get_arg_js_1.getPaths)('-') ??
(defaultConfigs?.include
? Array.prototype.concat(defaultConfigs?.include)
: ['.']);
const filter = (0, get_arg_js_1.getArg)('filter') ?? defaultConfigs?.filter;
const exclude = (0, get_arg_js_1.getArg)('exclude') ?? defaultConfigs?.exclude;
const killPort = (0, get_arg_js_1.getArg)('killPort');
const killRange = (0, get_arg_js_1.getArg)('killRange');
const killPID = (0, get_arg_js_1.getArg)('killPid');
const denoAllow = (_c = (0, get_arg_js_1.argToArray)('denoallow')) !== null && _c !== void 0 ? _c : (_d = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _d === void 0 ? void 0 : _d.allow;
const denoDeny = (_e = (0, get_arg_js_1.argToArray)('denodeny')) !== null && _e !== void 0 ? _e : (_f = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _f === void 0 ? void 0 : _f.deny;
const denoCJS = ((_g = (0, get_arg_js_1.getArg)('denocjs')) === null || _g === void 0 ? void 0 : _g.split(',').map((a) => a.trim()).filter((a) => a)) ||
(0, get_arg_js_1.hasArg)('denocjs') ||
((_h = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _h === void 0 ? void 0 : _h.cjs);
const denoAllow = (0, get_arg_js_1.argToArray)('denoAllow') ?? defaultConfigs?.deno?.allow;
const denoDeny = (0, get_arg_js_1.argToArray)('denoDeny') ?? defaultConfigs?.deno?.deny;
const denoCJS = (0, get_arg_js_1.getArg)('denoCjs')
?.split(',')
.map((a) => a.trim())
.filter((a) => a) ||
(0, get_arg_js_1.hasArg)('denoCjs') ||
defaultConfigs?.deno?.cjs;
const parallel = (0, get_arg_js_1.hasArg)('parallel') || (0, get_arg_js_1.hasArg)('p', '-') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel);
const quiet = (0, get_arg_js_1.hasArg)('quiet') || (0, get_arg_js_1.hasArg)('q', '-') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.quiet);
const debug = (0, get_arg_js_1.hasArg)('debug') || (0, get_arg_js_1.hasArg)('d', '-') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.debug);
const failFast = (0, get_arg_js_1.hasArg)('failfast') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.failFast);
const quiet = (0, get_arg_js_1.hasArg)('quiet') || (0, get_arg_js_1.hasArg)('q', '-') || defaultConfigs?.quiet;
const debug = (0, get_arg_js_1.hasArg)('debug') || (0, get_arg_js_1.hasArg)('d', '-') || defaultConfigs?.debug;
const failFast = (0, get_arg_js_1.hasArg)('failFast') || defaultConfigs?.failFast;
const watchMode = (0, get_arg_js_1.hasArg)('watch') || (0, get_arg_js_1.hasArg)('w', '-');
const hasEnvFile = (0, get_arg_js_1.hasArg)('envfile');
const hasEnvFile = (0, get_arg_js_1.hasArg)('envFile');
const concurrency = (() => {
if (!(parallel || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel)))
return;
const value = Number((0, get_arg_js_1.getArg)('concurrency'));
return Number.isNaN(value) ? defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.concurrency : value;
return Number.isNaN(value) ? defaultConfigs?.concurrency : value;
})();
const sequential = (0, get_arg_js_1.hasArg)('sequential');
if (dirs.length === 1)
files_js_1.states.isSinglePath = true;
if ((0, get_arg_js_1.hasArg)('listfiles')) {
if ((0, get_arg_js_1.hasArg)('listFiles')) {
const { listFiles } = require('../modules/helpers/list-files.js');

@@ -97,9 +89,9 @@ const files = [];

if (killPort || ((_j = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _j === void 0 ? void 0 : _j.port)) {
const ports = (killPort === null || killPort === void 0 ? void 0 : killPort.split(',').map(Number)) || ((_k = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _k === void 0 ? void 0 : _k.port) || [];
if (killPort || defaultConfigs?.kill?.port) {
const ports = killPort?.split(',').map(Number) || defaultConfigs?.kill?.port || [];
tasks.push(kill_js_1.kill.port(ports));
}
if (killRange || ((_l = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _l === void 0 ? void 0 : _l.range)) {
const ranges = (killRange === null || killRange === void 0 ? void 0 : killRange.split(',')) ||
((_o = (_m = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _m === void 0 ? void 0 : _m.range) === null || _o === void 0 ? void 0 : _o.map((range) => `${range[0]}-${range[1]}`)) ||
if (killRange || defaultConfigs?.kill?.range) {
const ranges = killRange?.split(',') ||
defaultConfigs?.kill?.range?.map((range) => `${range[0]}-${range[1]}`) ||
[];

@@ -113,28 +105,16 @@ for (const range of ranges) {

}
if (killPID || ((_p = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _p === void 0 ? void 0 : _p.pid)) {
const PIDs = (killPID === null || killPID === void 0 ? void 0 : killPID.split(',').map(Number)) || ((_q = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _q === void 0 ? void 0 : _q.pid) || [];
if (killPID || defaultConfigs?.kill?.pid) {
const PIDs = killPID?.split(',').map(Number) || defaultConfigs?.kill?.pid || [];
tasks.push(kill_js_1.kill.pid(PIDs));
}
if (hasEnvFile || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.envFile)) {
const envFilePath = (_r = (0, get_arg_js_1.getArg)('envfile')) !== null && _r !== void 0 ? _r : defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.envFile;
if (hasEnvFile || defaultConfigs?.envFile) {
const envFilePath = (0, get_arg_js_1.getArg)('envFile') ?? defaultConfigs?.envFile;
tasks.push((0, env_js_1.envFile)(envFilePath));
}
const options = {
platform: (0, get_runtime_js_1.platformIsValid)(platform)
? platform
: (0, get_arg_js_1.hasArg)('node')
? 'node'
: (0, get_arg_js_1.hasArg)('bun')
? 'bun'
: (0, get_arg_js_1.hasArg)('deno')
? 'deno'
: (0, get_runtime_js_1.platformIsValid)(defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.platform)
? defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.platform
: undefined,
filter: typeof filter === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(filter)) : filter,
exclude: typeof exclude === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(exclude)) : exclude,
parallel,
concurrency,
sequential,
quiet,

@@ -152,3 +132,3 @@ debug,

};
if (debug || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.debug)) {
if (debug || defaultConfigs?.debug) {
write_js_1.Write.hr();

@@ -155,0 +135,0 @@ write_js_1.Write.log(`${(0, format_js_1.format)(' Debug Enabled ').bg('brightBlue')}\n`);

@@ -20,3 +20,3 @@ "use strict";

const executing = new Set();
const interval = Number((0, get_arg_js_1.getArg)('watchinterval')) || 1500;
const interval = Number((0, get_arg_js_1.getArg)('watchInterval')) || 1500;
const setIsRunning = (value) => {

@@ -46,3 +46,2 @@ isRunning = value;

const currentWatcher = (0, watch_js_1.watch)(mappedTest, async (file, event) => {
var _a;
if (event === 'change') {

@@ -60,3 +59,4 @@ const filePath = (0, map_tests_js_1.normalizePath)(file);

...options,
concurrency: (_a = options.concurrency) !== null && _a !== void 0 ? _a : Math.max(Math.floor((0, os_js_1.availableParallelism)() / 2), 1),
concurrency: options.concurrency ??
Math.max(Math.floor((0, os_js_1.availableParallelism)() / 2), 1),
});

@@ -63,0 +63,0 @@ setTimeout(() => {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createAssert = void 0;
const get_runtime_js_1 = require("../parsers/get-runtime.js");
const assert_js_1 = require("../services/assert.js");

@@ -108,6 +107,3 @@ const createAssert = (nodeAssert) => {

const match = (value, regExp, message) => {
if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12)
throw new Error('match is available from Node.js 12 or higher');
(0, assert_js_1.processAssert)(() => nodeAssert === null || nodeAssert === void 0 ? void 0 : nodeAssert.match(value, regExp), {
(0, assert_js_1.processAssert)(() => nodeAssert?.match(value, regExp), {
message,

@@ -120,5 +116,2 @@ actual: 'Value',

const doesNotMatch = (value, regExp, message) => {
if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12)
throw new Error('doesNotMatch is available from Node.js 12 or higher');
(0, assert_js_1.processAssert)(() => nodeAssert.doesNotMatch(value, regExp), {

@@ -125,0 +118,0 @@ message,

@@ -9,1 +9,4 @@ export declare const results: {

export declare const deepOptions: string[];
export declare const GLOBAL: {
cwd: string;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deepOptions = exports.VERSION = exports.results = void 0;
exports.GLOBAL = exports.deepOptions = exports.VERSION = exports.results = void 0;
const node_process_1 = require("process");
exports.results = {

@@ -10,3 +11,6 @@ success: 0,

};
exports.VERSION = '2.7.1';
exports.VERSION = '3.0.0-rc.0';
exports.deepOptions = [];
exports.GLOBAL = {
cwd: (0, node_process_1.cwd)(),
};

@@ -9,3 +9,2 @@ "use strict";

const node_process_1 = __importDefault(require("process"));
const run_tests_js_1 = require("../../services/run-tests.js");
const write_js_1 = require("../../services/write.js");

@@ -16,2 +15,3 @@ const exit_js_1 = require("../helpers/exit.js");

const files_js_1 = require("../../configs/files.js");
const run_tests_js_1 = require("../../services/run-tests.js");

@@ -27,33 +27,8 @@ const onSigint = () => node_process_1.default.stdout.write('\u001B[?25h');

const showLogs = !(0, output_js_1.isQuiet)(configs);
if (!(configs === null || configs === void 0 ? void 0 : configs.parallel)) {
for (const dir of dirs) {
const result = await (0, run_tests_js_1.runTests)(dir, configs);
if (!result) {
code = 1;
if (configs === null || configs === void 0 ? void 0 : configs.failFast)
break;
}
}
if (configs === null || configs === void 0 ? void 0 : configs.noExit)
return code;
const end = node_process_1.default.hrtime(start);
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
files_js_1.finalResults.time = total;
showLogs && (0, format_js_1.showTestResults)();
(0, exit_js_1.exit)(code, configs === null || configs === void 0 ? void 0 : configs.quiet);
return;
}
if (showLogs) {
write_js_1.Write.hr();
write_js_1.Write.log(`${(0, format_js_1.format)('Running the Test Suite in Parallel').bold()}\n`);
write_js_1.Write.log(`${(0, format_js_1.format)('Running Tests').bold()}\n`);
}
try {
const promises = dirs.map(async (dir) => {
const result = await (0, run_tests_js_1.runTestsParallel)(dir, configs);
if (!result && (configs === null || configs === void 0 ? void 0 : configs.failFast))
throw new Error('quiet');
return result;
});
const promises = dirs.map(async (dir) => await (0, run_tests_js_1.runTests)(dir, configs));
const concurrency = await Promise.all(promises);

@@ -63,3 +38,3 @@ if (concurrency.some((result) => !result))

}
catch (_a) {
catch {
}

@@ -72,5 +47,5 @@ finally {

showLogs && (0, format_js_1.showTestResults)();
if (configs === null || configs === void 0 ? void 0 : configs.noExit)
if (configs?.noExit)
return code;
(0, exit_js_1.exit)(code, configs === null || configs === void 0 ? void 0 : configs.quiet);
(0, exit_js_1.exit)(code, configs?.quiet);
}

@@ -21,4 +21,4 @@ "use strict";

env: node_process_1.default.env,
timeout: options === null || options === void 0 ? void 0 : options.timeout,
cwd: (options === null || options === void 0 ? void 0 : options.cwd) ? (0, list_files_js_1.sanitizePath)((0, node_path_1.normalize)(options.cwd)) : undefined,
timeout: options?.timeout,
cwd: options?.cwd ? (0, list_files_js_1.sanitizePath)((0, node_path_1.normalize)(options.cwd)) : undefined,
shell: get_runner_js_1.isWindows,

@@ -40,3 +40,3 @@ detached: !get_runner_js_1.isWindows,

if (['bun', 'deno'].includes(runtime) ||
['bun', 'deno'].includes(String(options === null || options === void 0 ? void 0 : options.runner)))
['bun', 'deno'].includes(String(options?.runner)))
node_process_1.default.kill(PID);

@@ -57,3 +57,3 @@ else

}
catch (_a) {
catch {
resolve(undefined);

@@ -65,7 +65,7 @@ return;

service.stdout.on('data', (data) => {
if (!isResolved && typeof (options === null || options === void 0 ? void 0 : options.startAfter) !== 'number') {
if (!isResolved && typeof options?.startAfter !== 'number') {
const stringData = JSON.stringify(String(data));
if (typeof (options === null || options === void 0 ? void 0 : options.startAfter) === 'undefined' ||
(typeof (options === null || options === void 0 ? void 0 : options.startAfter) === 'string' &&
stringData.includes(options === null || options === void 0 ? void 0 : options.startAfter))) {
if (typeof options?.startAfter === 'undefined' ||
(typeof options?.startAfter === 'string' &&
stringData.includes(options?.startAfter))) {
resolve({ end });

@@ -76,10 +76,10 @@ clearTimeout(timeout);

}
(options === null || options === void 0 ? void 0 : options.verbose) && write_js_1.Write.log(data);
options?.verbose && write_js_1.Write.log(data);
});
service.stderr.on('data', (data) => {
if (!isResolved && typeof (options === null || options === void 0 ? void 0 : options.startAfter) !== 'number') {
if (!isResolved && typeof options?.startAfter !== 'number') {
const stringData = JSON.stringify(String(data));
if (typeof (options === null || options === void 0 ? void 0 : options.startAfter) === 'undefined' ||
(typeof (options === null || options === void 0 ? void 0 : options.startAfter) === 'string' &&
stringData.includes(options === null || options === void 0 ? void 0 : options.startAfter))) {
if (typeof options?.startAfter === 'undefined' ||
(typeof options?.startAfter === 'string' &&
stringData.includes(options?.startAfter))) {
resolve({ end });

@@ -90,3 +90,3 @@ clearTimeout(timeout);

}
(options === null || options === void 0 ? void 0 : options.verbose) && write_js_1.Write.log(data);
options?.verbose && write_js_1.Write.log(data);
});

@@ -106,4 +106,4 @@ service.on('error', (err) => {

}
}, (options === null || options === void 0 ? void 0 : options.timeout) || 60000);
if (typeof (options === null || options === void 0 ? void 0 : options.startAfter) === 'number')
}, options?.timeout || 60000);
if (typeof options?.startAfter === 'number')
setTimeout(() => {

@@ -117,7 +117,7 @@ if (!isResolved) {

}
catch (_a) { }
catch { }
});
/** Starts a file in a background process (useful for servers, APIs, etc.) */
const startService = async (file, options) => {
const runtimeOptions = (0, get_runner_js_1.runner)(file, { platform: options === null || options === void 0 ? void 0 : options.platform });
const runtimeOptions = (0, get_runner_js_1.runner)(file);
const runtime = runtimeOptions.shift();

@@ -137,4 +137,3 @@ const runtimeArgs = [...runtimeOptions, file];

const startScript = async (script, options) => {
var _a;
const runner = (_a = options === null || options === void 0 ? void 0 : options.runner) !== null && _a !== void 0 ? _a : 'npm';
const runner = options?.runner ?? 'npm';
const runtimeOptions = (0, get_runner_js_1.scriptRunner)(runner);

@@ -141,0 +140,0 @@ const runtime = runtimeOptions.shift();

@@ -15,4 +15,4 @@ "use strict";

let options;
const isPoku = typeof (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE) === 'string' && (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE.length) > 0;
const FILE = node_process_1.env.FILE;
const isPoku = typeof node_process_1.env?.FILE === 'string' && node_process_1.env?.FILE.length > 0;
const FILE = node_process_1.env.POKU_FILE;
if (typeof arg1 === 'string') {

@@ -31,4 +31,4 @@ title = arg1;

indentation_js_1.indentation.hasDescribe = true;
const { background, icon } = options !== null && options !== void 0 ? options : {};
const message = `${cb ? (0, format_js_1.format)('β—Œ').dim() : (icon !== null && icon !== void 0 ? icon : '☰')} ${cb ? (0, format_js_1.format)(isPoku ? `${title} β€Ί ${(0, format_js_1.format)(`${FILE}`).italic().gray()}` : title).dim() : (0, format_js_1.format)(title).bold()}`;
const { background, icon } = options ?? {};
const message = `${cb ? (0, format_js_1.format)('β—Œ').dim() : (icon ?? '☰')} ${cb ? (0, format_js_1.format)(isPoku ? `${title} β€Ί ${(0, format_js_1.format)(`${FILE}`).italic().gray()}` : title).dim() : (0, format_js_1.format)(title).bold()}`;
const noBackground = !background;

@@ -35,0 +35,0 @@ if (noBackground)

@@ -23,3 +23,3 @@ "use strict";

const beforeEach = (callback, options) => {
(options === null || options === void 0 ? void 0 : options.immediate) && callback();
options?.immediate && callback();
each_js_1.each.before.cb = () => {

@@ -26,0 +26,0 @@ if (each_js_1.each.before.status)

@@ -5,3 +5,3 @@ "use strict";

const node_process_1 = require("process");
const fs_js_1 = require("../../polyfills/fs.js");
const promises_1 = require("fs/promises");
const list_files_js_1 = require("./list-files.js");

@@ -15,3 +15,3 @@ const env_js_1 = require("../../services/env.js");

const mapEnv = new Map();
const env = await (0, fs_js_1.readFile)((0, list_files_js_1.sanitizePath)(filePath), 'utf8');
const env = await (0, promises_1.readFile)((0, list_files_js_1.sanitizePath)(filePath), 'utf8');
const lines = env

@@ -18,0 +18,0 @@ .split('\n')

@@ -16,4 +16,4 @@ "use strict";

let cb;
const isPoku = typeof (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE) === 'string' && (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE.length) > 0;
const FILE = node_process_1.env.FILE;
const isPoku = typeof node_process_1.env?.POKU_FILE === 'string' && node_process_1.env?.POKU_FILE.length > 0;
const FILE = node_process_1.env.POKU_FILE;
if (typeof args[0] === 'string') {

@@ -20,0 +20,0 @@ message = args[0];

"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -7,3 +6,3 @@ exports.listFiles = exports.getAllFiles = exports.escapeRegExp = exports.isFile = exports.sanitizePath = void 0;

const node_path_1 = require("path");
const fs_js_1 = require("../../polyfills/fs.js");
const promises_1 = require("fs/promises");
const files_js_1 = require("../../configs/files.js");

@@ -28,7 +27,7 @@ const regex = {

exports.sanitizePath = sanitizePath;
const isFile = async (fullPath) => (await (0, fs_js_1.stat)(fullPath)).isFile();
const isFile = async (fullPath) => (await (0, promises_1.stat)(fullPath)).isFile();
exports.isFile = isFile;
const escapeRegExp = (string) => string.replace(regex.safeRegExp, '\\$&');
exports.escapeRegExp = escapeRegExp;
const envFilter = ((_a = node_process_1.env.FILTER) === null || _a === void 0 ? void 0 : _a.trim())
const envFilter = node_process_1.env.FILTER?.trim()
? new RegExp((0, exports.escapeRegExp)(node_process_1.env.FILTER), 'i')

@@ -39,25 +38,35 @@ : undefined;

const currentFiles = await (async () => {
if (await (0, exports.isFile)(dirPath)) {
isFullPath = true;
return [(0, exports.sanitizePath)(dirPath)];
try {
if (await (0, exports.isFile)(dirPath)) {
isFullPath = true;
return [(0, exports.sanitizePath)(dirPath)];
}
return await (0, promises_1.readdir)((0, exports.sanitizePath)(dirPath));
}
return await (0, fs_js_1.readdir)((0, exports.sanitizePath)(dirPath));
catch (error) {
console.error(error);
process.exit(1);
}
})();
const filter = envFilter
? envFilter
: (configs === null || configs === void 0 ? void 0 : configs.filter) instanceof RegExp
? configs.filter
: regex.defaultFilter;
const exclude = (configs === null || configs === void 0 ? void 0 : configs.exclude)
? Array.isArray(configs.exclude)
? configs.exclude
: [configs.exclude]
: undefined;
const filter = (() => {
if (envFilter)
return envFilter;
if (configs?.filter instanceof RegExp)
return configs.filter;
return regex.defaultFilter;
})();
const exclude = (() => {
if (!configs?.exclude)
return undefined;
if (Array.isArray(configs.exclude))
return configs.exclude;
return [configs.exclude];
})();
await Promise.all(currentFiles.map(async (file) => {
const fullPath = isFullPath ? dirPath : (0, node_path_1.join)(dirPath, file);
const stat = await (0, fs_js_1.stat)(fullPath);
const stat = await (0, promises_1.stat)(fullPath);
if (fullPath.indexOf('node_modules') !== -1 ||
fullPath.indexOf('.git/') !== -1)
return;
if (isFullPath && (files_js_1.states === null || files_js_1.states === void 0 ? void 0 : files_js_1.states.isSinglePath))
if (isFullPath && files_js_1.states?.isSinglePath)
return files.add(fullPath);

@@ -64,0 +73,0 @@ if (exclude)

@@ -8,4 +8,4 @@ "use strict";

const skip = (message = 'Skipping') => {
const isPoku = typeof (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE) === 'string' && (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE.length) > 0;
const FILE = node_process_1.env.FILE;
const isPoku = typeof node_process_1.env?.POKU_FILE === 'string' && node_process_1.env?.POKU_FILE.length > 0;
const FILE = node_process_1.env.POKU_FILE;
if (message)

@@ -12,0 +12,0 @@ write_js_1.Write.log((0, format_js_1.format)(isPoku

@@ -23,5 +23,5 @@ "use strict";

const waitForExpectedResult = async (callback, expectedResult, options) => {
const delay = (options === null || options === void 0 ? void 0 : options.delay) || 0;
const interval = (options === null || options === void 0 ? void 0 : options.interval) || 100;
const timeout = (options === null || options === void 0 ? void 0 : options.timeout) || 60000;
const delay = options?.delay || 0;
const interval = options?.interval || 100;
const timeout = options?.timeout || 60000;
if (typeof callback !== 'function')

@@ -50,3 +50,3 @@ throw new Error('Callback must be a function.');

try {
(options === null || options === void 0 ? void 0 : options.strict)
options?.strict
? (0, node_assert_1.deepStrictEqual)(result, expectedResult)

@@ -56,3 +56,3 @@ : (0, node_assert_1.deepEqual)(result, expectedResult);

}
catch (_a) { }
catch { }
}

@@ -68,3 +68,3 @@ if (Date.now() - startTime >= timeout)

const waitForPort = async (port, options) => {
const host = (options === null || options === void 0 ? void 0 : options.host) || 'localhost';
const host = options?.host || 'localhost';
if (!Number.isInteger(port))

@@ -71,0 +71,0 @@ throw new Error('Port must be an integer.');

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseResultType = void 0;
const object_js_1 = require("../polyfills/object.js");
const recurse = (value) => {

@@ -17,5 +16,5 @@ if (typeof value === 'undefined' ||

if (value instanceof Map)
return recurse((0, object_js_1.fromEntries)(value));
return recurse(Object.fromEntries(value));
if (value !== null && typeof value === 'object')
return (0, object_js_1.fromEntries)((0, object_js_1.entries)(value).map(([key, val]) => [key, recurse(val)]));
return Object.fromEntries(Object.entries(value).map(([key, val]) => [key, recurse(val)]));
return value;

@@ -22,0 +21,0 @@ };

@@ -6,4 +6,3 @@ "use strict";

const findFile = (error) => {
var _a, _b;
const stackLines = (_b = (_a = error.stack) === null || _a === void 0 ? void 0 : _a.split('\n')) !== null && _b !== void 0 ? _b : [];
const stackLines = error.stack?.split('\n') ?? [];
let file = '';

@@ -15,7 +14,7 @@ const basePath = 'poku/lib/';

const match = line.match(regex);
if (match === null || match === void 0 ? void 0 : match[1]) {
if (match?.[1]) {
file = match[1];
break;
}
if (match === null || match === void 0 ? void 0 : match[3]) {
if (match?.[3]) {
file = match[3];

@@ -22,0 +21,0 @@ break;

@@ -5,7 +5,5 @@ "use strict";

const node_process_1 = require("process");
const to_dynamic_case_js_1 = require("./to-dynamic-case.js");
const [, , ...processArgs] = node_process_1.argv;
const regexQuotes = /''|""/;
const processedArgs = processArgs.map(to_dynamic_case_js_1.toDynamicCase);
const getArg = (arg, prefix = '--', baseArgs = processedArgs) => {
const getArg = (arg, prefix = '--', baseArgs = processArgs) => {
const argPattern = `${prefix}${arg}=`;

@@ -18,5 +16,5 @@ const argValue = baseArgs.find((a) => a.startsWith(argPattern));

exports.getArg = getArg;
const hasArg = (arg, prefix = '--', baseArgs = processedArgs) => baseArgs.some((a) => a.startsWith(`${prefix}${arg}`));
const hasArg = (arg, prefix = '--', baseArgs = processArgs) => baseArgs.some((a) => a.startsWith(`${prefix}${arg}`));
exports.hasArg = hasArg;
const getPaths = (prefix = '--', baseArgs = processedArgs) => {
const getPaths = (prefix = '--', baseArgs = processArgs) => {
let hasPaths = false;

@@ -27,6 +25,5 @@ const paths = [];

continue;
hasPaths = true;
const parts = arg.split(',');
for (const part of parts)
paths.push(part);
if (!hasPaths)
hasPaths = true;
paths.push(arg);
}

@@ -36,3 +33,3 @@ return hasPaths ? paths : undefined;

exports.getPaths = getPaths;
const argToArray = (arg, prefix = '--', baseArgs = processedArgs) => {
const argToArray = (arg, prefix = '--', baseArgs = processArgs) => {
const hasArgument = (0, exports.hasArg)(arg, prefix, baseArgs);

@@ -39,0 +36,0 @@ if (!hasArgument)

@@ -9,19 +9,12 @@ "use strict";

const runner = (filename, configs) => {
var _a, _b;
const runtime = (0, get_runtime_js_1.getRuntime)(configs);
const runtime = (0, get_runtime_js_1.getRuntime)();
if (runtime === 'bun')
return ['bun'];
if (runtime === 'deno') {
const denoAllow = ((_a = configs === null || configs === void 0 ? void 0 : configs.deno) === null || _a === void 0 ? void 0 : _a.allow)
const denoAllow = configs?.deno?.allow
? configs.deno.allow
.map((allow) => (allow ? `--allow-${allow}` : ''))
.filter((allow) => allow)
: [
'--allow-read',
'--allow-env',
'--allow-run',
'--allow-net',
'--allow-hrtime',
];
const denoDeny = ((_b = configs === null || configs === void 0 ? void 0 : configs.deno) === null || _b === void 0 ? void 0 : _b.deny)
: ['--allow-read', '--allow-env', '--allow-run', '--allow-net'];
const denoDeny = configs?.deno?.deny
? configs.deno.deny

@@ -40,3 +33,2 @@ .map((deny) => (deny ? `--deny-${deny}` : ''))

const scriptRunner = (runner) => {
var _a;
const commands = {

@@ -49,4 +41,4 @@ npm: [exports.isWindows ? 'npm.cmd' : 'npm', 'run'],

};
return (_a = commands === null || commands === void 0 ? void 0 : commands[runner]) !== null && _a !== void 0 ? _a : commands['npm'];
return commands?.[runner] ?? commands['npm'];
};
exports.scriptRunner = scriptRunner;

@@ -1,5 +0,3 @@

import type { Configs, Runtime } from '../@types/poku.js';
export declare const supportedPlatforms: readonly Runtime[];
export declare const platformIsValid: (platform: unknown) => platform is (typeof supportedPlatforms)[number];
export declare const getRuntime: (configs?: Configs) => (typeof supportedPlatforms)[number];
import type { Runtime } from '../@types/poku.js';
export declare const getRuntime: () => Runtime;
export declare const nodeVersion: number | undefined;
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.nodeVersion = exports.getRuntime = exports.platformIsValid = exports.supportedPlatforms = void 0;
exports.nodeVersion = exports.getRuntime = void 0;
const node_process_1 = require("process");
const regex = /v(\d+)\./;
exports.supportedPlatforms = ['node', 'bun', 'deno'];
const platformIsValid = (platform) => typeof platform === 'string' &&
exports.supportedPlatforms.indexOf(platform) > -1;
exports.platformIsValid = platformIsValid;
const getRuntime = (configs) => {
if ((configs === null || configs === void 0 ? void 0 : configs.platform) && (0, exports.platformIsValid)(configs.platform))
return configs.platform;
const getRuntime = () => {
if (node_process_1.env.POKU_RUNTIME)
return node_process_1.env.POKU_RUNTIME;
if (typeof Deno !== 'undefined')

@@ -21,2 +16,2 @@ return 'deno';

exports.getRuntime = getRuntime;
exports.nodeVersion = (0, exports.getRuntime)() === 'node' ? Number((_a = node_process_1.version.match(regex)) === null || _a === void 0 ? void 0 : _a[1]) : undefined;
exports.nodeVersion = (0, exports.getRuntime)() === 'node' ? Number(node_process_1.version.match(regex)?.[1]) : undefined;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfigs = void 0;
const node_process_1 = require("process");
const node_path_1 = require("path");
const fs_js_1 = require("../polyfills/fs.js");
const promises_1 = require("fs/promises");
const jsonc_js_1 = require("../polyfills/jsonc.js");
const processCWD = (0, node_process_1.cwd)();
const poku_js_1 = require("../configs/poku.js");
const getConfigs = async (customPath) => {

@@ -19,10 +18,10 @@ const expectedFiles = customPath

for (const file of expectedFiles) {
const filePath = (0, node_path_1.join)(processCWD, file);
const filePath = (0, node_path_1.join)(poku_js_1.GLOBAL.cwd, file);
try {
if (filePath.endsWith('.js') || filePath.endsWith('.cjs'))
return require(`file://${(0, node_path_1.normalize)(filePath)}`);
const configsFile = await (0, fs_js_1.readFile)(filePath, 'utf8');
const configsFile = await (0, promises_1.readFile)(filePath, 'utf8');
return jsonc_js_1.JSONC.parse(configsFile);
}
catch (_a) { }
catch { }
}

@@ -29,0 +28,0 @@ return {};

@@ -10,5 +10,5 @@ "use strict";

};
const isQuiet = (configs) => typeof (configs === null || configs === void 0 ? void 0 : configs.quiet) === 'boolean' && Boolean(configs === null || configs === void 0 ? void 0 : configs.quiet);
const isQuiet = (configs) => typeof configs?.quiet === 'boolean' && Boolean(configs?.quiet);
exports.isQuiet = isQuiet;
const isDebug = (configs) => Boolean(configs === null || configs === void 0 ? void 0 : configs.debug);
const isDebug = (configs) => Boolean(configs?.debug);
exports.isDebug = isDebug;

@@ -25,3 +25,3 @@ const parserOutput = (options) => {

const debug = (0, exports.isDebug)(configs);
const pad = (configs === null || configs === void 0 ? void 0 : configs.parallel) ? ' ' : ' ';
const pad = ' ';
const splittedOutput = output.split('\n');

@@ -34,3 +34,3 @@ const outputs = (debug || !result

return regex.ansi.test(JSON.stringify(current)) || current === '';
})).filter((line) => (line === null || line === void 0 ? void 0 : line.trim().length) > 0);
})).filter((line) => line?.trim().length > 0);
if (outputs.length === 0)

@@ -37,0 +37,0 @@ return;

@@ -5,8 +5,5 @@ "use strict";

const node_os_1 = require("os");
const availableParallelism = () => {
var _a, _b;
return typeof node_os_1.availableParallelism === 'function'
? (0, node_os_1.availableParallelism)()
: ((_b = (_a = (0, node_os_1.cpus)()) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0);
};
const availableParallelism = () => typeof node_os_1.availableParallelism === 'function'
? (0, node_os_1.availableParallelism)()
: ((0, node_os_1.cpus)()?.length ?? 0);
exports.availableParallelism = availableParallelism;

@@ -16,8 +16,9 @@ "use strict";

const write_js_1 = require("./write.js");
const cwd = node_process_1.default.cwd();
const poku_js_1 = require("../configs/poku.js");
const { cwd } = poku_js_1.GLOBAL;
const regexFile = /file:(\/\/)?/;
const assertProcessor = () => {
var _a, _b;
const isPoku = typeof ((_a = node_process_1.default.env) === null || _a === void 0 ? void 0 : _a.FILE) === 'string' && ((_b = node_process_1.default.env) === null || _b === void 0 ? void 0 : _b.FILE.length) > 0;
const FILE = node_process_1.default.env.FILE;
const isPoku = typeof node_process_1.default.env?.POKU_FILE === 'string' &&
node_process_1.default.env?.POKU_FILE.length > 0;
const FILE = node_process_1.default.env.POKU_FILE;
let preIdentation = '';

@@ -38,3 +39,2 @@ const handleSuccess = (options) => {

const handleError = (error, options) => {
var _a, _b;
node_process_1.default.exitCode = 1;

@@ -56,3 +56,3 @@ if (error instanceof node_assert_1.AssertionError) {

message = options.defaultMessage;
const finalMessage = (message === null || message === void 0 ? void 0 : message.trim().length) > 0
const finalMessage = message?.trim().length > 0
? (0, format_js_1.format)(`✘ ${message}`).fail().bold()

@@ -67,9 +67,9 @@ : (0, format_js_1.format)('✘ Assertion Error').fail().bold();

write_js_1.Write.log(`${(0, format_js_1.format)(`${preIdentation} Operator`).dim()} ${operator}\n`);
if (!(options === null || options === void 0 ? void 0 : options.hideDiff)) {
if (!options?.hideDiff) {
const splitActual = (0, assert_js_1.parseResultType)(actual).split('\n');
const splitExpected = (0, assert_js_1.parseResultType)(expected).split('\n');
write_js_1.Write.log((0, format_js_1.format)(`${preIdentation} ${(_a = options === null || options === void 0 ? void 0 : options.actual) !== null && _a !== void 0 ? _a : 'Actual'}:`).dim());
write_js_1.Write.log((0, format_js_1.format)(`${preIdentation} ${options?.actual ?? 'Actual'}:`).dim());
for (const line of splitActual)
write_js_1.Write.log(`${preIdentation} ${(0, format_js_1.format)(line).fail().bold()}`);
write_js_1.Write.log(`\n${preIdentation} ${(0, format_js_1.format)(`${(_b = options === null || options === void 0 ? void 0 : options.expected) !== null && _b !== void 0 ? _b : 'Expected'}:`).dim()}`);
write_js_1.Write.log(`\n${preIdentation} ${(0, format_js_1.format)(`${options?.expected ?? 'Expected'}:`).dim()}`);
for (const line of splitExpected)

@@ -76,0 +76,0 @@ write_js_1.Write.log(`${preIdentation} ${(0, format_js_1.format)(line).success().bold()}`);

@@ -31,5 +31,5 @@ "use strict";

this.context = context || '.';
this.ports = ports !== null && ports !== void 0 ? ports : [];
this.ports = ports ?? [];
this.cache = cache;
this.environments = environments !== null && environments !== void 0 ? environments : [];
this.environments = environments ?? [];
this.envFile = envFile;

@@ -70,3 +70,3 @@ this.detach = detach;

const { file, projectName, build, serviceName, envFile, detach, cwd, verbose, } = configs;
this.file = file !== null && file !== void 0 ? file : './docker-compose.yml';
this.file = file ?? './docker-compose.yml';
this.build = build;

@@ -73,0 +73,0 @@ this.serviceName = serviceName;

@@ -8,3 +8,3 @@ "use strict";

const eachCore = async (type, fileRelative, configs) => {
if (typeof (configs === null || configs === void 0 ? void 0 : configs[type]) !== 'function')
if (typeof configs?.[type] !== 'function')
return true;

@@ -38,3 +38,3 @@ const cb = configs[type];

const beforeEach = async (fileRelative, configs) => {
if (configs === null || configs === void 0 ? void 0 : configs.beforeEach)
if (configs?.beforeEach)
return await eachCore('beforeEach', fileRelative, configs);

@@ -45,3 +45,3 @@ return true;

const afterEach = async (fileRelative, configs) => {
if (configs === null || configs === void 0 ? void 0 : configs.afterEach)
if (configs?.afterEach)
return await eachCore('afterEach', fileRelative, configs);

@@ -48,0 +48,0 @@ return true;

@@ -41,3 +41,2 @@ "use strict";

const resolveEnvVariables = (str, env) => {
var _a;
let result = '';

@@ -54,3 +53,3 @@ let i = 0;

i++;
result += (_a = env[varName]) !== null && _a !== void 0 ? _a : '';
result += env[varName] ?? '';
}

@@ -57,0 +56,0 @@ else {

@@ -5,3 +5,3 @@ "use strict";

const node_path_1 = require("path");
const fs_js_1 = require("../polyfills/fs.js");
const promises_1 = require("fs/promises");
const list_files_js_1 = require("../modules/helpers/list-files.js");

@@ -51,3 +51,3 @@ const importMap = new Map();

const collectTestFiles = async (testPaths, testFilter, exclude) => {
const statsPromises = testPaths.map((testPath) => (0, fs_js_1.stat)(testPath));
const statsPromises = testPaths.map((testPath) => (0, promises_1.stat)(testPath));
const stats = await Promise.all(statsPromises);

@@ -72,3 +72,3 @@ const listFilesPromises = stats.map((stat, index) => {

processedFiles.add(srcFile);
const srcContent = await (0, fs_js_1.readFile)(srcFile, 'utf8');
const srcContent = await (0, promises_1.readFile)(srcFile, 'utf8');
const deepImports = (0, exports.getDeepImports)(srcContent);

@@ -87,4 +87,3 @@ const matchingFiles = (0, exports.findMatchingFiles)(deepImports, intersectedSrcFiles);

await Promise.all(Array.from(allTestFiles).map(async (testFile) => {
var _a;
const content = await (0, fs_js_1.readFile)(testFile, 'utf8');
const content = await (0, promises_1.readFile)(testFile, 'utf8');
for (const srcFile of intersectedSrcFiles) {

@@ -97,3 +96,3 @@ const relativePath = (0, exports.normalizePath)((0, node_path_1.relative)((0, node_path_1.dirname)(testFile), srcFile));

importMap.set(normalizedSrcFile, new Set());
(_a = importMap.get(normalizedSrcFile)) === null || _a === void 0 ? void 0 : _a.add((0, exports.normalizePath)(testFile));
importMap.get(normalizedSrcFile)?.add((0, exports.normalizePath)(testFile));
await (0, exports.processDeepImports)(srcFile, testFile, intersectedSrcFiles);

@@ -100,0 +99,0 @@ }

@@ -7,6 +7,4 @@ "use strict";

const node_child_process_1 = require("child_process");
const indentation_js_1 = require("../configs/indentation.js");
const files_js_1 = require("../configs/files.js");
const get_runner_js_1 = require("../parsers/get-runner.js");
const format_js_1 = require("./format.js");
const output_js_1 = require("../parsers/output.js");

@@ -16,5 +14,4 @@ const each_js_1 = require("./each.js");

const poku_js_1 = require("../configs/poku.js");
const cwd = (0, node_process_1.cwd)();
const { cwd } = poku_js_1.GLOBAL;
const runTestFile = async (filePath, configs) => {
var _a, _b;
const runtimeOptions = (0, get_runner_js_1.runner)(filePath, configs);

@@ -25,4 +22,4 @@ const runtime = runtimeOptions.shift();

((_a = configs === null || configs === void 0 ? void 0 : configs.deno) === null || _a === void 0 ? void 0 : _a.cjs) === true ||
(Array.isArray((_b = configs === null || configs === void 0 ? void 0 : configs.deno) === null || _b === void 0 ? void 0 : _b.cjs) &&
configs?.deno?.cjs === true ||
(Array.isArray(configs?.deno?.cjs) &&
configs.deno.cjs.some((ext) => filePath.includes(ext)))

@@ -38,6 +35,2 @@ ? `https://cdn.jsdelivr.net/npm/poku${poku_js_1.VERSION ? `@${poku_js_1.VERSION}` : ''}/lib/polyfills/deno.mjs`

};
if (!(configs === null || configs === void 0 ? void 0 : configs.parallel)) {
showLogs &&
write_js_1.Write.log(`${indentation_js_1.indentation.test}${(0, format_js_1.format)('●').info().dim()} ${(0, format_js_1.format)(fileRelative).dim()}`);
}
const start = (0, node_process_1.hrtime)();

@@ -48,3 +41,2 @@ let end;

return new Promise((resolve) => {
var _a;
const child = (0, node_child_process_1.spawn)(runtime, [...runtimeArguments, ...poku_js_1.deepOptions], {

@@ -55,3 +47,4 @@ stdio: ['inherit', 'pipe', 'pipe'],

...node_process_1.env,
FILE: (configs === null || configs === void 0 ? void 0 : configs.parallel) || ((_a = configs === null || configs === void 0 ? void 0 : configs.deno) === null || _a === void 0 ? void 0 : _a.cjs) ? fileRelative : '',
POKU_FILE: fileRelative,
POKU_RUNTIME: node_process_1.env.POKU_RUNTIME,
},

@@ -58,0 +51,0 @@ });

import type { Configs } from '../@types/poku.js';
export declare const runTests: (dir: string, configs?: Configs) => Promise<boolean>;
export declare const runTestsParallel: (dir: string, configs?: Configs) => Promise<boolean>;

@@ -6,7 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.runTestsParallel = exports.runTests = void 0;
exports.runTests = void 0;
const node_process_1 = __importDefault(require("process"));
const node_path_1 = require("path");
const get_runner_js_1 = require("../parsers/get-runner.js");
const indentation_js_1 = require("../configs/indentation.js");
const list_files_js_1 = require("../modules/helpers/list-files.js");

@@ -20,3 +18,4 @@ const write_js_1 = require("../services/write.js");

const get_arg_js_1 = require("../parsers/get-arg.js");
const cwd = node_process_1.default.cwd();
const { cwd } = poku_js_1.GLOBAL;
const failFastError = ` ${(0, format_js_1.format)('β„Ή').fail()} ${(0, format_js_1.format)('failFast').bold()} is enabled`;
if (get_arg_js_1.hasDescribeOnly)

@@ -29,91 +28,55 @@ poku_js_1.deepOptions.push('--only=describe');

const runTests = async (dir, configs) => {
let allPassed = true;
let activeTests = 0;
let resolveDone;
let rejectDone;
const testDir = (0, node_path_1.join)(cwd, dir);
const currentDir = (0, node_path_1.relative)(cwd, testDir);
const isFile = await (0, list_files_js_1.isFile)(testDir);
const files = await (0, list_files_js_1.listFiles)(testDir, configs);
const totalTests = files.length;
const showLogs = !(0, output_js_1.isQuiet)(configs);
let passed = true;
if (showLogs && files.length > 0) {
write_js_1.Write.hr();
write_js_1.Write.log(`${(0, format_js_1.format)(isFile ? 'File:' : 'Directory:').bold()} ${(0, format_js_1.format)(`.${node_path_1.sep}${currentDir}`).underline()}\n`);
}
for (let i = 0; i < files.length; i++) {
const filePath = files[i];
const fileRelative = (0, node_path_1.relative)(cwd, filePath);
const start = node_process_1.default.hrtime();
const testPassed = await (0, run_test_file_js_1.runTestFile)(filePath, configs);
const end = node_process_1.default.hrtime(start);
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
const testNumber = i + 1;
const counter = (0, format_js_1.format)('').counter(testNumber, totalTests);
const command = `${(0, get_runner_js_1.runner)(fileRelative, configs).join(' ')} ${fileRelative}`;
const nextLine = i + 1 !== files.length ? '\n' : '';
const log = `${counter}/${totalTests} ${command}`;
if (testPassed) {
++poku_js_1.results.success;
showLogs &&
write_js_1.Write.log(`${indentation_js_1.indentation.test}${(0, format_js_1.format)('βœ”').success()} ${log}${(0, format_js_1.format)(` β€Ί ${total}ms`).success().dim()}${nextLine}`);
const concurrency = (() => {
if (configs?.sequential)
return 1;
const limit = configs?.concurrency ?? Math.max((0, os_js_1.availableParallelism)() - 1, 1);
return limit <= 0 ? files.length || 1 : limit;
})();
const done = new Promise((resolve, reject) => {
resolveDone = resolve;
rejectDone = reject;
});
const runNext = async () => {
if (files.length === 0 && activeTests === 0) {
resolveDone(allPassed);
return;
}
else {
++poku_js_1.results.fail;
if (showLogs) {
write_js_1.Write.log(`${indentation_js_1.indentation.test}${(0, format_js_1.format)('✘').fail()} ${log}${(0, format_js_1.format)(` β€Ί ${total}ms`).fail().dim()}${nextLine}`);
}
passed = false;
if (configs === null || configs === void 0 ? void 0 : configs.failFast) {
node_process_1.default.exitCode = 1;
if (showLogs) {
write_js_1.Write.hr();
write_js_1.Write.log(` ${(0, format_js_1.format)('β„Ή').fail()} ${(0, format_js_1.format)('failFast').bold()} is enabled`);
const filePath = files.shift();
if (typeof filePath === 'undefined')
return;
activeTests++;
try {
const testPassed = await (0, run_test_file_js_1.runTestFile)(filePath, configs);
if (testPassed)
++poku_js_1.results.success;
else {
++poku_js_1.results.fail;
allPassed = false;
if (configs?.failFast) {
if (showLogs) {
write_js_1.Write.hr();
console.error(failFastError);
write_js_1.Write.log(`\n ${(0, format_js_1.format)('File:').bold()} ${(0, format_js_1.format)(`./${(0, node_path_1.relative)(cwd, filePath)}`).fail()}`);
write_js_1.Write.hr();
}
node_process_1.default.exit(1);
}
break;
}
}
}
return passed;
finally {
activeTests--;
}
runNext().catch(rejectDone);
};
for (let i = 0; i < concurrency; i++)
runNext();
return await done;
};
exports.runTests = runTests;
const runTestsParallel = async (dir, configs) => {
var _a;
const testDir = (0, node_path_1.join)(cwd, dir);
const files = await (0, list_files_js_1.listFiles)(testDir, configs);
const filesByConcurrency = [];
const concurrencyLimit = (_a = configs === null || configs === void 0 ? void 0 : configs.concurrency) !== null && _a !== void 0 ? _a : Math.max((0, os_js_1.availableParallelism)() - 1, 1);
const concurrencyResults = [];
const showLogs = !(0, output_js_1.isQuiet)(configs);
if (concurrencyLimit > 0) {
for (let i = 0; i < files.length; i += concurrencyLimit)
filesByConcurrency.push(files.slice(i, i + concurrencyLimit));
}
else
filesByConcurrency.push(files);
try {
for (const fileGroup of filesByConcurrency) {
const promises = fileGroup.map(async (filePath) => {
const testPassed = await (0, run_test_file_js_1.runTestFile)(filePath, configs);
if (!testPassed) {
++poku_js_1.results.fail;
if (configs === null || configs === void 0 ? void 0 : configs.failFast) {
node_process_1.default.exitCode = 1;
throw new Error(` ${(0, format_js_1.format)('β„Ή').fail()} ${(0, format_js_1.format)('failFast').bold()} is enabled`);
}
return false;
}
++poku_js_1.results.success;
return true;
});
const concurrency = await Promise.all(promises);
concurrencyResults.push(concurrency);
}
return concurrencyResults.every((group) => group.every((result) => result));
}
catch (error) {
if (showLogs) {
write_js_1.Write.hr();
error instanceof Error && console.error(error.message);
}
return false;
}
};
exports.runTestsParallel = runTestsParallel;

@@ -6,3 +6,3 @@ "use strict";

const node_path_1 = require("path");
const fs_js_1 = require("../polyfills/fs.js");
const promises_1 = require("fs/promises");
const list_files_js_1 = require("../modules/helpers/list-files.js");

@@ -43,11 +43,11 @@ class Watcher {

try {
const stats = await (0, fs_js_1.stat)(fullPath);
const stats = await (0, promises_1.stat)(fullPath);
if (stats.isDirectory())
await this.watchDirectory(fullPath);
}
catch (_a) { }
catch { }
}
});
this.dirWatchers.set(dir, watcher);
const entries = await (0, fs_js_1.readdir)(dir, { withFileTypes: true });
const entries = await (0, promises_1.readdir)(dir, { withFileTypes: true });
for (const entry of entries) {

@@ -61,3 +61,3 @@ if (!entry.isDirectory())

async start() {
const stats = await (0, fs_js_1.stat)(this.rootDir);
const stats = await (0, promises_1.stat)(this.rootDir);
if (stats.isDirectory()) {

@@ -64,0 +64,0 @@ this.files = await (0, list_files_js_1.listFiles)(this.rootDir);

{
"name": "poku",
"version": "2.7.1",
"version": "3.0.0-rc.0",
"description": "🐷 Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.",
"main": "./lib/modules/index.js",
"license": "MIT",
"type": "commonjs",
"bin": {

@@ -27,21 +28,15 @@ "poku": "./lib/bin/index.js"

"engines": {
"node": ">=8.17.0",
"bun": ">=1.0.0",
"deno": ">=1.30.0",
"typescript": ">=4.7.2"
"node": ">=14.x.x",
"bun": ">=1.x.x",
"deno": ">=1.x.x",
"typescript": ">=5.x.x"
},
"scripts": {
"test": "npm run test:parallel && npm run test:sequential",
"test:bun": "npm run test:bun:parallel && npm run test:bun:sequential",
"test:deno": "npm run test:deno:parallel && npm run test:deno:sequential",
"test:sequential": "tsx src/bin/index.ts test/unit test/integration test/e2e",
"test:parallel": "tsx src/bin/index.ts -p test/unit test/integration test/e2e",
"test:bun:sequential": "bun src/bin/index.ts --bun test/unit test/integration test/e2e",
"test:bun:parallel": "bun src/bin/index.ts --bun -p test/unit test/integration test/e2e",
"test:deno:sequential": "tsx src/bin/index.ts --deno --denoAllow=all test/unit test/integration test/e2e",
"test:deno:parallel": "tsx src/bin/index.ts --deno --denoAllow=all -p test/unit test/integration test/e2e",
"test": "tsx src/bin/index.ts test/unit test/integration test/e2e",
"test:bun": "bun src/bin/index.ts test/unit test/integration test/e2e",
"test:deno": "deno run -A src/bin/index.ts --denoAllow=all test/unit test/integration test/e2e",
"pretest:c8": "tsx tools/build/c8-file.ts",
"test:c8": "c8 --experimental-monocart tsx test/c8.test.ts",
"posttest:c8": "rm -rf ./.nycrc.json",
"test:docker:node": "tsx test/ci.test.ts",
"test:docker:node": "bun test/ci.test.ts",
"clear": "rm -rf lib ci coverage .temp test-src test-tests",

@@ -53,4 +48,4 @@ "prebuild": "npm run clear",

"postbuild:deno": "tsx tools/build/check-deno-polyfill.ts",
"lint": "npx @biomejs/biome lint && prettier --check .",
"lint:fix": "npx @biomejs/biome lint --write && prettier --write .github/workflows/*.yml .",
"lint": "biome lint --error-on-warnings && prettier --check .",
"lint:fix": "biome lint --write && prettier --write .github/workflows/*.yml .",
"update": "pu minor && npm i && (npm audit fix || true)",

@@ -62,10 +57,10 @@ "postupdate": "npm run lint:fix",

"@biomejs/biome": "1.9.4",
"@types/node": "^22.8.0",
"@types/node": "^22.10.1",
"c8": "^10.1.2",
"jsonc.min": "^1.1.0",
"monocart-coverage-reports": "^2.11.1",
"monocart-coverage-reports": "^2.11.4",
"packages-update": "^2.0.0",
"prettier": "^3.3.3",
"tsx": "4.19.1",
"typescript": "^5.6.3"
"prettier": "^3.4.2",
"tsx": "4.19.2",
"typescript": "^5.7.2"
},

@@ -72,0 +67,0 @@ "keywords": [

@@ -21,2 +21,6 @@ <div align="center">

> [!IMPORTANT]
>
> [**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` πŸ’‘
---

@@ -30,3 +34,2 @@

</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> **Performant** and **lightweight**<br />
<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Run **CommonJS** files directly with [**Deno**][deno-version-url]<br />
<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 />

@@ -123,3 +126,3 @@ <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 />

```bash
bunx poku
bun poku
```

@@ -220,6 +223,2 @@

<tr>
<td><a href="https://poku.io/docs/documentation/poku/options/parallel">parallel</a></td>
<td>πŸƒπŸ»β€β™€οΈ Run tests in parallel.</td>
</tr>
<tr>
<td><a href="https://poku.io/docs/documentation/poku/options/debug">debug</a></td>

@@ -226,0 +225,0 @@ <td>πŸ•΅πŸ» Shows all logs.</td>

Sorry, the diff of this file is not supported yet