-
Notifications
You must be signed in to change notification settings - Fork 11
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 #30 from tiktok/fix-ci-checkout
Fix ci checkout
- Loading branch information
Showing
4 changed files
with
62 additions
and
43 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,50 @@ | ||
import { inject } from 'inversify'; | ||
import type { Argv, ArgumentsCamelCase } from 'yargs'; | ||
import { ICommand } from './base'; | ||
import { Command } from '../../decorator'; | ||
import { GitSparseCheckoutService } from '../../services/GitSparseCheckoutService'; | ||
|
||
export interface ICICheckoutCommandOptions { | ||
to?: string[]; | ||
from?: string[]; | ||
} | ||
|
||
@Command() | ||
export class CICheckoutCommand implements ICommand<ICICheckoutCommandOptions> { | ||
public cmd: string = 'checkout'; | ||
public description: string = | ||
'Special checkout command for CI. It only accepts project selector suchs as --to and --from now.'; | ||
@inject(GitSparseCheckoutService) private _gitSparseCheckoutService!: GitSparseCheckoutService; | ||
public builder(yargs: Argv<ICICheckoutCommandOptions>): void { | ||
yargs | ||
.option('to', { | ||
type: 'array', | ||
alias: 't', | ||
description: 'See https://rushjs.io/pages/developer/selecting_subsets/#--to for more details.' | ||
}) | ||
.option('from', { | ||
type: 'array', | ||
alias: 'f', | ||
description: 'See https://rushjs.io/pages/developer/selecting_subsets/#--from for more details.' | ||
}) | ||
.check((argv, options) => { | ||
const { to, from } = argv; | ||
const toNum: number = (to || []).length; | ||
const fromNum: number = (from || []).length; | ||
if (toNum === 0 && fromNum === 0) { | ||
throw new Error('At least one of "--to" or "--from" must be specified'); | ||
} | ||
return true; | ||
}); | ||
} | ||
public handler = async (args: ArgumentsCamelCase<ICICheckoutCommandOptions>): Promise<void> => { | ||
const { to, from } = args; | ||
await this._gitSparseCheckoutService.checkoutAsync({ | ||
to, | ||
from | ||
}); | ||
}; | ||
public getHelp(): string { | ||
return 'sparse help'; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
10 changes: 10 additions & 0 deletions
10
common/changes/sparo/fix-ci-checkout_2024-02-28-22-28.json
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,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "sparo", | ||
"comment": "Support checkout --to or --from in sparo-ci, replacing sparo-ci sparse", | ||
"type": "none" | ||
} | ||
], | ||
"packageName": "sparo" | ||
} |