Skip to content

Commit

Permalink
feat: new build system and fixed some bugs
Browse files Browse the repository at this point in the history
New version
New choice function
Fix windows bug on read
Fix notice and warnings
Fix some possible issues

BREAKING CHANGE: later version can't no more update to latest
  • Loading branch information
marcocesarato committed Dec 18, 2019
1 parent f812aef commit 47eaf97
Show file tree
Hide file tree
Showing 13 changed files with 428 additions and 447 deletions.
1 change: 1 addition & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php


return PhpCsFixer\Config::create()
->setUsingCache(true)
->setRiskyAllowed(true)
Expand Down
57 changes: 22 additions & 35 deletions bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,30 @@ define('ROOT', dirname(__DIR__));

require ROOT . '/vendor/autoload.php';

$input = ROOT . '/src/scanner';
$output = ROOT . '/dist/scanner';

$jc = new JuggleCode();
$jc->masterfile = $input;
$jc->outfile = $output;
$jc->mergeScripts = true;
$jc->run();

if(empty($argv[1])) {
$version = "0.4.0";
} else {
$version = $argv[1];
}
$input = ROOT . '/src/';
$output = ROOT . '/dist/scanner.phar';
$finalOutput = ROOT . '/dist/scanner';

$date = date("d-m-Y");
$year = date("Y");
$comment = <<<EOD
<?php
// clean up
if (file_exists($output)) {
unlink($output);
}
if (file_exists($output . '.gz')) {
unlink($output . '.gz');
}
if (file_exists($finalOutput)) {
unlink($finalOutput);
}
// create phar
$p = new Phar($output);

/**
* PHP Antimalware Scanner
* Distribution generated on $date
* @version $version
* @author Marco Cesarato <[email protected]>
* @copyright Copyright (c) $year
* @license http://opensource.org/licenses/gpl-3.0.html GNU Public License
* @link https://github.com/marcocesarato/PHP-Antimalware-Scanner
*/
// creating our library using whole directory
$p->buildFromDirectory($input);

EOD;
// pointing main file which requires all classes
$p->setDefaultStub('index.php', '/index.php');

unset($p);
rename($output, $finalOutput);

$file = php_strip_whitespace($output);
$file = preg_replace('/namespace marcocesarato\\\\amwscan\;\s*/si', '', $file);
$file = preg_replace('/public\s*static\s*\$VERSION\s*=\s*(\"|\\\')0\.5\.0(\"|\\\')\s*\;/si', 'public static $VERSION = "'.$version.'";', $file);
$from = '/'.preg_quote("<?php", '/').'/';
$file = preg_replace($from, $comment, $file, 1);
$file = "#!/usr/bin/php" . PHP_EOL . $file;
$file = file_put_contents($output, $file);
echo "$output successfully created";
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
"post-update-cmd": "php bin/run vendor/bin/cghooks update"
},
"require": {
"php": ">=5.3.0",
"ext-json": "*",
"ext-curl": "*"
"php": ">=5.4",
"ext-json": "*"
},
"require-dev": {
"brainmaestro/composer-git-hooks": "^2.8",
Expand Down
Loading

0 comments on commit 47eaf97

Please sign in to comment.