Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (parseResult.hasPayloadValidationErrors()) {
stepsError.default(parseResult.payloadValidationErrors)
process.exit(1)
}
// const migrationName = path.basename(argv.filePath, '.js');
// const errorsFile = path.join(process.cwd(), `errors-${migrationName}-${Date.now()}.log`);
const errorsFile = path.join(process.cwd(), `errors-${Date.now()}.log`)
const { batches } = parseResult
if (parseResult.hasValidationErrors()) {
renderMigration.renderValidationErrors(batches)
process.exit(1)
}
if (parseResult.hasRuntimeErrors()) {
renderMigration.renderRuntimeErrors(batches, errorsFile)
await writeErrorsToLog.default(parseResult.getRuntimeErrors(), errorsFile)
process.exit(1)
}
await renderMigration.renderPlan(batches)
const serverErrorsWritten = []
const tasks = batches.map((batch) => {
return {
title: batch.intent.toPlanMessage().heading,
task: () => new Listr([
{
title: 'Making requests',
task: async (_ctx, task) => {
// TODO: We wanted to make this an async interator
// So we should not inspect the length but have a property for that
const numRequests = batch.requests.length
const requestErrors = []
let requestsDone = 0
await makeRequest(request).catch((error) => {
serverErrorsWritten.push(writeErrorsToLog.default(error, errorsFile))
const parsed = JSON.parse(error.message)
const errorMessage = {
status: parsed.statusText,
message: parsed.message,
details: parsed.details,
url: parsed.request.url
}
requestErrors.push(new Error(JSON.stringify(errorMessage)))
})
}