From f1c87b8ea544af8329e35bd14376fd4bb0163c3f Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sun, 17 Jan 2021 20:42:04 +0100 Subject: [PATCH] Add custom script --- .github/workflows/build.yml | 2 +- composer.json | 2 +- tools/convertPhabel.php | 79 +++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 tools/convertPhabel.php diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d44373b..befb13b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,4 +44,4 @@ jobs: run: | git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" git config --local user.name "Github Actions" - php vendor/phabel/phabel/tools/convertPhabel.php all + php tools/convertPhabel.php all diff --git a/composer.json b/composer.json index 2fd064a..a6b8ba7 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "nikic/php-parser", + "name": "phabel/php-parser", "type": "library", "description": "A PHP parser written in PHP", "keywords": [ diff --git a/tools/convertPhabel.php b/tools/convertPhabel.php new file mode 100644 index 0000000..87ccaab --- /dev/null +++ b/tools/convertPhabel.php @@ -0,0 +1,79 @@ + ['target' => $target]], $dir, $dir, $coverage); + } + + $str = (string) $target; + $packages["php"] = ">=${str[0]}.${str[1]}"; + if (!empty($packages)) { + $cmd = "composer require "; + foreach ($packages as $package => $constraint) { + $cmd .= \escapeshellarg("{$package}:{$constraint}")." "; + } + \passthru($cmd); + } + + \passthru("composer cs-fix"); + + if (!$dry) { + \passthru("git add -A"); + \passthru("git commit -m ".\escapeshellarg("phabel.io: transpile to $target")); + } + } + if (!$dry) { + \passthru("git push -f origin ".\escapeshellarg("phabel_tmp:{$branch}-{$target}")); + + \passthru("git checkout ".\escapeshellarg($branch)); + \passthru("git branch -D phabel_tmp"); + } + \passthru("git reset --hard"); +} + +\passthru("git stash pop");