Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
chore[ee]: improved single-branch cloning feature as optional (#10273)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-casarrubias authored May 29, 2024
1 parent f410ceb commit a4b3a82
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions scripts/install-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ cli.enable('status')
const options = cli.parse({
manifestURL: [false, 'Manifest URL', 'string'],
branch: ['b', 'Branch', 'string', 'main'],
replace: ['r', 'Replace existing project?', 'string', 'no']
replace: ['r', 'Replace existing project?', 'string', 'no'],
singleBranch: ['s', 'Clone repos in a single branch?', 'string', 'no']
}) as {
manifestURL?: string
branch?: string
replace?: string
singleBranch?: string
}

/**
Expand Down Expand Up @@ -93,7 +95,7 @@ interface PackageManifest_V_1_0_0 {
}

const installManifest = async () => {
const { branch } = options // ?? 'main' -> unnecessary coalescing operator, leveraging default value from cli settings instead
const { branch, singleBranch } = options // ?? 'main' -> unnecessary coalescing operator, leveraging default value from cli settings instead
const manifest = (await fetchManifest()) as PackageManifest_V_1_0_0
const replacing = options.replace?.toLowerCase() === 'yes' || options.replace?.toLowerCase() === 'y'
if (!manifest) throw new Error('No manifest found')
Expand Down Expand Up @@ -143,7 +145,7 @@ const installManifest = async () => {
const curatedURL = url.replace('https://github.com/', '[email protected]:')
console.log(`Cloning ${curatedURL}`)
// Improving performance by cloning the code from the expected branch in a single step
await execPromise(`git clone -b ${branch} --single-branch ${curatedURL}`, {
await execPromise(`git clone -b ${branch} ${singleBranch === 'yes' ? '--single-branch' : ''} ${curatedURL}`, {
cwd: path.resolve(appRootPath.path, 'packages/projects/projects')
})

Expand All @@ -159,9 +161,18 @@ const installManifest = async () => {
*/
})
)

await execPromise(`ls`, {
cwd: path.resolve(appRootPath.path, 'packages/projects/projects')
})

if (singleBranch === 'yes') {
console.log(`You enabled cloning a single branch, the only branch currently available in your local environment
is "${branch}", in case you need to checkout a different remote branch, run the following commands in your terminal:
$ git fetch origin [branch]
$ git checkout FETCH_HEAD -b [branch]`)
}
}

cli.main(async () => {
Expand Down

0 comments on commit a4b3a82

Please sign in to comment.