-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
150 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.DS_Store | ||
.git | ||
.gitignore | ||
.gitlab-ci.yml | ||
.editorconfig | ||
.travis.yml | ||
behat.yml | ||
circle.yml | ||
bin/ | ||
features/ | ||
utils/ | ||
*.zip | ||
*.tar.gz | ||
*.swp | ||
*.txt | ||
*.log |
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,25 @@ | ||
# This file is for unifying the coding style for different editors and IDEs | ||
# editorconfig.org | ||
|
||
# WordPress Coding Standards | ||
# https://make.wordpress.org/core/handbook/coding-standards/ | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
indent_style = tab | ||
|
||
[{.jshintrc,*.json,*.yml,*.feature}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[{*.txt,wp-config-sample.php}] | ||
end_of_line = crlf | ||
|
||
[composer.json] | ||
indent_style = space | ||
indent_size = 4 |
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,12 @@ | ||
.DS_Store | ||
wp-cli.local.yml | ||
node_modules/ | ||
vendor/ | ||
*.zip | ||
*.tar.gz | ||
*.swp | ||
*.txt | ||
*.log | ||
composer.lock | ||
.idea | ||
*.db |
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,25 @@ | ||
{ | ||
"name": "easyengine/shell-command", | ||
"description": "Shell to run helpful commands inside containers.", | ||
"type": "ee-cli-package", | ||
"homepage": "https://github.com/easyengine/shell-command", | ||
"license": "MIT", | ||
"authors": [], | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"autoload": { | ||
"psr-4": { | ||
"": "src/" | ||
}, | ||
"files": [ "shell-command.php" ] | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.x-dev" | ||
}, | ||
"bundled": true, | ||
"commands": [ | ||
"shell" | ||
] | ||
} | ||
} |
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,2 @@ | ||
require: | ||
- shell-command.php |
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,12 @@ | ||
<?php | ||
|
||
if ( ! class_exists( 'EE' ) ) { | ||
return; | ||
} | ||
|
||
$autoload = dirname( __FILE__ ) . '/vendor/autoload.php'; | ||
if ( file_exists( $autoload ) ) { | ||
require_once $autoload; | ||
} | ||
|
||
EE::add_command( 'shell', 'Shell_Command' ); |
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,58 @@ | ||
<?php | ||
|
||
/** | ||
* Executes wp-cli command on a site. | ||
* | ||
* ## EXAMPLES | ||
* | ||
* # Create simple WordPress site | ||
* $ ee wp test.local plugin list | ||
* | ||
* @package ee-cli | ||
*/ | ||
|
||
use EE\Utils; | ||
|
||
class Shell_Command extends EE_Command { | ||
|
||
/** | ||
* Brings up a shell to run wp-cli, composer etc. | ||
* | ||
* ## OPTIONS | ||
* | ||
* [<site-name>] | ||
* : Name of website to run shell on. | ||
*/ | ||
public function __invoke( $args ) { | ||
EE\Utils\delem_log( 'ee shell start' ); | ||
$args = EE\Utils\set_site_arg( $args, 'shell' ); | ||
$site_name = EE\Utils\remove_trailing_slash( $args[0] ); | ||
if ( EE::db()::site_in_db( $site_name ) ) { | ||
$db_select = EE::db()::select( ['site_path'], ['sitename' => $site_name]); | ||
$site_root = $db_select[0]['site_path']; | ||
} else { | ||
EE::error( "Site $site_name does not exist." ); | ||
} | ||
chdir($site_root); | ||
$this->run( "docker-compose exec --user='www-data' php bash" ); | ||
EE\Utils\delem_log( 'ee shell end' ); | ||
} | ||
|
||
private function run( $cmd, $descriptors = null ) { | ||
EE\Utils\check_proc_available( 'ee_shell' ); | ||
if ( ! $descriptors ) { | ||
$descriptors = array( STDIN, STDOUT, STDERR ); | ||
} | ||
|
||
$final_cmd = EE\Utils\force_env_on_nix_systems( $cmd ); | ||
$proc = EE\Utils\proc_open_compat( $final_cmd, $descriptors, $pipes ); | ||
if ( ! $proc ) { | ||
exit( 1 ); | ||
} | ||
$r = proc_close( $proc ); | ||
if ( $r ) { | ||
exit( $r ); | ||
} | ||
} | ||
|
||
} |