braeburn 1.5.2 → 1.6.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/runner.d.ts +1 -0
- package/dist/runner.js +50 -11
- package/dist/steps/index.d.ts +1 -1
- package/dist/steps/index.js +1 -1
- package/dist/steps/macos.js +4 -4
- package/dist/steps/runtime.d.ts +1 -0
- package/dist/steps/runtime.js +9 -1
- package/dist/steps/types.d.ts +1 -0
- package/dist/ui/header.d.ts +1 -1
- package/dist/ui/outputLines.d.ts +6 -0
- package/dist/ui/outputLines.js +33 -0
- package/dist/ui/screen.d.ts +1 -1
- package/dist/ui/screen.js +2 -2
- package/package.json +1 -1
- package/dist/ui/outputBox.d.ts +0 -6
- package/dist/ui/outputBox.js +0 -35
package/dist/runner.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare class ShellCommandCanceledError extends Error {
|
|
|
17
17
|
}
|
|
18
18
|
export declare function cancelActiveShellCommand(): boolean;
|
|
19
19
|
export declare function runShellCommand(options: RunCommandOptions): Promise<void>;
|
|
20
|
+
export declare function runShellCommandAndCaptureOutput(options: RunCommandOptions): Promise<string>;
|
|
20
21
|
type CheckCommandOptions = {
|
|
21
22
|
shellCommand: string;
|
|
22
23
|
};
|
package/dist/runner.js
CHANGED
|
@@ -60,30 +60,62 @@ function buildFailureSummaryLines(shellCommand, error) {
|
|
|
60
60
|
}
|
|
61
61
|
return summaryLines;
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
function createBufferedLineEmitter(emitLine) {
|
|
64
|
+
let pendingText = "";
|
|
65
|
+
return {
|
|
66
|
+
appendChunk(chunk) {
|
|
67
|
+
pendingText += String(chunk);
|
|
68
|
+
const lineParts = pendingText.split(/\r?\n|\r/);
|
|
69
|
+
pendingText = lineParts.pop() ?? "";
|
|
70
|
+
for (const linePart of lineParts) {
|
|
71
|
+
if (linePart.length === 0) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
emitLine(linePart);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
flushPendingLine() {
|
|
78
|
+
if (pendingText.length === 0) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
emitLine(pendingText);
|
|
82
|
+
pendingText = "";
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
async function executeShellCommand(options) {
|
|
87
|
+
const capturedOutputLines = [];
|
|
64
88
|
const subprocess = execa("bash", ["-c", options.shellCommand], {
|
|
65
89
|
all: true,
|
|
66
90
|
reject: true,
|
|
67
91
|
});
|
|
68
92
|
activeShellCommandSubprocess = subprocess;
|
|
93
|
+
const emitOutputLine = (line) => {
|
|
94
|
+
capturedOutputLines.push(line.text);
|
|
95
|
+
options.onOutputLine(line);
|
|
96
|
+
options.logWriter(line.text);
|
|
97
|
+
};
|
|
98
|
+
const stdoutEmitter = createBufferedLineEmitter((line) => {
|
|
99
|
+
emitOutputLine({ text: line, source: "stdout" });
|
|
100
|
+
});
|
|
101
|
+
const stderrEmitter = createBufferedLineEmitter((line) => {
|
|
102
|
+
emitOutputLine({ text: line, source: "stderr" });
|
|
103
|
+
});
|
|
69
104
|
subprocess.stdout?.on("data", (chunk) => {
|
|
70
|
-
|
|
71
|
-
for (const line of lines) {
|
|
72
|
-
options.onOutputLine({ text: line, source: "stdout" });
|
|
73
|
-
options.logWriter(line);
|
|
74
|
-
}
|
|
105
|
+
stdoutEmitter.appendChunk(chunk);
|
|
75
106
|
});
|
|
76
107
|
subprocess.stderr?.on("data", (chunk) => {
|
|
77
|
-
|
|
78
|
-
for (const line of lines) {
|
|
79
|
-
options.onOutputLine({ text: line, source: "stderr" });
|
|
80
|
-
options.logWriter(line);
|
|
81
|
-
}
|
|
108
|
+
stderrEmitter.appendChunk(chunk);
|
|
82
109
|
});
|
|
83
110
|
try {
|
|
84
111
|
await subprocess;
|
|
112
|
+
stdoutEmitter.flushPendingLine();
|
|
113
|
+
stderrEmitter.flushPendingLine();
|
|
114
|
+
return { capturedOutput: capturedOutputLines.join("\n") };
|
|
85
115
|
}
|
|
86
116
|
catch (error) {
|
|
117
|
+
stdoutEmitter.flushPendingLine();
|
|
118
|
+
stderrEmitter.flushPendingLine();
|
|
87
119
|
const commandWasCanceledByUser = userCanceledSubprocesses.has(subprocess);
|
|
88
120
|
const failureSummaryLines = buildFailureSummaryLines(options.shellCommand, error);
|
|
89
121
|
if (commandWasCanceledByUser) {
|
|
@@ -103,6 +135,13 @@ export async function runShellCommand(options) {
|
|
|
103
135
|
}
|
|
104
136
|
}
|
|
105
137
|
}
|
|
138
|
+
export async function runShellCommand(options) {
|
|
139
|
+
await executeShellCommand(options);
|
|
140
|
+
}
|
|
141
|
+
export async function runShellCommandAndCaptureOutput(options) {
|
|
142
|
+
const result = await executeShellCommand(options);
|
|
143
|
+
return result.capturedOutput;
|
|
144
|
+
}
|
|
106
145
|
export async function doesShellCommandSucceed(options) {
|
|
107
146
|
const result = await execa("bash", ["-c", options.shellCommand], {
|
|
108
147
|
reject: false,
|
package/dist/steps/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { StepCategoryId, StepCategoryDefinition, } from "./categories.js";
|
|
|
3
3
|
export { listStepCategoryDefinitions, getStepCategoryLabel, } from "./categories.js";
|
|
4
4
|
export type { CategorySection, } from "./grouping.js";
|
|
5
5
|
export { buildCategorySectionsInOrder, } from "./grouping.js";
|
|
6
|
-
export { checkCommandExists, checkPathExists, runStep, createDefaultStepRunContext, } from "./runtime.js";
|
|
6
|
+
export { checkCommandExists, checkPathExists, runStep, runStepAndCaptureOutput, createDefaultStepRunContext, } from "./runtime.js";
|
|
7
7
|
export { default as homebrewStep } from "./homebrew.js";
|
|
8
8
|
export { default as masStep } from "./mas.js";
|
|
9
9
|
export { default as ohmyzshStep } from "./ohmyzsh.js";
|
package/dist/steps/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { listStepCategoryDefinitions, getStepCategoryLabel, } from "./categories.js";
|
|
2
2
|
export { buildCategorySectionsInOrder, } from "./grouping.js";
|
|
3
|
-
export { checkCommandExists, checkPathExists, runStep, createDefaultStepRunContext, } from "./runtime.js";
|
|
3
|
+
export { checkCommandExists, checkPathExists, runStep, runStepAndCaptureOutput, createDefaultStepRunContext, } from "./runtime.js";
|
|
4
4
|
export { default as homebrewStep } from "./homebrew.js";
|
|
5
5
|
export { default as masStep } from "./mas.js";
|
|
6
6
|
export { default as ohmyzshStep } from "./ohmyzsh.js";
|
package/dist/steps/macos.js
CHANGED
|
@@ -7,10 +7,11 @@ const macosStep = {
|
|
|
7
7
|
return true;
|
|
8
8
|
},
|
|
9
9
|
async run(context) {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
context.onOutputLine({
|
|
11
|
+
text: "Checking for macOS updates...",
|
|
12
|
+
source: "stdout",
|
|
12
13
|
});
|
|
13
|
-
context.
|
|
14
|
+
const updateListOutput = await context.runStepAndCaptureOutput("softwareupdate -l 2>&1");
|
|
14
15
|
const noUpdatesAvailable = updateListOutput.includes("No new software available");
|
|
15
16
|
if (noUpdatesAvailable) {
|
|
16
17
|
context.onOutputLine({
|
|
@@ -19,7 +20,6 @@ const macosStep = {
|
|
|
19
20
|
});
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
22
|
-
context.onOutputLine({ text: updateListOutput, source: "stdout" });
|
|
23
23
|
context.onOutputLine({
|
|
24
24
|
text: "Updates found — installing now...",
|
|
25
25
|
source: "stdout",
|
package/dist/steps/runtime.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ import type { StepRunContext } from "./types.js";
|
|
|
4
4
|
export declare function checkCommandExists(command: string): Promise<boolean>;
|
|
5
5
|
export declare function checkPathExists(filePath: string): Promise<boolean>;
|
|
6
6
|
export declare function runStep(shellCommand: string, context: StepRunContext): Promise<void>;
|
|
7
|
+
export declare function runStepAndCaptureOutput(shellCommand: string, context: StepRunContext): Promise<string>;
|
|
7
8
|
export declare function createDefaultStepRunContext(onOutputLine: OutputLineCallback, logWriter: StepLogWriter): StepRunContext;
|
package/dist/steps/runtime.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { doesShellCommandSucceed, runShellCommand, captureShellCommandOutput, } from "../runner.js";
|
|
1
|
+
import { doesShellCommandSucceed, runShellCommand, captureShellCommandOutput, runShellCommandAndCaptureOutput, } from "../runner.js";
|
|
2
2
|
export async function checkCommandExists(command) {
|
|
3
3
|
return doesShellCommandSucceed({ shellCommand: `command -v ${command}` });
|
|
4
4
|
}
|
|
@@ -12,11 +12,19 @@ export async function runStep(shellCommand, context) {
|
|
|
12
12
|
logWriter: context.logWriter,
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
+
export async function runStepAndCaptureOutput(shellCommand, context) {
|
|
16
|
+
return runShellCommandAndCaptureOutput({
|
|
17
|
+
shellCommand,
|
|
18
|
+
onOutputLine: context.onOutputLine,
|
|
19
|
+
logWriter: context.logWriter,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
15
22
|
export function createDefaultStepRunContext(onOutputLine, logWriter) {
|
|
16
23
|
const context = {
|
|
17
24
|
onOutputLine,
|
|
18
25
|
logWriter,
|
|
19
26
|
runStep: (shellCommand) => runStep(shellCommand, context),
|
|
27
|
+
runStepAndCaptureOutput: (shellCommand) => runStepAndCaptureOutput(shellCommand, context),
|
|
20
28
|
captureOutput: captureShellCommandOutput,
|
|
21
29
|
};
|
|
22
30
|
return context;
|
package/dist/steps/types.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type StepRunContext = {
|
|
|
5
5
|
onOutputLine: OutputLineCallback;
|
|
6
6
|
logWriter: StepLogWriter;
|
|
7
7
|
runStep: (shellCommand: string) => Promise<void>;
|
|
8
|
+
runStepAndCaptureOutput: (shellCommand: string) => Promise<string>;
|
|
8
9
|
captureOutput: (options: {
|
|
9
10
|
shellCommand: string;
|
|
10
11
|
}) => Promise<string>;
|
package/dist/ui/header.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DisplayStep, StepPhase, CompletedStepRecord, LogoVisibility } from "./state.js";
|
|
2
|
-
import type { TerminalDimensions } from "./
|
|
2
|
+
import type { TerminalDimensions } from "./outputLines.js";
|
|
3
3
|
type LogoLayout = "side-by-side" | "stacked" | "none";
|
|
4
4
|
export declare function determineLogoLayout(logoLines: string[], dimensions?: TerminalDimensions): LogoLayout;
|
|
5
5
|
export declare function stepTrackerIcon(phase: StepPhase, activityFrameIndex?: number): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
const INDENT = " ";
|
|
3
|
+
const HEADER_LINES_APPROXIMATE = 18;
|
|
4
|
+
const MINIMUM_VISIBLE_LINES = 5;
|
|
5
|
+
function maxVisibleLines(rows) {
|
|
6
|
+
const available = rows - HEADER_LINES_APPROXIMATE;
|
|
7
|
+
return Math.max(MINIMUM_VISIBLE_LINES, available);
|
|
8
|
+
}
|
|
9
|
+
function maxLineWidth(columns) {
|
|
10
|
+
return Math.max(0, Math.min(columns, 120) - INDENT.length);
|
|
11
|
+
}
|
|
12
|
+
function resolveTerminalDimensions(dimensions) {
|
|
13
|
+
return dimensions ?? {
|
|
14
|
+
columns: process.stdout.columns ?? 80,
|
|
15
|
+
rows: process.stdout.rows ?? 40,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function expandRenderedLines(lines) {
|
|
19
|
+
return lines.flatMap((line) => line.text.split(/\r?\n|\r/).map((text) => ({
|
|
20
|
+
text,
|
|
21
|
+
source: line.source,
|
|
22
|
+
})));
|
|
23
|
+
}
|
|
24
|
+
export function buildStepOutputLines(lines, dimensions) {
|
|
25
|
+
const resolved = resolveTerminalDimensions(dimensions);
|
|
26
|
+
const visibleLines = expandRenderedLines(lines).slice(-maxVisibleLines(resolved.rows));
|
|
27
|
+
const width = maxLineWidth(resolved.columns);
|
|
28
|
+
return visibleLines.map((line) => {
|
|
29
|
+
const truncated = line.text.slice(0, width);
|
|
30
|
+
const colored = line.source === "stderr" ? chalk.yellow(truncated) : chalk.dim(truncated);
|
|
31
|
+
return `${INDENT}${colored}`;
|
|
32
|
+
});
|
|
33
|
+
}
|
package/dist/ui/screen.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TerminalDimensions } from "./
|
|
1
|
+
import { type TerminalDimensions } from "./outputLines.js";
|
|
2
2
|
import type { AppState } from "./state.js";
|
|
3
3
|
export type ScreenRenderer = (content: string) => void;
|
|
4
4
|
export declare function createScreenRenderer(output?: NodeJS.WritableStream): ScreenRenderer;
|
package/dist/ui/screen.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildHeaderLines } from "./header.js";
|
|
2
2
|
import { buildActiveStepLines } from "./currentStep.js";
|
|
3
|
-
import {
|
|
3
|
+
import { buildStepOutputLines } from "./outputLines.js";
|
|
4
4
|
import { buildPromptLines } from "./prompt.js";
|
|
5
5
|
import { buildFailedStepLogHintLines, buildVersionReportLines } from "./versionReport.js";
|
|
6
6
|
export function createScreenRenderer(output = process.stdout) {
|
|
@@ -60,7 +60,7 @@ export function buildScreenWithAnimationFrame(state, activityFrameIndex, termina
|
|
|
60
60
|
state.currentOutputLines.length > 0;
|
|
61
61
|
if (isShowingOutput) {
|
|
62
62
|
lines.push("");
|
|
63
|
-
lines.push(...
|
|
63
|
+
lines.push(...buildStepOutputLines(state.currentOutputLines, terminalDimensions));
|
|
64
64
|
}
|
|
65
65
|
if (state.currentPrompt) {
|
|
66
66
|
lines.push("");
|
package/package.json
CHANGED
package/dist/ui/outputBox.d.ts
DELETED
package/dist/ui/outputBox.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
const INDENT = " ";
|
|
3
|
-
const HEADER_LINES_APPROXIMATE = 18;
|
|
4
|
-
const OUTPUT_BOX_CHROME_LINES = 3;
|
|
5
|
-
const MINIMUM_VISIBLE_LINES = 5;
|
|
6
|
-
function maxVisibleLines(rows) {
|
|
7
|
-
const available = rows - HEADER_LINES_APPROXIMATE - OUTPUT_BOX_CHROME_LINES;
|
|
8
|
-
return Math.max(MINIMUM_VISIBLE_LINES, available);
|
|
9
|
-
}
|
|
10
|
-
function boxWidth(columns) {
|
|
11
|
-
return Math.min(columns, 120) - INDENT.length * 2;
|
|
12
|
-
}
|
|
13
|
-
function resolveTerminalDimensions(dimensions) {
|
|
14
|
-
return dimensions ?? {
|
|
15
|
-
columns: process.stdout.columns ?? 80,
|
|
16
|
-
rows: process.stdout.rows ?? 40,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export function buildOutputBoxLines(lines, stepName, dimensions) {
|
|
20
|
-
const resolved = resolveTerminalDimensions(dimensions);
|
|
21
|
-
const visibleLines = lines.slice(-maxVisibleLines(resolved.rows));
|
|
22
|
-
const width = boxWidth(resolved.columns);
|
|
23
|
-
const headerLabel = `─ ${stepName} output `;
|
|
24
|
-
const topDashes = "─".repeat(Math.max(0, width - headerLabel.length - 2));
|
|
25
|
-
const topBorder = chalk.dim(`${INDENT}┌${headerLabel}${topDashes}┐`);
|
|
26
|
-
const bottomBorder = chalk.dim(`${INDENT}└${"─".repeat(width - 2)}┘`);
|
|
27
|
-
const result = [topBorder];
|
|
28
|
-
for (const line of visibleLines) {
|
|
29
|
-
const truncated = line.text.slice(0, width - 4);
|
|
30
|
-
const colored = line.source === "stderr" ? chalk.yellow(truncated) : chalk.dim(truncated);
|
|
31
|
-
result.push(`${INDENT}${chalk.dim("│")} ${colored}`);
|
|
32
|
-
}
|
|
33
|
-
result.push(bottomBorder);
|
|
34
|
-
return result;
|
|
35
|
-
}
|