History

fmt

Rhys Sullivan committed 6 months ago

Commit c92c57d1 parent 87ab5c7265 files · +5705 −8140Browse files

Showing the changes to apps/cli/src (5 of 265 files). Show all

Unified · Split

5 files
  1. apps/cli/src/build.ts +15 −16
  2. apps/cli/src/daemon-state.ts +22 −14
  3. apps/cli/src/daemon.ts +7 −2
  4. apps/cli/src/main.ts +3 −6
  5. apps/cli/src/tooling.ts +6 −7
apps/cli/src/build.ts+15−16
@@ -68,8 +68,7 @@ const platformName = (t: Target) => (t.os === "win32" ? "windows" : t.os); · 67 unmodified lines
6868 /** Per-platform suffix used in dist directory names, npm dist-tags, and the
6969 * semver prerelease segment of variant package versions. e.g. "linux-x64",
7070 * "linux-x64-musl", "darwin-arm64". */
71−const platformTag = (t: Target) =>
72− [platformName(t), t.arch, t.abi].filter(Boolean).join("-");
71+const platformTag = (t: Target) => [platformName(t), t.arch, t.abi].filter(Boolean).join("-");
7372
7473 /** Dist directory name (e.g. dist/executor-linux-x64). Only used as a build
7574 * artifact convention; the actual npm package name inside is `executor`. */
@@ -126,7 +125,10 @@ const resolveKeyringNative = (t: Target): string | null => { · 50 unmodified lines
126125 const platformMap: Record<string, { pkg: string; node: string }> = {
127126 "darwin-arm64": { pkg: "@napi-rs/keyring-darwin-arm64", node: "keyring.darwin-arm64.node" },
128127 "darwin-x64": { pkg: "@napi-rs/keyring-darwin-x64", node: "keyring.darwin-x64.node" },
129− "linux-arm64": { pkg: "@napi-rs/keyring-linux-arm64-gnu", node: "keyring.linux-arm64-gnu.node" },
128+ "linux-arm64": {
129+ pkg: "@napi-rs/keyring-linux-arm64-gnu",
130+ node: "keyring.linux-arm64-gnu.node",
131+ },
130132 "linux-x64": { pkg: "@napi-rs/keyring-linux-x64-gnu", node: "keyring.linux-x64-gnu.node" },
131133 "linux-arm64-musl": {
132134 pkg: "@napi-rs/keyring-linux-arm64-musl",
@@ -146,9 +148,7 @@ const resolveKeyringNative = (t: Target): string | null => { · 13 unmodified lines
146148 const entry = platformMap[key];
147149 if (!entry) return null;
148150 try {
149− const req = createRequire(
150− join(repoRoot, "node_modules", "@napi-rs/keyring", "package.json"),
151− );
151+ const req = createRequire(join(repoRoot, "node_modules", "@napi-rs/keyring", "package.json"));
152152 const pkgJson = req.resolve(`${entry.pkg}/package.json`);
153153 return join(dirname(pkgJson), entry.node);
154154 } catch {
@@ -455,7 +455,10 @@ const buildPreviewTarballs = async (binaries: Record<string, string>) => { · 300 unmodified lines
455455
456456 const resolveTargetsFromEnv = (env: string | undefined): Target[] => {
457457 if (!env) throw new Error("EXECUTOR_PREVIEW_TARGETS must be set (comma-separated package names)");
458− const names = env.split(",").map((s) => s.trim()).filter(Boolean);
458+ const names = env
459+ .split(",")
460+ .map((s) => s.trim())
461+ .filter(Boolean);
459462 const resolved = names.map((name) => {
460463 const match = ALL_TARGETS.find((t) => targetPackageName(t) === name);
461464 if (!match) throw new Error(`Unknown preview target: ${name}`);
@@ -482,10 +485,7 @@ const buildPreviewWrapperPackage = async (targets: Target[]) => { · 20 unmodified lines
482485 await writeFile(join(binDir, "executor"), NODE_SHIM);
483486 await chmod(join(binDir, "executor"), 0o755);
484487
485− const postinstall = PREVIEW_POSTINSTALL_SCRIPT.replaceAll(
486− "__CDN_BASE_URL__",
487− `${cdnUrl}/${sha}`,
488− );
488+ const postinstall = PREVIEW_POSTINSTALL_SCRIPT.replaceAll("__CDN_BASE_URL__", `${cdnUrl}/${sha}`);
489489 await writeFile(join(wrapperDir, "postinstall.cjs"), postinstall);
490490
491491 // Restrict os/cpu to platforms we actually built this run so npm refuses
@@ -565,11 +565,10 @@ const publishPackedPackage = async (pkgDir: string, channel: string) => { · 73 unmodified lines
565565 await $`bun pm pack`.cwd(pkgDir);
566566
567567 const provenance = process.env.GITHUB_ACTIONS === "true" ? ["--provenance"] : [];
568− const result =
569− await $`npm publish *.tgz --access public --tag ${channel} ${provenance}`
570− .cwd(pkgDir)
571− .nothrow()
572− .quiet();
568+ const result = await $`npm publish *.tgz --access public --tag ${channel} ${provenance}`
569+ .cwd(pkgDir)
570+ .nothrow()
571+ .quiet();
573572
574573 const stdout = result.stdout.toString();
575574 const stderr = result.stderr.toString();
apps/cli/src/daemon-state.ts+22−14
@@ -59,7 +59,8 @@ export const currentDaemonScopeId = (): string => { · 58 unmodified lines
5959 const resolveDaemonDataDir = (path: Path.Path): string =>
6060 process.env.EXECUTOR_DATA_DIR ?? path.join(homedir(), ".executor");
6161
62−const sanitizeHostForPath = (hostname: string): string => hostname.replaceAll(/[^a-z0-9.-]+/gi, "_");
62+const sanitizeHostForPath = (hostname: string): string =>
63+ hostname.replaceAll(/[^a-z0-9.-]+/gi, "_");
6364 const sanitizeScopeForPath = (scopeId: string): string => scopeId.replaceAll(/[^a-z0-9.-]+/gi, "_");
6465
6566 const daemonRecordPath = (path: Path.Path, input: { hostname: string; port: number }): string => {
@@ -67,14 +68,19 @@ const daemonRecordPath = (path: Path.Path, input: { hostname: string; port: numb · 1 unmodified line
6768 return path.join(resolveDaemonDataDir(path), `daemon-${host}-${input.port}.json`);
6869 };
6970
70−const daemonPointerPath = (path: Path.Path, input: { hostname: string; scopeId: string }): string => {
71+const daemonPointerPath = (
72+ path: Path.Path,
73+ input: { hostname: string; scopeId: string },
74+): string => {
7175 const host = sanitizeHostForPath(canonicalDaemonHost(input.hostname));
7276 const scope = sanitizeScopeForPath(input.scopeId);
7377 return path.join(resolveDaemonDataDir(path), `daemon-active-${host}-${scope}.json`);
7478 };
7579
76−const daemonStartLockPath = (path: Path.Path, input: { hostname: string; scopeId: string }): string =>
77− `${daemonPointerPath(path, input)}.lock`;
80+const daemonStartLockPath = (
81+ path: Path.Path,
82+ input: { hostname: string; scopeId: string },
83+): string => `${daemonPointerPath(path, input)}.lock`;
7884
7985 // ---------------------------------------------------------------------------
8086 // Persistence
@@ -195,9 +201,9 @@ export const readDaemonRecord = (input: { · 114 unmodified lines
195201 Effect.gen(function* () {
196202 const fs = yield* FileSystem.FileSystem;
197203 const path = yield* Path.Path;
198− const raw = yield* fs.readFileString(daemonRecordPath(path, input)).pipe(
199− Effect.catchCause(() => Effect.succeed(null)),
200− );
204+ const raw = yield* fs
205+ .readFileString(daemonRecordPath(path, input))
206+ .pipe(Effect.catchCause(() => Effect.succeed(null)));
201207 if (raw === null) return null;
202208 return parseRecord(raw);
203209 });
@@ -322,7 +328,9 @@ export const acquireDaemonStartLock = (input: { · 118 unmodified lines
322328 };
323329 }
324330
325− const existingRaw = yield* fs.readFileString(lockPath).pipe(Effect.catchCause(() => Effect.succeed(null)));
331+ const existingRaw = yield* fs
332+ .readFileString(lockPath)
333+ .pipe(Effect.catchCause(() => Effect.succeed(null)));
326334 if (existingRaw !== null) {
327335 const existingPid = parseLockPid(existingRaw);
328336 if (existingPid !== null && !isPidAlive(existingPid)) {
@@ -344,11 +352,9 @@ export const acquireDaemonStartLock = (input: { · 15 unmodified lines
344352 );
345353 });
346354
347−export const releaseDaemonStartLock = (input: DaemonStartLock): Effect.Effect<
348− void,
349− PlatformError,
350− FileSystem.FileSystem | Path.Path
351−> =>
355+export const releaseDaemonStartLock = (
356+ input: DaemonStartLock,
357+): Effect.Effect<void, PlatformError, FileSystem.FileSystem | Path.Path> =>
352358 Effect.gen(function* () {
353359 const fs = yield* FileSystem.FileSystem;
354360 yield* fs.remove(input.path, { force: true });
@@ -374,5 +380,7 @@ export const terminatePid = (pid: number): Effect.Effect<void, Error> => · 19 unmodified lines
374380 process.kill(pid, "SIGTERM");
375381 },
376382 catch: (cause) =>
377− cause instanceof Error ? cause : new Error(`Failed to terminate pid ${pid}: ${String(cause)}`),
383+ cause instanceof Error
384+ ? cause
385+ : new Error(`Failed to terminate pid ${pid}: ${String(cause)}`),
378386 });
apps/cli/src/daemon.ts+7−2
@@ -167,7 +167,10 @@ const toProbeHost = (hostname: string): string => { · 166 unmodified lines
167167 return hostname;
168168 };
169169
170−const isPortAvailable = (input: { hostname: string; port: number }): Effect.Effect<boolean, Error> =>
170+const isPortAvailable = (input: {
171+ hostname: string;
172+ port: number;
173+}): Effect.Effect<boolean, Error> =>
171174 Effect.tryPromise({
172175 try: () =>
173176 new Promise<boolean>((resolve) => {
@@ -215,7 +218,9 @@ const pickEphemeralPort = (hostname: string): Effect.Effect<number, Error> => · 41 unmodified lines
215218 server.listen({ port: 0, host: toProbeHost(hostname) });
216219 }),
217220 catch: (cause) =>
218− cause instanceof Error ? cause : new Error(`Failed selecting ephemeral port: ${String(cause)}`),
221+ cause instanceof Error
222+ ? cause
223+ : new Error(`Failed selecting ephemeral port: ${String(cause)}`),
219224 });
220225
221226 export const chooseDaemonPort = (input: {
apps/cli/src/main.ts+3−6
@@ -33,13 +33,10 @@ if (typeof Bun !== "undefined" && (await Bun.file(wasmOnDisk).exists())) { · 32 unmodified lines
3333 type QuickJSSyncVariant = import("quickjs-emscripten").QuickJSSyncVariant;
3434 const wasmBinary = await Bun.file(wasmOnDisk).arrayBuffer();
3535 const importFFI: QuickJSSyncVariant["importFFI"] = () =>
36− import("@jitl/quickjs-wasmfile-release-sync/ffi").then(
37− (m) => m.QuickJSFFI,
38− );
36+ import("@jitl/quickjs-wasmfile-release-sync/ffi").then((m) => m.QuickJSFFI);
3937 const importModuleLoader: QuickJSSyncVariant["importModuleLoader"] = async () => {
40− const { default: original } = await import(
41− "@jitl/quickjs-wasmfile-release-sync/emscripten-module"
42− );
38+ const { default: original } =
39+ await import("@jitl/quickjs-wasmfile-release-sync/emscripten-module");
4340 return (moduleArg = {}) => original({ ...moduleArg, wasmBinary });
4441 };
4542 const variant: QuickJSSyncVariant = {
apps/cli/src/tooling.ts+6−7
@@ -42,7 +42,10 @@ export const inspectToolPath = (input: { · 41 unmodified lines
4242 }): ToolPathInspection => {
4343 const prefixSegments =
4444 input.rawPrefixParts.length === 0 ? [] : buildToolPath(input.rawPrefixParts).split(".");
45− const children = new Map<string, { invokable: boolean; hasChildren: boolean; toolCount: number }>();
45+ const children = new Map<
46+ string,
47+ { invokable: boolean; hasChildren: boolean; toolCount: number }
48+ >();
4649 let exactPath: string | undefined = undefined;
4750 let matchingToolCount = 0;
4851
@@ -97,9 +100,7 @@ export const buildToolPath = (parts: ReadonlyArray<string>): string => { · 48 unmodified lines
97100 throw new Error("Tool path must include at least one segment");
98101 }
99102 if (segments.some((segment) => !TOOL_PATH_TOKEN.test(segment))) {
100− throw new Error(
101− "Tool path segments must contain only letters, numbers, '.', '_' or '-'",
102− );
103+ throw new Error("Tool path segments must contain only letters, numbers, '.', '_' or '-'");
103104 }
104105 return segments.join(".");
105106 };
@@ -186,9 +187,7 @@ export interface PausedInteraction { · 80 unmodified lines
186187 readonly requestedSchema?: Record<string, unknown>;
187188 }
188189
189−export const extractPausedInteraction = (
190− structured: unknown,
191−): PausedInteraction | undefined => {
190+export const extractPausedInteraction = (structured: unknown): PausedInteraction | undefined => {
192191 if (!isRecord(structured) || !isRecord(structured.interaction)) {
193192 return undefined;
194193 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t