Skip to content

feat(pgpm): add pgpm ls for listing workspace modules - #1841

Merged
pyramation merged 1 commit into
mainfrom
feat/pgpm-ls-command
Sep 17, 2026
Merged

pyramation merged 1 commit into
mainfrom
feat/pgpm-ls-command

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

Adds pgpm ls (alias list) so workspace module discovery is a CLI call instead of shell plumbing. Motivated by the boilerplate CI matrix, which had to discover packages with ls -d packages/*/ | xargs -n1 basename | jq -Rsc ...; that becomes:

- id: list
  run: echo "packages=$(pnpm exec pgpm ls --paths --json)" >> "$GITHUB_OUTPUT"

The command reads new PgpmPackage(cwd).getModuleMap() — so it reports actual pgpm modules (pgpm.plan/.control), not whatever directories happen to sit under packages/, and the paths it emits are workspace-relative.

pgpm ls                  # name  version  path, aligned, sorted by name
pgpm ls --json           # [{ name, version, path, requires }, ...] (pretty)
pgpm ls --names --json   # ["a","b"]           single line, for $(...) capture
pgpm ls --paths --json   # ["packages/a","packages/b"]
pgpm ls --names|--paths  # one per line, plain

Two behaviors worth calling out:

  • --json mode writes nothing to stdout but the JSON, so CI can capture stdout verbatim.
  • Outside a workspace it exits non-zero via cliExitWithError even with --json — a broken discover step must fail the job rather than silently yield []. An empty-but-valid workspace still prints [].

ls/list are registered in the engine-exempt set: the command never touches Postgres.

Consumed by constructive-io/pgpm-boilerplates#53.

Link to Devin session: https://app.devin.ai/sessions/dd4055c50bcf4b1e8e604211038aaa82
Open in Devin Desktop: https://app.devin.ai/desktop/session/dd4055c50bcf4b1e8e604211038aaa82?variant=devin
Requested by: @pyramation

@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

@tenki-reviewer

tenki-reviewer Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Review complete. No blocking issues — approved ✅; 1 nitpick below.

🧹 Nitpicks (1) — 🟢 1 low
  • 🟢 Missing trailing newline in --json --names/--paths (ls.ts:70) — With json set, the --names and --paths branches write JSON.stringify(...) without a trailing newline (pgpm/cli/src/commands/ls.ts:70, :74), while the full --json object branch appends one (:77) and other CLI JSON output uses console.log.

This PR introduces a new pgpm ls command in pgpm/cli/src/commands/ls.ts that discovers modules via workspace.getModuleMap(), sorts them by name, and emits them in four output modes (column-aligned text, --names, --paths, and --json), wiring it into the CLI router in commands.ts and index.ts, with a corresponding test suite in ls.test.ts.

Files Change
pgpm/cli/src/commands/ls.ts New command implementing module listing with text/names/paths/JSON output modes and flag-conflict handling
pgpm/cli/src/commands.ts, pgpm/cli/src/index.ts Route and register the new ls command in the CLI
pgpm/cli/__tests__/ls.test.ts Adds fixtures-based tests covering the different output modes and the empty-workspace path
.agents/skills/pgpm/references/cli.md Documents the new ls command usage and options

Reviewed commit: 5bed508

@pyramation
pyramation merged commit c8ae99b into main Sep 17, 2026
21 checks passed
@pyramation
pyramation deleted the feat/pgpm-ls-command branch September 17, 2026 04:01
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