feat: add subdirectory support for static build pack - #38
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for deploying static apps whose source lives in a subdirectory of the repo (e.g. frontend/, packages/web/). A new optional subdirectory column on apps flows from the create-app modal through validators into the static build-pack worker steps so that install/build run inside the subdir and verify/copy resolve output paths relative to it.
Changes:
- Adds
apps.subdirectorycolumn (Drizzle migration0006_magenta_polaris), schema export, API service column projection, andcreateAppSchema/updateAppSchemavalidator entry (with slash trimming). - Threads
subdirectorythrough the static build-pack orchestrator intorunInstallStep,runBuildStep,runVerifyStep, and the copy-step path computation, including subdir-aware lockfile detection. - Adds a Subdirectory input to
CreateAppModal(static section) and adds unit/integration tests for the verify and pipeline behavior with a subdirectory set.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| drizzle/0006_magenta_polaris.sql | Migration adding the subdirectory column. |
| drizzle/meta/0006_snapshot.json | Drizzle snapshot reflecting the new column. |
| drizzle/meta/_journal.json | Journal entry for the new migration. |
| packages/shared/src/schema.ts | Declares subdirectory varchar(255) on apps. |
| packages/shared/src/validators/app.ts | Adds subdirectory to schema; trims slashes but no shell/traversal validation. |
| packages/api/src/services/apps.ts | Exposes subdirectory in safeColumns projection. |
| packages/worker/src/deployments/strategies/static.ts | Reads app.subdirectory and passes it to install/build/verify/copy. |
| packages/worker/src/deployments/steps/install-step.ts | Lockfile detection and install command use subdir-prefixed paths. |
| packages/worker/src/deployments/steps/build-step.ts | Build command cds into subdir. |
| packages/worker/src/deployments/steps/verify-step.ts | Resolves target path relative to subdir. |
| packages/web/src/components/CreateAppModal.tsx | Adds Subdirectory input under the static section and includes it in the payload. |
| packages/worker/test/unit/deployments/steps/verify-step.test.ts | Adds verify-step subdirectory cases. |
| packages/worker/test/unit/deployments/pipeline.test.ts | Adds an end-to-end pipeline test with a subdirectory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+25
to
+30
| subdirectory: z | ||
| .string() | ||
| .optional() | ||
| .transform((val) => | ||
| val?.trim() ? val.replace(/^\/+|\/+$/g, "") : undefined, | ||
| ), |
| if (buildPack === "nixpacks") { | ||
| if (runCommand) payload.runCommand = runCommand; | ||
| if (outputDir) payload.outputDir = outputDir; | ||
| if (subdirectory) payload.subdirectory = subdirectory; |
Comment on lines
+154
to
+161
| const outputDir = subdirectory | ||
| ? path.join( | ||
| workspacePath, | ||
| "repo", | ||
| subdirectory, | ||
| app.outputDir ?? "dist", | ||
| ) | ||
| : path.join(workspacePath, "repo", app.outputDir ?? "dist"); |
…rsal - Reject shell meta characters (;|&$()<>) via noShellMeta - Reject .. path components to prevent traversal - Collapse copy-step ternary to single path.join (handles empty subdirectory correctly)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #31