-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working automatic
composer require
on add ss ref. Fixes for update …
…reference.
- Loading branch information
Showing
5 changed files
with
248 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/net/servicestack/idea/php/ComposerPackageManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package net.servicestack.idea.php; | ||
|
||
import com.intellij.execution.process.CapturingProcessAdapter; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import com.jetbrains.php.composer.ComposerDataService; | ||
import com.jetbrains.php.composer.ComposerUtils; | ||
import com.jetbrains.php.composer.actions.ComposerCommandExecutor; | ||
import com.jetbrains.php.composer.actions.ComposerCommandRunner; | ||
import com.jetbrains.php.composer.actions.ComposerUpdateAction; | ||
import com.jetbrains.php.composer.addDependency.ComposerPackage; | ||
import com.jetbrains.php.composer.addDependency.ComposerPackagesUtil; | ||
import com.jetbrains.php.composer.execution.ComposerExecution; | ||
import com.jetbrains.php.composer.statistics.ComposerActionStatistics; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class ComposerPackageManager { | ||
|
||
private final Project project; | ||
|
||
public ComposerPackageManager(Project project) { | ||
this.project = project; | ||
} | ||
|
||
public ComposerPackage findPackage(DependentPackage dependentPackage) { | ||
ComposerExecution execution = ComposerDataService.getInstance(project).getComposerExecution(); | ||
ComposerCommandRunner executor = new ComposerCommandRunner(execution, project, project.getBasePath(), new ComposerProgressIndicator()); | ||
CapturingProcessAdapter outputCapturingAdapter = new CapturingProcessAdapter(); | ||
List<String> command = Arrays.asList("show", dependentPackage.getName(), "--no-ansi", "-d", project.getBasePath()); | ||
ComposerCommandRunner.ExecutionResult executionResult = executor.runCommand(command, outputCapturingAdapter); | ||
if (executionResult.myProgressIndicatorCancelled || !executionResult.isSuccess()) { | ||
return null; | ||
} | ||
|
||
try { | ||
return ComposerPackagesUtil.parsePackageDescriptionCommandOutput(dependentPackage.getName(), outputCapturingAdapter.getOutput().getStdout()); | ||
} catch (IOException e) { | ||
return null; | ||
} | ||
} | ||
|
||
public void installPackage(DependentPackage dependentPackage, VirtualFile configFile) { | ||
ComposerCommandExecutor commandExecutor = ComposerUpdateAction.createExecutor( | ||
project, | ||
configFile, | ||
"--no-interaction --no-ansi -d " + project.getBasePath(), | ||
"", | ||
ComposerActionStatistics.Action.REQUIRE, | ||
ComposerUtils.getInstallationCommand(dependentPackage.getName(), dependentPackage.getVersion())); | ||
commandExecutor.execute(); | ||
} | ||
|
||
public enum DependentPackage { | ||
SERVICESTACK_CLIENT("servicestack/client", ""); | ||
private final String name; | ||
private final String version; | ||
|
||
DependentPackage(String name, String version) { | ||
this.name = name; | ||
this.version = version; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getVersion() { | ||
return version; | ||
} | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
src/main/java/net/servicestack/idea/php/ComposerProgressIndicator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package net.servicestack.idea.php; | ||
|
||
import com.intellij.openapi.application.ModalityState; | ||
import com.intellij.openapi.progress.ProcessCanceledException; | ||
import com.intellij.openapi.progress.ProgressIndicator; | ||
import com.intellij.openapi.util.NlsContexts; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class ComposerProgressIndicator implements ProgressIndicator { | ||
@Override | ||
public void start() { | ||
|
||
} | ||
|
||
@Override | ||
public void stop() { | ||
|
||
} | ||
|
||
@Override | ||
public boolean isRunning() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void cancel() { | ||
|
||
} | ||
|
||
@Override | ||
public boolean isCanceled() { | ||
return false; | ||
} | ||
|
||
|
||
@Override | ||
public void setText(@NlsContexts.ProgressText String text) { | ||
|
||
} | ||
|
||
@Override | ||
public @NlsContexts.ProgressText String getText() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setText2(@NlsContexts.ProgressDetails String text) { | ||
|
||
} | ||
|
||
@Override | ||
public @NlsContexts.ProgressDetails String getText2() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public double getFraction() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void setFraction(double fraction) { | ||
|
||
} | ||
|
||
@Override | ||
public void pushState() { | ||
|
||
} | ||
|
||
@Override | ||
public void popState() { | ||
|
||
} | ||
|
||
@Override | ||
public boolean isModal() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public @NotNull ModalityState getModalityState() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setModalityProgress(@Nullable ProgressIndicator modalityProgress) { | ||
|
||
} | ||
|
||
@Override | ||
public boolean isIndeterminate() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void setIndeterminate(boolean indeterminate) { | ||
|
||
} | ||
|
||
@Override | ||
public void checkCanceled() throws ProcessCanceledException { | ||
|
||
} | ||
|
||
@Override | ||
public boolean isPopupWasShown() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isShowing() { | ||
return false; | ||
} | ||
} |