Skip to content

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Dec 26, 2025

feat(cli): separate cnc and pgpm CLIs - hard separation

Summary

This PR implements a hard separation between cnc (Constructive CLI) and pgpm (PostgreSQL Package Manager) to eliminate branding confusion.

Before: cnc included all 22+ pgpm commands plus GraphQL commands
After: cnc only has 4 GraphQL-focused commands: server, explorer, codegen, get-graphql-schema

Key changes:

  • Removed pgpm command spreading from cnc CLI entry point
  • Created local utility files to replace pgpm imports (argv.ts, cli-error.ts, update-check.ts)
  • Rewrote README.md to focus only on GraphQL commands
  • Updated QUICKSTART.md and AGENTS.md to use pgpm for database operations
  • Moved all pgpm-related tests from packages/cli to pgpm/cli - complete test infrastructure separation
  • Created pgpm/cli/test-utils with fixtures, CLI helpers, and TestDatabase
  • Cleaned up packages/cli/test-utils to only support cnc GraphQL commands

Updates since last revision

  • Complete test separation: Moved 13 pgpm test files from packages/cli/__tests__ to pgpm/cli/__tests__
  • Created pgpm/cli/test-utils/ with CLIDeployTestFixture, fixtures, cli helpers, and init-argv utilities
  • Removed unused test utilities from packages/cli (CLIDeployTestFixture, TestDatabase, init-argv)
  • packages/cli/__tests__ now only contains GraphQL tests: codegen.test.ts, get-graphql-schema.test.ts, cli.test.ts
  • No more cross-package imports (e.g., ../../../pgpm/cli/src/commands) in test code
  • Removed obsolete snapshot files that were causing CI failures (Jest was detecting orphaned snapshots from moved tests)
  • Updated packages/cli/AGENTS.md to remove outdated references to createPgpmCommandMap() and PGPM command delegation

Review & Testing Checklist for Human

This is a breaking change that affects all users who were using cnc for database operations.

  • Verify CLI commands work: Run cnc server, cnc explorer, cnc codegen, and cnc get-graphql-schema to confirm they still function
  • Verify pgpm commands removed: Confirm that running cnc deploy, cnc init, etc. now shows "Unknown command" error
  • Verify tests run in both packages: Run pnpm test in both packages/cli and pgpm/cli to ensure test separation is correct
  • Review update-check.ts: This is a new implementation that stores config in ~/.constructive/. Verify the version comparison logic and file-based caching work correctly

Recommended test plan:

  1. Install the CLI locally: cd packages/cli && pnpm link --global
  2. Run cnc --help and verify only 4 commands are shown
  3. Run cnc server in a workspace with a database to verify GraphQL server works
  4. Run cnc deploy and verify it fails with "Unknown command: deploy"
  5. Run cd pgpm/cli && pnpm test to verify pgpm tests pass
  6. Run cd packages/cli && pnpm test to verify cnc tests pass

Notes

  • The new utility files are simplified reimplementations - they don't have all the features of the pgpm versions but should be sufficient for cnc's needs
  • Users will need to install both @constructive-io/cli and pgpm for the complete workflow
  • Test utilities are now duplicated between packages - this is intentional to maintain hard separation
  • Local testing confirmed: cnc --help shows only 4 commands, cnc deploy correctly fails with "Unknown command"
  • @pgpmjs/logger and @pgpmjs/types remain as dependencies in packages/cli - these are legitimately used by the GraphQL commands (server, explorer)

Link to Devin run: https://app.devin.ai/sessions/e847fee58b144d5fa6a7c390d5d9b760
Requested by: Dan Lynch (@pyramation)

- Remove all pgpm commands from cnc CLI, keeping only GraphQL commands:
  - server, explorer, codegen, get-graphql-schema
- Create local utility files to replace pgpm dependencies:
  - argv.ts, cli-error.ts, update-check.ts
- Update usage text to only show GraphQL commands
- Update README.md to focus on GraphQL commands and reference pgpm
- Update QUICKSTART.md to use pgpm for database operations
- Update AGENTS.md to clarify the separation
- Update tests to use pgpm instead of cnc for database commands

This eliminates branding confusion between cnc (GraphQL server/tools)
and pgpm (PostgreSQL package manager/migrations).
@devin-ai-integration
Copy link
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 and CI monitoring

The test fixture now routes pgpm commands to the pgpm CLI,
allowing tests to use pgpm for database operations while
cnc is used only for GraphQL commands.
Use relative import path to pgpm/cli/src/commands instead of
the pgpm package which doesn't export the commands function.
Tests for pgpm functionality (init, add, extension, package) now
import commands from pgpm/cli/src/commands instead of cnc's
commands since these operations are no longer available in cnc.
Complete separation of test infrastructure:
- Move all pgpm-related tests from packages/cli to pgpm/cli
- Create pgpm/cli/test-utils with fixtures, CLI helpers, and TestDatabase
- Clean up packages/cli test-utils to only support cnc GraphQL commands
- Remove unused test utilities from packages/cli (CLIDeployTestFixture, init-argv)
- Keep only GraphQL tests in packages/cli (codegen, get-graphql-schema, cli)

This ensures no cross-package imports between cnc and pgpm test code.
Remove snapshot files that belonged to tests that were moved:
- packages/cli: remove pgpm test snapshots (add, extensions, init.install, init, package)
- pgpm/cli: remove cli.test.ts.snap (was copied but not needed)
Remove outdated references to createPgpmCommandMap() and PGPM command delegation.
Update documentation to reflect that cnc now only has 4 GraphQL commands.
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.

2 participants