Skip to content

Commit 3d9e4a5

Browse files
committed
Optimize installation scripts and configure workspace dependencies
- to build use command from root: [Pasted text] - should install deps using [Pasted text] - we shouldn't clone full repo's commit history. when no tag is given in args - clone main branch with depth 1. if there is tag, clone at tag. - use [Pasted text] in build scripts ├── apps │ └── editor │ └── package.json ├── install.ps1 ├── install.sh ├── package.json └── packages ├── shared │ └── package.json └── ui └── package.json
1 parent a599481 commit 3d9e4a5

7 files changed

Lines changed: 47 additions & 68 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,8 @@
13881388
"vite": "8.3.6"
13891389
},
13901390
"dependencies": {
1391+
"@cwc/ui": "workspace:*",
1392+
"@cwc/shared": "workspace:*",
13911393
"@mozilla/readability": "0.6.0",
13921394
"@vscode/codicons": "0.0.46-38",
13931395
"axios": "1.21.0",

‎file.ts‎

Lines changed: 0 additions & 15 deletions
This file was deleted.

‎install.ps1‎

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -479,24 +479,20 @@ $originalLocation = Get-Location
479479
$cwcDir = Join-Path $env:USERPROFILE ".cwc"
480480

481481
function Clone-Repo {
482-
git clone -c core.longpaths=true --quiet https://github.com/CodeWebChat/CWC.git $repoDir *>$null
482+
$cloneArgs = @("clone", "-c", "core.longpaths=true", "--quiet", "--depth", "1")
483+
if ($tagName) {
484+
$cloneArgs += @("--branch", $tagName)
485+
}
486+
$cloneArgs += @("https://github.com/CodeWebChat/CWC.git", $repoDir)
487+
488+
git @cloneArgs *>$null
483489
if ($LASTEXITCODE -ne 0) {
484490
if (Test-Path $repoDir) {
485491
Remove-Item -Path $repoDir -Recurse -Force -ErrorAction SilentlyContinue
486492
}
487-
git clone -c core.longpaths=true --quiet https://github.com/CodeWebChat/CWC.git $repoDir *>$null
493+
git @cloneArgs *>$null
488494
if ($LASTEXITCODE -ne 0) { throw "Failed to clone" }
489495
}
490-
if ($tagName) {
491-
git -C $repoDir checkout $tagName --quiet *>$null
492-
if ($LASTEXITCODE -ne 0) { throw "Failed to checkout" }
493-
} else {
494-
$latestTag = git -C $repoDir tag -l '*-vscode' --sort=-creatordate | Select-Object -First 1
495-
if ($latestTag) {
496-
git -C $repoDir checkout $latestTag --quiet *>$null
497-
if ($LASTEXITCODE -ne 0) { throw "Failed to checkout latest tag" }
498-
}
499-
}
500496
}
501497

502498
try {
@@ -515,20 +511,16 @@ if ($installAll) {
515511
$updated = $false
516512
if (Test-Path (Join-Path $repoDir ".git")) {
517513
$updated = Invoke-Step "$msg_step_cloning..." {
518-
git -C $repoDir fetch origin --tags --quiet *>$null
519-
if ($LASTEXITCODE -ne 0) { throw "Failed to fetch" }
520514
if ($tagName) {
521-
git -C $repoDir checkout $tagName --quiet *>$null
515+
git -C $repoDir fetch --depth 1 origin "+refs/tags/${tagName}:refs/tags/${tagName}" --quiet *>$null
516+
if ($LASTEXITCODE -ne 0) { throw "Failed to fetch" }
517+
git -C $repoDir checkout --force $tagName --quiet *>$null
522518
if ($LASTEXITCODE -ne 0) { throw "Failed to checkout" }
523519
} else {
524-
$latestTag = git -C $repoDir tag -l '*-vscode' --sort=-creatordate | Select-Object -First 1
525-
if ($latestTag) {
526-
git -C $repoDir checkout $latestTag --quiet *>$null
527-
if ($LASTEXITCODE -ne 0) { throw "Failed to checkout latest tag" }
528-
} else {
529-
git -C $repoDir reset --hard origin/main --quiet *>$null
530-
if ($LASTEXITCODE -ne 0) { throw "Failed to reset" }
531-
}
520+
git -C $repoDir fetch --depth 1 origin main --quiet *>$null
521+
if ($LASTEXITCODE -ne 0) { throw "Failed to fetch" }
522+
git -C $repoDir reset --hard FETCH_HEAD --quiet *>$null
523+
if ($LASTEXITCODE -ne 0) { throw "Failed to reset" }
532524
}
533525
git -C $repoDir clean -fd --quiet *>$null
534526
if ($LASTEXITCODE -ne 0) { throw "Failed to clean" }
@@ -547,7 +539,7 @@ if (-not $updated) {
547539
Set-Location $repoDir
548540

549541
$depsOk = Invoke-Step "$msg_step_deps..." {
550-
pnpm install *>$null
542+
pnpm --filter gemini-coder install --frozen-lockfile *>$null
551543
if ($LASTEXITCODE -ne 0) { throw "pnpm install failed" }
552544
}
553545

@@ -572,20 +564,20 @@ if (-not $depsOk) {
572564
Set-Location $repoDir
573565

574566
$null = Invoke-Step "$msg_step_deps..." {
575-
pnpm install *>$null
567+
pnpm --filter gemini-coder install --frozen-lockfile *>$null
576568
if ($LASTEXITCODE -ne 0) { throw "pnpm install failed" }
577569
} $msg_step_deps
578570
}
579571

580-
Set-Location apps/editor
581-
582-
Remove-Item *.vsix -Force -ErrorAction SilentlyContinue
572+
Remove-Item "apps/editor/*.vsix" -Force -ErrorAction SilentlyContinue
583573

584574
$null = Invoke-Step "$msg_step_build..." {
585-
pnpm run build *>$null
586-
if ($LASTEXITCODE -ne 0) { throw "pnpm run build failed" }
575+
pnpm --filter gemini-coder build *>$null
576+
if ($LASTEXITCODE -ne 0) { throw "pnpm build failed" }
587577
} $msg_step_build
588578

579+
Set-Location apps/editor
580+
589581
$vsixFile = Get-ChildItem *.vsix -ErrorAction SilentlyContinue | Select-Object -First 1
590582

591583
if (!$vsixFile) {

‎install.sh‎

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -502,33 +502,25 @@ mkdir -p -m 700 "$CWC_DIR"
502502
chmod 700 "$CWC_DIR" 2>/dev/null || true
503503

504504
update_repo() {
505-
git -C "$REPO_DIR" fetch origin --tags --quiet && \
506505
if [ -n "$TAG_NAME" ]; then
507-
git -C "$REPO_DIR" checkout "$TAG_NAME" --quiet
506+
git -C "$REPO_DIR" fetch --depth 1 origin "+refs/tags/$TAG_NAME:refs/tags/$TAG_NAME" --quiet && \
507+
git -C "$REPO_DIR" checkout --force "$TAG_NAME" --quiet
508508
else
509-
LATEST_TAG=$(git -C "$REPO_DIR" tag -l '*-vscode' --sort=-creatordate | head -n 1)
510-
if [ -n "$LATEST_TAG" ]; then
511-
git -C "$REPO_DIR" checkout "$LATEST_TAG" --quiet
512-
else
513-
git -C "$REPO_DIR" reset --hard origin/main --quiet
514-
fi
509+
git -C "$REPO_DIR" fetch --depth 1 origin main --quiet && \
510+
git -C "$REPO_DIR" reset --hard FETCH_HEAD --quiet
515511
fi && \
516512
git -C "$REPO_DIR" clean -fd --quiet
517513
}
518514

519515
clone_repo() {
520-
if ! git clone -c core.longpaths=true --quiet https://github.com/CodeWebChat/CWC.git "$REPO_DIR"; then
521-
rm -rf "$REPO_DIR"
522-
git clone -c core.longpaths=true --quiet https://github.com/CodeWebChat/CWC.git "$REPO_DIR" || return 1
516+
local clone_args=(-c core.longpaths=true --quiet --depth 1)
517+
if [ -n "$TAG_NAME" ]; then
518+
clone_args+=(--branch "$TAG_NAME")
523519
fi
524520

525-
if [ -n "$TAG_NAME" ]; then
526-
git -C "$REPO_DIR" checkout "$TAG_NAME" --quiet || return 1
527-
else
528-
LATEST_TAG=$(git -C "$REPO_DIR" tag -l '*-vscode' --sort=-creatordate | head -n 1)
529-
if [ -n "$LATEST_TAG" ]; then
530-
git -C "$REPO_DIR" checkout "$LATEST_TAG" --quiet || return 1
531-
fi
521+
if ! git clone "${clone_args[@]}" https://github.com/CodeWebChat/CWC.git "$REPO_DIR"; then
522+
rm -rf "$REPO_DIR"
523+
git clone "${clone_args[@]}" https://github.com/CodeWebChat/CWC.git "$REPO_DIR" || return 1
532524
fi
533525
}
534526

@@ -555,21 +547,21 @@ for i in "${indices[@]}"; do
555547

556548
cd "$REPO_DIR"
557549

558-
if ! run_step "$msg_step_deps" pnpm install; then
550+
if ! run_step "$msg_step_deps" pnpm --filter gemini-coder install --frozen-lockfile; then
559551
echo -e " \033[33m$msg_deps_retry\033[0m"
560552
cd "$CWC_DIR"
561553
rm -rf "$CWC_DIR"/repository*
562554
pnpm store prune > /dev/null 2>&1 || true
563555
run_step "$msg_step_cloning" clone_repo
564556
cd "$REPO_DIR"
565-
run_step "$msg_step_deps" pnpm install
557+
run_step "$msg_step_deps" pnpm --filter gemini-coder install --frozen-lockfile
566558
fi
567559

568-
cd apps/editor
560+
rm -f ./apps/editor/*.vsix
569561

570-
rm -f ./*.vsix
562+
run_step "$msg_step_build" pnpm --filter gemini-coder build
571563

572-
run_step "$msg_step_build" pnpm run build
564+
cd apps/editor
573565

574566
vsix_files=(*.vsix)
575567
VSIX_FILE="${vsix_files[0]}"

‎packages/shared/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"name": "@cwc/shared",
23
"dependencies": {
34
"react": "18.2.0",
45
"react-dom": "18.2.0"

‎packages/ui/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"name": "@cwc/ui",
23
"scripts": {
34
"storybook": "storybook dev -p 6006",
45
"build-storybook": "storybook build"

‎pnpm-lock.yaml‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)