Skip to content

Commit 794761c

Browse files
committed
fix(scripts): scope NEXT_PUBLIC_CODEBUFF_APP_URL to web package in worktrees
- Move URL override from root .env.development.local to web/.env.development.local - Prevents SDK integration tests from hitting localhost instead of production - Root .env.development.local now only contains port overrides
1 parent 70fd50f commit 794761c

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

.github/workflows/npm-app-release-legacy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
new-version: ${{ needs.prepare-and-commit-legacy.outputs.new_version }}
7979
artifact-name: updated-package
8080
checkout-ref: ${{ github.sha }}
81-
env-overrides: '{"NEXT_PUBLIC_CODEBUFF_BACKEND_URL": "manicode-backend.onrender.com", "NEXT_PUBLIC_CB_ENVIRONMENT": "prod"}'
81+
env-overrides: '{"NEXT_PUBLIC_CB_ENVIRONMENT": "prod"}'
8282
secrets: inherit
8383

8484
# Create GitHub release with all binaries

.github/workflows/npm-app-release-prod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
new-version: ${{ needs.prepare-and-commit-prod.outputs.new_version }}
7979
artifact-name: updated-package
8080
checkout-ref: ${{ github.sha }}
81-
env-overrides: '{"NEXT_PUBLIC_CODEBUFF_BACKEND_URL": "manicode-backend.onrender.com", "NEXT_PUBLIC_CB_ENVIRONMENT": "prod"}'
81+
env-overrides: '{"NEXT_PUBLIC_CB_ENVIRONMENT": "prod"}'
8282
secrets: inherit
8383

8484
# Create GitHub release with all binaries

.github/workflows/sdk-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
- name: Set environment variables
7171
env:
7272
SECRETS_CONTEXT: ${{ toJSON(secrets) }}
73-
ENV_OVERRIDES: '{"NEXT_PUBLIC_CODEBUFF_BACKEND_URL": "manicode-backend.onrender.com", "NEXT_PUBLIC_CB_ENVIRONMENT": "prod"}'
73+
ENV_OVERRIDES: '{"NEXT_PUBLIC_CB_ENVIRONMENT": "prod"}'
7474
shell: bash
7575
run: |
7676
VAR_NAMES=$(bun scripts/generate-ci-env.ts --scope client)

scripts/init-worktree.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,27 @@ function createEnvDevelopmentLocalFile(
210210
worktreePath: string,
211211
args: WorktreeArgs,
212212
): void {
213-
const envContent = `# Worktree-specific port overrides
213+
// Root .env.development.local - only port overrides that apply globally
214+
const rootEnvContent = `# Worktree-specific port overrides
214215
# Generated by init-worktree.ts for worktree: ${args.name}
215216
# This file has highest precedence in Bun's .env loading order, overriding .env.local
216-
# PORT is used by Next.js dev server
217217
PORT=${args.webPort}
218218
NEXT_PUBLIC_WEB_PORT=${args.webPort}
219-
NEXT_PUBLIC_CODEBUFF_APP_URL=http://localhost:${args.webPort}
220219
`
221220

222-
writeFileSync(join(worktreePath, '.env.development.local'), envContent)
221+
writeFileSync(join(worktreePath, '.env.development.local'), rootEnvContent)
223222
console.log('Created .env.development.local with port configurations')
223+
224+
// Web-specific .env.development.local - URL override only affects web package
225+
// This prevents SDK integration tests from hitting localhost instead of production
226+
const webEnvContent = `# Web-specific worktree overrides
227+
# Generated by init-worktree.ts for worktree: ${args.name}
228+
# This URL override only affects the web package, not SDK tests
229+
NEXT_PUBLIC_CODEBUFF_APP_URL=http://localhost:${args.webPort}
230+
`
231+
232+
writeFileSync(join(worktreePath, 'web', '.env.development.local'), webEnvContent)
233+
console.log('Created web/.env.development.local with URL configuration')
224234
}
225235

226236
function copyInfisicalConfig(worktreePath: string): void {

0 commit comments

Comments
 (0)