Skip to content

feat(app): revised deploy path#24

Merged
luanvdw merged 8 commits into
mainfrom
feat/j1-deploy-setup
May 22, 2026
Merged

feat(app): revised deploy path#24
luanvdw merged 8 commits into
mainfrom
feat/j1-deploy-setup

Conversation

@luanvdw
Copy link
Copy Markdown
Member

@luanvdw luanvdw commented May 21, 2026

Summary

  • Add the J1 deploy setup flow: infer Project, Branch, App, Framework, and Runtime before deploy.
  • Skip first-deploy app prompts when there is no real choice, and create the inferred app directly.
  • Add --framework / --branch, keep --build-type as legacy passthrough, and default runtime HTTP port to 3000.
  • Update product docs and tests for the new deploy contract.

Adds the J1 local resolution pin model for app deploy.

  • Writes .prisma/local.json after the first successful deploy.
  • Reads and validates the pin on later deploys.
  • Supports PRISMA_PROJECT_ID / PRISMA_APP_ID env overrides.
  • Adds LOCAL_STATE_STALE when the local pin points at deleted/inaccessible platform state.
  • Auto-ignores .prisma/ for the per-user local pin.

Linear

Verification

  • pnpm --filter @prisma/cli build
  • pnpm --filter @prisma/cli test

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Review Change Stack

Warning

Rate limit exceeded

@luanvdw has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 24 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 91c92f29-a32a-43eb-ad8b-db98a9a45364

📥 Commits

Reviewing files that changed from the base of the PR and between df71761 and 4b0d52a.

📒 Files selected for processing (5)
  • docs/product/resource-model.md
  • packages/cli/src/lib/app/preview-provider.ts
  • packages/cli/src/lib/project/local-pin.ts
  • packages/cli/tests/app-controller.test.ts
  • packages/cli/tests/app-provider.test.ts

Walkthrough

This PR adds branch- and framework-aware deploy resolution, new CLI flags (--branch, --framework), local directory pinning via .prisma/local.json, branch-scoped preview app management, updated presenters/docs, and broad test updates for first-deploy inference and ambiguity/error handling.

Changes

App deploy with local pin binding and context resolution

