Skip to content

Commit 993d008

Browse files
committed
fix: set up temporary vite 8 conflict resolution
1 parent b708b90 commit 993d008

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎src/ViewInstallCommand.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ protected function installReact()
150150

151151
$this->writeln("📦 <info>Installing react...</info>\n");
152152

153-
if (!sprout()->npm($this->option('pm'))->install('@leafphp/vite-plugin @vitejs/plugin-react @inertiajs/react react@18 react-dom@18')->isSuccessful()) {
153+
if (!sprout()->npm($this->option('pm'))->install('@leafphp/vite-plugin @vitejs/plugin-react@^5.0 @inertiajs/react react@18 react-dom@18')->isSuccessful()) {
154154
$this->writeln('❌ <error>Failed to install react</error>');
155155

156156
return 1;
@@ -214,7 +214,7 @@ protected function installSvelte()
214214

215215
$this->writeln("📦 <info>Installing svelte...</info>\n");
216216

217-
if (!sprout()->npm($this->option('pm'))->install('@leafphp/vite-plugin svelte @sveltejs/vite-plugin-svelte @inertiajs/svelte')->isSuccessful()) {
217+
if (!sprout()->npm($this->option('pm'))->install('@leafphp/vite-plugin svelte @sveltejs/vite-plugin-svelte@^6.0 @inertiajs/svelte')->isSuccessful()) {
218218
$this->writeln('❌ <error>Failed to install svelte</error>');
219219

220220
return 1;
@@ -352,7 +352,7 @@ protected function installVite()
352352

353353
$this->writeln("📦 <info>Installing vite...</info>\n");
354354

355-
if (!sprout()->npm($this->option('pm'))->install('@leafphp/vite-plugin vite')->isSuccessful()) {
355+
if (!sprout()->npm($this->option('pm'))->install('@leafphp/vite-plugin vite@^7.0')->isSuccessful()) {
356356
$this->writeln('❌ <error>Failed to install vite</error>');
357357

358358
return 1;
@@ -392,7 +392,7 @@ protected function installVue()
392392

393393
$this->writeln("📦 <info>Installing Vue...</info>\n");
394394

395-
if (!sprout()->npm($this->option('pm'))->install('@leafphp/vite-plugin @vitejs/plugin-vue @inertiajs/vue3@^1.0 vue')->isSuccessful()) {
395+
if (!sprout()->npm($this->option('pm'))->install('@leafphp/vite-plugin @vitejs/plugin-vue@^6.0 @inertiajs/vue3@^1.0 vue')->isSuccessful()) {
396396
$this->writeln('❌ <error>Failed to install Vue</error>');
397397

398398
return 1;

‎tests/commands.test.php‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,23 @@
101101
expect($theme['require']['leafs/leaf'])->toStartWith('^');
102102
});
103103

104+
test('view:install pins every vite-adjacent npm package', function () {
105+
$source = file_get_contents(dirname(__DIR__) . '/src/ViewInstallCommand.php');
106+
107+
// unpinned @vitejs/* and vite resolve to whatever npm's latest is —
108+
// when vite 8 shipped, latest plugin-react moved to a peer range
109+
// @leafphp/vite-plugin doesn't allow, and every install ERESOLVE'd
110+
preg_match_all('/->install\(\'([^\']+)\'\)/', $source, $matches);
111+
112+
foreach ($matches[1] as $packageList) {
113+
foreach (explode(' ', $packageList) as $package) {
114+
if (preg_match('/^(@vitejs\/|@sveltejs\/|vite$)/', $package)) {
115+
expect($package)->toContain('@^');
116+
}
117+
}
118+
}
119+
});
120+
104121
test('lite apps are born AI-ready', function () {
105122
leaf('create my-app --lite');
106123

0 commit comments

Comments
 (0)