Skip to content

Commit 8e2da8f

Browse files
committed
v1.0.1 Ignore if livewire installed
1 parent 9d8f355 commit 8e2da8f

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ For FluxUI I have to change file like
2222

2323
So, I decided to create this package. If you are also same like me then you can use this package in your next **Laravel** project.
2424

25-
## How to use
25+
## How to install
2626

2727
### In your laravel project
2828

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codingwithrk/rk-project-setup",
3-
"description": "Auto-setup a new Laravel project with NPM + Livewire + Flux",
3+
"description": "Auto-setup a new Laravel project with NPM + Livewire + FluxUI",
44
"type": "composer-plugin",
55
"license": "MIT",
66
"authors": [

src/ProjectSetupInstaller.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ public function handlePostInstall(PackageEvent $event)
3939
shell_exec("npm install");
4040
$io->write("<comment>✅ npm install completed!</comment>");
4141

42+
if ($this->isPackageInstalled('livewire/livewire')) {
43+
$io->write("<comment>⚠️ Livewire already installed. Skipping rk-project-setup.</comment>");
44+
return;
45+
}
46+
4247
// Install Livewire
4348
$io->write("<info>📦 Installing Livewire...</info>");
4449
shell_exec("composer require livewire/livewire");
@@ -110,4 +115,28 @@ public function handlePostInstall(PackageEvent $event)
110115
$io->write("<info>🎉 rk-project-setup completed successfully!</info>");
111116
}
112117

118+
119+
protected function isPackageInstalled(string $package): bool
120+
{
121+
$installedFile = __DIR__ . '/../../../composer/installed.json';
122+
123+
if (!file_exists($installedFile)) {
124+
return false;
125+
}
126+
127+
$installed = json_decode(file_get_contents($installedFile), true);
128+
129+
if (isset($installed['packages'])) {
130+
$installed = $installed['packages']; // Composer 2.x
131+
}
132+
133+
foreach ($installed as $pkg) {
134+
if (isset($pkg['name']) && $pkg['name'] === $package) {
135+
return true;
136+
}
137+
}
138+
139+
return false;
140+
}
141+
113142
}

0 commit comments

Comments
 (0)