This commit introduces a mechanism to use the setup-php scripts for configuring PHP environments on local Linux/Ubuntu machines. Key changes: - Added `src/local_installer.ts`: A Node.js script that takes command-line arguments to define the desired PHP setup (version, extensions, tools, INI settings) and generates a `run.sh` script. - Added `src/local_utils.ts`: A utility module with functions adapted for local execution, removing dependencies on `@actions/core`. It supports fetching inputs from yargs/environment variables. - Modified `src/fetch.ts`: Replaced `@actions/http-client` with `node-fetch` for compatibility. - Updated `src/config.ts`, `src/coverage.ts`, `src/extensions.ts`, and `src/tools.ts` to import utilities from `local_utils.ts` instead of `utils.ts`. - Added `LOCAL_SETUP_INSTRUCTIONS.md`: Comprehensive documentation on prerequisites, how to run the local installer, command-line options, and troubleshooting. This allows users to leverage the robust PHP environment configuration capabilities of this project directly on their development machines.
83 lines
2.0 KiB
TypeScript
83 lines
2.0 KiB
TypeScript
import * as utils from './local_utils';
|
|
|
|
/**
|
|
* Add script to set custom ini values for unix
|
|
*
|
|
* @param ini_values_csv
|
|
*/
|
|
export async function addINIValuesUnix(
|
|
ini_values_csv: string
|
|
): Promise<string> {
|
|
const ini_values: Array<string> = await utils.CSVArray(ini_values_csv);
|
|
let script = '';
|
|
await utils.asyncForEach(ini_values, async function (line: string) {
|
|
script +=
|
|
'\n' + (await utils.addLog('$tick', line, 'Added to php.ini', 'linux'));
|
|
});
|
|
return (
|
|
'echo "' +
|
|
ini_values.join('\n') +
|
|
'" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1' +
|
|
script
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Add script to set custom ini values for windows
|
|
*
|
|
* @param ini_values_csv
|
|
*/
|
|
export async function addINIValuesWindows(
|
|
ini_values_csv: string
|
|
): Promise<string> {
|
|
const ini_values: Array<string> = await utils.CSVArray(ini_values_csv);
|
|
let script = '\n';
|
|
await utils.asyncForEach(ini_values, async function (line: string) {
|
|
script +=
|
|
(await utils.addLog('$tick', line, 'Added to php.ini', 'win32')) + '\n';
|
|
});
|
|
return (
|
|
'Add-Content "$php_dir\\php.ini" "' + ini_values.join('\n') + '"' + script
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Function to add custom ini values
|
|
*
|
|
* @param ini_values_csv
|
|
* @param os
|
|
* @param no_step
|
|
*/
|
|
export async function addINIValues(
|
|
ini_values_csv: string,
|
|
os: string,
|
|
no_step = false
|
|
): Promise<string> {
|
|
let script = '\n';
|
|
switch (no_step) {
|
|
case true:
|
|
script +=
|
|
(await utils.stepLog('Add php.ini values', os)) +
|
|
(await utils.suppressOutput(os)) +
|
|
'\n';
|
|
break;
|
|
case false:
|
|
default:
|
|
script += (await utils.stepLog('Add php.ini values', os)) + '\n';
|
|
break;
|
|
}
|
|
switch (os) {
|
|
case 'win32':
|
|
return script + (await addINIValuesWindows(ini_values_csv));
|
|
case 'darwin':
|
|
case 'linux':
|
|
return script + (await addINIValuesUnix(ini_values_csv));
|
|
default:
|
|
return await utils.log(
|
|
'Platform ' + os + ' is not supported',
|
|
os,
|
|
'error'
|
|
);
|
|
}
|
|
}
|