-
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.
chore: Add repos cleanup sub-command and simplify git clone/checkout …
…commands
- Loading branch information
1 parent
dead7e1
commit da313c5
Showing
4 changed files
with
82 additions
and
25 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,51 @@ | ||
import chalk from 'chalk'; | ||
import { Command } from 'commander'; | ||
import cliConfig from '../../config/cli'; | ||
import { projectConfig } from '../../config/project'; | ||
import { deletePath } from '../../utils/file-system'; | ||
import log from '../../utils/log'; | ||
import sharedOptions from '../../utils/shared-options'; | ||
import { noIndent } from '../../utils/string'; | ||
|
||
export const cleanReposCommand = () => { | ||
const command = new Command(); | ||
command | ||
.name('repos') | ||
.summary("Remove the current project's git repositories.") | ||
.description( | ||
noIndent(` | ||
Removes the current project's git repositories cloned in the repository | ||
root path managed by DEMS. This action is irreversible. | ||
`), | ||
) | ||
.addOption(sharedOptions.force()) | ||
.action(async (options) => { | ||
const config = projectConfig(); | ||
log.info("Removing the current project's git repositories..."); | ||
log.info(`Current project: ${chalk.bold(cliConfig.currentProject)}`); | ||
|
||
if (options.force) { | ||
log.warning('User interactivity disabled due to --force flag.'); | ||
} | ||
|
||
log.warning('The repositories that will be removed are:'); | ||
for (const repo of config.repositories) { | ||
log.warning(` - ${repo}`); | ||
} | ||
|
||
for (const repo of Object.values(config.paths.repos)) { | ||
await deletePath({ | ||
path: repo, | ||
force: options.force, | ||
}); | ||
} | ||
|
||
log.success( | ||
'All managed git repositories directories have been removed.', | ||
); | ||
}); | ||
|
||
return command; | ||
}; | ||
|
||
export default cleanReposCommand(); |
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