mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-07-03 05:33:16 +07:00
Compare commits
62 Commits
Author | SHA1 | Date | |
---|---|---|---|
a36e1e52ff | |||
04ff9b08a2 | |||
65fad67e88 | |||
6668249e24 | |||
81c255f988 | |||
81cd5ae092 | |||
29a9813921 | |||
f60e7de98e | |||
b5efb21934 | |||
26e6a92f3b | |||
28b68529b5 | |||
4e4861ec30 | |||
70169700c3 | |||
f4e27c9ead | |||
9855c76987 | |||
546935924a | |||
491e9de600 | |||
e3bda5bed8 | |||
e70f6d9e7c | |||
92e992b198 | |||
99680be1df | |||
e83e329355 | |||
10c12b9377 | |||
91026460e4 | |||
7fdd3ece87 | |||
0de5aa9140 | |||
a6e0b1404f | |||
5d259c66b1 | |||
6207829361 | |||
319feb83c2 | |||
661ad4bf75 | |||
04c15e2314 | |||
5aa416d77b | |||
a9a661ccd4 | |||
321f8d7d9a | |||
7af6c0fe6f | |||
36e04fc85c | |||
95916a72b1 | |||
a5fb328c6a | |||
72ae4ccbe5 | |||
5b2015e8fe | |||
9c77701ae5 | |||
394503cb8a | |||
f1cc14e3d5 | |||
9d529a72e0 | |||
c63f07d82e | |||
e40aa32c04 | |||
a683e80307 | |||
7ce22e0264 | |||
4bd44f22a9 | |||
d2f333de6f | |||
948bd8df3c | |||
8cac79fdb1 | |||
6cc8b47c6f | |||
0be6fa1958 | |||
22d9c80367 | |||
4630172078 | |||
1b02c009e7 | |||
12282c9597 | |||
592bbc7716 | |||
fb5054b163 | |||
3f2a402846 |
1
.github/CONTRIBUTING.md
vendored
1
.github/CONTRIBUTING.md
vendored
@ -71,6 +71,7 @@ npm test
|
||||
Creating a release means compiling all the TypeScript code to a single file which `setup-php` can run. Run this, before you push your changes.
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
npm run release
|
||||
```
|
||||
|
||||
|
2
.github/workflows/codeql.yml
vendored
2
.github/workflows/codeql.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
|
2
.github/workflows/docs.yml
vendored
2
.github/workflows/docs.yml
vendored
@ -57,7 +57,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ github.repository }}.wiki
|
||||
- name: Download artifacts
|
||||
|
4
.github/workflows/node.yml
vendored
4
.github/workflows/node.yml
vendored
@ -29,12 +29,12 @@ jobs:
|
||||
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: Setup Node.js 16.x
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 16.x
|
||||
|
||||
|
7
.github/workflows/php.yml
vendored
7
.github/workflows/php.yml
vendored
@ -29,20 +29,17 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
operating-system: [ubuntu-22.04, ubuntu-20.04, windows-2019, macos-latest]
|
||||
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
|
||||
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
|
||||
include:
|
||||
- operating-system: ubuntu-22.04
|
||||
php-versions: ''
|
||||
php-version-file: 'php-version-file'
|
||||
exclude:
|
||||
- operating-system: macos-latest
|
||||
php-versions: '8.3'
|
||||
env:
|
||||
extensions: xml, opcache, xdebug, pcov, gd
|
||||
key: cache-v5
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup cache environment
|
||||
id: cache-env
|
||||
|
8
.github/workflows/publish.yml
vendored
8
.github/workflows/publish.yml
vendored
@ -19,16 +19,16 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout release
|
||||
if: github.event_name != 'workflow_dispatch'
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Checkout tag
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
with:
|
||||
ref: ${{ github.event.inputs.tag }}
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '16.x'
|
||||
registry-url: https://registry.npmjs.org
|
||||
@ -46,7 +46,7 @@ jobs:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: Change to GitHub Packages registry
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
registry-url: https://npm.pkg.github.com
|
||||
scope: '@shivammathur'
|
||||
|
29
README.md
29
README.md
@ -9,8 +9,8 @@
|
||||
<p align="center">
|
||||
<a href="https://github.com/shivammathur/setup-php" title="GitHub action to setup PHP"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
|
||||
<a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://img.shields.io/codecov/c/github/shivammathur/setup-php?logo=codecov"></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?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a>
|
||||
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.3%20to%208.3-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a>
|
||||
<a href="https://github.com/shivammathur/setup-php/blob/main/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a>
|
||||
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.3%20to%208.4-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://reddit.com/r/setup_php" title="setup-php reddit"><img alt="setup-php reddit" src="https://img.shields.io/badge/reddit-join-FF5700?logo=reddit&logoColor=FF5700&labelColor=555555"></a>
|
||||
@ -77,8 +77,8 @@ Both `GitHub-hosted` and `self-hosted` runners are supported by `setup-php` on t
|
||||
| Ubuntu 20.04 | `ubuntu-20.04` | `PHP 7.4` to `PHP 8.2` |
|
||||
| Windows Server 2022 | `windows-latest` or `windows-2022` | `PHP 8.2` |
|
||||
| Windows Server 2019 | `windows-2019` | `PHP 8.2` |
|
||||
| macOS Monterey 12.x | `macos-12` | `PHP 8.2` |
|
||||
| macOS Big Sur 11.x | `macos-latest` or `macos-11` | `PHP 8.2` |
|
||||
| macOS Ventura 13.x | `macos-13` | `PHP 8.2` |
|
||||
| macOS Monterey 12.x | `macos-latest` or `macos-12` | `PHP 8.2` |
|
||||
|
||||
### Self-Hosted Runners
|
||||
|
||||
@ -90,9 +90,9 @@ Both `GitHub-hosted` and `self-hosted` runners are supported by `setup-php` on t
|
||||
| Debian 10 | `self-hosted` or `Linux` |
|
||||
| Windows 7 and newer | `self-hosted` or `Windows` |
|
||||
| Windows Server 2012 R2 and newer | `self-hosted` or `Windows` |
|
||||
| macOS Sonoma 14.x x86_64/arm64 | `self-hosted` or `macOS` |
|
||||
| macOS Ventura 13.x x86_64/arm64 | `self-hosted` or `macOS` |
|
||||
| macOS Monterey 12.x x86_64/arm64 | `self-hosted` or `macOS` |
|
||||
| macOS Big Sur 11.x x86_64/arm64 | `self-hosted` or `macOS` |
|
||||
|
||||
- Refer to the [self-hosted setup](#self-hosted-setup) to use the action on self-hosted runners.
|
||||
- Operating systems based on the above Ubuntu and Debian versions are also supported on best effort basis.
|
||||
@ -102,8 +102,8 @@ Both `GitHub-hosted` and `self-hosted` runners are supported by `setup-php` on t
|
||||
|
||||
On all supported OS/Platforms the following PHP versions can be set up as per the runner.
|
||||
|
||||
- PHP 5.3 to PHP 8.3 on GitHub-hosted runners.
|
||||
- PHP 5.6 to PHP 8.3 on self-hosted runners.
|
||||
- PHP 5.3 to PHP 8.4 on GitHub-hosted runners.
|
||||
- PHP 5.6 to PHP 8.4 on self-hosted runners.
|
||||
|
||||
| PHP Version | Stability | Release Support | Runner Support |
|
||||
|-------------|-----------|-----------------------|--------------------------------|
|
||||
@ -120,9 +120,10 @@ On all supported OS/Platforms the following PHP versions can be set up as per th
|
||||
| `8.1` | `Stable` | `Active` | `GitHub-hosted`, `self-hosted` |
|
||||
| `8.2` | `Stable` | `Active` | `GitHub-hosted`, `self-hosted` |
|
||||
| `8.3` | `Nightly` | `In development` | `GitHub-hosted`, `self-hosted` |
|
||||
| `8.4` | `Nightly` | `In development` | `GitHub-hosted`, `self-hosted` |
|
||||
|
||||
**Notes:**
|
||||
- Specifying `8.3` in `php-version` input installs a nightly build of `PHP 8.3.0-dev`. See [nightly build setup](#nightly-build-setup) for more information.
|
||||
- Specifying `8.3` and `8.4` in `php-version` input installs a nightly build of `PHP 8.3.0-dev` and `PHP 8.4.0-dev` respectively. See [nightly build setup](#nightly-build-setup) for more information.
|
||||
- To use JIT on `PHP 8.0` and above, refer to the [JIT configuration](#jit-configuration) section.
|
||||
|
||||
## :heavy_plus_sign: PHP Extension Support
|
||||
@ -224,7 +225,7 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
|
||||
|
||||
These tools can be set up globally using the `tools` input. It accepts a string in csv-format.
|
||||
|
||||
[`behat`], [`blackfire`], [`blackfire-player`], [`churn`], [`codeception`], [`composer`], [`composer-normalize`], [`composer-prefetcher`], [`composer-require-checker`], [`composer-unused`], [`cs2pr`], [`deployer`], [`flex`], [`grpc_php_plugin`], [`infection`], [`parallel-lint`], [`pecl`], [`phan`], [`phing`], [`phinx`], [`phive`], [`php-config`], [`php-cs-fixer`], [`phpcbf`], [`phpcpd`], [`phpcs`], [`phpdoc`] or [`phpDocumentor`], [`phpize`], [`phplint`], [`phpmd`], [`phpspec`], [`phpstan`], [`phpunit`], [`phpunit-bridge`], [`phpunit-polyfills`], [`pint`], [`prestissimo`], [`protoc`], [`psalm`], [`rector`], [`symfony`] or [`symfony-cli`], [`vapor`] or [`vapor-cli`], [`wp`] or [`wp-cli`]
|
||||
[`behat`], [`blackfire`], [`blackfire-player`], [`castor`], [`churn`], [`codeception`], [`composer`], [`composer-normalize`], [`composer-prefetcher`], [`composer-require-checker`], [`composer-unused`], [`cs2pr`], [`deployer`], [`flex`], [`grpc_php_plugin`], [`infection`], [`parallel-lint`], [`pecl`], [`phan`], [`phing`], [`phinx`], [`phive`], [`php-config`], [`php-cs-fixer`], [`phpcbf`], [`phpcpd`], [`phpcs`], [`phpdoc`] or [`phpDocumentor`], [`phpize`], [`phplint`], [`phpmd`], [`phpspec`], [`phpstan`], [`phpunit`], [`phpunit-bridge`], [`phpunit-polyfills`], [`pint`], [`prestissimo`], [`protoc`], [`psalm`], [`rector`], [`symfony`] or [`symfony-cli`], [`vapor`] or [`vapor-cli`], [`wp`] or [`wp-cli`]
|
||||
|
||||
```yaml
|
||||
- name: Setup PHP with tools
|
||||
@ -533,9 +534,9 @@ jobs:
|
||||
|
||||
### Nightly Build Setup
|
||||
|
||||
> Set up a nightly build of `PHP 8.3`.
|
||||
> Set up a nightly build of `PHP 8.3` or `PHP 8.4`.
|
||||
|
||||
- This PHP version is currently in active development and might contain bugs and breaking changes.
|
||||
- These PHP versions are currently in active development and might contain bugs and breaking changes.
|
||||
- Some user space extensions might not support this version currently.
|
||||
|
||||
```yaml
|
||||
@ -939,9 +940,10 @@ Examples of using `setup-php` with various PHP frameworks and packages.
|
||||
|
||||
- Use the `v2` tag as `setup-php` version. It is a rolling tag and is synced with the latest minor and patch releases. With `v2` you automatically get the bug fixes, security patches, new features and support for latest PHP releases.
|
||||
- Semantic release versions can also be used. It is recommended to [use dependabot](https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot "Setup Dependabot with GitHub Actions") with semantic versioning to keep the actions in your workflows up to date.
|
||||
- Commit SHA can also be used, but are not recommended. They have to be updated with every release manually, without which you will not get any bug fixes, security patches or new features.
|
||||
- Commit SHA can also be used, but are not recommended unless you set up tooling to update them with each release of the action.
|
||||
- A new major version of the action will only be tagged when there are breaking changes in the setup-php API i.e. inputs, outputs, and environment flags.
|
||||
- For debugging any issues `verbose` tag can be used temporarily. It outputs all the logs and is also synced with the latest releases.
|
||||
- It is highly discouraged to use the `master` branch as version, it might break your workflow after major releases as they have breaking changes.
|
||||
- It is highly discouraged to use the `main` branch as version, it might break your workflow after major releases as they have breaking changes.
|
||||
- If you are using the `v1` tag or a `1.x.y` version, you should [switch to v2](https://github.com/shivammathur/setup-php/wiki/Switch-to-v2 "Guide for switching from setup-php v1 to v2") as `v1` only gets critical bug fixes. Maintenance support for `v1` will be dropped with the last `PHP 8.0` release.
|
||||
|
||||
## :scroll: License
|
||||
@ -1028,6 +1030,7 @@ These companies generously provide setup-php their products and services to aid
|
||||
[`behat`]: https://docs.behat.org/en/latest/
|
||||
[`blackfire`]: https://blackfire.io/docs/php/index
|
||||
[`blackfire-player`]: https://blackfire.io/docs/builds-cookbooks/player
|
||||
[`castor`]: https://github.com/jolicode/castor
|
||||
[`churn`]: https://github.com/bmitch/churn-php
|
||||
[`codeception`]: https://codeception.com/
|
||||
[`composer`]: https://getcomposer.org/
|
||||
|
@ -19,9 +19,12 @@ describe('Extension tests', () => {
|
||||
${'pcov'} | ${'5.6'} | ${'Add-Log "$cross" "pcov" "pcov is not supported on PHP 5.6"'}
|
||||
${'pdo_oci'} | ${'7.4'} | ${'Add-Oci pdo_oci'}
|
||||
${'pecl_http'} | ${'7.4'} | ${'Add-Http'}
|
||||
${'pdo_sqlsrv'} | ${'7.4'} | ${'Add-Sqlsrv pdo_sqlsrv'}
|
||||
${'phalcon3'} | ${'7.2'} | ${'Add-Phalcon phalcon3'}
|
||||
${'phalcon4'} | ${'7.4'} | ${'Add-Phalcon phalcon4'}
|
||||
${'sqlite'} | ${'7.4'} | ${'Add-Extension sqlite3'}
|
||||
${'sqlsrv'} | ${'5.6'} | ${'Add-Extension sqlsrv'}
|
||||
${'sqlsrv'} | ${'7.4'} | ${'Add-Sqlsrv sqlsrv'}
|
||||
${'sqlsrv-1.2.3preview1'} | ${'7.4'} | ${'Add-Extension sqlsrv devel 1.2.3'}
|
||||
${'Xdebug'} | ${'7.4'} | ${'Add-Extension xdebug'}
|
||||
${'xdebug2'} | ${'7.2'} | ${'Add-Extension xdebug stable 2.9.8'}
|
||||
|
50
__tests__/packagist.test.ts
Normal file
50
__tests__/packagist.test.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import * as packagist from '../src/packagist';
|
||||
import nock = require('nock');
|
||||
|
||||
describe('search function', () => {
|
||||
const mockResponse = {
|
||||
packages: {
|
||||
'test-package': [
|
||||
{
|
||||
require: {
|
||||
php: '8.0.0'
|
||||
},
|
||||
version: '1.0.0'
|
||||
},
|
||||
{
|
||||
version: '2.0.0'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
test('should return the version if matching php version is found', async () => {
|
||||
nock('https://repo.packagist.org')
|
||||
.get('/p2/test-package.json')
|
||||
.reply(200, mockResponse);
|
||||
const result = await packagist.search('test-package', '8.0');
|
||||
expect(result).toBe('1.0.0');
|
||||
});
|
||||
|
||||
test('should return null if no matching php version is found', async () => {
|
||||
nock('https://repo.packagist.org')
|
||||
.get('/p2/test-package.json')
|
||||
.reply(200, mockResponse);
|
||||
const result = await packagist.search('test-package', '5.6');
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
test('should return null if fetch fails', async () => {
|
||||
nock('https://repo.packagist.org').get('/p2/test-package.json').reply(404);
|
||||
const result = await packagist.search('test-package', '8.0');
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
test('should return null if the response is empty', async () => {
|
||||
nock('https://repo.packagist.org')
|
||||
.get('/p2/test-package.json')
|
||||
.reply(200, {error: true, data: '[]'});
|
||||
const result = await packagist.search('test-package', '8.0');
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
@ -1,3 +1,4 @@
|
||||
import fs = require('fs');
|
||||
import * as tools from '../src/tools';
|
||||
|
||||
interface IData {
|
||||
@ -70,6 +71,22 @@ jest.mock('../src/fetch', () => ({
|
||||
)
|
||||
}));
|
||||
|
||||
jest.mock('../src/packagist', () => ({
|
||||
search: jest
|
||||
.fn()
|
||||
.mockImplementation(
|
||||
async (
|
||||
package_name: string,
|
||||
php_version: string
|
||||
): Promise<string | null> => {
|
||||
if (package_name === 'phpunit/phpunit') {
|
||||
return php_version + '.0';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
)
|
||||
}));
|
||||
|
||||
describe('Tools tests', () => {
|
||||
it.each`
|
||||
token | version
|
||||
@ -264,16 +281,18 @@ describe('Tools tests', () => {
|
||||
);
|
||||
|
||||
it.each`
|
||||
version | php_version | url
|
||||
${'latest'} | ${'8.1'} | ${'https://get.blackfire.io/blackfire-player.phar'}
|
||||
${'1.2.3'} | ${'7.4'} | ${'https://get.blackfire.io/blackfire-player-v1.2.3.phar'}
|
||||
${'latest'} | ${'7.4'} | ${'https://get.blackfire.io/blackfire-player-v1.22.0.phar'}
|
||||
${'latest'} | ${'5.5'} | ${'https://get.blackfire.io/blackfire-player-v1.9.3.phar'}
|
||||
${'latest'} | ${'7.0'} | ${'https://get.blackfire.io/blackfire-player-v1.9.3.phar'}
|
||||
os | version | php_version | url
|
||||
${'linux'} | ${'latest'} | ${'8.1'} | ${'https://get.blackfire.io/blackfire-player.phar'}
|
||||
${'linux'} | ${'1.2.3'} | ${'7.4'} | ${'https://get.blackfire.io/blackfire-player-v1.2.3.phar'}
|
||||
${'linux'} | ${'latest'} | ${'7.4'} | ${'https://get.blackfire.io/blackfire-player-v1.22.0.phar'}
|
||||
${'linux'} | ${'latest'} | ${'5.5'} | ${'https://get.blackfire.io/blackfire-player-v1.9.3.phar'}
|
||||
${'linux'} | ${'latest'} | ${'7.0'} | ${'https://get.blackfire.io/blackfire-player-v1.9.3.phar'}
|
||||
${'win32'} | ${'latest'} | ${'7.0'} | ${'blackfire-player is not a windows tool'}
|
||||
`(
|
||||
'checking addBlackfirePlayer: $version, $php_version',
|
||||
async ({version, php_version, url}) => {
|
||||
'checking addBlackfirePlayer: $os, $version, $php_version',
|
||||
async ({os, version, php_version, url}) => {
|
||||
const data = getData({
|
||||
os: os,
|
||||
tool: 'blackfire-player',
|
||||
domain: 'https://get.blackfire.io',
|
||||
version_prefix: 'v',
|
||||
@ -373,21 +392,23 @@ describe('Tools tests', () => {
|
||||
|
||||
it.each([
|
||||
[
|
||||
'blackfire, blackfire-player, churn, cs2pr, flex, grpc_php_plugin, parallel-lint, php-cs-fixer, phpDocumentor, phplint, phpstan, phpunit, pecl, phing, phinx, phinx:1.2.3, phive, phpunit-bridge, phpunit-polyfills, pint, php-config, phpize, protoc, symfony, vapor, wp',
|
||||
'blackfire, blackfire-player, box, churn, cs2pr, flex, grpc_php_plugin, parallel-lint, php-cs-fixer, php-scoper, phpDocumentor, phplint, phpstan, phpunit, pecl, phing, phinx, phinx:1.2.3, phive, phpunit-bridge, phpunit-polyfills, pint, php-config, phpize, protoc, symfony, vapor, wp',
|
||||
[
|
||||
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
|
||||
'add_blackfire',
|
||||
'add_tool https://get.blackfire.io/blackfire-player-v1.22.0.phar blackfire-player "-V"',
|
||||
'add_tool https://github.com/box-project/box/releases/latest/download/box.phar box "--version"',
|
||||
'add_tool https://github.com/bmitch/churn-php/releases/latest/download/churn.phar churn "-V"',
|
||||
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"',
|
||||
'add_composer_tool flex flex symfony/ global',
|
||||
'add_grpc_php_plugin latest',
|
||||
'add_tool https://github.com/php-parallel-lint/PHP-Parallel-Lint/releases/latest/download/parallel-lint.phar parallel-lint "--version"',
|
||||
'add_tool https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.2.1/php-cs-fixer.phar php-cs-fixer "-V"',
|
||||
'add_tool https://github.com/humbug/php-scoper/releases/latest/download/php-scoper.phar php-scoper "--version"',
|
||||
'add_tool https://github.com/phpDocumentor/phpDocumentor/releases/latest/download/phpDocumentor.phar phpDocumentor "--version"',
|
||||
'add_composer_tool phplint phplint overtrue/',
|
||||
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan "-V"',
|
||||
'add_tool https://phar.phpunit.de/phpunit.phar phpunit "--version"',
|
||||
'add_tool https://phar.phpunit.de/phpunit-7.4.0.phar phpunit "--version"',
|
||||
'add_pecl',
|
||||
'add_tool https://www.phing.info/get/phing-latest.phar phing "-v"',
|
||||
'add_composer_tool phinx phinx robmorgan/ scoped',
|
||||
@ -463,7 +484,7 @@ describe('Tools tests', () => {
|
||||
[
|
||||
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
|
||||
'Add-Blackfire',
|
||||
'Add-Tool https://get.blackfire.io/blackfire-player-v1.2.3.phar blackfire-player "-V"',
|
||||
'blackfire-player is not a windows tool',
|
||||
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"',
|
||||
'Add-Tool https://github.com/bmitch/churn-php/releases/latest/download/churn.phar churn "-V"',
|
||||
'Add-Tool https://deployer.org/deployer.phar deployer "-V"',
|
||||
@ -510,10 +531,36 @@ describe('Tools tests', () => {
|
||||
}
|
||||
);
|
||||
|
||||
it.each`
|
||||
version | os | uri
|
||||
${'latest'} | ${'linux'} | ${'releases/latest/download/castor.linux-amd64.phar'}
|
||||
${'0.5.1'} | ${'linux'} | ${'releases/download/v0.5.1/castor.linux-amd64.phar'}
|
||||
${'latest'} | ${'darwin'} | ${'releases/latest/download/castor.darwin-amd64.phar'}
|
||||
${'0.5.1'} | ${'darwin'} | ${'releases/download/v0.5.1/castor.darwin-amd64.phar'}
|
||||
${'latest'} | ${'win32'} | ${'releases/latest/download/castor.windows-amd64.phar'}
|
||||
${'0.5.1'} | ${'win32'} | ${'releases/download/v0.5.1/castor.windows-amd64.phar castor -V'}
|
||||
${'latest'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
|
||||
`('checking addCastor: $version, $os', async ({version, os, uri}) => {
|
||||
const data = getData({
|
||||
tool: 'castor',
|
||||
php_version: '8.1',
|
||||
version_prefix: 'v',
|
||||
version: version,
|
||||
os: os
|
||||
});
|
||||
if (os === 'win32' && version === '0.5.1') {
|
||||
fs.writeFileSync('castor.php', '');
|
||||
expect(await tools.addCastor(data)).toContain(uri);
|
||||
fs.unlinkSync('castor.php');
|
||||
} else {
|
||||
expect(await tools.addCastor(data)).toContain(uri);
|
||||
}
|
||||
});
|
||||
|
||||
it.each`
|
||||
tools_csv | script
|
||||
${'none'} | ${''}
|
||||
${'none, phpunit'} | ${'\nstep_log "Setup Tools"\nadd_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer latest\n\nadd_tool https://phar.phpunit.de/phpunit.phar phpunit "--version"'}
|
||||
${'none, phpunit'} | ${'\nstep_log "Setup Tools"\nadd_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer latest\n\nadd_tool https://phar.phpunit.de/phpunit-7.4.0.phar phpunit "--version"'}
|
||||
${'composer:preview'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-preview.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-preview.phar,https://getcomposer.org/composer-preview.phar composer preview'}
|
||||
${'composer, composer:v1'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-1.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-1.phar,https://getcomposer.org/composer-1.phar composer'}
|
||||
${'composer:v1, composer:preview, composer:snapshot'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-snapshot.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-snapshot.phar,https://getcomposer.org/composer.phar composer snapshot'}
|
||||
@ -540,4 +587,22 @@ describe('Tools tests', () => {
|
||||
process.env['GITHUB_TOKEN'] = token;
|
||||
expect(await tools.addTools(tools_csv, '7.4', 'linux')).toContain(script);
|
||||
});
|
||||
|
||||
it.each`
|
||||
tools_csv | php_version | resolved
|
||||
${'phpunit'} | ${'8.2'} | ${'/phpunit-8.2.0.phar'}
|
||||
${'phpunit'} | ${'8.1'} | ${'/phpunit-8.1.0.phar'}
|
||||
${'phpunit'} | ${'8.0'} | ${'/phpunit-8.0.0.phar'}
|
||||
${'phpunit'} | ${'7.3'} | ${'/phpunit-7.3.0.phar'}
|
||||
${'phpunit'} | ${'7.2'} | ${'/phpunit-7.2.0.phar'}
|
||||
${'phpunit'} | ${'7.1'} | ${'/phpunit-7.1.0.phar'}
|
||||
${'phpunit'} | ${'7.0'} | ${'/phpunit-7.0.0.phar'}
|
||||
`(
|
||||
'checking error: $tools_csv',
|
||||
async ({tools_csv, php_version, resolved}) => {
|
||||
expect(await tools.addTools(tools_csv, php_version, 'linux')).toContain(
|
||||
resolved
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import fs from 'fs';
|
||||
import fs = require('fs');
|
||||
import * as path from 'path';
|
||||
import * as utils from '../src/utils';
|
||||
|
||||
@ -282,6 +282,24 @@ describe('Utils tests', () => {
|
||||
process.env['php-version'] = '8.2';
|
||||
expect(await utils.readPHPVersion()).toBe('8.2');
|
||||
|
||||
delete process.env['php-version-file'];
|
||||
delete process.env['php-version'];
|
||||
|
||||
existsSync.mockReturnValueOnce(false).mockReturnValueOnce(true);
|
||||
readFileSync.mockReturnValue(
|
||||
'{ "platform-overrides": { "php": "7.3.25" } }'
|
||||
);
|
||||
expect(await utils.readPHPVersion()).toBe('7.3.25');
|
||||
|
||||
existsSync
|
||||
.mockReturnValueOnce(false)
|
||||
.mockReturnValueOnce(false)
|
||||
.mockReturnValueOnce(true);
|
||||
readFileSync.mockReturnValue(
|
||||
'{ "config": { "platform": { "php": "7.4.33" } } }'
|
||||
);
|
||||
expect(await utils.readPHPVersion()).toBe('7.4.33');
|
||||
|
||||
existsSync.mockClear();
|
||||
readFileSync.mockClear();
|
||||
});
|
||||
|
@ -31,5 +31,5 @@ outputs:
|
||||
php-version:
|
||||
description: 'PHP version in semver format'
|
||||
runs:
|
||||
using: 'node16'
|
||||
using: 'node20'
|
||||
main: 'dist/index.js'
|
||||
|
349
dist/index.js
vendored
349
dist/index.js
vendored
@ -304,6 +304,7 @@ async function addExtensionWindows(extension_csv, version) {
|
||||
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(version_extension):
|
||||
case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
|
||||
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
||||
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
|
||||
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'win32');
|
||||
return;
|
||||
@ -475,7 +476,8 @@ async function fetch(input_url, auth_token, redirect_count = 5) {
|
||||
const options = {
|
||||
hostname: url_object.hostname,
|
||||
path: url_object.pathname,
|
||||
headers: headers
|
||||
headers: headers,
|
||||
agent: new https.Agent({ keepAlive: false })
|
||||
};
|
||||
const req = https.get(options, (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
@ -592,6 +594,64 @@ exports.run = run;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5151:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.search = void 0;
|
||||
const cv = __importStar(__nccwpck_require__(4773));
|
||||
const fetch = __importStar(__nccwpck_require__(2387));
|
||||
async function search(package_name, php_version) {
|
||||
const response = await fetch.fetch(`https://repo.packagist.org/p2/${package_name}.json`);
|
||||
if (response.error || response.data === '[]') {
|
||||
return null;
|
||||
}
|
||||
const data = JSON.parse(response['data']);
|
||||
if (data && data.packages) {
|
||||
const versions = data.packages[package_name];
|
||||
versions.sort((a, b) => cv.compareVersions(b.version, a.version));
|
||||
const result = versions.find((versionData) => {
|
||||
if (versionData?.require?.php) {
|
||||
return versionData?.require?.php
|
||||
.split('|')
|
||||
.some(require => require && cv.satisfies(php_version + '.0', require));
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return result ? result.version : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
exports.search = search;
|
||||
//# sourceMappingURL=packagist.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 7740:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
@ -624,10 +684,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.addTools = exports.functionRecord = exports.getData = exports.addWPCLI = exports.addPHPUnitTools = exports.addPhive = exports.addPhing = exports.addPECL = exports.addDevTools = exports.addDeployer = exports.addComposer = exports.addBlackfirePlayer = exports.addPackage = exports.addArchive = exports.getPharUrl = exports.getUrl = exports.filterList = exports.getRelease = exports.getVersion = exports.getLatestVersion = exports.getSemverVersion = void 0;
|
||||
exports.addTools = exports.functionRecord = exports.getData = exports.addWPCLI = exports.addPHPUnitTools = exports.addPhive = exports.addPhing = exports.addPECL = exports.addDevTools = exports.addDeployer = exports.addComposer = exports.addCastor = exports.addBlackfirePlayer = exports.addPackage = exports.addArchive = exports.getPharUrl = exports.getUrl = exports.filterList = exports.getRelease = exports.getVersion = exports.getLatestVersion = exports.getSemverVersion = void 0;
|
||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||
const fetch = __importStar(__nccwpck_require__(2387));
|
||||
const packagist = __importStar(__nccwpck_require__(5151));
|
||||
const utils = __importStar(__nccwpck_require__(918));
|
||||
async function getSemverVersion(data) {
|
||||
const search = data['version_prefix'] + data['version'];
|
||||
@ -766,18 +827,33 @@ async function addPackage(data) {
|
||||
}
|
||||
exports.addPackage = addPackage;
|
||||
async function addBlackfirePlayer(data) {
|
||||
if (data['version'] == 'latest') {
|
||||
if (/5\.[5-6]|7\.0/.test(data['php_version'])) {
|
||||
data['version'] = '1.9.3';
|
||||
}
|
||||
else if (/7\.[1-4]|8\.0/.test(data['php_version'])) {
|
||||
data['version'] = '1.22.0';
|
||||
}
|
||||
switch (data['os']) {
|
||||
case 'win32':
|
||||
return await utils.addLog('$cross', data['tool'], data['tool'] + ' is not a windows tool', 'win32');
|
||||
default:
|
||||
if (data['version'] == 'latest') {
|
||||
if (/5\.[5-6]|7\.0/.test(data['php_version'])) {
|
||||
data['version'] = '1.9.3';
|
||||
}
|
||||
else if (/7\.[1-4]|8\.0/.test(data['php_version'])) {
|
||||
data['version'] = '1.22.0';
|
||||
}
|
||||
}
|
||||
data['url'] = await getPharUrl(data);
|
||||
return addArchive(data);
|
||||
}
|
||||
data['url'] = await getPharUrl(data);
|
||||
return addArchive(data);
|
||||
}
|
||||
exports.addBlackfirePlayer = addBlackfirePlayer;
|
||||
async function addCastor(data) {
|
||||
data['tool'] = 'castor.' + data['os'].replace('win32', 'windows') + '-amd64';
|
||||
data['url'] = await getUrl(data);
|
||||
data['tool'] = 'castor';
|
||||
data['version_parameter'] = fs_1.default.existsSync('castor.php')
|
||||
? data['version_parameter']
|
||||
: '';
|
||||
return await addArchive(data);
|
||||
}
|
||||
exports.addCastor = addCastor;
|
||||
async function addComposer(data) {
|
||||
const channel = data['version'].replace('latest', 'stable');
|
||||
const github = data['github'];
|
||||
@ -885,6 +961,11 @@ async function addPhive(data) {
|
||||
}
|
||||
exports.addPhive = addPhive;
|
||||
async function addPHPUnitTools(data) {
|
||||
if (data['version'] === 'latest') {
|
||||
data['version'] =
|
||||
(await packagist.search(data['packagist'], data['php_version'])) ??
|
||||
'latest';
|
||||
}
|
||||
data['url'] = await getPharUrl(data);
|
||||
return await addArchive(data);
|
||||
}
|
||||
@ -936,6 +1017,7 @@ async function getData(release, php_version, os) {
|
||||
data['extension'] ??= '.phar';
|
||||
data['os'] = os;
|
||||
data['php_version'] = php_version;
|
||||
data['packagist'] ??= data['repository'];
|
||||
data['prefix'] = data['github'] === data['domain'] ? 'releases' : '';
|
||||
data['verb'] = data['github'] === data['domain'] ? 'download' : '';
|
||||
data['fetch_latest'] ??= 'false';
|
||||
@ -950,6 +1032,7 @@ async function getData(release, php_version, os) {
|
||||
}
|
||||
exports.getData = getData;
|
||||
exports.functionRecord = {
|
||||
castor: addCastor,
|
||||
composer: addComposer,
|
||||
deployer: addDeployer,
|
||||
dev_tools: addDevTools,
|
||||
@ -1189,7 +1272,8 @@ async function CSVArray(values_csv) {
|
||||
.trim()
|
||||
.replace(/^["']|["']$|(?<==)["']/g, '')
|
||||
.replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'")
|
||||
.replace(/=(.*?)(=.*)/, "='$1$2'");
|
||||
.replace(/=(.*?)(=.*)/, "='$1$2'")
|
||||
.replace(/:\s*["'](.*?)/g, ':$1');
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
@ -1294,6 +1378,23 @@ async function readPHPVersion() {
|
||||
else if (versionFile !== '.php-version') {
|
||||
throw new Error(`Could not find '${versionFile}' file.`);
|
||||
}
|
||||
const composerLock = 'composer.lock';
|
||||
if (fs_1.default.existsSync(composerLock)) {
|
||||
const lockFileContents = JSON.parse(fs_1.default.readFileSync(composerLock, 'utf8'));
|
||||
if (lockFileContents['platform-overrides'] &&
|
||||
lockFileContents['platform-overrides']['php']) {
|
||||
return lockFileContents['platform-overrides']['php'];
|
||||
}
|
||||
}
|
||||
const composerJson = 'composer.json';
|
||||
if (fs_1.default.existsSync(composerJson)) {
|
||||
const composerFileContents = JSON.parse(fs_1.default.readFileSync(composerJson, 'utf8'));
|
||||
if (composerFileContents['config'] &&
|
||||
composerFileContents['config']['platform'] &&
|
||||
composerFileContents['config']['platform']['php']) {
|
||||
return composerFileContents['config']['platform']['php'];
|
||||
}
|
||||
}
|
||||
return 'latest';
|
||||
}
|
||||
exports.readPHPVersion = readPHPVersion;
|
||||
@ -1869,7 +1970,7 @@ class OidcClient {
|
||||
.catch(error => {
|
||||
throw new Error(`Failed to get ID Token. \n
|
||||
Error Code : ${error.statusCode}\n
|
||||
Error Message: ${error.result.message}`);
|
||||
Error Message: ${error.message}`);
|
||||
});
|
||||
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
|
||||
if (!id_token) {
|
||||
@ -4302,6 +4403,228 @@ function copyFile(srcFile, destFile, force) {
|
||||
}
|
||||
//# sourceMappingURL=io.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4773:
|
||||
/***/ (function(__unused_webpack_module, exports) {
|
||||
|
||||
(function (global, factory) {
|
||||
true ? factory(exports) :
|
||||
0;
|
||||
})(this, (function (exports) { 'use strict';
|
||||
|
||||
const semver = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;
|
||||
const validateAndParse = (version) => {
|
||||
if (typeof version !== 'string') {
|
||||
throw new TypeError('Invalid argument expected string');
|
||||
}
|
||||
const match = version.match(semver);
|
||||
if (!match) {
|
||||
throw new Error(`Invalid argument not valid semver ('${version}' received)`);
|
||||
}
|
||||
match.shift();
|
||||
return match;
|
||||
};
|
||||
const isWildcard = (s) => s === '*' || s === 'x' || s === 'X';
|
||||
const tryParse = (v) => {
|
||||
const n = parseInt(v, 10);
|
||||
return isNaN(n) ? v : n;
|
||||
};
|
||||
const forceType = (a, b) => typeof a !== typeof b ? [String(a), String(b)] : [a, b];
|
||||
const compareStrings = (a, b) => {
|
||||
if (isWildcard(a) || isWildcard(b))
|
||||
return 0;
|
||||
const [ap, bp] = forceType(tryParse(a), tryParse(b));
|
||||
if (ap > bp)
|
||||
return 1;
|
||||
if (ap < bp)
|
||||
return -1;
|
||||
return 0;
|
||||
};
|
||||
const compareSegments = (a, b) => {
|
||||
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
||||
const r = compareStrings(a[i] || '0', b[i] || '0');
|
||||
if (r !== 0)
|
||||
return r;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Compare [semver](https://semver.org/) version strings to find greater, equal or lesser.
|
||||
* This library supports the full semver specification, including comparing versions with different number of digits like `1.0.0`, `1.0`, `1`, and pre-release versions like `1.0.0-alpha`.
|
||||
* @param v1 - First version to compare
|
||||
* @param v2 - Second version to compare
|
||||
* @returns Numeric value compatible with the [Array.sort(fn) interface](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters).
|
||||
*/
|
||||
const compareVersions = (v1, v2) => {
|
||||
// validate input and split into segments
|
||||
const n1 = validateAndParse(v1);
|
||||
const n2 = validateAndParse(v2);
|
||||
// pop off the patch
|
||||
const p1 = n1.pop();
|
||||
const p2 = n2.pop();
|
||||
// validate numbers
|
||||
const r = compareSegments(n1, n2);
|
||||
if (r !== 0)
|
||||
return r;
|
||||
// validate pre-release
|
||||
if (p1 && p2) {
|
||||
return compareSegments(p1.split('.'), p2.split('.'));
|
||||
}
|
||||
else if (p1 || p2) {
|
||||
return p1 ? -1 : 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Compare [semver](https://semver.org/) version strings using the specified operator.
|
||||
*
|
||||
* @param v1 First version to compare
|
||||
* @param v2 Second version to compare
|
||||
* @param operator Allowed arithmetic operator to use
|
||||
* @returns `true` if the comparison between the firstVersion and the secondVersion satisfies the operator, `false` otherwise.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* compare('10.1.8', '10.0.4', '>'); // return true
|
||||
* compare('10.0.1', '10.0.1', '='); // return true
|
||||
* compare('10.1.1', '10.2.2', '<'); // return true
|
||||
* compare('10.1.1', '10.2.2', '<='); // return true
|
||||
* compare('10.1.1', '10.2.2', '>='); // return false
|
||||
* ```
|
||||
*/
|
||||
const compare = (v1, v2, operator) => {
|
||||
// validate input operator
|
||||
assertValidOperator(operator);
|
||||
// since result of compareVersions can only be -1 or 0 or 1
|
||||
// a simple map can be used to replace switch
|
||||
const res = compareVersions(v1, v2);
|
||||
return operatorResMap[operator].includes(res);
|
||||
};
|
||||
const operatorResMap = {
|
||||
'>': [1],
|
||||
'>=': [0, 1],
|
||||
'=': [0],
|
||||
'<=': [-1, 0],
|
||||
'<': [-1],
|
||||
'!=': [-1, 1],
|
||||
};
|
||||
const allowedOperators = Object.keys(operatorResMap);
|
||||
const assertValidOperator = (op) => {
|
||||
if (typeof op !== 'string') {
|
||||
throw new TypeError(`Invalid operator type, expected string but got ${typeof op}`);
|
||||
}
|
||||
if (allowedOperators.indexOf(op) === -1) {
|
||||
throw new Error(`Invalid operator, expected one of ${allowedOperators.join('|')}`);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Match [npm semver](https://docs.npmjs.com/cli/v6/using-npm/semver) version range.
|
||||
*
|
||||
* @param version Version number to match
|
||||
* @param range Range pattern for version
|
||||
* @returns `true` if the version number is within the range, `false` otherwise.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* satisfies('1.1.0', '^1.0.0'); // return true
|
||||
* satisfies('1.1.0', '~1.0.0'); // return false
|
||||
* ```
|
||||
*/
|
||||
const satisfies = (version, range) => {
|
||||
// clean input
|
||||
range = range.replace(/([><=]+)\s+/g, '$1');
|
||||
// handle multiple comparators
|
||||
if (range.includes('||')) {
|
||||
return range.split('||').some((r) => satisfies(version, r));
|
||||
}
|
||||
else if (range.includes(' - ')) {
|
||||
const [a, b] = range.split(' - ', 2);
|
||||
return satisfies(version, `>=${a} <=${b}`);
|
||||
}
|
||||
else if (range.includes(' ')) {
|
||||
return range
|
||||
.trim()
|
||||
.replace(/\s{2,}/g, ' ')
|
||||
.split(' ')
|
||||
.every((r) => satisfies(version, r));
|
||||
}
|
||||
// if no range operator then "="
|
||||
const m = range.match(/^([<>=~^]+)/);
|
||||
const op = m ? m[1] : '=';
|
||||
// if gt/lt/eq then operator compare
|
||||
if (op !== '^' && op !== '~')
|
||||
return compare(version, range, op);
|
||||
// else range of either "~" or "^" is assumed
|
||||
const [v1, v2, v3, , vp] = validateAndParse(version);
|
||||
const [r1, r2, r3, , rp] = validateAndParse(range);
|
||||
const v = [v1, v2, v3];
|
||||
const r = [r1, r2 !== null && r2 !== void 0 ? r2 : 'x', r3 !== null && r3 !== void 0 ? r3 : 'x'];
|
||||
// validate pre-release
|
||||
if (rp) {
|
||||
if (!vp)
|
||||
return false;
|
||||
if (compareSegments(v, r) !== 0)
|
||||
return false;
|
||||
if (compareSegments(vp.split('.'), rp.split('.')) === -1)
|
||||
return false;
|
||||
}
|
||||
// first non-zero number
|
||||
const nonZero = r.findIndex((v) => v !== '0') + 1;
|
||||
// pointer to where segments can be >=
|
||||
const i = op === '~' ? 2 : nonZero > 1 ? nonZero : 1;
|
||||
// before pointer must be equal
|
||||
if (compareSegments(v.slice(0, i), r.slice(0, i)) !== 0)
|
||||
return false;
|
||||
// after pointer must be >=
|
||||
if (compareSegments(v.slice(i), r.slice(i)) === -1)
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Validate [semver](https://semver.org/) version strings.
|
||||
*
|
||||
* @param version Version number to validate
|
||||
* @returns `true` if the version number is a valid semver version number, `false` otherwise.
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* validate('1.0.0-rc.1'); // return true
|
||||
* validate('1.0-rc.1'); // return false
|
||||
* validate('foo'); // return false
|
||||
* ```
|
||||
*/
|
||||
const validate = (version) => typeof version === 'string' && /^[v\d]/.test(version) && semver.test(version);
|
||||
/**
|
||||
* Validate [semver](https://semver.org/) version strings strictly. Will not accept wildcards and version ranges.
|
||||
*
|
||||
* @param version Version number to validate
|
||||
* @returns `true` if the version number is a valid semver version number `false` otherwise
|
||||
*
|
||||
* @example
|
||||
* ```
|
||||
* validate('1.0.0-rc.1'); // return true
|
||||
* validate('1.0-rc.1'); // return false
|
||||
* validate('foo'); // return false
|
||||
* ```
|
||||
*/
|
||||
const validateStrict = (version) => typeof version === 'string' &&
|
||||
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/.test(version);
|
||||
|
||||
exports.compare = compare;
|
||||
exports.compareVersions = compareVersions;
|
||||
exports.satisfies = satisfies;
|
||||
exports.validate = validate;
|
||||
exports.validateStrict = validateStrict;
|
||||
|
||||
}));
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4294:
|
||||
|
@ -11,7 +11,7 @@ jobs:
|
||||
php-versions: ['7.4', '8.0', '8.1']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -19,7 +19,7 @@ jobs:
|
||||
# blackfire-player supports PHP >= 5.5
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -19,7 +19,7 @@ jobs:
|
||||
# Blackfire supports PHP >= 5.3 on Ubuntu and macOS, and PHP >= 5.4 on Windows
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -28,7 +28,7 @@ jobs:
|
||||
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
@ -75,7 +75,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
@ -108,7 +108,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -28,7 +28,7 @@ jobs:
|
||||
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
@ -75,7 +75,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
@ -108,7 +108,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -11,7 +11,7 @@ jobs:
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
@ -47,7 +47,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
@ -79,7 +79,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -10,7 +10,7 @@ jobs:
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -10,7 +10,7 @@ jobs:
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -37,7 +37,7 @@ jobs:
|
||||
php-versions: ['7.4', '8.0', '8.1']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -39,7 +39,7 @@ jobs:
|
||||
php-versions: ['7.4', '8.0', '8.1']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -12,7 +12,7 @@ jobs:
|
||||
php-versions: ['7.4', '8.0', '8.1']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -37,7 +37,7 @@ jobs:
|
||||
php-versions: ['7.4', '8.0', '8.1']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -39,7 +39,7 @@ jobs:
|
||||
php-versions: ['7.4', '8.0', '8.1']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -12,7 +12,7 @@ jobs:
|
||||
php-versions: ['7.4', '8.0', '8.1']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -36,7 +36,7 @@ jobs:
|
||||
# php-versions: ['7.0', '7.1', '7.2', '7.3']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -37,7 +37,7 @@ jobs:
|
||||
# php-versions: ['7.0', '7.1', '7.2', '7.3']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -12,7 +12,7 @@ jobs:
|
||||
node-versions: ['16']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v1
|
||||
|
@ -10,7 +10,7 @@ jobs:
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -23,7 +23,7 @@ jobs:
|
||||
php-versions: ['7.4', '8.0', '8.1']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -23,7 +23,7 @@ jobs:
|
||||
php-versions: ['7.4', '8.0', '8.1']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -12,7 +12,7 @@ jobs:
|
||||
php-versions: ['7.4', '8.0', '8.1']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Docs: https://github.com/shivammathur/setup-php
|
||||
- name: Setup PHP
|
||||
|
@ -29,7 +29,7 @@ jobs:
|
||||
php-versions: ['7.4', '8.0']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set Node.js 10.x
|
||||
uses: actions/setup-node@v1
|
||||
|
@ -29,7 +29,7 @@ jobs:
|
||||
php-versions: ['7.4', '8.0']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set Node.js 10.x
|
||||
uses: actions/setup-node@v1
|
||||
|
5457
package-lock.json
generated
5457
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setup-php",
|
||||
"version": "2.25.2",
|
||||
"version": "2.27.1",
|
||||
"private": false,
|
||||
"description": "Setup PHP for use with GitHub Actions",
|
||||
"main": "lib/install.js",
|
||||
@ -34,28 +34,29 @@
|
||||
"author": "shivammathur",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/core": "^1.10.1",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/io": "^1.1.3"
|
||||
"@actions/io": "^1.1.3",
|
||||
"compare-versions": "^6.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.1",
|
||||
"@types/node": "^20.2.3",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
||||
"@typescript-eslint/parser": "^5.59.7",
|
||||
"@vercel/ncc": "^0.36.1",
|
||||
"eslint": "^8.41.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-jest": "^27.2.1",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"jest": "^29.5.0",
|
||||
"jest-circus": "^29.5.0",
|
||||
"nock": "^13.3.1",
|
||||
"prettier": "^2.8.8",
|
||||
"simple-git-hooks": "^2.8.1",
|
||||
"ts-jest": "^29.1.0",
|
||||
"typescript": "^5.0.4"
|
||||
"@types/jest": "^29.5.7",
|
||||
"@types/node": "^20.8.10",
|
||||
"@typescript-eslint/eslint-plugin": "^6.10.0",
|
||||
"@typescript-eslint/parser": "^6.10.0",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"eslint": "^8.53.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-plugin-import": "^2.29.0",
|
||||
"eslint-plugin-jest": "^27.6.0",
|
||||
"eslint-plugin-prettier": "^5.0.1",
|
||||
"jest": "^29.7.0",
|
||||
"jest-circus": "^29.7.0",
|
||||
"nock": "^13.3.8",
|
||||
"prettier": "^3.0.3",
|
||||
"simple-git-hooks": "^2.9.0",
|
||||
"ts-jest": "^29.1.1",
|
||||
"typescript": "^5.2.2"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/shivammathur/setup-php/issues"
|
||||
|
@ -1,4 +1,13 @@
|
||||
{
|
||||
"box": {
|
||||
"type": "phar",
|
||||
"repository": "box-project/box",
|
||||
"packagist": "humbug/box",
|
||||
"extension": ".phar",
|
||||
"domain": "https://github.com",
|
||||
"version_prefix": "",
|
||||
"version_parameter": "--version"
|
||||
},
|
||||
"churn": {
|
||||
"type": "phar",
|
||||
"repository": "bmitch/churn-php",
|
||||
@ -64,6 +73,15 @@
|
||||
"version_prefix": "v",
|
||||
"version_parameter": "-V"
|
||||
},
|
||||
"php-scoper": {
|
||||
"type": "phar",
|
||||
"repository": "humbug/php-scoper",
|
||||
"packagist": "humbug/php-scoper",
|
||||
"extension": ".phar",
|
||||
"domain": "https://github.com",
|
||||
"version_prefix": "",
|
||||
"version_parameter": "--version"
|
||||
},
|
||||
"phpcbf": {
|
||||
"type": "phar",
|
||||
"repository": "squizlabs/PHP_CodeSniffer",
|
||||
@ -222,6 +240,14 @@
|
||||
"version_prefix": "v",
|
||||
"version_parameter": "-V"
|
||||
},
|
||||
"castor": {
|
||||
"type": "custom-function",
|
||||
"domain": "https://github.com",
|
||||
"repository": "jolicode/castor",
|
||||
"function": "castor",
|
||||
"version_prefix": "v",
|
||||
"version_parameter": "-V"
|
||||
},
|
||||
"composer": {
|
||||
"type": "custom-function",
|
||||
"domain": "https://getcomposer.org",
|
||||
@ -268,6 +294,7 @@
|
||||
"phpunit": {
|
||||
"type": "custom-function",
|
||||
"repository": "sebastianbergmann/phpunit",
|
||||
"packagist": "phpunit/phpunit",
|
||||
"domain": "https://phar.phpunit.de",
|
||||
"function": "phpunit",
|
||||
"version_prefix": "",
|
||||
|
@ -13,6 +13,7 @@
|
||||
"fetch_latest": "true",
|
||||
"function": "function_name",
|
||||
"repository": "user/tool",
|
||||
"packagist": "user/tool",
|
||||
"scope": "global, scoped",
|
||||
"type": "phar, composer, custom-package or custom-function",
|
||||
"version_parameter": "--version",
|
||||
@ -77,6 +78,15 @@
|
||||
"user/tool"
|
||||
]
|
||||
},
|
||||
"packagist": {
|
||||
"$id": "#/items/properties/packagist",
|
||||
"type": "string",
|
||||
"title": "The repository schema",
|
||||
"description": "Packagist repository of the tool in case different from repository.",
|
||||
"examples": [
|
||||
"user/tool"
|
||||
]
|
||||
},
|
||||
"scope": {
|
||||
"$id": "#/items/properties/scope",
|
||||
"type": "string",
|
||||
|
@ -150,6 +150,7 @@ export async function addExtensionWindows(
|
||||
version_extension
|
||||
):
|
||||
case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
|
||||
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
||||
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
|
||||
version_extension
|
||||
):
|
||||
|
@ -26,7 +26,8 @@ export async function fetch(
|
||||
const options: https.RequestOptions = {
|
||||
hostname: url_object.hostname,
|
||||
path: url_object.pathname,
|
||||
headers: headers
|
||||
headers: headers,
|
||||
agent: new https.Agent({keepAlive: false})
|
||||
};
|
||||
const req = https.get(options, (res: IncomingMessage) => {
|
||||
if (res.statusCode === 200) {
|
||||
|
37
src/packagist.ts
Normal file
37
src/packagist.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import * as cv from 'compare-versions';
|
||||
import * as fetch from './fetch';
|
||||
|
||||
type RS = Record<string, string>;
|
||||
type RSRS = Record<string, RS>;
|
||||
|
||||
export async function search(
|
||||
package_name: string,
|
||||
php_version: string
|
||||
): Promise<string | null> {
|
||||
const response = await fetch.fetch(
|
||||
`https://repo.packagist.org/p2/${package_name}.json`
|
||||
);
|
||||
if (response.error || response.data === '[]') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const data = JSON.parse(response['data']);
|
||||
if (data && data.packages) {
|
||||
const versions = data.packages[package_name];
|
||||
versions.sort((a: RS, b: RS) => cv.compareVersions(b.version, a.version));
|
||||
|
||||
const result = versions.find((versionData: RSRS) => {
|
||||
if (versionData?.require?.php) {
|
||||
return versionData?.require?.php
|
||||
.split('|')
|
||||
.some(
|
||||
require => require && cv.satisfies(php_version + '.0', require)
|
||||
);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
return result ? result.version : null;
|
||||
}
|
||||
return null;
|
||||
}
|
@ -43,7 +43,9 @@ copy_brew_extensions() {
|
||||
extension_file="${brew_prefix:?}/opt/$dependency/$(get_extension_from_formula "${dependency%@*}").so"
|
||||
[ -e "$extension_file" ] && sudo cp "$extension_file" "$ext_dir"
|
||||
done
|
||||
sudo find -- "$brew_prefix"/Cellar/"$formula"@"$version" -name "*.dylib" -exec cp {} "$ext_dir" \;
|
||||
if [ -d "$brew_prefix"/Cellar/"$formula"@"$version" ]; then
|
||||
sudo find -- "$brew_prefix"/Cellar/"$formula"@"$version" -name "*.dylib" -exec cp {} "$ext_dir" \;
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to install a php extension from shivammathur/extensions tap.
|
||||
@ -60,8 +62,7 @@ add_brew_extension() {
|
||||
sudo mv "$tap_dir"/"$ext_tap"/.github/deps/"$formula"/* "${core_repo:?}/Formula/" 2>/dev/null || true
|
||||
update_dependencies >/dev/null 2>&1
|
||||
disable_dependency_extensions "$extension" >/dev/null 2>&1
|
||||
brew install -f "$ext_tap/$formula@$version" >/dev/null 2>&1
|
||||
copy_brew_extensions "$formula"
|
||||
(brew install -f "$ext_tap/$formula@$version" >/dev/null 2>&1 && copy_brew_extensions "$formula") || pecl_install "$extension" >/dev/null 2>&1
|
||||
add_extension_log "$extension" "Installed and enabled"
|
||||
fi
|
||||
}
|
||||
@ -104,6 +105,15 @@ link_libraries() {
|
||||
done
|
||||
}
|
||||
|
||||
# Link opcache extension to extensions directory.
|
||||
link_opcache() {
|
||||
opcache_ini="$brew_prefix"/etc/php/"$version"/conf.d/ext-opcache.ini
|
||||
if [ -e "$opcache_ini" ]; then
|
||||
opcache_ext=$(grep -Eo "zend_extension.*opcache.*\.so" "$opcache_ini" | cut -d '"' -f 2)
|
||||
sudo ln -sf "$opcache_ext" "$ext_dir"
|
||||
fi
|
||||
}
|
||||
|
||||
# Patch brew to overwrite packages.
|
||||
patch_brew() {
|
||||
formula_installer="${brew_repo:?}"/Library/Homebrew/formula_installer.rb
|
||||
@ -116,7 +126,8 @@ patch_brew() {
|
||||
# Helper function to update the dependencies.
|
||||
update_dependencies_helper() {
|
||||
dependency=$1
|
||||
get -q -n "$core_repo/Formula/$dependency.rb" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$dependency.rb"
|
||||
[[ "${dependency:0:3}" = "lib" ]] && prefix=lib || prefix="${dependency:0:1}"
|
||||
get -q -n "$core_repo/Formula/$prefix/$dependency.rb" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$prefix/$dependency.rb"
|
||||
link_libraries "$dependency"
|
||||
}
|
||||
|
||||
@ -153,8 +164,11 @@ fix_dependencies() {
|
||||
|
||||
# Function to get PHP version if it is already installed using Homebrew.
|
||||
get_brewed_php() {
|
||||
php_cellar="$brew_prefix"/Cellar/php
|
||||
if [ -d "$php_cellar" ] && ! [[ "$(find "$php_cellar" -maxdepth 1 -name "$version*" | wc -l 2>/dev/null)" -eq 0 ]]; then
|
||||
cellar="$brew_prefix"/Cellar
|
||||
php_cellar="$cellar"/php
|
||||
if [ -d "$cellar" ] && ! [[ "$(find "$cellar" -maxdepth 1 -name "php@$version*" | wc -l 2>/dev/null)" -eq 0 ]]; then
|
||||
php_semver | cut -c 1-3
|
||||
elif [ -d "$php_cellar" ] && ! [[ "$(find "$php_cellar" -maxdepth 1 -name "$version*" | wc -l 2>/dev/null)" -eq 0 ]]; then
|
||||
php_semver | cut -c 1-3
|
||||
else
|
||||
echo 'false';
|
||||
@ -233,6 +247,7 @@ setup_php() {
|
||||
semver="$(php_semver)"
|
||||
extra_version="$(php_extra_version)"
|
||||
configure_php
|
||||
link_opcache
|
||||
set_output "php-version" "$semver"
|
||||
if [ "${semver%.*}" != "$version" ]; then
|
||||
add_log "${cross:?}" "PHP" "Could not setup PHP $version"
|
||||
@ -257,6 +272,7 @@ export HOMEBREW_NO_AUTO_UPDATE=1
|
||||
export HOMEBREW_NO_ENV_HINTS=1
|
||||
export HOMEBREW_NO_INSTALL_CLEANUP=1
|
||||
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
|
||||
export HOMEBREW_NO_INSTALL_FROM_API=1
|
||||
|
||||
# shellcheck source=.
|
||||
. "${scripts:?}"/unix.sh
|
||||
|
@ -1,3 +1,16 @@
|
||||
# Function to check if extension is enabled.
|
||||
Function Test-Extension() {
|
||||
Param (
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
[string]
|
||||
$extension
|
||||
)
|
||||
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
|
||||
return $null -ne $extension_info
|
||||
}
|
||||
|
||||
# Function to add extension log.
|
||||
Function Add-ExtensionLog() {
|
||||
Param (
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
@ -7,8 +20,7 @@ Function Add-ExtensionLog() {
|
||||
[ValidateNotNull()]
|
||||
$message
|
||||
)
|
||||
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
|
||||
if ($null -ne $extension_info -and ($extension_info.State -eq 'Enabled' -or $extension_info.State -eq 'Builtin')) {
|
||||
if (Test-Extension $extension) {
|
||||
Add-Log $tick $extension $message
|
||||
} else {
|
||||
Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )"
|
||||
|
@ -188,6 +188,7 @@ pecl_install() {
|
||||
yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f -D "$(parse_pecl_configure_options "$suffix_opts")" "$extension" >/dev/null 2>&1
|
||||
fi
|
||||
local exit_code=$?
|
||||
sudo pecl info "$extension" | grep -iq 'zend extension' && prefix=zend_extension
|
||||
enable_extension "${extension%-*}" "$prefix"
|
||||
return "$exit_code"
|
||||
}
|
||||
@ -202,7 +203,7 @@ add_pecl_extension() {
|
||||
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
||||
fi
|
||||
ext_version=$(php -r "echo phpversion('$extension');")
|
||||
if [ "${ext_version/-/}" = "$pecl_version" ]; then
|
||||
if check_extension "$extension" && [[ -z "$pecl_version" || (-n "$pecl_version" && "${ext_version/-/}" == "$pecl_version") ]]; then
|
||||
add_log "${tick:?}" "$extension" "Enabled"
|
||||
else
|
||||
[ -n "$pecl_version" ] && pecl_version="-$pecl_version"
|
||||
|
@ -32,6 +32,8 @@ get_couchbase_version() {
|
||||
echo couchbase-3.0.4
|
||||
elif [ "${version:?}" = '7.3' ]; then
|
||||
echo couchbase-3.2.2
|
||||
elif [ "${version:?}" = '7.4' ]; then
|
||||
echo couchbase-4.1.0
|
||||
else
|
||||
echo couchbase
|
||||
fi
|
||||
@ -55,6 +57,9 @@ add_couchbase() {
|
||||
else
|
||||
if [ "$ext" = "couchbase" ]; then
|
||||
ext="couchbase-$(get_pecl_version "couchbase" "stable")"
|
||||
n_proc="$(nproc)"
|
||||
export COUCHBASE_SUFFIX_OPTS="CMAKE_BUILD_TYPE=Release"
|
||||
export CMAKE_BUILD_PARALLEL_LEVEL="$n_proc"
|
||||
add_extension_from_source couchbase https://pecl.php.net couchbase couchbase "${ext##*-}" extension pecl >/dev/null 2>&1
|
||||
else
|
||||
pecl_install "${ext}" >/dev/null 2>&1
|
||||
|
@ -15,8 +15,9 @@ add_intl() {
|
||||
if [ "$icu" != "$supported_version" ]; then
|
||||
add_log "${cross:?}" "intl" "ICU $icu is not supported"
|
||||
else
|
||||
[ "${ts:?}" = 'zts' ] && suffix='-zts'
|
||||
install_icu "$icu" >/dev/null 2>&1
|
||||
get -q -n "${ext_dir:?}/intl.so" "https://github.com/shivammathur/icu-intl/releases/download/intl/php${version:?}-intl-$icu.so"
|
||||
get -q -n "${ext_dir:?}/intl.so" "https://github.com/shivammathur/icu-intl/releases/download/intl/php${version:?}-intl-$icu$suffix.so"
|
||||
enable_extension intl extension
|
||||
add_extension_log intl "Installed and enabled with ICU $icu"
|
||||
fi
|
||||
|
69
src/scripts/extensions/sqlsrv.ps1
Normal file
69
src/scripts/extensions/sqlsrv.ps1
Normal file
@ -0,0 +1,69 @@
|
||||
# Function to get sqlsrv extension version.
|
||||
Function Get-SqlsrvReleaseVersion() {
|
||||
if ($version -le '7.2') {
|
||||
# Use the releases from PECL for these versions
|
||||
return null;
|
||||
} elseif($version -eq '7.3') {
|
||||
return '5.9.0'
|
||||
} elseif ($version -eq '7.4') {
|
||||
return '5.10.1'
|
||||
} else {
|
||||
return 'latest'
|
||||
}
|
||||
}
|
||||
|
||||
# Function to get sqlsrv extension release URL.
|
||||
Function Get-SqlsrvReleaseUrl()
|
||||
{
|
||||
$extensionVersion = Get-SqlsrvReleaseVersion
|
||||
if($extensionVersion) {
|
||||
$repo = "$github/microsoft/msphpsql"
|
||||
if($extensionVersion -eq 'latest') {
|
||||
return "$repo/releases/latest/download/Windows-$version.zip"
|
||||
} else {
|
||||
return "$repo/releases/download/v$extensionVersion/Windows-$version.zip"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Function to add sqlsrv extension from GitHub.
|
||||
Function Add-SqlsrvFromGithub()
|
||||
{
|
||||
Param (
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
[string]
|
||||
$extension
|
||||
)
|
||||
$zipUrl = SqlsrvReleaseUrl
|
||||
if($zipUrl) {
|
||||
$nts = if (!$installed.ThreadSafe) { "nts" } else { "ts" }
|
||||
$noDotVersion = $version.replace('.', '')
|
||||
$extensionFilePath = "Windows-$version\$arch\php_${extension}_${noDotVersion}_${nts}.dll"
|
||||
Get-File -Url $zipUrl -OutFile $ENV:RUNNER_TOOL_CACHE\sqlsrv.zip > $null 2>&1
|
||||
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\sqlsrv.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\sqlsrv -Force > $null 2>&1
|
||||
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\sqlsrv\$extensionFilePath" -Destination "$ext_dir\php_$extension.dll"
|
||||
Enable-PhpExtension -Extension $extension -Path $php_dir
|
||||
}
|
||||
}
|
||||
|
||||
# Function to add sqlsrv extension.
|
||||
Function Add-Sqlsrv() {
|
||||
Param (
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
[string]
|
||||
$extension
|
||||
)
|
||||
$status = 'Enabled'
|
||||
if (Test-Path $ext_dir\php_$extension.dll) {
|
||||
Enable-PhpExtension -Extension $extension -Path $php_dir
|
||||
} else {
|
||||
Add-SqlsrvFromGithub $extension >$null 2>&1
|
||||
if (-not(Test-Extension $extension)) {
|
||||
Add-Extension $extension >$null 2>&1
|
||||
}
|
||||
$status = 'Installed and enabled'
|
||||
}
|
||||
Add-ExtensionLog $extension $status
|
||||
}
|
@ -2,8 +2,11 @@
|
||||
get_sqlsrv_version() {
|
||||
if [[ "${version:?}" =~ 7.[0-3] ]]; then
|
||||
echo '5.9.0'
|
||||
else
|
||||
elif [[ "${version:?}" =~ 7.4 ]]; then
|
||||
echo '5.10.1'
|
||||
else
|
||||
# Return an empty string so that pecl will install the latest version.
|
||||
echo ''
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ Function Get-ToolVersion() {
|
||||
Param (
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
$tool,
|
||||
[Parameter(Position = 1, Mandatory = $true)]
|
||||
[Parameter(Position = 1, Mandatory = $false)]
|
||||
$param
|
||||
)
|
||||
$alp = "[a-zA-Z0-9\.]"
|
||||
@ -72,7 +72,9 @@ Function Get-ToolVersion() {
|
||||
Set-Variable -Name 'composer_version' -Value $composer_version -Scope Global
|
||||
return "$composer_version"
|
||||
}
|
||||
return . $tool $param 2> $null | ForEach-Object { $_ -replace "composer $version_regex", '' } | Select-String -Pattern $version_regex | Select-Object -First 1 | ForEach-Object { $_.matches.Value }
|
||||
if($null -ne $param) {
|
||||
return . $tool $param 2> $null | ForEach-Object { $_ -replace "composer $version_regex", '' } | Select-String -Pattern $version_regex | Select-Object -First 1 | ForEach-Object { $_.matches.Value }
|
||||
}
|
||||
}
|
||||
|
||||
# Helper function to configure tools.
|
||||
@ -83,7 +85,9 @@ Function Add-ToolsHelper() {
|
||||
$tool
|
||||
)
|
||||
$extensions = @();
|
||||
if($tool -eq "codeception") {
|
||||
if($tool -eq "box") {
|
||||
$extensions += @('iconv', 'mbstring', 'phar', 'sodium')
|
||||
} elseif($tool -eq "codeception") {
|
||||
$extensions += @('json', 'mbstring')
|
||||
Copy-Item $env:codeception_bin\codecept.bat -Destination $env:codeception_bin\codeception.bat
|
||||
} elseif($tool -eq "composer") {
|
||||
@ -135,8 +139,7 @@ Function Add-Tool() {
|
||||
[Parameter(Position = 1, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
$tool,
|
||||
[Parameter(Position = 2, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
[Parameter(Position = 2, Mandatory = $false)]
|
||||
$ver_param
|
||||
)
|
||||
if (Test-Path $bin_dir\$tool) {
|
||||
|
@ -19,7 +19,7 @@ get_tool_version() {
|
||||
composer_version="$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")"
|
||||
fi
|
||||
echo "$composer_version" | sudo tee /tmp/composer_version
|
||||
else
|
||||
elif [ -n "$param" ]; then
|
||||
$tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1
|
||||
fi
|
||||
}
|
||||
@ -72,7 +72,11 @@ set_composer_auth() {
|
||||
add_tools_helper() {
|
||||
tool=$1
|
||||
extensions=()
|
||||
if [ "$tool" = "codeception" ]; then
|
||||
if [ "$tool" = "blackfire-player" ]; then
|
||||
extensions+=(uuid)
|
||||
elif [ "$tool" = "box" ]; then
|
||||
extensions+=(iconv mbstring phar sodium)
|
||||
elif [ "$tool" = "codeception" ]; then
|
||||
extensions+=(json mbstring)
|
||||
sudo ln -s "$scoped_dir"/vendor/bin/codecept "$scoped_dir"/vendor/bin/codeception
|
||||
elif [ "$tool" = "composer" ]; then
|
||||
@ -128,6 +132,9 @@ add_tool() {
|
||||
tool=$2
|
||||
ver_param=$3
|
||||
tool_path="$tool_path_dir/$tool"
|
||||
if ! [ -d "$tool_path_dir" ]; then
|
||||
sudo mkdir -p "$tool_path_dir"
|
||||
fi
|
||||
add_path "$tool_path_dir"
|
||||
if [ -e "$tool_path" ]; then
|
||||
sudo cp -aL "$tool_path" /tmp/"$tool"
|
||||
|
@ -31,10 +31,6 @@ set_base_version() {
|
||||
else
|
||||
set_base_version_codename
|
||||
set_base_version_id
|
||||
|
||||
# Remove once PPAs start having bookworm releases
|
||||
[ "$VERSION_CODENAME" = 'bookworm' ] && VERSION_CODENAME="bullseye"
|
||||
|
||||
printf "ID=%s\nVERSION_ID=%s\nVERSION_CODENAME=%s\n" "$ID" "$VERSION_ID" "$VERSION_CODENAME" | tee /tmp/os-release >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
@ -59,7 +55,7 @@ update_lists() {
|
||||
if [[ -n "$ppa" && -n "$ppa_search" ]]; then
|
||||
list="$list_dir"/"$(basename "$(grep -lr "$ppa_search" "$list_dir")")"
|
||||
status_file=/tmp/"${ppa/\//_}"
|
||||
elif grep -Eq '^deb ' "$list_file"; then
|
||||
elif [ -e "$list_file" ] && grep -Eq '^deb ' "$list_file"; then
|
||||
list="$list_file"
|
||||
fi
|
||||
if [ ! -e "$status_file" ]; then
|
||||
|
@ -53,7 +53,7 @@ read_env() {
|
||||
[ "${debug:-${DEBUG:-false}}" = "true" ] && debug=debug && update=true || debug=release
|
||||
[ "${phpts:-${PHPTS:-nts}}" = "ts" ] && ts=zts && update=true || ts=nts
|
||||
fail_fast="${fail_fast:-${FAIL_FAST:-false}}"
|
||||
[[ -z "${ImageOS}" && -z "${ImageVersion}" ]] && _runner=self-hosted || _runner=github
|
||||
[[ -z "${ImageOS}" && -z "${ImageVersion}" || -n ${ACT} ]] && _runner=self-hosted || _runner=github
|
||||
runner="${runner:-${RUNNER:-$_runner}}"
|
||||
|
||||
if [[ "$runner" = "github" && $_runner = "self-hosted" ]]; then
|
||||
|
49
src/tools.ts
49
src/tools.ts
@ -1,6 +1,7 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import * as fetch from './fetch';
|
||||
import * as packagist from './packagist';
|
||||
import * as utils from './utils';
|
||||
|
||||
type RS = Record<string, string>;
|
||||
@ -218,15 +219,40 @@ export async function addPackage(data: RS): Promise<string> {
|
||||
* @param data
|
||||
*/
|
||||
export async function addBlackfirePlayer(data: RS): Promise<string> {
|
||||
if (data['version'] == 'latest') {
|
||||
if (/5\.[5-6]|7\.0/.test(data['php_version'])) {
|
||||
data['version'] = '1.9.3';
|
||||
} else if (/7\.[1-4]|8\.0/.test(data['php_version'])) {
|
||||
data['version'] = '1.22.0';
|
||||
}
|
||||
switch (data['os']) {
|
||||
case 'win32':
|
||||
return await utils.addLog(
|
||||
'$cross',
|
||||
data['tool'],
|
||||
data['tool'] + ' is not a windows tool',
|
||||
'win32'
|
||||
);
|
||||
default:
|
||||
if (data['version'] == 'latest') {
|
||||
if (/5\.[5-6]|7\.0/.test(data['php_version'])) {
|
||||
data['version'] = '1.9.3';
|
||||
} else if (/7\.[1-4]|8\.0/.test(data['php_version'])) {
|
||||
data['version'] = '1.22.0';
|
||||
}
|
||||
}
|
||||
data['url'] = await getPharUrl(data);
|
||||
return addArchive(data);
|
||||
}
|
||||
data['url'] = await getPharUrl(data);
|
||||
return addArchive(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to add Castor
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
export async function addCastor(data: RS): Promise<string> {
|
||||
data['tool'] = 'castor.' + data['os'].replace('win32', 'windows') + '-amd64';
|
||||
data['url'] = await getUrl(data);
|
||||
data['tool'] = 'castor';
|
||||
data['version_parameter'] = fs.existsSync('castor.php')
|
||||
? data['version_parameter']
|
||||
: '';
|
||||
return await addArchive(data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -392,6 +418,11 @@ export async function addPhive(data: RS): Promise<string> {
|
||||
* @param data
|
||||
*/
|
||||
export async function addPHPUnitTools(data: RS): Promise<string> {
|
||||
if (data['version'] === 'latest') {
|
||||
data['version'] =
|
||||
(await packagist.search(data['packagist'], data['php_version'])) ??
|
||||
'latest';
|
||||
}
|
||||
data['url'] = await getPharUrl(data);
|
||||
return await addArchive(data);
|
||||
}
|
||||
@ -458,6 +489,7 @@ export async function getData(
|
||||
data['extension'] ??= '.phar';
|
||||
data['os'] = os;
|
||||
data['php_version'] = php_version;
|
||||
data['packagist'] ??= data['repository'];
|
||||
data['prefix'] = data['github'] === data['domain'] ? 'releases' : '';
|
||||
data['verb'] = data['github'] === data['domain'] ? 'download' : '';
|
||||
data['fetch_latest'] ??= 'false';
|
||||
@ -472,6 +504,7 @@ export async function getData(
|
||||
}
|
||||
|
||||
export const functionRecord: Record<string, (data: RS) => Promise<string>> = {
|
||||
castor: addCastor,
|
||||
composer: addComposer,
|
||||
deployer: addDeployer,
|
||||
dev_tools: addDevTools,
|
||||
|
29
src/utils.ts
29
src/utils.ts
@ -249,7 +249,8 @@ export async function CSVArray(values_csv: string): Promise<Array<string>> {
|
||||
.trim()
|
||||
.replace(/^["']|["']$|(?<==)["']/g, '')
|
||||
.replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'")
|
||||
.replace(/=(.*?)(=.*)/, "='$1$2'");
|
||||
.replace(/=(.*?)(=.*)/, "='$1$2'")
|
||||
.replace(/:\s*["'](.*?)/g, ':$1');
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
@ -439,6 +440,32 @@ export async function readPHPVersion(): Promise<string> {
|
||||
} else if (versionFile !== '.php-version') {
|
||||
throw new Error(`Could not find '${versionFile}' file.`);
|
||||
}
|
||||
|
||||
const composerLock = 'composer.lock';
|
||||
if (fs.existsSync(composerLock)) {
|
||||
const lockFileContents = JSON.parse(fs.readFileSync(composerLock, 'utf8'));
|
||||
if (
|
||||
lockFileContents['platform-overrides'] &&
|
||||
lockFileContents['platform-overrides']['php']
|
||||
) {
|
||||
return lockFileContents['platform-overrides']['php'];
|
||||
}
|
||||
}
|
||||
|
||||
const composerJson = 'composer.json';
|
||||
if (fs.existsSync(composerJson)) {
|
||||
const composerFileContents = JSON.parse(
|
||||
fs.readFileSync(composerJson, 'utf8')
|
||||
);
|
||||
if (
|
||||
composerFileContents['config'] &&
|
||||
composerFileContents['config']['platform'] &&
|
||||
composerFileContents['config']['platform']['php']
|
||||
) {
|
||||
return composerFileContents['config']['platform']['php'];
|
||||
}
|
||||
}
|
||||
|
||||
return 'latest';
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user