|
1 | 1 | #!/usr/bin/env bun |
2 | 2 |
|
3 | 3 | import { spawn } from 'child_process' |
4 | | -import { existsSync, mkdirSync, writeFileSync } from 'fs' |
| 4 | +import { existsSync, mkdirSync, writeFileSync, copyFileSync } from 'fs' |
5 | 5 | import { join, resolve } from 'path' |
6 | 6 | import { createInterface } from 'readline' |
7 | 7 |
|
@@ -218,6 +218,20 @@ NEXT_PUBLIC_WEB_PORT=${args.webPort} |
218 | 218 | console.log('Created .env.worktree with port configurations') |
219 | 219 | } |
220 | 220 |
|
| 221 | +function copyInfisicalConfig(worktreePath: string): void { |
| 222 | + const sourceInfisicalPath = '.infisical.json' |
| 223 | + const targetInfisicalPath = join(worktreePath, '.infisical.json') |
| 224 | + |
| 225 | + if (existsSync(sourceInfisicalPath)) { |
| 226 | + copyFileSync(sourceInfisicalPath, targetInfisicalPath) |
| 227 | + console.log('Copied .infisical.json to worktree') |
| 228 | + } else { |
| 229 | + console.warn( |
| 230 | + 'Warning: .infisical.json not found in project root, make sure to run `infisical init` in your new worktree!', |
| 231 | + ) |
| 232 | + } |
| 233 | +} |
| 234 | + |
221 | 235 | // Wrapper script no longer needed - .bin/bun handles .env.worktree loading |
222 | 236 | // function createWrapperScript(worktreePath: string): void { |
223 | 237 | // // This function is deprecated - the .bin/bun wrapper now handles .env.worktree loading |
@@ -294,6 +308,7 @@ async function main(): Promise<void> { |
294 | 308 |
|
295 | 309 | // Create configuration files |
296 | 310 | createEnvWorktreeFile(worktreePath, args) |
| 311 | + copyInfisicalConfig(worktreePath) |
297 | 312 | // Note: .bin/bun wrapper now automatically loads .env.worktree |
298 | 313 |
|
299 | 314 | // Run direnv allow |
|
0 commit comments