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.
Files changed (80) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +433 -458
  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 +4 -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 +188 -200
  11. package/lib/extensions.js.map +1 -1
  12. package/lib/install.d.ts +2 -0
  13. package/lib/install.js +96 -81
  14. package/lib/install.js.map +1 -1
  15. package/lib/tools.d.ts +18 -0
  16. package/lib/tools.js +306 -386
  17. package/lib/tools.js.map +1 -1
  18. package/lib/utils.d.ts +15 -0
  19. package/lib/utils.js +205 -291
  20. package/lib/utils.js.map +1 -1
  21. package/package.json +66 -56
  22. package/src/config.ts +82 -82
  23. package/src/configs/brew_extensions +28 -0
  24. package/src/configs/php-versions.json +5 -5
  25. package/src/configs/phpunit.json +24 -24
  26. package/src/coverage.ts +146 -146
  27. package/src/extensions.ts +235 -233
  28. package/src/install.ts +104 -104
  29. package/src/scripts/darwin.sh +341 -339
  30. package/src/scripts/ext/gearman.sh +22 -22
  31. package/src/scripts/ext/phalcon.ps1 +55 -55
  32. package/src/scripts/ext/phalcon.sh +70 -70
  33. package/src/scripts/linux.sh +361 -361
  34. package/src/scripts/win32.ps1 +326 -333
  35. package/src/tools.ts +472 -469
  36. package/src/utils.ts +319 -316
  37. package/.eslintrc.json +0 -16
  38. package/.github/CODE_OF_CONDUCT.md +0 -76
  39. package/.github/CONTRIBUTING.md +0 -69
  40. package/.github/FUNDING.yml +0 -7
  41. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -23
  42. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  43. package/.github/PULL_REQUEST_TEMPLATE.md +0 -38
  44. package/.github/SECURITY.md +0 -29
  45. package/.github/workflows/main-workflow.yml +0 -56
  46. package/.github/workflows/node-workflow.yml +0 -47
  47. package/.idea/workspace.xml +0 -113
  48. package/.prettierrc.json +0 -12
  49. package/__tests__/config.test.ts +0 -52
  50. package/__tests__/coverage.test.ts +0 -110
  51. package/__tests__/extensions.test.ts +0 -120
  52. package/__tests__/install.test.ts +0 -181
  53. package/__tests__/tools.test.ts +0 -476
  54. package/__tests__/utils.test.ts +0 -213
  55. package/action.yml +0 -38
  56. package/dist/index.js +0 -2854
  57. package/examples/bedrock.yml +0 -32
  58. package/examples/cakephp-mysql.yml +0 -114
  59. package/examples/cakephp-postgres.yml +0 -112
  60. package/examples/cakephp.yml +0 -92
  61. package/examples/codeigniter.yml +0 -34
  62. package/examples/laravel-mysql.yml +0 -74
  63. package/examples/laravel-postgres.yml +0 -74
  64. package/examples/laravel.yml +0 -42
  65. package/examples/lumen-mysql.yml +0 -74
  66. package/examples/lumen-postgres.yml +0 -74
  67. package/examples/lumen.yml +0 -38
  68. package/examples/phalcon-mysql.yml +0 -74
  69. package/examples/phalcon-postgres.yml +0 -73
  70. package/examples/sage.yml +0 -57
  71. package/examples/slim-framework.yml +0 -34
  72. package/examples/symfony-mysql.yml +0 -56
  73. package/examples/symfony-postgres.yml +0 -54
  74. package/examples/symfony.yml +0 -39
  75. package/examples/yii2-mysql.yml +0 -73
  76. package/examples/yii2-postgres.yml +0 -71
  77. package/examples/zend-framework.yml +0 -36
  78. package/jest.config.js +0 -12
  79. package/lib/sapi.js +0 -64
  80. package/tsconfig.json +0 -18
