Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
basic cli implementation
- Loading branch information
0 parents
commit b4b4abe
Showing
8 changed files
with
203 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,14 @@ | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
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,27 @@ | ||
# Autodetect text files | ||
* text=auto | ||
|
||
# ...Unless the name matches the following overriding patterns | ||
|
||
# Definitively text files | ||
*.php text | ||
*.css text | ||
*.js text | ||
*.txt text | ||
*.md text | ||
*.xml text | ||
*.json text | ||
*.bat text | ||
*.sql text | ||
*.yml text | ||
|
||
# Ensure those won't be messed up with | ||
*.png binary | ||
*.jpg binary | ||
*.gif binary | ||
*.ttf binary | ||
|
||
# Ignore some meta files when creating an archive of this repository | ||
/.editorconfig export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore |
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 @@ | ||
/*.local.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,11 @@ | ||
language: php | ||
|
||
php: | ||
- '7.0' | ||
- '7.1' | ||
- '7.2' | ||
- '7.3' | ||
- nightly | ||
|
||
script: | ||
- php -l yii-dev |
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,26 @@ | ||
Yii 3 development environment | ||
============================= | ||
|
||
This repo contains tools to set up a development environment for Yii 3 packages. | ||
|
||
It allows to work on separate packages and test the result in other packages at the same time. | ||
|
||
|
||
Requirements | ||
------------ | ||
|
||
- This is currently only tested on GNU/Linux, if you have another system, please try and report if something is not working. | ||
|
||
TBD | ||
|
||
Install | ||
------- | ||
|
||
TBD | ||
|
||
Usage | ||
----- | ||
|
||
TBD | ||
|
||
|
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 @@ | ||
* | ||
!.gitignore |
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,14 @@ | ||
<?php | ||
|
||
$packages = [ | ||
'yiisoft/di' => 'di', | ||
'yiisoft/core' => 'core', | ||
|
||
]; | ||
|
||
if (file_exists($localFile = __DIR__ . '/packages.local.php')) { | ||
$packages = array_merge($packages, require $localFile); | ||
} | ||
|
||
return $packages; | ||
|
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,108 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
if (PHP_MAJOR_VERSION < 7) { | ||
echo 'PHP 7.0 or higher is required to work with this tool. Yii 3.0 requires PHP 7.1!' . PHP_EOL; | ||
exit(1); | ||
} | ||
if (!isset($argv)) { | ||
$argv = $_SERVER['argv']; | ||
} | ||
$enableColor = DIRECTORY_SEPARATOR === '\\' | ||
? getenv('ANSICON') !== false || getenv('ConEmuANSI') === 'ON' | ||
: function_exists('posix_isatty') && @posix_isatty(STDOUT) && @posix_isatty(STDERR); | ||
|
||
/** | ||
* @param string $text the text to print. | ||
* @param int|null $color color according to https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit | ||
*/ | ||
function ansicolor(string $text, int $color = null): string | ||
{ | ||
global $enableColor; | ||
if ($color !== null && $enableColor) { | ||
return "\e[{$color}m$text\e[0m"; | ||
} | ||
return $text; | ||
} | ||
|
||
function stdout(string $text, int $color = null): void | ||
{ | ||
fwrite(STDOUT, ansicolor($text, $color)); | ||
} | ||
|
||
function stdoutln(string $text, int $color = null): void | ||
{ | ||
stdout(ansicolor($text, $color) . PHP_EOL); | ||
} | ||
|
||
function stderr(string $text, int $color = null): void | ||
{ | ||
fwrite(STDERR, ansicolor($text, $color)); | ||
} | ||
|
||
function stderrln(string $text, int $color = null): void | ||
{ | ||
stderr(ansicolor($text, $color) . PHP_EOL, $color); | ||
} | ||
|
||
function help() | ||
{ | ||
global $argv; | ||
|
||
stderrln(<<<YII | ||
_ _ _ _ | ||
| | | |(_)(_) | ||
| |_| || || | Development Tool | ||
\__, ||_||_| | ||
|___/ for Yii 3.0 | ||
YII | ||
); | ||
stderrln('This tools helps with setting up a development environment for Yii 3 packages.'); | ||
stderrln(''); | ||
stderrln('Usage: ' . ($argv[0] ?? 'yii-dev') . ' <command>'); | ||
stderrln(''); | ||
stderrln('Available Commands:'); | ||
stderrln(''); | ||
|
||
stderr(' install', 33); | ||
stderrln(" Install all packages listed in packages.php"); | ||
|
||
stderr(' install', 33); | ||
stderr(' <package>', 34); | ||
stderrln(" Install a single package. <package> refers to the array key in packages.php"); | ||
|
||
stderr(' status', 33); | ||
stderrln(" Show stats summary about all packages."); | ||
|
||
stderr(' lint', 33); | ||
stderrln(" Check packages for common mistakes."); | ||
stderrln(''); | ||
} | ||
|
||
$command = $argv[1] ?? 'help'; | ||
|
||
switch ($command) { | ||
case 'install': | ||
|
||
require __DIR__ . '/commands/InstallCommand.php'; | ||
$command = new \yiidev\commands\InstallCommand($argv[2] ?? null); | ||
$command->run(); | ||
|
||
break; | ||
case 'status': | ||
|
||
// TODO implement | ||
stderrln('Not implemented yet!', 31); | ||
|
||
break; | ||
case 'lint': | ||
|
||
// TODO implement | ||
stderrln('Not implemented yet!', 31); | ||
|
||
break; | ||
default: | ||
help(); | ||
exit(1); | ||
} |