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.
Files changed (134) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +990 -922
  3. package/lib/config.d.ts +3 -0
  4. package/lib/config.js +71 -71
  5. package/lib/config.js.map +1 -1
  6. package/lib/coverage.d.ts +5 -0
  7. package/lib/coverage.js +97 -87
  8. package/lib/coverage.js.map +1 -1
  9. package/lib/extensions.d.ts +4 -0
  10. package/lib/extensions.js +214 -200
  11. package/lib/extensions.js.map +1 -1
  12. package/lib/fetch.d.ts +1 -0
  13. package/lib/fetch.js +63 -0
  14. package/lib/fetch.js.map +1 -0
  15. package/lib/install.d.ts +2 -0
  16. package/lib/install.js +75 -81
  17. package/lib/install.js.map +1 -1
  18. package/lib/tools.d.ts +23 -0
  19. package/lib/tools.js +367 -386
  20. package/lib/tools.js.map +1 -1
  21. package/lib/utils.d.ts +21 -0
  22. package/lib/utils.js +261 -291
  23. package/lib/utils.js.map +1 -1
  24. package/package.json +67 -56
  25. package/src/config.ts +82 -82
  26. package/src/configs/brew_extensions +31 -0
  27. package/src/configs/composer.env +2 -0
  28. package/src/configs/ini/jit.ini +3 -0
  29. package/src/configs/ini/php.ini +2 -0
  30. package/src/configs/ini/xdebug.ini +1 -0
  31. package/src/configs/os_releases.csv +19 -17
  32. package/src/configs/php-versions.json +6 -5
  33. package/src/configs/php_packages +12 -0
  34. package/src/configs/{php.json → pm/php.json} +29 -29
  35. package/src/configs/{phpunit.json → pm/phpunit.json} +24 -24
  36. package/src/configs/tools.json +278 -235
  37. package/src/configs/tools_schema.json +125 -114
  38. package/src/coverage.ts +144 -142
  39. package/src/extensions.ts +367 -349
  40. package/src/fetch.ts +54 -0
  41. package/src/install.ts +66 -82
  42. package/src/scripts/darwin.sh +285 -249
  43. package/src/scripts/extensions/add_extensions.ps1 +194 -0
  44. package/src/scripts/extensions/add_extensions.sh +184 -0
  45. package/src/scripts/{ext → extensions}/blackfire.ps1 +32 -32
  46. package/src/scripts/{ext → extensions}/blackfire.sh +22 -21
  47. package/src/scripts/{ext → extensions}/couchbase.sh +43 -43
  48. package/src/scripts/{ext → extensions}/cubrid.sh +60 -60
  49. package/src/scripts/extensions/extension_map.php +132 -0
  50. package/src/scripts/{ext → extensions}/firebird.ps1 +19 -19
  51. package/src/scripts/{ext → extensions}/firebird.sh +39 -35
  52. package/src/scripts/{ext → extensions}/gearman.sh +22 -22
  53. package/src/scripts/{ext → extensions}/geos.sh +17 -17
  54. package/src/scripts/{ext → extensions}/http.ps1 +54 -54
  55. package/src/scripts/{ext → extensions}/http.sh +109 -120
  56. package/src/scripts/{ext → extensions}/intl.sh +23 -23
  57. package/src/scripts/{ext → extensions}/ioncube.ps1 +33 -32
  58. package/src/scripts/{ext → extensions}/ioncube.sh +21 -19
  59. package/src/scripts/{ext → extensions}/oci.ps1 +85 -60
  60. package/src/scripts/{ext → extensions}/oci.sh +65 -63
  61. package/src/scripts/{ext → extensions}/patches/firebird.sh +11 -11
  62. package/src/scripts/{ext → extensions}/patches/geos.sh +7 -7
  63. package/src/scripts/{ext → extensions}/patches/http.sh +11 -11
  64. package/src/scripts/{ext → extensions}/patches/pdo_oci.sh +6 -6
  65. package/src/scripts/{ext → extensions}/patches/phpize.sh +26 -26
  66. package/src/scripts/{ext → extensions}/patches/protobuf.sh +4 -4
  67. package/src/scripts/{ext → extensions}/phalcon.ps1 +54 -54
  68. package/src/scripts/{ext → extensions}/phalcon.sh +58 -58
  69. package/src/scripts/{ext → extensions}/source.sh +145 -144
  70. package/src/scripts/extensions/sqlsrv.sh +15 -0
  71. package/src/scripts/linux.sh +269 -256
  72. package/src/scripts/tools/add_tools.ps1 +239 -26
  73. package/src/scripts/tools/add_tools.sh +175 -20
  74. package/src/scripts/tools/blackfire.ps1 +19 -19
  75. package/src/scripts/tools/blackfire.sh +40 -39
  76. package/src/scripts/tools/grpc_php_plugin.ps1 +21 -21
  77. package/src/scripts/tools/grpc_php_plugin.sh +58 -58
  78. package/src/scripts/tools/ppa.sh +192 -151
  79. package/src/scripts/tools/protoc.ps1 +38 -38
  80. package/src/scripts/tools/protoc.sh +28 -28
  81. package/src/scripts/tools/symfony.ps1 +14 -0
  82. package/src/scripts/tools/symfony.sh +13 -0
  83. package/src/scripts/unix.sh +186 -0
  84. package/src/scripts/win32.ps1 +352 -494
  85. package/src/tools.ts +512 -538
  86. package/src/utils.ts +415 -500
  87. package/.eslintrc.json +0 -16
  88. package/.github/CODE_OF_CONDUCT.md +0 -76
  89. package/.github/CONTRIBUTING.md +0 -70
  90. package/.github/FUNDING.yml +0 -7
  91. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -42
  92. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -26
  93. package/.github/PULL_REQUEST_TEMPLATE.md +0 -37
  94. package/.github/SECURITY.md +0 -29
  95. package/.github/workflows/docs.yml +0 -77
  96. package/.github/workflows/node-workflow.yml +0 -51
  97. package/.github/workflows/workflow.yml +0 -78
  98. package/.idea/workspace.xml +0 -113
  99. package/.prettierrc.json +0 -12
  100. package/__tests__/config.test.ts +0 -52
  101. package/__tests__/coverage.test.ts +0 -110
  102. package/__tests__/extensions.test.ts +0 -263
  103. package/__tests__/install.test.ts +0 -175
  104. package/__tests__/tools.test.ts +0 -524
  105. package/__tests__/utils.test.ts +0 -307
  106. package/action.yml +0 -29
  107. package/dist/index.js +0 -3051
  108. package/examples/bedrock.yml +0 -32
  109. package/examples/blackfire-player.yml +0 -31
  110. package/examples/blackfire.yml +0 -31
  111. package/examples/cakephp-mysql.yml +0 -114
  112. package/examples/cakephp-postgres.yml +0 -112
  113. package/examples/cakephp.yml +0 -92
  114. package/examples/codeigniter.yml +0 -34
  115. package/examples/laravel-mysql.yml +0 -74
  116. package/examples/laravel-postgres.yml +0 -74
  117. package/examples/laravel.yml +0 -42
  118. package/examples/lumen-mysql.yml +0 -74
  119. package/examples/lumen-postgres.yml +0 -74
  120. package/examples/lumen.yml +0 -38
  121. package/examples/phalcon-mysql.yml +0 -74
  122. package/examples/phalcon-postgres.yml +0 -73
  123. package/examples/sage.yml +0 -57
  124. package/examples/slim-framework.yml +0 -34
  125. package/examples/symfony-mysql.yml +0 -57
  126. package/examples/symfony-postgres.yml +0 -55
  127. package/examples/symfony.yml +0 -39
  128. package/examples/yii2-mysql.yml +0 -73
  129. package/examples/yii2-postgres.yml +0 -71
  130. package/examples/zend-framework.yml +0 -36
  131. package/jest.config.js +0 -12
  132. package/lib/sapi.js +0 -64
  133. package/src/scripts/common.sh +0 -314
  134. package/tsconfig.json +0 -18
