-
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.
feat: Add clean and environment commands
- Loading branch information
1 parent
086c9d9
commit bbb0e6a
Showing
11 changed files
with
141 additions
and
45 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
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,35 @@ | ||
import { Command } from 'commander'; | ||
import { projectConfig } from '../../config/project'; | ||
import { deletePath } from '../../utils/file-system'; | ||
import log from '../../utils/log'; | ||
import sharedOptions from '../../utils/shared-options'; | ||
|
||
export const cleanCommand = () => { | ||
const command = new Command(); | ||
const config = projectConfig(); | ||
|
||
command | ||
.name('clean') | ||
.summary('Cleanup DEMS-managed resources') | ||
.description( | ||
'Cleans all configured resources and services initialized\n' + | ||
'by DEMS. Resets your local development environment.', | ||
) | ||
.addOption(sharedOptions.force().default(false)) | ||
.action(async (options) => { | ||
log.info('Cleaning DEMS-related resources...'); | ||
if (options.force) { | ||
log.info('User interactivity disabled due to --force flag.'); | ||
} | ||
|
||
await deletePath({ path: config.paths.repos_root, force: options.force }); | ||
await deletePath({ path: config.paths.data, force: options.force }); | ||
await deletePath({ path: config.paths.env_file, force: options.force }); | ||
|
||
log.success('Clean completed for current project.'); | ||
}); | ||
|
||
return command; | ||
}; | ||
|
||
export default cleanCommand(); |
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,37 @@ | ||
import { Command } from 'commander'; | ||
import { projectConfig, projectEnvVars } from '../../config/project'; | ||
import { deletePath } from '../../utils/file-system'; | ||
import log from '../../utils/log'; | ||
import sharedOptions from '../../utils/shared-options'; | ||
import dotEnv from '../../config/env'; | ||
|
||
export const environmentCommand = () => { | ||
const command = new Command(); | ||
const config = projectConfig(); | ||
|
||
command | ||
.name('environment') | ||
.alias('env') | ||
.summary('Updates application environment config (.env)') | ||
.description( | ||
'Apps are run in different environments throughout their development\n' + | ||
"life cycle. To ensure their configuration matches what's\n" + | ||
'expected for DEMS, we override some of the default env settings.', | ||
) | ||
.option( | ||
'-g, --generate-dot-env', | ||
"Generates the dot env file for current project's config.json", | ||
) | ||
.action(async (options) => { | ||
if (options.generateDotEnv) { | ||
log.info('Generating project\'s dot env file...'); | ||
dotEnv.generate(config.paths.env_file, config); | ||
} else { | ||
console.log(projectEnvVars()); | ||
}; | ||
}); | ||
|
||
return command; | ||
}; | ||
|
||
export default environmentCommand(); |
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
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