Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const run = async ({
spaceId, environmentId, accessToken, dryRun, migrationFunction
}) => {
const config = { spaceId, environmentId, accessToken }
const clientConfig = Object.assign({
application: `contentful-migrate/${version}`
}, config)
const client = createManagementClient(clientConfig)
const makeRequest = (requestConfig) => {
// eslint-disable-next-line no-param-reassign
requestConfig.url = path.join(config.spaceId, 'environments', environmentId, requestConfig.url)
return client.rawRequest(requestConfig)
}
const migrationParser = migrationParser1.default(makeRequest, clientConfig)
let parseResult
try {
parseResult = await migrationParser(migrationFunction)
} catch (e) {
if (e instanceof SpaceAccessError) {
const message = [
chalk.red.bold(`${e.message}\n`),
chalk.red.bold('🚨 Migration unsuccessful')
].join('\n')