Skip to content

fix(config): treat positional file root as deploy target, not config file#114

Open
tcerqueira wants to merge 1 commit into
mainfrom
tc/positional-file-root
Open

fix(config): treat positional file root as deploy target, not config file#114
tcerqueira wants to merge 1 commit into
mainfrom
tc/positional-file-root

Conversation

@tcerqueira

Copy link
Copy Markdown
Member

What

deno deploy --org o --app a --prod main.ts failed with Failed deserializing config file '.../main.ts'.: Unexpected word on line 1 column 1 because the positional [root-path] was passed into config discovery as a config file whenever it pointed at a file.

Why

resolve_config (rs_lib) treated any file path as WorkspaceDiscoverStart::ConfigFile. That is correct for --config deno-staging.json but wrong for a positional entrypoint/root like main.ts, which should be a deploy target.

Approach

  • rs_lib: thread a from_config flag. A positional file root now discovers config from its parent directory (Paths) and includes the file in the collected manifest; only --config <file> keeps ConfigFile discovery, so non-standard config filenames still work unchanged.
  • config.ts: pass fromConfig = Boolean(maybeConfigPath).
  • command actions (deploy/mod.ts, deploy/create/mod.ts): normalize a positional file argument to its containing directory via a new deployRootDir helper, so the publish manifest (relative(rootPath, …)) and framework detection operate on the project directory rather than the single file — otherwise the now-reachable upload path would produce corrupted manifest keys.

Rejected alternative

Normalizing the positional file to its directory purely in TS before calling resolve_config would also suppress the error without a Rust change, but it leaves resolve_config's "any file = config file" contract implicit/fragile. Making the distinction explicit in Rust keeps that function correct for any caller.

Tests

  • New Rust unit tests in rs_lib/src/lib.rs: positional_file_root_discovers_parent_config (positional main.ts → parent deno.json, file collected, no deserialize error) and explicit_config_flag_uses_named_config_file (--config deno-staging.json still uses ConfigFile discovery).
  • Manually verified the repro: positional entry.ts no longer errors during config resolution (proceeds to auth), and --config <non-standard>.json debug output shows is_config_file=true.

Fixes #107

…file

`deno deploy --org o --app a --prod main.ts` failed with "Failed
deserializing config file '.../main.ts'" because the positional
`[root-path]` was fed into config discovery as a config file whenever it
pointed at a file. Only an explicit `--config <file>` should force
ConfigFile discovery.

`resolve_config` now takes a `from_config` flag: a positional file root
discovers config from its parent directory (Paths) and includes the file
in the upload manifest, while `--config <non-standard-name.json>` keeps
ConfigFile discovery. The command actions also normalize a positional
file argument to its containing directory (`deployRootDir`) so the
publish manifest and framework detection operate on the project rather
than the single file.

Fixes #107
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Treat positional file arguments as deploy roots, not config files

1 participant