Skip to content

Commit

Permalink
Support for installing with Composer #63
Browse files Browse the repository at this point in the history
  • Loading branch information
junichi11 committed Oct 17, 2013
1 parent e38167f commit c39e8b8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
8 changes: 3 additions & 5 deletions src/org/cakephp/netbeans/commands/CakeScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,9 @@ public static String getOptionsPath() {

public void runCommand(PhpModule phpModule, List<String> parameters, Runnable postExecution) {
CakePhpModule cakeModule = CakePhpModule.forPhpModule(phpModule);
if (!"app".equals(cakeModule.getAppName())) { // NOI18N
FileObject app = CakePhpModule.forPhpModule(phpModule).getDirectory(CakePhpModule.DIR_TYPE.APP);
appParams.add("-app"); // NOI18N
appParams.add(app.getPath());
}
FileObject app = cakeModule.getDirectory(CakePhpModule.DIR_TYPE.APP);
appParams.add("-app"); // NOI18N
appParams.add(app.getPath());
createPhpExecutable(phpModule)
.displayName(getDisplayName(phpModule, parameters.get(0)))
.additionalParameters(getAllParams(parameters))
Expand Down
14 changes: 12 additions & 2 deletions src/org/cakephp/netbeans/module/CakePhp2ModuleImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ public FileObject getDirectory(DIR_TYPE type) {
case APP_VENDOR:
return getAppDirectory(type);
case CORE:
path = "lib/Cake"; // NOI18N
break;
return getCoreDirectory();
case PLUGIN:
path = "plugins"; // NOI18N
break;
Expand Down Expand Up @@ -260,6 +259,17 @@ private FileObject getAppDirectory(DIR_TYPE dirType) {
}
}

private FileObject getCoreDirectory() {
FileObject cakePhpDirectory = getCakePhpDirectory();
FileObject core = cakePhpDirectory.getFileObject("lib/Cake"); // NOI18N
if (core != null) {
return core;
}

// installing with Composer
return cakePhpDirectory.getFileObject("Vendor/pear-pear.cakephp.org/CakePHP/Cake"); // NOI18N
}

@Override
public String getFileNameWithExt(FILE_TYPE type, String name) {
if (type != null) {
Expand Down
15 changes: 13 additions & 2 deletions src/org/cakephp/netbeans/util/CakeVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ private CakeVersion(PhpModule pm) {
revision = -1;
notStable = ""; // NOI18N
} else {
cake = CakePhpModule.getCakePhpDirectory(pm).getFileObject("lib/Cake"); // NOI18N
FileObject cakePhpDirectory = CakePhpModule.getCakePhpDirectory(pm);
cake = cakePhpDirectory.getFileObject("lib/Cake"); // NOI18N

// installing with Composer
if (cake == null) {
cake = cakePhpDirectory.getFileObject("Vendor/pear-pear.cakephp.org/CakePHP/Cake"); // NOI18N
}

if (cake != null) {
FileObject app = CakePhpModule.getCakePhpDirectory(pm).getFileObject("App"); // NOI18N
if (app != null) {
Expand Down Expand Up @@ -184,11 +191,15 @@ private String getCakePhpVersion(PhpModule phpModule) {
} else {
version = root.getFileObject("lib/Cake/VERSION.txt"); // NOI18N
}
// installing with Composer
if (version == null) {
version = root.getFileObject("Vendor/pear-pear.cakephp.org/CakePHP/Cake/VERSION.txt"); // NOI18N
}
if (version == null) {
return null;
}
try {
versionNumber = "";
versionNumber = ""; // NOI18N
for (String line : version.asLines("UTF-8")) { // NOI18N
if (!line.contains("//") && !line.equals("")) { // NOI18N
line = line.trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ public CakePhpCustomizerValidator validateCakePhpPath(FileObject sourceDirectory
} else {
script = targetDirectory.getFileObject("lib/Cake/Console/cake.php"); // NOI18N
}

// installing with Composer
// cake.php Vendor/bin/cake.php | Vendor/pear-pear.cakephp.org/CakePHP/bin/cake.php
if (script == null) {
script = targetDirectory.getFileObject("Vendor/pear-pear.cakephp.org/CakePHP/bin/cake.php");
}

if (script == null) {
result.addWarning(new ValidationResult.Message("cake.script", Bundle.CakePhpCustomizerValidator_error_cake_script_invalid())); // NOI18N
}
Expand Down

0 comments on commit c39e8b8

Please sign in to comment.