Skip to content

Conversation

@pyramation
Copy link
Contributor

Summary

Fixes an issue where pgpm deploy --createdb would log "No modules found in the specified directory" but continue executing instead of stopping. The deploy command now properly handles the error case and uses consistent module discovery with the core deploy logic.

Key changes:

  1. Error handling: Deploy now stops execution when selectPackage returns undefined (no modules found)
  2. Module discovery: Changed selectPackage to use getModuleMap() instead of getModules() - the former scans for .control files directly while the latter uses pgpm.json patterns, which could miss nested modules
  3. Context-aware selection: Added logic to detect if running from inside a module (use current module) vs workspace root (prompt for selection), similar to the tag.ts command pattern
  4. Flag bug fixes: Fixed fast and logOnly flags which were incorrectly defaulting to true when not specified

Review & Testing Checklist for Human

  • Test from startkit-example-workspace root: Run pgpm deploy --createdb --database testdb and verify it now prompts for package selection instead of showing error then continuing
  • Test from inside a module directory: Verify deploy uses the current module automatically without prompting
  • Test with --package flag: Verify pgpm deploy --package mymodule works correctly
  • Verify logOnly behavior: Run deploy without --logOnly flag and confirm it actually executes SQL (not just logging)
  • Check nested workspace scenarios: The module discovery change (getModuleMap vs getModules) could behave differently in complex workspace structures

Notes

The root cause was a mismatch between how the CLI discovers modules (getModules() using pgpm.json patterns) vs how core deploy discovers them (getModuleMap() scanning for .control files). In nested workspaces like startkit-example-workspace, the CLI would find no modules while core deploy would find them via .control file scanning.

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

… module discovery

- Fix deploy command to handle undefined return from selectPackage by
  stopping execution with an error message instead of continuing
- Add context-aware package selection (similar to tag.ts pattern):
  - Use --package if explicitly specified
  - Use current module if running from inside a module
  - Prompt for package selection if in workspace with recursive mode
- Fix selectPackage to use getModuleMap() instead of getModules() for
  consistency with how core deploy discovers modules (via .control files)
- Fix logOnly and fast flags to use prompted values instead of argv values
  (was causing logOnly to default to true when flag was absent)
@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

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