diff --git a/composer.json b/composer.json index 945213b..ad31bfc 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "require": { "php": "^8.4", "composer-runtime-api": "^2.2", - "guzzlehttp/guzzle": "^7.16", + "guzzlehttp/guzzle": "^8.3", "illuminate/console": "^13.38", "illuminate/container": "^13.38", "illuminate/events": "^13.38", @@ -20,7 +20,7 @@ "illuminate/process": "^13.38" }, "require-dev": { - "phpunit/phpunit": "^11.5.57", + "phpunit/phpunit": "^13.4.3", "mockery/mockery": "^1.6.15" }, "autoload": { diff --git a/src/Console/Commands/StackCommand.php b/src/Console/Commands/StackCommand.php index 8cbcc2e..d065302 100644 --- a/src/Console/Commands/StackCommand.php +++ b/src/Console/Commands/StackCommand.php @@ -116,10 +116,6 @@ private function runDevMode(string $framework): int $ext = $this->appExtension($framework); $source = '../../'.self::CORE_STACK."/{$framework}/js"; $this->files->put($this->jsRoot."/app.{$ext}", "import '{$source}/app';\n"); - $this->files->put($this->jsRoot."/ssr.{$ext}", "export { default } from '{$source}/ssr';\n"); - - // module entry points must be written before skipGeneratedFiles so their paths are discovered - $this->updateModuleEntryPoints($framework); $this->writeProjectJson($framework); $this->skipGeneratedFiles($framework); @@ -158,12 +154,6 @@ private function runReset(): int $exitCode = Process::run(['git', '-C', $this->basePath, 'checkout', '--', $file])->exitCode(); if ($exitCode !== 0) { - // Module files are tracked in their own repos — skip-worktree was already - // cleared above; don't delete or warn, the content is already correct. - if (str_starts_with($file, 'modules/')) { - continue; - } - $abs = $this->basePath.'/'.$file; if ($this->files->exists($abs)) { $this->files->delete($abs); @@ -311,25 +301,6 @@ private function copyViewFiles(string $framework): void } } - private function updateModuleEntryPoints(string $framework): void - { - $moduleDirs = glob($this->basePath.'/modules/*/', GLOB_ONLYDIR); - - if (! $moduleDirs) { - return; - } - - foreach ($moduleDirs as $moduleDir) { - $jsRoot = $moduleDir.'resources/js'; - - if (! $this->files->isDirectory($jsRoot.'/'.$framework)) { - continue; - } - - $this->files->put($jsRoot.'/app.ts', "export * from './{$framework}/app';\n"); - } - } - // ------------------------------------------------------------------------- // Git helpers // ------------------------------------------------------------------------- @@ -419,14 +390,9 @@ private function generatedFiles(string $framework): array ...self::CONFIG_FILES, ...array_map(fn (string $f) => "resources/views/{$f}", self::VIEW_FILES), "resources/js/app.{$ext}", - "resources/js/ssr.{$ext}", 'saucebase.json', ]; - foreach (glob($this->basePath.'/modules/*/resources/js/app.ts') ?: [] as $path) { - $files[] = str_replace($this->basePath.'/', '', $path); - } - return $files; } } diff --git a/tests/Feature/StackCommandTest.php b/tests/Feature/StackCommandTest.php index b87e49c..95b9c2b 100644 --- a/tests/Feature/StackCommandTest.php +++ b/tests/Feature/StackCommandTest.php @@ -106,14 +106,15 @@ public function test_selecting_a_stack_keeps_the_other_settings(): void ); } - public function test_dev_mode_writes_app_and_ssr_shims(): void + public function test_dev_mode_writes_only_the_app_shim(): void { $this->seedFakeStubs('vue'); $this->artisan('stack vue --dev')->assertSuccessful(); $this->assertStringContainsString("import '../../vendor/saucebase/core/stubs/stack/vue/js/app'", file_get_contents($this->tmpDir.'/resources/js/app.ts')); - $this->assertStringContainsString("export { default } from '../../vendor/saucebase/core/stubs/stack/vue/js/ssr'", file_get_contents($this->tmpDir.'/resources/js/ssr.ts')); + // The Inertia Vite plugin renders on the server from app.ts: there is no ssr entry. + $this->assertFileDoesNotExist($this->tmpDir.'/resources/js/ssr.ts'); } public function test_dev_mode_react_writes_tsx_entry_points(): void @@ -123,7 +124,7 @@ public function test_dev_mode_react_writes_tsx_entry_points(): void $this->artisan('stack react --dev')->assertSuccessful(); $this->assertStringContainsString("import '../../vendor/saucebase/core/stubs/stack/react/js/app'", file_get_contents($this->tmpDir.'/resources/js/app.tsx')); - $this->assertStringContainsString("export { default } from '../../vendor/saucebase/core/stubs/stack/react/js/ssr'", file_get_contents($this->tmpDir.'/resources/js/ssr.tsx')); + $this->assertFileDoesNotExist($this->tmpDir.'/resources/js/ssr.tsx'); } public function test_dev_mode_runs_npm_install(): void @@ -205,15 +206,16 @@ public function test_dev_mode_does_not_rewrite_paths_in_config_files(): void $this->assertStringContainsString('vendor/saucebase/core/stubs/stack/vue/js/*', $tsconfig); } - public function test_dev_mode_writes_module_entry_point(): void + public function test_dev_mode_writes_no_module_entry_point(): void { $this->seedFakeStubs('vue'); $this->seedFakeModule('testmodule', 'vue'); $this->artisan('stack vue --dev')->assertSuccessful(); - $entryPoint = file_get_contents($this->tmpDir.'/modules/testmodule/resources/js/app.ts'); - $this->assertStringContainsString("from './vue/app'", $entryPoint); + // Core finds a module's setup in resources/js/vue/app.ts itself, so module + // repos carry no shim for the command to rewrite on every stack switch. + $this->assertFileDoesNotExist($this->tmpDir.'/modules/testmodule/resources/js/app.ts'); } public function test_dev_mode_skips_module_without_framework_dir(): void @@ -321,22 +323,21 @@ public function test_dev_mode_warns_for_untracked_entry_points(): void { $this->seedFakeStubs('react'); - // app.tsx and ssr.tsx are created by the command but not in git — warn for each + // app.tsx is created by the command but not in git — warn for it $this->artisan('stack react --dev') ->assertSuccessful() ->expectsOutputToContain('Could not skip-worktree resources/js/app.tsx') - ->expectsOutputToContain('Could not skip-worktree resources/js/ssr.tsx'); + ->doesntExpectOutputToContain('resources/js/ssr.tsx'); } - public function test_dev_mode_warns_for_untracked_module_entry_points(): void + public function test_dev_mode_leaves_module_files_out_of_skip_worktree(): void { $this->seedFakeStubs('vue'); $this->seedFakeModule('testmodule', 'vue'); - // module entry point not committed — should warn $this->artisan('stack vue --dev') ->assertSuccessful() - ->expectsOutputToContain('Could not skip-worktree modules/testmodule/resources/js/app.ts'); + ->doesntExpectOutputToContain('modules/testmodule'); } public function test_dev_mode_no_warnings_for_tracked_config_files(): void @@ -434,12 +435,10 @@ public function test_reset_deletes_generated_entry_points(): void $this->artisan('stack vue --dev')->assertSuccessful(); $this->assertFileExists($this->tmpDir.'/resources/js/app.ts'); - $this->assertFileExists($this->tmpDir.'/resources/js/ssr.ts'); $this->artisan('stack --reset')->assertSuccessful(); $this->assertFileDoesNotExist($this->tmpDir.'/resources/js/app.ts'); - $this->assertFileDoesNotExist($this->tmpDir.'/resources/js/ssr.ts'); } public function test_reset_preserves_module_entry_points(): void @@ -447,13 +446,14 @@ public function test_reset_preserves_module_entry_points(): void $this->seedFakeStubs('vue'); $this->seedFakeModule('testmodule', 'vue'); - $this->artisan('stack vue --dev')->assertSuccessful(); - $this->assertFileExists($this->tmpDir.'/modules/testmodule/resources/js/app.ts'); + // A flattened (installed) module keeps its real entry at the root. + file_put_contents($this->tmpDir.'/modules/testmodule/resources/js/app.ts', '// module'); + $this->artisan('stack vue --dev')->assertSuccessful(); $this->artisan('stack --reset')->assertSuccessful(); - // Module app.ts is tracked in the module's own repo — reset must not delete it. - $this->assertFileExists($this->tmpDir.'/modules/testmodule/resources/js/app.ts'); + // Module app.ts is tracked in the module's own repo — neither command touches it. + $this->assertSame('// module', file_get_contents($this->tmpDir.'/modules/testmodule/resources/js/app.ts')); } public function test_reset_deletes_package_lock(): void