package/src/fetch.ts ADDED
@@ -0,0 +1,54 @@
1
+ import {IncomingMessage, OutgoingHttpHeaders} from 'http';
2
+ import * as https from 'https';
3
+ import * as url from 'url';
4
+
5
+ /**
6
+ * Function to fetch an URL
7
+ *
8
+ * @param input_url
9
+ * @param auth_token
10
+ */
11
+ export async function fetch(
12
+ input_url: string,
13
+ auth_token?: string,
14
+ redirect_count = 5
15
+ ): Promise<Record<string, string>> {
16
+ const fetch_promise: Promise<Record<string, string>> = new Promise(
17
+ resolve => {
18
+ const url_object: url.UrlObject = new url.URL(input_url);
19
+ const headers: OutgoingHttpHeaders = {
20
+ 'User-Agent': `Mozilla/5.0 (${process.platform} ${process.arch}) setup-php`
21
+ };
22
+ if (auth_token) {
23
+ headers.authorization = 'Bearer ' + auth_token;
24
+ }
25
+ const options: https.RequestOptions = {
26
+ hostname: url_object.hostname,
27
+ path: url_object.pathname,
28
+ headers: headers
29
+ };
30
+ const req = https.get(options, (res: IncomingMessage) => {
31
+ if (res.statusCode === 200) {
32
+ let body = '';
33
+ res.setEncoding('utf8');
34
+ res.on('data', chunk => (body += chunk));
35
+ res.on('end', () => resolve({data: `${body}`}));
36
+ } else if (
37
+ [301, 302, 303, 307, 308].includes(res.statusCode as number)
38
+ ) {
39
+ if (redirect_count > 0 && res.headers.location) {
40
+ fetch(res.headers.location, auth_token, redirect_count--).then(
41
+ resolve
42
+ );
43
+ } else {
44
+ resolve({error: `${res.statusCode}: Redirect error`});
45
+ }
46
+ } else {
47
+ resolve({error: `${res.statusCode}: ${res.statusMessage}`});
48
+ }
49
+ });
50
+ req.end();
51
+ }
52
+ );
53
+ return await fetch_promise;
54
+ }
package/src/install.ts CHANGED
@@ -1,82 +1,66 @@
1
- import {exec} from '@actions/exec';
2
- import * as core from '@actions/core';
3
- import * as config from './config';
4
- import * as coverage from './coverage';
5
- import * as extensions from './extensions';
6
- import * as tools from './tools';
7
- import * as utils from './utils';
8
-
9
- /**
10
- * Build the script
11
- *
12
- * @param filename
13
- * @param version
14
- * @param os_version
15
- */
16
- export async function getScript(
17
- filename: string,
18
- version: string,
19
- os_version: string
20
- ): Promise<string> {
21
- const name = 'setup-php';
22
- const url = 'https://setup-php.com/support';
23
- // taking inputs
24
- process.env['fail_fast'] = await utils.getInput('fail-fast', false);
25
- const extension_csv: string = await utils.getInput('extensions', false);
26
- const ini_values_csv: string = await utils.getInput('ini-values', false);
27
- const coverage_driver: string = await utils.getInput('coverage', false);
28
- const tools_csv: string = await utils.getInput('tools', false);
29
-
30
- let script: string = await utils.readFile(filename, 'src/scripts');
31
- script += await tools.addTools(tools_csv, version, os_version);
32
-
33
- if (extension_csv) {
34
- script += await extensions.addExtension(extension_csv, version, os_version);
35
- }
36
- if (coverage_driver) {
37
- script += await coverage.addCoverage(coverage_driver, version, os_version);
38
- }
39
- if (ini_values_csv) {
40
- script += await config.addINIValues(ini_values_csv, os_version);
41
- }
42
-
43
- script += '\n' + (await utils.stepLog('Support this project', os_version));
44
- script += '\n' + (await utils.addLog('$tick', name, url, os_version));
45
-
46
- return await utils.writeScript(filename, script);
47
- }
48
-
49
- /**
50
- * Run the script
51
- */
52
- export async function run(): Promise<void> {
53
- try {
54
- if ((await utils.readEnv('ImageOS')) == 'ubuntu16') {
55
- core.setFailed(
56
- 'setup-php is not supported on Ubuntu 16.04. Please upgrade to Ubuntu 18.04 or Ubuntu 20.04 - https://setup-php.com/i/452'
57
- );
58
- return;
59
- }
60
- const version: string = await utils.parseVersion(
61
- await utils.getInput('php-version', true)
62
- );
63
- if (version) {
64
- const os_version: string = process.platform;
65
- const tool = await utils.scriptTool(os_version);
66
- const script = os_version + (await utils.scriptExtension(os_version));
67
- const location = await getScript(script, version, os_version);
68
- await exec(await utils.joins(tool, location, version, __dirname));
69
- } else {
70
- core.setFailed('Unable to get the PHP version');
71
- }
72
- } catch (error) {
73
- core.setFailed(error.message);
74
- }
75
- }
76
-
77
- // call the run function
78
- (async () => {
79
- await run();
80
- })().catch(error => {
81
- core.setFailed(error.message);
82
- });
1
+ import path from 'path';
2
+ import fs from 'fs';
3
+ import {exec} from '@actions/exec';
4
+ import * as core from '@actions/core';
5
+ import * as config from './config';
6
+ import * as coverage from './coverage';
7
+ import * as extensions from './extensions';
8
+ import * as tools from './tools';
9
+ import * as utils from './utils';
10
+
11
+ /**
12
+ * Build the script
13
+ *
14
+ * @param os
15
+ */
16
+ export async function getScript(os: string): Promise<string> {
17
+ const url = 'https://setup-php.com/sponsor';
18
+ const filename = os + (await utils.scriptExtension(os));
19
+ const script_path = path.join(__dirname, '../src/scripts', filename);
20
+ const run_path = script_path.replace(os, 'run');
21
+ process.env['fail_fast'] = await utils.getInput('fail-fast', false);
22
+ const extension_csv: string = await utils.getInput('extensions', false);
23
+ const ini_values_csv: string = await utils.getInput('ini-values', false);
24
+ const coverage_driver: string = await utils.getInput('coverage', false);
25
+ const tools_csv: string = await utils.getInput('tools', false);
26
+ const version: string = await utils.parseVersion(
27
+ await utils.getInput('php-version', true)
28
+ );
29
+ const ini_file: string = await utils.parseIniFile(
30
+ await utils.getInput('ini-file', false)
31
+ );
32
+ let script = await utils.joins('.', script_path, version, ini_file);
33
+ if (extension_csv) {
34
+ script += await extensions.addExtension(extension_csv, version, os);
35
+ }
36
+ script += await tools.addTools(tools_csv, version, os);
37
+ if (coverage_driver) {
38
+ script += await coverage.addCoverage(coverage_driver, version, os);
39
+ }
40
+ if (ini_values_csv) {
41
+ script += await config.addINIValues(ini_values_csv, os);
42
+ }
43
+ script += '\n' + (await utils.stepLog(`Sponsor setup-php`, os));
44
+ script += '\n' + (await utils.addLog('$tick', 'setup-php', url, os));
45
+
46
+ fs.writeFileSync(run_path, script, {mode: 0o755});
47
+
48
+ return run_path;
49
+ }
50
+
51
+ /**
52
+ * Run the script
53
+ */
54
+ export async function run(): Promise<void> {
55
+ const os: string = process.platform;
56
+ const tool = await utils.scriptTool(os);
57
+ const run_path = await getScript(os);
58
+ await exec(tool + run_path);
59
+ }
60
+
61
+ // call the run function
62
+ (async () => {
63
+ await run();
64
+ })().catch(error => {
65
+ core.setFailed(error.message);
66
+ });