File tree Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ For FluxUI I have to change file like
22
22
23
23
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.
24
24
25
- ## How to use
25
+ ## How to install
26
26
27
27
### In your laravel project
28
28
Original file line number Diff line number Diff line change 1
1
{
2
2
"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 " ,
4
4
"type" : " composer-plugin" ,
5
5
"license" : " MIT" ,
6
6
"authors" : [
Original file line number Diff line number Diff line change @@ -39,6 +39,11 @@ public function handlePostInstall(PackageEvent $event)
39
39
shell_exec ("npm install " );
40
40
$ io ->write ("<comment>✅ npm install completed!</comment> " );
41
41
42
+ if ($ this ->isPackageInstalled ('livewire/livewire ' )) {
43
+ $ io ->write ("<comment>⚠️ Livewire already installed. Skipping rk-project-setup.</comment> " );
44
+ return ;
45
+ }
46
+
42
47
// Install Livewire
43
48
$ io ->write ("<info>📦 Installing Livewire...</info> " );
44
49
shell_exec ("composer require livewire/livewire " );
@@ -110,4 +115,28 @@ public function handlePostInstall(PackageEvent $event)
110
115
$ io ->write ("<info>🎉 rk-project-setup completed successfully!</info> " );
111
116
}
112
117
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
+
113
142
}
You can’t perform that action at this time.
0 commit comments