abstract-migrate
Version:
Storage-agnostic migration runner
49 lines (31 loc) • 2.81 kB
JavaScript
;
var _commander = require('commander');
var _commander2 = _interopRequireDefault(_commander);
var _action = require('./action');
var _action2 = _interopRequireDefault(_action);
var _config = require('./config');
var _config2 = _interopRequireDefault(_config);
var _commands = require('./commands');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function setSetting(settingName, valueToSet) {
return function applySetting(value) {
_config2.default[settingName] = valueToSet !== undefined ? valueToSet : value;
};
}
_commander2.default.version('0.1.0').usage('perform migrations').option('-c, --config <path>', 'the path to the config file', _config.loadConfig, (0, _config.loadConfig)()).option('-r, --require <file>', 'require file before running', setSetting('require')).option('-e, --engine <module>', 'the storage engine', setSetting('engine')).option('-C, --no-color', 'turn off color output', setSetting('noColor', true)).option('--debug', 'more verbose output', setSetting('debug', true));
_commander2.default.command('create <name>').description('creates a new migration using the given name prepended with the current timestamp').action((0, _action2.default)(_commands.create));
_commander2.default.command('up [migration|num]').description('runs all of the migrations (optionally only up to and including a named one or count)').option('-p, --ignore-past', 'ignore old migrations from the past that have not ran yet').option('-d, --dry-run', 'lists the migrations that will be executed').option('-o, --only', 'only run the specified migration').action((0, _action2.default)(_commands.up));
_commander2.default.command('down <migration|num>').description('runs the migrations down to and including the named one or specified count').option('-d, --dry-run', 'lists the migrations that will be executed').option('-o, --only', 'only run the specified migration').action((0, _action2.default)(_commands.down));
_commander2.default.command('rollback').description('runs down the last set of migrations that were ran').option('-d, --dry-run', 'lists the migrations that will be executed').action((0, _action2.default)(_commands.rollback));
_commander2.default.command('list').alias('ls').description('lists out all of the migrations and their status').action((0, _action2.default)(_commands.list));
_commander2.default.on('--help', function () {
console.log(' Documentation:');
console.log('');
console.log(' Complete documentation, including engine documentation, can be found on the Github page:');
console.log(' https://github.com/bharley/abstract-migrate');
console.log('');
});
_commander2.default.parse(process.argv);
if (!process.argv.slice(2).length) {
_commander2.default.outputHelp();
}