Skip to content

feat(pgpm): add --pglite flag to init with workspace inheritance#1354

Closed
pyramation wants to merge 1 commit into
mainfrom
feat/pgpm-init-pglite
Closed

feat(pgpm): add --pglite flag to init with workspace inheritance#1354
pyramation wants to merge 1 commit into
mainfrom
feat/pgpm-init-pglite

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

Adds a --pglite flag to pgpm init that scaffolds from the pglite-boilerplates repo (in-process WASM Postgres, no server/Docker) instead of the default pgpm-boilerplates. The key UX win is inheritance: use --pglite once when creating the workspace, and later bare pgpm init calls inside it scaffold pglite modules automatically — no need to repeat the flag.

pgpm init workspace --pglite   # records the source in the workspace pgpm.json
pgpm init                      # inside that workspace → inherits pglite, no flag
pgpm init --pglite | --repo …  # explicit flags still override the inherited default

How it works

--pglite is pure sugar over --repo (with --repo winning):

resolveInitTemplateRepo({ repo, pglite }) => { templateRepo, repoWasExplicit }
//   --repo X            → X,                     explicit
//   --pglite            → PGLITE_TEMPLATE_REPO,  explicit
//   (neither)           → DEFAULT_TEMPLATE_REPO, not explicit

Persistence + inheritance:

  • handleWorkspaceInit: after scaffolding, if templateRepo !== DEFAULT_TEMPLATE_REPO, write a boilerplates: { repo, branch?, dir? } field into the workspace pgpm.json.
  • handleModuleInit: when !repoWasExplicit, read the enclosing workspace's boilerplates and use it as the template source. Explicit --pglite/--repo skips inheritance.

One supporting fix in resolveWorkspaceTemplateRepo (the -w combined path): for a non-default (single-family) repo, leave the variant dir undefined so the repo's own .boilerplates.json resolves it (e.g. pglite/), instead of forcing dir = workspaceType which only makes sense for the multi-family default repo.

Supporting changes

  • @pgpmjs/core: new PGLITE_TEMPLATE_REPO constant.
  • @pgpmjs/types: new optional PgpmWorkspaceConfig.boilerplates field.
  • New pgpm/cli/src/commands/init/boilerplate.ts holds the resolve/persist/read helpers (unit-testable, no network).

Tests

  • init.boilerplate.test.ts — unit tests for flag resolution + persist/read round-trip (network-free).
  • init.test.ts — a gated end-to-end test (skipped in CI like the sibling --repo/--create-workspace tests): init workspace --pglite records the pglite repo, then bare init inherits it and scaffolds a module using pglite-test (not pgsql-test). Verified locally against the live boilerplate repos.

Not in this PR

Wiring --pglite into deploy/verify/revert via the pluggable driver contract (#1352) is a separate follow-up; this PR is scaffolding-only.

Link to Devin session: https://app.devin.ai/sessions/424b76f81a60499493ac946b57136ad9
Requested by: @pyramation

- --pglite is sugar for the pglite-boilerplates template repo (--repo overrides)
- workspace init records the chosen boilerplate source in pgpm.json
- bare `pgpm init` inside a pglite workspace inherits that source automatically
- custom/single-family repos let .boilerplates.json resolve the variant dir

Adds PGLITE_TEMPLATE_REPO constant and PgpmWorkspaceConfig.boilerplates field.
@pyramation pyramation self-assigned this Jul 11, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Consolidated into #1358 per request to reduce open PR count. Same commits, merged into one branch.

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