Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
basic cli implementation
  • Loading branch information
cebe committed Nov 23, 2018
0 parents commit b4b4abe
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
@@ -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
27 changes: 27 additions & 0 deletions .gitattributes
@@ -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
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
/*.local.php
11 changes: 11 additions & 0 deletions .travis.yml
@@ -0,0 +1,11 @@
language: php

php:
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- nightly

script:
- php -l yii-dev
26 changes: 26 additions & 0 deletions README.md
@@ -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


2 changes: 2 additions & 0 deletions dev/.gitignore
@@ -0,0 +1,2 @@
*
!.gitignore
14 changes: 14 additions & 0 deletions packages.php
@@ -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;

108 changes: 108 additions & 0 deletions yii-dev
@@ -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);
}

0 comments on commit b4b4abe

Please sign in to comment.