package/src/utils.ts CHANGED
@@ -1,316 +1,319 @@
1
- import {IncomingMessage} from 'http';
2
- import * as fs from 'fs';
3
- import * as https from 'https';
4
- import * as path from 'path';
5
- import * as core from '@actions/core';
6
-
7
- /**
8
- * Function to read environment variable and return a string value.
9
- *
10
- * @param property
11
- */
12
- export async function readEnv(property: string): Promise<string> {
13
- const value = process.env[property];
14
- switch (value) {
15
- case undefined:
16
- return '';
17
- default:
18
- return value;
19
- }
20
- }
21
-
22
- /**
23
- * Function to get inputs from both with and env annotations.
24
- *
25
- * @param name
26
- * @param mandatory
27
- */
28
- export async function getInput(
29
- name: string,
30
- mandatory: boolean
31
- ): Promise<string> {
32
- const input = core.getInput(name);
33
- const env_input = await readEnv(name);
34
- switch (true) {
35
- case input != '':
36
- return input;
37
- case input == '' && env_input != '':
38
- return env_input;
39
- case input == '' && env_input == '' && mandatory:
40
- throw new Error(`Input required and not supplied: ${name}`);
41
- default:
42
- return '';
43
- }
44
- }
45
-
46
- /**
47
- * Function to fetch an URL
48
- *
49
- * @param url
50
- */
51
- export async function fetch(url: string): Promise<string> {
52
- const fetch_promise: Promise<string> = new Promise(resolve => {
53
- const req = https.get(url, (res: IncomingMessage) => {
54
- res.setEncoding('utf8');
55
- let body = '';
56
- res.on('data', chunk => (body += chunk));
57
- res.on('end', () => resolve(body));
58
- });
59
- req.end();
60
- });
61
- return await fetch_promise;
62
- }
63
-
64
- /**
65
- * Function to parse PHP version.
66
- *
67
- * @param version
68
- */
69
- export async function parseVersion(version: string): Promise<string> {
70
- const manifest =
71
- 'https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/configs/php-versions.json';
72
- switch (true) {
73
- case /^(latest|\d+\.x)$/.test(version):
74
- return JSON.parse(await fetch(manifest))[version];
75
- default:
76
- switch (true) {
77
- case version.length > 1:
78
- return version.slice(0, 3);
79
- default:
80
- return version + '.0';
81
- }
82
- }
83
- }
84
-
85
- /**
86
- * Async foreach loop
87
- *
88
- * @author https://github.com/Atinux
89
- * @param array
90
- * @param callback
91
- */
92
- export async function asyncForEach(
93
- array: Array<string>,
94
- callback: (
95
- element: string,
96
- index: number,
97
- array: Array<string>
98
- ) => Promise<void>
99
- ): Promise<void> {
100
- for (let index = 0; index < array.length; index++) {
101
- await callback(array[index], index, array);
102
- }
103
- }
104
-
105
- /**
106
- * Get color index
107
- *
108
- * @param type
109
- */
110
- export async function color(type: string): Promise<string> {
111
- switch (type) {
112
- case 'error':
113
- return '31';
114
- default:
115
- case 'success':
116
- return '32';
117
- case 'warning':
118
- return '33';
119
- }
120
- }
121
-
122
- /**
123
- * Log to console
124
- *
125
- * @param message
126
- * @param os_version
127
- * @param log_type
128
- */
129
- export async function log(
130
- message: string,
131
- os_version: string,
132
- log_type: string
133
- ): Promise<string> {
134
- switch (os_version) {
135
- case 'win32':
136
- return (
137
- 'printf "\\033[' +
138
- (await color(log_type)) +
139
- ';1m' +
140
- message +
141
- ' \\033[0m"'
142
- );
143
-
144
- case 'linux':
145
- case 'darwin':
146
- default:
147
- return (
148
- 'echo "\\033[' + (await color(log_type)) + ';1m' + message + '\\033[0m"'
149
- );
150
- }
151
- }
152
-
153
- /**
154
- * Function to log a step
155
- *
156
- * @param message
157
- * @param os_version
158
- */
159
- export async function stepLog(
160
- message: string,
161
- os_version: string
162
- ): Promise<string> {
163
- switch (os_version) {
164
- case 'win32':
165
- return 'Step-Log "' + message + '"';
166
- case 'linux':
167
- case 'darwin':
168
- return 'step_log "' + message + '"';
169
- default:
170
- return await log(
171
- 'Platform ' + os_version + ' is not supported',
172
- os_version,
173
- 'error'
174
- );
175
- }
176
- }
177
-
178
- /**
179
- * Function to log a result
180
- * @param mark
181
- * @param subject
182
- * @param message
183
- * @param os_version
184
- */
185
- export async function addLog(
186
- mark: string,
187
- subject: string,
188
- message: string,
189
- os_version: string
190
- ): Promise<string> {
191
- switch (os_version) {
192
- case 'win32':
193
- return 'Add-Log "' + mark + '" "' + subject + '" "' + message + '"';
194
- case 'linux':
195
- case 'darwin':
196
- return 'add_log "' + mark + '" "' + subject + '" "' + message + '"';
197
- default:
198
- return await log(
199
- 'Platform ' + os_version + ' is not supported',
200
- os_version,
201
- 'error'
202
- );
203
- }
204
- }
205
-
206
- /**
207
- * Read the scripts
208
- *
209
- * @param filename
210
- */
211
- export async function readScript(filename: string): Promise<string> {
212
- return fs.readFileSync(
213
- path.join(__dirname, '../src/scripts/' + filename),
214
- 'utf8'
215
- );
216
- }
217
-
218
- /**
219
- * Write final script which runs
220
- *
221
- * @param filename
222
- * @param script
223
- */
224
- export async function writeScript(
225
- filename: string,
226
- script: string
227
- ): Promise<string> {
228
- const runner_dir: string = await getInput('RUNNER_TOOL_CACHE', false);
229
- const script_path: string = path.join(runner_dir, filename);
230
- fs.writeFileSync(script_path, script, {mode: 0o755});
231
- return script_path;
232
- }
233
-
234
- /**
235
- * Function to break extension csv into an array
236
- *
237
- * @param extension_csv
238
- */
239
- export async function extensionArray(
240
- extension_csv: string
241
- ): Promise<Array<string>> {
242
- switch (extension_csv) {
243
- case '':
244
- case ' ':
245
- return [];
246
- default:
247
- return extension_csv
248
- .split(',')
249
- .map(function (extension: string) {
250
- return extension
251
- .trim()
252
- .toLowerCase()
253
- .replace(/^php[-_]/, '');
254
- })
255
- .filter(Boolean);
256
- }
257
- }
258
-
259
- /**
260
- * Function to break csv into an array
261
- *
262
- * @param values_csv
263
- * @constructor
264
- */
265
- export async function CSVArray(values_csv: string): Promise<Array<string>> {
266
- switch (values_csv) {
267
- case '':
268
- case ' ':
269
- return [];
270
- default:
271
- return values_csv
272
- .split(/,(?=(?:(?:[^"']*["']){2})*[^"']*$)/)
273
- .map(function (value) {
274
- return value
275
- .trim()
276
- .replace(/^["']|["']$|(?<==)["']/g, '')
277
- .replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'");
278
- })
279
- .filter(Boolean);
280
- }
281
- }
282
-
283
- /**
284
- * Function to get prefix required to load an extension.
285
- *
286
- * @param extension
287
- */
288
- export async function getExtensionPrefix(extension: string): Promise<string> {
289
- switch (true) {
290
- default:
291
- return 'extension';
292
- case /xdebug([2-3])?$|opcache|ioncube|eaccelerator/.test(extension):
293
- return 'zend_extension';
294
- }
295
- }
296
-
297
- /**
298
- * Function to get the suffix to suppress console output
299
- *
300
- * @param os_version
301
- */
302
- export async function suppressOutput(os_version: string): Promise<string> {
303
- switch (os_version) {
304
- case 'win32':
305
- return ' >$null 2>&1';
306
- case 'linux':
307
- case 'darwin':
308
- return ' >/dev/null 2>&1';
309
- default:
310
- return await log(
311
- 'Platform ' + os_version + ' is not supported',
312
- os_version,
313
- 'error'
314
- );
315
- }
316
- }
1
+ import {IncomingMessage} from 'http';
2
+ import * as fs from 'fs';
3
+ import * as https from 'https';
4
+ import * as path from 'path';
5
+ import * as core from '@actions/core';
6
+
7
+ /**
8
+ * Function to read environment variable and return a string value.
9
+ *
10
+ * @param property
11
+ */
12
+ export async function readEnv(property: string): Promise<string> {
13
+ const property_lc: string = property.toLowerCase();
14
+ const property_uc: string = property.toUpperCase();
15
+ return (
16
+ process.env[property] ||
17
+ process.env[property_lc] ||
18
+ process.env[property_uc] ||
19
+ process.env[property_lc.replace('_', '-')] ||
20
+ process.env[property_uc.replace('_', '-')] ||
21
+ ''
22
+ );
23
+ }
24
+
25
+ /**
26
+ * Function to get inputs from both with and env annotations.
27
+ *
28
+ * @param name
29
+ * @param mandatory
30
+ */
31
+ export async function getInput(
32
+ name: string,
33
+ mandatory: boolean
34
+ ): Promise<string> {
35
+ const input = core.getInput(name);
36
+ const env_input = await readEnv(name);
37
+ switch (true) {
38
+ case input != '':
39
+ return input;
40
+ case input == '' && env_input != '':
41
+ return env_input;
42
+ case input == '' && env_input == '' && mandatory:
43
+ throw new Error(`Input required and not supplied: ${name}`);
44
+ default:
45
+ return '';
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Function to fetch an URL
51
+ *
52
+ * @param url
53
+ */
54
+ export async function fetch(url: string): Promise<string> {
55
+ const fetch_promise: Promise<string> = new Promise(resolve => {
56
+ const req = https.get(url, (res: IncomingMessage) => {
57
+ res.setEncoding('utf8');
58
+ let body = '';
59
+ res.on('data', chunk => (body += chunk));
60
+ res.on('end', () => resolve(body));
61
+ });
62
+ req.end();
63
+ });
64
+ return await fetch_promise;
65
+ }
66
+
67
+ /**
68
+ * Function to parse PHP version.
69
+ *
70
+ * @param version
71
+ */
72
+ export async function parseVersion(version: string): Promise<string> {
73
+ const manifest =
74
+ 'https://raw.githubusercontent.com/shivammathur/setup-php/releases/v1/src/configs/php-versions.json';
75
+ switch (true) {
76
+ case /^(latest|\d+\.x)$/.test(version):
77
+ return JSON.parse(await fetch(manifest))[version];
78
+ default:
79
+ switch (true) {
80
+ case version.length > 1:
81
+ return version.slice(0, 3);
82
+ default:
83
+ return version + '.0';
84
+ }
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Async foreach loop
90
+ *
91
+ * @author https://github.com/Atinux
92
+ * @param array
93
+ * @param callback
94
+ */
95
+ export async function asyncForEach(
96
+ array: Array<string>,
97
+ callback: (
98
+ element: string,
99
+ index: number,
100
+ array: Array<string>
101
+ ) => Promise<void>
102
+ ): Promise<void> {
103
+ for (let index = 0; index < array.length; index++) {
104
+ await callback(array[index], index, array);
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Get color index
110
+ *
111
+ * @param type
112
+ */
113
+ export async function color(type: string): Promise<string> {
114
+ switch (type) {
115
+ case 'error':
116
+ return '31';
117
+ default:
118
+ case 'success':
119
+ return '32';
120
+ case 'warning':
121
+ return '33';
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Log to console
127
+ *
128
+ * @param message
129
+ * @param os_version
130
+ * @param log_type
131
+ */
132
+ export async function log(
133
+ message: string,
134
+ os_version: string,
135
+ log_type: string
136
+ ): Promise<string> {
137
+ switch (os_version) {
138
+ case 'win32':
139
+ return (
140
+ 'printf "\\033[' +
141
+ (await color(log_type)) +
142
+ ';1m' +
143
+ message +
144
+ ' \\033[0m"'
145
+ );
146
+
147
+ case 'linux':
148
+ case 'darwin':
149
+ default:
150
+ return (
151
+ 'echo "\\033[' + (await color(log_type)) + ';1m' + message + '\\033[0m"'
152
+ );
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Function to log a step
158
+ *
159
+ * @param message
160
+ * @param os_version
161
+ */
162
+ export async function stepLog(
163
+ message: string,
164
+ os_version: string
165
+ ): Promise<string> {
166
+ switch (os_version) {
167
+ case 'win32':
168
+ return 'Step-Log "' + message + '"';
169
+ case 'linux':
170
+ case 'darwin':
171
+ return 'step_log "' + message + '"';
172
+ default:
173
+ return await log(
174
+ 'Platform ' + os_version + ' is not supported',
175
+ os_version,
176
+ 'error'
177
+ );
178
+ }
179
+ }
180
+
181
+ /**
182
+ * Function to log a result
183
+ * @param mark
184
+ * @param subject
185
+ * @param message
186
+ * @param os_version
187
+ */
188
+ export async function addLog(
189
+ mark: string,
190
+ subject: string,
191
+ message: string,
192
+ os_version: string
193
+ ): Promise<string> {
194
+ switch (os_version) {
195
+ case 'win32':
196
+ return 'Add-Log "' + mark + '" "' + subject + '" "' + message + '"';
197
+ case 'linux':
198
+ case 'darwin':
199
+ return 'add_log "' + mark + '" "' + subject + '" "' + message + '"';
200
+ default:
201
+ return await log(
202
+ 'Platform ' + os_version + ' is not supported',
203
+ os_version,
204
+ 'error'
205
+ );
206
+ }
207
+ }
208
+
209
+ /**
210
+ * Read the scripts
211
+ *
212
+ * @param filename
213
+ */
214
+ export async function readScript(filename: string): Promise<string> {
215
+ return fs.readFileSync(
216
+ path.join(__dirname, '../src/scripts/' + filename),
217
+ 'utf8'
218
+ );
219
+ }
220
+
221
+ /**
222
+ * Write final script which runs
223
+ *
224
+ * @param filename
225
+ * @param script
226
+ */
227
+ export async function writeScript(
228
+ filename: string,
229
+ script: string
230
+ ): Promise<string> {
231
+ const runner_dir: string = await getInput('RUNNER_TOOL_CACHE', false);
232
+ const script_path: string = path.join(runner_dir, filename);
233
+ fs.writeFileSync(script_path, script, {mode: 0o755});
234
+ return script_path;
235
+ }
236
+
237
+ /**
238
+ * Function to break extension csv into an array
239
+ *
240
+ * @param extension_csv
241
+ */
242
+ export async function extensionArray(
243
+ extension_csv: string
244
+ ): Promise<Array<string>> {
245
+ switch (extension_csv) {
246
+ case '':
247
+ case ' ':
248
+ return [];
249
+ default:
250
+ return extension_csv
251
+ .split(',')
252
+ .map(function (extension: string) {
253
+ return extension
254
+ .trim()
255
+ .toLowerCase()
256
+ .replace(/^php[-_]/, '');
257
+ })
258
+ .filter(Boolean);
259
+ }
260
+ }
261
+
262
+ /**
263
+ * Function to break csv into an array
264
+ *
265
+ * @param values_csv
266
+ * @constructor
267
+ */
268
+ export async function CSVArray(values_csv: string): Promise<Array<string>> {
269
+ switch (values_csv) {
270
+ case '':
271
+ case ' ':
272
+ return [];
273
+ default:
274
+ return values_csv
275
+ .split(/,(?=(?:(?:[^"']*["']){2})*[^"']*$)/)
276
+ .map(function (value) {
277
+ return value
278
+ .trim()
279
+ .replace(/^["']|["']$|(?<==)["']/g, '')
280
+ .replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'");
281
+ })
282
+ .filter(Boolean);
283
+ }
284
+ }
285
+
286
+ /**
287
+ * Function to get prefix required to load an extension.
288
+ *
289
+ * @param extension
290
+ */
291
+ export async function getExtensionPrefix(extension: string): Promise<string> {
292
+ switch (true) {
293
+ default:
294
+ return 'extension';
295
+ case /xdebug([2-3])?$|opcache|ioncube|eaccelerator/.test(extension):
296
+ return 'zend_extension';
297
+ }
298
+ }
299
+
300
+ /**
301
+ * Function to get the suffix to suppress console output
302
+ *
303
+ * @param os_version
304
+ */
305
+ export async function suppressOutput(os_version: string): Promise<string> {
306
+ switch (os_version) {
307
+ case 'win32':
308
+ return ' >$null 2>&1';
309
+ case 'linux':
310
+ case 'darwin':
311
+ return ' >/dev/null 2>&1';
312
+ default:
313
+ return await log(
314
+ 'Platform ' + os_version + ' is not supported',
315
+ os_version,
316
+ 'error'
317
+ );
318
+ }
319
+ }
package/.eslintrc.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "env": { "node": true, "jest": true },
3
- "parser": "@typescript-eslint/parser",
4
- "parserOptions": { "ecmaVersion": 2019, "sourceType": "module" },
5
- "extends": [
6
- "eslint:recommended",
7
- "plugin:@typescript-eslint/eslint-recommended",
8
- "plugin:@typescript-eslint/recommended",
9
- "plugin:import/errors",
10
- "plugin:import/warnings",
11
- "plugin:import/typescript",
12
- "plugin:prettier/recommended",
13
- "prettier"
14
- ],
15
- "plugins": ["@typescript-eslint", "jest"]
16
- }