Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await updateAndWaitForStack({ isCLIMigration });
} catch (e) {
await TransformPackage.revertAPIMigration(resourceDir, oldProjectConfig);
throw e;
}
try {
// After the intermediate update, we need the transform function
// to look at this directory since we did not overwrite the currentCloudBackend with the build
options.cloudBackendDirectory = resourceDir;
await transformGraphQLSchema(context, options);
const result = await updateAndWaitForStack({ isCLIMigration });
context.print.info('\nFinished migrating API.');
return result;
} catch (e) {
context.print.error('Reverting API migration.');
await TransformPackage.revertAPIMigration(resourceDir, oldCloudBackend);
try {
await updateAndWaitForStack({ isReverting: true, isCLIMigration });
} catch (e) {
context.print.error('Error reverting intermediate migration stack.');
}
await TransformPackage.revertAPIMigration(resourceDir, oldProjectConfig);
context.print.error('API successfully reverted.');
throw e;
}
}
// After the intermediate update, we need the transform function
// to look at this directory since we did not overwrite the currentCloudBackend with the build
options.cloudBackendDirectory = resourceDir;
await transformGraphQLSchema(context, options);
const result = await updateAndWaitForStack({ isCLIMigration });
context.print.info('\nFinished migrating API.');
return result;
} catch (e) {
context.print.error('Reverting API migration.');
await TransformPackage.revertAPIMigration(resourceDir, oldCloudBackend);
try {
await updateAndWaitForStack({ isReverting: true, isCLIMigration });
} catch (e) {
context.print.error('Error reverting intermediate migration stack.');
}
await TransformPackage.revertAPIMigration(resourceDir, oldProjectConfig);
context.print.error('API successfully reverted.');
throw e;
}
}
async function migrateProject(context, options) {
const { resourceDir, isCLIMigration, cloudBackendDirectory } = options;
const updateAndWaitForStack = options.handleMigration || (() => Promise.resolve('Skipping update'));
let oldProjectConfig;
let oldCloudBackend;
try {
context.print.info('\nMigrating your API. This may take a few minutes.');
const { project, cloudBackend } = await TransformPackage.migrateAPIProject({
projectDirectory: resourceDir,
cloudBackendDirectory,
});
oldProjectConfig = project;
oldCloudBackend = cloudBackend;
await updateAndWaitForStack({ isCLIMigration });
} catch (e) {
await TransformPackage.revertAPIMigration(resourceDir, oldProjectConfig);
throw e;
}
try {
// After the intermediate update, we need the transform function
// to look at this directory since we did not overwrite the currentCloudBackend with the build
options.cloudBackendDirectory = resourceDir;
await transformGraphQLSchema(context, options);
const result = await updateAndWaitForStack({ isCLIMigration });
context.print.info('\nFinished migrating API.');
return result;
} catch (e) {
context.print.error('Reverting API migration.');
await TransformPackage.revertAPIMigration(resourceDir, oldCloudBackend);
try {
await updateAndWaitForStack({ isReverting: true, isCLIMigration });
} catch (e) {