Skip to content

Commit

Permalink
Phar bundled with PHPCS altogether
Browse files Browse the repository at this point in the history
  • Loading branch information
ᏒᏊᏀᏋᏒ ᏕξᏐ committed Oct 9, 2019
1 parent 77a7ec9 commit aebe82f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 35 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog
@author ᏒᏊᏀᏋᏒ ᏕξᏐ

## [0.5.0] - 2019-10-09
### Added
- PHPCS added on phar file, which is fully bundled now.


## [0.4.1] - 2019-10-08
### Added
- New option added: --diff-cached. An useful option to check for staged git files.
Expand Down
44 changes: 29 additions & 15 deletions scripts/build-phar
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (file_exists("$cwd/super-giggle.phar") === true) {
}

$phar = new Phar("$cwd/super-giggle.phar", 0);
$phar->buildFromDirectory("$base/src");
$phar->buildFromDirectory("$base");
foreach (($argv ?? []) as $arg) {
if ($arg === '--compress') {
$phar->compressFiles(Phar::GZ);
Expand All @@ -18,23 +18,37 @@ foreach (($argv ?? []) as $arg) {
$phar->setStub(
'#!/usr/bin/env php
<?php
Phar::mapPhar("super-giggle.phar");
require_once "phar://super-giggle.phar/Main.php";
require_once "phar://super-giggle.phar/Util.php";
require_once "phar://super-giggle.phar/Os.php";
$util = new SuperGiggle\Util();
$util->setOs(new SuperGiggle\Os());
$opts = $util->parseArgs();
if (isset($opts["help"])) {
$util->printUsage();
if (in_array("--phpcs-wrapper", $argv) === true) {
require_once "phar://super-giggle.phar/vendor/squizlabs/php_codesniffer/autoload.php";
define("PHP_CODESNIFFER_IN_TESTS", true);
$runner = new PHP_CodeSniffer\Runner();
$exitCode = $runner->runPHPCS();
exit($exitCode);
} else {
require_once "phar://super-giggle.phar/src/Main.php";
require_once "phar://super-giggle.phar/src/Util.php";
require_once "phar://super-giggle.phar/src/Os.php";
$util = new SuperGiggle\Util();
$util->setOs(new SuperGiggle\Os());
$opts = $util->parseArgs();
if (isset($opts["help"])) {
$util->printUsage();
}
$sg = new SuperGiggle\Main();
$sg->setUtil($util);
$sg->isPhar = true;
$sg->run($opts);
exit(0);
}
$sg = new SuperGiggle\Main();
$sg->setUtil($util);
$sg->isPhar = true;
$sg->run($opts);
exit(0);
__HALT_COMPILER();');

chmod("$cwd/super-giggle.phar", 0755);
23 changes: 5 additions & 18 deletions src/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
*
* @category PHP
* @package GT8
* @author GT8 <roger.sei@icloud.com>
* @author Roger Sei <roger.sei@icloud.com>
* @author Rodrigo Girorme <rodrigo.girorme@gmail.com>
* @copyright 2020 Roger Sei
* @license //github.com/roger-sei/SuperGiggle/blob/master/LICENSE MIT
* @version Release: GIT: 0.1.0
* @version Release: GIT: 0.5.0
* @link //github.com/roger-sei/SuperGiggle
*/

Expand Down Expand Up @@ -336,22 +337,8 @@ private function validateOptions(): void

// First, we check for basic system requirements.
if ($this->isPhar === true) {
if (isset($this->options['phpcs']) === true) {
$cwd = getcwd();
$pathRegular = $this->options['phpcs'];
$pathRelative = "$cwd/{$this->options['phpcs']}";
if (empty(shell_exec("command -v $pathRegular")) === false) {
$this->options['phpcs'] = $pathRegular;
} elseif (empty(shell_exec("command -v $pathRelative")) === false) {
$this->options['phpcs'] = $pathRelative;
} else {
$this->exit("phpcs not found.\n\nPlease, make sure the given ``--path={$this->options['phpcs']}`` points to the correct path.");
}
} else {
$this->exitIf(
empty(shell_exec('command -v phpcs')),
"'phpcs' is required when using phar.\n\nPlease, install it or use ``--phpcs`` option to indicate the path."
);
if (empty($this->options['phpcs']) === true) {
$this->options['phpcs'] = \Phar::running(false) . ' --phpcs-wrapper';
}
} else {
if (isset($this->options['phpcs']) === true) {
Expand Down
4 changes: 2 additions & 2 deletions src/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @author girorme <rodrigogirorme@gmail.com>
* @copyright 2020 Roger Sei
* @license //github.com/roger-sei/SuperGiggle/blob/master/LICENSE MIT
* @version Release: GIT: 0.1.0
* @version Release: GIT: 0.5.0
* @link //github.com/roger-sei/SuperGiggle
*/

Expand All @@ -31,7 +31,7 @@ class Util
*
* @var string
*/
const VERSION = '0.4.1';
const VERSION = '0.5.0';


/**
Expand Down

0 comments on commit aebe82f

Please sign in to comment.