@jsenv/core 27.0.3 → 27.1.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/dist/main.js +103 -12
- package/package.json +3 -3
- package/src/test/execute_plan.js +6 -0
- package/src/test/execute_test_plan.js +4 -0
- package/src/test/logs_file_execution.js +90 -13
package/dist/main.js
CHANGED
|
@@ -332,23 +332,27 @@ const canUseUnicode = isUnicodeSupported();
|
|
|
332
332
|
const COMMAND_RAW = canUseUnicode ? `❯` : `>`;
|
|
333
333
|
const OK_RAW = canUseUnicode ? `✔` : `√`;
|
|
334
334
|
const FAILURE_RAW = canUseUnicode ? `✖` : `×`;
|
|
335
|
+
const DEBUG_RAW = canUseUnicode ? `◆` : `♦`;
|
|
335
336
|
const INFO_RAW = canUseUnicode ? `ℹ` : `i`;
|
|
336
337
|
const WARNING_RAW = canUseUnicode ? `⚠` : `‼`;
|
|
337
338
|
const COMMAND = ANSI.color(COMMAND_RAW, ANSI.GREY); // ANSI_MAGENTA)
|
|
338
339
|
|
|
339
340
|
const OK = ANSI.color(OK_RAW, ANSI.GREEN);
|
|
340
341
|
const FAILURE = ANSI.color(FAILURE_RAW, ANSI.RED);
|
|
342
|
+
const DEBUG = ANSI.color(DEBUG_RAW, ANSI.GREY);
|
|
341
343
|
const INFO = ANSI.color(INFO_RAW, ANSI.BLUE);
|
|
342
344
|
const WARNING = ANSI.color(WARNING_RAW, ANSI.YELLOW);
|
|
343
345
|
const UNICODE = {
|
|
344
346
|
COMMAND,
|
|
345
347
|
OK,
|
|
346
348
|
FAILURE,
|
|
349
|
+
DEBUG,
|
|
347
350
|
INFO,
|
|
348
351
|
WARNING,
|
|
349
352
|
COMMAND_RAW,
|
|
350
353
|
OK_RAW,
|
|
351
354
|
FAILURE_RAW,
|
|
355
|
+
DEBUG_RAW,
|
|
352
356
|
INFO_RAW,
|
|
353
357
|
WARNING_RAW,
|
|
354
358
|
supported: canUseUnicode
|
|
@@ -24853,6 +24857,8 @@ const createExecutionLog = ({
|
|
|
24853
24857
|
}, {
|
|
24854
24858
|
completedExecutionLogAbbreviation,
|
|
24855
24859
|
counters,
|
|
24860
|
+
logRuntime,
|
|
24861
|
+
logEachDuration,
|
|
24856
24862
|
timeEllapsed,
|
|
24857
24863
|
memoryHeap
|
|
24858
24864
|
}) => {
|
|
@@ -24885,8 +24891,12 @@ const createExecutionLog = ({
|
|
|
24885
24891
|
label: `${description}${summary}`,
|
|
24886
24892
|
details: {
|
|
24887
24893
|
file: fileRelativeUrl,
|
|
24888
|
-
|
|
24889
|
-
|
|
24894
|
+
...(logRuntime ? {
|
|
24895
|
+
runtime: `${runtimeName}/${runtimeVersion}`
|
|
24896
|
+
} : {}),
|
|
24897
|
+
...(logEachDuration ? {
|
|
24898
|
+
duration: status === "executing" ? msAsEllapsedTime(Date.now() - startMs) : msAsDuration(endMs - startMs)
|
|
24899
|
+
} : {}),
|
|
24890
24900
|
...(error ? {
|
|
24891
24901
|
error: error.stack || error.message || error
|
|
24892
24902
|
} : {})
|
|
@@ -25040,22 +25050,93 @@ const descriptionFormatters = {
|
|
|
25040
25050
|
};
|
|
25041
25051
|
|
|
25042
25052
|
const formatConsoleCalls = consoleCalls => {
|
|
25043
|
-
|
|
25044
|
-
text
|
|
25045
|
-
}) => {
|
|
25046
|
-
return `${previous}${text}`;
|
|
25047
|
-
}, "");
|
|
25048
|
-
const consoleOutputTrimmed = consoleOutput.trim();
|
|
25049
|
-
|
|
25050
|
-
if (consoleOutputTrimmed === "") {
|
|
25053
|
+
if (consoleCalls.length === 0) {
|
|
25051
25054
|
return "";
|
|
25052
25055
|
}
|
|
25053
25056
|
|
|
25054
|
-
|
|
25055
|
-
|
|
25057
|
+
const repartition = {
|
|
25058
|
+
debug: 0,
|
|
25059
|
+
info: 0,
|
|
25060
|
+
warning: 0,
|
|
25061
|
+
error: 0,
|
|
25062
|
+
log: 0
|
|
25063
|
+
};
|
|
25064
|
+
let consoleOutput = ``;
|
|
25065
|
+
consoleCalls.forEach(consoleCall => {
|
|
25066
|
+
repartition[consoleCall.type]++;
|
|
25067
|
+
const text = consoleCall.text;
|
|
25068
|
+
const textFormatted = prefixFirstAndIndentRemainingLines({
|
|
25069
|
+
prefix: CONSOLE_ICONS[consoleCall.type],
|
|
25070
|
+
text,
|
|
25071
|
+
trimLastLine: consoleCall === consoleCalls[consoleCalls.length - 1]
|
|
25072
|
+
});
|
|
25073
|
+
consoleOutput += textFormatted;
|
|
25074
|
+
});
|
|
25075
|
+
return `${ANSI.color(`-------- ${formatConsoleSummary(repartition)} --------`, ANSI.GREY)}
|
|
25076
|
+
${consoleOutput}
|
|
25056
25077
|
${ANSI.color(`-------------------------`, ANSI.GREY)}`;
|
|
25057
25078
|
};
|
|
25058
25079
|
|
|
25080
|
+
const CONSOLE_ICONS = {
|
|
25081
|
+
debug: UNICODE.DEBUG,
|
|
25082
|
+
info: UNICODE.INFO,
|
|
25083
|
+
warning: UNICODE.WARNING,
|
|
25084
|
+
error: UNICODE.FAILURE,
|
|
25085
|
+
log: " "
|
|
25086
|
+
};
|
|
25087
|
+
|
|
25088
|
+
const formatConsoleSummary = repartition => {
|
|
25089
|
+
const {
|
|
25090
|
+
debug,
|
|
25091
|
+
info,
|
|
25092
|
+
warning,
|
|
25093
|
+
error
|
|
25094
|
+
} = repartition;
|
|
25095
|
+
const parts = [];
|
|
25096
|
+
|
|
25097
|
+
if (error) {
|
|
25098
|
+
parts.push(`${CONSOLE_ICONS.error} ${error}`);
|
|
25099
|
+
}
|
|
25100
|
+
|
|
25101
|
+
if (warning) {
|
|
25102
|
+
parts.push(`${CONSOLE_ICONS.warning} ${warning}`);
|
|
25103
|
+
}
|
|
25104
|
+
|
|
25105
|
+
if (info) {
|
|
25106
|
+
parts.push(`${CONSOLE_ICONS.info} ${info}`);
|
|
25107
|
+
}
|
|
25108
|
+
|
|
25109
|
+
if (debug) {
|
|
25110
|
+
parts.push(`${CONSOLE_ICONS.debug} ${debug}`);
|
|
25111
|
+
}
|
|
25112
|
+
|
|
25113
|
+
if (parts.length === 0) {
|
|
25114
|
+
return `console`;
|
|
25115
|
+
}
|
|
25116
|
+
|
|
25117
|
+
return `console (${parts.join(" ")})`;
|
|
25118
|
+
};
|
|
25119
|
+
|
|
25120
|
+
const prefixFirstAndIndentRemainingLines = ({
|
|
25121
|
+
prefix,
|
|
25122
|
+
text,
|
|
25123
|
+
trimLastLine
|
|
25124
|
+
}) => {
|
|
25125
|
+
const lines = text.split(/\r?\n/);
|
|
25126
|
+
const firstLine = lines.shift();
|
|
25127
|
+
let result = `${prefix} ${firstLine}`;
|
|
25128
|
+
let i = 0;
|
|
25129
|
+
const indentation = ` `;
|
|
25130
|
+
|
|
25131
|
+
while (i < lines.length) {
|
|
25132
|
+
const line = lines[i].trim();
|
|
25133
|
+
i++;
|
|
25134
|
+
result += line.length ? `\n${indentation}${line}` : trimLastLine && i === lines.length ? "" : `\n`;
|
|
25135
|
+
}
|
|
25136
|
+
|
|
25137
|
+
return result;
|
|
25138
|
+
};
|
|
25139
|
+
|
|
25059
25140
|
const formatExecution = ({
|
|
25060
25141
|
label,
|
|
25061
25142
|
details = {},
|
|
@@ -25080,6 +25161,8 @@ const executePlan = async (plan, {
|
|
|
25080
25161
|
signal,
|
|
25081
25162
|
handleSIGINT,
|
|
25082
25163
|
logger,
|
|
25164
|
+
logRuntime,
|
|
25165
|
+
logEachDuration,
|
|
25083
25166
|
logSummary,
|
|
25084
25167
|
logTimeUsage,
|
|
25085
25168
|
logMemoryHeapUsage,
|
|
@@ -25375,6 +25458,8 @@ const executePlan = async (plan, {
|
|
|
25375
25458
|
render: () => {
|
|
25376
25459
|
return createExecutionLog(beforeExecutionInfo, {
|
|
25377
25460
|
counters,
|
|
25461
|
+
logRuntime,
|
|
25462
|
+
logEachDuration,
|
|
25378
25463
|
...(logTimeUsage ? {
|
|
25379
25464
|
timeEllapsed: Date.now() - startMs
|
|
25380
25465
|
} : {}),
|
|
@@ -25448,6 +25533,8 @@ const executePlan = async (plan, {
|
|
|
25448
25533
|
let log = createExecutionLog(afterExecutionInfo, {
|
|
25449
25534
|
completedExecutionLogAbbreviation,
|
|
25450
25535
|
counters,
|
|
25536
|
+
logRuntime,
|
|
25537
|
+
logEachDuration,
|
|
25451
25538
|
...(logTimeUsage ? {
|
|
25452
25539
|
timeEllapsed: Date.now() - startMs
|
|
25453
25540
|
} : {}),
|
|
@@ -25654,6 +25741,8 @@ const executeTestPlan = async ({
|
|
|
25654
25741
|
signal = new AbortController().signal,
|
|
25655
25742
|
handleSIGINT = true,
|
|
25656
25743
|
logLevel = "info",
|
|
25744
|
+
logRuntime = true,
|
|
25745
|
+
logEachDuration = true,
|
|
25657
25746
|
logSummary = true,
|
|
25658
25747
|
logTimeUsage = false,
|
|
25659
25748
|
logMemoryHeapUsage = false,
|
|
@@ -25751,6 +25840,8 @@ const executeTestPlan = async ({
|
|
|
25751
25840
|
logger,
|
|
25752
25841
|
logLevel,
|
|
25753
25842
|
logSummary,
|
|
25843
|
+
logRuntime,
|
|
25844
|
+
logEachDuration,
|
|
25754
25845
|
logTimeUsage,
|
|
25755
25846
|
logMemoryHeapUsage,
|
|
25756
25847
|
logFileRelativeUrl,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "27.0
|
|
3
|
+
"version": "27.1.0",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -71,13 +71,13 @@
|
|
|
71
71
|
"@jsenv/importmap": "1.2.1",
|
|
72
72
|
"@jsenv/integrity": "0.0.1",
|
|
73
73
|
"@jsenv/node-esm-resolution": "0.1.0",
|
|
74
|
-
"@jsenv/server": "12.7.
|
|
74
|
+
"@jsenv/server": "12.7.5",
|
|
75
75
|
"@jsenv/uneval": "1.6.0",
|
|
76
76
|
"@jsenv/url-meta": "7.0.0",
|
|
77
77
|
"@jsenv/urls": "1.2.6",
|
|
78
78
|
"@jsenv/utils": "2.0.1",
|
|
79
79
|
"@jsenv/babel-plugins": "1.0.5",
|
|
80
|
-
"@jsenv/log": "3.0
|
|
80
|
+
"@jsenv/log": "3.1.0",
|
|
81
81
|
"@jsenv/sourcemap": "1.0.1",
|
|
82
82
|
"acorn-import-assertions": "1.8.0",
|
|
83
83
|
"cuid": "2.1.8",
|
package/src/test/execute_plan.js
CHANGED
|
@@ -37,6 +37,8 @@ export const executePlan = async (
|
|
|
37
37
|
signal,
|
|
38
38
|
handleSIGINT,
|
|
39
39
|
logger,
|
|
40
|
+
logRuntime,
|
|
41
|
+
logEachDuration,
|
|
40
42
|
logSummary,
|
|
41
43
|
logTimeUsage,
|
|
42
44
|
logMemoryHeapUsage,
|
|
@@ -338,6 +340,8 @@ export const executePlan = async (
|
|
|
338
340
|
render: () => {
|
|
339
341
|
return createExecutionLog(beforeExecutionInfo, {
|
|
340
342
|
counters,
|
|
343
|
+
logRuntime,
|
|
344
|
+
logEachDuration,
|
|
341
345
|
...(logTimeUsage
|
|
342
346
|
? {
|
|
343
347
|
timeEllapsed: Date.now() - startMs,
|
|
@@ -411,6 +415,8 @@ export const executePlan = async (
|
|
|
411
415
|
let log = createExecutionLog(afterExecutionInfo, {
|
|
412
416
|
completedExecutionLogAbbreviation,
|
|
413
417
|
counters,
|
|
418
|
+
logRuntime,
|
|
419
|
+
logEachDuration,
|
|
414
420
|
...(logTimeUsage
|
|
415
421
|
? {
|
|
416
422
|
timeEllapsed: Date.now() - startMs,
|
|
@@ -36,6 +36,8 @@ export const executeTestPlan = async ({
|
|
|
36
36
|
signal = new AbortController().signal,
|
|
37
37
|
handleSIGINT = true,
|
|
38
38
|
logLevel = "info",
|
|
39
|
+
logRuntime = true,
|
|
40
|
+
logEachDuration = true,
|
|
39
41
|
logSummary = true,
|
|
40
42
|
logTimeUsage = false,
|
|
41
43
|
logMemoryHeapUsage = false,
|
|
@@ -138,6 +140,8 @@ export const executeTestPlan = async ({
|
|
|
138
140
|
logger,
|
|
139
141
|
logLevel,
|
|
140
142
|
logSummary,
|
|
143
|
+
logRuntime,
|
|
144
|
+
logEachDuration,
|
|
141
145
|
logTimeUsage,
|
|
142
146
|
logMemoryHeapUsage,
|
|
143
147
|
logFileRelativeUrl,
|
|
@@ -19,7 +19,14 @@ export const createExecutionLog = (
|
|
|
19
19
|
startMs,
|
|
20
20
|
endMs,
|
|
21
21
|
},
|
|
22
|
-
{
|
|
22
|
+
{
|
|
23
|
+
completedExecutionLogAbbreviation,
|
|
24
|
+
counters,
|
|
25
|
+
logRuntime,
|
|
26
|
+
logEachDuration,
|
|
27
|
+
timeEllapsed,
|
|
28
|
+
memoryHeap,
|
|
29
|
+
},
|
|
23
30
|
) => {
|
|
24
31
|
const { status } = executionResult
|
|
25
32
|
const descriptionFormatter = descriptionFormatters[status]
|
|
@@ -43,11 +50,15 @@ export const createExecutionLog = (
|
|
|
43
50
|
label: `${description}${summary}`,
|
|
44
51
|
details: {
|
|
45
52
|
file: fileRelativeUrl,
|
|
46
|
-
runtime: `${runtimeName}/${runtimeVersion}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
...(logRuntime ? { runtime: `${runtimeName}/${runtimeVersion}` } : {}),
|
|
54
|
+
...(logEachDuration
|
|
55
|
+
? {
|
|
56
|
+
duration:
|
|
57
|
+
status === "executing"
|
|
58
|
+
? msAsEllapsedTime(Date.now() - startMs)
|
|
59
|
+
: msAsDuration(endMs - startMs),
|
|
60
|
+
}
|
|
61
|
+
: {}),
|
|
51
62
|
...(error ? { error: error.stack || error.message || error } : {}),
|
|
52
63
|
},
|
|
53
64
|
consoleOutput,
|
|
@@ -203,18 +214,84 @@ const descriptionFormatters = {
|
|
|
203
214
|
}
|
|
204
215
|
|
|
205
216
|
const formatConsoleCalls = (consoleCalls) => {
|
|
206
|
-
|
|
207
|
-
return `${previous}${text}`
|
|
208
|
-
}, "")
|
|
209
|
-
const consoleOutputTrimmed = consoleOutput.trim()
|
|
210
|
-
if (consoleOutputTrimmed === "") {
|
|
217
|
+
if (consoleCalls.length === 0) {
|
|
211
218
|
return ""
|
|
212
219
|
}
|
|
213
|
-
|
|
214
|
-
|
|
220
|
+
|
|
221
|
+
const repartition = {
|
|
222
|
+
debug: 0,
|
|
223
|
+
info: 0,
|
|
224
|
+
warning: 0,
|
|
225
|
+
error: 0,
|
|
226
|
+
log: 0,
|
|
227
|
+
}
|
|
228
|
+
let consoleOutput = ``
|
|
229
|
+
consoleCalls.forEach((consoleCall) => {
|
|
230
|
+
repartition[consoleCall.type]++
|
|
231
|
+
const text = consoleCall.text
|
|
232
|
+
const textFormatted = prefixFirstAndIndentRemainingLines({
|
|
233
|
+
prefix: CONSOLE_ICONS[consoleCall.type],
|
|
234
|
+
text,
|
|
235
|
+
trimLastLine: consoleCall === consoleCalls[consoleCalls.length - 1],
|
|
236
|
+
})
|
|
237
|
+
consoleOutput += textFormatted
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
return `${ANSI.color(
|
|
241
|
+
`-------- ${formatConsoleSummary(repartition)} --------`,
|
|
242
|
+
ANSI.GREY,
|
|
243
|
+
)}
|
|
244
|
+
${consoleOutput}
|
|
215
245
|
${ANSI.color(`-------------------------`, ANSI.GREY)}`
|
|
216
246
|
}
|
|
217
247
|
|
|
248
|
+
const CONSOLE_ICONS = {
|
|
249
|
+
debug: UNICODE.DEBUG,
|
|
250
|
+
info: UNICODE.INFO,
|
|
251
|
+
warning: UNICODE.WARNING,
|
|
252
|
+
error: UNICODE.FAILURE,
|
|
253
|
+
log: " ",
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const formatConsoleSummary = (repartition) => {
|
|
257
|
+
const { debug, info, warning, error } = repartition
|
|
258
|
+
const parts = []
|
|
259
|
+
if (error) {
|
|
260
|
+
parts.push(`${CONSOLE_ICONS.error} ${error}`)
|
|
261
|
+
}
|
|
262
|
+
if (warning) {
|
|
263
|
+
parts.push(`${CONSOLE_ICONS.warning} ${warning}`)
|
|
264
|
+
}
|
|
265
|
+
if (info) {
|
|
266
|
+
parts.push(`${CONSOLE_ICONS.info} ${info}`)
|
|
267
|
+
}
|
|
268
|
+
if (debug) {
|
|
269
|
+
parts.push(`${CONSOLE_ICONS.debug} ${debug}`)
|
|
270
|
+
}
|
|
271
|
+
if (parts.length === 0) {
|
|
272
|
+
return `console`
|
|
273
|
+
}
|
|
274
|
+
return `console (${parts.join(" ")})`
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const prefixFirstAndIndentRemainingLines = ({ prefix, text, trimLastLine }) => {
|
|
278
|
+
const lines = text.split(/\r?\n/)
|
|
279
|
+
const firstLine = lines.shift()
|
|
280
|
+
let result = `${prefix} ${firstLine}`
|
|
281
|
+
let i = 0
|
|
282
|
+
const indentation = ` `
|
|
283
|
+
while (i < lines.length) {
|
|
284
|
+
const line = lines[i].trim()
|
|
285
|
+
i++
|
|
286
|
+
result += line.length
|
|
287
|
+
? `\n${indentation}${line}`
|
|
288
|
+
: trimLastLine && i === lines.length
|
|
289
|
+
? ""
|
|
290
|
+
: `\n`
|
|
291
|
+
}
|
|
292
|
+
return result
|
|
293
|
+
}
|
|
294
|
+
|
|
218
295
|
const formatExecution = ({ label, details = {}, consoleOutput }) => {
|
|
219
296
|
let message = ``
|
|
220
297
|
message += label
|