Merge pull request #58 from tiktok/feat-extended-skeleton

Feat extended skeleton
This commit is contained in:
Cheng Liu 2024-03-15 12:40:50 -07:00 committed by GitHub
commit d533982ec3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 44 additions and 1 deletions

View file

@ -27,6 +27,12 @@ export interface ILaunchOptions {
* It is used to update notification.
*/
callerPackageJson?: ICallerPackageJson;
/**
* Provide the additional skeleton folders.
* @internal
*/
additionalSkeletonFolders?: string[];
}
/**

View file

@ -6,6 +6,7 @@ import { ICommand } from './commands/base';
import { ArgvService } from '../services/ArgvService';
import { GitVersionCompatibility } from '../logic/GitVersionCompatibility';
import { TelemetryService } from '../services/TelemetryService';
import { GitSparseCheckoutService } from '../services/GitSparseCheckoutService';
import { getCommandName } from './commands/util';
import { SparoStartupBanner } from './SparoStartupBanner';
import type { ILaunchOptions } from '../api/Sparo';
@ -28,6 +29,12 @@ export class SparoCICommandLine {
callerPackageJson: launchOptions.callerPackageJson
});
if (launchOptions.additionalSkeletonFolders) {
const gitSparseCheckoutService: GitSparseCheckoutService =
await getFromContainerAsync(GitSparseCheckoutService);
gitSparseCheckoutService.setAdditionalSkeletonFolders(launchOptions.additionalSkeletonFolders);
}
const sparoCI: SparoCICommandLine = new SparoCICommandLine();
await sparoCI.prepareCommandAsync();
await sparoCI.runAsync();

View file

@ -7,6 +7,7 @@ import { COMMAND_LIST } from './commands/cmd-list';
import { ICommand } from './commands/base';
import { GitVersionCompatibility } from '../logic/GitVersionCompatibility';
import { TelemetryService } from '../services/TelemetryService';
import { GitSparseCheckoutService } from '../services/GitSparseCheckoutService';
import { getCommandName } from './commands/util';
import { SparoStartupBanner } from './SparoStartupBanner';
import type { ILaunchOptions } from '../api/Sparo';
@ -29,6 +30,12 @@ export class SparoCommandLine {
callerPackageJson: launchOptions.callerPackageJson
});
if (launchOptions.additionalSkeletonFolders) {
const gitSparseCheckoutService: GitSparseCheckoutService =
await getFromContainerAsync(GitSparseCheckoutService);
gitSparseCheckoutService.setAdditionalSkeletonFolders(launchOptions.additionalSkeletonFolders);
}
const sparo: SparoCommandLine = new SparoCommandLine();
await sparo.prepareCommandAsync();
await sparo.runAsync();

View file

@ -32,6 +32,7 @@ export class GitSparseCheckoutService {
private _packageNames: Set<string> = new Set<string>();
private _isSkeletonInitializedAndUpdated: boolean = false;
private _finalSkeletonPaths: string[] = [];
private _additionalSkeletonFolders: string[] = [];
public ensureSkeletonExistAndUpdated(): void {
/**
@ -89,6 +90,10 @@ export class GitSparseCheckoutService {
await this._rushSparseCheckoutAsync({ checkoutAction: 'purge' });
}
public setAdditionalSkeletonFolders(additionalSkeletonFolders: string[]): void {
this._additionalSkeletonFolders = additionalSkeletonFolders;
}
/**
*
* @param options
@ -284,7 +289,13 @@ export class GitSparseCheckoutService {
}
private _getSkeletonPaths(): string[] {
const basicFolders: string[] = ['.vscode', 'common', 'common/sparse-profiles', 'scripts', 'plugins'];
const basicFolders: string[] = [
'.vscode',
'common',
'common/sparse-profiles',
'scripts',
'plugins'
].concat(this._additionalSkeletonFolders);
this._sparseCheckoutPaths(basicFolders, { action: 'add' });
const pluginPaths: string[] = this._findRushPluginsPaths();

View file

@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "sparo",
"comment": "Add a new launch option called \"additionalSkeletonFolders\" to add more folders to skeleton",
"type": "none"
}
],
"packageName": "sparo"
}

View file

@ -75,6 +75,8 @@ export interface IExecuteGitCommandParams {
// @public
export interface ILaunchOptions {
// @internal
additionalSkeletonFolders?: string[];
// @internal
callerPackageJson?: ICallerPackageJson;
// @internal