-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
prefix-code.sh
48 lines (33 loc) · 1.27 KB
/
prefix-code.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env bash
# inspired from https://github.com/rectorphp/rector/blob/main/build/build-rector-scoped.sh
# see https://stackoverflow.com/questions/66644233/how-to-propagate-colors-from-bash-script-to-github-action?noredirect=1#comment117811853_66644233
export TERM=xterm-color
# show errors
set -e
# script fails if trying to access to an undefined variable
set -u
# functions
note()
{
MESSAGE=$1;
printf "\n";
echo "\033[0;33m[NOTE] $MESSAGE\033[0m";
}
# ---------------------------
# 2. scope it
note "Downloading php-scoper 0.17.5"
# @todo upgrade to 0.18.1
wget https://github.com/humbug/php-scoper/releases/download/0.17.5/php-scoper.phar -N --no-verbose
note "Running php-scoper"
# Work around possible PHP memory limits
php -d memory_limit=-1 php-scoper.phar add-prefix bin config src vendor composer.json --config scoper.php --force --ansi --output-dir scoped-code
# the output code is in "/scoped-code", lets move it up
# the local directories have to be empty to move easily
rm -r bin config src vendor composer.json
mv scoped-code/* .
note "Dumping Composer Autoload"
composer dump-autoload --ansi --classmap-authoritative --no-dev
# make bin/ecs runnable without "php"
chmod 777 "bin/config-transformer"
chmod 777 "bin/config-transformer.php"
note "Finished"