contentful-migration
Version:
Migration tooling for contentful
100 lines • 3.58 kB
JavaScript
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const path = __importStar(require("path"));
const fs = __importStar(require("fs"));
const yargs = __importStar(require("yargs"));
const { version } = require('../../package.json');
exports.default = yargs
.usage('Parses and runs a migration script on a Contentful space.\n\nUsage: contentful-migration [args] <path-to-script-file>\n\nScript: path to a migration script.')
.demandCommand(1, 'Please provide the file containing the migration script.')
.check((args) => {
const filePath = path.resolve(process.cwd(), args._[0].toString());
if (fs.existsSync(filePath)) {
args.filePath = filePath;
return true;
}
throw new Error(`Cannot find file ${filePath}.`);
})
.version(version || 'Version only available on installed package')
.option('space-id', {
alias: 's',
describe: 'ID of the space to run the migration script on'
})
.option('environment-id', {
alias: 'e',
describe: 'ID of the environment within the space to run the migration script on',
default: 'master'
})
.option('access-token', {
alias: 'a',
describe: 'The access token to use\nThis takes precedence over environment variables or .contentfulrc'
})
.option('proxy', {
describe: 'Proxy configuration in HTTP auth format: [http|https]://host:port or [http|https]://user:password@host:port',
type: 'string'
})
.option('raw-proxy', {
describe: 'Pass proxy config to Axios instead of creating a custom httpsAgent',
type: 'boolean',
default: false
})
.option('yes', {
alias: 'y',
boolean: true,
describe: 'Skips any confirmation before applying the migration script',
default: false
})
.option('quiet', {
alias: 'q',
boolean: false,
describe: 'Reduce verbosity of information for the execution',
default: false
})
.option('request-batch-size', {
alias: 'l',
boolean: false,
describe: 'Batch size per request',
type: 'number',
default: 100
})
.option('request-limit', {
alias: 'r',
boolean: false,
describe: 'Max requests per second',
type: 'number',
default: 10
})
.option('header', {
alias: 'H',
type: 'string',
describe: 'Pass an additional HTTP Header'
})
.demandOption(['space-id'], 'Please provide a space ID')
.help('h')
.alias('h', 'help')
.example('contentful-migration', '--space-id abcedef my-migration.js')
.strict().argv;
//# sourceMappingURL=usage-params.js.map