Compare commits

..
2 Commits
Author SHA1 Message Date
Shivam Mathur 0585c3d59d Merge pull request #199 from shivammathur/develop
2.1.1
2020-03-08 08:39:56 +05:30
Shivam Mathur 7e62bc926b Bump version to 1.0.3 2020-03-08 08:14:57 +05:30
23 changed files with 1744 additions and 1942 deletions
+2 -1
View File
@@ -17,6 +17,7 @@
"camelcase": "off", "camelcase": "off",
"require-atomic-updates": "off", "require-atomic-updates": "off",
"@typescript-eslint/ban-ts-ignore": "off", "@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/camelcase": "off" "@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-unused-vars": "off"
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
# These are supported funding model platforms # These are supported funding model platforms
tidelift: "npm/setup-php" github: shivammathur
community_bridge: setup-php community_bridge: setup-php
issuehunt: shivammathur issuehunt: shivammathur
patreon: shivammathur patreon: shivammathur
-30
View File
@@ -1,30 +0,0 @@
# Security Policy
## Supported Versions
The following versions of this project are supported for security updates.
| Version | Supported |
| ------- | ------------------ |
| 1.8.x | :white_check_mark: |
| 2.1.x | :white_check_mark: |
## Supported PHP Versions
This security policy only applies to the latest patches of the following PHP versions.
| Version | Supported |
| ------- | ------------------ |
| 7.2 | :white_check_mark: |
| 7.3 | :white_check_mark: |
| 7.4 | :white_check_mark: |
| 8.0 | :white_check_mark: |
## Reporting a Vulnerability
If you have found any issues that might have security implications in the versions supported, please send a report privately to [contact@shivammathur.com](mailto:contact@shivammathur.com)
Do not report security reports publicly.
## Tidelift
If you use this GitHub Action through a Tidelift subscription, please refer to [https://tidelift.com/security](https://tidelift.com/security).
+1 -1
View File
@@ -28,7 +28,7 @@ jobs:
operating-system: [ubuntu-latest, windows-latest, macos-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['8.0'] php-versions: ['8.0']
env: env:
extensions: xml, opcache, pcov extensions: xml, opcache, xdebug, pcov
key: cache-v2 key: cache-v2
steps: steps:
- name: Checkout - name: Checkout
+2 -16
View File
@@ -29,14 +29,13 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
- [Inputs](#inputs) - [Inputs](#inputs)
- [Basic Setup](#basic-setup) - [Basic Setup](#basic-setup)
- [Matrix Setup](#matrix-setup) - [Matrix Setup](#matrix-setup)
- [Experimental Setup](#experimental-setup) - [Experimental Setup](#experimental-setup)
- [Thread Safe Setup](#thread-safe-setup) - [Thread Safe Setup](#thread-safe-setup)
- [Force Update](#force-update) - [Force Update](#force-update)
- [Verbose Setup](#verbose-setup) - [Verbose Setup](#verbose-setup)
- [Cache Extensions](#cache-extensions) - [Cache Extensions](#cache-extensions)
- [Cache Composer Dependencies](#cache-composer-dependencies) - [Cache Composer Dependencies](#cache-composer-dependencies)
- [Cache Node.js Dependencies](#cache-nodejs-dependencies) - [Cache Node.js Dependencies](#cache-nodejs-dependencies)
- [Composer GitHub OAuth](#composer-github-oauth)
- [Problem Matchers](#problem-matchers) - [Problem Matchers](#problem-matchers)
- [Examples](#examples) - [Examples](#examples)
- [License](#scroll-license) - [License](#scroll-license)
@@ -69,7 +68,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|Windows Server 2019|`windows-latest` or `windows-2019`| |Windows Server 2019|`windows-latest` or `windows-2019`|
|Ubuntu 18.04|`ubuntu-latest` or `ubuntu-18.04`| |Ubuntu 18.04|`ubuntu-latest` or `ubuntu-18.04`|
|Ubuntu 16.04|`ubuntu-16.04`| |Ubuntu 16.04|`ubuntu-16.04`|
|macOS X Catalina 10.15|`macos-latest` or `macos-10.15`| |macOS X Catalina 10.15|`macos-latest` or `macOS-10.15`|
## :heavy_plus_sign: PHP Extension Support ## :heavy_plus_sign: PHP Extension Support
- On `ubuntu` by default extensions which are available as a package can be installed. PECL extensions if not available as a package can be installed by specifying `pecl` in the tools input. - On `ubuntu` by default extensions which are available as a package can be installed. PECL extensions if not available as a package can be installed by specifying `pecl` in the tools input.
@@ -431,19 +430,6 @@ If your project has node.js dependencies, you can persist npm's or yarn's cache
**Note:** Please do not cache `node_modules` directory as that will have side-effects. **Note:** Please do not cache `node_modules` directory as that will have side-effects.
### Composer GitHub OAuth
If you have a number of workflows which setup multiple tools or have many composer dependencies, you might hit the GitHub's rate limit for composer. To avoid that you can add a `OAuth` token to the composer's config by setting `COMPOSER_TOKEN` environment variable. You can use [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token "GITHUB_TOKEN documentation") secret for this purpose.
```yaml
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
### Problem Matchers ### Problem Matchers
#### PHP #### PHP
+4 -24
View File
@@ -3,31 +3,17 @@ import * as extensions from '../src/extensions';
describe('Extension tests', () => { describe('Extension tests', () => {
it('checking addExtensionOnWindows', async () => { it('checking addExtensionOnWindows', async () => {
let win32: string = await extensions.addExtension( let win32: string = await extensions.addExtension(
'Xdebug, pcov, sqlite, phalcon4, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2', 'xdebug, pcov, phalcon4, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2',
'7.4', '7.4',
'win32' 'win32'
); );
expect(win32).toContain('Add-Extension xdebug'); expect(win32).toContain('Add-Extension xdebug');
expect(win32).toContain('Add-Extension pcov'); expect(win32).toContain('Add-Extension pcov');
expect(win32).toContain('Add-Extension sqlite3');
expect(win32).toContain('phalcon.ps1 phalcon4'); expect(win32).toContain('phalcon.ps1 phalcon4');
expect(win32).toContain('Add-Extension ast beta'); expect(win32).toContain('Add-Extension ast beta');
expect(win32).toContain('Add-Extension grpc stable 1.2.3'); expect(win32).toContain('Add-Extension grpc stable 1.2.3');
expect(win32).toContain('Add-Extension inotify alpha 1.2.3'); expect(win32).toContain('Add-Extension inotify alpha 1.2.3');
win32 = await extensions.addExtension('mysql', '7.4', 'win32');
expect(win32).toContain('Add-Extension mysqli');
expect(win32).toContain('Add-Extension mysqlnd');
win32 = await extensions.addExtension('mysql', '8.0', 'win32');
expect(win32).toContain('Add-Extension mysqli');
expect(win32).toContain('Add-Extension mysqlnd');
win32 = await extensions.addExtension('mysql', '5.5', 'win32');
expect(win32).toContain('Add-Extension mysql');
expect(win32).toContain('Add-Extension mysqli');
expect(win32).toContain('Add-Extension mysqlnd');
win32 = await extensions.addExtension( win32 = await extensions.addExtension(
'phalcon3, does_not_exist', 'phalcon3, does_not_exist',
'7.2', '7.2',
@@ -49,17 +35,12 @@ describe('Extension tests', () => {
it('checking addExtensionOnLinux', async () => { it('checking addExtensionOnLinux', async () => {
let linux: string = await extensions.addExtension( let linux: string = await extensions.addExtension(
'Xdebug, pcov, sqlite, ast, uopz, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3', 'xdebug, pcov, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
'7.4', '7.4',
'linux' 'linux'
); );
expect(linux).toContain('update_extension xdebug 2.9.3'); expect(linux).toContain('update_extension xdebug 2.9.1');
expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-pcov'); expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-pcov');
expect(linux).toContain(
'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
);
expect(linux).toContain('sudo $debconf_fix apt-get install -y php-ast');
expect(linux).toContain('sudo $debconf_fix apt-get install -y php-uopz');
expect(linux).toContain('add_unstable_extension ast beta extension'); expect(linux).toContain('add_unstable_extension ast beta extension');
expect(linux).toContain('add_pdo_extension mysql'); expect(linux).toContain('add_pdo_extension mysql');
expect(linux).toContain('add_pdo_extension odbc'); expect(linux).toContain('add_pdo_extension odbc');
@@ -98,13 +79,12 @@ describe('Extension tests', () => {
it('checking addExtensionOnDarwin', async () => { it('checking addExtensionOnDarwin', async () => {
let darwin: string = await extensions.addExtension( let darwin: string = await extensions.addExtension(
'Xdebug, pcov, sqlite, ast-beta, grpc-1.2.3', 'xdebug, pcov, ast-beta, grpc-1.2.3',
'7.2', '7.2',
'darwin' 'darwin'
); );
expect(darwin).toContain('sudo pecl install -f xdebug'); expect(darwin).toContain('sudo pecl install -f xdebug');
expect(darwin).toContain('sudo pecl install -f pcov'); expect(darwin).toContain('sudo pecl install -f pcov');
expect(darwin).toContain('sudo pecl install -f sqlite3');
expect(darwin).toContain('add_unstable_extension ast beta extension'); expect(darwin).toContain('add_unstable_extension ast beta extension');
expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension'); expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension');
+10
View File
@@ -1,6 +1,16 @@
import * as io from '@actions/io'; import * as io from '@actions/io';
import * as path from 'path';
import * as fs from 'fs';
import * as matchers from '../src/matchers'; import * as matchers from '../src/matchers';
async function cleanup(path: string): Promise<void> {
fs.unlink(path, error => {
if (error) {
console.log(error);
}
});
}
jest.mock('@actions/io'); jest.mock('@actions/io');
describe('Matchers', () => { describe('Matchers', () => {
+6 -6
View File
@@ -55,12 +55,12 @@ describe('Utils tests', () => {
path.join(__dirname, '../src/scripts/win32.ps1'), path.join(__dirname, '../src/scripts/win32.ps1'),
'utf8' 'utf8'
); );
expect(await utils.readScript('darwin.sh')).toBe(darwin); expect(await utils.readScript('darwin.sh', '7.4', 'darwin')).toBe(darwin);
expect(await utils.readScript('darwin.sh')).toBe(darwin); expect(await utils.readScript('darwin.sh', '7.3', 'darwin')).toBe(darwin);
expect(await utils.readScript('linux.sh')).toBe(linux); expect(await utils.readScript('linux.sh', '7.4', 'linux')).toBe(linux);
expect(await utils.readScript('linux.sh')).toBe(linux); expect(await utils.readScript('linux.sh', '7.3', 'linux')).toBe(linux);
expect(await utils.readScript('win32.ps1')).toBe(win32); expect(await utils.readScript('win32.ps1', '7.4', 'win32')).toBe(win32);
expect(await utils.readScript('win32.ps1')).toBe(win32); expect(await utils.readScript('win32.ps1', '7.3', 'win32')).toBe(win32);
}); });
it('checking writeScripts', async () => { it('checking writeScripts', async () => {
+998 -896
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -9,4 +9,4 @@ module.exports = {
}, },
verbose: true, verbose: true,
collectCoverage: true collectCoverage: true
}; };
+605 -775
View File
File diff suppressed because it is too large Load Diff
+11 -11
View File
@@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "2.1.4", "version": "2.1.1",
"private": false, "private": false,
"description": "Setup PHP for use with GitHub Actions", "description": "Setup PHP for use with GitHub Actions",
"main": "dist/index.js", "main": "dist/index.js",
@@ -30,21 +30,21 @@
"fs": "0.0.1-security" "fs": "0.0.1-security"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^25.2.1", "@types/jest": "^25.1.4",
"@types/node": "^13.11.1", "@types/node": "^13.9.0",
"@typescript-eslint/eslint-plugin": "^2.27.0", "@typescript-eslint/eslint-plugin": "^2.22.0",
"@typescript-eslint/parser": "^2.27.0", "@typescript-eslint/parser": "^2.22.0",
"@zeit/ncc": "^0.22.1", "@zeit/ncc": "^0.21.1",
"eslint": "^6.8.0", "eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1", "eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.20.2", "eslint-plugin-import": "^2.20.1",
"eslint-plugin-jest": "^23.8.2", "eslint-plugin-jest": "^23.8.2",
"eslint-plugin-prettier": "^3.1.2", "eslint-plugin-prettier": "^3.1.2",
"husky": "^4.2.3", "husky": "^4.2.3",
"jest": "^25.3.0", "jest": "^25.1.0",
"jest-circus": "^25.3.0", "jest-circus": "^25.1.0",
"prettier": "^1.19.1", "prettier": "^1.19.1",
"ts-jest": "^25.3.1", "ts-jest": "^25.2.1",
"typescript": "^3.8.3" "typescript": "^3.8.3"
}, },
"husky": { "husky": {
Binary file not shown.
Binary file not shown.
-1
View File
@@ -44,7 +44,6 @@ export async function addINIValuesWindows(
* *
* @param ini_values_csv * @param ini_values_csv
* @param os_version * @param os_version
* @param no_step
*/ */
export async function addINIValues( export async function addINIValues(
ini_values_csv: string, ini_values_csv: string,
+55 -93
View File
@@ -16,18 +16,18 @@ export async function addExtensionDarwin(
const extensions: Array<string> = await utils.extensionArray(extension_csv); const extensions: Array<string> = await utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
await utils.asyncForEach(extensions, async function(extension: string) { await utils.asyncForEach(extensions, async function(extension: string) {
extension = extension.toLowerCase();
const version_extension: string = version + extension; const version_extension: string = version + extension;
const [ext_name, ext_version]: string[] = extension.split('-'); const [ext_name, ext_version]: string[] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(ext_name); const prefix = await utils.getExtensionPrefix(ext_name);
const command_prefix = 'sudo pecl install -f '; let install_command = '';
let command = '';
switch (true) { switch (true) {
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
command = install_command =
'bash ' + 'bash ' +
path.join(__dirname, '../src/scripts/ext/blackfire_darwin.sh') + path.join(__dirname, '../src/scripts/ext/blackfire_darwin.sh') +
' ' + ' ' +
@@ -35,7 +35,7 @@ export async function addExtensionDarwin(
' ' + ' ' +
(await utils.getBlackfireVersion(ext_version)); (await utils.getBlackfireVersion(ext_version));
break; break;
// match pre-release versions. For example - xdebug-beta // match pre-release versions
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += script +=
'\nadd_unstable_extension ' + '\nadd_unstable_extension ' +
@@ -43,54 +43,35 @@ export async function addExtensionDarwin(
' ' + ' ' +
ext_version + ext_version +
' ' + ' ' +
ext_prefix; prefix;
return; return;
// match semver // match exact versions
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
script += script +=
'\nadd_pecl_extension ' + '\nadd_pecl_extension ' + ext_name + ' ' + ext_version + ' ' + prefix;
ext_name +
' ' +
ext_version +
' ' +
ext_prefix;
return; return;
// match 5.3xdebug
case /5\.3xdebug/.test(version_extension): case /5\.3xdebug/.test(version_extension):
command = command_prefix + 'xdebug-2.2.7' + pipe; install_command = 'sudo pecl install -f xdebug-2.2.7' + pipe;
break; break;
// match 5.4xdebug
case /5\.4xdebug/.test(version_extension): case /5\.4xdebug/.test(version_extension):
command = command_prefix + 'xdebug-2.4.1' + pipe; install_command = 'sudo pecl install -f xdebug-2.4.1' + pipe;
break; break;
// match 5.5xdebug and 5.6xdebug
case /5\.[5-6]xdebug/.test(version_extension): case /5\.[5-6]xdebug/.test(version_extension):
command = command_prefix + 'xdebug-2.5.5' + pipe; install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
break; break;
// match 7.0redis
case /7\.0xdebug/.test(version_extension): case /7\.0xdebug/.test(version_extension):
command = command_prefix + 'xdebug-2.9.0' + pipe; install_command = 'sudo pecl install -f xdebug-2.9.0' + pipe;
break; break;
// match 5.6redis
case /5\.6redis/.test(version_extension): case /5\.6redis/.test(version_extension):
command = command_prefix + 'redis-2.2.8' + pipe; install_command = 'sudo pecl install -f redis-2.2.8' + pipe;
break; break;
// match imagick case /[5-9]\.\dimagick/.test(version_extension):
case /^imagick$/.test(extension): install_command =
command =
'brew install pkg-config imagemagick' + 'brew install pkg-config imagemagick' +
pipe + pipe +
' && ' + ' && sudo pecl install -f imagick' +
command_prefix +
'imagick' +
pipe; pipe;
break; break;
// match sqlite
case /^sqlite$/.test(extension):
extension = 'sqlite3';
command = command_prefix + extension + pipe;
break;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script += script +=
'sh ' + 'sh ' +
@@ -101,11 +82,16 @@ export async function addExtensionDarwin(
version; version;
return; return;
default: default:
command = command_prefix + extension + pipe; install_command = 'sudo pecl install -f ' + extension + pipe;
break; break;
} }
script += script +=
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix; '\nadd_extension ' +
extension +
' "' +
install_command +
'" ' +
(await utils.getExtensionPrefix(extension));
}); });
return script; return script;
} }
@@ -115,14 +101,17 @@ export async function addExtensionDarwin(
* *
* @param extension_csv * @param extension_csv
* @param version * @param version
* @param pipe
*/ */
export async function addExtensionWindows( export async function addExtensionWindows(
extension_csv: string, extension_csv: string,
version: string version: string,
pipe: string
): Promise<string> { ): Promise<string> {
const extensions: Array<string> = await utils.extensionArray(extension_csv); const extensions: Array<string> = await utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
await utils.asyncForEach(extensions, async function(extension: string) { await utils.asyncForEach(extensions, async function(extension: string) {
extension = extension.toLowerCase();
const [ext_name, ext_version]: string[] = extension.split('-'); const [ext_name, ext_version]: string[] = extension.split('-');
const version_extension: string = version + extension; const version_extension: string = version + extension;
let matches: RegExpExecArray; let matches: RegExpExecArray;
@@ -140,42 +129,23 @@ export async function addExtensionWindows(
' ' + ' ' +
(await utils.getBlackfireVersion(ext_version)); (await utils.getBlackfireVersion(ext_version));
return; return;
// match pre-release versions. For example - xdebug-beta // match pre-release versions
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += '\nAdd-Extension ' + ext_name + ' ' + ext_version; script += '\nAdd-Extension ' + ext_name + ' ' + ext_version;
break; break;
// match semver without state // match exact versions
case /.*-\d+\.\d+\.\d+$/.test(version_extension): case /.*-\d+\.\d+\.\d+$/.test(version_extension):
script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version; script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version;
return; return;
// match semver with state case /.*-(\d+\.\d+\.\d)+(beta|alpha|devel|snapshot)\d*/.test(
case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test(
version_extension version_extension
): ):
matches = /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.exec( matches = /.*-(\d+\.\d+\.\d)+(beta|alpha|devel|snapshot)\d*/.exec(
version_extension version_extension
) as RegExpExecArray; ) as RegExpExecArray;
script += script +=
'\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1]; '\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1];
return; return;
// match 5.3mysql..5.6mysql
// match 5.3mysqli..5.6mysqli
// match 5.3mysqlnd..5.6mysqlnd
case /^5\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
script +=
'\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
break;
// match 7.0mysql..8.0mysql
// match 7.0mysqli..8.0mysqli
// match 7.0mysqlnd..8.0mysqlnd
case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
break;
// match sqlite
case /^sqlite$/.test(extension):
extension = 'sqlite3';
script += '\nAdd-Extension ' + extension;
break;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script += script +=
@@ -210,18 +180,18 @@ export async function addExtensionLinux(
const extensions: Array<string> = await utils.extensionArray(extension_csv); const extensions: Array<string> = await utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
await utils.asyncForEach(extensions, async function(extension: string) { await utils.asyncForEach(extensions, async function(extension: string) {
extension = extension.toLowerCase();
const version_extension: string = version + extension; const version_extension: string = version + extension;
const [ext_name, ext_version]: string[] = extension.split('-'); const [ext_name, ext_version]: string[] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(ext_name); const prefix = await utils.getExtensionPrefix(ext_name);
const command_prefix = 'sudo $debconf_fix apt-get install -y php'; let install_command = '';
let command = '';
switch (true) { switch (true) {
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
command = install_command =
'bash ' + 'bash ' +
path.join(__dirname, '../src/scripts/ext/blackfire.sh') + path.join(__dirname, '../src/scripts/ext/blackfire.sh') +
' ' + ' ' +
@@ -229,7 +199,7 @@ export async function addExtensionLinux(
' ' + ' ' +
(await utils.getBlackfireVersion(ext_version)); (await utils.getBlackfireVersion(ext_version));
break; break;
// match pre-release versions. For example - xdebug-beta // match pre-release versions
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += script +=
'\nadd_unstable_extension ' + '\nadd_unstable_extension ' +
@@ -237,21 +207,16 @@ export async function addExtensionLinux(
' ' + ' ' +
ext_version + ext_version +
' ' + ' ' +
ext_prefix; prefix;
return; return;
// match semver versions // match exact versions
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
script += script +=
'\nadd_pecl_extension ' + '\nadd_pecl_extension ' + ext_name + ' ' + ext_version + ' ' + prefix;
ext_name +
' ' +
ext_version +
' ' +
ext_prefix;
return; return;
// match 5.6gearman..7.4gearman // match 5.6gearman..7.4gearman
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
command = install_command =
'sh ' + 'sh ' +
path.join(__dirname, '../src/scripts/ext/gearman.sh') + path.join(__dirname, '../src/scripts/ext/gearman.sh') +
' ' + ' ' +
@@ -268,34 +233,31 @@ export async function addExtensionLinux(
' ' + ' ' +
version; version;
return; return;
// match 7.1xdebug..7.4xdebug // match 7.0xdebug..7.4xdebug
case /^7\.[1-4]xdebug$/.test(version_extension): case /^7\.[0-4]xdebug$/.test(version_extension):
script += script +=
'\nupdate_extension xdebug 2.9.3' + '\nupdate_extension xdebug 2.9.1' +
pipe + pipe +
'\n' + '\n' +
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux')); (await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
return; return;
// match pdo extensions // match pdo extensions
case /.*pdo[_-].*/.test(version_extension): case /.*pdo[_-].*/.test(version_extension):
extension = extension.replace('pdo_', '').replace('pdo-', ''); script +=
script += '\nadd_pdo_extension ' + extension; '\nadd_pdo_extension ' +
extension.replace('pdo_', '').replace('pdo-', '');
return; return;
// match ast and uopz
case /^(ast|uopz)$/.test(extension):
command = command_prefix + '-' + extension + pipe;
break;
// match sqlite
case /^sqlite$/.test(extension):
extension = 'sqlite3';
command = command_prefix + version + '-' + extension + pipe;
break;
default: default:
command = command_prefix + version + '-' + extension + pipe; install_command =
'sudo $debconf_fix apt-get install -y php' +
version +
'-' +
extension +
pipe;
break; break;
} }
script += script +=
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix; '\nadd_extension ' + extension + ' "' + install_command + '" ' + prefix;
}); });
return script; return script;
} }
@@ -306,7 +268,7 @@ export async function addExtensionLinux(
* @param extension_csv * @param extension_csv
* @param version * @param version
* @param os_version * @param os_version
* @param no_step * @param log_prefix
*/ */
export async function addExtension( export async function addExtension(
extension_csv: string, extension_csv: string,
@@ -328,7 +290,7 @@ export async function addExtension(
switch (os_version) { switch (os_version) {
case 'win32': case 'win32':
return script + (await addExtensionWindows(extension_csv, version)); return script + (await addExtensionWindows(extension_csv, version, pipe));
case 'darwin': case 'darwin':
return script + (await addExtensionDarwin(extension_csv, version, pipe)); return script + (await addExtensionDarwin(extension_csv, version, pipe));
case 'linux': case 'linux':
+1 -1
View File
@@ -35,7 +35,7 @@ export async function build(
tools_csv = 'pecl, ' + tools_csv; tools_csv = 'pecl, ' + tools_csv;
} }
let script: string = await utils.readScript(filename); let script: string = await utils.readScript(filename, version, os_version);
script += await tools.addTools(tools_csv, version, os_version); script += await tools.addTools(tools_csv, version, os_version);
if (extension_csv) { if (extension_csv) {
+7 -30
View File
@@ -27,11 +27,7 @@ remove_extension() {
# Function to test if extension is loaded # Function to test if extension is loaded
check_extension() { check_extension() {
extension=$1 extension=$1
if [ "$extension" != "mysql" ]; then php -m | grep -i -q -w "$extension"
php -m | grep -i -q -w "$extension"
else
php -m | grep -i -q "$extension"
fi
} }
# Fuction to get the PECL version # Fuction to get the PECL version
@@ -108,9 +104,6 @@ add_tool() {
sudo chmod a+x "$tool_path" sudo chmod a+x "$tool_path"
if [ "$tool" = "composer" ]; then if [ "$tool" = "composer" ]; then
composer -q global config process-timeout 0 composer -q global config process-timeout 0
if [ -n "$COMPOSER_TOKEN" ]; then
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
fi
elif [ "$tool" = "phive" ]; then elif [ "$tool" = "phive" ]; then
add_extension curl "sudo pecl install -f curl" extension >/dev/null 2>&1 add_extension curl "sudo pecl install -f curl" extension >/dev/null 2>&1
add_extension mbstring "sudo pecl install -f mbstring" extension >/dev/null 2>&1 add_extension mbstring "sudo pecl install -f mbstring" extension >/dev/null 2>&1
@@ -165,29 +158,13 @@ add_pecl() {
add_log "$tick" "PECL" "Added" add_log "$tick" "PECL" "Added"
} }
# Function to fetch updated formulas
update_formulae() {
brew_dir=$(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
for formula in httpd pkg-config apr apr-util argon2 aspell autoconf bison curl-openssl freetds freetype gettext glib gmp icu4c jpeg krb5 libffi libpng libpq libsodium libzip oniguruma openldap openssl@1.1 re2c sqlite tidyp unixodbc webp; do
sudo curl -o "$brew_dir"/"$formula".rb -sSL https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/"$formula".rb &
to_wait+=( $! )
done
wait "${to_wait[@]}"
}
# Function to setup PHP >=5.6 # Function to setup PHP >=5.6
setup_php() { setup_php() {
action=$1 action=$1
if [ "$version" = "8.0" ]; then export HOMEBREW_NO_INSTALL_CLEANUP=TRUE >/dev/null 2>&1
update_formulae brew tap shivammathur/homebrew-php >/dev/null 2>&1
fi brew "$action" shivammathur/php/php@"$version" >/dev/null 2>&1
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE brew link --force --overwrite php@"$version" >/dev/null 2>&1
brew tap shivammathur/homebrew-php
if [ "$version" = "5.6" ] || [ "$version" = "7.0" ]; then
brew install https://raw.githubusercontent.com/shivammathur/homebrew-php/master/Formula/icu4c.rb --force
fi
brew "$action" shivammathur/php/php@"$version"
brew link --force --overwrite php@"$version"
} }
# Variables # Variables
@@ -206,10 +183,10 @@ if [[ "$version" =~ $old_versions ]]; then
curl -sSL https://github.com/shivammathur/php5-darwin/releases/latest/download/install.sh | bash -s "$nodot_version" >/dev/null 2>&1 && curl -sSL https://github.com/shivammathur/php5-darwin/releases/latest/download/install.sh | bash -s "$nodot_version" >/dev/null 2>&1 &&
status="Installed" status="Installed"
elif [ "$existing_version" != "$version" ]; then elif [ "$existing_version" != "$version" ]; then
setup_php "install" >/dev/null 2>&1 setup_php "install"
status="Installed" status="Installed"
elif [ "$existing_version" = "$version" ] && [ "$update" = "true" ]; then elif [ "$existing_version" = "$version" ] && [ "$update" = "true" ]; then
setup_php "upgrade" >/dev/null 2>&1 setup_php "upgrade"
status="Updated to" status="Updated to"
else else
status="Found" status="Found"
+24 -25
View File
@@ -19,7 +19,12 @@ add_log() {
# Function to update php ppa # Function to update php ppa
update_ppa() { update_ppa() {
if [ "$ppa_updated" = "false" ]; then if [ "$ppa_updated" = "false" ]; then
sudo "$debconf_fix" apt-get update >/dev/null 2>&1 if [[ "$version" =~ $old_versions ]]; then
ppa="dotdeb-ubuntu-php*.list"
else
ppa="ondrej-ubuntu-php*.list"
fi
find /etc/apt/sources.list.d -type f -name "$ppa" -exec sudo "$debconf_fix" apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
ppa_updated="true" ppa_updated="true"
fi fi
} }
@@ -27,9 +32,8 @@ update_ppa() {
# Function to configure PECL # Function to configure PECL
configure_pecl() { configure_pecl() {
if [ "$pecl_config" = "false" ] && [ -e /usr/bin/pecl ]; then if [ "$pecl_config" = "false" ] && [ -e /usr/bin/pecl ]; then
sudo touch "$scan_dir"/99-pecl.ini >/dev/null 2>&1
for tool in pear pecl; do for tool in pear pecl; do
sudo "$tool" config-set php_ini "$scan_dir"/99-pecl.ini >/dev/null 2>&1 sudo "$tool" config-set php_ini "$ini_file" >/dev/null 2>&1
sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1 sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1
sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1 sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1
done done
@@ -52,12 +56,7 @@ get_pecl_version() {
# Function to test if extension is loaded # Function to test if extension is loaded
check_extension() { check_extension() {
extension=$1 php -m | grep -i -q -w "$1"
if [ "$extension" != "mysql" ]; then
php -m | grep -i -q -w "$extension"
else
php -m | grep -i -q "$extension"
fi
} }
# Function to delete extensions # Function to delete extensions
@@ -182,9 +181,6 @@ add_tool() {
sudo chmod a+x "$tool_path" sudo chmod a+x "$tool_path"
if [ "$tool" = "composer" ]; then if [ "$tool" = "composer" ]; then
composer -q global config process-timeout 0 composer -q global config process-timeout 0
if [ -n "$COMPOSER_TOKEN" ]; then
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
fi
elif [ "$tool" = "cs2pr" ]; then elif [ "$tool" = "cs2pr" ]; then
sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path" sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path"
elif [ "$tool" = "phive" ]; then elif [ "$tool" = "phive" ]; then
@@ -238,26 +234,29 @@ add_blackfire() {
# Function to setup the nightly build from master branch # Function to setup the nightly build from master branch
setup_master() { setup_master() {
update_ppa && $apt_install libzip-dev
tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz
install_dir=~/php/"$version" install_dir=~/php/"$version"
bintray_url=https://dl.bintray.com/shivammathur/php/"$tar_file"
sudo mkdir -m 777 -p ~/php sudo mkdir -m 777 -p ~/php
curl -o /tmp/"$tar_file" -sSL "$bintray_url" update_ppa && $apt_install libicu-dev >/dev/null 2>&1
sudo tar xf /tmp/"$tar_file" -C ~/php curl -SLO https://dl.bintray.com/shivammathur/php/"$tar_file" >/dev/null 2>&1
sudo tar xf "$tar_file" -C ~/php >/dev/null 2>&1
rm -rf "$tar_file"
sudo ln -sf -S "$version" "$install_dir"/bin/* /usr/bin/ sudo ln -sf -S "$version" "$install_dir"/bin/* /usr/bin/
sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini
} }
# Function to setup PHP 5.3, PHP 5.4 and PHP 5.5 # Function to setup PHP 5.3, PHP 5.4 and PHP 5.5
setup_old_versions() { setup_old_versions() {
dir=php-"$version" (
tar_file="$dir".tar.xz cd /tmp || exit
bintray_url=https://dl.bintray.com/shivammathur/php/"$tar_file" curl -SLO https://dl.bintray.com/shivammathur/php/php-"$version".tar.xz >/dev/null 2>&1
curl -o /tmp/"$tar_file" -sSL "$bintray_url" sudo tar xf php-"$version".tar.xz >/dev/null 2>&1
sudo tar xf /tmp/"$tar_file" -C /tmp cd php-"$version" || exit
sudo chmod a+x /tmp/"$dir"/*.sh sudo chmod a+x ./*.sh
(cd /tmp/"$dir" && ./install.sh && ./post-install.sh) ./install.sh >/dev/null 2>&1
./post-install.sh >/dev/null 2>&1
)
sudo rm -rf /tmp/php-"$version"
configure_pecl configure_pecl
release_version=$(php -v | head -n 1 | cut -d' ' -f 2) release_version=$(php -v | head -n 1 | cut -d' ' -f 2)
} }
@@ -323,9 +322,9 @@ sudo mkdir -p /var/run /run/php
if [ "$existing_version" != "$version" ]; then if [ "$existing_version" != "$version" ]; then
if [ ! -e "/usr/bin/php$version" ]; then if [ ! -e "/usr/bin/php$version" ]; then
if [ "$version" = "8.0" ]; then if [ "$version" = "8.0" ]; then
setup_master >/dev/null 2>&1 setup_master
elif [[ "$version" =~ $old_versions ]] || [ "$version" = "5.3" ]; then elif [[ "$version" =~ $old_versions ]] || [ "$version" = "5.3" ]; then
setup_old_versions >/dev/null 2>&1 setup_old_versions
else else
update_ppa update_ppa
$apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1 $apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1
+1 -16
View File
@@ -20,18 +20,6 @@ Function Add-Log($mark, $subject, $message) {
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message
} }
Function Install-PhpManager() {
$repo = "mlocati/powershell-phpmanager"
$zip_file = "$php_dir\PhpManager.zip"
$tags = Invoke-WebRequest https://api.github.com/repos/$repo/tags | ConvertFrom-Json
$tag = $tags[0].Name
$module_path = "$php_dir\PhpManager\powershell-phpmanager-$tag\PhpManager"
Invoke-WebRequest -UseBasicParsing -Uri https://github.com/$repo/archive/$tag.zip -OutFile $zip_file
Expand-Archive -Path $zip_file -DestinationPath $php_dir\PhpManager
Import-Module $module_path
Add-Content -Path $PsHome\profile.ps1 -Value "Import-Module $module_path"
}
Function Add-Extension { Function Add-Extension {
Param ( Param (
[Parameter(Position = 0, Mandatory = $true)] [Parameter(Position = 0, Mandatory = $true)]
@@ -136,9 +124,6 @@ Function Add-Tool() {
(Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr (Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr
} elseif($tool -eq "composer") { } elseif($tool -eq "composer") {
composer -q global config process-timeout 0 composer -q global config process-timeout 0
if (Test-Path env:COMPOSER_TOKEN) {
composer -q global config github-oauth.github.com $env:COMPOSER_TOKEN
}
} elseif($tool -eq "wp-cli") { } elseif($tool -eq "wp-cli") {
Copy-Item $php_dir\wp-cli.bat -Destination $php_dir\wp.bat Copy-Item $php_dir\wp-cli.bat -Destination $php_dir\wp.bat
} }
@@ -219,7 +204,7 @@ if((Test-Path env:PHPTS) -and $env:PHPTS -eq 'ts') {
} }
Step-Log "Setup PhpManager" Step-Log "Setup PhpManager"
Install-PhpManager >$null 2>&1 Install-Module -Name PhpManager -Force -Scope CurrentUser
Add-Log $tick "PhpManager" "Installed" Add-Log $tick "PhpManager" "Installed"
$installed = $null $installed = $null
+5 -10
View File
@@ -4,7 +4,6 @@ import * as utils from './utils';
* Function to get command to setup tools * Function to get command to setup tools
* *
* @param os_version * @param os_version
* @param suffix
*/ */
export async function getCommand( export async function getCommand(
os_version: string, os_version: string,
@@ -70,8 +69,6 @@ export async function parseTool(
/** /**
* Function to get the url of tool with the given version * Function to get the url of tool with the given version
* *
* @param tool
* @param extension
* @param version * @param version
* @param prefix * @param prefix
* @param version_prefix * @param version_prefix
@@ -170,14 +167,16 @@ export async function getCodeceptionUri(
case /(^2\.(1\.[0-5]|0\.\d+)|^1\.[6-8]\.\d+).*/.test(version): case /(^2\.(1\.[0-5]|0\.\d+)|^1\.[6-8]\.\d+).*/.test(version):
return codecept; return codecept;
default: default:
return codecept; return await codecept;
} }
} }
/** /**
* Helper function to get script to setup phive * Helper function to get script to setup phive
* *
* @param tool
* @param version * @param version
* @param url
* @param os_version * @param os_version
*/ */
export async function addPhive( export async function addPhive(
@@ -205,9 +204,6 @@ export async function addPhive(
/** /**
* Function to get the phar url in domain/tool-version.phar format * Function to get the phar url in domain/tool-version.phar format
* *
* @param domain
* @param tool
* @param prefix
* @param version * @param version
*/ */
export async function getPharUrl( export async function getPharUrl(
@@ -297,7 +293,7 @@ export async function getWpCliUrl(version: string): Promise<string> {
/** /**
* Function to add/move composer in the tools list * Function to add/move composer in the tools list
* *
* @param tools_list * @param tools
*/ */
export async function addComposer(tools_list: string[]): Promise<string[]> { export async function addComposer(tools_list: string[]): Promise<string[]> {
const regex = /^composer($|:.*)/; const regex = /^composer($|:.*)/;
@@ -406,8 +402,7 @@ export async function addPackage(
/** /**
* Setup tools * Setup tools
* *
* @param tools_csv * @param tool_csv
* @param php_version
* @param os_version * @param os_version
*/ */
export async function addTools( export async function addTools(
+9 -3
View File
@@ -65,6 +65,7 @@ export async function color(type: string): Promise<string> {
* @param message * @param message
* @param os_version * @param os_version
* @param log_type * @param log_type
* @param prefix
*/ */
export async function log( export async function log(
message: string, message: string,
@@ -120,7 +121,6 @@ export async function stepLog(
* @param mark * @param mark
* @param subject * @param subject
* @param message * @param message
* @param os_version
*/ */
export async function addLog( export async function addLog(
mark: string, mark: string,
@@ -147,8 +147,14 @@ export async function addLog(
* Read the scripts * Read the scripts
* *
* @param filename * @param filename
* @param version
* @param os_version
*/ */
export async function readScript(filename: string): Promise<string> { export async function readScript(
filename: string,
version: string,
os_version: string
): Promise<string> {
return fs.readFileSync( return fs.readFileSync(
path.join(__dirname, '../src/scripts/' + filename), path.join(__dirname, '../src/scripts/' + filename),
'utf8' 'utf8'
@@ -159,6 +165,7 @@ export async function readScript(filename: string): Promise<string> {
* Write final script which runs * Write final script which runs
* *
* @param filename * @param filename
* @param version
* @param script * @param script
*/ */
export async function writeScript( export async function writeScript(
@@ -189,7 +196,6 @@ export async function extensionArray(
.map(function(extension: string) { .map(function(extension: string) {
return extension return extension
.trim() .trim()
.toLowerCase()
.replace('php-', '') .replace('php-', '')
.replace('php_', ''); .replace('php_', '');
}) })
+1 -1
View File
@@ -2,7 +2,7 @@
"compilerOptions": { "compilerOptions": {
/* Basic Options */ /* Basic Options */
// "incremental": true, /* Enable incremental compilation */ // "incremental": true, /* Enable incremental compilation */
"target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "allowJs": true, /* Allow javascript files to be compiled. */ // "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */ // "checkJs": true, /* Report errors in .js files. */