easc 0.0.29 → 0.0.31

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.
@@ -1,25 +1,31 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
1
+ import { describe, it, expect, vi, beforeEach } from "vite-plus/test";
2
2
  import fs from "fs";
3
3
  import path from "path";
4
- import {
5
- readAppJson,
6
- readMetadata,
7
- findBundleFile,
8
- getAssetFiles,
9
- checkDistDirectory,
10
- } from "./files";
4
+ import { Platform } from "../enums/platform";
5
+ import { readAppJson, readMetadata, findBundleFile } from "./files";
6
+
7
+ const { requireImpl } = vi.hoisted(() => ({
8
+ requireImpl: vi.fn().mockImplementation(() => ({
9
+ expo: { name: "FromConfigJs", version: "1.0.0" },
10
+ })),
11
+ }));
11
12
 
12
13
  vi.mock("fs");
13
14
  vi.mock("path");
15
+ vi.mock("module", () => ({ createRequire: () => requireImpl }));
14
16
 
15
17
  describe("File utilities", () => {
16
18
  beforeEach(() => {
17
19
  vi.clearAllMocks();
18
20
  vi.mocked(path.join).mockImplementation((...args) => args.join("/"));
21
+ vi.mocked(path.resolve).mockImplementation((...args) => args[0] ?? "");
22
+ requireImpl.mockImplementation(() => ({
23
+ expo: { name: "FromConfigJs", version: "1.0.0" },
24
+ }));
19
25
  });
20
26
 
21
27
  describe("readAppJson", () => {
22
- it("should read and parse app.json", () => {
28
+ it("should read app.json when only app.json exists", () => {
23
29
  const mockAppJson = {
24
30
  expo: {
25
31
  name: "TestApp",
@@ -27,27 +33,101 @@ describe("File utilities", () => {
27
33
  },
28
34
  };
29
35
 
30
- vi.mocked(fs.existsSync).mockReturnValue(true);
36
+ vi.mocked(fs.existsSync).mockImplementation(
37
+ (p: fs.PathLike) => typeof p === "string" && p.endsWith("app.json"),
38
+ );
31
39
  vi.mocked(fs.readFileSync).mockReturnValue(JSON.stringify(mockAppJson));
32
40
 
33
41
  const result = readAppJson("/test/dir");
34
42
 
35
- expect(fs.existsSync).toHaveBeenCalledWith("/test/dir/app.json");
36
43
  expect(fs.readFileSync).toHaveBeenCalledWith("/test/dir/app.json", "utf-8");
37
44
  expect(result).toEqual(mockAppJson);
38
45
  });
39
46
 
40
- it("should throw if app.json doesn't exist", () => {
47
+ it("should use app.config.js when it exists and not read app.json", () => {
48
+ vi.mocked(fs.existsSync).mockImplementation(
49
+ (p: fs.PathLike) => typeof p === "string" && p.endsWith("app.config.js"),
50
+ );
51
+
52
+ const result = readAppJson("/test/dir");
53
+
54
+ expect(result.expo.name).toBe("FromConfigJs");
55
+ expect(result.expo.version).toBe("1.0.0");
56
+ expect(fs.readFileSync).not.toHaveBeenCalled();
57
+ });
58
+
59
+ it("should use app.config.ts when it exists and .js does not", () => {
60
+ requireImpl.mockReturnValueOnce({
61
+ expo: { name: "FromConfigTs", version: "1.0.0" },
62
+ });
63
+ vi.mocked(fs.existsSync).mockImplementation(
64
+ (p: fs.PathLike) => typeof p === "string" && p.endsWith("app.config.ts"),
65
+ );
66
+
67
+ const result = readAppJson("/test/dir");
68
+
69
+ expect(result.expo.name).toBe("FromConfigTs");
70
+ expect(fs.readFileSync).not.toHaveBeenCalled();
71
+ });
72
+
73
+ it("should use app.config.ts over app.config.js when both exist", () => {
74
+ requireImpl.mockReturnValueOnce({
75
+ expo: { name: "FromConfigTs", version: "1.0.0" },
76
+ });
77
+ vi.mocked(fs.existsSync).mockImplementation(
78
+ (p: fs.PathLike) =>
79
+ typeof p === "string" && (p.endsWith("app.config.js") || p.endsWith("app.config.ts")),
80
+ );
81
+
82
+ const result = readAppJson("/test/dir");
83
+
84
+ expect(result.expo.name).toBe("FromConfigTs");
85
+ expect(requireImpl).toHaveBeenCalledWith("/test/dir/app.config.ts");
86
+ });
87
+
88
+ it("should throw if no app config found", () => {
41
89
  vi.mocked(fs.existsSync).mockReturnValue(false);
42
90
 
43
- expect(() => readAppJson("/test/dir")).toThrow("app.json not found");
91
+ expect(() => readAppJson("/test/dir")).toThrow("No app config found");
44
92
  });
45
93
 
46
- it("should throw if app.json is invalid JSON", () => {
47
- vi.mocked(fs.existsSync).mockReturnValue(true);
94
+ it("should throw with cause when app.config.js fails to load", () => {
95
+ requireImpl.mockImplementationOnce(() => {
96
+ throw new Error("SyntaxError");
97
+ });
98
+ vi.mocked(fs.existsSync).mockImplementation(
99
+ (p: fs.PathLike) => typeof p === "string" && p.endsWith("app.config.js"),
100
+ );
101
+
102
+ try {
103
+ readAppJson("/test/dir");
104
+ expect.fail("should have thrown");
105
+ } catch (error) {
106
+ expect(error).toBeInstanceOf(Error);
107
+ if (!(error instanceof Error)) throw error;
108
+ expect(error.message).toMatch(/Failed to load app.config.js/);
109
+ expect(error.cause).toBeDefined();
110
+ expect(error.cause).toBeInstanceOf(Error);
111
+ if (!(error.cause instanceof Error)) throw error;
112
+ expect(error.cause.message).toBe("SyntaxError");
113
+ }
114
+ });
115
+
116
+ it("should throw with cause when app.json is invalid JSON", () => {
117
+ vi.mocked(fs.existsSync).mockImplementation(
118
+ (p: fs.PathLike) => typeof p === "string" && p.endsWith("app.json"),
119
+ );
48
120
  vi.mocked(fs.readFileSync).mockReturnValue("invalid json");
49
121
 
50
- expect(() => readAppJson("/test/dir")).toThrow("Failed to parse app.json");
122
+ try {
123
+ readAppJson("/test/dir");
124
+ expect.fail("should have thrown");
125
+ } catch (error) {
126
+ expect(error).toBeInstanceOf(Error);
127
+ if (!(error instanceof Error)) throw error;
128
+ expect(error.message).toMatch(/Failed to load app.json/);
129
+ expect(error.cause).toBeDefined();
130
+ }
51
131
  });
52
132
  });
53
133
 
@@ -72,59 +152,107 @@ describe("File utilities", () => {
72
152
  vi.mocked(fs.existsSync).mockReturnValue(false);
73
153
 
74
154
  expect(() => readMetadata("/test/dist")).toThrow(
75
- "metadata.json not found in /test/dist. Did you run 'expo export'?"
155
+ "metadata.json not found in /test/dist. Did you run 'expo export'?",
76
156
  );
77
157
  });
158
+
159
+ it("should throw with cause when metadata.json is invalid JSON", () => {
160
+ vi.mocked(fs.existsSync).mockReturnValue(true);
161
+ vi.mocked(fs.readFileSync).mockReturnValue("invalid");
162
+
163
+ try {
164
+ readMetadata("/test/dist");
165
+ expect.fail("should have thrown");
166
+ } catch (error) {
167
+ expect(error).toBeInstanceOf(Error);
168
+ if (!(error instanceof Error)) throw error;
169
+ expect(error.message).toMatch(/Failed to parse metadata.json/);
170
+ expect(error.cause).toBeDefined();
171
+ }
172
+ });
78
173
  });
79
174
 
80
175
  describe("findBundleFile", () => {
81
- it("should find bundle file for platform", () => {
176
+ it("should return correct path from metadata bundle field", () => {
82
177
  vi.mocked(fs.existsSync).mockReturnValue(true);
83
- vi.mocked(fs.readdirSync).mockReturnValue([
84
- "entry-abc123.hbc",
85
- "other-file.js",
86
- ] as any);
87
178
 
88
- const result = findBundleFile("/dist", "ios");
179
+ const metadata = {
180
+ version: 0,
181
+ bundler: "metro",
182
+ fileMetadata: {
183
+ [Platform.iOS]: {
184
+ bundle: "_expo/static/js/ios/entry-abc123.hbc",
185
+ assets: [],
186
+ },
187
+ },
188
+ };
189
+
190
+ const result = findBundleFile("/dist", metadata, Platform.iOS);
89
191
 
90
192
  expect(result).toBe("/dist/_expo/static/js/ios/entry-abc123.hbc");
91
193
  });
92
194
 
93
- it("should throw if bundle directory doesn't exist", () => {
94
- vi.mocked(fs.existsSync).mockReturnValue(false);
195
+ it("should work for android platform", () => {
196
+ vi.mocked(fs.existsSync).mockReturnValue(true);
95
197
 
96
- expect(() => findBundleFile("/dist", "android")).toThrow(
97
- "Bundle directory not found"
98
- );
198
+ const metadata = {
199
+ version: 0,
200
+ bundler: "metro",
201
+ fileMetadata: {
202
+ [Platform.Android]: {
203
+ bundle: "_expo/static/js/android/index-xyz789.js",
204
+ assets: [],
205
+ },
206
+ },
207
+ };
208
+
209
+ const result = findBundleFile("/dist", metadata, Platform.Android);
210
+
211
+ expect(result).toBe("/dist/_expo/static/js/android/index-xyz789.js");
99
212
  });
100
213
 
101
- it("should throw if no bundle files found", () => {
102
- vi.mocked(fs.existsSync).mockReturnValue(true);
103
- vi.mocked(fs.readdirSync).mockReturnValue([]);
214
+ it("should throw if platform not in metadata", () => {
215
+ const metadata = {
216
+ version: 0,
217
+ bundler: "metro",
218
+ fileMetadata: {
219
+ [Platform.iOS]: {
220
+ bundle: "_expo/static/js/ios/entry-abc123.hbc",
221
+ assets: [],
222
+ },
223
+ },
224
+ };
104
225
 
105
- expect(() => findBundleFile("/dist", "ios")).toThrow(
106
- "No bundle found for ios"
226
+ expect(() => findBundleFile("/dist", metadata, Platform.Android)).toThrow(
227
+ "No bundle path found for android in metadata.json",
107
228
  );
108
229
  });
109
- });
110
-
111
- describe("checkDistDirectory", () => {
112
- it("should return dist dir when valid", () => {
113
- vi.mocked(fs.existsSync).mockReturnValue(true);
114
230
 
115
- const result = checkDistDirectory("/test");
231
+ it("should throw if fileMetadata is missing", () => {
232
+ const metadata = { version: 0, bundler: "metro" };
116
233
 
117
- expect(result).toBe("/test/dist");
234
+ expect(() => findBundleFile("/dist", metadata, Platform.iOS)).toThrow(
235
+ "No bundle path found for ios in metadata.json",
236
+ );
118
237
  });
119
238
 
120
- it("should throw if dist directory doesn't exist", () => {
121
- vi.mocked(fs.existsSync).mockImplementation((path) => {
122
- return path !== "/test/dist";
123
- });
239
+ it("should throw if bundle file doesn't exist on disk", () => {
240
+ vi.mocked(fs.existsSync).mockReturnValue(false);
241
+
242
+ const metadata = {
243
+ version: 0,
244
+ bundler: "metro",
245
+ fileMetadata: {
246
+ [Platform.iOS]: {
247
+ bundle: "_expo/static/js/ios/entry-abc123.hbc",
248
+ assets: [],
249
+ },
250
+ },
251
+ };
124
252
 
125
- expect(() => checkDistDirectory("/test")).toThrow(
126
- "Export directory not found"
253
+ expect(() => findBundleFile("/dist", metadata, Platform.iOS)).toThrow(
254
+ "Bundle file not found",
127
255
  );
128
256
  });
129
257
  });
130
- });
258
+ });
@@ -1,35 +1,48 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
+ import { createRequire } from "module";
3
4
  import { IAppJson } from "./runtime";
4
5
  import { Platform, PlatformType } from "../enums/platform";
5
6
 
7
+ const require = createRequire(import.meta.url);
8
+
9
+ interface IPlatformMetadata {
10
+ bundle: string;
11
+ assets: Array<{ path: string; ext: string }>;
12
+ }
13
+
14
+ const APP_CONFIGS = [
15
+ { filename: "app.config.ts", loader: _loadJsConfig },
16
+ { filename: "app.config.js", loader: _loadJsConfig },
17
+ { filename: "app.json", loader: _loadJsonConfig },
18
+ ] as const;
19
+
6
20
  export interface IMetadata {
21
+ version: number;
22
+ bundler: string;
7
23
  fileMetadata?: {
8
- [Platform.iOS]?: {
9
- assets: Array<{ path: string }>;
10
- };
11
- [Platform.Android]?: {
12
- assets: Array<{ path: string }>;
13
- };
24
+ [Platform.iOS]?: IPlatformMetadata;
25
+ [Platform.Android]?: IPlatformMetadata;
14
26
  };
15
27
  }
16
28
 
17
29
  /**
18
- * Read and parse app.json file
30
+ * Read app config from the app directory.
31
+ * Tries in order: app.config.js, app.config.ts, app.json.
32
+ * Returns the first found; throws if none exist.
19
33
  */
20
34
  export function readAppJson(appDir: string = process.cwd()): IAppJson {
21
- const appJsonPath = path.join(appDir, "app.json");
35
+ const resolvedDir = path.resolve(appDir);
22
36
 
23
- if (!fs.existsSync(appJsonPath)) {
24
- throw new Error(`app.json not found in ${appDir}`);
37
+ for (const { filename, loader } of APP_CONFIGS) {
38
+ const filePath = path.join(resolvedDir, filename);
39
+ if (fs.existsSync(filePath)) {
40
+ return _parseAppConfig(filePath, filename, loader);
41
+ }
25
42
  }
26
43
 
27
- try {
28
- const content = fs.readFileSync(appJsonPath, "utf-8");
29
- return JSON.parse(content);
30
- } catch (error) {
31
- throw new Error(`Failed to parse app.json: ${error}`);
32
- }
44
+ const names = APP_CONFIGS.map((config) => config.filename).join(", ");
45
+ throw new Error(`No app config found in ${appDir}. Create ${names}`);
33
46
  }
34
47
 
35
48
  /**
@@ -39,46 +52,41 @@ export function readMetadata(exportDir: string): IMetadata {
39
52
  const metadataPath = path.join(exportDir, "metadata.json");
40
53
 
41
54
  if (!fs.existsSync(metadataPath)) {
42
- throw new Error(
43
- `metadata.json not found in ${exportDir}. Did you run 'expo export'?`
44
- );
55
+ throw new Error(`metadata.json not found in ${exportDir}. Did you run 'expo export'?`);
45
56
  }
46
57
 
47
58
  try {
48
59
  const content = fs.readFileSync(metadataPath, "utf-8");
49
60
  return JSON.parse(content);
50
61
  } catch (error) {
51
- throw new Error(`Failed to parse metadata.json: ${error}`);
62
+ const msg = error instanceof Error ? error.message : String(error);
63
+ throw new Error(`Failed to parse metadata.json: ${msg}`, { cause: error });
52
64
  }
53
65
  }
54
66
 
55
67
  /**
56
- * Find the bundle file for a platform
68
+ * Find the bundle file for a platform using metadata.json
57
69
  */
58
70
  export function findBundleFile(
59
71
  exportDir: string,
60
- platform: PlatformType
72
+ metadata: IMetadata,
73
+ platform: PlatformType,
61
74
  ): string {
62
- const bundlePath = path.join(exportDir, `_expo/static/js/${platform}`);
75
+ const platformMetadata = metadata.fileMetadata?.[platform];
63
76
 
64
- if (!fs.existsSync(bundlePath)) {
65
- throw new Error(`Bundle directory not found: ${bundlePath}`);
77
+ if (!platformMetadata?.bundle) {
78
+ throw new Error(
79
+ `No bundle path found for ${platform} in metadata.json. Run 'npx expo export' first.`,
80
+ );
66
81
  }
67
82
 
68
- const bundleFiles = fs
69
- .readdirSync(bundlePath)
70
- .filter((f) => f.startsWith("entry-") && f.endsWith(".hbc"));
83
+ const bundlePath = path.join(exportDir, platformMetadata.bundle);
71
84
 
72
- if (bundleFiles.length === 0) {
73
- throw new Error(`No bundle found for ${platform}`);
74
- }
75
-
76
- const [firstBundle] = bundleFiles;
77
- if (!firstBundle) {
78
- throw new Error(`No bundle found for ${platform}`);
85
+ if (!fs.existsSync(bundlePath)) {
86
+ throw new Error(`Bundle file not found: ${bundlePath}. Run 'npx expo export' first.`);
79
87
  }
80
88
 
81
- return path.join(bundlePath, firstBundle);
89
+ return bundlePath;
82
90
  }
83
91
 
84
92
  /**
@@ -87,7 +95,7 @@ export function findBundleFile(
87
95
  export function getAssetFiles(
88
96
  exportDir: string,
89
97
  metadata: IMetadata,
90
- platform: PlatformType
98
+ platform: PlatformType,
91
99
  ): string[] {
92
100
  const assetsPath = path.join(exportDir, "assets");
93
101
 
@@ -105,9 +113,7 @@ export function getAssetFiles(
105
113
  return [];
106
114
  }
107
115
 
108
- const platformAssetFiles = new Set(
109
- platformAssets.map((asset) => path.basename(asset.path))
110
- );
116
+ const platformAssetFiles = new Set(platformAssets.map((asset) => path.basename(asset.path)));
111
117
 
112
118
  const assetFiles = fs.readdirSync(assetsPath);
113
119
  const validAssets: string[] = [];
@@ -126,19 +132,14 @@ export function getAssetFiles(
126
132
  * Check if the export directory exists and has been built
127
133
  * Supports custom export directories (EAS-compatible)
128
134
  */
129
- export function checkExportDirectory(
130
- exportDir: string,
131
- appDir: string = process.cwd()
132
- ): string {
135
+ export function checkExportDirectory(exportDir: string, appDir: string = process.cwd()): string {
133
136
  // If exportDir is relative, resolve it from appDir
134
- const resolvedExportDir = path.isAbsolute(exportDir)
135
- ? exportDir
136
- : path.join(appDir, exportDir);
137
+ const resolvedExportDir = path.isAbsolute(exportDir) ? exportDir : path.join(appDir, exportDir);
137
138
 
138
139
  if (!fs.existsSync(resolvedExportDir)) {
139
140
  throw new Error(
140
141
  `Export directory not found: ${resolvedExportDir}\n` +
141
- `Run 'npx expo export' or use --export-dir to specify a different directory.`
142
+ `Run 'npx expo export' or use --export-dir to specify a different directory.`,
142
143
  );
143
144
  }
144
145
 
@@ -152,7 +153,7 @@ export function checkExportDirectory(
152
153
  if (!fs.existsSync(expectedPath)) {
153
154
  throw new Error(
154
155
  `Invalid export directory structure in: ${resolvedExportDir}\n` +
155
- `Run 'npx expo export' to generate a valid export.`
156
+ `Run 'npx expo export' to generate a valid export.`,
156
157
  );
157
158
  }
158
159
  }
@@ -161,9 +162,51 @@ export function checkExportDirectory(
161
162
  }
162
163
 
163
164
  /**
164
- * Legacy wrapper for backwards compatibility
165
- * @deprecated Use checkExportDirectory instead
165
+ * Type guard that checks whether a value conforms to the IAppJson shape
166
+ */
167
+ function _isAppJson(value: unknown): value is IAppJson {
168
+ if (typeof value !== "object" || value === null || !("expo" in value)) {
169
+ return false;
170
+ }
171
+ const record = value as Record<string, unknown>;
172
+ return typeof record["expo"] === "object" && record["expo"] !== null;
173
+ }
174
+
175
+ /**
176
+ * Load a JS/TS config file via require, resolving default exports
177
+ */
178
+ function _loadJsConfig(filePath: string): unknown {
179
+ const config = require(filePath);
180
+ return config?.default ?? config;
181
+ }
182
+
183
+ /**
184
+ * Load and parse a JSON config file from disk
166
185
  */
167
- export function checkDistDirectory(appDir: string = process.cwd()): string {
168
- return checkExportDirectory("dist", appDir);
186
+ function _loadJsonConfig(filePath: string): unknown {
187
+ const content = fs.readFileSync(filePath, "utf-8");
188
+ return JSON.parse(content);
189
+ }
190
+
191
+ /**
192
+ * Load a config file using the given loader and validate it as IAppJson
193
+ */
194
+ function _parseAppConfig(
195
+ filePath: string,
196
+ label: string,
197
+ loader: (filePath: string) => unknown,
198
+ ): IAppJson {
199
+ try {
200
+ const result = loader(filePath);
201
+ if (!_isAppJson(result)) {
202
+ throw new Error(`${label} must contain an object with an "expo" key`);
203
+ }
204
+ return result;
205
+ } catch (error) {
206
+ if (error instanceof Error && error.message.endsWith('"expo" key')) {
207
+ throw error;
208
+ }
209
+ const msg = error instanceof Error ? error.message : String(error);
210
+ throw new Error(`Failed to load ${label}: ${msg}`, { cause: error });
211
+ }
169
212
  }
@@ -1,4 +1,4 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
1
+ import { describe, it, expect, vi, beforeEach } from "vite-plus/test";
2
2
  import { execSync } from "child_process";
3
3
  import { getCommitHash, getShortCommitHash, isGitClean, getCurrentBranch } from "./git";
4
4
 
@@ -109,4 +109,4 @@ describe("Git utilities", () => {
109
109
  expect(getCurrentBranch()).toBeUndefined();
110
110
  });
111
111
  });
112
- });
112
+ });
package/src/utils/git.ts CHANGED
@@ -25,9 +25,7 @@ export function getCommitHash(cwd: string = process.cwd()): string | undefined {
25
25
  * @param cwd - Working directory (defaults to process.cwd())
26
26
  * @returns The short commit hash or undefined if not in a git repo
27
27
  */
28
- export function getShortCommitHash(
29
- cwd: string = process.cwd()
30
- ): string | undefined {
28
+ export function getShortCommitHash(cwd: string = process.cwd()): string | undefined {
31
29
  const hash = getCommitHash(cwd);
32
30
  return hash ? hash.substring(0, 7) : undefined;
33
31
  }
@@ -57,9 +55,7 @@ export function isGitClean(cwd: string = process.cwd()): boolean {
57
55
  * @param cwd - Working directory (defaults to process.cwd())
58
56
  * @returns The branch name or undefined if not in a git repo
59
57
  */
60
- export function getCurrentBranch(
61
- cwd: string = process.cwd()
62
- ): string | undefined {
58
+ export function getCurrentBranch(cwd: string = process.cwd()): string | undefined {
63
59
  try {
64
60
  const branch = execSync("git rev-parse --abbrev-ref HEAD", {
65
61
  cwd,
@@ -1,8 +1,16 @@
1
1
  import chalk from "chalk";
2
- import ora, { Ora } from "ora";
2
+
3
+ const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
4
+
5
+ interface SpinnerEntry {
6
+ label: string;
7
+ status: "pending" | "done" | "failed";
8
+ }
3
9
 
4
10
  export class Logger {
5
- private spinner: Ora | null = null;
11
+ private lines: SpinnerEntry[] | null = null;
12
+ private timer: ReturnType<typeof setInterval> | null = null;
13
+ private frame = 0;
6
14
 
7
15
  constructor() {}
8
16
 
@@ -35,48 +43,63 @@ export class Logger {
35
43
  }
36
44
 
37
45
  /**
38
- * Start a spinner with a message
46
+ * Start one or more spinner lines
39
47
  */
40
- startSpinner(message: string): void {
41
- this.spinner = ora(message).start();
42
- }
48
+ startSpinner(labels: string | string[]): void {
49
+ const items = Array.isArray(labels) ? labels : [labels];
50
+ this.lines = items.map((label) => ({ label, status: "pending" as const }));
51
+ this.frame = 0;
43
52
 
44
- /**
45
- * Update spinner text
46
- */
47
- updateSpinner(message: string): void {
48
- if (this.spinner) {
49
- this.spinner.text = message;
53
+ for (const entry of this.lines) {
54
+ process.stderr.write(` ${SPINNER_FRAMES[0]} ${entry.label}\n`);
50
55
  }
56
+
57
+ this.timer = setInterval(() => {
58
+ this.frame = (this.frame + 1) % SPINNER_FRAMES.length;
59
+ this.render();
60
+ }, 80);
51
61
  }
52
62
 
53
63
  /**
54
- * Stop spinner with success
64
+ * Mark a spinner line as done or failed
55
65
  */
56
- succeedSpinner(message?: string): void {
57
- if (this.spinner) {
58
- this.spinner.succeed(message);
59
- this.spinner = null;
66
+ updateSpinner(label: string, status: "done" | "failed"): void {
67
+ if (!this.lines) return;
68
+ const entry = this.lines.find((e) => e.label === label);
69
+ if (entry) {
70
+ entry.status = status;
71
+ this.render();
60
72
  }
61
73
  }
62
74
 
63
75
  /**
64
- * Stop spinner with failure
76
+ * Stop all spinner lines
65
77
  */
66
- failSpinner(message?: string): void {
67
- if (this.spinner) {
68
- this.spinner.fail(message);
69
- this.spinner = null;
78
+ stopSpinner(): void {
79
+ if (this.timer) {
80
+ clearInterval(this.timer);
81
+ this.timer = null;
82
+ }
83
+ if (this.lines) {
84
+ this.render();
85
+ this.lines = null;
70
86
  }
71
87
  }
72
88
 
73
- /**
74
- * Stop spinner without status
75
- */
76
- stopSpinner(): void {
77
- if (this.spinner) {
78
- this.spinner.stop();
79
- this.spinner = null;
89
+ private render(): void {
90
+ if (!this.lines) return;
91
+
92
+ process.stderr.write(`\x1B[${this.lines.length}A`);
93
+
94
+ for (const entry of this.lines) {
95
+ process.stderr.write("\x1B[2K\r");
96
+ if (entry.status === "done") {
97
+ process.stderr.write(` ${chalk.green("✓")} ${entry.label}\n`);
98
+ } else if (entry.status === "failed") {
99
+ process.stderr.write(` ${chalk.red("✗")} ${entry.label}\n`);
100
+ } else {
101
+ process.stderr.write(` ${chalk.cyan(SPINNER_FRAMES[this.frame])} ${entry.label}\n`);
102
+ }
80
103
  }
81
104
  }
82
105