This repository was archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplugin.sh
More file actions
executable file
·113 lines (102 loc) · 3.59 KB
/
plugin.sh
File metadata and controls
executable file
·113 lines (102 loc) · 3.59 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
set -e # Quit the script on error
cd "$( dirname "${BASH_SOURCE[0]}" )" # cd to the directory containg the script
[[ -z "$SYMFONY_ENV" ]] && [[ -e ".staging" ]] && export SYMFONY_ENV="staging" # If no environment is set and staging flag exists, use staging
[[ -z "$SYMFONY_ENV" ]] && export SYMFONY_ENV="prod" # If no environment is set, use production
function init_composer_json {
cat > plugins/composer.json <<EOL
{
"type": "metapackage",
"require": {
"vierbergenlars/authserver-installer": "^1.2.0"
},
"config": {
"prepend-autoloader": false
},
"extra": {
"parent-lock-file": "../composer.lock",
"authserver-plugin-dir": "."
}
}
EOL
}
function init_composer_lock {
sed 's/\\/\\\\/g' > plugins/composer.lock <<EOL
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "e0b456db4c0210a32f43f7fe0257655c",
"packages": [
{
"name": "vierbergenlars/authserver-installer",
"version": "v1.2.0",
"source": {
"type": "git",
"url": "https://gitea.vbgn.be/authserver/authserver-installer.git",
"reference": "10f0ed2d7e4a6b41356fbc768412f35367a28876"
},
"require": {
"composer-plugin-api": "^1.1"
},
"require-dev": {
"composer/composer": "^1.5"
},
"type": "composer-plugin",
"extra": {
"class": "vierbergenlars\\Authserver\\Composer\\AuthserverInstallerPlugin"
},
"autoload": {
"psr-4": {
"vierbergenlars\\Authserver\\Composer\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"AGPL"
],
"authors": [
{
"name": "Lars Vierbergen",
"email": "vierbergenlars@gmail.com"
}
],
"description": "Composer installer for custom Authserver plugins",
"time": "2017-08-30T12:01:23+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}
EOL
}
function composer_install {
composer --working-dir=plugins install
}
if [[ -f "plugins/composer.json" && -f "plugins/composer.lock" && ! -d "plugins/vendor" ]]; then
# A composer.json and composer.lock file exists, but vendor does not.
# This means composer.json and composer.lock are copied from another location, and we now have to initialize the vendor directory.
# We need our installer plugin first, or dependency solving will encounter missing packages that are present in the parent.
temp_composer_json=$(tempfile -d plugins -p composer -s .json)
temp_composer_lock=$(tempfile -d plugins -p composer -s .lock)
cat plugins/composer.json > $temp_composer_json
cat plugins/composer.lock > $temp_composer_lock
init_composer_json
init_composer_lock
composer_install
mv $temp_composer_json plugins/composer.json
mv $temp_composer_lock plugins/composer.lock
fi;
if [[ ! -f "plugins/composer.json" ]]; then
init_composer_json
composer_install
fi;
composer --working-dir=plugins "$@"