Layer / File(s) Summary
Docs & output conventions
docs/product/command-spec.md, docs/product/error-conventions.md, docs/product/output-conventions.md, docs/product/resource-model.md
Documents new resolution order (Project→Branch→App), new CLI flag surface, APP_AMBIGUOUS/FRAMEWORK_NOT_DETECTED error codes, and first-run vs subsequent-run deploy output rules.
CLI flags, examples & prompts
packages/cli/src/commands/app/index.ts, packages/cli/src/shell/command-meta.ts, packages/cli/src/shell/prompt.ts, packages/cli/src/lib/app/preview-interaction.ts
Adds --branch and --framework, hides legacy --build-type, updates examples, and adds a confirmPrompt helper; removes a hardcoded placeholder from the app-name prompt.
Types & presenters
packages/cli/src/types/app.ts, packages/cli/src/types/project.ts, packages/cli/src/presenters/app.ts, packages/cli/src/presenters/project.ts
Adds AppDeployResult.localPin, expands ProjectSource/ProjectResolution with targetName/targetNameSource, presents local-pin binding message in deploy output, and maps new project source labels.
Local resolution pin storage
packages/cli/src/lib/project/local-pin.ts
New helpers to read/write .prisma/local.json atomically, validate its shape, and ensure .prisma/ is in .gitignore.
Project target inference & remembered resolution
packages/cli/src/lib/project/resolution.ts
Adds inferTargetName(cwd), new inferred-name types, refactors remembered-resolution to carry targetName/targetNameSource and handles stale remembered pins.
Deploy controller: branch/framework/runtime resolution
packages/cli/src/controllers/app.ts
Refactors runAppDeploy to read env/project overrides, validate/read local pin, resolve branch (flag/git/main), detect/resolve framework (flag/legacy/detection), determine runtime HTTP port, preview settings with optional first-deploy customization, and parse repeated --env assignments.
App selection & ambiguity handling
packages/cli/src/controllers/app.ts
Introduces resolveDeployAppSelection and resolveAmbiguousDeployApp to return multiple candidates, support interactive pick/create, or throw structured APP_AMBIGUOUS in non-interactive/JSON mode.
Branch-aware preview apps & provider helpers
packages/cli/src/lib/app/preview-provider.ts
Extends preview provider to accept branch filters, include branchId in records, list/create branch-linked compute services, and deploy a branch-scoped service via management API helpers.
List/logs/promote/rollback/remove wiring
packages/cli/src/controllers/app.ts
Makes listApps branch-aware and threads branchName into app listing for update-env, list-env, list-deploys, show, open, logs, promote, rollback, and remove flows.
Tests: controller, provider, help output
packages/cli/tests/app-controller.test.ts, packages/cli/tests/app-env-vars.test.ts, packages/cli/tests/app.test.ts, packages/cli/tests/project.test.ts, packages/cli/tests/app-provider.test.ts
Updates tests to the new runAppDeploy signature and behavior, adds filesystem test helpers, validates first-deploy inference and local-pin side effects, adapts help-output assertions to --framework, and adds branch-scoped provider tests.

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(app): revised deploy path' clearly and concisely summarizes the main change: a revised deployment flow for the app command with new setup and inference logic.
Description check ✅ Passed The description comprehensively details the changeset including the J1 deploy setup flow, local resolution pin implementation, new flags, documentation updates, and related Linear issues.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/j1-deploy-setup
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/j1-deploy-setup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@luanvdw luanvdw marked this pull request as ready for review May 22, 2026 05:30
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
docs/product/command-spec.md (1)

74-82: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Document env override precedence in context resolution.

PRISMA_PROJECT_ID / PRISMA_APP_ID override behavior is missing from the Project/App resolution orders, so the public contract is incomplete for CI/headless usage.

📝 Suggested doc update
 Commands resolve project context in this order:

 1. explicit `--project <id-or-name>` when present
-2. durable platform mapping when available
-3. remembered local project context, revalidated against platform data
-4. `package.json` name matched exactly against accessible project id, name, or slug
-5. unambiguous project creation for commands that are allowed to create projects
-6. prompt in interactive mode, or structured failure in `--json` / `--no-interactive` mode
+2. `PRISMA_PROJECT_ID` when set
+3. durable platform mapping when available
+4. remembered local project context, revalidated against platform data
+5. `package.json` name matched exactly against accessible project id, name, or slug
+6. unambiguous project creation for commands that are allowed to create projects
+7. prompt in interactive mode, or structured failure in `--json` / `--no-interactive` mode

 Preview app commands that need an app resolve it in this order:

 1. `--app <name>`
-2. locally selected app for the resolved project when it still exists
-3. inferred app name from `package.json#name`
-4. current directory name
-5. create the inferred app when no existing app matches
-6. interactive picker only when multiple matching apps make the target ambiguous
-7. `APP_AMBIGUOUS` in non-interactive or `--json` mode when unresolved
+2. `PRISMA_APP_ID` when set
+3. locally selected app for the resolved project when it still exists
+4. inferred app name from `package.json#name`
+5. current directory name
+6. create the inferred app when no existing app matches
+7. interactive picker only when multiple matching apps make the target ambiguous
+8. `APP_AMBIGUOUS` in non-interactive or `--json` mode when unresolved

