@@ -1105,19 +1105,14 @@ export async function dump(dir: string, options: DumpOptions = {}): Promise<void
1105
1105
catch { }
1106
1106
}
1107
1107
if ( isReady ) {
1108
- const tIni = tick ( )
1109
- await ensureProjectPhpIni ( projectDir , envDir )
1110
- addTiming ( 'ensurePhpIni' , tIni )
1111
- try {
1112
- const tSvc = tick ( )
1113
- await setupProjectServices ( projectDir , sniffResult , true )
1114
- addTiming ( 'setupServices' , tSvc )
1115
- const tPost = tick ( )
1116
- // Run project-configured post-setup once in shell fast path (idempotent)
1117
- await maybeRunProjectPostSetup ( projectDir , envDir , true )
1118
- addTiming ( 'postSetup' , tPost )
1108
+ // Skip all expensive operations in shell integration mode for instant activation
1109
+ // Services, PHP ini, and post-setup will be handled by regular dev command when needed
1110
+ if ( isVerbose ) {
1111
+ try {
1112
+ process . stderr . write ( `🔍 Shell fast path: skipping services/php/post-setup for performance\n` )
1113
+ }
1114
+ catch { }
1119
1115
}
1120
- catch { }
1121
1116
}
1122
1117
1123
1118
const tOut1 = tick ( )
@@ -1306,51 +1301,66 @@ export async function dump(dir: string, options: DumpOptions = {}): Promise<void
1306
1301
const globalBinPath = path . join ( globalEnvDir , 'bin' )
1307
1302
const globalSbinPath = path . join ( globalEnvDir , 'sbin' )
1308
1303
1309
- // Check what packages are actually missing and need installation
1310
- const packageStatus = needsPackageInstallation ( localPackages , globalPackages , envDir , globalEnvDir )
1311
-
1312
- // Install missing packages if any are found
1313
- if ( packageStatus . needsLocal || packageStatus . needsGlobal ) {
1314
- const tInstall = tick ( )
1315
- await installPackagesOptimized (
1316
- packageStatus . missingLocal ,
1317
- packageStatus . missingGlobal ,
1318
- envDir ,
1319
- globalEnvDir ,
1320
- dryrun ,
1321
- quiet ,
1322
- )
1323
- addTiming ( 'install(packages)' , tInstall )
1304
+ // In shell integration mode with ready environment, skip package installation checks
1305
+ const readyMarker = path . join ( envDir , '.launchpad_ready' )
1306
+ const isEnvReady = fs . existsSync ( readyMarker )
1307
+
1308
+ if ( ! isEnvReady ) {
1309
+ // Check what packages are actually missing and need installation
1310
+ const packageStatus = needsPackageInstallation ( localPackages , globalPackages , envDir , globalEnvDir )
1311
+
1312
+ // Install missing packages if any are found
1313
+ if ( packageStatus . needsLocal || packageStatus . needsGlobal ) {
1314
+ const tInstall = tick ( )
1315
+ await installPackagesOptimized (
1316
+ packageStatus . missingLocal ,
1317
+ packageStatus . missingGlobal ,
1318
+ envDir ,
1319
+ globalEnvDir ,
1320
+ dryrun ,
1321
+ quiet ,
1322
+ )
1323
+ addTiming ( 'install(packages)' , tInstall )
1324
+ }
1324
1325
}
1325
-
1326
- // Create PHP shims after all dependencies are installed
1327
- if ( config . verbose ) {
1328
- console . log ( '🔍 Checking for PHP installations to create shims...' )
1326
+ else if ( isVerbose ) {
1327
+ try {
1328
+ process . stderr . write ( `🔍 Shell integration: environment ready, skipping package checks\n` )
1329
+ }
1330
+ catch { }
1329
1331
}
1330
- const tShim = tick ( )
1331
- await createPhpShimsAfterInstall ( envDir )
1332
- addTiming ( 'createPhpShims' , tShim )
1333
1332
1334
- // Start services during shell integration when configured
1335
- try {
1336
- const tSvc2 = tick ( )
1337
- await setupProjectServices ( projectDir , sniffResult , true )
1338
- addTiming ( 'setupServices' , tSvc2 )
1333
+ // Create PHP shims only if environment was just created or updated
1334
+ if ( ! isEnvReady ) {
1335
+ if ( config . verbose ) {
1336
+ console . log ( '🔍 Checking for PHP installations to create shims...' )
1337
+ }
1338
+ const tShim = tick ( )
1339
+ if ( isShellIntegration ) {
1340
+ // Run PHP shim creation in background to avoid blocking shell activation
1341
+ createPhpShimsAfterInstall ( envDir ) . catch ( ( ) => { } ) // Fire and forget
1342
+ addTiming ( 'createPhpShims(async)' , tShim )
1343
+ }
1344
+ else {
1345
+ await createPhpShimsAfterInstall ( envDir )
1346
+ addTiming ( 'createPhpShims' , tShim )
1347
+ }
1348
+ }
1349
+ else if ( isVerbose ) {
1350
+ try {
1351
+ process . stderr . write ( `🔍 Shell integration: environment ready, skipping PHP shim creation\n` )
1352
+ }
1353
+ catch { }
1339
1354
}
1340
- catch { }
1341
-
1342
- // Ensure project php.ini exists only
1343
- const tIni2 = tick ( )
1344
- await ensureProjectPhpIni ( projectDir , envDir )
1345
- addTiming ( 'ensurePhpIni' , tIni2 )
1346
1355
1347
- // Run project-configured post-setup once (idempotent marker)
1348
- try {
1349
- const tPost2 = tick ( )
1350
- await maybeRunProjectPostSetup ( projectDir , envDir , true )
1351
- addTiming ( 'postSetup' , tPost2 )
1356
+ // Skip expensive operations in shell integration mode for instant activation
1357
+ // Services, PHP ini, and post-setup will be handled by regular dev command when needed
1358
+ if ( isVerbose ) {
1359
+ try {
1360
+ process . stderr . write ( `🔍 Shell integration: skipping services/php/post-setup for performance\n` )
1361
+ }
1362
+ catch { }
1352
1363
}
1353
- catch { }
1354
1364
1355
1365
const tOut2 = tick ( )
1356
1366
outputShellCode ( dir , envBinPath , envSbinPath , projectHash , sniffResult , globalBinPath , globalSbinPath )
@@ -1414,10 +1424,12 @@ export async function dump(dir: string, options: DumpOptions = {}): Promise<void
1414
1424
}
1415
1425
1416
1426
// Ensure php.ini and Laravel post-setup runs (regular path)
1417
- const tIni3 = tick ( )
1418
- await ensureProjectPhpIni ( projectDir , envDir )
1419
- addTiming ( 'ensurePhpIni' , tIni3 )
1427
+ // Skip expensive operations in shell integration mode
1420
1428
if ( ! isShellIntegration ) {
1429
+ const tIni3 = tick ( )
1430
+ await ensureProjectPhpIni ( projectDir , envDir )
1431
+ addTiming ( 'ensurePhpIni' , tIni3 )
1432
+
1421
1433
const tPost3 = tick ( )
1422
1434
await maybeRunProjectPostSetup ( projectDir , envDir , isShellIntegration )
1423
1435
addTiming ( 'postSetup' , tPost3 )
@@ -1475,16 +1487,18 @@ export async function dump(dir: string, options: DumpOptions = {}): Promise<void
1475
1487
addTiming ( 'total' , tTotal )
1476
1488
flushTimings ( 'regular-activation' )
1477
1489
1478
- // Post-activation hook (file-level then config)
1479
- if ( dependencyFile ) {
1480
- const filePostActivation = extractHookCommandsFromDepsYaml ( dependencyFile , 'postActivation' )
1481
- if ( filePostActivation . length > 0 ) {
1482
- await executepostSetup ( projectDir , filePostActivation )
1490
+ // Post-activation hook (file-level then config) - skip in shell integration mode for performance
1491
+ if ( ! isShellIntegration ) {
1492
+ if ( dependencyFile ) {
1493
+ const filePostActivation = extractHookCommandsFromDepsYaml ( dependencyFile , 'postActivation' )
1494
+ if ( filePostActivation . length > 0 ) {
1495
+ await executepostSetup ( projectDir , filePostActivation )
1496
+ }
1497
+ }
1498
+ const postActivation = config . postActivation
1499
+ if ( postActivation ?. enabled ) {
1500
+ await executepostSetup ( projectDir , postActivation . commands || [ ] )
1483
1501
}
1484
- }
1485
- const postActivation = config . postActivation
1486
- if ( postActivation ?. enabled ) {
1487
- await executepostSetup ( projectDir , postActivation . commands || [ ] )
1488
1502
}
1489
1503
}
1490
1504
}
@@ -1910,8 +1924,8 @@ function outputShellCode(dir: string, envBinPath: string, envSbinPath: string, p
1910
1924
process . stdout . write ( ` ;;\n` )
1911
1925
process . stdout . write ( ` esac\n` )
1912
1926
process . stdout . write ( `}\n` )
1913
- // Refresh the command hash so version switches take effect immediately
1914
- process . stdout . write ( `hash -r 2>/dev/null || true\n` )
1927
+ // Refresh the command hash so version switches take effect immediately (async)
1928
+ process . stdout . write ( `{ hash -r 2>/dev/null || true; } & \n` )
1915
1929
}
1916
1930
1917
1931
/**
@@ -1966,8 +1980,13 @@ async function createPhpShimsAfterInstall(envDir: string): Promise<void> {
1966
1980
/**
1967
1981
* Run Laravel post-setup commands once per project activation
1968
1982
*/
1969
- async function maybeRunProjectPostSetup ( projectDir : string , envDir : string , _isShellIntegration : boolean ) : Promise < void > {
1983
+ async function maybeRunProjectPostSetup ( projectDir : string , envDir : string , isShellIntegration : boolean ) : Promise < void > {
1970
1984
try {
1985
+ // Skip post-setup entirely in shell integration mode for performance
1986
+ if ( isShellIntegration ) {
1987
+ return
1988
+ }
1989
+
1971
1990
if ( process . env . LAUNCHPAD_VERBOSE === 'true' ) {
1972
1991
console . warn ( `maybeRunProjectPostSetup called: projectDir=${ projectDir } , envDir=${ envDir } ` )
1973
1992
}
@@ -2050,6 +2069,9 @@ async function setupProjectServices(projectDir: string, sniffResult: any, showMe
2050
2069
try {
2051
2070
// Check services.autoStart configuration from deps.yaml
2052
2071
if ( ! sniffResult ?. services ?. enabled || ! sniffResult . services . autoStart || sniffResult . services . autoStart . length === 0 ) {
2072
+ if ( showMessages && process . env . LAUNCHPAD_VERBOSE === 'true' ) {
2073
+ console . log ( '🔍 No services configured in deps.yaml - skipping service setup' )
2074
+ }
2053
2075
return // No services to auto-start
2054
2076
}
2055
2077
0 commit comments