@magic-mustard/sqlsync
Version:
SQLSync simplifies database schema evolution by allowing a declarative approach to table management
32 lines (31 loc) • 1.41 kB
JavaScript
;
// cli/generate.ts
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GenerateCommand = void 0;
const chalk_1 = __importDefault(require("chalk"));
/**
* CLI command for parsing 'generate' arguments only.
* Returns a structured object for the entrypoint to handle orchestration.
*/
class GenerateCommand {
register(program) {
program
.command('generate <migration-name>')
.description('Generate a new migration file based on changes in SQL definitions')
.option('--no-mark-applied', 'Do not mark the generated migration as locally applied')
.action((migrationName, options) => {
const generateOpts = {
migrationName,
markApplied: options.markApplied !== false, // default = true
};
// Instead of orchestration, return a structured object
console.log(chalk_1.default.green(`Parsed generate command: ${JSON.stringify(generateOpts)}`));
// In a real CLI, this would return or pass the object to the entrypoint, not run logic here.
// e.g., process.emit('cliCommand', { command: 'generate', args: generateOpts });
});
}
}
exports.GenerateCommand = GenerateCommand;