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.
- package/lib/configs/poku.js +1 -1
- package/lib/modules/helpers/create-service.js +6 -7
- package/lib/modules/helpers/it/core.js +0 -4
- package/lib/parsers/options.js +7 -1
- package/lib/polyfills/jsonc.d.ts +3 -6
- package/lib/polyfills/jsonc.js +80 -38
- package/lib/services/map-tests.js +2 -2
- package/package.json +1 -1
package/lib/configs/poku.js
CHANGED
|
@@ -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
|
|
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,
|
|
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(
|
|
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(
|
|
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
|
|
142
|
-
await end(
|
|
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);
|
package/lib/parsers/options.js
CHANGED
|
@@ -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
|
};
|
package/lib/polyfills/jsonc.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Adapted from https://github.com/wellwelwel/jsonc.min
|
|
3
3
|
*/
|
|
4
|
-
declare
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
export declare const JSONC: JsoncProcessor;
|
|
9
|
-
export {};
|
|
4
|
+
export declare const JSONC: {
|
|
5
|
+
parse: <T = unknown>(text: string) => T;
|
|
6
|
+
};
|
package/lib/polyfills/jsonc.js
CHANGED
|
@@ -4,54 +4,96 @@ exports.JSONC = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Adapted from https://github.com/wellwelwel/jsonc.min
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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 (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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 (
|
|
34
|
-
|
|
35
|
-
|
|
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 (
|
|
39
|
-
|
|
40
|
-
|
|
79
|
+
if (current === CLOSE_BRACKET || current === CLOSE_BRACE) {
|
|
80
|
+
pendingComma = false;
|
|
81
|
+
cursor++;
|
|
41
82
|
continue;
|
|
42
83
|
}
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
84
|
+
if (pendingComma && current > SPACE) {
|
|
85
|
+
result += `,${content.slice(segment, cursor)}`;
|
|
86
|
+
segment = cursor;
|
|
87
|
+
pendingComma = false;
|
|
47
88
|
}
|
|
48
|
-
|
|
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
|
-
|
|
54
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
}
|