mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Merge branch 'develop'
This commit is contained in:
commit
2484a27666
@ -24,6 +24,7 @@ const fs = __importStar(require("fs"));
|
|||||||
/*
|
/*
|
||||||
Read the scripts
|
Read the scripts
|
||||||
*/
|
*/
|
||||||
|
let os_version = process.platform;
|
||||||
let darwin = fs.readFileSync(path.join(__dirname, '../src/darwin.sh'), 'utf8');
|
let darwin = fs.readFileSync(path.join(__dirname, '../src/darwin.sh'), 'utf8');
|
||||||
let linux = fs.readFileSync(path.join(__dirname, '../src/linux.sh'), 'utf8');
|
let linux = fs.readFileSync(path.join(__dirname, '../src/linux.sh'), 'utf8');
|
||||||
let windows = fs.readFileSync(path.join(__dirname, '../src/windows.ps1'), 'utf8');
|
let windows = fs.readFileSync(path.join(__dirname, '../src/windows.ps1'), 'utf8');
|
||||||
@ -38,7 +39,7 @@ function asyncForEach(array, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Enable functions which are installed but not enabled
|
Enable extensions which are installed but not enabled
|
||||||
*/
|
*/
|
||||||
function enableExtension(extension) {
|
function enableExtension(extension) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
@ -52,10 +53,11 @@ function enableExtension(extension) {
|
|||||||
} catch [Exception] {
|
} catch [Exception] {
|
||||||
echo $_
|
echo $_
|
||||||
}\n`;
|
}\n`;
|
||||||
let shell_code = `ext_dir=$(php -i | grep "extension_dir" | sed -e "s|.*=>\s*||")
|
let shell_code = `ext_dir=$(php-config --extension-dir)
|
||||||
enabled=$(php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}")
|
enabled=$(php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}")
|
||||||
if [ "$enabled" == 'no' ] && [ test -f "$ext_dir/${extension}.so" ]; then
|
if [ "$enabled" = "no" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
||||||
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*:\s*||"'
|
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'
|
||||||
|
echo "${extension} enabled"
|
||||||
fi\n`;
|
fi\n`;
|
||||||
linux += shell_code;
|
linux += shell_code;
|
||||||
darwin += shell_code;
|
darwin += shell_code;
|
||||||
@ -79,7 +81,10 @@ function addExtension(extension_csv, version) {
|
|||||||
darwin += '\n';
|
darwin += '\n';
|
||||||
yield asyncForEach(extensions, function (extension) {
|
yield asyncForEach(extensions, function (extension) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
// add script to enable extension is already installed along with php
|
||||||
enableExtension(extension);
|
enableExtension(extension);
|
||||||
|
// else add script to attempt to install the extension
|
||||||
|
if (os_version == 'linux') {
|
||||||
linux +=
|
linux +=
|
||||||
'sudo apt install -y php' +
|
'sudo apt install -y php' +
|
||||||
version +
|
version +
|
||||||
@ -90,6 +95,9 @@ function addExtension(extension_csv, version) {
|
|||||||
'-' +
|
'-' +
|
||||||
extension +
|
extension +
|
||||||
'"\n';
|
'"\n';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// check if pecl extension exists
|
||||||
const http = new httpm.HttpClient('shivammathur/php-setup', [], {
|
const http = new httpm.HttpClient('shivammathur/php-setup', [], {
|
||||||
allowRetries: true,
|
allowRetries: true,
|
||||||
maxRetries: 2
|
maxRetries: 2
|
||||||
@ -112,6 +120,7 @@ function addExtension(extension_csv, version) {
|
|||||||
else {
|
else {
|
||||||
console.log('Cannot find pecl extension: ' + extension);
|
console.log('Cannot find pecl extension: ' + extension);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
linux += 'sudo apt autoremove -y';
|
linux += 'sudo apt autoremove -y';
|
||||||
@ -146,6 +155,7 @@ Run the script
|
|||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
|
// taking inputs
|
||||||
let version = process.env['php-version'];
|
let version = process.env['php-version'];
|
||||||
if (!version) {
|
if (!version) {
|
||||||
version = core.getInput('php-version', { required: true });
|
version = core.getInput('php-version', { required: true });
|
||||||
@ -159,7 +169,7 @@ function run() {
|
|||||||
console.log('Input: ' + extension_csv);
|
console.log('Input: ' + extension_csv);
|
||||||
yield addExtension(extension_csv, version);
|
yield addExtension(extension_csv, version);
|
||||||
}
|
}
|
||||||
let os_version = process.platform;
|
// check the os version and run the respective script
|
||||||
if (os_version == 'darwin') {
|
if (os_version == 'darwin') {
|
||||||
yield createScript('darwin.sh', version);
|
yield createScript('darwin.sh', version);
|
||||||
yield exec_1.exec('sudo chmod a+x ' + version + 'darwin.sh');
|
yield exec_1.exec('sudo chmod a+x ' + version + 'darwin.sh');
|
||||||
|
@ -7,6 +7,7 @@ import * as fs from 'fs';
|
|||||||
/*
|
/*
|
||||||
Read the scripts
|
Read the scripts
|
||||||
*/
|
*/
|
||||||
|
let os_version = process.platform;
|
||||||
let darwin = fs.readFileSync(path.join(__dirname, '../src/darwin.sh'), 'utf8');
|
let darwin = fs.readFileSync(path.join(__dirname, '../src/darwin.sh'), 'utf8');
|
||||||
let linux = fs.readFileSync(path.join(__dirname, '../src/linux.sh'), 'utf8');
|
let linux = fs.readFileSync(path.join(__dirname, '../src/linux.sh'), 'utf8');
|
||||||
let windows = fs.readFileSync(
|
let windows = fs.readFileSync(
|
||||||
@ -24,7 +25,7 @@ async function asyncForEach(array: any, callback: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Enable functions which are installed but not enabled
|
Enable extensions which are installed but not enabled
|
||||||
*/
|
*/
|
||||||
async function enableExtension(extension: string) {
|
async function enableExtension(extension: string) {
|
||||||
windows += `try {
|
windows += `try {
|
||||||
@ -38,10 +39,11 @@ async function enableExtension(extension: string) {
|
|||||||
echo $_
|
echo $_
|
||||||
}\n`;
|
}\n`;
|
||||||
|
|
||||||
let shell_code = `ext_dir=$(php -i | grep "extension_dir" | sed -e "s|.*=>\s*||")
|
let shell_code = `ext_dir=$(php-config --extension-dir)
|
||||||
enabled=$(php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}")
|
enabled=$(php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}")
|
||||||
if [ "$enabled" == 'no' ] && [ test -f "$ext_dir/${extension}.so" ]; then
|
if [ "$enabled" = "no" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
||||||
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*:\s*||"'
|
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'
|
||||||
|
echo "${extension} enabled"
|
||||||
fi\n`;
|
fi\n`;
|
||||||
linux += shell_code;
|
linux += shell_code;
|
||||||
darwin += shell_code;
|
darwin += shell_code;
|
||||||
@ -63,7 +65,11 @@ async function addExtension(extension_csv: string, version: string) {
|
|||||||
windows += '\n';
|
windows += '\n';
|
||||||
darwin += '\n';
|
darwin += '\n';
|
||||||
await asyncForEach(extensions, async function(extension: string) {
|
await asyncForEach(extensions, async function(extension: string) {
|
||||||
|
// add script to enable extension is already installed along with php
|
||||||
enableExtension(extension);
|
enableExtension(extension);
|
||||||
|
|
||||||
|
// else add script to attempt to install the extension
|
||||||
|
if (os_version == 'linux') {
|
||||||
linux +=
|
linux +=
|
||||||
'sudo apt install -y php' +
|
'sudo apt install -y php' +
|
||||||
version +
|
version +
|
||||||
@ -74,6 +80,8 @@ async function addExtension(extension_csv: string, version: string) {
|
|||||||
'-' +
|
'-' +
|
||||||
extension +
|
extension +
|
||||||
'"\n';
|
'"\n';
|
||||||
|
} else {
|
||||||
|
// check if pecl extension exists
|
||||||
const http = new httpm.HttpClient('shivammathur/php-setup', [], {
|
const http = new httpm.HttpClient('shivammathur/php-setup', [], {
|
||||||
allowRetries: true,
|
allowRetries: true,
|
||||||
maxRetries: 2
|
maxRetries: 2
|
||||||
@ -97,6 +105,7 @@ async function addExtension(extension_csv: string, version: string) {
|
|||||||
} else {
|
} else {
|
||||||
console.log('Cannot find pecl extension: ' + extension);
|
console.log('Cannot find pecl extension: ' + extension);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
linux += 'sudo apt autoremove -y';
|
linux += 'sudo apt autoremove -y';
|
||||||
}
|
}
|
||||||
@ -117,7 +126,6 @@ async function createScript(filename: string, version: string) {
|
|||||||
if (error) {
|
if (error) {
|
||||||
return console.log(error);
|
return console.log(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('The file was saved!');
|
console.log('The file was saved!');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -127,6 +135,7 @@ Run the script
|
|||||||
*/
|
*/
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
|
// taking inputs
|
||||||
let version = process.env['php-version'];
|
let version = process.env['php-version'];
|
||||||
if (!version) {
|
if (!version) {
|
||||||
version = core.getInput('php-version', {required: true});
|
version = core.getInput('php-version', {required: true});
|
||||||
@ -142,7 +151,7 @@ async function run() {
|
|||||||
await addExtension(extension_csv, version);
|
await addExtension(extension_csv, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
let os_version = process.platform;
|
// check the os version and run the respective script
|
||||||
if (os_version == 'darwin') {
|
if (os_version == 'darwin') {
|
||||||
await createScript('darwin.sh', version);
|
await createScript('darwin.sh', version);
|
||||||
await exec('sudo chmod a+x ' + version + 'darwin.sh');
|
await exec('sudo chmod a+x ' + version + 'darwin.sh');
|
||||||
|
Loading…
Reference in New Issue
Block a user