-
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: Refactor clone command, use git command instead
- Loading branch information
1 parent
65188fc
commit 73a83bc
Showing
10 changed files
with
132 additions
and
85 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,36 @@ | ||
import chalk from 'chalk'; | ||
import { Command } from 'commander'; | ||
import { projectConfig } from '../../config/project'; | ||
import git from '../../utils/git'; | ||
import sharedOptions from '../../utils/shared-options'; | ||
|
||
export const gitCheckoutCommand = () => { | ||
const command = new Command(); | ||
const config = projectConfig(); | ||
|
||
command | ||
.name('checkout') | ||
.description( | ||
'Checkout all configured git repositories defined in the config.json\n' + | ||
', to the specified git ref.', | ||
) | ||
.addOption(sharedOptions.gitRef().default(config.git.default_ref)) | ||
.addOption(sharedOptions.reposRoot().default(config.paths.repos_root)) | ||
.addOption(sharedOptions.repos().default(config.repositories)) | ||
.action((options) => { | ||
console.log(`Git org > ${chalk.bold(options.gitOrg)}`); | ||
console.log(`Git ref > ${chalk.bold(options.gitRef)}`); | ||
console.log(`Repos path > ${chalk.bold(options.reposRoot)}`); | ||
|
||
for (const repo of options.repos) { | ||
git.checkout({ | ||
path: `${options.reposRoot}/${repo}`, | ||
ref: options.gitRef, | ||
}); | ||
} | ||
}); | ||
|
||
return command; | ||
}; | ||
|
||
export default gitCheckoutCommand(); |
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,17 @@ | ||
import { Command } from 'commander'; | ||
import { gitCheckoutCommand } from './checkout'; | ||
import { gitCloneCommand } from './clone'; | ||
|
||
export const gitCommand = () => { | ||
const command = new Command(); | ||
|
||
command | ||
.name('git') | ||
.description('All git commands abstracted by DEMS') | ||
.addCommand(gitCloneCommand()) | ||
.addCommand(gitCheckoutCommand()); | ||
|
||
return command; | ||
}; | ||
|
||
export default gitCommand(); |
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