-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a
webstone web delete page
CLI command (#82)
* chore(cli): ensure CLI templates are copied when starting the dev env * feat(cli): add a `webstone web delete page` CLI command Add a `webstone web delete page` CLI command. close #76 * docs(cli): add a changelog entry for the `webstone web delete page` CLI command * chore(create-webstone-app): sneaking in a small cosmetic change in the terminal output
- Loading branch information
1 parent
58bc87d
commit db93524
Showing
4 changed files
with
37 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@webstone/cli": minor | ||
--- | ||
|
||
Add a `webstone web delete page` CLI command. |
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,30 @@ | ||
import { GluegunCommand } from "gluegun"; | ||
|
||
const command: GluegunCommand = { | ||
run: async (toolbox) => { | ||
const { filesystem, parameters, print, prompt, strings } = toolbox; | ||
|
||
let name = parameters.first; | ||
if (!name) { | ||
const result = await prompt.ask({ | ||
type: "input", | ||
name: "name", | ||
message: `What's the page to delete?`, | ||
}); | ||
if (result && result.name) name = result.name; | ||
} | ||
|
||
if (!name) { | ||
print.error("Please provide a page, e.g. 'about-us'."); | ||
return; | ||
} | ||
|
||
const filename = strings.kebabCase(name); | ||
const target = `services/web/src/routes/${filename}`; | ||
const spinner = print.spin(`Removing page "${target}"...`); | ||
filesystem.remove(target); | ||
spinner.succeed(`Page deleted at: ${target}`); | ||
}, | ||
}; | ||
|
||
module.exports = command; |
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