setup-php 2.12.0 → 2.16.0
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 +977 -936
- package/package.json +66 -56
- package/src/config.ts +82 -82
- package/src/configs/brew_extensions +30 -0
- package/src/configs/os_releases.csv +17 -0
- package/src/configs/php-versions.json +6 -5
- package/src/configs/{php.json → pm/php.json} +29 -29
- package/src/configs/{phpunit.json → pm/phpunit.json} +24 -24
- package/src/configs/tools.json +256 -234
- package/src/configs/tools_schema.json +114 -103
- package/src/coverage.ts +169 -142
- package/src/extensions.ts +363 -349
- package/src/install.ts +79 -82
- package/src/scripts/common.sh +366 -314
- package/src/scripts/darwin.sh +257 -248
- package/src/scripts/ext/blackfire.ps1 +32 -32
- package/src/scripts/ext/blackfire.sh +22 -21
- package/src/scripts/ext/couchbase.sh +43 -43
- package/src/scripts/ext/cubrid.sh +60 -60
- package/src/scripts/ext/extension_map.php +109 -0
- package/src/scripts/ext/firebird.ps1 +19 -19
- package/src/scripts/ext/firebird.sh +39 -35
- package/src/scripts/ext/gearman.sh +22 -22
- package/src/scripts/ext/geos.sh +17 -17
- package/src/scripts/ext/http.ps1 +54 -54
- package/src/scripts/ext/http.sh +120 -120
- package/src/scripts/ext/intl.sh +23 -23
- package/src/scripts/ext/ioncube.ps1 +33 -32
- package/src/scripts/ext/ioncube.sh +21 -19
- package/src/scripts/ext/oci.ps1 +60 -60
- package/src/scripts/ext/oci.sh +65 -63
- package/src/scripts/ext/patches/firebird.sh +11 -11
- package/src/scripts/ext/patches/geos.sh +7 -7
- package/src/scripts/ext/patches/http.sh +11 -11
- package/src/scripts/ext/patches/pdo_oci.sh +6 -6
- package/src/scripts/ext/patches/phpize.sh +26 -26
- package/src/scripts/ext/patches/protobuf.sh +4 -4
- package/src/scripts/ext/phalcon.ps1 +54 -55
- package/src/scripts/ext/phalcon.sh +59 -59
- package/src/scripts/ext/source.sh +144 -144
- package/src/scripts/linux.sh +239 -280
- package/src/scripts/tools/add_tools.ps1 +28 -25
- package/src/scripts/tools/add_tools.sh +27 -19
- package/src/scripts/tools/blackfire.ps1 +19 -21
- package/src/scripts/tools/blackfire.sh +40 -35
- package/src/scripts/tools/grpc_php_plugin.ps1 +21 -21
- package/src/scripts/tools/grpc_php_plugin.sh +58 -61
- package/src/scripts/tools/ppa.sh +189 -0
- package/src/scripts/tools/protoc.ps1 +38 -38
- package/src/scripts/tools/protoc.sh +28 -28
- package/src/scripts/win32.ps1 +566 -471
- package/src/tools.ts +538 -509
- package/src/utils.ts +503 -497
- package/.eslintrc.json +0 -16
- package/.github/CODE_OF_CONDUCT.md +0 -76
- package/.github/CONTRIBUTING.md +0 -70
- package/.github/FUNDING.yml +0 -7
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -42
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -26
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -37
- package/.github/SECURITY.md +0 -29
- package/.github/workflows/docs.yml +0 -77
- package/.github/workflows/node-workflow.yml +0 -51
- package/.github/workflows/workflow.yml +0 -78
- 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 -261
- package/__tests__/install.test.ts +0 -175
- package/__tests__/tools.test.ts +0 -490
- package/__tests__/utils.test.ts +0 -303
- package/action.yml +0 -29
- package/dist/index.js +0 -3001
- package/examples/bedrock.yml +0 -32
- package/examples/blackfire-player.yml +0 -31
- package/examples/blackfire.yml +0 -31
- 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 -57
- package/examples/symfony-postgres.yml +0 -55
- 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/config.js +0 -72
- package/lib/config.js.map +0 -1
- package/lib/coverage.js +0 -88
- package/lib/coverage.js.map +0 -1
- package/lib/extensions.js +0 -201
- package/lib/extensions.js.map +0 -1
- package/lib/install.js +0 -82
- package/lib/install.js.map +0 -1
- package/lib/sapi.js +0 -64
- package/lib/tools.js +0 -387
- package/lib/tools.js.map +0 -1
- package/lib/utils.js +0 -292
- package/lib/utils.js.map +0 -1
- package/tsconfig.json +0 -18
package/src/utils.ts
CHANGED
|
@@ -1,497 +1,503 @@
|
|
|
1
|
-
import {IncomingMessage, OutgoingHttpHeaders} from 'http';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
import * as https from 'https';
|
|
4
|
-
import * as path from 'path';
|
|
5
|
-
import * as url from 'url';
|
|
6
|
-
import * as core from '@actions/core';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Function to read environment variable and return a string value.
|
|
10
|
-
*
|
|
11
|
-
* @param property
|
|
12
|
-
*/
|
|
13
|
-
export async function readEnv(property: string): Promise<string> {
|
|
14
|
-
const
|
|
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
|
-
res.
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
case '
|
|
145
|
-
return '
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
*
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
case '
|
|
197
|
-
return '
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
*
|
|
212
|
-
* @param
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
case '
|
|
225
|
-
return '
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
*
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
*
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
})
|
|
315
|
-
.
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
);
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
);
|
|
497
|
-
|
|
1
|
+
import {IncomingMessage, OutgoingHttpHeaders} from 'http';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as https from 'https';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import * as url from 'url';
|
|
6
|
+
import * as core from '@actions/core';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Function to read environment variable and return a string value.
|
|
10
|
+
*
|
|
11
|
+
* @param property
|
|
12
|
+
*/
|
|
13
|
+
export async function readEnv(property: string): Promise<string> {
|
|
14
|
+
const property_lc: string = property.toLowerCase();
|
|
15
|
+
const property_uc: string = property.toUpperCase();
|
|
16
|
+
return (
|
|
17
|
+
process.env[property] ||
|
|
18
|
+
process.env[property_lc] ||
|
|
19
|
+
process.env[property_uc] ||
|
|
20
|
+
process.env[property_lc.replace('_', '-')] ||
|
|
21
|
+
process.env[property_uc.replace('_', '-')] ||
|
|
22
|
+
''
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Function to get inputs from both with and env annotations.
|
|
28
|
+
*
|
|
29
|
+
* @param name
|
|
30
|
+
* @param mandatory
|
|
31
|
+
*/
|
|
32
|
+
export async function getInput(
|
|
33
|
+
name: string,
|
|
34
|
+
mandatory: boolean
|
|
35
|
+
): Promise<string> {
|
|
36
|
+
const input = core.getInput(name);
|
|
37
|
+
const env_input = await readEnv(name);
|
|
38
|
+
switch (true) {
|
|
39
|
+
case input != '':
|
|
40
|
+
return input;
|
|
41
|
+
case input == '' && env_input != '':
|
|
42
|
+
return env_input;
|
|
43
|
+
case input == '' && env_input == '' && mandatory:
|
|
44
|
+
throw new Error(`Input required and not supplied: ${name}`);
|
|
45
|
+
default:
|
|
46
|
+
return '';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Function to fetch an URL
|
|
52
|
+
*
|
|
53
|
+
* @param input_url
|
|
54
|
+
* @param auth_token
|
|
55
|
+
*/
|
|
56
|
+
export async function fetch(
|
|
57
|
+
input_url: string,
|
|
58
|
+
auth_token?: string
|
|
59
|
+
): Promise<Record<string, string>> {
|
|
60
|
+
const fetch_promise: Promise<Record<string, string>> = new Promise(
|
|
61
|
+
resolve => {
|
|
62
|
+
const url_object: url.UrlObject = new url.URL(input_url);
|
|
63
|
+
const headers: OutgoingHttpHeaders = {
|
|
64
|
+
'User-Agent': `Mozilla/5.0 (${process.platform} ${process.arch}) setup-php`
|
|
65
|
+
};
|
|
66
|
+
if (auth_token) {
|
|
67
|
+
headers.authorization = 'Bearer ' + auth_token;
|
|
68
|
+
}
|
|
69
|
+
const options: https.RequestOptions = {
|
|
70
|
+
hostname: url_object.hostname,
|
|
71
|
+
path: url_object.pathname,
|
|
72
|
+
headers: headers
|
|
73
|
+
};
|
|
74
|
+
const req = https.get(options, (res: IncomingMessage) => {
|
|
75
|
+
if (res.statusCode != 200) {
|
|
76
|
+
resolve({error: `${res.statusCode}: ${res.statusMessage}`});
|
|
77
|
+
} else {
|
|
78
|
+
let body = '';
|
|
79
|
+
res.setEncoding('utf8');
|
|
80
|
+
res.on('data', chunk => (body += chunk));
|
|
81
|
+
res.on('end', () => resolve({data: `${body}`}));
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
req.end();
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
return await fetch_promise;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Function to get manifest URL
|
|
91
|
+
*
|
|
92
|
+
*/
|
|
93
|
+
export async function getManifestURL(): Promise<string> {
|
|
94
|
+
return 'https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/configs/php-versions.json';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Function to parse PHP version.
|
|
99
|
+
*
|
|
100
|
+
* @param version
|
|
101
|
+
*/
|
|
102
|
+
export async function parseVersion(version: string): Promise<string> {
|
|
103
|
+
const manifest = await getManifestURL();
|
|
104
|
+
switch (true) {
|
|
105
|
+
case /^(latest|nightly|\d+\.x)$/.test(version):
|
|
106
|
+
return JSON.parse((await fetch(manifest))['data'])[version];
|
|
107
|
+
default:
|
|
108
|
+
switch (true) {
|
|
109
|
+
case version.length > 1:
|
|
110
|
+
return version.slice(0, 3);
|
|
111
|
+
default:
|
|
112
|
+
return version + '.0';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Async foreach loop
|
|
119
|
+
*
|
|
120
|
+
* @author https://github.com/Atinux
|
|
121
|
+
* @param array
|
|
122
|
+
* @param callback
|
|
123
|
+
*/
|
|
124
|
+
export async function asyncForEach(
|
|
125
|
+
array: Array<string>,
|
|
126
|
+
callback: (
|
|
127
|
+
element: string,
|
|
128
|
+
index: number,
|
|
129
|
+
array: Array<string>
|
|
130
|
+
) => Promise<void>
|
|
131
|
+
): Promise<void> {
|
|
132
|
+
for (let index = 0; index < array.length; index++) {
|
|
133
|
+
await callback(array[index], index, array);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Get color index
|
|
139
|
+
*
|
|
140
|
+
* @param type
|
|
141
|
+
*/
|
|
142
|
+
export async function color(type: string): Promise<string> {
|
|
143
|
+
switch (type) {
|
|
144
|
+
case 'error':
|
|
145
|
+
return '31';
|
|
146
|
+
default:
|
|
147
|
+
case 'success':
|
|
148
|
+
return '32';
|
|
149
|
+
case 'warning':
|
|
150
|
+
return '33';
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Log to console
|
|
156
|
+
*
|
|
157
|
+
* @param message
|
|
158
|
+
* @param os_version
|
|
159
|
+
* @param log_type
|
|
160
|
+
*/
|
|
161
|
+
export async function log(
|
|
162
|
+
message: string,
|
|
163
|
+
os_version: string,
|
|
164
|
+
log_type: string
|
|
165
|
+
): Promise<string> {
|
|
166
|
+
switch (os_version) {
|
|
167
|
+
case 'win32':
|
|
168
|
+
return (
|
|
169
|
+
'printf "\\033[' +
|
|
170
|
+
(await color(log_type)) +
|
|
171
|
+
';1m' +
|
|
172
|
+
message +
|
|
173
|
+
' \\033[0m"'
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
case 'linux':
|
|
177
|
+
case 'darwin':
|
|
178
|
+
default:
|
|
179
|
+
return (
|
|
180
|
+
'echo "\\033[' + (await color(log_type)) + ';1m' + message + '\\033[0m"'
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Function to log a step
|
|
187
|
+
*
|
|
188
|
+
* @param message
|
|
189
|
+
* @param os_version
|
|
190
|
+
*/
|
|
191
|
+
export async function stepLog(
|
|
192
|
+
message: string,
|
|
193
|
+
os_version: string
|
|
194
|
+
): Promise<string> {
|
|
195
|
+
switch (os_version) {
|
|
196
|
+
case 'win32':
|
|
197
|
+
return 'Step-Log "' + message + '"';
|
|
198
|
+
case 'linux':
|
|
199
|
+
case 'darwin':
|
|
200
|
+
return 'step_log "' + message + '"';
|
|
201
|
+
default:
|
|
202
|
+
return await log(
|
|
203
|
+
'Platform ' + os_version + ' is not supported',
|
|
204
|
+
os_version,
|
|
205
|
+
'error'
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Function to log a result
|
|
212
|
+
* @param mark
|
|
213
|
+
* @param subject
|
|
214
|
+
* @param message
|
|
215
|
+
* @param os_version
|
|
216
|
+
*/
|
|
217
|
+
export async function addLog(
|
|
218
|
+
mark: string,
|
|
219
|
+
subject: string,
|
|
220
|
+
message: string,
|
|
221
|
+
os_version: string
|
|
222
|
+
): Promise<string> {
|
|
223
|
+
switch (os_version) {
|
|
224
|
+
case 'win32':
|
|
225
|
+
return 'Add-Log "' + mark + '" "' + subject + '" "' + message + '"';
|
|
226
|
+
case 'linux':
|
|
227
|
+
case 'darwin':
|
|
228
|
+
return 'add_log "' + mark + '" "' + subject + '" "' + message + '"';
|
|
229
|
+
default:
|
|
230
|
+
return await log(
|
|
231
|
+
'Platform ' + os_version + ' is not supported',
|
|
232
|
+
os_version,
|
|
233
|
+
'error'
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Read the scripts
|
|
240
|
+
*
|
|
241
|
+
* @param filename
|
|
242
|
+
* @param directory
|
|
243
|
+
*/
|
|
244
|
+
export async function readFile(
|
|
245
|
+
filename: string,
|
|
246
|
+
directory: string
|
|
247
|
+
): Promise<string> {
|
|
248
|
+
return fs.readFileSync(
|
|
249
|
+
path.join(__dirname, '../' + directory, filename),
|
|
250
|
+
'utf8'
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Write final script which runs
|
|
256
|
+
*
|
|
257
|
+
* @param filename
|
|
258
|
+
* @param script
|
|
259
|
+
*/
|
|
260
|
+
export async function writeScript(
|
|
261
|
+
filename: string,
|
|
262
|
+
script: string
|
|
263
|
+
): Promise<string> {
|
|
264
|
+
const runner_dir: string = await getInput('RUNNER_TOOL_CACHE', false);
|
|
265
|
+
const script_path: string = path.join(runner_dir, filename);
|
|
266
|
+
fs.writeFileSync(script_path, script, {mode: 0o755});
|
|
267
|
+
return script_path;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Function to break extension csv into an array
|
|
272
|
+
*
|
|
273
|
+
* @param extension_csv
|
|
274
|
+
*/
|
|
275
|
+
export async function extensionArray(
|
|
276
|
+
extension_csv: string
|
|
277
|
+
): Promise<Array<string>> {
|
|
278
|
+
switch (extension_csv) {
|
|
279
|
+
case '':
|
|
280
|
+
case ' ':
|
|
281
|
+
return [];
|
|
282
|
+
default:
|
|
283
|
+
return [
|
|
284
|
+
extension_csv.match(/(^|,\s?)none(\s?,|$)/) ? 'none' : '',
|
|
285
|
+
...extension_csv
|
|
286
|
+
.split(',')
|
|
287
|
+
|
|
288
|
+
.map(function (extension: string) {
|
|
289
|
+
if (/.+-.+\/.+@.+/.test(extension)) {
|
|
290
|
+
return extension;
|
|
291
|
+
}
|
|
292
|
+
return extension
|
|
293
|
+
.trim()
|
|
294
|
+
.toLowerCase()
|
|
295
|
+
.replace(/^(:)?(php[-_]|none|zend )/, '$1');
|
|
296
|
+
})
|
|
297
|
+
].filter(Boolean);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Function to break csv into an array
|
|
303
|
+
*
|
|
304
|
+
* @param values_csv
|
|
305
|
+
* @constructor
|
|
306
|
+
*/
|
|
307
|
+
export async function CSVArray(values_csv: string): Promise<Array<string>> {
|
|
308
|
+
switch (values_csv) {
|
|
309
|
+
case '':
|
|
310
|
+
case ' ':
|
|
311
|
+
return [];
|
|
312
|
+
default:
|
|
313
|
+
return values_csv
|
|
314
|
+
.split(/,(?=(?:(?:[^"']*["']){2})*[^"']*$)/)
|
|
315
|
+
.map(function (value) {
|
|
316
|
+
return value
|
|
317
|
+
.trim()
|
|
318
|
+
.replace(/^["']|["']$|(?<==)["']/g, '')
|
|
319
|
+
.replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'");
|
|
320
|
+
})
|
|
321
|
+
.filter(Boolean);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Function to get prefix required to load an extension.
|
|
327
|
+
*
|
|
328
|
+
* @param extension
|
|
329
|
+
*/
|
|
330
|
+
export async function getExtensionPrefix(extension: string): Promise<string> {
|
|
331
|
+
switch (true) {
|
|
332
|
+
default:
|
|
333
|
+
return 'extension';
|
|
334
|
+
case /xdebug([2-3])?$|opcache|ioncube|eaccelerator/.test(extension):
|
|
335
|
+
return 'zend_extension';
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Function to get the suffix to suppress console output
|
|
341
|
+
*
|
|
342
|
+
* @param os_version
|
|
343
|
+
*/
|
|
344
|
+
export async function suppressOutput(os_version: string): Promise<string> {
|
|
345
|
+
switch (os_version) {
|
|
346
|
+
case 'win32':
|
|
347
|
+
return ' >$null 2>&1';
|
|
348
|
+
case 'linux':
|
|
349
|
+
case 'darwin':
|
|
350
|
+
return ' >/dev/null 2>&1';
|
|
351
|
+
default:
|
|
352
|
+
return await log(
|
|
353
|
+
'Platform ' + os_version + ' is not supported',
|
|
354
|
+
os_version,
|
|
355
|
+
'error'
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Function to get script to log unsupported extensions.
|
|
362
|
+
*
|
|
363
|
+
* @param extension
|
|
364
|
+
* @param version
|
|
365
|
+
* @param os_version
|
|
366
|
+
*/
|
|
367
|
+
export async function getUnsupportedLog(
|
|
368
|
+
extension: string,
|
|
369
|
+
version: string,
|
|
370
|
+
os_version: string
|
|
371
|
+
): Promise<string> {
|
|
372
|
+
return (
|
|
373
|
+
'\n' +
|
|
374
|
+
(await addLog(
|
|
375
|
+
'$cross',
|
|
376
|
+
extension,
|
|
377
|
+
[extension, 'is not supported on PHP', version].join(' '),
|
|
378
|
+
os_version
|
|
379
|
+
)) +
|
|
380
|
+
'\n'
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Function to get command to setup tools
|
|
386
|
+
*
|
|
387
|
+
* @param os_version
|
|
388
|
+
* @param suffix
|
|
389
|
+
*/
|
|
390
|
+
export async function getCommand(
|
|
391
|
+
os_version: string,
|
|
392
|
+
suffix: string
|
|
393
|
+
): Promise<string> {
|
|
394
|
+
switch (os_version) {
|
|
395
|
+
case 'linux':
|
|
396
|
+
case 'darwin':
|
|
397
|
+
return 'add_' + suffix + ' ';
|
|
398
|
+
case 'win32':
|
|
399
|
+
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
|
400
|
+
default:
|
|
401
|
+
return await log(
|
|
402
|
+
'Platform ' + os_version + ' is not supported',
|
|
403
|
+
os_version,
|
|
404
|
+
'error'
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Function to join strings with space
|
|
411
|
+
*
|
|
412
|
+
* @param str
|
|
413
|
+
*/
|
|
414
|
+
export async function joins(...str: string[]): Promise<string> {
|
|
415
|
+
return [...str].join(' ');
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Function to get script extensions
|
|
420
|
+
*
|
|
421
|
+
* @param os_version
|
|
422
|
+
*/
|
|
423
|
+
export async function scriptExtension(os_version: string): Promise<string> {
|
|
424
|
+
switch (os_version) {
|
|
425
|
+
case 'win32':
|
|
426
|
+
return '.ps1';
|
|
427
|
+
case 'linux':
|
|
428
|
+
case 'darwin':
|
|
429
|
+
return '.sh';
|
|
430
|
+
default:
|
|
431
|
+
return await log(
|
|
432
|
+
'Platform ' + os_version + ' is not supported',
|
|
433
|
+
os_version,
|
|
434
|
+
'error'
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Function to get script tool
|
|
441
|
+
*
|
|
442
|
+
* @param os_version
|
|
443
|
+
*/
|
|
444
|
+
export async function scriptTool(os_version: string): Promise<string> {
|
|
445
|
+
switch (os_version) {
|
|
446
|
+
case 'win32':
|
|
447
|
+
return 'pwsh';
|
|
448
|
+
case 'linux':
|
|
449
|
+
case 'darwin':
|
|
450
|
+
return 'bash';
|
|
451
|
+
default:
|
|
452
|
+
return await log(
|
|
453
|
+
'Platform ' + os_version + ' is not supported',
|
|
454
|
+
os_version,
|
|
455
|
+
'error'
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Function to get script to add tools with custom support.
|
|
462
|
+
*
|
|
463
|
+
* @param pkg
|
|
464
|
+
* @param type
|
|
465
|
+
* @param version
|
|
466
|
+
* @param os_version
|
|
467
|
+
*/
|
|
468
|
+
export async function customPackage(
|
|
469
|
+
pkg: string,
|
|
470
|
+
type: string,
|
|
471
|
+
version: string,
|
|
472
|
+
os_version: string
|
|
473
|
+
): Promise<string> {
|
|
474
|
+
const pkg_name: string = pkg.replace(/\d+|(pdo|pecl)[_-]/, '');
|
|
475
|
+
const script_extension: string = await scriptExtension(os_version);
|
|
476
|
+
const script: string = path.join(
|
|
477
|
+
__dirname,
|
|
478
|
+
'../src/scripts/' + type + '/' + pkg_name + script_extension
|
|
479
|
+
);
|
|
480
|
+
const command: string = await getCommand(os_version, pkg_name);
|
|
481
|
+
return '\n. ' + script + '\n' + command + version;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Function to extension input for installation from source.
|
|
486
|
+
*
|
|
487
|
+
* @param extension
|
|
488
|
+
* @param prefix
|
|
489
|
+
*/
|
|
490
|
+
export async function parseExtensionSource(
|
|
491
|
+
extension: string,
|
|
492
|
+
prefix: string
|
|
493
|
+
): Promise<string> {
|
|
494
|
+
// Groups: extension, domain url, org, repo, release
|
|
495
|
+
const regex = /(\w+)-(.+:\/\/.+(?:[.:].+)+\/)?([\w.-]+)\/([\w.-]+)@(.+)/;
|
|
496
|
+
const matches = regex.exec(extension) as RegExpExecArray;
|
|
497
|
+
matches[2] = matches[2] ? matches[2].slice(0, -1) : 'https://github.com';
|
|
498
|
+
return await joins(
|
|
499
|
+
'\nadd_extension_from_source',
|
|
500
|
+
...matches.splice(1, matches.length),
|
|
501
|
+
prefix
|
|
502
|
+
);
|
|
503
|
+
}
|