This document outlines the implementation of three new CLI commands for LaunchQL's publish flow:
lql validate- Ensure package consistency before bumpinglql sync- Synchronize artifacts with the new bumped versionlql version- Detect changed packages, bump versions, update dependencies, commit and tag
- LaunchQLPackage class (
packages/core/src/core/class/launchql.ts): Core orchestrator for workspace and module management - analyzeModule() method: Comprehensive validation logic for package consistency
- Control file generation (
packages/core/src/files/extension/writer.ts):generateControlFileContent()for PostgreSQL control files - Plan file management (
packages/core/src/files/plan/): Parsing and writing launchql.plan files with tag support - Dependency resolution (
packages/core/src/resolution/deps.ts): Workspace dependency resolution and topological sorting - CLI command patterns (
packages/cli/src/commands/): Consistent structure with usage text, error handling, and logging - Lerna integration (
lerna.json):conventionalCommits: truefor automatic change detection and version bumping
- Yarn workspaces with
packages/*pattern - Independent versioning via lerna
- Workspace dependencies using
workspace:*andworkspace:^semantics - Package.json files in each module with version management
Purpose: Ensure package is consistent before bumping
Implementation Strategy:
- Extend existing
LaunchQLPackage.analyzeModule()method as foundation - Add specific validation checks:
.control.default_version === package.json.version- SQL migration file for current version exists (
sql/<extension>--<version>.sql) launchql.planhas a tag for current version- Dependencies in
launchql.planreference real published versions
- Return exit code 0 if valid, 1 if inconsistencies found
Key Files:
packages/cli/src/commands/validate.ts(new)- Leverage
packages/core/src/core/class/launchql.tsanalyzeModule()
Purpose: Synchronize artifacts with the new bumped version
Implementation Strategy:
- Read
package.jsonversion - Update PostgreSQL control file using
generateControlFileContent() - Write
default_version = '<version>'in<pkg>.control - Generate SQL migration file ensuring
sql/<extension>--<version>.sqlexists - Use existing file creation patterns from LaunchQLPackage
Key Files:
packages/cli/src/commands/sync.ts(new)- Leverage
packages/core/src/files/extension/writer.ts
Purpose: Comprehensive version management workflow
Implementation Strategy:
- Change Detection: Use git operations and lerna's conventional commit parsing
- Version Bumping: Support
--bumpflags (patch|minor|major|prerelease|exact) - Package Updates: Update
package.jsonversions for changed packages - Dependency Management:
- For
workspace:*, do nothing (pnpm resolves at pack time) - For caret ranges, rewrite version ranges (e.g.,
^1.2.3→^1.3.0)
- For
- Synchronization: Run
lql syncper bumped package - Plan Updates: Append plan tags using existing tag management
- Git Operations: Stage + commit with "chore(release): publish" message
- Tagging: Create per-package git tags
name@version
Key Files:
packages/cli/src/commands/version.ts(new)- Leverage dependency resolution from
packages/core/src/resolution/deps.ts - Use plan file writing from
packages/core/src/files/plan/writer.ts
Following existing patterns from packages/cli/src/commands/deploy.ts:
export default async (
argv: Partial<ParsedArgs>,
prompter: Inquirerer,
_options: CLIOptions
) => {
// Usage text handling
if (argv.help || argv.h) {
console.log(usageText);
process.exit(0);
}
// Argument processing and validation
// Core logic using LaunchQLPackage
// Error handling and logging
// Return argv
};- Use
Loggerfrom@launchql/loggerfor consistent logging - Proper exit codes: 0 for success, 1 for errors
- Comprehensive error messages with context
- Usage text for each command following existing patterns
For lql version command, handle workspace dependencies:
- Detection: Use existing dependency resolution to find internal dependencies
- Version Range Updates:
workspace:*→ no change (pnpm handles at pack time)^1.2.3→^1.3.0(update caret ranges between workspace packages)
- Dependency Order: Use topological sorting from existing dependency resolution
- Use
execSyncfor git operations following patterns in codebase - Conventional commit message format: "chore(release): publish"
- Per-package tags in format:
name@version - Single commit for all version updates
packages/cli/src/commands/
├── validate.ts # New: Package validation command
├── sync.ts # New: Artifact synchronization command
├── version.ts # New: Version management command
└── ...existing commands
packages/cli/src/commands.ts # Updated: Add new commands to registry
- Unit Testing: Test each command with valid/invalid scenarios
- Integration Testing: Test full workflow (validate → version → sync)
- Workspace Testing: Test with multiple packages and dependencies
- Git Testing: Verify commit and tagging behavior
- Regression Testing: Ensure existing functionality remains intact
Reuse existing dependencies:
@launchql/core- LaunchQLPackage class and file operations@launchql/logger- Consistent logging@launchql/types- Type definitions and error handlinginquirerer- CLI prompting (following existing patterns)minimist- Argument parsingchild_process- Git operations via execSync
- ✅ Control file
default_versionmatchespackage.jsonversion - ✅ SQL migration file exists for current version
- ✅
launchql.planhas tag for current version - ✅ All dependencies reference valid published versions
- ✅ Exit code 0 for valid packages, 1 for invalid
- ✅ Control file updated with correct version
- ✅ SQL migration file created/updated
- ✅ File operations follow existing patterns
- ✅ Proper error handling for file system operations
- ✅ Changed packages detected correctly
- ✅ Version bumping follows conventional commits or explicit flags
- ✅ Internal dependency ranges updated appropriately
- ✅
lql syncexecuted for each bumped package - ✅ Plan tags appended correctly
- ✅ Single commit with proper message
- ✅ Per-package git tags created
- Backward Compatibility: All changes extend existing functionality without breaking current workflows
- Error Recovery: Comprehensive error handling with clear messages
- Validation: Extensive validation before making changes
- Atomic Operations: Git operations are atomic to prevent partial state
- Testing: Thorough testing of edge cases and error scenarios
- Integration with CI/CD pipelines
- Support for pre-release versions
- Automated changelog generation
- Integration with npm/yarn publish workflows
- Support for custom version bump strategies