poku 4.3.0 → 4.3.1-canary.cf096c2b

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.
@@ -21,7 +21,7 @@ exports.results = {
21
21
  skipped: 0,
22
22
  todo: 0,
23
23
  };
24
- exports.VERSION = '4.3.0';
24
+ exports.VERSION = '4.3.1-canary.cf096c2b';
25
25
  exports.deepOptions = [];
26
26
  exports.GLOBAL = {
27
27
  cwd: (0, node_process_1.cwd)(),
@@ -28,7 +28,6 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
28
28
  const PID = service.pid;
29
29
  service.stdout.setEncoding('utf8');
30
30
  service.stderr.setEncoding('utf8');
31
- let portBackup;
32
31
  const end = (port) => new Promise((resolve) => {
33
32
  try {
34
33
  runningProcesses.delete(PID);
@@ -41,7 +40,7 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
41
40
  node_process_1.default.kill(PID);
42
41
  else
43
42
  node_process_1.default.kill(-PID, 'SIGKILL');
44
- if (port && ['bun', 'deno'].includes(runtime)) {
43
+ if (port) {
45
44
  setTimeout(async () => {
46
45
  await kill_js_1.kill.port(port);
47
46
  resolve(undefined);
@@ -58,7 +57,7 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
58
57
  return;
59
58
  }
60
59
  });
61
- runningProcesses.set(PID, { end, port: portBackup });
60
+ runningProcesses.set(PID, end);
62
61
  service.stdout.on('data', (data) => {
63
62
  if (!isResolved && typeof options?.startAfter !== 'number') {
64
63
  const stringData = JSON.stringify(String(data));
@@ -86,7 +85,7 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
86
85
  options?.verbose && (0, write_js_1.log)(data);
87
86
  });
88
87
  service.on('error', (err) => {
89
- end(portBackup);
88
+ end();
90
89
  reject(`Service failed to start: ${err}`);
91
90
  });
92
91
  service.on('close', (code) => {
@@ -95,7 +94,7 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
95
94
  });
96
95
  const timeout = setTimeout(() => {
97
96
  if (!isResolved) {
98
- end(portBackup);
97
+ end();
99
98
  reject(`createService: Timeout\nFile: ${file}`);
100
99
  }
101
100
  }, options?.timeout || 60000);
@@ -138,6 +137,6 @@ const startScript = (script, options) => {
138
137
  };
139
138
  exports.startScript = startScript;
140
139
  node_process_1.default.once('SIGINT', async () => {
141
- for (const { end, port } of runningProcesses.values())
142
- await end(port);
140
+ for (const end of runningProcesses.values())
141
+ await end();
143
142
  });
@@ -112,10 +112,6 @@ async function itCore(titleOrCb, cb) {
112
112
  if (get_arg_js_1.hasOnly) {
113
113
  if (!poku_js_1.GLOBAL.runAsOnly)
114
114
  return;
115
- if (typeof titleOrCb === 'string' && typeof cb === 'function')
116
- return (0, exports.itBase)(titleOrCb, cb);
117
- if (typeof titleOrCb === 'function')
118
- return (0, exports.itBase)(titleOrCb);
119
115
  }
120
116
  if (typeof titleOrCb === 'string' && cb)
121
117
  return (0, exports.itBase)(titleOrCb, cb);
@@ -6,6 +6,8 @@ const promises_1 = require("node:fs/promises");
6
6
  const node_path_1 = require("node:path");
7
7
  const poku_js_1 = require("../configs/poku.js");
8
8
  const jsonc_js_1 = require("../polyfills/jsonc.js");
9
+ const format_js_1 = require("../services/format.js");
10
+ const write_js_1 = require("../services/write.js");
9
11
  const os_js_1 = require("./os.js");
10
12
  const getConfigs = async (customPath) => {
11
13
  const expectedFiles = customPath
@@ -24,7 +26,11 @@ const getConfigs = async (customPath) => {
24
26
  const configsFile = await (0, promises_1.readFile)(filePath, 'utf8');
25
27
  return jsonc_js_1.JSONC.parse(configsFile);
26
28
  }
27
- catch { }
29
+ catch (error) {
30
+ (0, write_js_1.log)(`${(0, format_js_1.format)('⚠').bold()} Failed to load config file ${(0, format_js_1.format)(file).bold()}:`);
31
+ const message = error instanceof Error ? error.message : String(error);
32
+ (0, write_js_1.log)(`${(0, format_js_1.format)(message).fail()}`);
33
+ }
28
34
  }
29
35
  return Object.create(null);
30
36
  };
@@ -1,9 +1,6 @@
1
1
  /**
2
2
  * Adapted from https://github.com/wellwelwel/jsonc.min
3
3
  */
4
- declare class JsoncProcessor {
5
- toJSON(content: string): string;
6
- parse<T = unknown>(text: string): T;
7
- }
8
- export declare const JSONC: JsoncProcessor;
9
- export {};
4
+ export declare const JSONC: {
5
+ parse: <T = unknown>(text: string) => T;
6
+ };
@@ -4,54 +4,96 @@ exports.JSONC = void 0;
4
4
  /**
5
5
  * Adapted from https://github.com/wellwelwel/jsonc.min
6
6
  */
7
- class JsoncProcessor {
8
- toJSON(content) {
7
+ exports.JSONC = (() => {
8
+ const DOUBLE_QUOTE = 0x22;
9
+ const BACKSLASH = 0x5c;
10
+ const SLASH = 0x2f;
11
+ const ASTERISK = 0x2a;
12
+ const COMMA = 0x2c;
13
+ const CLOSE_BRACKET = 0x5d;
14
+ const CLOSE_BRACE = 0x7d;
15
+ const SPACE = 0x20;
16
+ const BOM = 0xfeff;
17
+ const toJSON = (content) => {
18
+ const offset = content.charCodeAt(0) === BOM ? 1 : 0;
9
19
  const length = content.length;
10
- let inBlockComment = false;
11
- let inString = false;
12
- let skipChar = false;
13
20
  let result = '';
14
- for (let i = 0; i < length; i++) {
15
- const char = content[i];
16
- if (skipChar) {
17
- skipChar = false;
18
- continue;
19
- }
20
- if (inBlockComment) {
21
- if (char === '*' && content[i + 1] === '/') {
22
- inBlockComment = false;
23
- skipChar = true;
21
+ let segment = offset;
22
+ let pendingComma = false;
23
+ let cursor = offset;
24
+ while (cursor < length) {
25
+ const current = content.charCodeAt(cursor);
26
+ if (current === DOUBLE_QUOTE) {
27
+ if (pendingComma) {
28
+ result += `,${content.slice(segment, cursor)}`;
29
+ segment = cursor;
30
+ pendingComma = false;
31
+ }
32
+ cursor++;
33
+ for (;;) {
34
+ const closing = content.indexOf('"', cursor);
35
+ if (closing === -1) {
36
+ cursor = length;
37
+ break;
38
+ }
39
+ let backslashes = 0;
40
+ for (let pos = closing - 1; pos >= cursor && content.charCodeAt(pos) === BACKSLASH; pos--) {
41
+ backslashes++;
42
+ }
43
+ cursor = closing + 1;
44
+ if ((backslashes & 1) === 0) {
45
+ break;
46
+ }
24
47
  }
25
48
  continue;
26
49
  }
27
- if (inString) {
28
- if (char === '"' && content[i - 1] !== '\\')
29
- inString = false;
30
- result += char;
31
- continue;
50
+ if (current === SLASH) {
51
+ const next = content.charCodeAt(cursor + 1);
52
+ if (next === SLASH) {
53
+ result += content.slice(segment, cursor);
54
+ const endOfLine = content.indexOf('\n', cursor + 2);
55
+ cursor = endOfLine === -1 ? length : endOfLine;
56
+ segment = cursor;
57
+ continue;
58
+ }
59
+ if (next === ASTERISK) {
60
+ result += content.slice(segment, cursor);
61
+ const endOfBlock = content.indexOf('*/', cursor + 2);
62
+ cursor = endOfBlock === -1 ? length : endOfBlock + 2;
63
+ segment = cursor;
64
+ continue;
65
+ }
32
66
  }
33
- if (char === '"') {
34
- inString = true;
35
- result += char;
67
+ if (current === COMMA) {
68
+ if (pendingComma) {
69
+ result += `,${content.slice(segment, cursor)}`;
70
+ }
71
+ else {
72
+ result += content.slice(segment, cursor);
73
+ }
74
+ segment = cursor + 1;
75
+ pendingComma = true;
76
+ cursor++;
36
77
  continue;
37
78
  }
38
- if (char === '/' && content[i + 1] === '*') {
39
- inBlockComment = true;
40
- skipChar = true;
79
+ if (current === CLOSE_BRACKET || current === CLOSE_BRACE) {
80
+ pendingComma = false;
81
+ cursor++;
41
82
  continue;
42
83
  }
43
- if (char === '/' && content[i + 1] === '/') {
44
- while (i < length && content[i] !== '\n')
45
- i++;
46
- continue;
84
+ if (pendingComma && current > SPACE) {
85
+ result += `,${content.slice(segment, cursor)}`;
86
+ segment = cursor;
87
+ pendingComma = false;
47
88
  }
48
- result += char;
89
+ cursor++;
90
+ }
91
+ if (pendingComma) {
92
+ result += ',';
49
93
  }
94
+ result += content.slice(segment, length);
50
95
  return result;
51
- }
52
- parse(text) {
53
- const cleanContent = this.toJSON(text);
54
- return JSON.parse(cleanContent);
55
- }
56
- }
57
- exports.JSONC = new JsoncProcessor();
96
+ };
97
+ const parse = (text) => JSON.parse(toJSON(text));
98
+ return { parse };
99
+ })();
@@ -6,7 +6,7 @@ const node_path_1 = require("node:path");
6
6
  const list_files_js_1 = require("../modules/helpers/list-files.js");
7
7
  const regex = {
8
8
  extFilter: /\.(js|cjs|mjs|ts|cts|mts)$/,
9
- dependecy: /['"](\.{1,2}\/[^'"]+)['"]/,
9
+ dependency: /['"`](\.{1,2}\/[^'"`]+)['"`]/,
10
10
  dotBar: /(\.\/)/g,
11
11
  sep: /[/\\]+/g,
12
12
  dot: /^\.+/,
@@ -23,7 +23,7 @@ const getDeepImports = (content) => {
23
23
  if (line.indexOf('import') !== -1 ||
24
24
  line.indexOf('require') !== -1 ||
25
25
  line.indexOf(' from ') !== -1) {
26
- const path = line.match(regex.dependecy);
26
+ const path = line.match(regex.dependency);
27
27
  if (path)
28
28
  paths.add((0, exports.normalizePath)(path[1].replace(regex.extFilter, '')));
29
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poku",
3
- "version": "4.3.0",
3
+ "version": "4.3.1-canary.cf096c2b",
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": {