@lage-run/reporters 1.3.2 → 1.3.3
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/CHANGELOG.json +15 -0
- package/CHANGELOG.md +9 -1
- package/lib/ProgressReporter.js +0 -1
- package/lib/ProgressReporter.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lage-run/reporters",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"date": "Fri, 08 Aug 2025 08:09:59 GMT",
|
|
6
|
+
"version": "1.3.3",
|
|
7
|
+
"tag": "@lage-run/reporters_v1.3.3",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "email not defined",
|
|
12
|
+
"package": "@lage-run/reporters",
|
|
13
|
+
"commit": "733dbd23642c8ca7dc405de21a3c8b65b5a1aa5c",
|
|
14
|
+
"comment": "Update dependency @ms-cloudpack/task-reporter to v0.17.2"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
4
19
|
{
|
|
5
20
|
"date": "Sat, 29 Mar 2025 02:16:38 GMT",
|
|
6
21
|
"version": "1.3.0",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
# Change Log - @lage-run/reporters
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on
|
|
3
|
+
<!-- This log was last generated on Fri, 08 Aug 2025 08:09:59 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.3.3
|
|
8
|
+
|
|
9
|
+
Fri, 08 Aug 2025 08:09:59 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Update dependency @ms-cloudpack/task-reporter to v0.17.2 (email not defined)
|
|
14
|
+
|
|
7
15
|
## 1.3.0
|
|
8
16
|
|
|
9
17
|
Wed, 12 Feb 2025 00:08:30 GMT
|
package/lib/ProgressReporter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ProgressReporter.ts"],"sourcesContent":["import EventEmitter from \"events\";\nimport { type LogEntry, LogLevel, type Reporter } from \"@lage-run/logger\";\nimport type { SchedulerRunSummary, TargetStatus } from \"@lage-run/scheduler-types\";\n\n// @ts-ignore Ignoring ESM in CJS errors here, but still importing the types to be used\n// import type { TaskReporter as TaskReporterType, TaskReporterTask } from \"@ms-cloudpack/task-reporter\";\nimport { TaskReporter, type TaskReporterTask } from \"@ms-cloudpack/task-reporter\";\nimport type { Target } from \"@lage-run/target-graph\";\nimport gradient from \"gradient-string\";\nimport chalk from \"chalk\";\nimport type { Writable } from \"stream\";\nimport { formatDuration, hrToSeconds, hrtimeDiff } from \"@lage-run/format-hrtime\";\nimport { formatBytes } from \"./formatBytes.js\";\nimport { slowestTargetRuns } from \"./slowestTargetRuns.js\";\n\nconst colors = {\n [LogLevel.info]: chalk.white,\n [LogLevel.verbose]: chalk.gray,\n [LogLevel.warn]: chalk.white,\n [LogLevel.error]: chalk.hex(\"#FF1010\"),\n [LogLevel.silly]: chalk.green,\n task: chalk.hex(\"#00DDDD\"),\n pkg: chalk.hex(\"#FFD66B\"),\n ok: chalk.green,\n error: chalk.red,\n warn: chalk.yellow,\n};\n\nfunction fancy(str: string) {\n return gradient({ r: 237, g: 178, b: 77 }, \"cyan\")(str);\n}\n\nexport class ProgressReporter implements Reporter {\n logStream: Writable = process.stdout;\n startTime: [number, number] = [0, 0];\n\n logEvent: EventEmitter = new EventEmitter();\n logEntries = new Map<string, LogEntry[]>();\n\n taskReporter: TaskReporter;\n tasks: Map<string, TaskReporterTask> = new Map();\n\n constructor(private options: { concurrency: number; version: string } = { concurrency: 0, version: \"0.0.0\" }) {\n this.taskReporter = this.createTaskReporter();\n\n this.print(`${fancy(\"lage\")} - Version ${options.version} - ${options.concurrency} Workers`);\n }\n\n createTaskReporter() {\n return new TaskReporter({\n productName: \"lage\",\n version: this.options.version,\n\n showCompleted: true,\n showConsoleDebug: true,\n showConsoleError: true,\n showConsoleInfo: true,\n showConsoleLog: true,\n showConsoleWarn: true,\n showErrors: true,\n showPending: true,\n showProgress: true,\n showStarted: true,\n showSummary: true,\n showTaskDetails: true,\n showTaskExtended: true,\n });\n }\n\n log(entry: LogEntry<any>) {\n // save the logs for errors\n if (entry.data?.target?.id) {\n if (!this.logEntries.has(entry.data.target.id)) {\n this.logEntries.set(entry.data.target.id, []);\n }\n this.logEntries.get(entry.data.target.id)!.push(entry);\n }\n\n // if \"hidden\", do not even attempt to record or report the entry\n if (entry?.data?.target?.hidden) {\n return;\n }\n\n if (entry.data && entry.data.schedulerRun) {\n this.startTime = entry.data.schedulerRun.startTime;\n }\n\n if (entry.data && entry.data.status && entry.data.target) {\n const target: Target = entry.data.target;\n const status: TargetStatus = entry.data.status;\n\n const reporterTask = this.tasks.has(target.id) ? this.tasks.get(target.id) : this.taskReporter.addTask(target.label, true);\n\n if (reporterTask) {\n this.tasks.set(target.id, reporterTask);\n switch (status) {\n case \"running\":\n reporterTask.start();\n break;\n\n case \"success\":\n reporterTask.complete({ status: \"complete\" });\n break;\n\n case \"aborted\":\n reporterTask.complete({ status: \"abort\" });\n break;\n\n case \"skipped\":\n reporterTask.complete({ status: \"skip\" });\n break;\n\n case \"failed\":\n reporterTask.complete({ status: \"fail\" });\n break;\n }\n }\n }\n }\n\n private print(message: string) {\n this.logStream.write(message + \"\\n\");\n }\n\n hr() {\n this.print(\"┈\".repeat(80));\n }\n\n summarize(schedulerRunSummary: SchedulerRunSummary) {\n const { targetRuns, targetRunByStatus, duration } = schedulerRunSummary;\n const { failed, aborted, skipped, success, pending, running, queued } = targetRunByStatus;\n\n // If we are printing summary, and there are still some running / queued tasks - report them as aborted\n for (const wrappedTarget of running.concat(queued)) {\n const reporterTask = this.tasks.get(wrappedTarget);\n if (reporterTask) {\n reporterTask.complete({ status: \"abort\" });\n }\n }\n\n const statusColorFn: {\n [status in TargetStatus]: chalk.Chalk;\n } = {\n success: chalk.greenBright,\n failed: chalk.redBright,\n skipped: chalk.gray,\n running: chalk.yellow,\n pending: chalk.gray,\n aborted: chalk.red,\n queued: chalk.magenta,\n };\n\n if (targetRuns.size > 0) {\n this.print(chalk.cyanBright(`\\nSummary`));\n\n this.hr();\n\n const slowestTargets = slowestTargetRuns([...targetRuns.values()]);\n\n for (const wrappedTarget of slowestTargets) {\n if (wrappedTarget.target.hidden) {\n continue;\n }\n\n const colorFn = statusColorFn[wrappedTarget.status] ?? chalk.white;\n const target = wrappedTarget.target;\n const hasDurations = !!wrappedTarget.duration && !!wrappedTarget.queueTime;\n const queueDuration: [number, number] = hasDurations ? hrtimeDiff(wrappedTarget.queueTime, wrappedTarget.startTime) : [0, 0];\n\n if (wrappedTarget.status === \"running\") {\n const reporterTask = this.tasks.get(wrappedTarget.target.id);\n if (reporterTask) {\n reporterTask.complete({ status: \"fail\" });\n }\n }\n\n this.print(\n `${target.label} ${colorFn(\n `${wrappedTarget.status === \"running\" ? \"running - incomplete\" : wrappedTarget.status}${\n hasDurations\n ? `, took ${formatDuration(hrToSeconds(wrappedTarget.duration))}, queued for ${formatDuration(hrToSeconds(queueDuration))}`\n : \"\"\n }`\n )}`\n );\n }\n\n this.print(\n `success: ${success.length}, skipped: ${skipped.length}, pending: ${pending.length}, aborted: ${aborted.length}, failed: ${failed.length}`\n );\n\n this.print(\n `worker restarts: ${schedulerRunSummary.workerRestarts}, max worker memory usage: ${formatBytes(\n schedulerRunSummary.maxWorkerMemoryUsage\n )}`\n );\n } else {\n this.print(\"Nothing has been run.\");\n }\n\n this.hr();\n\n if (failed && failed.length > 0) {\n for (const targetId of failed) {\n const target = targetRuns.get(targetId)?.target;\n\n if (target) {\n const { packageName, task } = target;\n const failureLogs = this.logEntries.get(targetId);\n\n this.print(`[${colors.pkg(packageName ?? \"<root>\")} ${colors.task(task)}] ${colors[LogLevel.error](\"ERROR DETECTED\")}`);\n\n if (failureLogs) {\n for (const entry of failureLogs) {\n // Log each entry separately to prevent truncation\n this.print(entry.msg);\n }\n }\n\n this.hr();\n }\n }\n }\n\n const allCacheHits = [...targetRuns.values()].filter((run) => !run.target.hidden).length === skipped.length;\n const allCacheHitText = allCacheHits ? fancy(`All targets skipped!`) : \"\";\n\n this.print(`Took a total of ${formatDuration(hrToSeconds(duration))} to complete. ${allCacheHitText}`);\n }\n}\n"],"names":["ProgressReporter","colors","LogLevel","info","chalk","white","verbose","gray","warn","error","hex","silly","green","task","pkg","ok","red","yellow","fancy","str","gradient","r","g","b","createTaskReporter","TaskReporter","productName","version","options","showCompleted","showConsoleDebug","showConsoleError","showConsoleInfo","showConsoleLog","showConsoleWarn","showErrors","showPending","showProgress","showStarted","showSummary","showTaskDetails","showTaskExtended","log","entry","data","target","id","logEntries","has","set","get","push","hidden","schedulerRun","startTime","status","reporterTask","tasks","taskReporter","addTask","label","start","complete","print","message","logStream","write","hr","repeat","summarize","schedulerRunSummary","targetRuns","targetRunByStatus","duration","failed","aborted","skipped","success","pending","running","queued","wrappedTarget","concat","statusColorFn","greenBright","redBright","magenta","size","cyanBright","slowestTargets","slowestTargetRuns","values","colorFn","hasDurations","queueTime","queueDuration","hrtimeDiff","formatDuration","hrToSeconds","length","workerRestarts","formatBytes","maxWorkerMemoryUsage","targetId","packageName","failureLogs","msg","allCacheHits","filter","run","allCacheHitText","concurrency","logEvent","process","stdout","EventEmitter","Map"],"mappings":";;;;+BAgCaA;;;eAAAA;;;+DAhCY;wBAC8B;8BAKH;uEAE/B;8DACH;8BAEsC;6BAC5B;mCACM;;;;;;;;;;;;;;;;;;;AAElC,MAAMC,SAAS;IACb,CAACC,gBAAQ,CAACC,IAAI,CAAC,EAAEC,cAAK,CAACC,KAAK;IAC5B,CAACH,gBAAQ,CAACI,OAAO,CAAC,EAAEF,cAAK,CAACG,IAAI;IAC9B,CAACL,gBA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I,CAACuC,KAAK,CAAC,GAAG7C,MAAM,QAAQ,WAAW,EAAEU,QAAQD,OAAO,CAAC,GAAG,EAAEC,QAAQmF,WAAW,CAAC,QAAQ,CAAC;IAC7F;AAuLF"}
|
|
1
|
+
{"version":3,"sources":["../src/ProgressReporter.ts"],"sourcesContent":["import EventEmitter from \"events\";\nimport { type LogEntry, LogLevel, type Reporter } from \"@lage-run/logger\";\nimport type { SchedulerRunSummary, TargetStatus } from \"@lage-run/scheduler-types\";\n\n// @ts-ignore -- this package has CJS via the exports map, but old TS might not recognize it?\n// (it works fine with the actual transpiling via SWC)\nimport { TaskReporter, type TaskReporterTask } from \"@ms-cloudpack/task-reporter\";\nimport type { Target } from \"@lage-run/target-graph\";\nimport gradient from \"gradient-string\";\nimport chalk from \"chalk\";\nimport type { Writable } from \"stream\";\nimport { formatDuration, hrToSeconds, hrtimeDiff } from \"@lage-run/format-hrtime\";\nimport { formatBytes } from \"./formatBytes.js\";\nimport { slowestTargetRuns } from \"./slowestTargetRuns.js\";\n\nconst colors = {\n [LogLevel.info]: chalk.white,\n [LogLevel.verbose]: chalk.gray,\n [LogLevel.warn]: chalk.white,\n [LogLevel.error]: chalk.hex(\"#FF1010\"),\n [LogLevel.silly]: chalk.green,\n task: chalk.hex(\"#00DDDD\"),\n pkg: chalk.hex(\"#FFD66B\"),\n ok: chalk.green,\n error: chalk.red,\n warn: chalk.yellow,\n};\n\nfunction fancy(str: string) {\n return gradient({ r: 237, g: 178, b: 77 }, \"cyan\")(str);\n}\n\nexport class ProgressReporter implements Reporter {\n logStream: Writable = process.stdout;\n startTime: [number, number] = [0, 0];\n\n logEvent: EventEmitter = new EventEmitter();\n logEntries = new Map<string, LogEntry[]>();\n\n taskReporter: TaskReporter;\n tasks: Map<string, TaskReporterTask> = new Map();\n\n constructor(private options: { concurrency: number; version: string } = { concurrency: 0, version: \"0.0.0\" }) {\n this.taskReporter = this.createTaskReporter();\n\n this.print(`${fancy(\"lage\")} - Version ${options.version} - ${options.concurrency} Workers`);\n }\n\n createTaskReporter() {\n return new TaskReporter({\n productName: \"lage\",\n version: this.options.version,\n\n showCompleted: true,\n showConsoleDebug: true,\n showConsoleError: true,\n showConsoleInfo: true,\n showConsoleLog: true,\n showConsoleWarn: true,\n showErrors: true,\n showPending: true,\n showStarted: true,\n showSummary: true,\n showTaskDetails: true,\n showTaskExtended: true,\n });\n }\n\n log(entry: LogEntry<any>) {\n // save the logs for errors\n if (entry.data?.target?.id) {\n if (!this.logEntries.has(entry.data.target.id)) {\n this.logEntries.set(entry.data.target.id, []);\n }\n this.logEntries.get(entry.data.target.id)!.push(entry);\n }\n\n // if \"hidden\", do not even attempt to record or report the entry\n if (entry?.data?.target?.hidden) {\n return;\n }\n\n if (entry.data && entry.data.schedulerRun) {\n this.startTime = entry.data.schedulerRun.startTime;\n }\n\n if (entry.data && entry.data.status && entry.data.target) {\n const target: Target = entry.data.target;\n const status: TargetStatus = entry.data.status;\n\n const reporterTask = this.tasks.has(target.id) ? this.tasks.get(target.id) : this.taskReporter.addTask(target.label, true);\n\n if (reporterTask) {\n this.tasks.set(target.id, reporterTask);\n switch (status) {\n case \"running\":\n reporterTask.start();\n break;\n\n case \"success\":\n reporterTask.complete({ status: \"complete\" });\n break;\n\n case \"aborted\":\n reporterTask.complete({ status: \"abort\" });\n break;\n\n case \"skipped\":\n reporterTask.complete({ status: \"skip\" });\n break;\n\n case \"failed\":\n reporterTask.complete({ status: \"fail\" });\n break;\n }\n }\n }\n }\n\n private print(message: string) {\n this.logStream.write(message + \"\\n\");\n }\n\n hr() {\n this.print(\"┈\".repeat(80));\n }\n\n summarize(schedulerRunSummary: SchedulerRunSummary) {\n const { targetRuns, targetRunByStatus, duration } = schedulerRunSummary;\n const { failed, aborted, skipped, success, pending, running, queued } = targetRunByStatus;\n\n // If we are printing summary, and there are still some running / queued tasks - report them as aborted\n for (const wrappedTarget of running.concat(queued)) {\n const reporterTask = this.tasks.get(wrappedTarget);\n if (reporterTask) {\n reporterTask.complete({ status: \"abort\" });\n }\n }\n\n const statusColorFn: {\n [status in TargetStatus]: chalk.Chalk;\n } = {\n success: chalk.greenBright,\n failed: chalk.redBright,\n skipped: chalk.gray,\n running: chalk.yellow,\n pending: chalk.gray,\n aborted: chalk.red,\n queued: chalk.magenta,\n };\n\n if (targetRuns.size > 0) {\n this.print(chalk.cyanBright(`\\nSummary`));\n\n this.hr();\n\n const slowestTargets = slowestTargetRuns([...targetRuns.values()]);\n\n for (const wrappedTarget of slowestTargets) {\n if (wrappedTarget.target.hidden) {\n continue;\n }\n\n const colorFn = statusColorFn[wrappedTarget.status] ?? chalk.white;\n const target = wrappedTarget.target;\n const hasDurations = !!wrappedTarget.duration && !!wrappedTarget.queueTime;\n const queueDuration: [number, number] = hasDurations ? hrtimeDiff(wrappedTarget.queueTime, wrappedTarget.startTime) : [0, 0];\n\n if (wrappedTarget.status === \"running\") {\n const reporterTask = this.tasks.get(wrappedTarget.target.id);\n if (reporterTask) {\n reporterTask.complete({ status: \"fail\" });\n }\n }\n\n this.print(\n `${target.label} ${colorFn(\n `${wrappedTarget.status === \"running\" ? \"running - incomplete\" : wrappedTarget.status}${\n hasDurations\n ? `, took ${formatDuration(hrToSeconds(wrappedTarget.duration))}, queued for ${formatDuration(hrToSeconds(queueDuration))}`\n : \"\"\n }`\n )}`\n );\n }\n\n this.print(\n `success: ${success.length}, skipped: ${skipped.length}, pending: ${pending.length}, aborted: ${aborted.length}, failed: ${failed.length}`\n );\n\n this.print(\n `worker restarts: ${schedulerRunSummary.workerRestarts}, max worker memory usage: ${formatBytes(\n schedulerRunSummary.maxWorkerMemoryUsage\n )}`\n );\n } else {\n this.print(\"Nothing has been run.\");\n }\n\n this.hr();\n\n if (failed && failed.length > 0) {\n for (const targetId of failed) {\n const target = targetRuns.get(targetId)?.target;\n\n if (target) {\n const { packageName, task } = target;\n const failureLogs = this.logEntries.get(targetId);\n\n this.print(`[${colors.pkg(packageName ?? \"<root>\")} ${colors.task(task)}] ${colors[LogLevel.error](\"ERROR DETECTED\")}`);\n\n if (failureLogs) {\n for (const entry of failureLogs) {\n // Log each entry separately to prevent truncation\n this.print(entry.msg);\n }\n }\n\n this.hr();\n }\n }\n }\n\n const allCacheHits = [...targetRuns.values()].filter((run) => !run.target.hidden).length === skipped.length;\n const allCacheHitText = allCacheHits ? fancy(`All targets skipped!`) : \"\";\n\n this.print(`Took a total of ${formatDuration(hrToSeconds(duration))} to complete. ${allCacheHitText}`);\n }\n}\n"],"names":["ProgressReporter","colors","LogLevel","info","chalk","white","verbose","gray","warn","error","hex","silly","green","task","pkg","ok","red","yellow","fancy","str","gradient","r","g","b","createTaskReporter","TaskReporter","productName","version","options","showCompleted","showConsoleDebug","showConsoleError","showConsoleInfo","showConsoleLog","showConsoleWarn","showErrors","showPending","showStarted","showSummary","showTaskDetails","showTaskExtended","log","entry","data","target","id","logEntries","has","set","get","push","hidden","schedulerRun","startTime","status","reporterTask","tasks","taskReporter","addTask","label","start","complete","print","message","logStream","write","hr","repeat","summarize","schedulerRunSummary","targetRuns","targetRunByStatus","duration","failed","aborted","skipped","success","pending","running","queued","wrappedTarget","concat","statusColorFn","greenBright","redBright","magenta","size","cyanBright","slowestTargets","slowestTargetRuns","values","colorFn","hasDurations","queueTime","queueDuration","hrtimeDiff","formatDuration","hrToSeconds","length","workerRestarts","formatBytes","maxWorkerMemoryUsage","targetId","packageName","failureLogs","msg","allCacheHits","filter","run","allCacheHitText","concurrency","logEvent","process","stdout","EventEmitter","Map"],"mappings":";;;;+BAgCaA;;;eAAAA;;;+DAhCY;wBAC8B;8BAKH;uEAE/B;8DACH;8BAEsC;6BAC5B;mCACM;;;;;;;;;;;;;;;;;;;AAElC,MAAMC,SAAS;IACb,CAACC,gBAAQ,CAACC,IAAI,CAAC,EAAEC,cAAK,CAACC,KAAK;IAC5B,CAACH,gBAAQ,CAACI,OAAO,CAAC,EAAEF,cAAK,CAACG,IAAI;IAC9B,CAACL,gBAAQ,CAACM,IAAI,CAAC,EAAEJ,cAAK,C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AAEU,QAAQD,OAAO,CAAC,GAAG,EAAEC,QAAQkF,WAAW,CAAC,QAAQ,CAAC;IAC7F;AAsLF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lage-run/reporters",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Log reporters for Lage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@lage-run/logger": "^1.3.1",
|
|
22
22
|
"@lage-run/scheduler-types": "^0.3.25",
|
|
23
23
|
"@lage-run/target-graph": "^0.11.3",
|
|
24
|
-
"@ms-cloudpack/task-reporter": "0.
|
|
24
|
+
"@ms-cloudpack/task-reporter": "0.17.2",
|
|
25
25
|
"ansi-regex": "5.0.1",
|
|
26
26
|
"chalk": "4.1.2",
|
|
27
27
|
"gradient-string": "2.0.2"
|