Skip to content

Commit

Permalink
feat(cli): amplify folder deletes regardless of presence in the cloud
Browse files Browse the repository at this point in the history
`amplify delete` now deletes the local `amplify` folder even if the project has been deleted in the
cloud.

close aws-amplify#7631
  • Loading branch information
Bentheburrito committed Jul 15, 2021
1 parent 5c4b0cb commit 0415f16
Showing 1 changed file with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,29 @@ export async function deleteProject(context) {
context.print.warning('Amplify App cannot be deleted, other environments still linked to Application');
}
}
spinner.succeed('Project deleted in the cloud.');
} catch (ex) {
spinner.fail('Project delete failed.');
throw ex;
if (ex.code === 'NotFoundException') {
spinner.succeed('Project already deleted in the cloud.');
} else {
spinner.fail('Project delete failed.');
throw ex;
}
}
spinner.succeed('Project deleted in the cloud.');
// Remove amplify dir
const { frontend } = context.amplify.getProjectConfig();
const frontendPlugins = getFrontendPlugins(context);
const frontendPluginModule = require(frontendPlugins[frontend]);
frontendPluginModule.deleteConfig(context);
context.filesystem.remove(getAmplifyDirPath());
context.print.success('Project deleted locally.');
removeLocalAmplifyDir(context);
}
}

function removeLocalAmplifyDir(context) {
const { frontend } = context.amplify.getProjectConfig();
const frontendPlugins = getFrontendPlugins(context);
const frontendPluginModule = require(frontendPlugins[frontend]);

frontendPluginModule.deleteConfig(context);
context.filesystem.remove(getAmplifyDirPath());
context.print.success('Project deleted locally.');
}

async function amplifyBackendEnvironments(client, appId) {
const data = await client
.listBackendEnvironments({
Expand Down

0 comments on commit 0415f16

Please sign in to comment.