-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from zanerock/work-liquid-labs/cloudsite/93
Implement delayed cleanup support
- Loading branch information
Showing
19 changed files
with
189 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,10 +56,12 @@ const siteInfo = { | |
"apexDomain": "your-website-domain.com", | ||
"sourceType": "docusaurus", // or 'vanilla' | ||
"sourcePath": "/Users/your-home-dir/path/to/website/source" | ||
"pluginSettings": { | ||
"plugins": { | ||
"contactHandler": { | ||
"path": "/contact-handler", | ||
"emailFrom": "[email protected]" | ||
"settings": { | ||
"path": "/contact-handler", | ||
"emailFrom": "[email protected]" | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -287,6 +289,7 @@ cloudsite update your-domain.com | |
### Commands | ||
- [`cleanup`](#cloudsite-cleanup): Attempts to fully delete partially deleted sites in the 'needs to be cleaned up' state. | ||
- [`configuration`](#cloudsite-configuration): Command group for managing the Cloudsite CLI configuration. | ||
- [`create`](#cloudsite-create): Creates a new website, setting up infrastructure and copying content. | ||
- [`destroy`](#cloudsite-destroy): Destroys the named site. I.e., deletes all cloud resources associated with the site. | ||
|
@@ -298,6 +301,18 @@ cloudsite update your-domain.com | |
- [`update`](#cloudsite-update): Updates a website content and/or infrastructure. | ||
- [`verify`](#cloudsite-verify): Verifies the site is up and running and that the stack and content are up-to-date. | ||
<span id="cloudsite-cleanup"></span> | ||
#### `cloudsite cleanup <options> <apex-domain>` | ||
Attempts to fully delete partially deleted sites in the 'needs to be cleaned up' state. | ||
##### `cleanup` options | ||
|Option|Description| | ||
|------|------| | ||
|`<apex-domain>`|(_main argument_,_optional_) Specifies the site to clean up rather than trying to cleanup all pending sites.| | ||
|`--list`|Lists the sites in need of cleaning up.| | ||
<span id="cloudsite-configuration"></span> | ||
#### `cloudsite configuration [subcommand]` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import commandLineArgs from 'command-line-args' | ||
|
||
import { cliSpec } from '../constants' | ||
import { destroy } from '../../lib/actions/destroy' | ||
|
||
const handleCleanup = async ({ argv, db }) => { | ||
const cleanupOptionsSpec = cliSpec.commands.find(({ name }) => name === 'cleanup').arguments | ||
const cleanupOptions = commandLineArgs(cleanupOptionsSpec, { argv }) | ||
const apexDomain = cleanupOptions['apex-domain'] | ||
const { list } = cleanupOptions | ||
|
||
if (list === true) { | ||
process.stdout.write(Object.keys(db.toCleanup).join('\n') + '\n') | ||
return | ||
} | ||
|
||
const listOfSitesToCleanup = apexDomain === undefined | ||
? Object.keys(db.toCleanup) | ||
: [apexDomain] | ||
|
||
const deleteActions = listOfSitesToCleanup | ||
.map((apexDomain) => { | ||
process.stdout.write(`Cleaning up ${apexDomain}...\n`) | ||
return destroy({ db, siteInfo : db.toCleanup[apexDomain], verbose : false }) | ||
}) | ||
|
||
process.stdout.write('.') | ||
const intervalID = setInterval(() => process.stdout.write('.'), 2000) | ||
const cleanupResults = await Promise.all(deleteActions) | ||
clearInterval(intervalID) | ||
process.stdout.write('\n') | ||
|
||
listOfSitesToCleanup.forEach((apexDomain, i) => { | ||
const cleanupResult = cleanupResults[i] | ||
process.stdout.write(`${apexDomain}: ${cleanupResult === true ? 'CLEANED' : 'NOT cleaned'}\n`) | ||
if (cleanupResult === true) { | ||
delete db.toCleanup[apexDomain] | ||
db.reminders.splice(db.reminders.findIndex(({ apexDomain: testDomain }) => testDomain === apexDomain), 1) | ||
} | ||
}) | ||
} | ||
|
||
export { handleCleanup } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,10 +56,12 @@ const siteInfo = { | |
"apexDomain": "your-website-domain.com", | ||
"sourceType": "docusaurus", // or 'vanilla' | ||
"sourcePath": "/Users/your-home-dir/path/to/website/source" | ||
"pluginSettings": { | ||
"plugins": { | ||
"contactHandler": { | ||
"path": "/contact-handler", | ||
"emailFrom": "[email protected]" | ||
"settings": { | ||
"path": "/contact-handler", | ||
"emailFrom": "[email protected]" | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.