Also applies to: 89-97

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/product/command-spec.md` around lines 74 - 82, The docs omit
environment-variable overrides: add PRISMA_PROJECT_ID and PRISMA_APP_ID into the
context-resolution precedence so they are considered (immediately after an
explicit --project <id-or-name> flag), shift subsequent steps down accordingly,
and mirror the same change in the equivalent section later in the file; ensure
the text explicitly names PRISMA_PROJECT_ID / PRISMA_APP_ID and how they
interact with --project, durable platform mapping, remembered local context,
package.json name matching, creation, and interactive/JSON fallback.
packages/cli/src/presenters/project.ts (1)

119-138: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Missing case for "directory-name" projectSource.

The formatProjectSource switch handles "package-name" but not "directory-name", which is a valid InferredTargetNameSource that can be assigned to projectSource via the resolution flow (e.g., when a project is created from the directory name).

If projectSource is "directory-name", the function will reach the end without matching any case. In TypeScript strict mode with noImplicitReturns, this would be a compile error, but if not enforced, it returns undefined.

Proposed fix
   case "package-name":
     return "package name";
+  case "directory-name":
+    return "directory name";
   case "created":
     return "created";
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/presenters/project.ts` around lines 119 - 138, The switch in
formatProjectSource is missing the "directory-name" case causing undefined
returns; update formatProjectSource (which takes
ProjectShowResult["resolution"]["projectSource"]) to include case
"directory-name" and return a human-readable label (e.g., "directory name") and
ensure the switch is exhaustive so the function always returns a string.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/product/command-spec.md`:
- Line 480: The docs for the `prisma-cli app deploy` command were updated to
remove the `--entry <path>` flag but the CLI still exposes `--entry`, causing
spec/CLI drift; update the command signature in docs/product/command-spec.md to
include `--entry <path>` (or, if the flag was intentionally removed, update the
CLI implementation to remove the `--entry` flag from the `prisma-cli app deploy`
command) so the documentation and the actual CLI flags for `prisma-cli app
deploy --project --app --branch --framework --http-port --env` match; reference
the `--entry` flag and the `prisma-cli app deploy` command when making the
change.

In `@packages/cli/src/controllers/app.ts`:
- Around line 2012-2039: The detection regex in detectNextConfig currently only
matches output: "standalone" and can miss template literals; update the regex
used in detectNextConfig (the /\boutput\s*:\s*["']standalone["']/ test) to also
accept backtick-quoted values and tolerate surrounding whitespace (e.g., match
output: `standalone` as well as "standalone" and 'standalone'); keep behavior
unchanged for non-literal values (variables) and leave the rest of the function
logic intact.
- Line 219: The second call to assertSupportedEntrypoint after
maybeCustomizeDeploySettings is redundant because maybeCustomizeDeploySettings
only switches frameworks within DEPLOY_FRAMEWORKS (nextjs, hono, tanstack-start)
which already have valid buildType values; remove the duplicate
assertSupportedEntrypoint(framework.buildType, options?.entrypoint, "deploy")
that appears after maybeCustomizeDeploySettings and instead add a short
clarifying comment next to maybeCustomizeDeploySettings (and/or above
DEPLOY_FRAMEWORKS) stating that customization is limited to those frameworks and
thus the second assertion is unnecessary; reference the functions/assertion
names assertSupportedEntrypoint, maybeCustomizeDeploySettings and the
DEPLOY_FRAMEWORKS constant when making the change.
- Around line 1899-1903: The empty catch block that checks (error as
NodeJS.ErrnoException).code !== "EISDIR" && !== "EACCES" currently swallows all
other errors; update that catch to log unexpected errors instead of ignoring
them: inside the catch (error) block keep the existing check for EISDIR/EACCES
but for any other error call the CLI logger (e.g., processLogger.trace or
processLogger.debug) with the error and a short context message so unexpected
I/O or permission errors are visible while still allowing the code to "try the
normal directory shape below" as before.

---

Outside diff comments:
In `@docs/product/command-spec.md`:
- Around line 74-82: The docs omit environment-variable overrides: add
PRISMA_PROJECT_ID and PRISMA_APP_ID into the context-resolution precedence so
they are considered (immediately after an explicit --project <id-or-name> flag),
shift subsequent steps down accordingly, and mirror the same change in the
equivalent section later in the file; ensure the text explicitly names
PRISMA_PROJECT_ID / PRISMA_APP_ID and how they interact with --project, durable
platform mapping, remembered local context, package.json name matching,
creation, and interactive/JSON fallback.

In `@packages/cli/src/presenters/project.ts`:
- Around line 119-138: The switch in formatProjectSource is missing the
"directory-name" case causing undefined returns; update formatProjectSource
(which takes ProjectShowResult["resolution"]["projectSource"]) to include case
"directory-name" and return a human-readable label (e.g., "directory name") and
ensure the switch is exhaustive so the function always returns a string.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: fab7b1be-624c-4281-9359-ec97a1644201

📥 Commits

Reviewing files that changed from the base of the PR and between 8399f34 and 32b7155.

📒 Files selected for processing (18)
  • docs/product/command-spec.md
  • docs/product/error-conventions.md
  • docs/product/output-conventions.md
  • packages/cli/src/commands/app/index.ts
  • packages/cli/src/controllers/app.ts
  • packages/cli/src/lib/app/preview-interaction.ts
  • packages/cli/src/lib/project/local-pin.ts
  • packages/cli/src/lib/project/resolution.ts
  • packages/cli/src/presenters/app.ts
  • packages/cli/src/presenters/project.ts
  • packages/cli/src/shell/command-meta.ts
  • packages/cli/src/shell/prompt.ts
  • packages/cli/src/types/app.ts
  • packages/cli/src/types/project.ts
  • packages/cli/tests/app-controller.test.ts
  • packages/cli/tests/app-env-vars.test.ts
  • packages/cli/tests/app.test.ts
  • packages/cli/tests/project.test.ts
💤 Files with no reviewable changes (1)
  • packages/cli/src/lib/app/preview-interaction.ts

Comment thread docs/product/command-spec.md Outdated
Comment thread packages/cli/src/controllers/app.ts
Comment thread packages/cli/src/controllers/app.ts Outdated
Comment thread packages/cli/src/controllers/app.ts
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/product/resource-model.md`:
- Around line 217-220: Update the paragraph about `.prisma/local.json` and
branch resolution to explicitly state that if neither explicit targeting nor
Git-derived branch information is available, deploy resolution falls back to the
`main` branch; mention that the local pin still binds the directory to a
Workspace and Project and that apps are then resolved within that (fallback)
branch to avoid accidental deployment of feature-branch code into services owned
by `main`.

