Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 });