Skip to content

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Dec 27, 2025

fix(pgpm): use workspace-level module detection for export flow

Summary

Fixes "Not inside a module" error when running pgpm export from workspace root.

The previous implementation called getInstalledModules() which requires being inside a module directory. This PR:

  1. Adds getWorkspaceInstalledModules() method to PgpmPackage that scans workspace/extensions/ directly without requiring module context
  2. Splits the module detection/installation flow:
    • detectMissingModules() - workspace-level detection + user prompt (before module creation)
    • installMissingModules() - module-level installation (after module creation)
  3. Updates preparePackage() to return the module directory path for use in installation
  4. Extracts EXTENSIONS_DIR constant to centralize the extensions directory name

Updates since last revision

  • Added EXTENSIONS_DIR constant at module level to avoid hardcoding 'extensions' string in multiple places
  • Updated installModules(), getInstalledModules(), and getWorkspaceInstalledModules() to use the constant

Review & Testing Checklist for Human

  • Test the fix: Run pgpm export from workspace root and verify it no longer throws "Not inside a module" error
  • Verify scoped package detection: Check that getWorkspaceInstalledModules() correctly detects packages like @pgpm/base32 in extensions/@pgpm/base32/
  • Verify installation still works: If you have missing modules, confirm the install prompt works and modules are installed into the correct module's package.json
  • Check for other callers: Verify no other code depends on preparePackage() returning void

Recommended test plan:

  1. Navigate to a pgpm workspace root (not inside a module)
  2. Run pgpm export with a database that has migrations
  3. Confirm the export completes without "Not inside a module" error
  4. If prompted to install missing modules, confirm they install correctly

Notes

  • This fix was not E2E tested due to lack of database seed data
  • The flow change (detect before module creation, install after) is intentional to satisfy both workspace-level detection and module-level installation requirements

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

- Add getWorkspaceInstalledModules() method to PgpmPackage that scans
  workspace/extensions/ directory without requiring module context
- Split promptAndInstallMissingModules into detectMissingModules (workspace-level)
  and installMissingModules (module-level)
- Move installation to after preparePackage creates the module
- Fixes 'Not inside a module' error when running pgpm export from workspace root
@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

- Add EXTENSIONS_DIR constant for workspace extensions directory name
- Update installModules, getInstalledModules, and getWorkspaceInstalledModules to use constant
- Improves maintainability by centralizing the directory name
@pyramation pyramation merged commit 1b19a8c into main Dec 27, 2025
34 checks passed
@pyramation pyramation deleted the devin/1766803205-fix-workspace-module-check branch December 27, 2025 03:26
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