In `@packages/cli/src/lib/app/preview-provider.ts`:
- Around line 550-560: The POST to create compute-service in createBranchApp can
race and return a conflict; update the logic around
client.POST("/v1/compute-services", ...) in createBranchApp to handle 409
Conflict by catching the error (result.error || !result.data), and on 409 call
the existing GET/list endpoint for compute services (or re-fetch by
branchId/displayName) to return the already-created service instead of throwing
apiCallError; only throw apiCallError for non-409 errors or if the subsequent
lookup still fails.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 135f6c8e-bbed-4bcd-b660-0a24f245c06d

📥 Commits

Reviewing files that changed from the base of the PR and between 32b7155 and df71761.

📒 Files selected for processing (8)
  • docs/product/command-spec.md
  • docs/product/resource-model.md
  • packages/cli/src/controllers/app.ts
  • packages/cli/src/lib/app/preview-provider.ts
  • packages/cli/src/lib/project/local-pin.ts
  • packages/cli/src/presenters/project.ts
  • packages/cli/tests/app-controller.test.ts
  • packages/cli/tests/app-provider.test.ts

Comment thread docs/product/resource-model.md Outdated
Comment thread packages/cli/src/lib/app/preview-provider.ts
@luanvdw
Copy link
Copy Markdown
Member Author

luanvdw commented May 22, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@luanvdw luanvdw merged commit 5c904fa into main May 22, 2026
4 checks passed
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.

1 participant