From ad719324c4af3c69a358ead953dc93fc2a146942 Mon Sep 17 00:00:00 2001 From: Joe Yeager Date: Thu, 9 Jan 2025 09:09:51 -0800 Subject: [PATCH 1/2] WIP --- lib/projects/index.ts | 6 +++++- yarn.lock | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/projects/index.ts b/lib/projects/index.ts index 9a86d6b1e..59d91684d 100644 --- a/lib/projects/index.ts +++ b/lib/projects/index.ts @@ -2,7 +2,10 @@ import fs from 'fs-extra'; import path from 'path'; import findup from 'findup-sync'; import { logger } from '@hubspot/local-dev-lib/logger'; -import { fetchFileFromRepository } from '@hubspot/local-dev-lib/github'; +import { + cloneGithubRepo, + fetchFileFromRepository, +} from '@hubspot/local-dev-lib/github'; import { createProject, fetchProject, @@ -134,6 +137,7 @@ export async function createProjectConfig( const hasCustomTemplateSource = Boolean(templateSource); + // TODO: Swap this out await downloadGithubRepoContents( templateSource || HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, template.path, diff --git a/yarn.lock b/yarn.lock index 1a8ff8a26..1bd1a3387 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11753,6 +11753,7 @@ wordwrap@^1.0.0: integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q== "wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: + name wrap-ansi-cjs version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== From 69045d1423548e86b8620ce1c5c2192df8bc114a Mon Sep 17 00:00:00 2001 From: Joe Yeager Date: Thu, 9 Jan 2025 14:40:26 -0800 Subject: [PATCH 2/2] fix: Download the entire repo for create and add --- acceptance-tests/yarn.lock | 8 ++++---- lib/projects/index.ts | 21 ++++++++++----------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/acceptance-tests/yarn.lock b/acceptance-tests/yarn.lock index 793c22df0..2d485e419 100644 --- a/acceptance-tests/yarn.lock +++ b/acceptance-tests/yarn.lock @@ -368,10 +368,10 @@ concat-stream@^2.0.0: readable-stream "^3.0.2" typedarray "^0.0.6" -cross-spawn@^7.0.3: - version "7.0.3" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" - integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== +cross-spawn@^7.0.5: + version "7.0.6" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f" + integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA== dependencies: path-key "^3.1.0" shebang-command "^2.0.0" diff --git a/lib/projects/index.ts b/lib/projects/index.ts index 59d91684d..963ca14ae 100644 --- a/lib/projects/index.ts +++ b/lib/projects/index.ts @@ -12,7 +12,6 @@ import { } from '@hubspot/local-dev-lib/api/projects'; import { isSpecifiedError } from '@hubspot/local-dev-lib/errors/index'; import { getCwd, getAbsoluteFilePath } from '@hubspot/local-dev-lib/path'; -import { downloadGithubRepoContents } from '@hubspot/local-dev-lib/github'; import { RepoPath } from '@hubspot/local-dev-lib/types/Github'; import { Project } from '@hubspot/local-dev-lib/types/Project'; import { HubSpotPromise } from '@hubspot/local-dev-lib/types/Http'; @@ -137,13 +136,15 @@ export async function createProjectConfig( const hasCustomTemplateSource = Boolean(templateSource); - // TODO: Swap this out - await downloadGithubRepoContents( + await cloneGithubRepo( templateSource || HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, - template.path, projectPath, - hasCustomTemplateSource ? undefined : githubRef + { + sourceDir: template.path, + tag: hasCustomTemplateSource ? undefined : githubRef, + } ); + const _config: ProjectConfig = JSON.parse( fs.readFileSync(projectConfigPath).toString() ); @@ -355,12 +356,10 @@ export async function createProjectComponent( componentName ); - await downloadGithubRepoContents( - HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, - component.path, - componentPath, - projectComponentsVersion - ); + await cloneGithubRepo(HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, componentPath, { + sourceDir: component.path, + tag: projectComponentsVersion, + }); } export async function getProjectComponentsByVersion(