@memberjunction/installer 5.11.0 → 5.12.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/InstallerEngine.d.ts +83 -0
- package/dist/InstallerEngine.d.ts.map +1 -1
- package/dist/InstallerEngine.js +476 -3
- package/dist/InstallerEngine.js.map +1 -1
- package/dist/adapters/GitHubReleaseProvider.d.ts +66 -9
- package/dist/adapters/GitHubReleaseProvider.d.ts.map +1 -1
- package/dist/adapters/GitHubReleaseProvider.js +157 -29
- package/dist/adapters/GitHubReleaseProvider.js.map +1 -1
- package/dist/adapters/ProcessRunner.d.ts +6 -0
- package/dist/adapters/ProcessRunner.d.ts.map +1 -1
- package/dist/adapters/ProcessRunner.js +3 -0
- package/dist/adapters/ProcessRunner.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/logging/EventLogger.d.ts +105 -0
- package/dist/logging/EventLogger.d.ts.map +1 -0
- package/dist/logging/EventLogger.js +165 -0
- package/dist/logging/EventLogger.js.map +1 -0
- package/dist/logging/ReportGenerator.d.ts +175 -0
- package/dist/logging/ReportGenerator.d.ts.map +1 -0
- package/dist/logging/ReportGenerator.js +526 -0
- package/dist/logging/ReportGenerator.js.map +1 -0
- package/dist/models/InstallConfig.d.ts +5 -0
- package/dist/models/InstallConfig.d.ts.map +1 -1
- package/dist/models/InstallConfig.js +2 -1
- package/dist/models/InstallConfig.js.map +1 -1
- package/dist/models/InstallPlan.d.ts +17 -0
- package/dist/models/InstallPlan.d.ts.map +1 -1
- package/dist/models/InstallPlan.js.map +1 -1
- package/dist/phases/CodeGenPhase.d.ts +35 -2
- package/dist/phases/CodeGenPhase.d.ts.map +1 -1
- package/dist/phases/CodeGenPhase.js +128 -8
- package/dist/phases/CodeGenPhase.js.map +1 -1
- package/dist/phases/ConfigurePhase.d.ts +143 -8
- package/dist/phases/ConfigurePhase.d.ts.map +1 -1
- package/dist/phases/ConfigurePhase.js +378 -31
- package/dist/phases/ConfigurePhase.js.map +1 -1
- package/dist/phases/DependencyPhase.d.ts +40 -2
- package/dist/phases/DependencyPhase.d.ts.map +1 -1
- package/dist/phases/DependencyPhase.js +102 -5
- package/dist/phases/DependencyPhase.js.map +1 -1
- package/dist/phases/MigratePhase.d.ts +34 -6
- package/dist/phases/MigratePhase.d.ts.map +1 -1
- package/dist/phases/MigratePhase.js +48 -7
- package/dist/phases/MigratePhase.js.map +1 -1
- package/dist/phases/ScaffoldPhase.d.ts.map +1 -1
- package/dist/phases/ScaffoldPhase.js +20 -6
- package/dist/phases/ScaffoldPhase.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export { type InstallConfig, type PartialInstallConfig, InstallConfigDefaults, r
|
|
|
43
43
|
export { InstallPlan, type CreatePlanInput, type RunOptions, type DoctorOptions, type InstallResult, type PhaseInfo, } from './models/InstallPlan.js';
|
|
44
44
|
export { InstallState, type InstallStateData, type PhaseState, type PhaseStatus, } from './models/InstallState.js';
|
|
45
45
|
export { Diagnostics, type DiagnosticCheck, type DiagnosticStatus, type EnvironmentInfo, type LastInstallInfo, } from './models/Diagnostics.js';
|
|
46
|
+
export { EventLogger, type LogEntry, type LogLevel } from './logging/EventLogger.js';
|
|
47
|
+
export { ReportGenerator, type ReportData } from './logging/ReportGenerator.js';
|
|
46
48
|
export { GitHubReleaseProvider } from './adapters/GitHubReleaseProvider.js';
|
|
47
49
|
export { FileSystemAdapter } from './adapters/FileSystemAdapter.js';
|
|
48
50
|
export { ProcessRunner, type ProcessResult, type ProcessOptions } from './adapters/ProcessRunner.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;A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AK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACzG,OAAO,EAAE,sBAAsB,EAAE,KAAK,wBAAwB,EAAE,KAAK,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AACzI,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAE,KAAK,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC7H,OAAO,EAAE,eAAe,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAClJ,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -45,6 +45,9 @@ export { InstallConfigDefaults, resolveFromEnvironment, loadConfigFile, mergeCon
|
|
|
45
45
|
export { InstallPlan, } from './models/InstallPlan.js';
|
|
46
46
|
export { InstallState, } from './models/InstallState.js';
|
|
47
47
|
export { Diagnostics, } from './models/Diagnostics.js';
|
|
48
|
+
// Logging (exported for testing and extension use)
|
|
49
|
+
export { EventLogger } from './logging/EventLogger.js';
|
|
50
|
+
export { ReportGenerator } from './logging/ReportGenerator.js';
|
|
48
51
|
// Adapters (exported for testing and extension use)
|
|
49
52
|
export { GitHubReleaseProvider } from './adapters/GitHubReleaseProvider.js';
|
|
50
53
|
export { FileSystemAdapter } from './adapters/FileSystemAdapter.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file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MAAM,iCAAiC,CAAC;AAC7H,OAAO,EAAE,eAAe,EAAiD,MAAM,6BAA6B,CAAC;AAC7G,OAAO,EAAE,YAAY,EAA4F,MAAM,0BAA0B,CAAC;AAClJ,OAAO,EAAE,cAAc,EAA+C,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventLogger — captures all installer events into a time-stamped buffer.
|
|
3
|
+
*
|
|
4
|
+
* Subscribes to every event type on an {@link InstallerEventEmitter} and
|
|
5
|
+
* stores structured entries. The buffer is used by {@link ReportGenerator}
|
|
6
|
+
* to produce diagnostic reports for remote troubleshooting.
|
|
7
|
+
*
|
|
8
|
+
* **Design decisions:**
|
|
9
|
+
* - Entries are capped at {@link MAX_ENTRIES} to prevent runaway memory
|
|
10
|
+
* usage during long installs with verbose output.
|
|
11
|
+
* - Passwords and secrets are never stored — the logger sanitizes config
|
|
12
|
+
* values before capture.
|
|
13
|
+
* - The logger is passive: it only reads events, never emits or modifies them.
|
|
14
|
+
*
|
|
15
|
+
* @module logging/EventLogger
|
|
16
|
+
* @see ReportGenerator — consumes the event log to produce markdown reports.
|
|
17
|
+
* @see InstallerEngine — wires the logger to the engine's event emitter.
|
|
18
|
+
*/
|
|
19
|
+
import type { InstallerEventEmitter } from '../events/InstallerEvents.js';
|
|
20
|
+
import type { PhaseId } from '../errors/InstallerError.js';
|
|
21
|
+
/**
|
|
22
|
+
* Severity level for a log entry, derived from the source event type.
|
|
23
|
+
*
|
|
24
|
+
* - `'info'` — normal progress, phase lifecycle, diagnostics.
|
|
25
|
+
* - `'warn'` — non-blocking warnings.
|
|
26
|
+
* - `'error'` — terminal failures.
|
|
27
|
+
* - `'verbose'` — detailed output (npm lines, build output).
|
|
28
|
+
* - `'prompt'` — user interaction events.
|
|
29
|
+
*/
|
|
30
|
+
export type LogLevel = 'info' | 'warn' | 'error' | 'verbose' | 'prompt';
|
|
31
|
+
/**
|
|
32
|
+
* A single captured event entry with timestamp and metadata.
|
|
33
|
+
*/
|
|
34
|
+
export interface LogEntry {
|
|
35
|
+
/** ISO 8601 timestamp when the event was captured. */
|
|
36
|
+
Timestamp: string;
|
|
37
|
+
/** Severity level derived from the source event type. */
|
|
38
|
+
Level: LogLevel;
|
|
39
|
+
/** Human-readable message describing the event. */
|
|
40
|
+
Message: string;
|
|
41
|
+
/** Phase that produced the event (if applicable). */
|
|
42
|
+
Phase?: PhaseId;
|
|
43
|
+
/** Source event type (e.g., `'phase:start'`, `'error'`, `'step:progress'`). */
|
|
44
|
+
Source: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Captures all installer events into a queryable, time-stamped buffer.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const logger = new EventLogger();
|
|
52
|
+
* logger.Attach(engine.emitter);
|
|
53
|
+
*
|
|
54
|
+
* // ... install runs ...
|
|
55
|
+
*
|
|
56
|
+
* const entries = logger.Entries;
|
|
57
|
+
* const errors = logger.GetByLevel('error');
|
|
58
|
+
* logger.Detach();
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare class EventLogger {
|
|
62
|
+
private entries;
|
|
63
|
+
private emitter;
|
|
64
|
+
private handlers;
|
|
65
|
+
/**
|
|
66
|
+
* Subscribe to all event types on the given emitter.
|
|
67
|
+
*
|
|
68
|
+
* @param emitter - The installer event emitter to capture events from.
|
|
69
|
+
*/
|
|
70
|
+
Attach(emitter: InstallerEventEmitter): void;
|
|
71
|
+
/**
|
|
72
|
+
* Unsubscribe from all event types. Safe to call multiple times.
|
|
73
|
+
*/
|
|
74
|
+
Detach(): void;
|
|
75
|
+
/** All captured log entries in chronological order. */
|
|
76
|
+
get Entries(): ReadonlyArray<LogEntry>;
|
|
77
|
+
/** Number of entries in the buffer. */
|
|
78
|
+
get Count(): number;
|
|
79
|
+
/**
|
|
80
|
+
* Filter entries by severity level.
|
|
81
|
+
*
|
|
82
|
+
* @param level - The severity level to filter by.
|
|
83
|
+
* @returns Entries matching the given level.
|
|
84
|
+
*/
|
|
85
|
+
GetByLevel(level: LogLevel): LogEntry[];
|
|
86
|
+
/**
|
|
87
|
+
* Filter entries by phase.
|
|
88
|
+
*
|
|
89
|
+
* @param phase - The phase ID to filter by.
|
|
90
|
+
* @returns Entries associated with the given phase.
|
|
91
|
+
*/
|
|
92
|
+
GetByPhase(phase: PhaseId): LogEntry[];
|
|
93
|
+
/** Clear all captured entries. */
|
|
94
|
+
Clear(): void;
|
|
95
|
+
private addEntry;
|
|
96
|
+
private onPhaseStart;
|
|
97
|
+
private onPhaseEnd;
|
|
98
|
+
private onStepProgress;
|
|
99
|
+
private onLog;
|
|
100
|
+
private onWarn;
|
|
101
|
+
private onError;
|
|
102
|
+
private onPrompt;
|
|
103
|
+
private onDiagnostic;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=EventLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventLogger.d.ts","sourceRoot":"","sources":["../../src/logging/EventLogger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAK3D;;;;;;;;GAQG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,KAAK,EAAE,QAAQ,CAAC;IAChB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,OAAO,CAAsC;IAGrD,OAAO,CAAC,QAAQ,CASd;IAEF;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI;IAY5C;;OAEG;IACH,MAAM,IAAI,IAAI;IAad,uDAAuD;IACvD,IAAI,OAAO,IAAI,aAAa,CAAC,QAAQ,CAAC,CAErC;IAED,uCAAuC;IACvC,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;;;;OAKG;IACH,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,EAAE;IAIvC;;;;;OAKG;IACH,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,EAAE;IAItC,kCAAkC;IAClC,KAAK,IAAI,IAAI;IAQb,OAAO,CAAC,QAAQ;IAchB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventLogger — captures all installer events into a time-stamped buffer.
|
|
3
|
+
*
|
|
4
|
+
* Subscribes to every event type on an {@link InstallerEventEmitter} and
|
|
5
|
+
* stores structured entries. The buffer is used by {@link ReportGenerator}
|
|
6
|
+
* to produce diagnostic reports for remote troubleshooting.
|
|
7
|
+
*
|
|
8
|
+
* **Design decisions:**
|
|
9
|
+
* - Entries are capped at {@link MAX_ENTRIES} to prevent runaway memory
|
|
10
|
+
* usage during long installs with verbose output.
|
|
11
|
+
* - Passwords and secrets are never stored — the logger sanitizes config
|
|
12
|
+
* values before capture.
|
|
13
|
+
* - The logger is passive: it only reads events, never emits or modifies them.
|
|
14
|
+
*
|
|
15
|
+
* @module logging/EventLogger
|
|
16
|
+
* @see ReportGenerator — consumes the event log to produce markdown reports.
|
|
17
|
+
* @see InstallerEngine — wires the logger to the engine's event emitter.
|
|
18
|
+
*/
|
|
19
|
+
/** Maximum number of log entries before oldest entries are discarded. */
|
|
20
|
+
const MAX_ENTRIES = 5000;
|
|
21
|
+
/**
|
|
22
|
+
* Captures all installer events into a queryable, time-stamped buffer.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const logger = new EventLogger();
|
|
27
|
+
* logger.Attach(engine.emitter);
|
|
28
|
+
*
|
|
29
|
+
* // ... install runs ...
|
|
30
|
+
*
|
|
31
|
+
* const entries = logger.Entries;
|
|
32
|
+
* const errors = logger.GetByLevel('error');
|
|
33
|
+
* logger.Detach();
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export class EventLogger {
|
|
37
|
+
constructor() {
|
|
38
|
+
this.entries = [];
|
|
39
|
+
this.emitter = null;
|
|
40
|
+
// Store handler references for cleanup
|
|
41
|
+
this.handlers = {
|
|
42
|
+
phaseStart: this.onPhaseStart.bind(this),
|
|
43
|
+
phaseEnd: this.onPhaseEnd.bind(this),
|
|
44
|
+
stepProgress: this.onStepProgress.bind(this),
|
|
45
|
+
log: this.onLog.bind(this),
|
|
46
|
+
warn: this.onWarn.bind(this),
|
|
47
|
+
error: this.onError.bind(this),
|
|
48
|
+
prompt: this.onPrompt.bind(this),
|
|
49
|
+
diagnostic: this.onDiagnostic.bind(this),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Subscribe to all event types on the given emitter.
|
|
54
|
+
*
|
|
55
|
+
* @param emitter - The installer event emitter to capture events from.
|
|
56
|
+
*/
|
|
57
|
+
Attach(emitter) {
|
|
58
|
+
this.emitter = emitter;
|
|
59
|
+
emitter.On('phase:start', this.handlers.phaseStart);
|
|
60
|
+
emitter.On('phase:end', this.handlers.phaseEnd);
|
|
61
|
+
emitter.On('step:progress', this.handlers.stepProgress);
|
|
62
|
+
emitter.On('log', this.handlers.log);
|
|
63
|
+
emitter.On('warn', this.handlers.warn);
|
|
64
|
+
emitter.On('error', this.handlers.error);
|
|
65
|
+
emitter.On('prompt', this.handlers.prompt);
|
|
66
|
+
emitter.On('diagnostic', this.handlers.diagnostic);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Unsubscribe from all event types. Safe to call multiple times.
|
|
70
|
+
*/
|
|
71
|
+
Detach() {
|
|
72
|
+
if (!this.emitter)
|
|
73
|
+
return;
|
|
74
|
+
this.emitter.Off('phase:start', this.handlers.phaseStart);
|
|
75
|
+
this.emitter.Off('phase:end', this.handlers.phaseEnd);
|
|
76
|
+
this.emitter.Off('step:progress', this.handlers.stepProgress);
|
|
77
|
+
this.emitter.Off('log', this.handlers.log);
|
|
78
|
+
this.emitter.Off('warn', this.handlers.warn);
|
|
79
|
+
this.emitter.Off('error', this.handlers.error);
|
|
80
|
+
this.emitter.Off('prompt', this.handlers.prompt);
|
|
81
|
+
this.emitter.Off('diagnostic', this.handlers.diagnostic);
|
|
82
|
+
this.emitter = null;
|
|
83
|
+
}
|
|
84
|
+
/** All captured log entries in chronological order. */
|
|
85
|
+
get Entries() {
|
|
86
|
+
return this.entries;
|
|
87
|
+
}
|
|
88
|
+
/** Number of entries in the buffer. */
|
|
89
|
+
get Count() {
|
|
90
|
+
return this.entries.length;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Filter entries by severity level.
|
|
94
|
+
*
|
|
95
|
+
* @param level - The severity level to filter by.
|
|
96
|
+
* @returns Entries matching the given level.
|
|
97
|
+
*/
|
|
98
|
+
GetByLevel(level) {
|
|
99
|
+
return this.entries.filter((e) => e.Level === level);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Filter entries by phase.
|
|
103
|
+
*
|
|
104
|
+
* @param phase - The phase ID to filter by.
|
|
105
|
+
* @returns Entries associated with the given phase.
|
|
106
|
+
*/
|
|
107
|
+
GetByPhase(phase) {
|
|
108
|
+
return this.entries.filter((e) => e.Phase === phase);
|
|
109
|
+
}
|
|
110
|
+
/** Clear all captured entries. */
|
|
111
|
+
Clear() {
|
|
112
|
+
this.entries = [];
|
|
113
|
+
}
|
|
114
|
+
// -------------------------------------------------------------------------
|
|
115
|
+
// Event handlers
|
|
116
|
+
// -------------------------------------------------------------------------
|
|
117
|
+
addEntry(level, message, source, phase) {
|
|
118
|
+
if (this.entries.length >= MAX_ENTRIES) {
|
|
119
|
+
// Drop oldest 10% to avoid constant shifting
|
|
120
|
+
this.entries = this.entries.slice(Math.floor(MAX_ENTRIES * 0.1));
|
|
121
|
+
}
|
|
122
|
+
this.entries.push({
|
|
123
|
+
Timestamp: new Date().toISOString(),
|
|
124
|
+
Level: level,
|
|
125
|
+
Message: message,
|
|
126
|
+
Phase: phase,
|
|
127
|
+
Source: source,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
onPhaseStart(event) {
|
|
131
|
+
this.addEntry('info', `Phase started: ${event.Description}`, 'phase:start', event.Phase);
|
|
132
|
+
}
|
|
133
|
+
onPhaseEnd(event) {
|
|
134
|
+
const duration = `${Math.round(event.DurationMs / 1000)}s`;
|
|
135
|
+
if (event.Status === 'failed' && event.Error) {
|
|
136
|
+
this.addEntry('error', `Phase failed (${duration}): [${event.Error.Code}] ${event.Error.message}`, 'phase:end', event.Phase);
|
|
137
|
+
if (event.Error.SuggestedFix) {
|
|
138
|
+
this.addEntry('info', `Suggested fix: ${event.Error.SuggestedFix}`, 'phase:end', event.Phase);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
this.addEntry('info', `Phase ${event.Status} (${duration})`, 'phase:end', event.Phase);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
onStepProgress(event) {
|
|
146
|
+
const percent = event.Percent != null ? ` (${event.Percent}%)` : '';
|
|
147
|
+
this.addEntry('verbose', `${event.Message}${percent}`, 'step:progress', event.Phase);
|
|
148
|
+
}
|
|
149
|
+
onLog(event) {
|
|
150
|
+
this.addEntry(event.Level, event.Message, 'log');
|
|
151
|
+
}
|
|
152
|
+
onWarn(event) {
|
|
153
|
+
this.addEntry('warn', event.Message, 'warn', event.Phase);
|
|
154
|
+
}
|
|
155
|
+
onError(event) {
|
|
156
|
+
this.addEntry('error', `[${event.Error.Code}] ${event.Error.message}`, 'error', event.Phase);
|
|
157
|
+
}
|
|
158
|
+
onPrompt(event) {
|
|
159
|
+
this.addEntry('prompt', `Prompt [${event.PromptId}]: ${event.Message}`, 'prompt');
|
|
160
|
+
}
|
|
161
|
+
onDiagnostic(event) {
|
|
162
|
+
this.addEntry('info', `[${event.Status.toUpperCase()}] ${event.Check}: ${event.Message}`, 'diagnostic');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=EventLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventLogger.js","sourceRoot":"","sources":["../../src/logging/EventLogger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,yEAAyE;AACzE,MAAM,WAAW,GAAG,IAAI,CAAC;AA6BzB;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,WAAW;IAAxB;QACU,YAAO,GAAe,EAAE,CAAC;QACzB,YAAO,GAAiC,IAAI,CAAC;QAErD,uCAAuC;QAC/B,aAAQ,GAAG;YACjB,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;YACxC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;YACpC,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5C,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CA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,EAAE,QAAQ,CAAC,CAAC;IACpF,CAAC;IAEO,YAAY,CAAC,KAAyD;QAC5E,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;IAC1G,CAAC;CACF"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReportGenerator — produces comprehensive diagnostic reports for remote troubleshooting.
|
|
3
|
+
*
|
|
4
|
+
* Generates a single markdown file containing everything needed to diagnose
|
|
5
|
+
* an installation failure without access to the user's machine:
|
|
6
|
+
*
|
|
7
|
+
* - Environment info (OS, Node, npm, architecture)
|
|
8
|
+
* - Install state (version, phase statuses, timestamps)
|
|
9
|
+
* - Sanitized configuration (passwords/secrets redacted)
|
|
10
|
+
* - Diagnostic check results (preflight + known issues)
|
|
11
|
+
* - Key file existence checks
|
|
12
|
+
* - Full event log (timestamped, all severity levels)
|
|
13
|
+
*
|
|
14
|
+
* **Security**: All passwords, secrets, and API keys are redacted before
|
|
15
|
+
* inclusion in the report. The report is safe to share publicly.
|
|
16
|
+
*
|
|
17
|
+
* @module logging/ReportGenerator
|
|
18
|
+
* @see EventLogger — provides the event log buffer consumed by this generator.
|
|
19
|
+
* @see InstallerEngine — triggers report generation on install failure.
|
|
20
|
+
*/
|
|
21
|
+
import type { Diagnostics, EnvironmentInfo } from '../models/Diagnostics.js';
|
|
22
|
+
import type { InstallStateData } from '../models/InstallState.js';
|
|
23
|
+
import type { PartialInstallConfig } from '../models/InstallConfig.js';
|
|
24
|
+
import type { InstallResult } from '../models/InstallPlan.js';
|
|
25
|
+
import type { LogEntry } from './EventLogger.js';
|
|
26
|
+
/**
|
|
27
|
+
* Data collected for the diagnostic report.
|
|
28
|
+
*
|
|
29
|
+
* All fields are optional — the generator produces whatever sections have data.
|
|
30
|
+
* This allows reports from both full installs (all fields populated) and
|
|
31
|
+
* standalone `mj doctor` runs (only diagnostics + environment).
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Sanitized contents of a configuration file for inclusion in the report.
|
|
35
|
+
*/
|
|
36
|
+
export interface ConfigFileSnapshot {
|
|
37
|
+
/** Relative path from the install directory. */
|
|
38
|
+
RelativePath: string;
|
|
39
|
+
/** Whether the file was found. */
|
|
40
|
+
Exists: boolean;
|
|
41
|
+
/** Sanitized file contents (passwords/secrets redacted), or `null` if not found. */
|
|
42
|
+
Content: string | null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Captured startup output from a service (MJAPI or Explorer).
|
|
46
|
+
*/
|
|
47
|
+
export interface ServiceLogCapture {
|
|
48
|
+
/** Service name (e.g., `"MJAPI"`, `"Explorer"`). */
|
|
49
|
+
Service: string;
|
|
50
|
+
/** Whether the service started successfully. */
|
|
51
|
+
Started: boolean;
|
|
52
|
+
/** Captured stdout/stderr lines during startup. */
|
|
53
|
+
Output: string[];
|
|
54
|
+
/** Duration of the startup capture in milliseconds. */
|
|
55
|
+
DurationMs: number;
|
|
56
|
+
/** Reason for failure (if applicable). */
|
|
57
|
+
FailureReason?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface ReportData {
|
|
60
|
+
/** Detected runtime environment (OS, Node, npm, architecture). */
|
|
61
|
+
Environment?: EnvironmentInfo;
|
|
62
|
+
/** Install state from the checkpoint file. */
|
|
63
|
+
InstallState?: InstallStateData;
|
|
64
|
+
/** Install result (success, duration, warnings, phases). */
|
|
65
|
+
InstallResult?: InstallResult;
|
|
66
|
+
/** Sanitized configuration (passwords redacted). */
|
|
67
|
+
Config?: PartialInstallConfig;
|
|
68
|
+
/** Diagnostic check results from preflight and known-issue scans. */
|
|
69
|
+
Diagnostics?: Diagnostics;
|
|
70
|
+
/** Full event log from the install or doctor run. */
|
|
71
|
+
EventLog?: ReadonlyArray<LogEntry>;
|
|
72
|
+
/** Absolute path to the install directory. */
|
|
73
|
+
TargetDir?: string;
|
|
74
|
+
/** Trigger that caused the report to be generated. */
|
|
75
|
+
Trigger?: 'install-failure' | 'doctor-report' | 'manual';
|
|
76
|
+
/** Sanitized snapshots of key configuration files. */
|
|
77
|
+
ConfigFiles?: ConfigFileSnapshot[];
|
|
78
|
+
/** Captured service startup logs (MJAPI, Explorer). */
|
|
79
|
+
ServiceLogs?: ServiceLogCapture[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Generates and saves comprehensive diagnostic reports.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const generator = new ReportGenerator();
|
|
87
|
+
* const reportPath = await generator.Generate({
|
|
88
|
+
* Environment: diagnostics.Environment,
|
|
89
|
+
* InstallState: state.ToJSON(),
|
|
90
|
+
* EventLog: logger.Entries,
|
|
91
|
+
* TargetDir: '/path/to/install',
|
|
92
|
+
* Trigger: 'install-failure',
|
|
93
|
+
* });
|
|
94
|
+
* console.log(`Report saved to: ${reportPath}`);
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare class ReportGenerator {
|
|
98
|
+
private fileSystem;
|
|
99
|
+
/**
|
|
100
|
+
* Generate a markdown diagnostic report and save it to the target directory.
|
|
101
|
+
*
|
|
102
|
+
* @param data - Collected diagnostic data for the report.
|
|
103
|
+
* @returns Absolute path to the generated report file.
|
|
104
|
+
*/
|
|
105
|
+
Generate(data: ReportData): Promise<string>;
|
|
106
|
+
/**
|
|
107
|
+
* Generate the markdown report content without saving to disk.
|
|
108
|
+
*
|
|
109
|
+
* @param data - Collected diagnostic data for the report.
|
|
110
|
+
* @returns The full markdown string.
|
|
111
|
+
*/
|
|
112
|
+
Render(data: ReportData): string;
|
|
113
|
+
/**
|
|
114
|
+
* Check which key files exist in the target directory.
|
|
115
|
+
*
|
|
116
|
+
* @param targetDir - The install directory to check.
|
|
117
|
+
* @returns Array of file checks with existence status.
|
|
118
|
+
*/
|
|
119
|
+
CheckKeyFiles(targetDir: string): Promise<Array<{
|
|
120
|
+
Path: string;
|
|
121
|
+
Description: string;
|
|
122
|
+
Exists: boolean;
|
|
123
|
+
}>>;
|
|
124
|
+
/**
|
|
125
|
+
* Redact sensitive fields from a config object.
|
|
126
|
+
*
|
|
127
|
+
* @param config - The config to sanitize (not mutated).
|
|
128
|
+
* @returns A new object with sensitive values replaced by `"[REDACTED]"`.
|
|
129
|
+
*/
|
|
130
|
+
SanitizeConfig(config: PartialInstallConfig): Record<string, unknown>;
|
|
131
|
+
/**
|
|
132
|
+
* Snapshot all key configuration files with sensitive values redacted.
|
|
133
|
+
*
|
|
134
|
+
* Reads `.env`, `environment.ts`, and `mj.config.cjs` files from both
|
|
135
|
+
* monorepo and distribution layouts, redacting passwords and secrets.
|
|
136
|
+
*
|
|
137
|
+
* @param targetDir - The install directory to scan.
|
|
138
|
+
* @returns Array of config file snapshots for inclusion in the report.
|
|
139
|
+
*/
|
|
140
|
+
SnapshotConfigFiles(targetDir: string): Promise<ConfigFileSnapshot[]>;
|
|
141
|
+
/**
|
|
142
|
+
* Sanitize file content based on format, redacting sensitive values.
|
|
143
|
+
*
|
|
144
|
+
* @param content - Raw file content.
|
|
145
|
+
* @param format - File format for context-aware redaction.
|
|
146
|
+
* @returns Content with sensitive values replaced by `[REDACTED]`.
|
|
147
|
+
*/
|
|
148
|
+
private sanitizeFileContent;
|
|
149
|
+
/**
|
|
150
|
+
* Sanitize a `.env` file by redacting values of sensitive keys.
|
|
151
|
+
*/
|
|
152
|
+
private sanitizeEnvContent;
|
|
153
|
+
/**
|
|
154
|
+
* Sanitize TypeScript/JavaScript code by redacting known secret patterns.
|
|
155
|
+
* Handles patterns like `CLIENT_SECRET: 'value'` and `password: 'value'`.
|
|
156
|
+
*/
|
|
157
|
+
private sanitizeCodeContent;
|
|
158
|
+
/** Check if an environment variable key holds a sensitive value. */
|
|
159
|
+
private isSensitiveEnvKey;
|
|
160
|
+
private renderMarkdown;
|
|
161
|
+
private renderHeader;
|
|
162
|
+
private renderEnvironment;
|
|
163
|
+
private renderInstallResult;
|
|
164
|
+
private renderInstallState;
|
|
165
|
+
private renderConfig;
|
|
166
|
+
private renderDiagnostics;
|
|
167
|
+
private renderKeyFilesPlaceholder;
|
|
168
|
+
private renderEventLog;
|
|
169
|
+
private renderConfigFiles;
|
|
170
|
+
private renderServiceLogs;
|
|
171
|
+
private formatDuration;
|
|
172
|
+
private truncate;
|
|
173
|
+
private escapeMarkdownTable;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=ReportGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReportGenerator.d.ts","sourceRoot":"","sources":["../../src/logging/ReportGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAuGjD;;;;;;GAMG;AACH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,YAAY,EAAE,MAAM,CAAC;IACrB,kCAAkC;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,oFAAoF;IACpF,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,mDAAmD;IACnD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;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