dynamit-cli
Version:
The DynamoDB migrations tool CLI
47 lines (46 loc) • 1.57 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ramda_1 = require("ramda");
const migrator_1 = require("./migrator");
function baseOptions(yargs) {
return yargs
.option('migrations-path', {
describe: 'The path to the migrations folder',
default: 'migrations',
type: 'string'
})
.option('access-key-id', {
describe: 'AWS access key id',
type: 'string'
})
.option('secret-access-key', {
describe: 'AWS secret access key',
type: 'string'
})
.option('region', {
describe: 'AWS service region',
type: 'string'
})
.option('endpoint-url', {
describe: 'The DynamoDB endpoint url to use. The DynamoDB local instance url could be specified here.',
type: 'string'
})
.option('table-name', {
describe: 'The DynamoDB table name',
default: 'migrations',
type: 'string'
})
.option('attribute-name', {
describe: 'The DynamoDB primaryKey attribute name',
default: 'name',
type: 'string'
});
}
exports.baseOptions = baseOptions;
function baseHandler(callback) {
return (args) => {
const migrator = new migrator_1.Migrator(Object.assign(Object.assign({}, ramda_1.pick(['region', 'accessKeyId', 'secretAccessKey', 'endpointUrl'], args)), { tableName: args.tableName, attributeName: args.attributeName, migrationsPath: args.migrationsPath }));
callback(args, migrator);
};
}
exports.baseHandler = baseHandler;