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