setup-php 1.11.2 → 1.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +433 -458
- package/lib/config.d.ts +3 -0
- package/lib/config.js +71 -71
- package/lib/config.js.map +1 -1
- package/lib/coverage.d.ts +4 -0
- package/lib/coverage.js +97 -87
- package/lib/coverage.js.map +1 -1
- package/lib/extensions.d.ts +4 -0
- package/lib/extensions.js +188 -200
- package/lib/extensions.js.map +1 -1
- package/lib/install.d.ts +2 -0
- package/lib/install.js +96 -81
- package/lib/install.js.map +1 -1
- package/lib/tools.d.ts +18 -0
- package/lib/tools.js +306 -386
- package/lib/tools.js.map +1 -1
- package/lib/utils.d.ts +15 -0
- package/lib/utils.js +205 -291
- package/lib/utils.js.map +1 -1
- package/package.json +66 -56
- package/src/config.ts +82 -82
- package/src/configs/brew_extensions +28 -0
- package/src/configs/php-versions.json +5 -5
- package/src/configs/phpunit.json +24 -24
- package/src/coverage.ts +146 -146
- package/src/extensions.ts +235 -233
- package/src/install.ts +104 -104
- package/src/scripts/darwin.sh +341 -339
- package/src/scripts/ext/gearman.sh +22 -22
- package/src/scripts/ext/phalcon.ps1 +55 -55
- package/src/scripts/ext/phalcon.sh +70 -70
- package/src/scripts/linux.sh +361 -361
- package/src/scripts/win32.ps1 +326 -333
- package/src/tools.ts +472 -469
- package/src/utils.ts +319 -316
- package/.eslintrc.json +0 -16
- package/.github/CODE_OF_CONDUCT.md +0 -76
- package/.github/CONTRIBUTING.md +0 -69
- package/.github/FUNDING.yml +0 -7
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -23
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -38
- package/.github/SECURITY.md +0 -29
- package/.github/workflows/main-workflow.yml +0 -56
- package/.github/workflows/node-workflow.yml +0 -47
- package/.idea/workspace.xml +0 -113
- package/.prettierrc.json +0 -12
- package/__tests__/config.test.ts +0 -52
- package/__tests__/coverage.test.ts +0 -110
- package/__tests__/extensions.test.ts +0 -120
- package/__tests__/install.test.ts +0 -181
- package/__tests__/tools.test.ts +0 -476
- package/__tests__/utils.test.ts +0 -213
- package/action.yml +0 -38
- package/dist/index.js +0 -2854
- package/examples/bedrock.yml +0 -32
- package/examples/cakephp-mysql.yml +0 -114
- package/examples/cakephp-postgres.yml +0 -112
- package/examples/cakephp.yml +0 -92
- package/examples/codeigniter.yml +0 -34
- package/examples/laravel-mysql.yml +0 -74
- package/examples/laravel-postgres.yml +0 -74
- package/examples/laravel.yml +0 -42
- package/examples/lumen-mysql.yml +0 -74
- package/examples/lumen-postgres.yml +0 -74
- package/examples/lumen.yml +0 -38
- package/examples/phalcon-mysql.yml +0 -74
- package/examples/phalcon-postgres.yml +0 -73
- package/examples/sage.yml +0 -57
- package/examples/slim-framework.yml +0 -34
- package/examples/symfony-mysql.yml +0 -56
- package/examples/symfony-postgres.yml +0 -54
- package/examples/symfony.yml +0 -39
- package/examples/yii2-mysql.yml +0 -73
- package/examples/yii2-postgres.yml +0 -71
- package/examples/zend-framework.yml +0 -36
- package/jest.config.js +0 -12
- package/lib/sapi.js +0 -64
- package/tsconfig.json +0 -18
package/src/scripts/win32.ps1
CHANGED
|
@@ -1,333 +1,326 @@
|
|
|
1
|
-
param (
|
|
2
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
3
|
-
[ValidateNotNull()]
|
|
4
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
5
|
-
[string]
|
|
6
|
-
$version = '7.4',
|
|
7
|
-
[Parameter(Position = 1, Mandatory = $true)]
|
|
8
|
-
[ValidateNotNull()]
|
|
9
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
10
|
-
[string]
|
|
11
|
-
$dist
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
Function Step-Log($message) {
|
|
15
|
-
printf "\n\033[90;1m==> \033[0m\033[37;1m%s \033[0m\n" $message
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
Function Add-Log($mark, $subject, $message) {
|
|
19
|
-
$code = if ($mark -eq $cross) { "31" } else { "32" }
|
|
20
|
-
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
Function Add-ToProfile {
|
|
24
|
-
param(
|
|
25
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
26
|
-
[ValidateNotNull()]
|
|
27
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
28
|
-
[string]
|
|
29
|
-
$input_profile,
|
|
30
|
-
[Parameter(Position = 1, Mandatory = $true)]
|
|
31
|
-
[ValidateNotNull()]
|
|
32
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
33
|
-
[string]
|
|
34
|
-
$search,
|
|
35
|
-
[Parameter(Position = 2, Mandatory = $true)]
|
|
36
|
-
[ValidateNotNull()]
|
|
37
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
38
|
-
[string]
|
|
39
|
-
$value
|
|
40
|
-
)
|
|
41
|
-
if($null -eq (Get-Content $input_profile | findstr $search)) {
|
|
42
|
-
Add-Content -Path $input_profile -Value $value
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
Function Add-Printf {
|
|
47
|
-
if (-not(Test-Path "C:\Program Files\Git\usr\bin\printf.exe")) {
|
|
48
|
-
if(Test-Path "C:\msys64\usr\bin\printf.exe") {
|
|
49
|
-
New-Item -Path $php_dir\printf.exe -ItemType SymbolicLink -Value C:\msys64\usr\bin\printf.exe
|
|
50
|
-
} else {
|
|
51
|
-
Invoke-WebRequest -UseBasicParsing -Uri "$github/shivammathur/printf/releases/latest/download/printf-x64.zip" -OutFile "$php_dir\printf.zip"
|
|
52
|
-
Expand-Archive -Path $php_dir\printf.zip -DestinationPath $php_dir -Force
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
New-Item -Path $php_dir\printf.exe -ItemType SymbolicLink -Value "C:\Program Files\Git\usr\bin\printf.exe"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
Function Install-PSPackage() {
|
|
60
|
-
param(
|
|
61
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
62
|
-
$package,
|
|
63
|
-
[Parameter(Position = 1, Mandatory = $true)]
|
|
64
|
-
$psm1_path,
|
|
65
|
-
[Parameter(Position = 2, Mandatory = $true)]
|
|
66
|
-
$url,
|
|
67
|
-
[Parameter(Position = 3, Mandatory = $true)]
|
|
68
|
-
$cmdlet
|
|
69
|
-
)
|
|
70
|
-
$module_path = "$php_dir\$psm1_path.psm1"
|
|
71
|
-
if(-not (Test-Path $module_path -PathType Leaf)) {
|
|
72
|
-
$zip_file = "$php_dir\$package.zip"
|
|
73
|
-
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $zip_file
|
|
74
|
-
Expand-Archive -Path $zip_file -DestinationPath $php_dir -Force
|
|
75
|
-
}
|
|
76
|
-
Import-Module $module_path
|
|
77
|
-
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
|
|
78
|
-
|
|
79
|
-
if($null -eq (Get-Command $cmdlet -ErrorAction SilentlyContinue)) {
|
|
80
|
-
Install-Module -Name $
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
Function Add-Extension {
|
|
85
|
-
Param (
|
|
86
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
87
|
-
[ValidateNotNull()]
|
|
88
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
89
|
-
[string]
|
|
90
|
-
$extension,
|
|
91
|
-
[Parameter(Position = 1, Mandatory = $false)]
|
|
92
|
-
[ValidateNotNull()]
|
|
93
|
-
[ValidateSet('stable', 'beta', 'alpha', 'devel', 'snapshot')]
|
|
94
|
-
[string]
|
|
95
|
-
$stability = 'stable',
|
|
96
|
-
[Parameter(Position = 2, Mandatory = $false)]
|
|
97
|
-
[ValidateNotNull()]
|
|
98
|
-
[ValidatePattern('^\d+(\.\d+){0,2}$')]
|
|
99
|
-
[string]
|
|
100
|
-
$extension_version = ''
|
|
101
|
-
)
|
|
102
|
-
try {
|
|
103
|
-
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
|
|
104
|
-
if ($null -ne $extension_info) {
|
|
105
|
-
switch ($extension_info.State) {
|
|
106
|
-
'Builtin' {
|
|
107
|
-
Add-Log $tick $extension "Enabled"
|
|
108
|
-
}
|
|
109
|
-
'Enabled' {
|
|
110
|
-
Add-Log $tick $extension "Enabled"
|
|
111
|
-
}
|
|
112
|
-
default {
|
|
113
|
-
Enable-PhpExtension -Extension $extension_info.Handle -Path $php_dir
|
|
114
|
-
Add-Log $tick $extension "Enabled"
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
if($extension_version -ne '') {
|
|
120
|
-
Install-PhpExtension -Extension $extension -Version $extension_version -MinimumStability $stability -MaximumStability $stability -Path $php_dir
|
|
121
|
-
} else {
|
|
122
|
-
Install-PhpExtension -Extension $extension -MinimumStability $stability -MaximumStability $stability -Path $php_dir
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
Add-Log $tick $extension "Installed and enabled"
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
129
|
-
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
Function Remove-Extension() {
|
|
134
|
-
Param (
|
|
135
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
136
|
-
[ValidateNotNull()]
|
|
137
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
138
|
-
[string]
|
|
139
|
-
$extension
|
|
140
|
-
)
|
|
141
|
-
if(php -m | findstr -i $extension) {
|
|
142
|
-
Disable-PhpExtension $extension $php_dir
|
|
143
|
-
}
|
|
144
|
-
if (Test-Path $ext_dir\php_$extension.dll) {
|
|
145
|
-
Remove-Item $ext_dir\php_$extension.dll
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
Function Edit-ComposerConfig() {
|
|
151
|
-
Param(
|
|
152
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
153
|
-
[ValidateNotNull()]
|
|
154
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
155
|
-
[string]
|
|
156
|
-
$tool_path
|
|
157
|
-
)
|
|
158
|
-
Copy-Item $tool_path -Destination "$tool_path.phar"
|
|
159
|
-
php -r "try {`$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception `$e) {exit(1);}"
|
|
160
|
-
if ($? -eq $False) {
|
|
161
|
-
Add-Log "$cross" "composer" "Could not download composer"
|
|
162
|
-
exit 1;
|
|
163
|
-
}
|
|
164
|
-
if (-not(Test-Path $composer_json)) {
|
|
165
|
-
Set-Content -Path $composer_json -Value "{}"
|
|
166
|
-
}
|
|
167
|
-
composer -q config -g process-timeout 0
|
|
168
|
-
Write-Output $composer_bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
|
|
169
|
-
if (Test-Path env:COMPOSER_TOKEN) {
|
|
170
|
-
composer -q config -g github-oauth.github.com $env:COMPOSER_TOKEN
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
Function Add-Tool() {
|
|
175
|
-
Param (
|
|
176
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
177
|
-
[ValidateNotNull()]
|
|
178
|
-
$url,
|
|
179
|
-
[Parameter(Position = 1, Mandatory = $true)]
|
|
180
|
-
[ValidateNotNull()]
|
|
181
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
182
|
-
[string]
|
|
183
|
-
$tool
|
|
184
|
-
)
|
|
185
|
-
if (Test-Path $php_dir\$tool) {
|
|
186
|
-
Remove-Item $php_dir\$tool
|
|
187
|
-
}
|
|
188
|
-
if($url.Count -gt 1) { $url = $url[0] }
|
|
189
|
-
if ($tool -eq "symfony") {
|
|
190
|
-
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool.exe
|
|
191
|
-
Add-ToProfile $current_profile $tool "New-Alias $tool $php_dir\$tool.exe" >$null 2>&1
|
|
192
|
-
} else {
|
|
193
|
-
try {
|
|
194
|
-
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool
|
|
195
|
-
} catch {
|
|
196
|
-
if($url -match '.*github.com.*releases.*latest.*') {
|
|
197
|
-
try {
|
|
198
|
-
$url = $url.replace("releases/latest/download", "releases/download/" + ([regex]::match((Invoke-WebRequest -UseBasicParsing -Uri ($url.split('/release')[0] + "/releases")).Content, "([0-9]+\.[0-9]+\.[0-9]+)/" + ($url.Substring($url.LastIndexOf("/") + 1))).Groups[0].Value).split('/')[0])
|
|
199
|
-
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool
|
|
200
|
-
} catch { }
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
if (((Get-ChildItem -Path $php_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
|
|
205
|
-
$bat_content = @()
|
|
206
|
-
$bat_content += "@ECHO off"
|
|
207
|
-
$bat_content += "setlocal DISABLEDELAYEDEXPANSION"
|
|
208
|
-
$bat_content += "SET BIN_TARGET=%~dp0/" + $tool
|
|
209
|
-
$bat_content += "php %BIN_TARGET% %*"
|
|
210
|
-
Set-Content -Path $php_dir\$tool.bat -Value $bat_content
|
|
211
|
-
Add-ToProfile $current_profile $tool "New-Alias $tool $php_dir\$tool.bat" >$null 2>&1
|
|
212
|
-
if($tool -eq "composer") {
|
|
213
|
-
Edit-ComposerConfig $php_dir\$tool
|
|
214
|
-
} elseif($tool -eq "cs2pr") {
|
|
215
|
-
(Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr
|
|
216
|
-
} elseif($tool -eq "phan") {
|
|
217
|
-
Add-Extension fileinfo >$null 2>&1
|
|
218
|
-
Add-Extension ast >$null 2>&1
|
|
219
|
-
} elseif($tool -eq "phive") {
|
|
220
|
-
Add-Extension xml >$null 2>&1
|
|
221
|
-
} elseif($tool -eq "wp-cli") {
|
|
222
|
-
Copy-Item $php_dir\wp-cli.bat -Destination $php_dir\wp.bat
|
|
223
|
-
}
|
|
224
|
-
Add-Log $tick $tool "Added"
|
|
225
|
-
} else {
|
|
226
|
-
Add-Log $cross $tool "Could not add $tool"
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
Function Add-Composertool() {
|
|
231
|
-
Param (
|
|
232
|
-
[Parameter(Position = 0, Mandatory = $true)]
|
|
233
|
-
[ValidateNotNull()]
|
|
234
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
235
|
-
[string]
|
|
236
|
-
$tool,
|
|
237
|
-
[Parameter(Position = 1, Mandatory = $true)]
|
|
238
|
-
[ValidateNotNull()]
|
|
239
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
240
|
-
[string]
|
|
241
|
-
$release,
|
|
242
|
-
[Parameter(Position = 2, Mandatory = $true)]
|
|
243
|
-
[ValidateNotNull()]
|
|
244
|
-
[ValidateLength(1, [int]::MaxValue)]
|
|
245
|
-
[string]
|
|
246
|
-
$prefix
|
|
247
|
-
)
|
|
248
|
-
if(Test-Path $composer_lock) {
|
|
249
|
-
Remove-Item -Path $composer_lock -Force
|
|
250
|
-
}
|
|
251
|
-
composer -q global require $prefix$release 2>&1 | out-null
|
|
252
|
-
if($tool -eq "codeception") {
|
|
253
|
-
Copy-Item $composer_bin\codecept.bat -Destination $composer_bin\codeception.bat
|
|
254
|
-
}
|
|
255
|
-
if($?) {
|
|
256
|
-
Add-Log $tick $tool "Added"
|
|
257
|
-
} else {
|
|
258
|
-
Add-Log $cross $tool "Could not setup $tool"
|
|
259
|
-
}
|
|
260
|
-
if(Test-Path $composer_bin\composer) {
|
|
261
|
-
Copy-Item -Path "$php_dir\composer" -Destination "$composer_bin\composer" -Force
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
Function Add-Pecl() {
|
|
266
|
-
Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows"
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
# Variables
|
|
270
|
-
$tick = ([char]8730)
|
|
271
|
-
$cross = ([char]10007)
|
|
272
|
-
$php_dir = 'C:\tools\php'
|
|
273
|
-
$ext_dir = "$php_dir\ext"
|
|
274
|
-
$current_profile = "$PSHOME\Profile.ps1"
|
|
275
|
-
$ProgressPreference = 'SilentlyContinue'
|
|
276
|
-
$github = 'https://github.com'
|
|
277
|
-
$composer_bin = "$env:APPDATA\Composer\vendor\bin"
|
|
278
|
-
$composer_json = "$env:APPDATA\Composer\composer.json"
|
|
279
|
-
$composer_lock = "$env:APPDATA\Composer\composer.lock"
|
|
280
|
-
$
|
|
281
|
-
$
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
$
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
$
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
$
|
|
306
|
-
if ($
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
}
|
|
328
|
-
('date.timezone=UTC', 'memory_limit=-1', 'xdebug.mode=coverage') | ForEach-Object { $p=$_.split('='); Set-PhpIniKey -Key $p[0] -Value $p[1] -Path $php_dir }
|
|
329
|
-
Enable-PhpExtension -Extension openssl, curl, opcache, mbstring -Path $php_dir
|
|
330
|
-
Update-PhpCAInfo -Path $php_dir -Source CurrentUser
|
|
331
|
-
Copy-Item -Path $dist\..\src\configs\*.json -Destination $env:RUNNER_TOOL_CACHE
|
|
332
|
-
New-Item -ItemType Directory -Path $composer_bin -Force 2>&1 | Out-Null
|
|
333
|
-
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)"
|
|
1
|
+
param (
|
|
2
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
3
|
+
[ValidateNotNull()]
|
|
4
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
5
|
+
[string]
|
|
6
|
+
$version = '7.4',
|
|
7
|
+
[Parameter(Position = 1, Mandatory = $true)]
|
|
8
|
+
[ValidateNotNull()]
|
|
9
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
10
|
+
[string]
|
|
11
|
+
$dist
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
Function Step-Log($message) {
|
|
15
|
+
printf "\n\033[90;1m==> \033[0m\033[37;1m%s \033[0m\n" $message
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Function Add-Log($mark, $subject, $message) {
|
|
19
|
+
$code = if ($mark -eq $cross) { "31" } else { "32" }
|
|
20
|
+
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Function Add-ToProfile {
|
|
24
|
+
param(
|
|
25
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
26
|
+
[ValidateNotNull()]
|
|
27
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
28
|
+
[string]
|
|
29
|
+
$input_profile,
|
|
30
|
+
[Parameter(Position = 1, Mandatory = $true)]
|
|
31
|
+
[ValidateNotNull()]
|
|
32
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
33
|
+
[string]
|
|
34
|
+
$search,
|
|
35
|
+
[Parameter(Position = 2, Mandatory = $true)]
|
|
36
|
+
[ValidateNotNull()]
|
|
37
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
38
|
+
[string]
|
|
39
|
+
$value
|
|
40
|
+
)
|
|
41
|
+
if($null -eq (Get-Content $input_profile | findstr $search)) {
|
|
42
|
+
Add-Content -Path $input_profile -Value $value
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
Function Add-Printf {
|
|
47
|
+
if (-not(Test-Path "C:\Program Files\Git\usr\bin\printf.exe")) {
|
|
48
|
+
if(Test-Path "C:\msys64\usr\bin\printf.exe") {
|
|
49
|
+
New-Item -Path $php_dir\printf.exe -ItemType SymbolicLink -Value C:\msys64\usr\bin\printf.exe -Force > $null 2>&1
|
|
50
|
+
} else {
|
|
51
|
+
Invoke-WebRequest -UseBasicParsing -Uri "$github/shivammathur/printf/releases/latest/download/printf-x64.zip" -OutFile "$php_dir\printf.zip"
|
|
52
|
+
Expand-Archive -Path $php_dir\printf.zip -DestinationPath $php_dir -Force
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
New-Item -Path $php_dir\printf.exe -ItemType SymbolicLink -Value "C:\Program Files\Git\usr\bin\printf.exe" -Force > $null 2>&1
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
Function Install-PSPackage() {
|
|
60
|
+
param(
|
|
61
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
62
|
+
$package,
|
|
63
|
+
[Parameter(Position = 1, Mandatory = $true)]
|
|
64
|
+
$psm1_path,
|
|
65
|
+
[Parameter(Position = 2, Mandatory = $true)]
|
|
66
|
+
$url,
|
|
67
|
+
[Parameter(Position = 3, Mandatory = $true)]
|
|
68
|
+
$cmdlet
|
|
69
|
+
)
|
|
70
|
+
$module_path = "$php_dir\$psm1_path.psm1"
|
|
71
|
+
if(-not (Test-Path $module_path -PathType Leaf)) {
|
|
72
|
+
$zip_file = "$php_dir\$package.zip"
|
|
73
|
+
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $zip_file
|
|
74
|
+
Expand-Archive -Path $zip_file -DestinationPath $php_dir -Force
|
|
75
|
+
}
|
|
76
|
+
Import-Module $module_path
|
|
77
|
+
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
|
|
78
|
+
|
|
79
|
+
if($null -eq (Get-Command $cmdlet -ErrorAction SilentlyContinue)) {
|
|
80
|
+
Install-Module -Name $package -Force
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
Function Add-Extension {
|
|
85
|
+
Param (
|
|
86
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
87
|
+
[ValidateNotNull()]
|
|
88
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
89
|
+
[string]
|
|
90
|
+
$extension,
|
|
91
|
+
[Parameter(Position = 1, Mandatory = $false)]
|
|
92
|
+
[ValidateNotNull()]
|
|
93
|
+
[ValidateSet('stable', 'beta', 'alpha', 'devel', 'snapshot')]
|
|
94
|
+
[string]
|
|
95
|
+
$stability = 'stable',
|
|
96
|
+
[Parameter(Position = 2, Mandatory = $false)]
|
|
97
|
+
[ValidateNotNull()]
|
|
98
|
+
[ValidatePattern('^\d+(\.\d+){0,2}$')]
|
|
99
|
+
[string]
|
|
100
|
+
$extension_version = ''
|
|
101
|
+
)
|
|
102
|
+
try {
|
|
103
|
+
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
|
|
104
|
+
if ($null -ne $extension_info) {
|
|
105
|
+
switch ($extension_info.State) {
|
|
106
|
+
'Builtin' {
|
|
107
|
+
Add-Log $tick $extension "Enabled"
|
|
108
|
+
}
|
|
109
|
+
'Enabled' {
|
|
110
|
+
Add-Log $tick $extension "Enabled"
|
|
111
|
+
}
|
|
112
|
+
default {
|
|
113
|
+
Enable-PhpExtension -Extension $extension_info.Handle -Path $php_dir
|
|
114
|
+
Add-Log $tick $extension "Enabled"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
if($extension_version -ne '') {
|
|
120
|
+
Install-PhpExtension -Extension $extension -Version $extension_version -MinimumStability $stability -MaximumStability $stability -Path $php_dir
|
|
121
|
+
} else {
|
|
122
|
+
Install-PhpExtension -Extension $extension -MinimumStability $stability -MaximumStability $stability -Path $php_dir
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
Add-Log $tick $extension "Installed and enabled"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
Function Remove-Extension() {
|
|
134
|
+
Param (
|
|
135
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
136
|
+
[ValidateNotNull()]
|
|
137
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
138
|
+
[string]
|
|
139
|
+
$extension
|
|
140
|
+
)
|
|
141
|
+
if(php -m | findstr -i $extension) {
|
|
142
|
+
Disable-PhpExtension $extension $php_dir
|
|
143
|
+
}
|
|
144
|
+
if (Test-Path $ext_dir\php_$extension.dll) {
|
|
145
|
+
Remove-Item $ext_dir\php_$extension.dll
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
Function Edit-ComposerConfig() {
|
|
151
|
+
Param(
|
|
152
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
153
|
+
[ValidateNotNull()]
|
|
154
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
155
|
+
[string]
|
|
156
|
+
$tool_path
|
|
157
|
+
)
|
|
158
|
+
Copy-Item $tool_path -Destination "$tool_path.phar"
|
|
159
|
+
php -r "try {`$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception `$e) {exit(1);}"
|
|
160
|
+
if ($? -eq $False) {
|
|
161
|
+
Add-Log "$cross" "composer" "Could not download composer"
|
|
162
|
+
exit 1;
|
|
163
|
+
}
|
|
164
|
+
if (-not(Test-Path $composer_json)) {
|
|
165
|
+
Set-Content -Path $composer_json -Value "{}"
|
|
166
|
+
}
|
|
167
|
+
composer -q config -g process-timeout 0
|
|
168
|
+
Write-Output $composer_bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
|
|
169
|
+
if (Test-Path env:COMPOSER_TOKEN) {
|
|
170
|
+
composer -q config -g github-oauth.github.com $env:COMPOSER_TOKEN
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
Function Add-Tool() {
|
|
175
|
+
Param (
|
|
176
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
177
|
+
[ValidateNotNull()]
|
|
178
|
+
$url,
|
|
179
|
+
[Parameter(Position = 1, Mandatory = $true)]
|
|
180
|
+
[ValidateNotNull()]
|
|
181
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
182
|
+
[string]
|
|
183
|
+
$tool
|
|
184
|
+
)
|
|
185
|
+
if (Test-Path $php_dir\$tool) {
|
|
186
|
+
Remove-Item $php_dir\$tool
|
|
187
|
+
}
|
|
188
|
+
if($url.Count -gt 1) { $url = $url[0] }
|
|
189
|
+
if ($tool -eq "symfony") {
|
|
190
|
+
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool.exe
|
|
191
|
+
Add-ToProfile $current_profile $tool "New-Alias $tool $php_dir\$tool.exe" >$null 2>&1
|
|
192
|
+
} else {
|
|
193
|
+
try {
|
|
194
|
+
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool
|
|
195
|
+
} catch {
|
|
196
|
+
if($url -match '.*github.com.*releases.*latest.*') {
|
|
197
|
+
try {
|
|
198
|
+
$url = $url.replace("releases/latest/download", "releases/download/" + ([regex]::match((Invoke-WebRequest -UseBasicParsing -Uri ($url.split('/release')[0] + "/releases")).Content, "([0-9]+\.[0-9]+\.[0-9]+)/" + ($url.Substring($url.LastIndexOf("/") + 1))).Groups[0].Value).split('/')[0])
|
|
199
|
+
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool
|
|
200
|
+
} catch { }
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (((Get-ChildItem -Path $php_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
|
|
205
|
+
$bat_content = @()
|
|
206
|
+
$bat_content += "@ECHO off"
|
|
207
|
+
$bat_content += "setlocal DISABLEDELAYEDEXPANSION"
|
|
208
|
+
$bat_content += "SET BIN_TARGET=%~dp0/" + $tool
|
|
209
|
+
$bat_content += "php %BIN_TARGET% %*"
|
|
210
|
+
Set-Content -Path $php_dir\$tool.bat -Value $bat_content
|
|
211
|
+
Add-ToProfile $current_profile $tool "New-Alias $tool $php_dir\$tool.bat" >$null 2>&1
|
|
212
|
+
if($tool -eq "composer") {
|
|
213
|
+
Edit-ComposerConfig $php_dir\$tool
|
|
214
|
+
} elseif($tool -eq "cs2pr") {
|
|
215
|
+
(Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr
|
|
216
|
+
} elseif($tool -eq "phan") {
|
|
217
|
+
Add-Extension fileinfo >$null 2>&1
|
|
218
|
+
Add-Extension ast >$null 2>&1
|
|
219
|
+
} elseif($tool -eq "phive") {
|
|
220
|
+
Add-Extension xml >$null 2>&1
|
|
221
|
+
} elseif($tool -eq "wp-cli") {
|
|
222
|
+
Copy-Item $php_dir\wp-cli.bat -Destination $php_dir\wp.bat
|
|
223
|
+
}
|
|
224
|
+
Add-Log $tick $tool "Added"
|
|
225
|
+
} else {
|
|
226
|
+
Add-Log $cross $tool "Could not add $tool"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
Function Add-Composertool() {
|
|
231
|
+
Param (
|
|
232
|
+
[Parameter(Position = 0, Mandatory = $true)]
|
|
233
|
+
[ValidateNotNull()]
|
|
234
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
235
|
+
[string]
|
|
236
|
+
$tool,
|
|
237
|
+
[Parameter(Position = 1, Mandatory = $true)]
|
|
238
|
+
[ValidateNotNull()]
|
|
239
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
240
|
+
[string]
|
|
241
|
+
$release,
|
|
242
|
+
[Parameter(Position = 2, Mandatory = $true)]
|
|
243
|
+
[ValidateNotNull()]
|
|
244
|
+
[ValidateLength(1, [int]::MaxValue)]
|
|
245
|
+
[string]
|
|
246
|
+
$prefix
|
|
247
|
+
)
|
|
248
|
+
if(Test-Path $composer_lock) {
|
|
249
|
+
Remove-Item -Path $composer_lock -Force
|
|
250
|
+
}
|
|
251
|
+
composer -q global require $prefix$release 2>&1 | out-null
|
|
252
|
+
if($tool -eq "codeception") {
|
|
253
|
+
Copy-Item $composer_bin\codecept.bat -Destination $composer_bin\codeception.bat
|
|
254
|
+
}
|
|
255
|
+
if($?) {
|
|
256
|
+
Add-Log $tick $tool "Added"
|
|
257
|
+
} else {
|
|
258
|
+
Add-Log $cross $tool "Could not setup $tool"
|
|
259
|
+
}
|
|
260
|
+
if(Test-Path $composer_bin\composer) {
|
|
261
|
+
Copy-Item -Path "$php_dir\composer" -Destination "$composer_bin\composer" -Force
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
Function Add-Pecl() {
|
|
266
|
+
Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows"
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
# Variables
|
|
270
|
+
$tick = ([char]8730)
|
|
271
|
+
$cross = ([char]10007)
|
|
272
|
+
$php_dir = 'C:\tools\php'
|
|
273
|
+
$ext_dir = "$php_dir\ext"
|
|
274
|
+
$current_profile = "$PSHOME\Profile.ps1"
|
|
275
|
+
$ProgressPreference = 'SilentlyContinue'
|
|
276
|
+
$github = 'https://github.com'
|
|
277
|
+
$composer_bin = "$env:APPDATA\Composer\vendor\bin"
|
|
278
|
+
$composer_json = "$env:APPDATA\Composer\composer.json"
|
|
279
|
+
$composer_lock = "$env:APPDATA\Composer\composer.lock"
|
|
280
|
+
$arch = 'x64'
|
|
281
|
+
if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
|
|
282
|
+
$arch = 'x86'
|
|
283
|
+
}
|
|
284
|
+
$ts = $env:PHPTS -eq 'ts'
|
|
285
|
+
if($env:PHPTS -ne 'ts') {
|
|
286
|
+
$env:PHPTS = 'nts'
|
|
287
|
+
}
|
|
288
|
+
if(-not(Test-Path -LiteralPath $current_profile)) {
|
|
289
|
+
New-Item -Path $current_profile -ItemType "file" -Force >$null 2>&1
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
Add-Printf >$null 2>&1
|
|
293
|
+
Step-Log "Setup PhpManager"
|
|
294
|
+
Install-PSPackage PhpManager PhpManager\PhpManager "$github/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip" Get-Php >$null 2>&1
|
|
295
|
+
Add-Log $tick "PhpManager" "Installed"
|
|
296
|
+
|
|
297
|
+
Step-Log "Setup PHP"
|
|
298
|
+
$installed = $null
|
|
299
|
+
if (Test-Path -LiteralPath $php_dir -PathType Container) {
|
|
300
|
+
try {
|
|
301
|
+
$installed = Get-Php -Path $php_dir
|
|
302
|
+
} catch { }
|
|
303
|
+
}
|
|
304
|
+
$status = "Installed"
|
|
305
|
+
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
|
|
306
|
+
if ($version -lt '7.0' -and ($null -eq (Get-Module -ListAvailable -Name VcRedist))) {
|
|
307
|
+
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList >$null 2>&1
|
|
308
|
+
}
|
|
309
|
+
try {
|
|
310
|
+
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force > $null 2>&1
|
|
311
|
+
} catch { }
|
|
312
|
+
} else {
|
|
313
|
+
$status = "Found"
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
$installed = Get-Php -Path $php_dir
|
|
317
|
+
if($installed.MajorMinorVersion -ne $version) {
|
|
318
|
+
Add-Log $cross "PHP" "Could not setup PHP $version"
|
|
319
|
+
exit 1
|
|
320
|
+
}
|
|
321
|
+
('date.timezone=UTC', 'memory_limit=-1', 'xdebug.mode=coverage') | ForEach-Object { $p=$_.split('='); Set-PhpIniKey -Key $p[0] -Value $p[1] -Path $php_dir }
|
|
322
|
+
Enable-PhpExtension -Extension openssl, curl, opcache, mbstring -Path $php_dir
|
|
323
|
+
Update-PhpCAInfo -Path $php_dir -Source CurrentUser
|
|
324
|
+
Copy-Item -Path $dist\..\src\configs\*.json -Destination $env:RUNNER_TOOL_CACHE
|
|
325
|
+
New-Item -ItemType Directory -Path $composer_bin -Force > $null 2>&1
|
|
326
|
+
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)"
|