mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-07-08 16:10:35 +07:00
Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
ffded4a3e8 | |||
9e6b9d7d70 | |||
7d45057bba | |||
c4fd8b0739 | |||
49088ede98 | |||
3543ed1ef8 | |||
9bd0fdbc18 | |||
c5d29cf8e3 | |||
c5e0997b44 | |||
ee084d3176 | |||
c256f0c9cb | |||
d84365cd03 | |||
3c52e818b1 | |||
188598ef9d | |||
f8b8d766d5 | |||
15a6402865 |
77
README.md
77
README.md
@ -11,6 +11,7 @@
|
|||||||
<a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://codecov.io/gh/shivammathur/setup-php/branch/master/graph/badge.svg"></a>
|
<a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://codecov.io/gh/shivammathur/setup-php/branch/master/graph/badge.svg"></a>
|
||||||
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></a>
|
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></a>
|
||||||
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.3-8892BF.svg"></a>
|
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.3-8892BF.svg"></a>
|
||||||
|
<a href="https://twitter.com/setup_php" title="setup-php twitter"><img alt="setup-php twitter" src="https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
|
Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
|
||||||
@ -143,7 +144,7 @@ with:
|
|||||||
|
|
||||||
- Extensions which cannot be added or removed gracefully leave an error message in the logs, the action is not interrupted.
|
- Extensions which cannot be added or removed gracefully leave an error message in the logs, the action is not interrupted.
|
||||||
|
|
||||||
- These extensions have custom support - `gearman` on `Ubuntu`, `blackfire`, `ioncube`, `oci8`, `pdo_oci`, `phalcon3` and `phalcon4` on all supported OS.
|
- These extensions have custom support - `cubrid`, `pdo_cubrid` and `gearman` on `Ubuntu`, and `blackfire`, `ioncube`, `oci8`, `pdo_oci`, `phalcon3` and `phalcon4` on all supported OS.
|
||||||
|
|
||||||
## :wrench: Tools Support
|
## :wrench: Tools Support
|
||||||
|
|
||||||
@ -178,7 +179,8 @@ with:
|
|||||||
```
|
```
|
||||||
|
|
||||||
**Notes**
|
**Notes**
|
||||||
- Both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified in tools input.
|
- Latest versions of both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified in tools input.
|
||||||
|
- If you have a tool in your `composer.json`, do not setup it globally using this action as the two instances of the tool might conflict.
|
||||||
- Tools which cannot be setup gracefully leave an error message in the logs, the action is not interrupted.
|
- Tools which cannot be setup gracefully leave an error message in the logs, the action is not interrupted.
|
||||||
|
|
||||||
## :signal_strength: Coverage Support
|
## :signal_strength: Coverage Support
|
||||||
@ -315,7 +317,7 @@ jobs:
|
|||||||
|
|
||||||
- This version is currently in development.
|
- This version is currently in development.
|
||||||
- `PECL` is installed by default with this version on `ubuntu` and `macOS`.
|
- `PECL` is installed by default with this version on `ubuntu` and `macOS`.
|
||||||
- Some extensions might not support this version currently.
|
- Some user space extensions might not support this version currently.
|
||||||
- Refer to this [RFC](https://wiki.php.net/rfc/jit "PHP JIT RFC configuration") for configuring `PHP JIT` on this version.
|
- Refer to this [RFC](https://wiki.php.net/rfc/jit "PHP JIT RFC configuration") for configuring `PHP JIT` on this version.
|
||||||
- Refer to this [list of RFCs](https://wiki.php.net/rfc#php_80 "List of RFCs implemented in PHP8") implemented in this version.
|
- Refer to this [list of RFCs](https://wiki.php.net/rfc#php_80 "List of RFCs implemented in PHP8") implemented in this version.
|
||||||
|
|
||||||
@ -364,6 +366,10 @@ jobs:
|
|||||||
runner: self-hosted # Specify the runner.
|
runner: self-hosted # Specify the runner.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Notes**
|
||||||
|
- Do not setup multiple self-hosted runners on the a single server instance as parallel workflow will conflict with each other.
|
||||||
|
- Do not setup self-hosted runners on the side on your development environment or your production server.
|
||||||
|
|
||||||
### Local Testing Setup
|
### Local Testing Setup
|
||||||
|
|
||||||
> Test your `Ubuntu` workflow locally using [`nektos/act`](https://github.com/nektos/act "Project to test GitHub Actions locally").
|
> Test your `Ubuntu` workflow locally using [`nektos/act`](https://github.com/nektos/act "Project to test GitHub Actions locally").
|
||||||
@ -455,45 +461,8 @@ To debug any issues, you can use the `verbose` tag instead of `v2`.
|
|||||||
|
|
||||||
### Cache Extensions
|
### Cache Extensions
|
||||||
|
|
||||||
You can cache PHP extensions using [`shivammathur/cache-extensions`](https://github.com/shivammathur/cache-extensions "GitHub Action to cache php extensions") and [`action/cache`](https://github.com/actions/cache "GitHub Action to cache files") GitHub Actions. Extensions which take very long to setup when cached are available in the next workflow run and are enabled directly. This reduces the workflow execution time.
|
You can cache PHP extensions using `shivammathur/cache-extensions` and `action/cache` GitHub Actions. Extensions which take very long to setup when cached are available in the next workflow run and are enabled directly. This reduces the workflow execution time.
|
||||||
|
Refer to [`shivammathur/cache-extensions`](https://github.com/shivammathur/cache-extensions "GitHub Action to cache php extensions") for details.
|
||||||
```yaml
|
|
||||||
runs-on: ${{ matrix.operating-system }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
php-versions: ['7.2', '7.3', '7.4']
|
|
||||||
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
|
|
||||||
env:
|
|
||||||
extensions: intl, pcov
|
|
||||||
key: cache-v1 # can be any string, change to clear the extension cache.
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Setup cache environment
|
|
||||||
id: extcache
|
|
||||||
uses: shivammathur/cache-extensions@v1
|
|
||||||
with:
|
|
||||||
php-version: ${{ matrix.php-versions }}
|
|
||||||
extensions: ${{ env.extensions }}
|
|
||||||
key: ${{ env.key }}
|
|
||||||
|
|
||||||
- name: Cache extensions
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: ${{ steps.extcache.outputs.dir }}
|
|
||||||
key: ${{ steps.extcache.outputs.key }}
|
|
||||||
restore-keys: ${{ steps.extcache.outputs.key }}
|
|
||||||
|
|
||||||
- name: Setup PHP
|
|
||||||
uses: shivammathur/setup-php@v2
|
|
||||||
with:
|
|
||||||
php-version: ${{ matrix.php-versions }}
|
|
||||||
extensions: ${{ env.extensions }}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Note:** If you setup both `TS` and `NTS` PHP versions on `windows`, add `${{ env.phpts }}` to `key` and `restore-keys` inputs in `actions/cache` step.
|
|
||||||
|
|
||||||
### Cache Composer Dependencies
|
### Cache Composer Dependencies
|
||||||
|
|
||||||
@ -646,10 +615,21 @@ Examples of using `setup-php` with various PHP Frameworks and Packages.
|
|||||||
|
|
||||||
## :sparkling_heart: Support This Project
|
## :sparkling_heart: Support This Project
|
||||||
|
|
||||||
If this action helped you.
|
- Please star the project and share it. If you blog, please share your experience of using this action.
|
||||||
|
- Please consider supporting our work by sponsoring using [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal") or by subscribing on [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon").
|
||||||
|
- If you use `setup-php` at your company, please [reach out](mailto:contact@setup-php.com) to sponsor the project.
|
||||||
|
|
||||||
- Sponsor the project by subscribing on [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon") or by contributing using [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal"). This project is also available as part of the [Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-setup-php?utm_source=npm-setup-php&utm_medium=referral&utm_campaign=enterprise&utm_term=repo "Tidelift Subscription for setup-php") to support delivering enterprise-level maintenance.
|
*Huge thanks to the following companies for supporting `setup-php`*
|
||||||
- Please star the project and dependencies. If you blog, please share your experience of using this action with the community.
|
|
||||||
|
<p>
|
||||||
|
<a href="https://www.jetbrains.com/?from=setup-php">
|
||||||
|
<img src="https://shivammathur.com/jetbrains.svg" alt="JetBrains" width="150" height="85">
|
||||||
|
</a>
|
||||||
|
<img src="https://shivammathur.com/blank.svg" alt="spacer" width="40" height="85">
|
||||||
|
<a href="https://tidelift.com/subscription/pkg/npm-setup-php">
|
||||||
|
<img src="https://shivammathur.com/tidelift.png" alt="Tidelift" width="100" height="85">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
## :package: Dependencies
|
## :package: Dependencies
|
||||||
|
|
||||||
@ -658,9 +638,12 @@ If this action helped you.
|
|||||||
- [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows")
|
- [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows")
|
||||||
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Packaging active PHP packages")
|
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Packaging active PHP packages")
|
||||||
- [shivammathur/cache-extensions](https://github.com/shivammathur/cache-extensions "GitHub action to help with caching PHP extensions")
|
- [shivammathur/cache-extensions](https://github.com/shivammathur/cache-extensions "GitHub action to help with caching PHP extensions")
|
||||||
- [shivammathur/homebrew-php](https://github.com/shivammathur/homebrew-php "Tap for PHP builds on MacOS")
|
- [shivammathur/composer-cache](https://github.com/shivammathur/composer-cache "Cache composer releases")
|
||||||
- [shivammathur/homebrew-extensions](https://github.com/shivammathur/homebrew-extensions "Tap for PHP extensions on MacOS")
|
- [shivammathur/homebrew-extensions](https://github.com/shivammathur/homebrew-extensions "Tap for PHP extensions on MacOS")
|
||||||
- [shivammathur/php-builder](https://github.com/shivammathur/php-builder "Nightly PHP package")
|
- [shivammathur/homebrew-php](https://github.com/shivammathur/homebrew-php "Tap for PHP builds on MacOS")
|
||||||
|
- [shivammathur/php-builder](https://github.com/shivammathur/php-builder "Nightly PHP package for Ubuntu")
|
||||||
|
- [shivammathur/php-builder-windows](https://github.com/shivammathur/php-builder-windows "Nightly PHP package for Windows")
|
||||||
|
- [shivammathur/php-ubuntu](https://github.com/shivammathur/php-ubuntu "Cache stable PHP Packages for Ubuntu")
|
||||||
- [shivammathur/php5-darwin](https://github.com/shivammathur/php5-darwin "Scripts to setup PHP5 versions on darwin")
|
- [shivammathur/php5-darwin](https://github.com/shivammathur/php5-darwin "Scripts to setup PHP5 versions on darwin")
|
||||||
- [shivammathur/php5-ubuntu](https://github.com/shivammathur/php5-ubuntu "Scripts to setup PHP5 versions on ubuntu")
|
- [shivammathur/php5-ubuntu](https://github.com/shivammathur/php5-ubuntu "Scripts to setup PHP5 versions on ubuntu")
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ describe('Extension tests', () => {
|
|||||||
expect(win32).toContain('Remove-Extension intl');
|
expect(win32).toContain('Remove-Extension intl');
|
||||||
expect(win32).toContain('Add-Phalcon phalcon4');
|
expect(win32).toContain('Add-Phalcon phalcon4');
|
||||||
expect(win32).toContain('Add-Ioncube');
|
expect(win32).toContain('Add-Ioncube');
|
||||||
expect(win32).toContain('Add-OCI oci8');
|
expect(win32).toContain('Add-Oci oci8');
|
||||||
expect(win32).toContain('Add-OCI pdo_oci');
|
expect(win32).toContain('Add-Oci pdo_oci');
|
||||||
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');
|
||||||
@ -95,6 +95,11 @@ describe('Extension tests', () => {
|
|||||||
linux = await extensions.addExtension('gearman', '7.4', 'linux');
|
linux = await extensions.addExtension('gearman', '7.4', 'linux');
|
||||||
expect(linux).toContain('add_gearman');
|
expect(linux).toContain('add_gearman');
|
||||||
|
|
||||||
|
linux = await extensions.addExtension('pdo_cubrid', '7.0', 'linux');
|
||||||
|
expect(linux).toContain('add_cubrid pdo_cubrid');
|
||||||
|
linux = await extensions.addExtension('cubrid', '7.4', 'linux');
|
||||||
|
expect(linux).toContain('add_cubrid cubrid');
|
||||||
|
|
||||||
linux = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
linux = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
||||||
expect(linux).toContain('Platform fedora is not supported');
|
expect(linux).toContain('Platform fedora is not supported');
|
||||||
|
|
||||||
|
@ -1,31 +1,6 @@
|
|||||||
import * as httpm from '@actions/http-client';
|
|
||||||
import * as tools from '../src/tools';
|
import * as tools from '../src/tools';
|
||||||
|
|
||||||
httpm.HttpClient.prototype.get = jest.fn().mockImplementation(() => {
|
|
||||||
return {
|
|
||||||
message: null,
|
|
||||||
readBody: jest.fn().mockImplementation(() => {
|
|
||||||
return JSON.stringify({
|
|
||||||
stable: [{path: '/composer-stable.phar'}],
|
|
||||||
preview: [{path: '/composer-preview.phar'}],
|
|
||||||
snapshot: [{path: '/composer.phar'}],
|
|
||||||
'1': [{path: '/composer-1.phar'}],
|
|
||||||
'2': [{path: '/composer-2.phar'}]
|
|
||||||
});
|
|
||||||
})
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Tools tests', () => {
|
describe('Tools tests', () => {
|
||||||
it('checking getCommand', async () => {
|
|
||||||
expect(await tools.getCommand('linux', 'tool')).toBe('add_tool ');
|
|
||||||
expect(await tools.getCommand('darwin', 'tool')).toBe('add_tool ');
|
|
||||||
expect(await tools.getCommand('win32', 'tool')).toBe('Add-Tool ');
|
|
||||||
expect(await tools.getCommand('fedora', 'tool')).toContain(
|
|
||||||
'Platform fedora is not supported'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('checking parseToolVersion', async () => {
|
it('checking parseToolVersion', async () => {
|
||||||
expect(await tools.getToolVersion('latest')).toBe('latest');
|
expect(await tools.getToolVersion('latest')).toBe('latest');
|
||||||
expect(await tools.getToolVersion('1.2.3')).toBe('1.2.3');
|
expect(await tools.getToolVersion('1.2.3')).toBe('1.2.3');
|
||||||
@ -402,17 +377,6 @@ describe('Tools tests', () => {
|
|||||||
expect(script).toContain('Platform fedora is not supported');
|
expect(script).toContain('Platform fedora is not supported');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addCustomTool', async () => {
|
|
||||||
let script: string = await tools.addCustomTool('tool', '1.2.3', 'linux');
|
|
||||||
expect(script).toContain('tool.sh\nadd_tool 1.2.3');
|
|
||||||
|
|
||||||
script = await tools.addCustomTool('tool', '1.2.3', 'darwin');
|
|
||||||
expect(script).toContain('tool.sh\nadd_tool 1.2.3');
|
|
||||||
|
|
||||||
script = await tools.addCustomTool('tool', '1.2.3', 'win32');
|
|
||||||
expect(script).toContain('tool.ps1\nAdd-Tool 1.2.3');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('checking addTools on linux', async () => {
|
it('checking addTools on linux', async () => {
|
||||||
const script: string = await tools.addTools(
|
const script: string = await tools.addTools(
|
||||||
'blackfire, blackfire-player, cs2pr, flex, grpc_php_plugin, php-cs-fixer, phplint, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, protoc, symfony, wp-cli',
|
'blackfire, blackfire-player, cs2pr, flex, grpc_php_plugin, php-cs-fixer, phplint, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, protoc, symfony, wp-cli',
|
||||||
|
@ -174,6 +174,15 @@ describe('Utils tests', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('checking getCommand', async () => {
|
||||||
|
expect(await utils.getCommand('linux', 'tool')).toBe('add_tool ');
|
||||||
|
expect(await utils.getCommand('darwin', 'tool')).toBe('add_tool ');
|
||||||
|
expect(await utils.getCommand('win32', 'tool')).toBe('Add-Tool ');
|
||||||
|
expect(await utils.getCommand('fedora', 'tool')).toContain(
|
||||||
|
'Platform fedora is not supported'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('checking joins', async () => {
|
it('checking joins', async () => {
|
||||||
expect(await utils.joins('a', 'b', 'c')).toBe('a b c');
|
expect(await utils.joins('a', 'b', 'c')).toBe('a b c');
|
||||||
});
|
});
|
||||||
@ -186,4 +195,17 @@ describe('Utils tests', () => {
|
|||||||
'Platform fedora is not supported'
|
'Platform fedora is not supported'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('checking customPackage', async () => {
|
||||||
|
const script_path: string = path.join('ext', 'pkg.sh');
|
||||||
|
expect(await utils.customPackage('pkg', 'ext', '1.2.3', 'linux')).toContain(
|
||||||
|
script_path + '\nadd_pkg 1.2.3'
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
await utils.customPackage('pdo_pkg', 'ext', '1.2.3', 'linux')
|
||||||
|
).toContain(script_path + '\nadd_pkg 1.2.3');
|
||||||
|
expect(
|
||||||
|
await utils.customPackage('pkg8', 'ext', '1.2.3', 'linux')
|
||||||
|
).toContain(script_path + '\nadd_pkg 1.2.3');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
1084
dist/index.js
vendored
1084
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
1403
package-lock.json
generated
1403
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "2.4.1",
|
"version": "2.4.3",
|
||||||
"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",
|
||||||
@ -26,26 +26,25 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.4",
|
"@actions/core": "^1.2.4",
|
||||||
"@actions/exec": "^1.0.4",
|
"@actions/exec": "^1.0.4",
|
||||||
"@actions/http-client": "^1.0.8",
|
|
||||||
"@actions/io": "^1.0.2",
|
"@actions/io": "^1.0.2",
|
||||||
"fs": "0.0.1-security"
|
"fs": "0.0.1-security"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.8",
|
"@types/jest": "^26.0.10",
|
||||||
"@types/node": "^14.0.27",
|
"@types/node": "^14.6.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^3.7.1",
|
"@typescript-eslint/eslint-plugin": "^3.9.1",
|
||||||
"@typescript-eslint/parser": "^3.7.1",
|
"@typescript-eslint/parser": "^3.9.1",
|
||||||
"@zeit/ncc": "^0.22.3",
|
"@zeit/ncc": "^0.22.3",
|
||||||
"eslint": "^7.6.0",
|
"eslint": "^7.7.0",
|
||||||
"eslint-config-prettier": "^6.11.0",
|
"eslint-config-prettier": "^6.11.0",
|
||||||
"eslint-plugin-import": "^2.22.0",
|
"eslint-plugin-import": "^2.22.0",
|
||||||
"eslint-plugin-jest": "^23.20.0",
|
"eslint-plugin-jest": "^23.20.0",
|
||||||
"eslint-plugin-prettier": "^3.1.4",
|
"eslint-plugin-prettier": "^3.1.4",
|
||||||
"husky": "^4.2.5",
|
"husky": "^4.2.5",
|
||||||
"jest": "^26.2.2",
|
"jest": "^26.4.0",
|
||||||
"jest-circus": "^26.2.2",
|
"jest-circus": "^26.4.0",
|
||||||
"prettier": "^2.0.5",
|
"prettier": "^2.0.5",
|
||||||
"ts-jest": "^26.1.4",
|
"ts-jest": "^26.2.0",
|
||||||
"typescript": "^3.9.7"
|
"typescript": "^3.9.7"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
|
@ -1,24 +1,5 @@
|
|||||||
import * as path from 'path';
|
|
||||||
import * as utils from './utils';
|
import * as utils from './utils';
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to get script to install custom extensions
|
|
||||||
*
|
|
||||||
* @param script
|
|
||||||
* @param command
|
|
||||||
*/
|
|
||||||
export async function customExtension(
|
|
||||||
script: string,
|
|
||||||
...command: string[]
|
|
||||||
): Promise<string> {
|
|
||||||
return (
|
|
||||||
'\n. ' +
|
|
||||||
path.join(__dirname, '../src/scripts/ext/' + script) +
|
|
||||||
'\n' +
|
|
||||||
(await utils.joins(...command))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install and enable extensions for darwin
|
* Install and enable extensions for darwin
|
||||||
*
|
*
|
||||||
@ -47,29 +28,20 @@ export async function addExtensionDarwin(
|
|||||||
return;
|
return;
|
||||||
// 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
|
||||||
|
// match pdo_oci and oci8
|
||||||
|
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||||
|
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||||
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
|
||||||
):
|
):
|
||||||
add_script += await customExtension(
|
|
||||||
'blackfire.sh',
|
|
||||||
'add_blackfire',
|
|
||||||
extension
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
// match pdo_oci and oci8
|
|
||||||
case /^pdo_oci$|^oci8$/.test(extension):
|
case /^pdo_oci$|^oci8$/.test(extension):
|
||||||
add_script += await customExtension('oci.sh', 'add_oci', extension);
|
|
||||||
return;
|
|
||||||
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
|
||||||
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||||
add_script += await customExtension('ioncube.sh', 'add_ioncube');
|
|
||||||
return;
|
|
||||||
// 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):
|
||||||
add_script += await customExtension(
|
add_script += await utils.customPackage(
|
||||||
'phalcon.sh',
|
ext_name,
|
||||||
'add_phalcon',
|
'ext',
|
||||||
extension
|
extension,
|
||||||
|
'darwin'
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
// match pre-release versions. For example - xdebug-beta
|
// match pre-release versions. For example - xdebug-beta
|
||||||
@ -154,33 +126,24 @@ export async function addExtensionWindows(
|
|||||||
case /^:/.test(ext_name):
|
case /^:/.test(ext_name):
|
||||||
remove_script += '\nRemove-Extension ' + ext_name.slice(1);
|
remove_script += '\nRemove-Extension ' + ext_name.slice(1);
|
||||||
break;
|
break;
|
||||||
// match 5.4blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
|
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
|
||||||
// match 5.4blackfire-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\.[4-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
|
// match pdo_oci and oci8
|
||||||
|
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||||
|
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||||
|
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
|
||||||
version_extension
|
version_extension
|
||||||
):
|
):
|
||||||
add_script += await customExtension(
|
|
||||||
'blackfire.ps1',
|
|
||||||
'Add-Blackfire',
|
|
||||||
extension
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
// match pdo_oci and oci8
|
|
||||||
case /^pdo_oci$|^oci8$/.test(extension):
|
case /^pdo_oci$|^oci8$/.test(extension):
|
||||||
add_script += await customExtension('oci.ps1', 'Add-OCI', extension);
|
|
||||||
break;
|
|
||||||
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
|
||||||
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||||
add_script += await customExtension('ioncube.ps1', 'Add-Ioncube');
|
|
||||||
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):
|
||||||
add_script += await customExtension(
|
add_script += await utils.customPackage(
|
||||||
'phalcon.ps1',
|
ext_name,
|
||||||
'Add-Phalcon',
|
'ext',
|
||||||
extension
|
extension,
|
||||||
|
'win32'
|
||||||
);
|
);
|
||||||
break;
|
return;
|
||||||
// match pre-release versions. For example - xdebug-beta
|
// match pre-release versions. For example - xdebug-beta
|
||||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||||
add_script += await utils.joins(
|
add_script += await utils.joins(
|
||||||
@ -269,35 +232,28 @@ export async function addExtensionLinux(
|
|||||||
remove_script += '\nremove_extension ' + ext_name.slice(1);
|
remove_script += '\nremove_extension ' + ext_name.slice(1);
|
||||||
return;
|
return;
|
||||||
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
|
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
|
||||||
// match 5.3blackfire-{semver}...5.6blackfire-{semver}, 7.0blackfire-{semver}...7.4blackfire-{semver}
|
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
|
||||||
|
// match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid
|
||||||
|
// match pdo_oci and oci8
|
||||||
|
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||||
|
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||||
|
// match 5.6gearman..7.4gearman
|
||||||
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
|
||||||
):
|
):
|
||||||
add_script += await customExtension(
|
case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test(
|
||||||
'blackfire.sh',
|
version_extension
|
||||||
'add_blackfire',
|
):
|
||||||
extension
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
// match pdo_oci and oci8
|
|
||||||
case /^pdo_oci$|^oci8$/.test(extension):
|
case /^pdo_oci$|^oci8$/.test(extension):
|
||||||
add_script += await customExtension('oci.sh', 'add_oci', extension);
|
|
||||||
return;
|
|
||||||
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
|
||||||
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||||
add_script += await customExtension('ioncube.sh', 'add_ioncube');
|
|
||||||
return;
|
|
||||||
// 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):
|
||||||
add_script += await customExtension(
|
|
||||||
'phalcon.sh',
|
|
||||||
'add_phalcon',
|
|
||||||
extension
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
// 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):
|
||||||
add_script += await customExtension('gearman.sh', 'add_gearman');
|
add_script += await utils.customPackage(
|
||||||
|
ext_name,
|
||||||
|
'ext',
|
||||||
|
extension,
|
||||||
|
'linux'
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
// match pre-release versions. For example - xdebug-beta
|
// match pre-release versions. For example - xdebug-beta
|
||||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||||
|
@ -166,13 +166,12 @@ add_tool() {
|
|||||||
if [ ! -e "$tool_path" ]; then
|
if [ ! -e "$tool_path" ]; then
|
||||||
rm -rf "$tool_path"
|
rm -rf "$tool_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$tool" = "composer" ]; then
|
if [ "$tool" = "composer" ]; then
|
||||||
IFS="," read -r -a urls <<< "$url"
|
IFS="," read -r -a urls <<< "$url"
|
||||||
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") ||
|
status_code=$(sudo curl -f -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") ||
|
||||||
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}")
|
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}")
|
||||||
else
|
else
|
||||||
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
||||||
fi
|
fi
|
||||||
if [ "$status_code" = "200" ]; then
|
if [ "$status_code" = "200" ]; then
|
||||||
sudo chmod a+x "$tool_path"
|
sudo chmod a+x "$tool_path"
|
||||||
|
50
src/scripts/ext/cubrid.sh
Normal file
50
src/scripts/ext/cubrid.sh
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# Function to log license details.
|
||||||
|
add_license_log() {
|
||||||
|
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$ext" "Click to read the $ext related license information"
|
||||||
|
printf "Cubrid CCI package is required for %s extension.\n" "$ext"
|
||||||
|
printf "The extension %s and Cubrid CCI are provided under the license linked below.\n" "$ext"
|
||||||
|
printf "Refer to: \033[35;1m%s \033[0m\n" "https://github.com/CUBRID/cubrid-cci/blob/develop/COPYING"
|
||||||
|
echo "::endgroup::"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to set cubrid repo for the extension.
|
||||||
|
set_cubrid_repo() {
|
||||||
|
case "${ext:?}" in
|
||||||
|
"cubrid") cubrid_repo="cubrid-php";;
|
||||||
|
"pdo_cubrid") cubrid_repo="cubrid-pdo";;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to set cubrid branch for a PHP version.
|
||||||
|
set_cubrid_branch() {
|
||||||
|
case "${version:?}" in
|
||||||
|
5.[3-6]) cubrid_branch="RB-9.3.0";;
|
||||||
|
*) cubrid_branch="develop";;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
add_cubrid_helper() {
|
||||||
|
if ! [ -e "${ext_dir:?}/$ext.so" ]; then
|
||||||
|
status='Installed and enabled'
|
||||||
|
set_cubrid_repo
|
||||||
|
set_cubrid_branch
|
||||||
|
(
|
||||||
|
git clone -b "$cubrid_branch" --recursive "https://github.com/CUBRID/$cubrid_repo" "/tmp/$cubrid_repo"
|
||||||
|
cd "/tmp/$cubrid_repo" || exit
|
||||||
|
! [[ "$version" =~ ${old_versions:?} ]] && add_devtools
|
||||||
|
phpize && ./configure --with-php-config="$(command -v php-config)" --with-"${ext/_/-}"=shared
|
||||||
|
make -j"$(nproc)"
|
||||||
|
sudo make install
|
||||||
|
)
|
||||||
|
echo "extension=$ext.so" | sudo tee "${scan_dir:?}/$ext.ini"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add cubrid and pdo_cubrid.
|
||||||
|
add_cubrid() {
|
||||||
|
ext=$1
|
||||||
|
status='Enabled'
|
||||||
|
add_cubrid_helper >/dev/null 2>&1
|
||||||
|
add_extension_log "$ext" "$status"
|
||||||
|
check_extension "$ext" && add_license_log
|
||||||
|
}
|
@ -21,7 +21,7 @@ Function Add-InstantClient() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Function to install oci8 and pdo_oci.
|
# Function to install oci8 and pdo_oci.
|
||||||
Function Add-OCI() {
|
Function Add-Oci() {
|
||||||
Param (
|
Param (
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
@ -35,6 +35,7 @@ Function Add-OCI() {
|
|||||||
if ($extension -eq "pdo_oci") {
|
if ($extension -eq "pdo_oci") {
|
||||||
Enable-PhpExtension pdo_oci -Path $php_dir
|
Enable-PhpExtension pdo_oci -Path $php_dir
|
||||||
} else {
|
} else {
|
||||||
|
if(-not(Test-Path $ext_dir\php_oci8.dll)) {
|
||||||
$status = 'Installed and enabled'
|
$status = 'Installed and enabled'
|
||||||
$ociVersion = '2.2.0'
|
$ociVersion = '2.2.0'
|
||||||
if ($version -eq '7.0') {
|
if ($version -eq '7.0') {
|
||||||
@ -45,6 +46,8 @@ Function Add-OCI() {
|
|||||||
$ociUrl = Get-PeclArchiveUrl oci8 $ociVersion $installed
|
$ociUrl = Get-PeclArchiveUrl oci8 $ociVersion $installed
|
||||||
Invoke-WebRequest -UseBasicParsing -Uri $ociUrl -OutFile $php_dir\oci8.zip
|
Invoke-WebRequest -UseBasicParsing -Uri $ociUrl -OutFile $php_dir\oci8.zip
|
||||||
Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force
|
Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force
|
||||||
|
|
||||||
|
}
|
||||||
Add-Content -Value "`r`nextension=php_oci8.dll" -Path $php_dir\php.ini
|
Add-Content -Value "`r`nextension=php_oci8.dll" -Path $php_dir\php.ini
|
||||||
}
|
}
|
||||||
Add-Log $tick $extension $status
|
Add-Log $tick $extension $status
|
||||||
|
@ -124,6 +124,7 @@ delete_extension() {
|
|||||||
sudo sed -i "/$extension/d" "$pecl_file"
|
sudo sed -i "/$extension/d" "$pecl_file"
|
||||||
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
||||||
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
||||||
|
[ "$runner" = "self-hosted" ] && $apt_remove "php-$extension"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to disable and delete extensions.
|
# Function to disable and delete extensions.
|
||||||
@ -164,7 +165,7 @@ add_pdo_extension() {
|
|||||||
read -r ext ext_name <<< "sqlite3 sqlite3"
|
read -r ext ext_name <<< "sqlite3 sqlite3"
|
||||||
fi
|
fi
|
||||||
add_extension "$ext_name" "$apt_install php$version-$ext" "extension" >/dev/null 2>&1
|
add_extension "$ext_name" "$apt_install php$version-$ext" "extension" >/dev/null 2>&1
|
||||||
enable_extension "$pdo_ext" "extension"
|
add_extension "$pdo_ext" "pecl_install $pdo_ext" "extension" >/dev/null 2>&1
|
||||||
add_extension_log "$pdo_ext" "Enabled"
|
add_extension_log "$pdo_ext" "Enabled"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -263,10 +264,10 @@ add_tool() {
|
|||||||
fi
|
fi
|
||||||
if [ "$tool" = "composer" ]; then
|
if [ "$tool" = "composer" ]; then
|
||||||
IFS="," read -r -a urls <<< "$url"
|
IFS="," read -r -a urls <<< "$url"
|
||||||
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") ||
|
status_code=$(sudo curl -f -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") ||
|
||||||
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}")
|
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}")
|
||||||
else
|
else
|
||||||
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
||||||
fi
|
fi
|
||||||
if [ "$status_code" = "200" ]; then
|
if [ "$status_code" = "200" ]; then
|
||||||
sudo chmod a+x "$tool_path"
|
sudo chmod a+x "$tool_path"
|
||||||
@ -397,6 +398,7 @@ old_versions="5.[3-5]"
|
|||||||
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
||||||
github="https://github.com/shivammathur"
|
github="https://github.com/shivammathur"
|
||||||
apt_install="sudo $debconf_fix apt-fast install -y"
|
apt_install="sudo $debconf_fix apt-fast install -y"
|
||||||
|
apt_remove="sudo $debconf_fix apt-fast remove -y"
|
||||||
tool_path_dir="/usr/local/bin"
|
tool_path_dir="/usr/local/bin"
|
||||||
curl_opts=(-sL)
|
curl_opts=(-sL)
|
||||||
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
||||||
@ -444,5 +446,6 @@ scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
|||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
pecl_file="$scan_dir"/99-pecl.ini
|
pecl_file="$scan_dir"/99-pecl.ini
|
||||||
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
|
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
|
||||||
|
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
|
||||||
sudo chmod 777 "$ini_file" "$pecl_file" "$tool_path_dir"
|
sudo chmod 777 "$ini_file" "$pecl_file" "$tool_path_dir"
|
||||||
add_log "$tick" "PHP" "$status PHP $semver"
|
add_log "$tick" "PHP" "$status PHP $semver"
|
||||||
|
73
src/tools.ts
73
src/tools.ts
@ -1,32 +1,4 @@
|
|||||||
import * as utils from './utils';
|
import * as utils from './utils';
|
||||||
import * as httpm from '@actions/http-client';
|
|
||||||
import {IHttpClientResponse as hcr} from '@actions/http-client/interfaces';
|
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to get command to setup tools
|
|
||||||
*
|
|
||||||
* @param os_version
|
|
||||||
* @param suffix
|
|
||||||
*/
|
|
||||||
export async function getCommand(
|
|
||||||
os_version: string,
|
|
||||||
suffix: string
|
|
||||||
): Promise<string> {
|
|
||||||
switch (os_version) {
|
|
||||||
case 'linux':
|
|
||||||
case 'darwin':
|
|
||||||
return 'add_' + suffix + ' ';
|
|
||||||
case 'win32':
|
|
||||||
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
|
||||||
default:
|
|
||||||
return await utils.log(
|
|
||||||
'Platform ' + os_version + ' is not supported',
|
|
||||||
os_version,
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to get tool version
|
* Function to get tool version
|
||||||
@ -194,12 +166,12 @@ export async function addPhive(
|
|||||||
switch (version) {
|
switch (version) {
|
||||||
case 'latest':
|
case 'latest':
|
||||||
return (
|
return (
|
||||||
(await getCommand(os_version, 'tool')) +
|
(await utils.getCommand(os_version, 'tool')) +
|
||||||
'https://phar.io/releases/phive.phar phive'
|
'https://phar.io/releases/phive.phar phive'
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
(await getCommand(os_version, 'tool')) +
|
(await utils.getCommand(os_version, 'tool')) +
|
||||||
'https://github.com/phar-io/phive/releases/download/' +
|
'https://github.com/phar-io/phive/releases/download/' +
|
||||||
version +
|
version +
|
||||||
'/phive-' +
|
'/phive-' +
|
||||||
@ -333,21 +305,15 @@ export async function getComposerUrl(version: string): Promise<string> {
|
|||||||
'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-' +
|
'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-' +
|
||||||
version.replace('latest', 'stable') +
|
version.replace('latest', 'stable') +
|
||||||
'.phar,';
|
'.phar,';
|
||||||
const getComposerUrlHelper = async function (
|
|
||||||
version: string
|
|
||||||
): Promise<string> {
|
|
||||||
const client: httpm.HttpClient = new httpm.HttpClient('setup-php');
|
|
||||||
const response: hcr = await client.get('https://getcomposer.org/versions');
|
|
||||||
const data = JSON.parse(await response.readBody());
|
|
||||||
return cache_url + 'https://getcomposer.org' + data[version][0]['path'];
|
|
||||||
};
|
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case 'snapshot':
|
case 'snapshot':
|
||||||
return cache_url + 'https://getcomposer.org/composer.phar';
|
return cache_url + 'https://getcomposer.org/composer.phar';
|
||||||
case 'preview':
|
case 'preview':
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
return await getComposerUrlHelper(version);
|
return (
|
||||||
|
cache_url + 'https://getcomposer.org/composer-' + version + '.phar'
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return cache_url + 'https://getcomposer.org/composer-stable.phar';
|
return cache_url + 'https://getcomposer.org/composer-stable.phar';
|
||||||
}
|
}
|
||||||
@ -390,7 +356,7 @@ export async function addArchive(
|
|||||||
url: string,
|
url: string,
|
||||||
os_version: string
|
os_version: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
return (await getCommand(os_version, 'tool')) + url + ' ' + tool;
|
return (await utils.getCommand(os_version, 'tool')) + url + ' ' + tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -442,31 +408,10 @@ export async function addPackage(
|
|||||||
prefix: string,
|
prefix: string,
|
||||||
os_version: string
|
os_version: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const tool_command = await getCommand(os_version, 'composertool');
|
const tool_command = await utils.getCommand(os_version, 'composertool');
|
||||||
return tool_command + tool + ' ' + release + ' ' + prefix;
|
return tool_command + tool + ' ' + release + ' ' + prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to get script to add tools with custom support.
|
|
||||||
*
|
|
||||||
* @param tool
|
|
||||||
* @param version
|
|
||||||
* @param os_version
|
|
||||||
*/
|
|
||||||
export async function addCustomTool(
|
|
||||||
tool: string,
|
|
||||||
version: string,
|
|
||||||
os_version: string
|
|
||||||
): Promise<string> {
|
|
||||||
const script_extension: string = await utils.scriptExtension(os_version);
|
|
||||||
const script: string = path.join(
|
|
||||||
__dirname,
|
|
||||||
'../src/scripts/tools/' + tool + script_extension
|
|
||||||
);
|
|
||||||
const command: string = await getCommand(os_version, tool);
|
|
||||||
return '. ' + script + '\n' + command + version;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup tools
|
* Setup tools
|
||||||
*
|
*
|
||||||
@ -500,7 +445,7 @@ export async function addTools(
|
|||||||
case 'blackfire':
|
case 'blackfire':
|
||||||
case 'grpc_php_plugin':
|
case 'grpc_php_plugin':
|
||||||
case 'protoc':
|
case 'protoc':
|
||||||
script += await addCustomTool(tool, version, os_version);
|
script += await utils.customPackage(tool, 'tools', version, os_version);
|
||||||
break;
|
break;
|
||||||
case 'blackfire-player':
|
case 'blackfire-player':
|
||||||
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version);
|
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version);
|
||||||
@ -556,7 +501,7 @@ export async function addTools(
|
|||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, version, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'pecl':
|
case 'pecl':
|
||||||
script += await getCommand(os_version, 'pecl');
|
script += await utils.getCommand(os_version, 'pecl');
|
||||||
break;
|
break;
|
||||||
case 'phan':
|
case 'phan':
|
||||||
url = github + 'phan/phan/' + uri;
|
url = github + 'phan/phan/' + uri;
|
||||||
|
49
src/utils.ts
49
src/utils.ts
@ -284,6 +284,31 @@ export async function getUnsupportedLog(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to get command to setup tools
|
||||||
|
*
|
||||||
|
* @param os_version
|
||||||
|
* @param suffix
|
||||||
|
*/
|
||||||
|
export async function getCommand(
|
||||||
|
os_version: string,
|
||||||
|
suffix: string
|
||||||
|
): Promise<string> {
|
||||||
|
switch (os_version) {
|
||||||
|
case 'linux':
|
||||||
|
case 'darwin':
|
||||||
|
return 'add_' + suffix + ' ';
|
||||||
|
case 'win32':
|
||||||
|
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
||||||
|
default:
|
||||||
|
return await log(
|
||||||
|
'Platform ' + os_version + ' is not supported',
|
||||||
|
os_version,
|
||||||
|
'error'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to join strings with space
|
* Function to join strings with space
|
||||||
*
|
*
|
||||||
@ -313,3 +338,27 @@ export async function scriptExtension(os_version: string): Promise<string> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to get script to add tools with custom support.
|
||||||
|
*
|
||||||
|
* @param pkg
|
||||||
|
* @param type
|
||||||
|
* @param version
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
export async function customPackage(
|
||||||
|
pkg: string,
|
||||||
|
type: string,
|
||||||
|
version: string,
|
||||||
|
os_version: string
|
||||||
|
): Promise<string> {
|
||||||
|
const pkg_name: string = pkg.replace(/\d+|pdo[_-]/, '');
|
||||||
|
const script_extension: string = await scriptExtension(os_version);
|
||||||
|
const script: string = path.join(
|
||||||
|
__dirname,
|
||||||
|
'../src/scripts/' + type + '/' + pkg_name + script_extension
|
||||||
|
);
|
||||||
|
const command: string = await getCommand(os_version, pkg_name);
|
||||||
|
return '\n. ' + script + '\n' + command + version;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user