Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return db.sadd(appNameSetKey, app.id).catch((err) => log.error('Key existing', err)); // Try to add the missing index
});
.catch(err => log.error('Credential existing already', err)) // Create a new one with the ID instead of the username
)
mkdirp(directory, (makeDirectoryError) => {
if (makeDirectoryError) {
reject(logError(`🚨 Failed to create ${directory}`, makeDirectoryError))
}
// Fix up file path
const date = dateformat(new Date(), 'UTC:yyyymmddHHMMss')
const fileName = `${date}-create-${camelToDash(contentTypeId)}.js`
const filePath = path.join(process.cwd(), directory, fileName)
// Write the template file
return fs.writeFile(filePath, fileContent, (writeFileError) => {
if (writeFileError) {
reject(logError(`🚨 Failed to create ${directory}/${fileName}`, writeFileError))
}
log('Created', `${directory}/${fileName}`)
resolve({ contentTypeId, fileName })
})
})
.catch((err) => {
log.error('error', err)
console.log(chalk.bold.red(`\n🚨 Error applying migrations to "${environmentId}" environment! See above for error messages`))
process.exit(1)
})
}
.catch((err) => {
log.error('error', err)
process.exit(1)
}))
}
.catch((err) => {
log.error('error', err)
process.exit(1)
}))
}
return rimraf(contentTypeDirectory, (error) => {
if (error) {
reject(logError(`🚨 Failed to delete migrations/${contentType} folder`, error))
}
resolve(log(`migrations/${contentType} folder`, 'deleted'))
})
})
spaceId,
environmentId,
contentTypes,
accessToken,
migrationsDirectory,
writeMigrationState
) => {
try {
await deleteScripts(migrationsDirectory, contentTypes)
const files = await generateScripts(spaceId, environmentId, contentTypes, accessToken, migrationsDirectory)
if (writeMigrationState) {
rewriteMigration(spaceId, environmentId, accessToken, files)
}
log(chalk.bold.green('🎉 Bootstrap'), chalk.bold.green('successful'))
} catch (error) {
logError('🚨 Failed to perform bootstrap', error)
}
}
return fs.writeFile(filePath, fileContent, (writeFileError) => {
if (writeFileError) {
reject(logError(`🚨 Failed to create ${directory}/${fileName}`, writeFileError))
}
log('Created', `${directory}/${fileName}`)
resolve({ contentTypeId, fileName })
})
})
return rimraf(migrationsDirectory, (error) => {
if (error) {
reject(logError('🚨 Failed to delete migrations folder', error))
}
resolve(log('Migrations folder', 'deleted'))
})
})