@@ -9,7 +9,7 @@ import com.intellij.openapi.project.Project
99import com.intellij.openapi.util.Key
1010
1111object ComposerUtil {
12- private val LOG = Logger .getInstance(ComposerUtil ::class .java)
12+ private val log = Logger .getInstance(ComposerUtil ::class .java)
1313 private var composerGlobalDir: String? = null
1414 private var isComposerAvailable: Boolean? = null
1515
@@ -31,10 +31,10 @@ object ComposerUtil {
3131 processHandler.waitFor()
3232
3333 isComposerAvailable = processHandler.exitCode == 0
34- LOG .debug(" Composer availability check: $isComposerAvailable " )
34+ log .debug(" Composer availability check: $isComposerAvailable " )
3535 return isComposerAvailable!!
3636 } catch (e: Exception ) {
37- LOG .warn(" Failed to check composer availability: ${e.message} " )
37+ log .warn(" Failed to check composer availability: ${e.message} " )
3838 isComposerAvailable = false
3939 return false
4040 }
@@ -69,16 +69,16 @@ object ComposerUtil {
6969 if (processHandler.exitCode == 0 && output.isNotEmpty()) {
7070 // Clean up the output - remove any extra whitespace or newlines
7171 composerGlobalDir = output.toString().trim()
72- LOG .debug(" Found composer global directory: $composerGlobalDir " )
72+ log .debug(" Found composer global directory: $composerGlobalDir " )
7373 return composerGlobalDir
7474 } else {
75- LOG .warn(" Composer command exited with code ${processHandler.exitCode} or empty output" )
75+ log .warn(" Composer command exited with code ${processHandler.exitCode} or empty output" )
7676 }
7777 } catch (e: Exception ) {
78- LOG .error(" Failed to get composer global directory: ${e.message} " , e)
78+ log .error(" Failed to get composer global directory: ${e.message} " , e)
7979 }
8080 } else {
81- LOG .warn(" Composer is not available, falling back to default locations" )
81+ log .warn(" Composer is not available, falling back to default locations" )
8282 }
8383
8484 // Fallback to default locations if composer command fails
@@ -91,13 +91,13 @@ object ComposerUtil {
9191 for (location in possibleLocations) {
9292 val dir = java.io.File (location)
9393 if (dir.exists() && dir.isDirectory) {
94- LOG .debug(" Using fallback composer global directory: $location " )
94+ log .debug(" Using fallback composer global directory: $location " )
9595 composerGlobalDir = location
9696 return composerGlobalDir
9797 }
9898 }
9999
100- LOG .warn(" Could not determine composer global directory" )
100+ log .warn(" Could not determine composer global directory" )
101101 return null
102102 }
103103
@@ -130,13 +130,13 @@ object ComposerUtil {
130130 fun runComposerInstall (project : Project , directory : String ): Boolean {
131131 // First check if composer is available
132132 if (! isComposerAvailable()) {
133- LOG .warn(" Composer is not available, skipping composer install" )
133+ log .warn(" Composer is not available, skipping composer install" )
134134 return false
135135 }
136136
137137 val workDir = java.io.File (directory)
138138 if (! workDir.exists() || ! workDir.isDirectory) {
139- LOG .debug(" Directory does not exist or is not a directory: $directory " )
139+ log .debug(" Directory does not exist or is not a directory: $directory " )
140140 return false
141141 }
142142
@@ -148,12 +148,12 @@ object ComposerUtil {
148148 val processHandler = OSProcessHandler (commandLine)
149149 processHandler.addProcessListener(object : ProcessAdapter () {
150150 override fun onTextAvailable (event : ProcessEvent , outputType : Key <* >) {
151- LOG .debug(" Composer install output: ${event.text} " )
151+ log .debug(" Composer install output: ${event.text} " )
152152 }
153153
154154 override fun processTerminated (event : ProcessEvent ) {
155155 if (event.exitCode != 0 ) {
156- LOG .warn(" Composer install failed with exit code: ${event.exitCode} " )
156+ log .warn(" Composer install failed with exit code: ${event.exitCode} " )
157157 }
158158 }
159159 })
@@ -163,17 +163,17 @@ object ComposerUtil {
163163
164164 return processHandler.exitCode == 0
165165 } catch (e: Exception ) {
166- LOG .error(" Failed to run composer install: ${e.message} " , e)
166+ log .error(" Failed to run composer install: ${e.message} " , e)
167167 return false
168168 }
169169 }
170170
171171 fun setupMoodleCs (project : Project ): Boolean {
172- LOG .debug(" Setting up Moodle CS..." )
172+ log .debug(" Setting up Moodle CS..." )
173173
174174 // First check if composer is available
175175 if (! isComposerAvailable()) {
176- LOG .warn(" Composer is not available, skipping Moodle CS setup" )
176+ log .warn(" Composer is not available, skipping Moodle CS setup" )
177177 return false
178178 }
179179
@@ -186,7 +186,7 @@ object ComposerUtil {
186186 val phpcbfFile = java.io.File (phpcbfPath)
187187
188188 if (phpcsFile.exists() && phpcbfFile.exists()) {
189- LOG .debug(" PHPCS and PHPCBF already exist, checking if moodle standard is available" )
189+ log .debug(" PHPCS and PHPCBF already exist, checking if moodle standard is available" )
190190
191191 // Check if moodle standard is available
192192 try {
@@ -205,32 +205,32 @@ object ComposerUtil {
205205 processHandler.waitFor()
206206
207207 if (processHandler.exitCode == 0 && output.toString().lowercase().contains(" moodle" )) {
208- LOG .debug(" Moodle standard is already available" )
208+ log .debug(" Moodle standard is already available" )
209209 return true
210210 }
211211 } catch (e: Exception ) {
212- LOG .warn(" Failed to check if moodle standard is available: ${e.message} " )
212+ log .warn(" Failed to check if moodle standard is available: ${e.message} " )
213213 // Continue with setup
214214 }
215215 }
216216 }
217217
218218 try {
219219 // Set minimum-stability to dev
220- LOG .debug(" Setting composer minimum-stability to dev" )
220+ log .debug(" Setting composer minimum-stability to dev" )
221221 if (! executeComposerCommand(project, listOf (" global" , " config" , " minimum-stability" , " dev" ))) {
222- LOG .warn(" Failed to set composer minimum-stability to dev, but continuing with installation" )
222+ log .warn(" Failed to set composer minimum-stability to dev, but continuing with installation" )
223223 }
224224
225225 // Install moodlehq/moodle-cs
226- LOG .debug(" Installing moodlehq/moodle-cs" )
226+ log .debug(" Installing moodlehq/moodle-cs" )
227227 if (! executeComposerCommand(project, listOf (" global" , " require" , " moodlehq/moodle-cs" ))) {
228- LOG .error(" Failed to install moodlehq/moodle-cs" )
228+ log .error(" Failed to install moodlehq/moodle-cs" )
229229
230230 // Try alternative approach - install with --dev flag
231- LOG .debug(" Trying alternative approach with --dev flag" )
231+ log .debug(" Trying alternative approach with --dev flag" )
232232 if (! executeComposerCommand(project, listOf (" global" , " require" , " --dev" , " moodlehq/moodle-cs" ))) {
233- LOG .error(" Failed to install moodlehq/moodle-cs with --dev flag" )
233+ log .error(" Failed to install moodlehq/moodle-cs with --dev flag" )
234234 return false
235235 }
236236 }
@@ -244,23 +244,23 @@ object ComposerUtil {
244244 val newPhpcbfFile = java.io.File (newPhpcbfPath)
245245
246246 if (newPhpcsFile.exists() && newPhpcbfFile.exists()) {
247- LOG .debug(" Successfully installed PHPCS and PHPCBF" )
247+ log .debug(" Successfully installed PHPCS and PHPCBF" )
248248 return true
249249 }
250250 }
251251
252- LOG .warn(" PHPCS or PHPCBF not found after installation" )
252+ log .warn(" PHPCS or PHPCBF not found after installation" )
253253 return false
254254 } catch (e: Exception ) {
255- LOG .error(" Error setting up Moodle CS: ${e.message} " , e)
255+ log .error(" Error setting up Moodle CS: ${e.message} " , e)
256256 return false
257257 }
258258 }
259259
260260 private fun executeComposerCommand (project : Project , arguments : List <String >): Boolean {
261261 // First check if composer is available
262262 if (! isComposerAvailable()) {
263- LOG .warn(" Composer is not available, skipping composer command: ${arguments.joinToString(" " )} " )
263+ log .warn(" Composer is not available, skipping composer command: ${arguments.joinToString(" " )} " )
264264 return false
265265 }
266266
@@ -274,13 +274,13 @@ object ComposerUtil {
274274 val processHandler = OSProcessHandler (commandLine)
275275 processHandler.addProcessListener(object : ProcessAdapter () {
276276 override fun onTextAvailable (event : ProcessEvent , outputType : Key <* >) {
277- LOG .debug(" Composer output: ${event.text} " )
277+ log .debug(" Composer output: ${event.text} " )
278278 }
279279
280280 override fun processTerminated (event : ProcessEvent ) {
281281 success = event.exitCode == 0
282282 if (! success) {
283- LOG .warn(" Composer command failed with exit code: ${event.exitCode} " )
283+ log .warn(" Composer command failed with exit code: ${event.exitCode} " )
284284 }
285285 }
286286 })
@@ -290,8 +290,8 @@ object ComposerUtil {
290290
291291 return success
292292 } catch (e: Exception ) {
293- LOG .error(" Failed to execute composer command: ${e.message} " , e)
293+ log .error(" Failed to execute composer command: ${e.message} " , e)
294294 return false
295295 }
296296 }
297- }
297+ }
0 commit comments