From 013aa8098ede2ed28ca0912a6179bbaf392faf24 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 09:12:15 -0700 Subject: [PATCH 01/16] feat(deploy): send deno.json to the console on every deploy `deno deploy` uploaded the files but never passed the deno.json contents to `apps.initiateCliRevision`, so the console fell back to the app's stored config and the `deploy` section only took effect once, when `deno deploy create` captured it. Every deno.json and deno.jsonc among the uploaded files is now sent as `denoJsonFiles`, and the console applies the app directory's `deploy` section as it does for GitHub deployments. --- deploy/publish.ts | 19 +++++++++++++++++-- tests/deno_json_files.test.ts | 11 +++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/deno_json_files.test.ts diff --git a/deploy/publish.ts b/deploy/publish.ts index 0bb66d6..0ba3d14 100644 --- a/deploy/publish.ts +++ b/deploy/publish.ts @@ -26,6 +26,12 @@ type Chunk = { data: Uint8Array; }; +const DENO_JSON_NAMES = new Set(["deno.json", "deno.jsonc"]); + +export function isDenoJson(path: string): boolean { + return DENO_JSON_NAMES.has(path.slice(path.lastIndexOf("/") + 1)); +} + export async function publish( context: GlobalContext, configContext: ConfigContext, @@ -83,11 +89,19 @@ export async function publish( const [counter, body] = stream.tee(); const manifest: Record = {}; + // The console reads the `deploy` section of the app directory's deno.json + // from these, as it does for GitHub deployments, so it applies on every + // deploy rather than only when the app is created. + const denoJsonFiles: Record = {}; spinner.message = "Generating hashes..."; - for await (const { hash, relativePath } of counter) { - manifest[relativePath.replaceAll(SEPARATOR, "/")] = hash; + for await (const { hash, relativePath, data } of counter) { + const path = relativePath.replaceAll(SEPARATOR, "/"); + manifest[path] = hash; + if (isDenoJson(path)) { + denoJsonFiles[path] = new TextDecoder().decode(data); + } } if (context.debug) { @@ -103,6 +117,7 @@ export async function publish( app, production: prod, manifest, + denoJsonFiles, }, ) as string; diff --git a/tests/deno_json_files.test.ts b/tests/deno_json_files.test.ts new file mode 100644 index 0000000..ab2d37d --- /dev/null +++ b/tests/deno_json_files.test.ts @@ -0,0 +1,11 @@ +import { assertEquals } from "@std/assert"; +import { isDenoJson } from "../deploy/publish.ts"; + +Deno.test("isDenoJson: matches deno.json and deno.jsonc at any depth", () => { + assertEquals(isDenoJson("deno.json"), true); + assertEquals(isDenoJson("deno.jsonc"), true); + assertEquals(isDenoJson("apps/web/deno.json"), true); + assertEquals(isDenoJson("package.json"), false); + assertEquals(isDenoJson("deno.json.bak"), false); + assertEquals(isDenoJson("src/mydeno.json"), false); +}); From 57320660c218f1f7e2dcba2fa2874c16b3b7019a Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 09:19:26 -0700 Subject: [PATCH 02/16] feat(create): warn when deno.json overrides the build config given to create --- deploy/create/flow.ts | 19 +++++++++++++++++++ deploy/create/mod.ts | 9 +++++++++ deploy/publish.ts | 5 ++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/deploy/create/flow.ts b/deploy/create/flow.ts index e707e33..3ae622b 100644 --- a/deploy/create/flow.ts +++ b/deploy/create/flow.ts @@ -63,6 +63,16 @@ export async function detectedBuildTimeoutForOrg( return detectedBuildTimeout(buildConfig, maxBuildTimeout); } +/** + * The `deploy` section of deno.json takes precedence over the app's stored + * build configuration on every deploy, so settings given to `create` that + * differ from it would never be used. + */ +export const DENO_JSON_PRECEDENCE_WARNING = + "This app's deno.json has a `deploy` section, which takes precedence over " + + "the build configuration given here on every deploy. To change the build " + + "configuration, edit deno.json instead."; + const NA = "(n/a)"; const TITLES = { organization: "organization", @@ -222,6 +232,9 @@ export async function createFlow( clearPreviousLines(renderedBuildConfigLines + 1); if (!useDetected) { + if (buildConfig.from === "deno.json") { + console.warn(DENO_JSON_PRECEDENCE_WARNING); + } finalBuildConfig = getBuildConfig(context, buildConfig); } else { finalBuildConfig = buildConfig; @@ -246,6 +259,12 @@ export async function createFlow( finalBuildConfig = getBuildConfig(context, buildConfig); } + if ( + explicitBuildTimeout !== undefined && finalBuildConfig === buildConfig && + buildConfig?.from === "deno.json" + ) { + console.warn(DENO_JSON_PRECEDENCE_WARNING); + } let buildTimeout = explicitBuildTimeout ?? await detectedBuildTimeoutForOrg( trpcClient, org, diff --git a/deploy/create/mod.ts b/deploy/create/mod.ts index a9fd3ed..6f3854c 100644 --- a/deploy/create/mod.ts +++ b/deploy/create/mod.ts @@ -5,6 +5,7 @@ import { AVAILABLE_BUILD_MEMORY_LIMITS, AVAILABLE_BUILD_TIMEOUTS, createFlow, + DENO_JSON_PRECEDENCE_WARNING, detectedBuildTimeoutForOrg, REGIONS, renderBuildConfig, @@ -246,6 +247,14 @@ export const createCommand = new Command() buildDirectory = options.appDirectory || ""; } + if ( + member?.buildConfig.from === "deno.json" && + (options.doNotUseDetectedBuildConfig || + options.buildTimeout !== undefined) + ) { + console.warn(DENO_JSON_PRECEDENCE_WARNING); + } + let buildConfig; if (!options.doNotUseDetectedBuildConfig) { if (member?.buildConfig) { diff --git a/deploy/publish.ts b/deploy/publish.ts index 0ba3d14..694c2ba 100644 --- a/deploy/publish.ts +++ b/deploy/publish.ts @@ -91,7 +91,10 @@ export async function publish( const manifest: Record = {}; // The console reads the `deploy` section of the app directory's deno.json // from these, as it does for GitHub deployments, so it applies on every - // deploy rather than only when the app is created. + // deploy rather than only when the app is created. They are taken from the + // uploaded files rather than from the config the CLI resolved (which may be + // `--config other.json`, or outside the upload): the console only ever reads + // deno.json/deno.jsonc in the app directory of what the build sees. const denoJsonFiles: Record = {}; spinner.message = "Generating hashes..."; From 0b2870a0e395492b3708066a00151d9b88629857 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 09:29:33 -0700 Subject: [PATCH 03/16] fix(create): keep --json stderr to the JSON envelope --- deploy/create/mod.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/create/mod.ts b/deploy/create/mod.ts index 6f3854c..a4c918c 100644 --- a/deploy/create/mod.ts +++ b/deploy/create/mod.ts @@ -248,7 +248,7 @@ export const createCommand = new Command() } if ( - member?.buildConfig.from === "deno.json" && + !options.json && member?.buildConfig.from === "deno.json" && (options.doNotUseDetectedBuildConfig || options.buildTimeout !== undefined) ) { From 475550fd542aece6db1bd40b1181f71b2080903e Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 09:35:56 -0700 Subject: [PATCH 04/16] fix(deploy): send the root deno.json even when the upload excludes it --- deploy/publish.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/deploy/publish.ts b/deploy/publish.ts index 694c2ba..7569f67 100644 --- a/deploy/publish.ts +++ b/deploy/publish.ts @@ -92,9 +92,9 @@ export async function publish( // The console reads the `deploy` section of the app directory's deno.json // from these, as it does for GitHub deployments, so it applies on every // deploy rather than only when the app is created. They are taken from the - // uploaded files rather than from the config the CLI resolved (which may be - // `--config other.json`, or outside the upload): the console only ever reads - // deno.json/deno.jsonc in the app directory of what the build sees. + // uploaded files and the deploy root rather than from the config the CLI + // resolved (which may be `--config other.json`, or above the deploy root): + // the console only ever reads deno.json/deno.jsonc in the app directory. const denoJsonFiles: Record = {}; spinner.message = "Generating hashes..."; @@ -106,6 +106,17 @@ export async function publish( denoJsonFiles[path] = new TextDecoder().decode(data); } } + // The root config also holds `deploy.include`/`exclude`, which can leave it + // out of the upload itself (e.g. `"include": ["dist/**"]`); its `deploy` + // section still applies. + for (const name of DENO_JSON_NAMES) { + if (name in denoJsonFiles) continue; + try { + denoJsonFiles[name] = await Deno.readTextFile(join(rootPath, name)); + } catch (err) { + if (!(err instanceof Deno.errors.NotFound)) throw err; + } + } if (context.debug) { console.error("Manifest", manifest); From 3f99929c3555adb5e4140e4296f0b57f461d545a Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 09:42:31 -0700 Subject: [PATCH 05/16] fix(create): don't prompt for a timeout deno.json decides; warn for custom app directories --- deploy/create/flow.ts | 8 ++++++++ deploy/create/mod.ts | 15 +++++++++++++-- deploy/publish.ts | 3 ++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/deploy/create/flow.ts b/deploy/create/flow.ts index 3ae622b..48b46c3 100644 --- a/deploy/create/flow.ts +++ b/deploy/create/flow.ts @@ -270,6 +270,14 @@ export async function createFlow( org, finalBuildConfig, ); + // A deno.json `deploy` section decides the timeout on every deploy, an + // omitted one meaning the default, so there is nothing to ask for. + if ( + buildTimeout === undefined && buildConfig?.from === "deno.json" && + finalBuildConfig === buildConfig + ) { + buildTimeout = AVAILABLE_BUILD_TIMEOUTS[0]; + } if (buildTimeout === undefined) { // TODO: check pro const selectedBuildTimeout = promptSelect( diff --git a/deploy/create/mod.ts b/deploy/create/mod.ts index a4c918c..2ff03f3 100644 --- a/deploy/create/mod.ts +++ b/deploy/create/mod.ts @@ -13,6 +13,7 @@ import { import { createTrpcClient, getAuth } from "../../auth.ts"; import { type BuildConfig, + detectBuildConfig, detectWorkspace, FrameworkFileSystemReader, type FrameworkPreset, @@ -248,11 +249,21 @@ export const createCommand = new Command() } if ( - !options.json && member?.buildConfig.from === "deno.json" && + !options.json && (options.doNotUseDetectedBuildConfig || options.buildTimeout !== undefined) ) { - console.warn(DENO_JSON_PRECEDENCE_WARNING); + // A custom app directory is not a detected workspace member, but a + // local deploy still sends its deno.json, so check it directly. + const detected = member?.buildConfig ?? + (source === "local" + ? await detectBuildConfig( + new FrameworkFileSystemReader(resolve(rootPath, buildDirectory)), + ).catch(() => undefined) + : undefined); + if (detected?.from === "deno.json") { + console.warn(DENO_JSON_PRECEDENCE_WARNING); + } } let buildConfig; diff --git a/deploy/publish.ts b/deploy/publish.ts index 7569f67..136cd25 100644 --- a/deploy/publish.ts +++ b/deploy/publish.ts @@ -108,7 +108,8 @@ export async function publish( } // The root config also holds `deploy.include`/`exclude`, which can leave it // out of the upload itself (e.g. `"include": ["dist/**"]`); its `deploy` - // section still applies. + // section still applies. A deno.json in a non-root app directory that the + // upload excludes is not sent: the CLI does not know the app directory. for (const name of DENO_JSON_NAMES) { if (name in denoJsonFiles) continue; try { From 1a0df030fdfcb731bc058cd6ed49207204011e63 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 10:29:56 -0700 Subject: [PATCH 06/16] fix(deploy): send the config selected with --config as the root deno.json --- deploy/publish.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/deploy/publish.ts b/deploy/publish.ts index 136cd25..ca9fd87 100644 --- a/deploy/publish.ts +++ b/deploy/publish.ts @@ -118,6 +118,13 @@ export async function publish( if (!(err instanceof Deno.errors.NotFound)) throw err; } } + // A config selected with `--config` is the root config for this deploy, so + // it takes the place of the root deno.json (and of a root deno.jsonc, which + // the console would otherwise prefer). + if (context.config) { + delete denoJsonFiles["deno.jsonc"]; + denoJsonFiles["deno.json"] = await Deno.readTextFile(context.config); + } if (context.debug) { console.error("Manifest", manifest); From d08cca467f0bb66970e739eab85fe921ba758e5d Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 10:37:59 -0700 Subject: [PATCH 07/16] fix(deploy): send the app directory's deno.json, and warn for custom app directories * look up the app's stored build directory, so an excluded deno.json there, or a config selected with --config, lands where the console reads it * the create warning checks custom app directories even without --build-timeout or --do-not-use-detected-build-config, since their build config is synthesized from flags --- deploy/create/mod.ts | 5 +++- deploy/publish.ts | 66 ++++++++++++++++++++++++++++++-------------- 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/deploy/create/mod.ts b/deploy/create/mod.ts index 38b98eb..562f115 100644 --- a/deploy/create/mod.ts +++ b/deploy/create/mod.ts @@ -252,10 +252,13 @@ export const createCommand = new Command() buildDirectory = options.appDirectory || ""; } + // Build settings given here are overridden by a deno.json `deploy` + // section: those passed as flags, or all of them for a custom app + // directory, whose config is synthesized from the flags below. if ( !options.json && (options.doNotUseDetectedBuildConfig || - options.buildTimeout !== undefined) + options.buildTimeout !== undefined || member === undefined) ) { // A custom app directory is not a detected workspace member, but a // local deploy still sends its deno.json, so check it directly. diff --git a/deploy/publish.ts b/deploy/publish.ts index ca9fd87..4a54780 100644 --- a/deploy/publish.ts +++ b/deploy/publish.ts @@ -32,6 +32,29 @@ export function isDenoJson(path: string): boolean { return DENO_JSON_NAMES.has(path.slice(path.lastIndexOf("/") + 1)); } +/** + * The app's stored build directory, relative to the deploy root ("" for the + * root). Falls back to the root if the app cannot be read, leaving the error + * to `apps.initiateCliRevision`, which reports a missing app as before. + */ +async function appBuildDirectory( + context: GlobalContext, + org: string, + app: string, +): Promise { + try { + const fullApp = await createTrpcClient(context).query("apps.get", { + org, + app, + }) as { build_config?: { buildDirectory?: string } }; + // Normalized as the console does: `.` and empty segments are dropped. + return (fullApp.build_config?.buildDirectory ?? "").split("/") + .filter((p) => p !== "" && p !== ".").join("/"); + } catch { + return ""; + } +} + export async function publish( context: GlobalContext, configContext: ConfigContext, @@ -92,9 +115,8 @@ export async function publish( // The console reads the `deploy` section of the app directory's deno.json // from these, as it does for GitHub deployments, so it applies on every // deploy rather than only when the app is created. They are taken from the - // uploaded files and the deploy root rather than from the config the CLI - // resolved (which may be `--config other.json`, or above the deploy root): - // the console only ever reads deno.json/deno.jsonc in the app directory. + // uploaded files, plus the app directory's config as below: the console + // only ever reads deno.json/deno.jsonc in the app's build directory. const denoJsonFiles: Record = {}; spinner.message = "Generating hashes..."; @@ -106,24 +128,28 @@ export async function publish( denoJsonFiles[path] = new TextDecoder().decode(data); } } - // The root config also holds `deploy.include`/`exclude`, which can leave it - // out of the upload itself (e.g. `"include": ["dist/**"]`); its `deploy` - // section still applies. A deno.json in a non-root app directory that the - // upload excludes is not sent: the CLI does not know the app directory. - for (const name of DENO_JSON_NAMES) { - if (name in denoJsonFiles) continue; - try { - denoJsonFiles[name] = await Deno.readTextFile(join(rootPath, name)); - } catch (err) { - if (!(err instanceof Deno.errors.NotFound)) throw err; - } - } - // A config selected with `--config` is the root config for this deploy, so - // it takes the place of the root deno.json (and of a root deno.jsonc, which - // the console would otherwise prefer). + // The console reads the config in the app's build directory, which the + // upload can leave out through `deploy.include`/`exclude` (e.g. + // `"include": ["dist/**"]`) while its `deploy` section still applies, and + // which a config selected with `--config` stands in for. + const appDir = await appBuildDirectory(context, org, app); + const prefix = appDir === "" ? "" : `${appDir}/`; if (context.config) { - delete denoJsonFiles["deno.jsonc"]; - denoJsonFiles["deno.json"] = await Deno.readTextFile(context.config); + delete denoJsonFiles[`${prefix}deno.jsonc`]; + denoJsonFiles[`${prefix}deno.json`] = await Deno.readTextFile( + context.config, + ); + } else { + for (const name of DENO_JSON_NAMES) { + if (`${prefix}${name}` in denoJsonFiles) continue; + try { + denoJsonFiles[`${prefix}${name}`] = await Deno.readTextFile( + join(rootPath, appDir, name), + ); + } catch (err) { + if (!(err instanceof Deno.errors.NotFound)) throw err; + } + } } if (context.debug) { From 83f112d34aed2c1ca98634322dfdd6a4dc3cdaea Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 10:47:36 -0700 Subject: [PATCH 08/16] fix(deploy): ignore a stored build directory that leaves the deploy root --- deploy/publish.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/deploy/publish.ts b/deploy/publish.ts index 4a54780..0831f50 100644 --- a/deploy/publish.ts +++ b/deploy/publish.ts @@ -47,9 +47,11 @@ async function appBuildDirectory( org, app, }) as { build_config?: { buildDirectory?: string } }; - // Normalized as the console does: `.` and empty segments are dropped. - return (fullApp.build_config?.buildDirectory ?? "").split("/") - .filter((p) => p !== "" && p !== ".").join("/"); + // Normalized as the console does: `.` and empty segments are dropped, and + // a path leaving the deploy root (which the console rejects) is ignored. + const segments = (fullApp.build_config?.buildDirectory ?? "").split("/") + .filter((p) => p !== "" && p !== "."); + return segments.includes("..") ? "" : segments.join("/"); } catch { return ""; } From 727debf0f78d194df858bfa21326995681c8fa7d Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 10:55:39 -0700 Subject: [PATCH 09/16] fix(deploy): keep app config reads inside the deploy root on Windows too --- deploy/publish.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/deploy/publish.ts b/deploy/publish.ts index 0831f50..9f8bcc0 100644 --- a/deploy/publish.ts +++ b/deploy/publish.ts @@ -49,8 +49,8 @@ async function appBuildDirectory( }) as { build_config?: { buildDirectory?: string } }; // Normalized as the console does: `.` and empty segments are dropped, and // a path leaving the deploy root (which the console rejects) is ignored. - const segments = (fullApp.build_config?.buildDirectory ?? "").split("/") - .filter((p) => p !== "" && p !== "."); + const segments = (fullApp.build_config?.buildDirectory ?? "") + .split(/[\\/]/).filter((p) => p !== "" && p !== "."); return segments.includes("..") ? "" : segments.join("/"); } catch { return ""; @@ -142,11 +142,14 @@ export async function publish( context.config, ); } else { - for (const name of DENO_JSON_NAMES) { + const root = resolve(rootPath); + const dir = resolve(root, appDir); + const insideRoot = dir === root || dir.startsWith(root + SEPARATOR); + for (const name of insideRoot ? DENO_JSON_NAMES : []) { if (`${prefix}${name}` in denoJsonFiles) continue; try { denoJsonFiles[`${prefix}${name}`] = await Deno.readTextFile( - join(rootPath, appDir, name), + join(dir, name), ); } catch (err) { if (!(err instanceof Deno.errors.NotFound)) throw err; From 5039027b5ad8fb777fb390962c53d082c4bf6425 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 11:09:15 -0700 Subject: [PATCH 10/16] fix(deploy): handle a filesystem-root deploy root; let a failed app lookup report normally --- deploy/publish.ts | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/deploy/publish.ts b/deploy/publish.ts index 9f8bcc0..e535f19 100644 --- a/deploy/publish.ts +++ b/deploy/publish.ts @@ -1,7 +1,7 @@ import { TarStream, type TarStreamFile } from "@std/tar"; import { ProgressBar } from "@std/cli/unstable-progress-bar"; import { Spinner } from "@std/cli/unstable-spinner"; -import { join, relative, resolve, SEPARATOR } from "@std/path"; +import { isAbsolute, join, relative, resolve, SEPARATOR } from "@std/path"; import { green, red, yellow } from "@std/fmt/colors"; import { authedFetch, createTrpcClient } from "../auth.ts"; import { @@ -34,27 +34,23 @@ export function isDenoJson(path: string): boolean { /** * The app's stored build directory, relative to the deploy root ("" for the - * root). Falls back to the root if the app cannot be read, leaving the error - * to `apps.initiateCliRevision`, which reports a missing app as before. + * root). A failure here (e.g. a missing app) is reported and exits just as + * `apps.initiateCliRevision` would have. */ async function appBuildDirectory( context: GlobalContext, org: string, app: string, ): Promise { - try { - const fullApp = await createTrpcClient(context).query("apps.get", { - org, - app, - }) as { build_config?: { buildDirectory?: string } }; - // Normalized as the console does: `.` and empty segments are dropped, and - // a path leaving the deploy root (which the console rejects) is ignored. - const segments = (fullApp.build_config?.buildDirectory ?? "") - .split(/[\\/]/).filter((p) => p !== "" && p !== "."); - return segments.includes("..") ? "" : segments.join("/"); - } catch { - return ""; - } + const fullApp = await createTrpcClient(context).query("apps.get", { + org, + app, + }) as { build_config?: { buildDirectory?: string } }; + // Normalized as the console does: `.` and empty segments are dropped, and a + // path leaving the deploy root (which the console rejects) is ignored. + const segments = (fullApp.build_config?.buildDirectory ?? "") + .split(/[\\/]/).filter((p) => p !== "" && p !== "."); + return segments.includes("..") ? "" : segments.join("/"); } export async function publish( @@ -142,9 +138,9 @@ export async function publish( context.config, ); } else { - const root = resolve(rootPath); - const dir = resolve(root, appDir); - const insideRoot = dir === root || dir.startsWith(root + SEPARATOR); + const dir = resolve(rootPath, appDir); + const fromRoot = relative(resolve(rootPath), dir); + const insideRoot = !fromRoot.startsWith("..") && !isAbsolute(fromRoot); for (const name of insideRoot ? DENO_JSON_NAMES : []) { if (`${prefix}${name}` in denoJsonFiles) continue; try { From e794f13675cf608774a22274501e1cfd61aa1e22 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 11:19:52 -0700 Subject: [PATCH 11/16] refactor(deploy): send only the app directory's deno.json --- deploy/publish.ts | 43 +++++++++++++++++++---------------- tests/deno_json_files.test.ts | 19 +++++++++------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/deploy/publish.ts b/deploy/publish.ts index e535f19..786bd55 100644 --- a/deploy/publish.ts +++ b/deploy/publish.ts @@ -28,8 +28,16 @@ type Chunk = { const DENO_JSON_NAMES = new Set(["deno.json", "deno.jsonc"]); -export function isDenoJson(path: string): boolean { - return DENO_JSON_NAMES.has(path.slice(path.lastIndexOf("/") + 1)); +/** + * Normalizes an app's stored build directory as the console does: `.` and + * empty segments are dropped, and a path leaving the deploy root (which the + * console rejects) becomes the root, "". + */ +export function normalizeBuildDirectory(buildDirectory: string): string { + const segments = buildDirectory.split(/[\\/]/).filter((p) => + p !== "" && p !== "." + ); + return segments.includes("..") ? "" : segments.join("/"); } /** @@ -46,11 +54,7 @@ async function appBuildDirectory( org, app, }) as { build_config?: { buildDirectory?: string } }; - // Normalized as the console does: `.` and empty segments are dropped, and a - // path leaving the deploy root (which the console rejects) is ignored. - const segments = (fullApp.build_config?.buildDirectory ?? "") - .split(/[\\/]/).filter((p) => p !== "" && p !== "."); - return segments.includes("..") ? "" : segments.join("/"); + return normalizeBuildDirectory(fullApp.build_config?.buildDirectory ?? ""); } export async function publish( @@ -110,11 +114,12 @@ export async function publish( const [counter, body] = stream.tee(); const manifest: Record = {}; - // The console reads the `deploy` section of the app directory's deno.json - // from these, as it does for GitHub deployments, so it applies on every - // deploy rather than only when the app is created. They are taken from the - // uploaded files, plus the app directory's config as below: the console - // only ever reads deno.json/deno.jsonc in the app's build directory. + // The console reads the `deploy` section of the deno.json in the app's build + // directory, as it does for GitHub deployments, so it applies on every + // deploy rather than only when the app is created. Only that directory's + // configs are sent: the console reads no others. + const appDir = await appBuildDirectory(context, org, app); + const prefix = appDir === "" ? "" : `${appDir}/`; const denoJsonFiles: Record = {}; spinner.message = "Generating hashes..."; @@ -122,16 +127,13 @@ export async function publish( for await (const { hash, relativePath, data } of counter) { const path = relativePath.replaceAll(SEPARATOR, "/"); manifest[path] = hash; - if (isDenoJson(path)) { + if (path === `${prefix}deno.json` || path === `${prefix}deno.jsonc`) { denoJsonFiles[path] = new TextDecoder().decode(data); } } - // The console reads the config in the app's build directory, which the - // upload can leave out through `deploy.include`/`exclude` (e.g. - // `"include": ["dist/**"]`) while its `deploy` section still applies, and - // which a config selected with `--config` stands in for. - const appDir = await appBuildDirectory(context, org, app); - const prefix = appDir === "" ? "" : `${appDir}/`; + // A config selected with `--config` stands in for the app directory's. One + // the upload leaves out through `deploy.include`/`exclude` (e.g. + // `"include": ["dist/**"]`) still applies, so it is read from disk. if (context.config) { delete denoJsonFiles[`${prefix}deno.jsonc`]; denoJsonFiles[`${prefix}deno.json`] = await Deno.readTextFile( @@ -140,7 +142,8 @@ export async function publish( } else { const dir = resolve(rootPath, appDir); const fromRoot = relative(resolve(rootPath), dir); - const insideRoot = !fromRoot.startsWith("..") && !isAbsolute(fromRoot); + const insideRoot = fromRoot !== ".." && + !fromRoot.startsWith(`..${SEPARATOR}`) && !isAbsolute(fromRoot); for (const name of insideRoot ? DENO_JSON_NAMES : []) { if (`${prefix}${name}` in denoJsonFiles) continue; try { diff --git a/tests/deno_json_files.test.ts b/tests/deno_json_files.test.ts index ab2d37d..8449a0f 100644 --- a/tests/deno_json_files.test.ts +++ b/tests/deno_json_files.test.ts @@ -1,11 +1,14 @@ import { assertEquals } from "@std/assert"; -import { isDenoJson } from "../deploy/publish.ts"; +import { normalizeBuildDirectory } from "../deploy/publish.ts"; -Deno.test("isDenoJson: matches deno.json and deno.jsonc at any depth", () => { - assertEquals(isDenoJson("deno.json"), true); - assertEquals(isDenoJson("deno.jsonc"), true); - assertEquals(isDenoJson("apps/web/deno.json"), true); - assertEquals(isDenoJson("package.json"), false); - assertEquals(isDenoJson("deno.json.bak"), false); - assertEquals(isDenoJson("src/mydeno.json"), false); +Deno.test("normalizeBuildDirectory: matches the console's normalization", () => { + assertEquals(normalizeBuildDirectory(""), ""); + assertEquals(normalizeBuildDirectory("."), ""); + assertEquals(normalizeBuildDirectory("apps/web"), "apps/web"); + assertEquals(normalizeBuildDirectory("./apps/web/"), "apps/web"); + assertEquals(normalizeBuildDirectory("apps\\web"), "apps/web"); + assertEquals(normalizeBuildDirectory("..app"), "..app"); + assertEquals(normalizeBuildDirectory("../private"), ""); + assertEquals(normalizeBuildDirectory("apps/../.."), ""); + assertEquals(normalizeBuildDirectory("..\\private"), ""); }); From ca25625e430542f9307872176e982821fe143a2f Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 11:40:31 -0700 Subject: [PATCH 12/16] refactor(deploy): type the apps.get build directory through AppDetail --- deploy/apps.ts | 9 +++++++-- deploy/publish.ts | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/deploy/apps.ts b/deploy/apps.ts index ce2e109..43f2eac 100644 --- a/deploy/apps.ts +++ b/deploy/apps.ts @@ -17,12 +17,17 @@ interface AppItem { layers: Array<{ slug: string }>; } -interface AppDetail { +/** The app row `apps.get` returns, as far as the CLI reads it. */ +export interface AppDetail { id: string; slug: string; created_at: Date; updated_at: Date; - build_config: { frameworkPreset?: string | null } | null; + build_config: { + frameworkPreset?: string | null; + /** The app directory, relative to the repository or deploy root. */ + buildDirectory?: string; + } | null; } interface TimelineEntry { diff --git a/deploy/publish.ts b/deploy/publish.ts index 786bd55..fb742a0 100644 --- a/deploy/publish.ts +++ b/deploy/publish.ts @@ -12,6 +12,7 @@ import { } from "../util.ts"; import type { GlobalContext } from "../main.ts"; import type { ConfigContext } from "../config.ts"; +import type { AppDetail } from "./apps.ts"; interface Revision { labels: Record; @@ -53,7 +54,7 @@ async function appBuildDirectory( const fullApp = await createTrpcClient(context).query("apps.get", { org, app, - }) as { build_config?: { buildDirectory?: string } }; + }) as AppDetail; return normalizeBuildDirectory(fullApp.build_config?.buildDirectory ?? ""); } From 1a2af44c626fc4456a50b0f094a29b94926e5cda Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 12:03:05 -0700 Subject: [PATCH 13/16] test(deploy): cover which deno.json files a deploy sends Splits the selection into collectDenoJsonFiles and tests it for a nested app directory, an excluded config, --config, and a stored build directory leaving the deploy root. --- deploy/publish.ts | 100 +++++++++++++++++++++------------ tests/deno_json_files.test.ts | 103 +++++++++++++++++++++++++++++++++- 2 files changed, 166 insertions(+), 37 deletions(-) diff --git a/deploy/publish.ts b/deploy/publish.ts index fb742a0..1be212f 100644 --- a/deploy/publish.ts +++ b/deploy/publish.ts @@ -42,8 +42,59 @@ export function normalizeBuildDirectory(buildDirectory: string): string { } /** - * The app's stored build directory, relative to the deploy root ("" for the - * root). A failure here (e.g. a missing app) is reported and exits just as + * The deno.json files to send with a CLI revision. The console reads the + * `deploy` section of the deno.json in the app's build directory, as it does + * for GitHub deployments, so it applies on every deploy rather than only when + * the app is created; it reads no other config, so only that directory's are + * sent. A config selected with `--config` stands in for it, and one the upload + * leaves out through `deploy.include`/`exclude` (e.g. `"include": ["dist/**"]`) + * still applies, so it is read from disk. + */ +export async function collectDenoJsonFiles( + { rootPath, buildDirectory, uploaded, configPath }: { + rootPath: string; + /** The app's stored build directory, as stored. */ + buildDirectory: string; + /** The uploaded deno.json/deno.jsonc files, by `/`-separated path. */ + uploaded: Record; + configPath?: string; + }, +): Promise> { + const appDir = normalizeBuildDirectory(buildDirectory); + const prefix = appDir === "" ? "" : `${appDir}/`; + const files: Record = {}; + for (const name of DENO_JSON_NAMES) { + if (`${prefix}${name}` in uploaded) { + files[`${prefix}${name}`] = uploaded[`${prefix}${name}`]; + } + } + if (configPath) { + delete files[`${prefix}deno.jsonc`]; + files[`${prefix}deno.json`] = await Deno.readTextFile(configPath); + return files; + } + const dir = resolve(rootPath, appDir); + const fromRoot = relative(resolve(rootPath), dir); + if ( + fromRoot === ".." || fromRoot.startsWith(`..${SEPARATOR}`) || + isAbsolute(fromRoot) + ) { + return files; + } + for (const name of DENO_JSON_NAMES) { + if (`${prefix}${name}` in files) continue; + try { + files[`${prefix}${name}`] = await Deno.readTextFile(join(dir, name)); + } catch (err) { + if (!(err instanceof Deno.errors.NotFound)) throw err; + } + } + return files; +} + +/** + * The app's stored build directory, as stored (see `normalizeBuildDirectory`). + * A failure here (e.g. a missing app) is reported and exits just as * `apps.initiateCliRevision` would have. */ async function appBuildDirectory( @@ -55,7 +106,7 @@ async function appBuildDirectory( org, app, }) as AppDetail; - return normalizeBuildDirectory(fullApp.build_config?.buildDirectory ?? ""); + return fullApp.build_config?.buildDirectory ?? ""; } export async function publish( @@ -115,48 +166,25 @@ export async function publish( const [counter, body] = stream.tee(); const manifest: Record = {}; - // The console reads the `deploy` section of the deno.json in the app's build - // directory, as it does for GitHub deployments, so it applies on every - // deploy rather than only when the app is created. Only that directory's - // configs are sent: the console reads no others. - const appDir = await appBuildDirectory(context, org, app); - const prefix = appDir === "" ? "" : `${appDir}/`; - const denoJsonFiles: Record = {}; + const uploadedDenoJsonFiles: Record = {}; spinner.message = "Generating hashes..."; for await (const { hash, relativePath, data } of counter) { const path = relativePath.replaceAll(SEPARATOR, "/"); manifest[path] = hash; - if (path === `${prefix}deno.json` || path === `${prefix}deno.jsonc`) { - denoJsonFiles[path] = new TextDecoder().decode(data); - } - } - // A config selected with `--config` stands in for the app directory's. One - // the upload leaves out through `deploy.include`/`exclude` (e.g. - // `"include": ["dist/**"]`) still applies, so it is read from disk. - if (context.config) { - delete denoJsonFiles[`${prefix}deno.jsonc`]; - denoJsonFiles[`${prefix}deno.json`] = await Deno.readTextFile( - context.config, - ); - } else { - const dir = resolve(rootPath, appDir); - const fromRoot = relative(resolve(rootPath), dir); - const insideRoot = fromRoot !== ".." && - !fromRoot.startsWith(`..${SEPARATOR}`) && !isAbsolute(fromRoot); - for (const name of insideRoot ? DENO_JSON_NAMES : []) { - if (`${prefix}${name}` in denoJsonFiles) continue; - try { - denoJsonFiles[`${prefix}${name}`] = await Deno.readTextFile( - join(dir, name), - ); - } catch (err) { - if (!(err instanceof Deno.errors.NotFound)) throw err; - } + if (DENO_JSON_NAMES.has(path.slice(path.lastIndexOf("/") + 1))) { + uploadedDenoJsonFiles[path] = new TextDecoder().decode(data); } } + const denoJsonFiles = await collectDenoJsonFiles({ + rootPath, + buildDirectory: await appBuildDirectory(context, org, app), + uploaded: uploadedDenoJsonFiles, + configPath: context.config, + }); + if (context.debug) { console.error("Manifest", manifest); } diff --git a/tests/deno_json_files.test.ts b/tests/deno_json_files.test.ts index 8449a0f..f36ce4c 100644 --- a/tests/deno_json_files.test.ts +++ b/tests/deno_json_files.test.ts @@ -1,5 +1,9 @@ import { assertEquals } from "@std/assert"; -import { normalizeBuildDirectory } from "../deploy/publish.ts"; +import { dirname, join } from "@std/path"; +import { + collectDenoJsonFiles, + normalizeBuildDirectory, +} from "../deploy/publish.ts"; Deno.test("normalizeBuildDirectory: matches the console's normalization", () => { assertEquals(normalizeBuildDirectory(""), ""); @@ -12,3 +16,100 @@ Deno.test("normalizeBuildDirectory: matches the console's normalization", () => assertEquals(normalizeBuildDirectory("apps/../.."), ""); assertEquals(normalizeBuildDirectory("..\\private"), ""); }); + +async function withProject( + files: Record, + fn: (root: string) => Promise, +) { + const root = await Deno.makeTempDir(); + try { + for (const [path, content] of Object.entries(files)) { + await Deno.mkdir(join(root, dirname(path)), { recursive: true }); + await Deno.writeTextFile(join(root, path), content); + } + await fn(root); + } finally { + await Deno.remove(root, { recursive: true }); + } +} + +Deno.test("collectDenoJsonFiles: sends only the app directory's config", async () => { + await withProject({ + "deno.json": "root", + "apps/web/deno.json": "web", + "apps/api/deno.json": "api", + }, async (rootPath) => { + const uploaded = { + "deno.json": "root", + "apps/web/deno.json": "web", + "apps/api/deno.json": "api", + }; + assertEquals( + await collectDenoJsonFiles({ + rootPath, + buildDirectory: "apps/web", + uploaded, + }), + { "apps/web/deno.json": "web" }, + ); + assertEquals( + await collectDenoJsonFiles({ + rootPath, + buildDirectory: "./apps/web/", + uploaded, + }), + { "apps/web/deno.json": "web" }, + ); + assertEquals( + await collectDenoJsonFiles({ rootPath, buildDirectory: "", uploaded }), + { "deno.json": "root" }, + ); + }); +}); + +Deno.test("collectDenoJsonFiles: reads a config the upload excluded", async () => { + await withProject({ + "apps/web/deno.jsonc": "web", + }, async (rootPath) => { + assertEquals( + await collectDenoJsonFiles({ + rootPath, + buildDirectory: "apps/web", + uploaded: {}, + }), + { "apps/web/deno.jsonc": "web" }, + ); + }); +}); + +Deno.test("collectDenoJsonFiles: --config stands in for the app directory's", async () => { + await withProject({ + "staging.json": "staging", + }, async (rootPath) => { + assertEquals( + await collectDenoJsonFiles({ + rootPath, + buildDirectory: "apps/web", + uploaded: { "apps/web/deno.jsonc": "web" }, + configPath: join(rootPath, "staging.json"), + }), + { "apps/web/deno.json": "staging" }, + ); + }); +}); + +Deno.test("collectDenoJsonFiles: never reads outside the deploy root", async () => { + await withProject({ + "project/main.ts": "", + "private/deno.json": "secret", + }, async (dir) => { + const rootPath = join(dir, "project"); + for (const buildDirectory of ["../private", "..\\private"]) { + assertEquals( + await collectDenoJsonFiles({ rootPath, buildDirectory, uploaded: {} }), + {}, + buildDirectory, + ); + } + }); +}); From b47aae5918619ef24e1d97a63fc586a0af6d5375 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 12:13:49 -0700 Subject: [PATCH 14/16] fix(deploy): resolve symlinks before reading an excluded config; detect custom app directories in create * the excluded-config fallback resolves real paths and skips anything outside the deploy root * create detects the build config of a custom app directory, locally or via github.detectBuildConfigForRepo, in both the interactive and the flag-driven flow --- deploy/create/flow.ts | 33 ++++++++++++++++++++++++++++++++- deploy/create/mod.ts | 15 +++++++-------- deploy/publish.ts | 25 +++++++++++++++---------- tests/deno_json_files.test.ts | 30 ++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 19 deletions(-) diff --git a/deploy/create/flow.ts b/deploy/create/flow.ts index fa44a29..dee6c02 100644 --- a/deploy/create/flow.ts +++ b/deploy/create/flow.ts @@ -1,4 +1,5 @@ import { createTrpcClient, type TRPCClient } from "../../auth.ts"; +import { resolve } from "@std/path"; import { green } from "@std/fmt/colors"; import { error } from "../../util.ts"; import { @@ -7,6 +8,7 @@ import { } from "@std/cli/unstable-prompt-select"; import { type BuildConfig, + detectBuildConfig, type DetectedBuildConfig, detectWorkspace, FrameworkFileSystemReader, @@ -44,6 +46,29 @@ export function parseBuildTimeoutFlag(value: string): number | null { return AVAILABLE_BUILD_TIMEOUTS.includes(minutes) ? minutes : null; } +/** + * The build config detected in an app directory that is not a detected + * workspace member, locally or in the GitHub repo. A deploy still applies its + * deno.json `deploy` section, so `create` must know about it. + */ +export async function customDirectoryBuildConfig( + trpcClient: TRPCClient, + rootPath: string, + repo: Repo, + path: string, +): Promise { + if (repo !== undefined) { + return await trpcClient.query("github.detectBuildConfigForRepo", { + owner: repo.owner, + repo: repo.repo, + path, + }) as DetectedBuildConfig | null; + } + return await detectBuildConfig( + new FrameworkFileSystemReader(resolve(rootPath, path)), + ).catch(() => null); +} + /** * The build timeout a detected build config asks for (deno.json * `deploy.buildTimeout`), as the largest available step not above it or @@ -231,7 +256,13 @@ export async function createFlow( if (typeof selectedAppDirectory === "string") { buildConfig = appDirectories.members.find((member) => member.path === selectedAppDirectory - )?.buildConfig ?? null; + )?.buildConfig ?? + await customDirectoryBuildConfig( + trpcClient, + rootPath, + repo, + selectedAppDirectory, + ); } else { buildConfig = selectedAppDirectory.buildConfig; } diff --git a/deploy/create/mod.ts b/deploy/create/mod.ts index 562f115..4da5033 100644 --- a/deploy/create/mod.ts +++ b/deploy/create/mod.ts @@ -5,6 +5,7 @@ import { AVAILABLE_BUILD_MEMORY_LIMITS, AVAILABLE_BUILD_TIMEOUTS, createFlow, + customDirectoryBuildConfig, DENO_JSON_PRECEDENCE_WARNING, detectedBuildTimeoutForOrg, parseBuildTimeoutFlag, @@ -14,7 +15,6 @@ import { import { createTrpcClient, getAuth } from "../../auth.ts"; import { type BuildConfig, - detectBuildConfig, detectWorkspace, FrameworkFileSystemReader, type FrameworkPreset, @@ -260,14 +260,13 @@ export const createCommand = new Command() (options.doNotUseDetectedBuildConfig || options.buildTimeout !== undefined || member === undefined) ) { - // A custom app directory is not a detected workspace member, but a - // local deploy still sends its deno.json, so check it directly. const detected = member?.buildConfig ?? - (source === "local" - ? await detectBuildConfig( - new FrameworkFileSystemReader(resolve(rootPath, buildDirectory)), - ).catch(() => undefined) - : undefined); + await customDirectoryBuildConfig( + createTrpcClient(options), + rootPath, + repo, + buildDirectory, + ); if (detected?.from === "deno.json") { console.warn(DENO_JSON_PRECEDENCE_WARNING); } diff --git a/deploy/publish.ts b/deploy/publish.ts index 1be212f..a791c57 100644 --- a/deploy/publish.ts +++ b/deploy/publish.ts @@ -73,21 +73,26 @@ export async function collectDenoJsonFiles( files[`${prefix}deno.json`] = await Deno.readTextFile(configPath); return files; } - const dir = resolve(rootPath, appDir); - const fromRoot = relative(resolve(rootPath), dir); - if ( - fromRoot === ".." || fromRoot.startsWith(`..${SEPARATOR}`) || - isAbsolute(fromRoot) - ) { - return files; - } + // Symlinks are resolved first, so that neither the app directory nor the + // config can point outside the deploy root. + const root = await Deno.realPath(rootPath); for (const name of DENO_JSON_NAMES) { if (`${prefix}${name}` in files) continue; + let path; try { - files[`${prefix}${name}`] = await Deno.readTextFile(join(dir, name)); + path = await Deno.realPath(join(rootPath, appDir, name)); } catch (err) { - if (!(err instanceof Deno.errors.NotFound)) throw err; + if (err instanceof Deno.errors.NotFound) continue; + throw err; + } + const fromRoot = relative(root, path); + if ( + fromRoot === ".." || fromRoot.startsWith(`..${SEPARATOR}`) || + isAbsolute(fromRoot) + ) { + continue; } + files[`${prefix}${name}`] = await Deno.readTextFile(path); } return files; } diff --git a/tests/deno_json_files.test.ts b/tests/deno_json_files.test.ts index f36ce4c..5f31955 100644 --- a/tests/deno_json_files.test.ts +++ b/tests/deno_json_files.test.ts @@ -113,3 +113,33 @@ Deno.test("collectDenoJsonFiles: never reads outside the deploy root", async () } }); }); + +Deno.test("collectDenoJsonFiles: never follows a symlink out of the deploy root", async () => { + await withProject({ + "project/main.ts": "", + "private/deno.json": "secret", + }, async (dir) => { + const rootPath = join(dir, "project"); + await Deno.symlink(join(dir, "private"), join(rootPath, "linked")); + await Deno.symlink( + join(dir, "private", "deno.json"), + join(rootPath, "deno.json"), + ); + assertEquals( + await collectDenoJsonFiles({ + rootPath, + buildDirectory: "linked", + uploaded: {}, + }), + {}, + ); + assertEquals( + await collectDenoJsonFiles({ + rootPath, + buildDirectory: "", + uploaded: {}, + }), + {}, + ); + }); +}); From 0a2298943dfc8ae9180bb74647320cfcc88825d9 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 12:31:43 -0700 Subject: [PATCH 15/16] fix(create): don't let the custom-directory deno.json check fail create The GitHub lookup could exit the CLI on a failed request, for what is only a warning; custom GitHub app directories are no longer probed. --- deploy/create/flow.ts | 17 +++++------------ deploy/create/mod.ts | 1 - 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/deploy/create/flow.ts b/deploy/create/flow.ts index dee6c02..84895f1 100644 --- a/deploy/create/flow.ts +++ b/deploy/create/flow.ts @@ -47,23 +47,17 @@ export function parseBuildTimeoutFlag(value: string): number | null { } /** - * The build config detected in an app directory that is not a detected - * workspace member, locally or in the GitHub repo. A deploy still applies its - * deno.json `deploy` section, so `create` must know about it. + * The build config detected in a local app directory that is not a detected + * workspace member: a deploy still applies its deno.json `deploy` section, so + * `create` must know about it. Not attempted for a GitHub repo, where it would + * need a request whose failure exits the CLI, for what is only a warning. */ export async function customDirectoryBuildConfig( - trpcClient: TRPCClient, rootPath: string, repo: Repo, path: string, ): Promise { - if (repo !== undefined) { - return await trpcClient.query("github.detectBuildConfigForRepo", { - owner: repo.owner, - repo: repo.repo, - path, - }) as DetectedBuildConfig | null; - } + if (repo !== undefined) return null; return await detectBuildConfig( new FrameworkFileSystemReader(resolve(rootPath, path)), ).catch(() => null); @@ -258,7 +252,6 @@ export async function createFlow( member.path === selectedAppDirectory )?.buildConfig ?? await customDirectoryBuildConfig( - trpcClient, rootPath, repo, selectedAppDirectory, diff --git a/deploy/create/mod.ts b/deploy/create/mod.ts index 4da5033..4b61c57 100644 --- a/deploy/create/mod.ts +++ b/deploy/create/mod.ts @@ -262,7 +262,6 @@ export const createCommand = new Command() ) { const detected = member?.buildConfig ?? await customDirectoryBuildConfig( - createTrpcClient(options), rootPath, repo, buildDirectory, From c9eac00e9d8c69ecb7eec86e7b1eb9f38bad8fa8 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 1 Oct 2026 12:38:44 -0700 Subject: [PATCH 16/16] fix(create): detect a custom app directory with the root's package manager --- deploy/create/flow.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/deploy/create/flow.ts b/deploy/create/flow.ts index 84895f1..759f80e 100644 --- a/deploy/create/flow.ts +++ b/deploy/create/flow.ts @@ -10,6 +10,7 @@ import { type BuildConfig, detectBuildConfig, type DetectedBuildConfig, + detectPackageManager, detectWorkspace, FrameworkFileSystemReader, SUPPORTED_FRAMEWORK_PRESETS, @@ -58,9 +59,19 @@ export async function customDirectoryBuildConfig( path: string, ): Promise { if (repo !== undefined) return null; - return await detectBuildConfig( - new FrameworkFileSystemReader(resolve(rootPath, path)), - ).catch(() => null); + try { + // As `detectWorkspace` does: a lockfile at the root decides the package + // manager of a nested app. + const packageManager = await detectPackageManager( + new FrameworkFileSystemReader(rootPath), + ); + return await detectBuildConfig( + new FrameworkFileSystemReader(resolve(rootPath, path)), + packageManager, + ); + } catch { + return null; + } } /**