Compare commits

..
10 Commits
Author SHA1 Message Date
Shivam Mathur 19d3947a16 Fix fallback to latest release containing tool PHAR 2026-10-12 09:48:45 +05:30
Shivam Mathur 5a89ae6dd6 Update setup-php in docs workflow [skip ci] 2026-10-10 21:35:44 +05:30
dependabot[bot] b828e3206e Bump shivammathur/cache-extensions
Bumps the github-actions group with 1 update: [shivammathur/cache-extensions](https://github.com/shivammathur/cache-extensions).


Updates `shivammathur/cache-extensions` from 1.15.1 to 1.15.2
- [Release notes](https://github.com/shivammathur/cache-extensions/releases)
- [Commits](https://github.com/shivammathur/cache-extensions/compare/de3c642a5fce0ef91581a1c9831e229f525196d6...22e24453af1bf3851994136f122ce065ab828a74)

---
updated-dependencies:
- dependency-name: shivammathur/cache-extensions
  dependency-version: 1.15.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-10-10 16:18:51 +05:30
Michael Lip c463b1d02f Keep a two digit minor in parseVersion (#1134)
Co-authored-by: Michael Lip <51033404+theluckystrike@users.noreply.github.com>
2026-10-10 15:23:58 +05:30
Shivam Mathur db75472672 Fall back to PHAR when Composer tool installation fails 2026-10-10 12:24:10 +05:30
Shivam Mathur 40d4c7a0d3 Modernize the tools manifest schema to Draft 2020-12 2026-10-10 12:24:10 +05:30
Shivam Mathur f5a207e3fa Use Homebrew API when the core tap is missing 2026-10-09 10:56:37 +05:30
Shivam Mathur 11b9f9a7f0 Migrate the action and tests to ES modules 2026-10-09 00:14:33 +05:30
Shivam Mathur f1477a078f Install PHPStan using scoped Composer 2026-10-08 22:36:54 +05:30
Shivam Mathur 0534f032be Bump Node.js dependencies and support ESM packages 2026-10-08 22:36:54 +05:30
64 changed files with 730 additions and 514 deletions

No files matched your search

+1 -1
View File
@@ -23,7 +23,7 @@ jobs:
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', '8.5', '8.6', '8.7'] 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', '8.5', '8.6', '8.7']
steps: steps:
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2 uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
tools: none tools: none
+1 -1
View File
@@ -48,7 +48,7 @@ jobs:
- name: Setup cache environment - name: Setup cache environment
id: cache-env id: cache-env
uses: shivammathur/cache-extensions@de3c642a5fce0ef91581a1c9831e229f525196d6 # v1 uses: shivammathur/cache-extensions@22e24453af1bf3851994136f122ce065ab828a74 # v1
with: with:
php-version: ${{ matrix.php-versions || env.default-php-version }} php-version: ${{ matrix.php-versions || env.default-php-version }}
extensions: ${{ env.extensions }} extensions: ${{ env.extensions }}
+1 -1
View File
@@ -1,4 +1,4 @@
import * as config from '../src/config'; import * as config from '../src/config.js';
describe('Config tests', () => { describe('Config tests', () => {
it.each` it.each`
+2 -1
View File
@@ -1,4 +1,5 @@
import * as core from '../src/core'; import {jest} from '@jest/globals';
import * as core from '../src/core.js';
describe('Core tests', () => { describe('Core tests', () => {
const originalEnv = process.env; const originalEnv = process.env;
+1 -1
View File
@@ -1,4 +1,4 @@
import * as coverage from '../src/coverage'; import * as coverage from '../src/coverage.js';
describe('Config tests', () => { describe('Config tests', () => {
it.each` it.each`
+1 -1
View File
@@ -1,5 +1,5 @@
import * as fs from 'fs'; import * as fs from 'fs';
import * as extensions from '../src/extensions'; import * as extensions from '../src/extensions.js';
describe('Extension tests', () => { describe('Extension tests', () => {
it.each` it.each`
+17 -5
View File
@@ -1,6 +1,19 @@
import * as fetch from '../src/fetch'; import * as fetch from '../src/fetch.js';
import nock from 'nock'; import nock from 'nock';
beforeAll(() => nock.disableNetConnect());
afterEach(() => {
const pending = nock.pendingMocks();
nock.cleanAll();
expect(pending).toEqual([]);
});
afterAll(() => {
nock.enableNetConnect();
nock.restore();
});
it('checking fetch', async () => { it('checking fetch', async () => {
const host_url = 'https://example.com'; const host_url = 'https://example.com';
const manifest_url = host_url + '/manifest'; const manifest_url = host_url + '/manifest';
@@ -9,9 +22,8 @@ it('checking fetch', async () => {
nock(host_url) nock(host_url)
.get('/manifest') .get('/manifest')
.reply(200, {latest: 'latest'}) .reply(200, {latest: 'latest'})
.get('/manifest', '', { .get('/manifest')
reqheaders: {authorization: 'Bearer invalid_token'} .matchHeader('authorization', 'Bearer invalid_token')
})
.reply(401, {error: '401: Unauthorized'}) .reply(401, {error: '401: Unauthorized'})
.get('/ping') .get('/ping')
.twice() .twice()
@@ -36,7 +48,7 @@ it('checking fetch', async () => {
expect(response.data).toBe(undefined); expect(response.data).toBe(undefined);
response = await fetch.fetch(manifest_url, 'invalid_token'); response = await fetch.fetch(manifest_url, 'invalid_token');
expect(response.error).not.toBe(undefined); expect(response.error).toBe('401: Unauthorized');
expect(response.data).toBe(undefined); expect(response.data).toBe(undefined);
response = await fetch.fetch(host_url + '/error'); response = await fetch.fetch(host_url + '/error');
+7 -5
View File
@@ -1,12 +1,11 @@
import * as install from '../src/install'; import {jest} from '@jest/globals';
import * as utils from '../src/utils';
/** /**
* Mock install.ts * Mock install.ts
*/ */
jest.mock('../src/install', () => ({ jest.unstable_mockModule('../src/install.js', () => ({
getScript: jest getScript: jest
.fn() .fn<typeof import('../src/install.js').getScript>()
.mockImplementation(async (os: string): Promise<string> => { .mockImplementation(async (os: string): Promise<string> => {
const filename = os + (await utils.scriptExtension(os)); const filename = os + (await utils.scriptExtension(os));
const version: string = await utils.parseVersion( const version: string = await utils.parseVersion(
@@ -36,7 +35,7 @@ jest.mock('../src/install', () => ({
/** /**
* Mock fetch.ts * Mock fetch.ts
*/ */
jest.mock('../src/fetch', () => ({ jest.unstable_mockModule('../src/fetch.js', () => ({
fetch: jest.fn().mockImplementation(() => { fetch: jest.fn().mockImplementation(() => {
return { return {
data: '{ "latest": "8.3", "lowest": "8.1", "highest": "8.3", "nightly": "8.4", "5.x": "5.6" }' data: '{ "latest": "8.3", "lowest": "8.1", "highest": "8.3", "nightly": "8.4", "5.x": "5.6" }'
@@ -44,6 +43,9 @@ jest.mock('../src/fetch', () => ({
}) })
})); }));
const utils = await import('../src/utils.js');
const install = await import('../src/install.js');
describe('Install', () => { describe('Install', () => {
it.each` it.each`
version | os | extension_csv | ini_file | ini_values_csv | coverage_driver | tools | output version | os | extension_csv | ini_file | ini_values_csv | coverage_driver | tools | output
+14 -1
View File
@@ -1,6 +1,19 @@
import * as packagist from '../src/packagist'; import * as packagist from '../src/packagist.js';
import nock from 'nock'; import nock from 'nock';
beforeAll(() => nock.disableNetConnect());
afterEach(() => {
const pending = nock.pendingMocks();
nock.cleanAll();
expect(pending).toEqual([]);
});
afterAll(() => {
nock.enableNetConnect();
nock.restore();
});
describe('search function', () => { describe('search function', () => {
const mockResponse = { const mockResponse = {
packages: { packages: {
+74 -51
View File
@@ -1,6 +1,6 @@
import * as fs from 'fs'; import {jest} from '@jest/globals';
import * as tools from '../src/tools'; import fs from 'fs';
import {ToolData, ToolInput} from '../src/tools'; import type {ToolData, ToolInput} from '../src/tools.js';
function getData(data: Partial<ToolData>): ToolData { function getData(data: Partial<ToolData>): ToolData {
const tool = data.tool || 'tool'; const tool = data.tool || 'tool';
@@ -40,9 +40,9 @@ function unsetComposerAuthEnv(): void {
/** /**
* Mock fetch.ts * Mock fetch.ts
*/ */
jest.mock('../src/fetch', () => ({ jest.unstable_mockModule('../src/fetch.js', () => ({
fetch: jest fetch: jest
.fn() .fn<typeof import('../src/fetch.js').fetch>()
.mockImplementation( .mockImplementation(
async (url: string, token?: string): Promise<Record<string, string>> => { async (url: string, token?: string): Promise<Record<string, string>> => {
if (url.includes('deployer')) { if (url.includes('deployer')) {
@@ -86,9 +86,9 @@ jest.mock('../src/fetch', () => ({
) )
})); }));
jest.mock('../src/packagist', () => ({ jest.unstable_mockModule('../src/packagist.js', () => ({
search: jest search: jest
.fn() .fn<typeof import('../src/packagist.js').search>()
.mockImplementation( .mockImplementation(
async ( async (
package_name: string, package_name: string,
@@ -102,6 +102,10 @@ jest.mock('../src/packagist', () => ({
) )
})); }));
const tools = await import('../src/tools.js');
afterEach(() => jest.restoreAllMocks());
describe('Tools tests', () => { describe('Tools tests', () => {
it.each` it.each`
token | version token | version
@@ -381,6 +385,56 @@ describe('Tools tests', () => {
} }
); );
it.each`
release | resolved
${'phpstan'} | ${'latest/download'}
${'phpstan:0.12.68'} | ${'download/0.12.68'}
${'phpstan:^0.12.68'} | ${'download/0.12.68'}
${'phpstan:0.12'} | ${'download/1.2.3'}
${'phpstan:0.12.x'} | ${'download/1.2.3'}
${'phpstan:0.12.*'} | ${'download/1.2.3'}
`(
'resolving PHPStan PHAR fallback for $release',
async ({release, resolved}) => {
unsetComposerAuthEnv();
for (const os of ['linux', 'darwin', 'win32']) {
const data = await tools.getData(release, '8.0', os);
const script = await tools.addPackage(data);
expect(script).toContain(
'scoped https://github.com/phpstan/phpstan/releases/' +
resolved +
'/phpstan.phar "-V"'
);
expect(data.type).toBe('composer');
expect(data.release).toContain('phpstan');
}
}
);
it('keeps Composer available when the fallback version lookup fails', async () => {
process.env['GITHUB_TOKEN'] = 'invalid_token';
const data = await tools.getData('phpstan:0.12', '8.0', 'linux');
expect(await tools.addPackage(data)).toBe(
'add_composer_tool phpstan "phpstan:0.12.*" phpstan/ scoped'
);
unsetComposerAuthEnv();
});
it('uses fallback settings independently of the Composer repository', async () => {
const data = await tools.getData('vendor/tool:1.2.3', '8.0', 'linux', {
fallback: {
type: 'phar',
repository: 'releases/tool',
domain: 'https://example.com',
extension: '.phar',
version_prefix: 'v'
}
});
expect(await tools.addPackage(data)).toBe(
'add_composer_tool tool tool:1.2.3 vendor/ global https://example.com/releases/tool/v1.2.3/tool.phar ""'
);
});
it.each` it.each`
version | php_version | os | script version | php_version | os | script
${'latest'} | ${'8.0'} | ${'linux'} | ${'add_tool https://github.com/phar-io/phive/releases/download/3.2.1/phive-3.2.1.phar phive'} ${'latest'} | ${'8.0'} | ${'linux'} | ${'add_tool https://github.com/phar-io/phive/releases/download/3.2.1/phive-3.2.1.phar phive'}
@@ -527,30 +581,11 @@ describe('Tools tests', () => {
}); });
it('checking affected composer version with CRLF ranges', async () => { it('checking affected composer version with CRLF ranges', async () => {
let affected = false; jest
let fixed = true; .spyOn(fs, 'readFileSync')
await jest.isolateModulesAsync(async () => { .mockReturnValue('1.0.0-0 1.10.28\r\n2.0.0-0 2.2.28\r\n2.3.0-0 2.9.8');
jest.doMock('fs', () => ({ expect(tools.skipGitHubAuthForComposerVersion('2.9.7')).toBe(true);
...jest.requireActual('fs'), expect(tools.skipGitHubAuthForComposerVersion('2.9.8')).toBe(false);
readFileSync: (
filePath: fs.PathOrFileDescriptor,
options?: unknown
) => {
if (String(filePath).includes('composer-gh-auth-no-op')) {
return '1.0.0-0 1.10.28\r\n2.0.0-0 2.2.28\r\n2.3.0-0 2.9.8';
}
return (jest.requireActual('fs') as typeof fs).readFileSync(
filePath,
options as fs.ObjectEncodingOptions & {flag?: string}
);
}
}));
const isolatedTools = jest.requireActual<typeof tools>('../src/tools');
affected = isolatedTools.skipGitHubAuthForComposerVersion('2.9.7');
fixed = isolatedTools.skipGitHubAuthForComposerVersion('2.9.8');
});
expect(affected).toBe(true);
expect(fixed).toBe(false);
}); });
it.each` it.each`
@@ -655,7 +690,7 @@ describe('Tools tests', () => {
'add_tool https://github.com/humbug/php-scoper/releases/latest/download/php-scoper.phar php-scoper "--version"', '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_tool https://github.com/phpDocumentor/phpDocumentor/releases/latest/download/phpDocumentor.phar phpDocumentor "--version"',
'add_composer_tool phplint phplint overtrue/', 'add_composer_tool phplint phplint overtrue/',
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan "-V"', 'add_composer_tool phpstan phpstan phpstan/ scoped',
'add_tool https://phar.phpunit.de/phpunit-7.4.0.phar,https://phar.phpunit.de/phpunit-7.phar phpunit "--version"', 'add_tool https://phar.phpunit.de/phpunit-7.4.0.phar,https://phar.phpunit.de/phpunit-7.phar phpunit "--version"',
'add_pecl', 'add_pecl',
'add_tool https://www.phing.info/get/phing-latest.phar phing "-v"', 'add_tool https://www.phing.info/get/phing-latest.phar phing "-v"',
@@ -948,26 +983,14 @@ describe('Tools tests', () => {
} }
}); });
let result: string = ''; const readFileSync = fs.readFileSync;
await jest.isolateModulesAsync(async () => { jest.spyOn(fs, 'readFileSync').mockImplementation((filePath, options) => {
jest.doMock('fs', () => ({ if (String(filePath).includes('tools.json')) {
...jest.requireActual('fs'), return brokenToolsJson;
readFileSync: ( }
filePath: fs.PathOrFileDescriptor, return readFileSync(filePath, options);
options?: unknown
) => {
if (String(filePath).includes('tools.json')) {
return brokenToolsJson;
}
return (jest.requireActual('fs') as typeof fs).readFileSync(
filePath,
options as fs.ObjectEncodingOptions & {flag?: string}
);
}
}));
const isolatedTools = jest.requireActual<typeof tools>('../src/tools');
result = await isolatedTools.addTools('broken-tool', '7.4', 'linux');
}); });
const result = await tools.addTools('broken-tool', '7.4', 'linux');
expect(result).toContain( expect(result).toContain(
'add_log "$cross" "broken-tool" "broken-tool has no function defined. Please report this issue."' 'add_log "$cross" "broken-tool" "broken-tool has no function defined. Please report this issue."'
+23 -13
View File
@@ -1,8 +1,13 @@
import {fileURLToPath} from 'url';
import {jest} from '@jest/globals';
import fs from 'fs'; import fs from 'fs';
import os from 'os'; import os from 'os';
import * as path from 'path'; import * as path from 'path';
import * as utils from '../src/utils'; const fetchMock = jest.fn<typeof import('../src/fetch.js').fetch>();
import * as fetchModule from '../src/fetch'; jest.unstable_mockModule('../src/fetch.js', () => ({fetch: fetchMock}));
const utils = await import('../src/utils.js');
const dirname = path.dirname(fileURLToPath(import.meta.url));
describe('Utils tests', () => { describe('Utils tests', () => {
it('checking readEnv', async () => { it('checking readEnv', async () => {
@@ -40,9 +45,9 @@ describe('Utils tests', () => {
}); });
it('checking parseVersion', async () => { it('checking parseVersion', async () => {
const fetchSpy = jest.spyOn(fetchModule, 'fetch').mockResolvedValue({ const fetchSpy = fetchMock.mockResolvedValue({
data: fs.readFileSync( data: fs.readFileSync(
path.join(__dirname, '../src/configs/php-versions.json'), path.join(dirname, '../src/configs/php-versions.json'),
'utf8' 'utf8'
) )
}); });
@@ -53,6 +58,9 @@ describe('Utils tests', () => {
expect(await utils.parseVersion('8.7.0')).toBe('8.7'); expect(await utils.parseVersion('8.7.0')).toBe('8.7');
expect(await utils.parseVersion('7')).toBe('7.0'); expect(await utils.parseVersion('7')).toBe('7.0');
expect(await utils.parseVersion('7.4')).toBe('7.4'); expect(await utils.parseVersion('7.4')).toBe('7.4');
expect(await utils.parseVersion('8.10')).toBe('8.10');
expect(await utils.parseVersion('10')).toBe('10.0');
expect(await utils.parseVersion('10.0')).toBe('10.0');
expect(await utils.parseVersion('5.x')).toBe('5.6'); expect(await utils.parseVersion('5.x')).toBe('5.6');
expect(await utils.parseVersion('pre')).toBe('pre'); expect(await utils.parseVersion('pre')).toBe('pre');
expect(await utils.parseVersion('pre-installed')).toBe('pre'); expect(await utils.parseVersion('pre-installed')).toBe('pre');
@@ -230,9 +238,9 @@ describe('Utils tests', () => {
}); });
it('checking suppressOutput', async () => { it('checking suppressOutput', async () => {
expect(await utils.suppressOutput('win32')).toEqual(' '); expect(await utils.suppressOutput('win32')).toEqual(' >$null 2>&1');
expect(await utils.suppressOutput('linux')).toEqual(' '); expect(await utils.suppressOutput('linux')).toEqual(' >/dev/null 2>&1');
expect(await utils.suppressOutput('darwin')).toEqual(' '); expect(await utils.suppressOutput('darwin')).toEqual(' >/dev/null 2>&1');
expect(await utils.suppressOutput('openbsd')).toContain( expect(await utils.suppressOutput('openbsd')).toContain(
'Platform openbsd is not supported' 'Platform openbsd is not supported'
); );
@@ -324,8 +332,8 @@ describe('Utils tests', () => {
"Could not find '.phpenv-version' file." "Could not find '.phpenv-version' file."
); );
const existsSync = jest.spyOn(fs, 'existsSync').mockImplementation(); const existsSync = jest.spyOn(fs, 'existsSync').mockReturnValue(false);
const readFileSync = jest.spyOn(fs, 'readFileSync').mockImplementation(); const readFileSync = jest.spyOn(fs, 'readFileSync').mockReturnValue('');
existsSync.mockReturnValue(true); existsSync.mockReturnValue(true);
readFileSync.mockReturnValue('8.1'); readFileSync.mockReturnValue('8.1');
@@ -391,8 +399,8 @@ describe('Utils tests', () => {
}); });
it('readPHPVersion rejects unsupported values from each source', async () => { it('readPHPVersion rejects unsupported values from each source', async () => {
const existsSync = jest.spyOn(fs, 'existsSync').mockImplementation(); const existsSync = jest.spyOn(fs, 'existsSync').mockReturnValue(false);
const readFileSync = jest.spyOn(fs, 'readFileSync').mockImplementation(); const readFileSync = jest.spyOn(fs, 'readFileSync').mockReturnValue('');
process.env['php-version'] = '$0'; process.env['php-version'] = '$0';
await expect(utils.readPHPVersion()).rejects.toThrow('php-version input'); await expect(utils.readPHPVersion()).rejects.toThrow('php-version input');
@@ -547,7 +555,7 @@ describe.each(['linux', 'darwin', 'win32'])(
'uses fresh copies without writing through source symlinks', 'uses fresh copies without writing through source symlinks',
async () => { async () => {
const outside = path.join(root, path.basename(helper)); const outside = path.join(root, path.basename(helper));
const original = 'echo original \n'; const original = 'echo original >/dev/null 2>&1\n';
fs.writeFileSync(outside, original); fs.writeFileSync(outside, original);
fs.unlinkSync(helper); fs.unlinkSync(helper);
fs.symlinkSync(outside, helper); fs.symlinkSync(outside, helper);
@@ -562,7 +570,9 @@ describe.each(['linux', 'darwin', 'win32'])(
path.join(path.dirname(first), 'tools', path.basename(helper)), path.join(path.dirname(first), 'tools', path.basename(helper)),
'utf8' 'utf8'
) )
).toBe(`echo original ${platform === 'win32' ? '' : ''}\n`); ).toBe(
`echo original ${platform === 'win32' ? '2>&1 | Out-Host' : ''}\n`
);
} }
); );
} }
+1 -1
View File
@@ -1 +1 @@
(()=>{var e={472:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(){var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r))t[t.length]=r;return t};return ownKeys(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ownKeys(e),i=0;i<r.length;i++)if(r[i]!=="default")n(t,e,r[i]);s(t,e);return t}}();Object.defineProperty(t,"__esModule",{value:true});t.addINIValuesUnix=addINIValuesUnix;t.addINIValuesWindows=addINIValuesWindows;t.addINIValues=addINIValues;const o=i(r(277));async function addINIValuesUnix(e){const t=await o.CSVArray(e);let r="";await o.asyncForEach(t,async function(e){r+="\n"+await o.addLog("$tick",e,"Added to php.ini","linux")});return'echo "'+t.map(e=>o.escapeForShell(e,"linux")).join("\n")+'" | sudo tee -a "${pecl_file:-${ini_file[@]}}" '+r}async function addINIValuesWindows(e){const t=await o.CSVArray(e);let r="\n";await o.asyncForEach(t,async function(e){r+=await o.addLog("$tick",e,"Added to php.ini","win32")+"\n"});return'Add-Content "$php_dir\\php.ini" "'+t.map(e=>o.escapeForShell(e,"win32")).join("\n")+'"'+r}async function addINIValues(e,t,r=false){let n="\n";switch(r){case true:n+=await o.stepLog("Add php.ini values",t)+await o.suppressOutput(t)+"\n";break;case false:default:n+=await o.stepLog("Add php.ini values",t)+"\n";break}switch(t){case"win32":return n+await addINIValuesWindows(e);case"darwin":case"linux":return n+await addINIValuesUnix(e);default:return await o.log("Platform "+t+" is not supported",t,"error")}}},469:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.issueCommand=issueCommand;t.error=error;t.setFailed=setFailed;t.getInput=getInput;const n=r(857);function toCommandValue(e){if(e instanceof Error){return e.toString()}return e}function escapeData(e){return toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(e){return e.replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}function issueCommand(e,t,r){let s=`::${e}`;if(t&&Object.keys(t).length>0){s+=" ";const e=Object.entries(t).filter(([,e])=>e).map(([e,t])=>`${e}=${escapeProperty(t)}`).join(",");s+=e}s+=`::${escapeData(r)}`;process.stdout.write(s+n.EOL)}function error(e){issueCommand("error",{},e)}function setFailed(e){process.exitCode=1;error(e)}function getInput(e,t=false){const r=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&!r){throw new Error(`Input required and not supplied: ${e}`)}return r.trim()}},524:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(){var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r))t[t.length]=r;return t};return ownKeys(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ownKeys(e),i=0;i<r.length;i++)if(r[i]!=="default")n(t,e,r[i]);s(t,e);return t}}();Object.defineProperty(t,"__esModule",{value:true});t.checkXdebugError=checkXdebugError;t.addCoverageXdebug=addCoverageXdebug;t.addCoveragePCOV=addCoveragePCOV;t.disableCoverage=disableCoverage;t.addCoverage=addCoverage;const o=i(r(277));const a=i(r(252));const c=i(r(472));async function checkXdebugError(e,t){if(/^5\.[3-6]$|^7\.[0-1]$/.test(t)&&e=="xdebug3"||/^8\.[0-9]$/.test(t)&&e=="xdebug2"){return e+" is not supported on PHP "+t}return""}async function addCoverageXdebug(e,t,r,n){let s="\n";const i=await checkXdebugError(e,t);if(!i){s+=await a.addExtension(":pcov:false",t,r,true)+n;e=e=="xdebug3"?"xdebug":e;s+=await a.addExtension(e,t,r,true)+n;s+=await o.setVariable("xdebug_version","php -r \"echo phpversion('xdebug');\"",r);s+=await o.getCommand(r,"extension_log")+'xdebug "Xdebug $xdebug_version enabled as coverage driver"'}else{s+=await o.addLog("$cross",e,i,r)}return s}async function addCoveragePCOV(e,t,r){let n="\n";switch(true){default:n+=await a.addExtension(":xdebug:false",e,t,trueLine truncated import{createRequire as e}from"module";var t={26:function(e,t){(function(e,s){true?s(t):0})(this,function(e){"use strict";const t=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;const validateAndParse=e=>{if(typeof e!=="string"){throw new TypeError("Invalid argument expected string")}const s=e.match(t);if(!s){throw new Error(`Invalid argument not valid semver ('${e}' received)`)}s.shift();return s};const isWildcard=e=>e==="*"||e==="x"||e==="X";const tryParse=e=>{const t=parseInt(e,10);return isNaN(t)?e:t};const forceType=(e,t)=>typeof e!==typeof t?[String(e),String(t)]:[e,t];const compareStrings=(e,t)=>{if(isWildcard(e)||isWildcard(t))return 0;const[s,r]=forceType(tryParse(e),tryParse(t));if(s>r)return 1;if(s<r)return-1;return 0};const compareSegments=(e,t)=>{for(let s=0;s<Math.max(e.length,t.length);s++){const r=compareStrings(e[s]||"0",t[s]||"0");if(r!==0)return r}return 0};const compareVersions=(e,t)=>{const s=validateAndParse(e);const r=validateAndParse(t);const n=s.pop();const i=r.pop();const o=compareSegments(s,r);if(o!==0)return o;if(n&&i){return compareSegments(n.split("."),i.split("."))}else if(n||i){return n?-1:1}return 0};const compare=(e,t,r)=>{assertValidOperator(r);const n=compareVersions(e,t);return s[r].includes(n)};const s={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]};const r=Object.keys(s);const assertValidOperator=e=>{if(typeof e!=="string"){throw new TypeError(`Invalid operator type, expected string but got ${typeof e}`)}if(r.indexOf(e)===-1){throw new Error(`Invalid operator, expected one of ${r.join("|")}`)}};const satisfies=(e,t)=>{t=t.replace(/([><=]+)\s+/g,"$1");if(t.includes("||")){return t.split("||").some(t=>satisfies(e,t))}else if(t.includes(" - ")){const[s,r]=t.split(" - ",2);return satisfies(e,`>=${s} <=${r}`)}else if(t.includes(" ")){return t.trim().replace(/\s{2,}/g," ").split(" ").every(t=>satisfies(e,t))}const s=t.match(/^([<>=~^]+)/);const r=s?s[1]:"=";if(r!=="^"&&r!=="~")return compare(e,t,r);const[n,i,o,,a]=validateAndParse(e);const[c,l,d,,u]=validateAndParse(t);const p=[n,i,o];const f=[c,l!==null&&l!==void 0?l:"x",d!==null&&d!==void 0?d:"x"];if(u){if(!a)return false;if(compareSegments(p,f)!==0)return false;if(compareSegments(a.split("."),u.split("."))===-1)return false}const h=f.findIndex(e=>e!=="0")+1;const w=r==="~"?2:h>1?h:1;if(compareSegments(p.slice(0,w),f.slice(0,w))!==0)return false;if(compareSegments(p.slice(w),f.slice(w))===-1)return false;return true};const validate=e=>typeof e==="string"&&/^[v\d]/.test(e)&&t.test(e);const validateStrict=e=>typeof e==="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(e);e.compare=compare;e.compareVersions=compareVersions;e.satisfies=satisfies;e.validate=validate;e.validateStrict=validateStrict})}};var s={};function __nccwpck_require__(e){var r=s[e];if(r!==undefined){return r.exports}var n=s[e]={exports:{}};var i=true;try{t[e].call(n.exports,n,n.exports,__nccwpck_require__);i=false}finally{if(i)delete s[e]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=decodeURIComponent(new URL(".",import.meta.url).pathname).slice(import.meta.url.match(/^file:\/\/\/\w:/)?1:0,-1)+"/";(()=>{__nccwpck_require__.d=(e,t)=>{for(var s in t){if(__nccwpck_require__.o(t,s)&&!__nccwpck_require__.o(e,s)){Object.defineProperty(e,s,{enumerable:true,get:t[s]})}}}})();(()=>{__nccwpck_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})();var r={};__nccwpck_require__.d(r,{IT:()=>getScript,eF:()=>run,GJ:()=>setEnv});const n=e(import.meta.url)("url");const i=e(import.meta.url)("path");const o=e(import.meta.url)("string_decoder");const a=e(import.meta.url)("os");const c=e(import.meta.url)("events");const l=e(import.meta.url)("child_process");const d=e(import.meta.url)("assert");const u=e(import.meta.url)("fs");var p=undefined&&undefined.__awaiter||function(e,t,s,r){function adopt(e){return e instanceof s?e:new s(function(t){t(e)})}return new(s||(s=Promise))(function(s,n){function fulfilled(e){try{step(r.next(e))}catch(e){n(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){n(e)}}function step(e){e.done?s(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};const{chmod:f,copyFile:h,lstat:w,mkdir:m,open:g,readdir:v,rename:y,rm:_,rmdir:x,stat:b,symlink:$,unlink:E}=u.promises;const P=process.platform==="win32";function readlink(e){return p(this,void 0,void 0,function*(){const t=yield fs.promises.readlink(e);if(P&&!t.endsWith("\\")){return`${t}\\`}return t})}const k=268435456;const S=u.constants.O_RDONLY;function exists(e){return p(this,void 0,void 0,function*(){try{yield b(e)}catch(e){if(e.code==="ENOENT"){return false}throw e}return true})}function isDirectory(e){return p(this,arguments,void 0,function*(e,t=false){const s=t?yieLine truncated
+3
View File
@@ -0,0 +1,3 @@
{
"type": "module"
}
+6 -2
View File
@@ -1,11 +1,15 @@
module.exports = { export default {
clearMocks: true, clearMocks: true,
moduleFileExtensions: ['js', 'ts'], moduleFileExtensions: ['js', 'ts'],
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1'
},
testEnvironment: 'node', testEnvironment: 'node',
testMatch: ['**/*.test.ts'], testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner', testRunner: 'jest-circus/runner',
transform: { transform: {
'^.+\\.ts$': ['ts-jest', {tsconfig: 'tsconfig.test.json'}] '^.+\\.ts$': ['ts-jest', {tsconfig: 'tsconfig.test.json', useESM: true}]
}, },
verbose: true, verbose: true,
collectCoverage: true collectCoverage: true
+54 -71
View File
@@ -9,7 +9,7 @@
"version": "2.40.0", "version": "2.40.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/exec": "^2.0.0", "@actions/exec": "^3.0.0",
"compare-versions": "^6.1.1" "compare-versions": "^6.1.1"
}, },
"devDependencies": { "devDependencies": {
@@ -17,8 +17,8 @@
"@eslint/js": "^10.0.1", "@eslint/js": "^10.0.1",
"@types/jest": "^30.0.0", "@types/jest": "^30.0.0",
"@types/node": "^26.6.4", "@types/node": "^26.6.4",
"@typescript-eslint/eslint-plugin": "^8.71.0", "@typescript-eslint/eslint-plugin": "^8.71.1",
"@typescript-eslint/parser": "^8.71.0", "@typescript-eslint/parser": "^8.71.1",
"@typescript/native": "npm:typescript@^7.0.2", "@typescript/native": "npm:typescript@^7.0.2",
"@vercel/ncc": "^0.45.0", "@vercel/ncc": "^0.45.0",
"eslint": "^10.12.0", "eslint": "^10.12.0",
@@ -30,7 +30,7 @@
"globals": "^17.13.0", "globals": "^17.13.0",
"jest": "^30.5.2", "jest": "^30.5.2",
"jest-circus": "^30.5.2", "jest-circus": "^30.5.2",
"nock": "^14.0.17", "nock": "^15.0.1",
"prettier": "^3.9.9", "prettier": "^3.9.9",
"simple-git-hooks": "^2.14.0", "simple-git-hooks": "^2.14.0",
"ts-jest": "^29.4.14", "ts-jest": "^29.4.14",
@@ -38,18 +38,18 @@
} }
}, },
"node_modules/@actions/exec": { "node_modules/@actions/exec": {
"version": "2.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-2.0.0.tgz", "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-3.0.0.tgz",
"integrity": "sha512-k8ngrX2voJ/RIN6r9xB82NVqKpnMRtxDoiO+g3olkIUpQNqjArXrCQceduQZCQj3P3xm32pChRLqRrtXTlqhIw==", "integrity": "sha512-6xH/puSoNBXb72VPlZVm7vQ+svQpFyA96qdDBvhB8eNZOE8LtPf9L4oAsfzK/crCL8YZ+19fKYVnM63Sl+Xzlw==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/io": "^2.0.0" "@actions/io": "^3.0.2"
} }
}, },
"node_modules/@actions/io": { "node_modules/@actions/io": {
"version": "2.0.0", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/@actions/io/-/io-2.0.0.tgz", "resolved": "https://registry.npmjs.org/@actions/io/-/io-3.0.2.tgz",
"integrity": "sha512-Jv33IN09XLO+0HS79aaODsvIRyduiF7NY/F6LYeK5oeUmrsz7aFdRphQjFoESF4jS7lMauDOttKALcpapVDIAg==", "integrity": "sha512-nRBchcMM+QK1pdjO7/idu86rbJI5YHUKCvKs0KxnSYbVe3F51UfGxuZX4Qy/fWlp6l7gWFwIkrOzN+oUK03kfw==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/@babel/code-frame": { "node_modules/@babel/code-frame": {
@@ -1344,21 +1344,21 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@mswjs/interceptors": { "node_modules/@mswjs/interceptors": {
"version": "0.41.9", "version": "0.44.0",
"resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.41.9.tgz", "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.44.0.tgz",
"integrity": "sha512-VVPPgHyQ6ShqnrmDWuxjmUIsO9gWyOZFmuOfLd9LfBGQJwZfy0gvv9pbHSJuoFNIYC7ZDX9aoFwowjcdSC4E8w==", "integrity": "sha512-IYHevRStF4ijM20GI9c9Ndhw483NSAjCydQhUr4/zIB0BNLsTVw3vFAxTo6TlvX4QnV60wEHttUa9539TTAq+A==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@open-draft/deferred-promise": "^2.2.0", "@open-draft/until": "^3.0.1",
"@open-draft/logger": "^0.3.0", "@types/debug": "^4.1.13",
"@open-draft/until": "^2.0.0", "debug": "^4.4.3",
"is-node-process": "^1.2.0", "is-node-process": "^1.2.0",
"outvariant": "^1.4.3", "outvariant": "^1.4.3",
"strict-event-emitter": "^0.5.1" "rettime": "^0.11.11"
}, },
"engines": { "engines": {
"node": ">=18" "node": ">=22"
} }
}, },
"node_modules/@napi-rs/wasm-runtime": { "node_modules/@napi-rs/wasm-runtime": {
@@ -1383,31 +1383,16 @@
"@emnapi/runtime": "^1.7.1 || ^2.0.0-alpha.4" "@emnapi/runtime": "^1.7.1 || ^2.0.0-alpha.4"
} }
}, },
"node_modules/@open-draft/deferred-promise": { "node_modules/@open-draft/until": {
"version": "2.2.0", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz", "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-3.0.1.tgz",
"integrity": "sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==", "integrity": "sha512-s7/9ELP4aP9YZtW7RJaa0Xf3RISaRH9+EFN18FtykJYRHGNrl8f9ymvoNXzjhrjmftFvkQudtuDU9RYhk0xs3A==",
"dev": true,
"license": "MIT"
},
"node_modules/@open-draft/logger": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/@open-draft/logger/-/logger-0.3.0.tgz",
"integrity": "sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "funding": {
"is-node-process": "^1.2.0", "url": "https://github.com/sponsors/kettanaito"
"outvariant": "^1.4.0"
} }
}, },
"node_modules/@open-draft/until": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz",
"integrity": "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==",
"dev": true,
"license": "MIT"
},
"node_modules/@parcel/watcher": { "node_modules/@parcel/watcher": {
"version": "2.6.0", "version": "2.6.0",
"resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.6.0.tgz", "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.6.0.tgz",
@@ -1809,6 +1794,16 @@
"@babel/types": "^7.28.2" "@babel/types": "^7.28.2"
} }
}, },
"node_modules/@types/debug": {
"version": "4.1.13",
"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz",
"integrity": "sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/ms": "*"
}
},
"node_modules/@types/esrecurse": { "node_modules/@types/esrecurse": {
"version": "4.3.1", "version": "4.3.1",
"resolved": "https://registry.npmjs.org/@types/esrecurse/-/esrecurse-4.3.1.tgz", "resolved": "https://registry.npmjs.org/@types/esrecurse/-/esrecurse-4.3.1.tgz",
@@ -1868,6 +1863,13 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/ms": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz",
"integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "26.6.4", "version": "26.6.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.4.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.4.tgz",
@@ -5046,13 +5048,6 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/json-stringify-safe": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
"integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==",
"dev": true,
"license": "ISC"
},
"node_modules/json5": { "node_modules/json5": {
"version": "2.2.3", "version": "2.2.3",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
@@ -5254,18 +5249,16 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/nock": { "node_modules/nock": {
"version": "14.0.17", "version": "15.0.1",
"resolved": "https://registry.npmjs.org/nock/-/nock-14.0.17.tgz", "resolved": "https://registry.npmjs.org/nock/-/nock-15.0.1.tgz",
"integrity": "sha512-EjRr1weMa4ALQX35AgZTEnP+weJJjlW1KGDiNM2IQC2069YDHas4f4B4UUYR+TTLyKWxJvOz2wObDKQs/LNreA==", "integrity": "sha512-Mjx5Xl4t9vP13eUZPWqwwpjjXNjvhUTo1qTdryVM3+7t6Z2w6WHZ9GVZk/zQ8Ym1vbmloWaglye3cloyHAJ8FA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@mswjs/interceptors": "^0.41.0", "@mswjs/interceptors": "^0.44.0"
"json-stringify-safe": "^5.0.1",
"propagate": "^2.0.0"
}, },
"engines": { "engines": {
"node": ">=18.20.0 <20 || >=20.12.1" "node": ">=20.12.1"
} }
}, },
"node_modules/node-addon-api": { "node_modules/node-addon-api": {
@@ -5631,16 +5624,6 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1" "url": "https://github.com/chalk/ansi-styles?sponsor=1"
} }
}, },
"node_modules/propagate": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz",
"integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 8"
}
},
"node_modules/punycode": { "node_modules/punycode": {
"version": "2.3.1", "version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
@@ -5731,6 +5714,13 @@
"url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1"
} }
}, },
"node_modules/rettime": {
"version": "0.11.12",
"resolved": "https://registry.npmjs.org/rettime/-/rettime-0.11.12.tgz",
"integrity": "sha512-5ExtR1ppiDBQkVoPw5NAqdbfH4Iq2VOmQKHMtUoaFxA9bo2krzFYBtyq6K40xxbYp+2w/YOr6D+1ToF6tTN53A==",
"dev": true,
"license": "MIT"
},
"node_modules/semver": { "node_modules/semver": {
"version": "7.8.5", "version": "7.8.5",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
@@ -5838,13 +5828,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/strict-event-emitter": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz",
"integrity": "sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==",
"dev": true,
"license": "MIT"
},
"node_modules/string-length": { "node_modules/string-length": {
"version": "4.0.2", "version": "4.0.2",
"resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz",
+9 -7
View File
@@ -3,6 +3,7 @@
"version": "2.40.0", "version": "2.40.0",
"private": false, "private": false,
"description": "Setup PHP for use with GitHub Actions", "description": "Setup PHP for use with GitHub Actions",
"type": "module",
"main": "lib/install.js", "main": "lib/install.js",
"types": "lib/install.d.ts", "types": "lib/install.d.ts",
"directories": { "directories": {
@@ -21,7 +22,7 @@
"format-check": "prettier --check **/src/*.ts **/__tests__/*.ts", "format-check": "prettier --check **/src/*.ts **/__tests__/*.ts",
"release": "ncc build -m -o dist && git add -f dist/", "release": "ncc build -m -o dist && git add -f dist/",
"typecheck": "tsc --project tsconfig.test.json --noEmit", "typecheck": "tsc --project tsconfig.test.json --noEmit",
"test": "jest" "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -35,7 +36,7 @@
"author": "shivammathur", "author": "shivammathur",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/exec": "^2.0.0", "@actions/exec": "^3.0.0",
"compare-versions": "^6.1.1" "compare-versions": "^6.1.1"
}, },
"devDependencies": { "devDependencies": {
@@ -43,8 +44,8 @@
"@eslint/js": "^10.0.1", "@eslint/js": "^10.0.1",
"@types/jest": "^30.0.0", "@types/jest": "^30.0.0",
"@types/node": "^26.6.4", "@types/node": "^26.6.4",
"@typescript-eslint/eslint-plugin": "^8.71.0", "@typescript-eslint/eslint-plugin": "^8.71.1",
"@typescript-eslint/parser": "^8.71.0", "@typescript-eslint/parser": "^8.71.1",
"@typescript/native": "npm:typescript@^7.0.2", "@typescript/native": "npm:typescript@^7.0.2",
"@vercel/ncc": "^0.45.0", "@vercel/ncc": "^0.45.0",
"eslint": "^10.12.0", "eslint": "^10.12.0",
@@ -56,7 +57,7 @@
"globals": "^17.13.0", "globals": "^17.13.0",
"jest": "^30.5.2", "jest": "^30.5.2",
"jest-circus": "^30.5.2", "jest-circus": "^30.5.2",
"nock": "^14.0.17", "nock": "^15.0.1",
"prettier": "^3.9.9", "prettier": "^3.9.9",
"simple-git-hooks": "^2.14.0", "simple-git-hooks": "^2.14.0",
"ts-jest": "^29.4.14", "ts-jest": "^29.4.14",
@@ -76,8 +77,9 @@
"pre-commit": "npm run format && npm run lint && npm run test && npm run build && npm run release" "pre-commit": "npm run format && npm run lint && npm run test && npm run build && npm run release"
}, },
"allowScripts": { "allowScripts": {
"@parcel/watcher@2.6.0": true,
"fsevents@2.3.3": true, "fsevents@2.3.3": true,
"simple-git-hooks@2.13.1": true, "simple-git-hooks@2.14.0": true,
"unrs-resolver@1.11.1": true "unrs-resolver@1.12.2": true
} }
} }
+2 -2
View File
@@ -1,4 +1,4 @@
import * as utils from './utils'; import * as utils from './utils.js';
/** /**
* Add script to set custom ini values for unix * Add script to set custom ini values for unix
@@ -17,7 +17,7 @@ export async function addINIValuesUnix(
return ( return (
'echo "' + 'echo "' +
ini_values.map(v => utils.escapeForShell(v, 'linux')).join('\n') + ini_values.map(v => utils.escapeForShell(v, 'linux')).join('\n') +
'" | sudo tee -a "${pecl_file:-${ini_file[@]}}" ' + '" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1' +
script script
); );
} }
+10 -5
View File
@@ -153,12 +153,17 @@
"version_parameter": "-V" "version_parameter": "-V"
}, },
"phpstan": { "phpstan": {
"type": "phar", "type": "composer",
"repository": "phpstan/phpstan", "repository": "phpstan/phpstan",
"extension": ".phar", "scope": "scoped",
"domain": "https://github.com", "fallback": {
"version_prefix": "", "type": "phar",
"version_parameter": "-V" "repository": "phpstan/phpstan",
"extension": ".phar",
"domain": "https://github.com",
"version_prefix": "",
"version_parameter": "-V"
}
}, },
"pie": { "pie": {
"type": "phar", "type": "phar",
+152 -114
View File
@@ -1,5 +1,5 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/configs/tools_schema.json", "$id": "https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/configs/tools_schema.json",
"type": "object", "type": "object",
"title": "Tools", "title": "Tools",
@@ -14,123 +14,161 @@
"function": "function_name", "function": "function_name",
"repository": "user/tool", "repository": "user/tool",
"packagist": "user/tool", "packagist": "user/tool",
"scope": "global, scoped", "scope": "scoped",
"type": "phar, composer, custom-package or custom-function", "type": "composer",
"version_parameter": "--version", "version_parameter": "--version",
"version_prefix": "v" "version_prefix": "v",
"fallback": {
"type": "phar",
"repository": "user/tool",
"domain": "https://github.com",
"extension": ".phar",
"version_prefix": "v",
"version_parameter": "--version"
}
} }
} }
], ],
"items": { "additionalProperties": {
"properties": { "$ref": "#/$defs/tool"
"alias": { },
"$id": "#/items/properties/alias", "$defs": {
"type": "string", "tool": {
"title": "The alias schema", "type": "object",
"description": "Alias for a tool.", "properties": {
"examples": [ "alias": {
"tool_alias" "type": "string",
] "title": "The alias schema",
"description": "Alias for a tool.",
"examples": [
"tool_alias"
]
},
"domain": {
"type": "string",
"title": "The domain schema",
"description": "Domain URL of the tool.",
"examples": [
"https://example.com"
]
},
"extension": {
"type": "string",
"title": "The extension schema",
"description": "File extension of the tool.",
"examples": [
".ext"
]
},
"fetch_latest": {
"type": "string",
"title": "The fetch_latest schema",
"description": "Fetch the latest version from GitHub releases.",
"enum": [
"true",
"false"
]
},
"function": {
"type": "string",
"title": "The function schema",
"description": "Function name in tools.ts which returns the script to setup the tool.",
"examples": [
"function_name"
]
},
"repository": {
"type": "string",
"title": "The repository schema",
"description": "GitHub repository of the tool.",
"examples": [
"user/tool"
]
},
"packagist": {
"type": "string",
"title": "The repository schema",
"description": "Packagist repository of the tool in case different from repository.",
"examples": [
"user/tool"
]
},
"scope": {
"type": "string",
"title": "The scope schema",
"description": "Scope of tool installation: global or scoped",
"enum": [
"global",
"scoped"
]
},
"type": {
"type": "string",
"title": "The type schema",
"description": "Type of tool: phar, composer, custom-package or custom-function.",
"enum": [
"phar",
"composer",
"custom-package",
"custom-function"
]
},
"version_parameter": {
"type": "string",
"title": "The version_parameter schema",
"description": "Parameter to get the tool version.",
"examples": [
"--version"
]
},
"version_prefix": {
"type": "string",
"title": "The version_prefix schema",
"description": "Prefix of the version in the download URL.",
"examples": [
"v"
]
},
"fallback": {
"$ref": "#/$defs/pharFallback"
}
}, },
"domain": { "required": [
"$id": "#/items/properties/domain", "type"
"type": "string", ],
"title": "The domain schema", "additionalProperties": true
"description": "Domain URL of the tool.",
"examples": [
"https://example.com"
]
},
"extension": {
"$id": "#/items/properties/extension",
"type": "string",
"title": "The extension schema",
"description": "File extension of the tool.",
"examples": [
".ext"
]
},
"fetch_latest": {
"$id": "#/items/properties/fetch_latest",
"type": "string",
"title": "The fetch_latest schema",
"description": "Fetch the latest version from GitHub releases.",
"enum": [
"true",
"false"
]
},
"function": {
"$id": "#/items/properties/function",
"type": "string",
"title": "The function schema",
"description": "Function name in tools.ts which returns the script to setup the tool.",
"examples": [
"function_name"
]
},
"repository": {
"$id": "#/items/properties/repository",
"type": "string",
"title": "The repository schema",
"description": "GitHub repository of the tool.",
"examples": [
"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",
"title": "The scope schema",
"description": "Scope of tool installation: global or scoped",
"enum": [
"global",
"scoped"
]
},
"type": {
"$id": "#/items/properties/type",
"type": "string",
"title": "The type schema",
"description": "Type of tool: phar, composer, custom-package or custom-function.",
"enum": [
"phar",
"composer",
"custom-package",
"custom-function"
]
},
"version_parameter": {
"$id": "#/items/properties/version_parameter",
"type": "string",
"title": "The version_parameter schema",
"description": "Parameter to get the tool version.",
"examples": [
"--version"
]
},
"version_prefix": {
"$id": "#/items/properties/version_prefix",
"type": "string",
"title": "The version_prefix schema",
"description": "Prefix of the version in the download URL.",
"examples": [
"v"
]
}
}, },
"required": [ "pharFallback": {
"type" "type": "object",
], "title": "The fallback schema",
"additionalProperties": true "description": "PHAR installation settings used when Composer installation fails.",
"properties": {
"type": {
"const": "phar"
},
"repository": {
"$ref": "#/$defs/tool/properties/repository"
},
"domain": {
"$ref": "#/$defs/tool/properties/domain"
},
"extension": {
"$ref": "#/$defs/tool/properties/extension"
},
"fetch_latest": {
"$ref": "#/$defs/tool/properties/fetch_latest"
},
"version_parameter": {
"$ref": "#/$defs/tool/properties/version_parameter"
},
"version_prefix": {
"$ref": "#/$defs/tool/properties/version_prefix"
}
},
"required": [
"type"
],
"additionalProperties": false
}
} }
} }
+3 -3
View File
@@ -1,6 +1,6 @@
import * as utils from './utils'; import * as utils from './utils.js';
import * as extensions from './extensions'; import * as extensions from './extensions.js';
import * as config from './config'; import * as config from './config.js';
export async function checkXdebugError( export async function checkXdebugError(
extension: string, extension: string,
+1 -1
View File
@@ -1,4 +1,4 @@
import * as utils from './utils'; import * as utils from './utils.js';
/** /**
* Install and enable extensions for darwin * Install and enable extensions for darwin
+11 -8
View File
@@ -1,12 +1,15 @@
import {fileURLToPath} from 'url';
import path from 'path'; import path from 'path';
import fs from 'fs';
import {exec} from '@actions/exec'; import {exec} from '@actions/exec';
import * as config from './config'; import fs from 'fs';
import * as core from './core'; import * as config from './config.js';
import * as coverage from './coverage'; import * as core from './core.js';
import * as extensions from './extensions'; import * as coverage from './coverage.js';
import * as tools from './tools'; import * as extensions from './extensions.js';
import * as utils from './utils'; import * as tools from './tools.js';
import * as utils from './utils.js';
const dirname = path.dirname(fileURLToPath(import.meta.url));
/** /**
* Build the script * Build the script
@@ -16,7 +19,7 @@ import * as utils from './utils';
export async function getScript(os: string): Promise<string> { export async function getScript(os: string): Promise<string> {
const url = 'https://setup-php.com/sponsor'; const url = 'https://setup-php.com/sponsor';
const filename = os + (await utils.scriptExtension(os)); const filename = os + (await utils.scriptExtension(os));
const script_path = path.join(__dirname, '../src/scripts', filename); const script_path = path.join(dirname, '../src/scripts', filename);
const run_path = script_path.replace(os, 'run'); const run_path = script_path.replace(os, 'run');
const extension_csv: string = utils.sanitizeShellInput( const extension_csv: string = utils.sanitizeShellInput(
await utils.getInput('extensions', false), await utils.getInput('extensions', false),
+1 -1
View File
@@ -1,5 +1,5 @@
import * as cv from 'compare-versions'; import * as cv from 'compare-versions';
import * as fetch from './fetch'; import * as fetch from './fetch.js';
type RS = Record<string, string>; type RS = Record<string, string>;
type RSRS = Record<string, RS>; type RSRS = Record<string, RS>;
+24 -21
View File
@@ -13,10 +13,10 @@ handle_dependency_extensions() {
suffix="$(get_php_formula_suffix)" suffix="$(get_php_formula_suffix)"
if [[ -n "$suffix" ]]; then if [[ -n "$suffix" ]]; then
brew_opts=(-sf) brew_opts=(-sf)
patch_abstract_file patch_abstract_file >/dev/null 2>&1
for dependency_extension in "${dependency_extensions[@]}"; do for dependency_extension in "${dependency_extensions[@]}"; do
safe_brew install --skip-link "${brew_opts[@]}" "$ext_tap/$dependency_extension@$version" && safe_brew install --skip-link "${brew_opts[@]}" "$ext_tap/$dependency_extension@$version" >/dev/null 2>&1 &&
brew link --overwrite --force "$dependency_extension@$version" && brew link --overwrite --force "$dependency_extension@$version" >/dev/null 2>&1 &&
copy_brew_extensions "$dependency_extension" || return $? copy_brew_extensions "$dependency_extension" || return $?
done done
fi fi
@@ -33,7 +33,7 @@ disable_extension_helper() {
sudo sed -Ei '' "/=(.*\/)?\"?$extension(.so)?$/d" "${ini_file:?}" sudo sed -Ei '' "/=(.*\/)?\"?$extension(.so)?$/d" "${ini_file:?}"
sudo rm -rf "$scan_dir"/*"$extension"* /tmp/php"$version"_extensions sudo rm -rf "$scan_dir"/*"$extension"* /tmp/php"$version"_extensions
mkdir -p /tmp/extdisabled/"$version" mkdir -p /tmp/extdisabled/"$version"
echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension" echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension" >/dev/null 2>&1
} }
# Function to get extension name from brew formula. # Function to get extension name from brew formula.
@@ -100,13 +100,13 @@ add_brew_extension() {
SETUP_PHP_BREW_RETRY_ATTEMPTS=1 install_brew_extension "$formula" "$extension" || { SETUP_PHP_BREW_RETRY_ATTEMPTS=1 install_brew_extension "$formula" "$extension" || {
update_dependencies && install_brew_extension "$formula" "$extension" update_dependencies && install_brew_extension "$formula" "$extension"
} }
) || { ) >/dev/null 2>&1 || {
if [ -n "$expected_version" ]; then if [ -n "$expected_version" ]; then
pecl_install "$extension-$expected_version" || pecl_install "$extension" pecl_install "$extension-$expected_version" || pecl_install "$extension"
else else
pecl_install "$extension" pecl_install "$extension"
fi fi
} } >/dev/null 2>&1
add_extension_log "$extension" "Installed and enabled" add_extension_log "$extension" "Installed and enabled"
fi fi
} }
@@ -115,7 +115,7 @@ add_brew_extension() {
patch_abstract_file() { patch_abstract_file() {
abstract_path="$tap_dir"/"$ext_tap"/Abstract/abstract-php-extension.rb abstract_path="$tap_dir"/"$ext_tap"/Abstract/abstract-php-extension.rb
if [[ -e "$abstract_path" && ! -e /tmp/abstract_patch ]]; then if [[ -e "$abstract_path" && ! -e /tmp/abstract_patch ]]; then
echo '' | sudo tee /tmp/abstract_patch echo '' | sudo tee /tmp/abstract_patch >/dev/null 2>&1
sudo sed -i '' -e "s|php@#{\(.*\)}|php@#{\1}$suffix|g" -e "s|php_version /|\"#{php_version}$suffix\" /|g" "$abstract_path" sudo sed -i '' -e "s|php@#{\(.*\)}|php@#{\1}$suffix|g" -e "s|php_version /|\"#{php_version}$suffix\" /|g" "$abstract_path"
fi fi
} }
@@ -125,9 +125,9 @@ add_extension_helper() {
local extension=$1 local extension=$1
prefix=$2 prefix=$2
if [[ "$version" =~ ${old_versions:?} ]] && [ "$extension" = "imagick" ]; then if [[ "$version" =~ ${old_versions:?} ]] && [ "$extension" = "imagick" ]; then
run_script "php5-darwin" "${version/./}" "$extension" run_script "php5-darwin" "${version/./}" "$extension" >/dev/null 2>&1
else else
pecl_install "$extension" && pecl_install "$extension" >/dev/null 2>&1 &&
if [[ "$version" =~ ${old_versions:?} ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi if [[ "$version" =~ ${old_versions:?} ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi
fi fi
add_extension_log "$extension" "Installed and enabled" add_extension_log "$extension" "Installed and enabled"
@@ -141,8 +141,8 @@ add_devtools() {
# Function to handle request to add PECL. # Function to handle request to add PECL.
add_pecl() { add_pecl() {
enable_extension xml extension enable_extension xml extension >/dev/null 2>&1
configure_pecl configure_pecl >/dev/null 2>&1
pear_version=$(get_tool_version "pecl" "version") pear_version=$(get_tool_version "pecl" "version")
add_log "${tick:?}" "PECL" "Found PECL $pear_version" add_log "${tick:?}" "PECL" "Found PECL $pear_version"
} }
@@ -168,12 +168,16 @@ patch_brew() {
# Function to update dependencies. # Function to update dependencies.
update_dependencies() { update_dependencies() {
if ! [ -e /tmp/update_dependencies ]; then if ! [ -e /tmp/update_dependencies ]; then
for repo in "$brew_repo" "${core_repo:?}"; do local repos=("$brew_repo")
if [ -e "$repo" ]; then if [ -n "${HOMEBREW_NO_INSTALL_FROM_API:-}" ]; then
repos+=("${core_repo:?}")
fi
for repo in "${repos[@]}"; do
if [ -d "$repo" ]; then
git_retry -C "$repo" fetch origin main && git -C "$repo" reset --hard origin/main || return $? git_retry -C "$repo" fetch origin main && git -C "$repo" reset --hard origin/main || return $?
fi fi
done done
echo '' | sudo tee /tmp/update_dependencies echo '' | sudo tee /tmp/update_dependencies >/dev/null 2>&1
fi fi
patch_brew patch_brew
} }
@@ -194,7 +198,7 @@ get_brewed_php() {
# Function to setup PHP from the cached builds. # Function to setup PHP from the cached builds.
setup_cached_versions() { setup_cached_versions() {
latest="releases/download/php-$version" run_script \ latest="releases/download/php-$version" run_script \
"php-darwin" "$version" "${debug:?}" "${ts:?}" "" "${INPUT_EXTENSIONS:-}" "php-darwin" "$version" "${debug:?}" "${ts:?}" "" "${INPUT_EXTENSIONS:-}" >/dev/null 2>&1
} }
# Function to setup PHP 5.6 and newer using Homebrew. # Function to setup PHP 5.6 and newer using Homebrew.
@@ -262,7 +266,7 @@ add_php_config() {
if [[ "$ini" = "production" || "$ini" = "development" ]]; then if [[ "$ini" = "production" || "$ini" = "development" ]]; then
sudo cp "$ini_dir"/php.ini-"$ini" "$ini_dir"/php.ini sudo cp "$ini_dir"/php.ini-"$ini" "$ini_dir"/php.ini
elif [ "$ini" = "none" ]; then elif [ "$ini" = "none" ]; then
echo '' | sudo tee "${ini_file[@]}" echo '' | sudo tee "${ini_file[@]}" >/dev/null 2>&1
fi fi
} }
@@ -277,7 +281,7 @@ get_scan_dir() {
# Function to handle self-hosted runner setup. # Function to handle self-hosted runner setup.
self_hosted_helper() { self_hosted_helper() {
sudo mkdir -p /opt/hostedtoolcache || true sudo mkdir -p /opt/hostedtoolcache >/dev/null 2>&1 || true
} }
# Function to Setup PHP. # Function to Setup PHP.
@@ -289,10 +293,10 @@ setup_php() {
existing_version=$([ "$(uname -m)" != "x86_64" ] && get_brewed_php || echo false) existing_version=$([ "$(uname -m)" != "x86_64" ] && get_brewed_php || echo false)
status="Found" status="Found"
if [[ "$version" =~ ${old_versions:?} ]]; then if [[ "$version" =~ ${old_versions:?} ]]; then
run_script "php5-darwin" "${version/./}" run_script "php5-darwin" "${version/./}" >/dev/null 2>&1
status="Installed" status="Installed"
elif [[ "${existing_version:0:3}" != "$version" || -n "$(get_php_formula_suffix)" ]]; then elif [[ "${existing_version:0:3}" != "$version" || -n "$(get_php_formula_suffix)" ]]; then
add_php "install" "$existing_version" || { add_php "install" "$existing_version" >/dev/null 2>&1 || {
add_log "${cross:?}" "PHP" "Could not install PHP $version" add_log "${cross:?}" "PHP" "Could not install PHP $version"
exit 1 exit 1
} }
@@ -300,7 +304,7 @@ setup_php() {
elif [[ "${existing_version:0:3}" = "$version" && "${update:?}" = "true" ]]; then elif [[ "${existing_version:0:3}" = "$version" && "${update:?}" = "true" ]]; then
brew_php_version="$(brew info --json "php@$version" 2>/dev/null | jq -r '.[].versions.stable')" brew_php_version="$(brew info --json "php@$version" 2>/dev/null | jq -r '.[].versions.stable')"
if [ "$brew_php_version" != "$existing_version" ]; then if [ "$brew_php_version" != "$existing_version" ]; then
add_php "upgrade" "$existing_version" || { add_php "upgrade" "$existing_version" >/dev/null 2>&1 || {
add_log "${cross:?}" "PHP" "Could not upgrade PHP $version" add_log "${cross:?}" "PHP" "Could not upgrade PHP $version"
exit 1 exit 1
} }
@@ -341,7 +345,6 @@ export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_ENV_HINTS=1 export HOMEBREW_NO_ENV_HINTS=1
export HOMEBREW_NO_INSTALL_CLEANUP=1 export HOMEBREW_NO_INSTALL_CLEANUP=1
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
export HOMEBREW_NO_INSTALL_FROM_API=1
# shellcheck source=. # shellcheck source=.
. "${scripts:?}"/unix.sh . "${scripts:?}"/unix.sh
+13 -13
View File
@@ -25,7 +25,7 @@ check_extension() {
check_extension_version() { check_extension_version() {
local extension=$1 local extension=$1
local ext_version=$2 local ext_version=$2
php -d display_errors=0 -r "exit(phpversion(\$argv[1]) === \$argv[2] ? 0 : 1);" -- "$extension" "$ext_version" php -d display_errors=0 -r "exit(phpversion(\$argv[1]) === \$argv[2] ? 0 : 1);" -- "$extension" "$ext_version" >/dev/null 2>&1
} }
# Function to check if extension is shared # Function to check if extension is shared
@@ -57,7 +57,7 @@ enable_extension() {
[ -d "$modules_dir" ] && sudo find "$modules_dir" -path "*disabled*$1" -delete [ -d "$modules_dir" ] && sudo find "$modules_dir" -path "*disabled*$1" -delete
enable_extension_dependencies "$1" "$2" enable_extension_dependencies "$1" "$2"
enable_cache_extension_dependencies "$1" "$2" enable_cache_extension_dependencies "$1" "$2"
if ! [[ "${version:?}" =~ ${old_versions:?} ]] && command -v phpenmod ; then if ! [[ "${version:?}" =~ ${old_versions:?} ]] && command -v phpenmod >/dev/null 2>&1; then
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?\"?$/d" "$pecl_file" sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?\"?$/d" "$pecl_file"
mod="${ini_dir:?}"/../mods-available/"$1".ini mod="${ini_dir:?}"/../mods-available/"$1".ini
if ! [ -e "$mod" ]; then if ! [ -e "$mod" ]; then
@@ -66,7 +66,7 @@ enable_extension() {
[ -n "$mod_priority_line" ] && priority=$(echo "$mod_priority_line" | cut -d'=' -f 2) [ -n "$mod_priority_line" ] && priority=$(echo "$mod_priority_line" | cut -d'=' -f 2)
(echo "; priority=$priority"; echo "$2=${ext_dir:?}/$1.so") | sudo tee "$mod" >/dev/null (echo "; priority=$priority"; echo "$2=${ext_dir:?}/$1.so") | sudo tee "$mod" >/dev/null
fi fi
sudo phpenmod -v "$version" "$1" sudo phpenmod -v "$version" "$1" >/dev/null 2>&1
else else
echo "$2=${ext_dir:?}/$1.so" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null echo "$2=${ext_dir:?}/$1.so" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null
fi fi
@@ -78,7 +78,7 @@ enable_extensions() {
local extensions=("$@") local extensions=("$@")
to_wait=() to_wait=()
for ext in "${extensions[@]}"; do for ext in "${extensions[@]}"; do
enable_extension "$ext" extension & enable_extension "$ext" extension >/dev/null 2>&1 &
to_wait+=($!) to_wait+=($!)
done done
wait "${to_wait[@]}" wait "${to_wait[@]}"
@@ -86,7 +86,7 @@ enable_extensions() {
# Function to get a map of extensions and their dependent shared extensions. # Function to get a map of extensions and their dependent shared extensions.
get_extension_map() { get_extension_map() {
php -d'error_reporting=0' "${src:?}"/scripts/extensions/extension_map.php /tmp/map"$version".orig php -d'error_reporting=0' "${src:?}"/scripts/extensions/extension_map.php /tmp/map"$version".orig >/dev/null 2>&1
} }
# Function to enable extension dependencies which are also extensions. # Function to enable extension dependencies which are also extensions.
@@ -132,7 +132,7 @@ disable_extension() {
disable_all_shared() { disable_all_shared() {
get_extension_map get_extension_map
sudo sed -i.orig -E -e "/^(zend_)?extension\s*=/d" "${ini_file[@]}" "$pecl_file" 2>/dev/null || true sudo sed -i.orig -E -e "/^(zend_)?extension\s*=/d" "${ini_file[@]}" "$pecl_file" 2>/dev/null || true
sudo find "${ini_dir:-$scan_dir}"/.. -name "*.ini" -not -path "*php.ini" -not -path "*phar.ini" -not -path "*pecl.ini" -not -path "*mods-available*" -delete || true sudo find "${ini_dir:-$scan_dir}"/.. -name "*.ini" -not -path "*php.ini" -not -path "*phar.ini" -not -path "*pecl.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true
mkdir -p /tmp/extdisabled/"$version" mkdir -p /tmp/extdisabled/"$version"
sudo rm -f /tmp/php"$version"_extensions sudo rm -f /tmp/php"$version"_extensions
sudo find "$ext_dir" -name '*.so' -print0 | xargs -0 -n 1 basename -s .so | xargs -I{} touch /tmp/extdisabled/"$version"/{} sudo find "$ext_dir" -name '*.so' -print0 | xargs -0 -n 1 basename -s .so | xargs -I{} touch /tmp/extdisabled/"$version"/{}
@@ -146,7 +146,7 @@ configure_pecl() {
for script in pear pecl; do for script in pear pecl; do
sudo "$script" channel-update "$script".php.net sudo "$script" channel-update "$script".php.net
done done
echo '' | sudo tee /tmp/pecl_config echo '' | sudo tee /tmp/pecl_config >/dev/null 2>&1
fi fi
} }
@@ -184,8 +184,8 @@ get_pecl_version() {
pecl_install() { pecl_install() {
local extension=$1 local extension=$1
local prefix=${2:-extension} local prefix=${2:-extension}
add_pecl add_pecl >/dev/null 2>&1
disable_extension_helper "${extension%-*}" disable_extension_helper "${extension%-*}" >/dev/null 2>&1
# Compare version with 8.3 so it runs only on 8.4 and above # Compare version with 8.3 so it runs only on 8.4 and above
# Install using the source interface as it allows for patching. # Install using the source interface as it allows for patching.
if [[ $(printf "%s\n%s" "${version:?}" "8.3" | sort -V | head -n1) != "$version" ]]; then if [[ $(printf "%s\n%s" "${version:?}" "8.3" | sort -V | head -n1) != "$version" ]]; then
@@ -199,11 +199,11 @@ pecl_install() {
IFS=' ' read -r -a prefix_opts <<<"$(parse_args "$extension" CONFIGURE_PREFIX_OPTS)" IFS=' ' read -r -a prefix_opts <<<"$(parse_args "$extension" CONFIGURE_PREFIX_OPTS)"
suffix_opts="$(parse_args "$extension" CONFIGURE_OPTS) $(parse_args "$extension" CONFIGURE_SUFFIX_OPTS)" suffix_opts="$(parse_args "$extension" CONFIGURE_OPTS) $(parse_args "$extension" CONFIGURE_SUFFIX_OPTS)"
IFS=' ' read -r -a libraries <<<"$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)" IFS=' ' read -r -a libraries <<<"$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)"
(( ${#libraries[@]} )) && add_libs "${libraries[@]}" (( ${#libraries[@]} )) && add_libs "${libraries[@]}" >/dev/null 2>&1
if [ "$version" = "5.3" ]; then if [ "$version" = "5.3" ]; then
yes '' 2>/dev/null | sudo env "${prefix_opts[@]}" MAKEFLAGS="-j $cpu_count" pecl install -f "$extension" yes '' 2>/dev/null | sudo env "${prefix_opts[@]}" MAKEFLAGS="-j $cpu_count" pecl install -f "$extension" >/dev/null 2>&1
else else
yes '' 2>/dev/null | sudo env "${prefix_opts[@]}" MAKEFLAGS="-j $cpu_count" pecl install -f -D "$(parse_pecl_configure_options "$suffix_opts")" "$extension" yes '' 2>/dev/null | sudo env "${prefix_opts[@]}" MAKEFLAGS="-j $cpu_count" pecl install -f -D "$(parse_pecl_configure_options "$suffix_opts")" "$extension" >/dev/null 2>&1
fi fi
local exit_code=$? local exit_code=$?
sudo pecl info "$extension" 2>/dev/null | grep -iq 'zend extension' && prefix=zend_extension sudo pecl info "$extension" 2>/dev/null | grep -iq 'zend extension' && prefix=zend_extension
@@ -233,7 +233,7 @@ add_pecl_extension() {
else else
[ -n "$pecl_version" ] && sudo rm -f "${ext_dir:?}/$extension-$pecl_version" [ -n "$pecl_version" ] && sudo rm -f "${ext_dir:?}/$extension-$pecl_version"
[ -n "$pecl_version" ] && pecl_version="-$pecl_version" [ -n "$pecl_version" ] && pecl_version="-$pecl_version"
pecl_install "$extension$pecl_version" || ( [ "${fail_fast:?}" = "false" ] && add_extension "$extension" "$(get_extension_prefix "$extension")" ) pecl_install "$extension$pecl_version" || ( [ "${fail_fast:?}" = "false" ] && add_extension "$extension" "$(get_extension_prefix "$extension")" >/dev/null 2>&1)
extension_version="$(php -r "echo phpversion('$extension');")" extension_version="$(php -r "echo phpversion('$extension');")"
if [ -n "$pecl_version" ] && [ "${extension_version/-/}" = "${pecl_version#-}" ]; then if [ -n "$pecl_version" ] && [ "${extension_version/-/}" = "${pecl_version#-}" ]; then
sudo cp "${ext_dir:?}/$extension.so" "${ext_dir:?}/$extension-$extension_version" 2>/dev/null || true sudo cp "${ext_dir:?}/$extension.so" "${ext_dir:?}/$extension-$extension_version" 2>/dev/null || true
+3 -3
View File
@@ -19,11 +19,11 @@ add_blackfire() {
extension_version=$(get -s -n "" https://blackfire.io/api/v1/releases | grep -Eo 'php":"([0-9]+.[0-9]+.[0-9]+)' | cut -d '"' -f 3) extension_version=$(get -s -n "" https://blackfire.io/api/v1/releases | grep -Eo 'php":"([0-9]+.[0-9]+.[0-9]+)' | cut -d '"' -f 3)
fi fi
fi fi
get -q -n "${ext_dir:?}/blackfire.so" https://packages.blackfire.io/binaries/blackfire-php/"$extension_version"/blackfire-php-"$platform"_"$arch_name"-php-"$no_dot_version".so get -q -n "${ext_dir:?}/blackfire.so" https://packages.blackfire.io/binaries/blackfire-php/"$extension_version"/blackfire-php-"$platform"_"$arch_name"-php-"$no_dot_version".so >/dev/null 2>&1
fi fi
if [ -e "${ext_dir:?}/blackfire.so" ]; then if [ -e "${ext_dir:?}/blackfire.so" ]; then
disable_extension xdebug disable_extension xdebug >/dev/null 2>&1
disable_extension pcov disable_extension pcov >/dev/null 2>&1
enable_extension blackfire extension enable_extension blackfire extension
add_extension_log blackfire "$status" add_extension_log blackfire "$status"
else else
+5 -5
View File
@@ -60,9 +60,9 @@ add_couchbase() {
fi fi
if [[ "$ext" =~ couchbase-[2-3].+ ]]; then if [[ "$ext" =~ couchbase-[2-3].+ ]]; then
export COUCHBASE_CONFIGURE_PREFIX_OPTS="${COUCHBASE_CONFIGURE_PREFIX_OPTS:-} SED=sed CFLAGS=-Wno-error=incompatible-pointer-types" export COUCHBASE_CONFIGURE_PREFIX_OPTS="${COUCHBASE_CONFIGURE_PREFIX_OPTS:-} SED=sed CFLAGS=-Wno-error=incompatible-pointer-types"
add_couchbase_clibs "$ext" add_couchbase_clibs "$ext" >/dev/null 2>&1
else else
add_couchbase_cxxlibs add_couchbase_cxxlibs >/dev/null 2>&1
if [[ "$ext" =~ ^couchbase-4\.1\. ]]; then if [[ "$ext" =~ ^couchbase-4\.1\. ]]; then
export COUCHBASE_CONFIGURE_PREFIX_OPTS="${COUCHBASE_CONFIGURE_PREFIX_OPTS:-} COUCHBASE_CMAKE_EXTRA=-DCMAKE_POLICY_VERSION_MINIMUM=3.5" export COUCHBASE_CONFIGURE_PREFIX_OPTS="${COUCHBASE_CONFIGURE_PREFIX_OPTS:-} COUCHBASE_CMAKE_EXTRA=-DCMAKE_POLICY_VERSION_MINIMUM=3.5"
fi fi
@@ -82,9 +82,9 @@ add_couchbase() {
install_method=add_extension_from_source install_method=add_extension_from_source
fi fi
if [ "$install_method" = add_extension_from_source ]; then if [ "$install_method" = add_extension_from_source ]; then
add_extension_from_source couchbase https://pecl.php.net couchbase couchbase "${ext##*-}" extension pecl add_extension_from_source couchbase https://pecl.php.net couchbase couchbase "${ext##*-}" extension pecl >/dev/null 2>&1
else else
"$install_method" "${ext}" "$install_method" "${ext}" >/dev/null 2>&1
fi fi
add_extension_log "couchbase" "Installed and enabled" add_extension_log "couchbase" "Installed and enabled"
fi fi
@@ -103,6 +103,6 @@ add_couchbase() {
fi fi
add_brew_extension couchbase extension add_brew_extension couchbase extension
find "${brew_prefix:?}/lib" "${brew_prefix:?}/opt/couchbase@${version:?}" "${brew_prefix:?}/Cellar/couchbase@${version:?}" \ find "${brew_prefix:?}/lib" "${brew_prefix:?}/opt/couchbase@${version:?}" "${brew_prefix:?}/Cellar/couchbase@${version:?}" \
-name 'libcouchbase_php*.dylib' -exec sudo cp {} "${ext_dir:?}" \; -name 'libcouchbase_php*.dylib' -exec sudo cp {} "${ext_dir:?}" \; >/dev/null 2>&1
fi fi
} }
+1 -1
View File
@@ -42,7 +42,7 @@ add_cubrid_helper() {
add_cubrid() { add_cubrid() {
ext=$1 ext=$1
status='Enabled' status='Enabled'
add_cubrid_helper "$ext" add_cubrid_helper "$ext" >/dev/null 2>&1
add_extension_log "$ext" "$status" add_extension_log "$ext" "$status"
check_extension "$ext" && add_license_log check_extension "$ext" && add_license_log
} }
+2 -2
View File
@@ -39,9 +39,9 @@ add_event() {
add_log "${tick:?}" "event" "Enabled" add_log "${tick:?}" "event" "Enabled"
else else
if ! [[ "${version:?}" =~ ${old_versions:?} ]] && [ "$os" = "Darwin" ]; then if ! [[ "${version:?}" =~ ${old_versions:?} ]] && [ "$os" = "Darwin" ]; then
add_brew_extension event extension add_brew_extension event extension >/dev/null 2>&1
else else
add_event_helper "$ext" add_event_helper "$ext" >/dev/null 2>&1
fi fi
add_extension_log "event" "Installed and enabled" add_extension_log "event" "Installed and enabled"
fi fi
+3 -3
View File
@@ -15,12 +15,12 @@ add_firebird() {
else else
if [ "$(uname -s)" = "Linux" ]; then if [ "$(uname -s)" = "Linux" ]; then
if [[ "${version:?}" =~ 5.3|${php_builder_versions:?} ]]; then if [[ "${version:?}" =~ 5.3|${php_builder_versions:?} ]]; then
add_firebird_helper /usr add_firebird_helper /usr >/dev/null 2>&1
else else
add_pdo_extension firebird add_pdo_extension firebird >/dev/null 2>&1
fi fi
else else
add_brew_extension pdo_firebird extension add_brew_extension pdo_firebird extension >/dev/null 2>&1
fi fi
add_extension_log pdo_firebird "Installed and enabled" add_extension_log pdo_firebird "Installed and enabled"
fi fi
+1 -1
View File
@@ -19,7 +19,7 @@ add_gearman_helper() {
add_gearman() { add_gearman() {
status="Enabled" status="Enabled"
if [ "$(uname -s)" = 'Linux' ]; then if [ "$(uname -s)" = 'Linux' ]; then
add_gearman_helper add_gearman_helper >/dev/null 2>&1
add_extension_log "gearman" "$status" add_extension_log "gearman" "$status"
else else
add_brew_extension gearman extension add_brew_extension gearman extension
+1 -1
View File
@@ -15,7 +15,7 @@ add_geos() {
if check_extension "geos"; then if check_extension "geos"; then
add_log "${tick:?}" "geos" "Enabled" add_log "${tick:?}" "geos" "Enabled"
else else
add_geos_helper add_geos_helper >/dev/null 2>&1
add_extension_log "geos" "Installed and enabled" add_extension_log "geos" "Installed and enabled"
fi fi
} }
+4 -4
View File
@@ -42,12 +42,12 @@ Function Repair-ICU() {
} }
Function Add-Http() { Function Add-Http() {
Add-Extension iconv Add-Extension iconv >$null 2>&1
Add-Extension raphf Add-Extension raphf >$null 2>&1
if($version -lt '8.0') { if($version -lt '8.0') {
Add-Extension propro Add-Extension propro >$null 2>&1
} }
Add-Extension pecl_http Add-Extension pecl_http >$null 2>&1
Repair-ICU Repair-ICU
Add-ExtensionLog http "Installed and enabled" Add-ExtensionLog http "Installed and enabled"
} }
+3 -3
View File
@@ -75,7 +75,7 @@ add_http_latest() {
if [ "$os" = "Linux" ]; then if [ "$os" = "Linux" ]; then
add_http_dependencies add_http_dependencies
package="php$version-http" package="php$version-http"
add_ppa ondrej/php || update_ppa ondrej/php add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
(check_package "$package" && install_packages "$package") || add_http_helper "$(get_http_version)" "$os" (check_package "$package" && install_packages "$package") || add_http_helper "$(get_http_version)" "$os"
else else
if ! [[ "${version:?}" =~ ${old_versions:?} ]]; then if ! [[ "${version:?}" =~ ${old_versions:?} ]]; then
@@ -103,9 +103,9 @@ add_http() {
ext=$1 ext=$1
status="Enabled" status="Enabled"
if [[ "$ext" =~ ^(pecl_http|http)$ ]]; then if [[ "$ext" =~ ^(pecl_http|http)$ ]]; then
add_http_latest add_http_latest >/dev/null 2>&1
else else
add_http_version "$ext" add_http_version "$ext" >/dev/null 2>&1
fi fi
add_extension_log "http" "$status" add_extension_log "http" "$status"
} }
+3 -3
View File
@@ -71,7 +71,7 @@ add_cli_driver() {
else else
libs='/usr/local/lib' libs='/usr/local/lib'
sudo mkdir -p "$libs" sudo mkdir -p "$libs"
sudo ln -sf "$ibm_cli"/lib/*.dylib "$libs" || true sudo ln -sf "$ibm_cli"/lib/*.dylib "$libs" >/dev/null 2>&1 || true
fi fi
} }
@@ -104,11 +104,11 @@ add_ibm() {
status='Enabled' status='Enabled'
ibm_home='/opt/ibm' ibm_home='/opt/ibm'
ibm_cli=$ibm_home/clidriver ibm_cli=$ibm_home/clidriver
if ! add_cli_driver ; then if ! add_cli_driver >/dev/null 2>&1; then
add_log "${cross:?}" "$ext" "IBM Db2 CLI driver is not available on $(uname -s)/$(uname -m)" add_log "${cross:?}" "$ext" "IBM Db2 CLI driver is not available on $(uname -s)/$(uname -m)"
return 1 return 1
fi fi
add_ibm_helper add_ibm_helper >/dev/null 2>&1
add_extension_log "$ext" "$status" add_extension_log "$ext" "$status"
check_extension "$ext" && add_license_log check_extension "$ext" && add_license_log
} }
+1 -1
View File
@@ -17,7 +17,7 @@ add_intl() {
add_log "${cross:?}" "intl" "ICU $icu is not supported for PHP $version" add_log "${cross:?}" "intl" "ICU $icu is not supported for PHP $version"
else else
[ "${ts:?}" = 'zts' ] && suffix='-zts' [ "${ts:?}" = 'zts' ] && suffix='-zts'
install_icu "$icu" install_icu "$icu" >/dev/null 2>&1
get -q -n "${ext_dir:?}/intl.so" "https://github.com/shivammathur/icu-intl/releases/download/intl-$icu/php${version:?}-intl-$icu$suffix$arch_suffix.so" get -q -n "${ext_dir:?}/intl.so" "https://github.com/shivammathur/icu-intl/releases/download/intl-$icu/php${version:?}-intl-$icu$suffix$arch_suffix.so"
enable_extension intl extension enable_extension intl extension
add_extension_log intl "Installed and enabled with ICU $icu" add_extension_log intl "Installed and enabled with ICU $icu"
+2 -2
View File
@@ -24,10 +24,10 @@ add_ioncube() {
if [ -e "$loader_file" ]; then if [ -e "$loader_file" ]; then
sudo mv /tmp/ioncube/ioncube_loader_"${os_suffix%%_*}_${version:?}$ts_part".so "${ext_dir:?}/ioncube.so" sudo mv /tmp/ioncube/ioncube_loader_"${os_suffix%%_*}_${version:?}$ts_part".so "${ext_dir:?}/ioncube.so"
sudo cp /tmp/ioncube/LICENSE.txt "$ext_dir"/IONCUBE_LICENSE.txt sudo cp /tmp/ioncube/LICENSE.txt "$ext_dir"/IONCUBE_LICENSE.txt
echo "zend_extension=$ext_dir/ioncube.so" | sudo tee "${scan_dir:?}/00-ioncube.ini" echo "zend_extension=$ext_dir/ioncube.so" | sudo tee "${scan_dir:?}/00-ioncube.ini" >/dev/null 2>&1
fi fi
else else
echo "zend_extension=$ext_dir/ioncube.so" | sudo tee "${scan_dir:?}/00-ioncube.ini" echo "zend_extension=$ext_dir/ioncube.so" | sudo tee "${scan_dir:?}/00-ioncube.ini" >/dev/null 2>&1
fi fi
add_extension_log "ioncube" "$status" add_extension_log "ioncube" "$status"
check_extension "ioncube" && add_license_log check_extension "ioncube" && add_license_log
+1 -1
View File
@@ -71,7 +71,7 @@ Function Add-Oci() {
} }
} else { } else {
$status = 'Installed and enabled' $status = 'Installed and enabled'
Add-Extension $extension Add-Extension $extension >$null 2>&1
} }
Add-ExtensionLog $extension $status Add-ExtensionLog $extension $status
Add-LicenseLog Add-LicenseLog
+2 -2
View File
@@ -82,8 +82,8 @@ add_oci() {
oracle_home='/opt/oracle' oracle_home='/opt/oracle'
oracle_client=$oracle_home/instantclient oracle_client=$oracle_home/instantclient
os=$(uname -s) os=$(uname -s)
add_client add_client >/dev/null 2>&1
add_oci_helper add_oci_helper >/dev/null 2>&1
add_extension_log "$ext" "$status" add_extension_log "$ext" "$status"
check_extension "$ext" && add_license_log check_extension "$ext" && add_license_log
} }
+2 -2
View File
@@ -36,7 +36,7 @@ add_phalcon_helper() {
add_brew_extension "$extension" extension add_brew_extension "$extension" extension
else else
package="php${version:?}-$extension" package="php${version:?}-$extension"
add_ppa ondrej/php || update_ppa ondrej/php add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
[[ "$extension" =~ phalcon[4|5] ]] && (install_packages "php${version:?}-psr" || pecl_install psr || pecl_install psr-1.1.0) [[ "$extension" =~ phalcon[4|5] ]] && (install_packages "php${version:?}-psr" || pecl_install psr || pecl_install psr-1.1.0)
(check_package "$package" && install_packages "$package") || pecl_install phalcon-"$(get_phalcon_version)" || add_phalcon_from_repo (check_package "$package" && install_packages "$package") || pecl_install phalcon-"$(get_phalcon_version)" || add_phalcon_from_repo
fi fi
@@ -96,7 +96,7 @@ add_phalcon() {
[ "$extension" = "phalcon" ] && extension=phalcon5 [ "$extension" = "phalcon" ] && extension=phalcon5
extension_major_version=${extension: -1} extension_major_version=${extension: -1}
if [[ "$extension_major_version" =~ [3-5] ]]; then if [[ "$extension_major_version" =~ [3-5] ]]; then
add_phalcon"$extension_major_version" add_phalcon"$extension_major_version" >/dev/null 2>&1
fi fi
add_extension_log "phalcon" "$status" add_extension_log "phalcon" "$status"
} }
+3 -3
View File
@@ -149,14 +149,14 @@ add_relay() {
error="Relay extension is not available for macOS x86_64 architecture" error="Relay extension is not available for macOS x86_64 architecture"
else else
relay_version=$(get_relay_version "$ext") relay_version=$(get_relay_version "$ext")
add_relay_dependencies add_relay_dependencies >/dev/null 2>&1
if shared_extension relay; then if shared_extension relay; then
message="Enabled" message="Enabled"
else else
add_relay_helper "$arch" add_relay_helper "$arch" >/dev/null 2>&1
message="Installed and enabled ${relay_version}" message="Installed and enabled ${relay_version}"
fi fi
configure_relay configure_relay >/dev/null 2>&1
fi fi
add_extension_log relay "$message" "$error" add_extension_log relay "$message" "$error"
} }
+7 -7
View File
@@ -51,7 +51,7 @@ check_lib() {
add_linux_libs() { add_linux_libs() {
local lib=$1 local lib=$1
if ! check_lib "$lib"; then if ! check_lib "$lib"; then
install_packages "$lib" || true install_packages "$lib" >/dev/null 2>&1 || true
fi fi
add_lib_log "$lib" add_lib_log "$lib"
} }
@@ -61,10 +61,10 @@ add_darwin_libs() {
local lib=$1 local lib=$1
if ! check_lib "$lib"; then if ! check_lib "$lib"; then
if [[ "$lib" = *@* ]]; then if [[ "$lib" = *@* ]]; then
safe_brew install --skip-link "$lib" || true safe_brew install --skip-link "$lib" >/dev/null 2>&1 || true
brew link --overwrite --force "$lib" || true brew link --overwrite --force "$lib" >/dev/null 2>&1 || true
else else
safe_brew install "$lib" || true safe_brew install "$lib" >/dev/null 2>&1 || true
fi fi
fi fi
add_lib_log "$lib" add_lib_log "$lib"
@@ -99,7 +99,7 @@ get_libraries() {
run_group() { run_group() {
local command=$1 local command=$1
local log=$2 local log=$2
echo "$command" | sudo tee ./run_group.sh echo "$command" | sudo tee ./run_group.sh >/dev/null 2>&1
echo "$GROUP$log" echo "$GROUP$log"
. ./run_group.sh . ./run_group.sh
local status=$? local status=$?
@@ -163,7 +163,7 @@ add_extension_from_source() {
sub_dir="$(parse_args "$extension" PATH)" sub_dir="$(parse_args "$extension" PATH)"
step_log "Setup $slug" step_log "Setup $slug"
( (
add_devtools phpize add_devtools phpize >/dev/null 2>&1
disable_extension_helper "$extension" disable_extension_helper "$extension"
fetch_extension "$extension" "$fetch" fetch_extension "$extension" "$fetch"
if ! [ "$(find . -maxdepth 1 -name '*.m4' -exec grep -H 'PHP_NEW_EXTENSION' {} \; | wc -l)" != "0" ]; then if ! [ "$(find . -maxdepth 1 -name '*.m4' -exec grep -H 'PHP_NEW_EXTENSION' {} \; | wc -l)" != "0" ]; then
@@ -171,7 +171,7 @@ add_extension_from_source() {
else else
[[ -n "${libraries// }" ]] && run_group "add_libs $libraries" "add libraries" [[ -n "${libraries// }" ]] && run_group "add_libs $libraries" "add libraries"
[ "${debug:?}" = "debug" ] && suffix_opts="$suffix_opts --enable-debug" [ "${debug:?}" = "debug" ] && suffix_opts="$suffix_opts --enable-debug"
patch_extension "$extension" patch_extension "$extension" >/dev/null 2>&1
run_group "phpize" "phpize" && \ run_group "phpize" "phpize" && \
run_group "sudo $prefix_opts ./configure $suffix_opts $opts" "configure" && \ run_group "sudo $prefix_opts ./configure $suffix_opts $opts" "configure" && \
run_group "sudo $prefix_opts make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu)" "make" && \ run_group "sudo $prefix_opts make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu)" "make" && \
+2 -2
View File
@@ -69,10 +69,10 @@ Function Add-Sqlsrv() {
Add-ExtensionFromGithub $extension > $null 2>&1 Add-ExtensionFromGithub $extension > $null 2>&1
} catch {} } catch {}
if (-not(Test-Extension $extension)) { if (-not(Test-Extension $extension)) {
Add-SqlsrvFromMSGithub $extension Add-SqlsrvFromMSGithub $extension >$null 2>&1
} }
if (-not(Test-Extension $extension)) { if (-not(Test-Extension $extension)) {
Add-Extension $extension Add-Extension $extension >$null 2>&1
} }
$status = 'Installed and enabled' $status = 'Installed and enabled'
} }
+1 -1
View File
@@ -77,7 +77,7 @@ Function Add-ZephirParser() {
try { try {
Add-ZephirParserFromGitHub $extension Add-ZephirParserFromGitHub $extension
} catch { } catch {
Add-Extension $extension Add-Extension $extension >$null 2>&1
} }
} }
Add-ExtensionLog zephir_parser $status Add-ExtensionLog zephir_parser $status
+1 -1
View File
@@ -33,7 +33,7 @@ add_zephir_parser() {
zp_releases=https://github.com/"$repo"/releases zp_releases=https://github.com/"$repo"/releases
if ! shared_extension zephir_parser; then if ! shared_extension zephir_parser; then
message='Installed and enabled' message='Installed and enabled'
add_zephir_parser_helper "$ext" add_zephir_parser_helper "$ext" >/dev/null 2>&1
else else
message='Enabled' message='Enabled'
enable_extension zephir_parser extension enable_extension zephir_parser extension
+28 -28
View File
@@ -20,23 +20,23 @@ self_hosted_helper() {
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
trap "sudo rm -f /usr/bin/apt-fast 2>/dev/null" exit trap "sudo rm -f /usr/bin/apt-fast 2>/dev/null" exit
fi fi
sudo mkdir -p /opt/hostedtoolcache || true sudo mkdir -p /opt/hostedtoolcache >/dev/null 2>&1 || true
install_packages apt-transport-https ca-certificates curl file make jq unzip autoconf automake gcc g++ gnupg install_packages apt-transport-https ca-certificates curl file make jq unzip autoconf automake gcc g++ gnupg
} }
# Function to fix broken packages. # Function to fix broken packages.
fix_broken_packages() { fix_broken_packages() {
sudo apt --fix-broken install sudo apt --fix-broken install >/dev/null 2>&1
} }
# Function to install a package # Function to install a package
install_packages() { install_packages() {
packages=("$@") packages=("$@")
if ! [ -e /etc/dpkg/dpkg.cfg.d/force-confnew ]; then if ! [ -e /etc/dpkg/dpkg.cfg.d/force-confnew ]; then
echo "force-confnew" | sudo tee /etc/dpkg/dpkg.cfg.d/force-confnew echo "force-confnew" | sudo tee /etc/dpkg/dpkg.cfg.d/force-confnew >/dev/null 2>&1
trap "sudo rm -f /etc/dpkg/dpkg.cfg.d/force-confnew 2>/dev/null" exit trap "sudo rm -f /etc/dpkg/dpkg.cfg.d/force-confnew 2>/dev/null" exit
fi fi
$apt_install "${packages[@]}" || (update_lists && fix_broken_packages && $apt_install "${packages[@]}" ) $apt_install "${packages[@]}" >/dev/null 2>&1 || (update_lists && fix_broken_packages && $apt_install "${packages[@]}" >/dev/null 2>&1)
} }
# Function to disable an extension. # Function to disable an extension.
@@ -48,10 +48,10 @@ disable_extension_helper() {
disable_extension_dependents "$extension" disable_extension_dependents "$extension"
fi fi
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?\"?$/d" "${ini_file[@]}" "$pecl_file" sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?\"?$/d" "${ini_file[@]}" "$pecl_file"
sudo find "$ini_dir"/.. -name "*-$extension.ini" -not -path "*phar.ini" -not -path "*pecl.ini" -not -path "*mods-available*" -delete || true sudo find "$ini_dir"/.. -name "*-$extension.ini" -not -path "*phar.ini" -not -path "*pecl.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true
sudo rm -f /tmp/php"$version"_extensions sudo rm -f /tmp/php"$version"_extensions
mkdir -p /tmp/extdisabled/"$version" mkdir -p /tmp/extdisabled/"$version"
echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension" echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension" >/dev/null 2>&1
} }
# Function to add PDO extension. # Function to add PDO extension.
@@ -64,7 +64,7 @@ add_pdo_extension() {
ext_name=$1 ext_name=$1
if shared_extension pdo; then if shared_extension pdo; then
disable_extension_helper pdo disable_extension_helper pdo
echo "extension=pdo.so" | sudo tee "${ini_file[@]/php.ini/conf.d/10-pdo.ini}" echo "extension=pdo.so" | sudo tee "${ini_file[@]/php.ini/conf.d/10-pdo.ini}" >/dev/null 2>&1
fi fi
if [ "$ext" = "mysql" ]; then if [ "$ext" = "mysql" ]; then
enable_extension "mysqlnd" "extension" enable_extension "mysqlnd" "extension"
@@ -72,15 +72,15 @@ add_pdo_extension() {
elif [ "$ext" = "dblib" ]; then elif [ "$ext" = "dblib" ]; then
ext_name="sybase" ext_name="sybase"
elif [ "$ext" = "firebird" ]; then elif [ "$ext" = "firebird" ]; then
install_packages libfbclient2 install_packages libfbclient2 >/dev/null 2>&1
enable_extension "pdo_firebird" "extension" enable_extension "pdo_firebird" "extension"
ext_name="interbase" ext_name="interbase"
elif [ "$ext" = "sqlite" ]; then elif [ "$ext" = "sqlite" ]; then
ext="sqlite3" ext="sqlite3"
ext_name="sqlite3" ext_name="sqlite3"
fi fi
add_extension "$ext_name" "extension" add_extension "$ext_name" "extension" >/dev/null 2>&1
add_extension "$pdo_ext" "extension" add_extension "$pdo_ext" "extension" >/dev/null 2>&1
add_extension_log "$pdo_ext" "Enabled" add_extension_log "$pdo_ext" "Enabled"
fi fi
} }
@@ -94,7 +94,7 @@ check_package() {
add_extension_helper() { add_extension_helper() {
local extension=$1 local extension=$1
packages=(php"$version"-"$extension") packages=(php"$version"-"$extension")
add_ppa ondrej/php || update_ppa ondrej/php add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
[ "${debug:?}" = "debug" ] && check_package php"$version"-"$extension"-dbgsym && packages+=(php"$version"-"$extension"-dbgsym) [ "${debug:?}" = "debug" ] && check_package php"$version"-"$extension"-dbgsym && packages+=(php"$version"-"$extension"-dbgsym)
(check_package "${packages[0]}" && install_packages "${packages[@]}") || pecl_install "$extension" (check_package "${packages[0]}" && install_packages "${packages[@]}") || pecl_install "$extension"
add_extension_log "$extension" "Installed and enabled" add_extension_log "$extension" "Installed and enabled"
@@ -108,7 +108,7 @@ add_devtools() {
install_packages "php$version-dev" install_packages "php$version-dev"
fi fi
switch_version "phpize" "php-config" switch_version "phpize" "php-config"
add_extension xml extension add_extension xml extension >/dev/null 2>&1
add_log "${tick:?}" "$tool" "Added $tool $semver" add_log "${tick:?}" "$tool" "Added $tool $semver"
} }
@@ -159,7 +159,7 @@ register_alternative() {
fi fi
link="$(alternative_link "$tool")" link="$(alternative_link "$tool")"
priority="${version//./}" priority="${version//./}"
sudo update-alternatives --install "$link" "$tool" "$target" "$priority" sudo update-alternatives --install "$link" "$tool" "$target" "$priority" >/dev/null 2>&1
} }
# Function to register and switch an alternative. # Function to register and switch an alternative.
@@ -169,16 +169,16 @@ set_alternative() {
target="$(alternative_target "$tool")" target="$(alternative_target "$tool")"
[ -e "$target" ] || return 0 [ -e "$target" ] || return 0
register_alternative "$tool" || return 1 register_alternative "$tool" || return 1
sudo update-alternatives --set "$tool" "$target" sudo update-alternatives --set "$tool" "$target" >/dev/null 2>&1
} }
# Function to add PECL. # Function to add PECL.
add_pecl() { add_pecl() {
add_devtools phpize add_devtools phpize >/dev/null 2>&1
if ! command -v pecl >/dev/null; then if ! command -v pecl >/dev/null; then
install_packages php-pear install_packages php-pear
fi fi
configure_pecl configure_pecl >/dev/null 2>&1
pear_version=$(get_tool_version "pecl" "version") pear_version=$(get_tool_version "pecl" "version")
add_log "${tick:?}" "PECL" "Added PECL $pear_version" add_log "${tick:?}" "PECL" "Added PECL $pear_version"
} }
@@ -207,7 +207,7 @@ get_php_packages() {
# Function to install packaged PHP # Function to install packaged PHP
add_packaged_php() { add_packaged_php() {
add_ppa ondrej/php || update_ppa ondrej/php add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
IFS=' ' read -r -a packages <<<"$(get_php_packages)" IFS=' ' read -r -a packages <<<"$(get_php_packages)"
install_packages "${packages[@]}" install_packages "${packages[@]}"
} }
@@ -231,7 +231,7 @@ add_php() {
setup_php_builder setup_php_builder
else else
add_packaged_php add_packaged_php
switch_version switch_version >/dev/null 2>&1
add_pecl add_pecl
fi fi
elif [[ "$version" =~ ${old_versions:?} ]]; then elif [[ "$version" =~ ${old_versions:?} ]]; then
@@ -244,7 +244,7 @@ add_php() {
# Function to ini file for pear and link it to each SAPI. # Function to ini file for pear and link it to each SAPI.
link_pecl_file() { link_pecl_file() {
echo '' | sudo tee "$pecl_file" echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
for file in "${ini_file[@]}"; do for file in "${ini_file[@]}"; do
sapi_scan_dir="$(realpath -m "$(dirname "$file")")/conf.d" sapi_scan_dir="$(realpath -m "$(dirname "$file")")/conf.d"
if [ "$sapi_scan_dir" != "$scan_dir" ] && ! [ -h "$sapi_scan_dir" ]; then if [ "$sapi_scan_dir" != "$scan_dir" ] && ! [ -h "$sapi_scan_dir" ]; then
@@ -277,9 +277,9 @@ add_php_config() {
elif [ "$ini" = "development" ]; then elif [ "$ini" = "development" ]; then
echo "${ini_file[@]}" | xargs -n 1 -P 6 sudo cp "$php_lib_dir"/php.ini-development echo "${ini_file[@]}" | xargs -n 1 -P 6 sudo cp "$php_lib_dir"/php.ini-development
elif [ "$ini" = "none" ]; then elif [ "$ini" = "none" ]; then
echo '' | sudo tee "${ini_file[@]}" echo '' | sudo tee "${ini_file[@]}" >/dev/null 2>&1
fi fi
echo "$ini" | sudo tee "$current_ini" echo "$ini" | sudo tee "$current_ini" >/dev/null 2>&1
} }
# Function to Setup PHP # Function to Setup PHP
@@ -293,13 +293,13 @@ setup_php() {
check_pre_installed check_pre_installed
if [[ -z "$php_config" ]] || [ "$(php_semver | cut -c 1-3)" != "$version" ]; then if [[ -z "$php_config" ]] || [ "$(php_semver | cut -c 1-3)" != "$version" ]; then
if [ ! -e "/usr/bin/php$version" ] || [ ! -e "/usr/bin/php-config$version" ]; then if [ ! -e "/usr/bin/php$version" ] || [ ! -e "/usr/bin/php-config$version" ]; then
add_php add_php >/dev/null 2>&1
else else
if ! [[ "$version" =~ ${old_versions:?} ]]; then if ! [[ "$version" =~ ${old_versions:?} ]]; then
switch_version switch_version >/dev/null 2>&1
fi fi
if [ "${update:?}" = "true" ]; then if [ "${update:?}" = "true" ]; then
update_php update_php >/dev/null 2>&1
else else
status="Switched to" status="Switched to"
fi fi
@@ -307,7 +307,7 @@ setup_php() {
php_config="$(command -v php-config)" php_config="$(command -v php-config)"
else else
if [ "$update" = "true" ]; then if [ "$update" = "true" ]; then
update_php update_php >/dev/null 2>&1
else else
status="Found" status="Found"
fi fi
@@ -327,7 +327,7 @@ setup_php() {
link_pecl_file link_pecl_file
configure_php configure_php
set_output "php-version" "$semver" set_output "php-version" "$semver"
sudo rm -rf /usr/local/bin/phpunit 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:?}"
sudo cp "$src"/configs/pm/*.json "$RUNNER_TOOL_CACHE/" sudo cp "$src"/configs/pm/*.json "$RUNNER_TOOL_CACHE/"
add_log "${tick:?}" "PHP" "$status PHP $semver$extra_version" add_log "${tick:?}" "PHP" "$status PHP $semver$extra_version"
@@ -341,8 +341,8 @@ debconf_fix="DEBIAN_FRONTEND=noninteractive"
apt_install="sudo $debconf_fix apt-fast install -y --no-install-recommends" apt_install="sudo $debconf_fix apt-fast install -y --no-install-recommends"
scripts="$src"/scripts scripts="$src"/scripts
add_sudo add_sudo >/dev/null 2>&1
link_apt_fast link_apt_fast >/dev/null 2>&1
. /etc/os-release . /etc/os-release
# shellcheck source=. # shellcheck source=.
+57 -16
View File
@@ -217,7 +217,7 @@ Function Add-ToolsHelper() {
$extensions += @('json', 'tokenizer') $extensions += @('json', 'tokenizer')
} elseif($tool -eq "phpDocumentor") { } elseif($tool -eq "phpDocumentor") {
$extensions+=('ctype', 'hash', 'json', 'fileinfo', 'iconv', 'mbstring', 'simplexml', 'xml') $extensions+=('ctype', 'hash', 'json', 'fileinfo', 'iconv', 'mbstring', 'simplexml', 'xml')
Add-Extension fileinfo Add-Extension fileinfo >$null 2>&1
Copy-Item $bin_dir\phpDocumentor.bat -Destination $bin_dir\phpdoc.bat Copy-Item $bin_dir\phpDocumentor.bat -Destination $bin_dir\phpdoc.bat
} elseif($tool -eq "phpunit") { } elseif($tool -eq "phpunit") {
$extensions += @('dom', 'json', 'libxml', 'mbstring', 'xml', 'xmlwriter') $extensions += @('dom', 'json', 'libxml', 'mbstring', 'xml', 'xmlwriter')
@@ -233,10 +233,30 @@ Function Add-ToolsHelper() {
Copy-Item $bin_dir\wp-cli.bat -Destination $bin_dir\wp.bat Copy-Item $bin_dir\wp-cli.bat -Destination $bin_dir\wp.bat
} }
foreach($extension in $extensions) { foreach($extension in $extensions) {
Add-Extension $extension Add-Extension $extension >$null 2>&1
} }
} }
# Function to find the newest stable release containing a tool asset.
Function Get-LastRelease($url) {
$releases_url = $url.Split('/latest/download/')[0]
$asset = $url.Split('/')[-1]
$page = 1
do {
$releases = (Get-File -Url "${releases_url}?page=$page&q=prerelease%3Afalse").Content
foreach ($match in [regex]::Matches($releases, 'src="([^"]+/releases/expanded_assets/[^"]+)"')) {
$assets_url = $match.Groups[1].Value
if (-not $assets_url.StartsWith("$releases_url/expanded_assets/")) { continue }
$download_path = $assets_url.Substring('https://github.com'.Length).Replace('/expanded_assets/', '/download/') + "/$asset"
$assets = (Get-File -Url $assets_url).Content
if ($assets.Contains("href=`"$download_path`"")) {
return "https://github.com$download_path"
}
}
$page++
} while ($releases.Contains('class="next_page"'))
}
# Function to add tools. # Function to add tools.
Function Add-Tool() { Function Add-Tool() {
Param ( Param (
@@ -288,15 +308,17 @@ Function Add-Tool() {
try { try {
$status_code = (Invoke-WebRequest -Passthru -Uri $url -OutFile $tool_path).StatusCode $status_code = (Invoke-WebRequest -Passthru -Uri $url -OutFile $tool_path).StatusCode
} catch { } catch {
if($url -match '.*github.com.*releases.*latest.*') { $status_code = 0
if($url -match '^https://github\.com/[^/]+/[^/]+/releases/latest/download/[^/?#]+$') {
try { try {
$url = $url.replace("releases/latest/download", "releases/download/" + ([regex]::match((Get-File -Url ($url.split('/release')[0] + "/releases")).Content, "([0-9]+\.[0-9]+\.[0-9]+)/" + ($url.Substring($url.LastIndexOf("/") + 1))).Groups[0].Value).split('/')[0]) $release_url = Get-LastRelease $url
$status_code = (Invoke-WebRequest -Passthru -Uri $url -OutFile $tool_path).StatusCode if ($release_url) {
$url = $release_url
$status_code = (Invoke-WebRequest -Passthru -Uri $url -OutFile $tool_path).StatusCode
}
} catch { } catch {
$status_code = 0 $status_code = 0
} }
} else {
$status_code = 0
} }
} }
if($status_code -eq 200 -and (Test-Path $tool_path)) { if($status_code -eq 200 -and (Test-Path $tool_path)) {
@@ -334,7 +356,7 @@ Function Add-Tool() {
$bat_content += "php %BIN_TARGET% %*" $bat_content += "php %BIN_TARGET% %*"
Set-Content -Path $bin_dir\$tool.bat -Value $bat_content Set-Content -Path $bin_dir\$tool.bat -Value $bat_content
Add-ToolsHelper $tool Add-ToolsHelper $tool
Add-ToProfile $current_profile $tool "New-Alias $tool $bin_dir\$tool.bat" Add-ToProfile $current_profile $tool "New-Alias $tool $bin_dir\$tool.bat" >$null 2>&1
$tool_version = Get-ToolVersion $tool $ver_param $tool_version = Get-ToolVersion $tool $ver_param
Add-Log $tick $tool "Added $tool $tool_version" Add-Log $tick $tool "Added $tool $tool_version"
} else { } else {
@@ -372,26 +394,36 @@ Function Add-ComposerToolHelper() {
Remove-Item -Path $composer_lock -Force Remove-Item -Path $composer_lock -Force
} }
if((composer global show $prefix$tool $tool_version -a 2>&1 | findstr '^type *: *composer-plugin') -and ($composer_args -ne '')) { if((composer global show $prefix$tool $tool_version -a 2>&1 | findstr '^type *: *composer-plugin') -and ($composer_args -ne '')) {
composer global config --no-plugins allow-plugins."$prefix$tool" true composer global config --no-plugins allow-plugins."$prefix$tool" true >$null 2>&1
}
composer global require $prefix$release $composer_args >$null 2>&1
if($LASTEXITCODE -ne 0) {
return
} }
composer global require $prefix$release $composer_args
return composer global show $prefix$tool 2>&1 | findstr '^versions' return composer global show $prefix$tool 2>&1 | findstr '^versions'
} else { } else {
$release_stream = [System.IO.MemoryStream]::New([System.Text.Encoding]::ASCII.GetBytes($release)) $release_stream = [System.IO.MemoryStream]::New([System.Text.Encoding]::ASCII.GetBytes($release))
$scoped_dir_suffix = (Get-FileHash -InputStream $release_stream -Algorithm sha256).Hash $scoped_dir_suffix = (Get-FileHash -InputStream $release_stream -Algorithm sha256).Hash
$scoped_dir = "$composer_bin\_tools\$tool-$scoped_dir_suffix" $scoped_dir = "$composer_bin\_tools\$tool-$scoped_dir_suffix"
$unix_scoped_dir = $scoped_dir.replace('\', '/') $unix_scoped_dir = $scoped_dir.replace('\', '/')
if(-not(Test-Path $scoped_dir)) { if(-not(Test-Path $scoped_dir\vendor\autoload.php)) {
New-Item -ItemType Directory -Force -Path $scoped_dir > $null 2>&1 New-Item -ItemType Directory -Force -Path $scoped_dir > $null 2>&1
Set-Content -Path $scoped_dir\composer.json -Value "{}" Set-Content -Path $scoped_dir\composer.json -Value "{}"
if((composer show $prefix$tool $tool_version -d $unix_scoped_dir -a 2>&1 | findstr '^type *: *composer-plugin') -and ($composer_args -ne '')) { if((composer show $prefix$tool $tool_version -d $unix_scoped_dir -a 2>&1 | findstr '^type *: *composer-plugin') -and ($composer_args -ne '')) {
composer config -d $unix_scoped_dir --no-plugins allow-plugins."$prefix$tool" true composer config -d $unix_scoped_dir --no-plugins allow-plugins."$prefix$tool" true >$null 2>&1
} }
composer require $prefix$release -d $unix_scoped_dir $composer_args composer require $prefix$release -d $unix_scoped_dir $composer_args >$null 2>&1
if($LASTEXITCODE -ne 0) {
return
}
}
$log = composer show $prefix$tool -d $unix_scoped_dir 2>&1 | findstr '^versions'
if(-not $log) {
return
} }
[System.Environment]::SetEnvironmentVariable(($tool.replace('-', '_') + '_bin'), "$scoped_dir\vendor\bin") [System.Environment]::SetEnvironmentVariable(($tool.replace('-', '_') + '_bin'), "$scoped_dir\vendor\bin")
Add-Path $scoped_dir\vendor\bin Add-Path $scoped_dir\vendor\bin
return composer show $prefix$tool -d $unix_scoped_dir 2>&1 | findstr '^versions' return $log
} }
} }
@@ -417,7 +449,13 @@ Function Add-ComposerTool() {
[ValidateNotNull()] [ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)] [ValidateLength(1, [int]::MaxValue)]
[string] [string]
$scope $scope,
[Parameter(Position = 4, Mandatory = $false)]
[string]
$fallback_url,
[Parameter(Position = 5, Mandatory = $false)]
[string]
$fallback_version_parameter
) )
$composer_args = "" $composer_args = ""
if($composer_version.split('.')[0] -ne "1") { if($composer_version.split('.')[0] -ne "1") {
@@ -433,10 +471,13 @@ Function Add-ComposerTool() {
if(Test-Path $composer_bin\composer) { if(Test-Path $composer_bin\composer) {
Copy-Item -Path "$bin_dir\composer" -Destination "$composer_bin\composer" -Force Copy-Item -Path "$bin_dir\composer" -Destination "$composer_bin\composer" -Force
} }
Add-ToolsHelper $tool
if($log) { if($log) {
$tool_version = Get-ToolVersion "Write-Output" "$log" $tool_version = Get-ToolVersion "Write-Output" "$log"
Add-ToolsHelper $tool
Add-Log $tick $tool "Added $tool $tool_version" Add-Log $tick $tool "Added $tool $tool_version"
} elseif($fallback_url) {
Add-Log "!" $tool "Could not setup $tool using Composer. Falling back to PHAR."
Add-Tool $fallback_url $tool $fallback_version_parameter
} else { } else {
Add-Log $cross $tool "Could not setup $tool" Add-Log $cross $tool "Could not setup $tool"
} }
+51 -19
View File
@@ -69,7 +69,7 @@ update_auth_json() {
# Function to check if public GitHub token authentication is possible. # Function to check if public GitHub token authentication is possible.
can_access_public_github() { can_access_public_github() {
curl --fail -s -H "Authorization: token $1" 'https://api.github.com/' curl --fail -s -H "Authorization: token $1" 'https://api.github.com/' >/dev/null 2>&1
} }
composer_gh_auth_no_op() { composer_gh_auth_no_op() {
@@ -131,7 +131,7 @@ set_composer_env() {
add_env_path "$composer_env" add_env_path "$composer_env"
if [ -n "$COMPOSER_ALLOW_PLUGINS" ]; then if [ -n "$COMPOSER_ALLOW_PLUGINS" ]; then
echo "$COMPOSER_ALLOW_PLUGINS" | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | grep -v '^$' | while IFS= read -r plugin; do echo "$COMPOSER_ALLOW_PLUGINS" | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | grep -v '^$' | while IFS= read -r plugin; do
composer global config --no-plugins "allow-plugins.$plugin" true composer global config --no-plugins "allow-plugins.$plugin" true >/dev/null 2>&1
done done
fi fi
} }
@@ -199,7 +199,28 @@ add_tools_helper() {
sudo ln -s "$tool_path" "$tool_path_dir"/"${tool%-*}" 2>/dev/null || true sudo ln -s "$tool_path" "$tool_path_dir"/"${tool%-*}" 2>/dev/null || true
fi fi
for extension in "${extensions[@]}"; do for extension in "${extensions[@]}"; do
add_extension "$extension" extension add_extension "$extension" extension >/dev/null 2>&1
done
}
# Function to find the newest stable release containing a tool asset.
get_last_release() {
local releases_url="${1%/latest/download/*}"
local asset="${1##*/}"
local page=1 releases assets_url tag download_path
while true; do
releases=$(get -s -n "" "$releases_url?page=$page&q=prerelease%3Afalse") || return 1
while IFS= read -r assets_url; do
[[ "$assets_url" = "$releases_url/expanded_assets/"* ]] || continue
tag="${assets_url#"$releases_url/expanded_assets/"}"
download_path="${releases_url#https://github.com}/download/$tag/$asset"
if get -s -n "" "$assets_url" | grep -Fq "href=\"$download_path\""; then
printf 'https://github.com%s\n' "$download_path"
return 0
fi
done <<< "$(printf '%s' "$releases" | grep -Eo 'src="[^"]+/releases/expanded_assets/[^"]+"' | cut -d '"' -f 2)"
[[ "$releases" = *'class="next_page"'* ]] || return 1
page=$((page + 1))
done done
} }
@@ -243,9 +264,12 @@ add_tool() {
else else
[ -f "$tool_path" ] && sudo cp -a "$tool_path" "$tool_path.bak" [ -f "$tool_path" ] && sudo cp -a "$tool_path" "$tool_path.bak"
status_code=$(get -v -e "$tool_path" "${url[@]}") status_code=$(get -v -e "$tool_path" "${url[@]}")
if [ "$status_code" != "200" ] && [[ "${url[0]}" =~ .*github.com.*releases.*latest.* ]]; then if [ "$status_code" != "200" ] && [[ "${url[0]}" =~ ^https://github\.com/[^/]+/[^/]+/releases/latest/download/[^/?#]+$ ]]; then
url[0]="${url[0]//releases\/latest\/download/releases/download/$(get -s -n "" "$(echo "${url[0]}" | cut -d '/' -f '1-5')/releases" | grep -Eo -m 1 "([0-9]+\.[0-9]+\.[0-9]+)/$(echo "${url[0]}" | sed -e "s/.*\///")" | cut -d '/' -f 1)}" local release_url
status_code=$(get -v -e "$tool_path" "${url[0]}") if release_url=$(get_last_release "${url[0]}"); then
url[0]="$release_url"
status_code=$(get -v -e "$tool_path" "${url[0]}")
fi
fi fi
if [ "$status_code" = "200" ]; then if [ "$status_code" = "200" ]; then
if [ -n "$checksum" ] && ! verify_checksum "$tool_path" "$checksum"; then if [ -n "$checksum" ] && ! verify_checksum "$tool_path" "$checksum"; then
@@ -289,23 +313,24 @@ add_composer_tool_helper() {
enable_extensions curl mbstring openssl enable_extensions curl mbstring openssl
tool_version=${release##*:}; [ "$tool_version" = "$tool" ] && tool_version="*" tool_version=${release##*:}; [ "$tool_version" = "$tool" ] && tool_version="*"
if [ "$scope" = "global" ]; then if [ "$scope" = "global" ]; then
sudo rm -f "$composer_lock" || true sudo rm -f "$composer_lock" >/dev/null 2>&1 || true
if composer global show "$prefix$tool" "$tool_version" -a 2>&1 | grep -qE '^type *: *composer-plugin' && [ -n "$composer_args" ]; then if composer global show "$prefix$tool" "$tool_version" -a 2>&1 | grep -qE '^type *: *composer-plugin' && [ -n "$composer_args" ]; then
composer global config --no-plugins allow-plugins."$prefix$tool" true composer global config --no-plugins allow-plugins."$prefix$tool" true >/dev/null 2>&1
fi fi
composer global require "$prefix$release" "$composer_args" composer global require "$prefix$release" "$composer_args" >/dev/null 2>&1 || return 1
composer global show "$prefix$tool" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log composer global show "$prefix$tool" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1
else else
scoped_dir="$composer_bin/_tools/$tool-$(echo -n "$release" | shasum -a 256 | cut -d ' ' -f 1)" scoped_dir="$composer_bin/_tools/$tool-$(echo -n "$release" | shasum -a 256 | cut -d ' ' -f 1)"
if ! [ -d "$scoped_dir" ]; then if ! [ -f "$scoped_dir/vendor/autoload.php" ]; then
mkdir -p "$scoped_dir" mkdir -p "$scoped_dir"
echo '{}' | tee "$scoped_dir/composer.json" >/dev/null echo '{}' | tee "$scoped_dir/composer.json" >/dev/null
if composer show "$prefix$tool" "$tool_version" -d "$scoped_dir" -a 2>&1 | grep -qE '^type *: *composer-plugin' && [ -n "$composer_args" ]; then if composer show "$prefix$tool" "$tool_version" -d "$scoped_dir" -a 2>&1 | grep -qE '^type *: *composer-plugin' && [ -n "$composer_args" ]; then
composer config -d "$scoped_dir" --no-plugins allow-plugins."$prefix$tool" true composer config -d "$scoped_dir" --no-plugins allow-plugins."$prefix$tool" true >/dev/null 2>&1
fi fi
composer require "$prefix$release" -d "$scoped_dir" "$composer_args" composer require "$prefix$release" -d "$scoped_dir" "$composer_args" >/dev/null 2>&1 || return 1
composer show "$prefix$tool" -d "$scoped_dir" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log
fi fi
composer show "$prefix$tool" -d "$scoped_dir" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1
[ -s /tmp/composer.log ] || return 1
add_path "$scoped_dir"/vendor/bin add_path "$scoped_dir"/vendor/bin
fi fi
} }
@@ -316,6 +341,7 @@ add_composer_tool() {
release=$2 release=$2
prefix=$3 prefix=$3
scope=$4 scope=$4
local fallback_url=${5:-} fallback_version_parameter=${6:-}
composer_args= composer_args=
composer_major_version=$(cut -d'.' -f 1 /tmp/composer_version) composer_major_version=$(cut -d'.' -f 1 /tmp/composer_version)
if [ "$composer_major_version" != "1" ]; then if [ "$composer_major_version" != "1" ]; then
@@ -326,11 +352,17 @@ add_composer_tool() {
return return
fi fi
fi fi
add_composer_tool_helper "$tool" "$release" "$prefix" "$scope" "$composer_args" sudo rm -f /tmp/composer.log
tool_version=$(get_tool_version cat /tmp/composer.log) if add_composer_tool_helper "$tool" "$release" "$prefix" "$scope" "$composer_args" && [ -s /tmp/composer.log ]; then
([ -s /tmp/composer.log ] && add_log "$tick" "$tool" "Added $tool $tool_version" tool_version=$(get_tool_version cat /tmp/composer.log)
) || add_log "$cross" "$tool" "Could not setup $tool" add_tools_helper "$tool"
add_tools_helper "$tool" add_log "$tick" "$tool" "Added $tool $tool_version"
elif [ -n "$fallback_url" ]; then
add_log "!" "$tool" "Could not setup $tool using Composer. Falling back to PHAR."
add_tool "$fallback_url" "$tool" "$fallback_version_parameter"
else
add_log "$cross" "$tool" "Could not setup $tool"
fi
if [ -e "$composer_bin/composer" ]; then if [ -e "$composer_bin/composer" ]; then
sudo cp -a "$tool_path_dir/composer" "$composer_bin" sudo cp -a "$tool_path_dir/composer" "$composer_bin"
fi fi
+4 -4
View File
@@ -6,15 +6,15 @@ Function Add-Blackfire() {
} }
$cli_version = (Invoke-RestMethod https://blackfire.io/api/v1/releases).cli $cli_version = (Invoke-RestMethod https://blackfire.io/api/v1/releases).cli
$url = "https://packages.blackfire.io/binaries/blackfire/${cli_version}/blackfire-windows_${arch_name}.zip" $url = "https://packages.blackfire.io/binaries/blackfire/${cli_version}/blackfire-windows_${arch_name}.zip"
Get-File -Url $url -OutFile $bin_dir\blackfire.zip Get-File -Url $url -OutFile $bin_dir\blackfire.zip >$null 2>&1
Expand-Archive -Path $bin_dir\blackfire.zip -DestinationPath $bin_dir -Force Expand-Archive -Path $bin_dir\blackfire.zip -DestinationPath $bin_dir -Force >$null 2>&1
Add-ToProfile $current_profile 'blackfire' "New-Alias blackfire $bin_dir\blackfire.exe" Add-ToProfile $current_profile 'blackfire' "New-Alias blackfire $bin_dir\blackfire.exe"
Invoke-WithoutTrace { Invoke-WithoutTrace {
if ((Test-Path env:BLACKFIRE_SERVER_ID) -and (Test-Path env:BLACKFIRE_SERVER_TOKEN)) { if ((Test-Path env:BLACKFIRE_SERVER_ID) -and (Test-Path env:BLACKFIRE_SERVER_TOKEN)) {
blackfire agent:config --server-id=$env:BLACKFIRE_SERVER_ID --server-token=$env:BLACKFIRE_SERVER_TOKEN blackfire agent:config --server-id=$env:BLACKFIRE_SERVER_ID --server-token=$env:BLACKFIRE_SERVER_TOKEN >$null 2>&1
} }
if ((Test-Path env:BLACKFIRE_CLIENT_ID) -and (Test-Path env:BLACKFIRE_CLIENT_TOKEN)) { if ((Test-Path env:BLACKFIRE_CLIENT_ID) -and (Test-Path env:BLACKFIRE_CLIENT_TOKEN)) {
blackfire client:config --client-id=$env:BLACKFIRE_CLIENT_ID --client-token=$env:BLACKFIRE_CLIENT_TOKEN --ca-cert=$php_dir\ssl\cacert.pem blackfire client:config --client-id=$env:BLACKFIRE_CLIENT_ID --client-token=$env:BLACKFIRE_CLIENT_TOKEN --ca-cert=$php_dir\ssl\cacert.pem >$null 2>&1
} }
} }
Add-Log $tick "blackfire" "Added blackfire $cli_version" Add-Log $tick "blackfire" "Added blackfire $cli_version"
+3 -3
View File
@@ -36,9 +36,9 @@ blackfire_config_helper() {
# Function to add blackfire cli. # Function to add blackfire cli.
add_blackfire() { add_blackfire() {
os="$(uname -s)" os="$(uname -s)"
[ "$os" = "Linux" ] && add_blackfire_linux [ "$os" = "Linux" ] && add_blackfire_linux >/dev/null 2>&1
[ "$os" = "Darwin" ] && add_blackfire_darwin [ "$os" = "Darwin" ] && add_blackfire_darwin >/dev/null 2>&1
blackfire_config blackfire_config >/dev/null 2>&1
tool_version=$(get_tool_version "blackfire" "version") tool_version=$(get_tool_version "blackfire" "version")
add_log "${tick:?}" "blackfire" "Added blackfire $tool_version" add_log "${tick:?}" "blackfire" "Added blackfire $tool_version"
} }
+15 -10
View File
@@ -14,15 +14,15 @@ add_brew_tap() {
tap=$1 tap=$1
if ! [ -d "$tap_dir/$tap" ]; then if ! [ -d "$tap_dir/$tap" ]; then
if [ "${runner:?}" = "self-hosted" ]; then if [ "${runner:?}" = "self-hosted" ]; then
brew tap "$tap" brew tap "$tap" >/dev/null 2>&1
else else
fetch_brew_tap "$tap" fetch_brew_tap "$tap" >/dev/null 2>&1
if ! [ -d "$tap_dir/$tap" ]; then if ! [ -d "$tap_dir/$tap" ]; then
brew tap "$tap" brew tap "$tap" >/dev/null 2>&1
fi fi
fi fi
fi fi
brew trust "$tap" brew trust "$tap" >/dev/null 2>&1
} }
# Function to get brew prefix. # Function to get brew prefix.
@@ -82,11 +82,11 @@ terminate_process_tree() {
local pids pid local pids pid
pids=$(get_process_tree "$1") pids=$(get_process_tree "$1")
for pid in $pids; do for pid in $pids; do
kill -TERM "$pid" || true kill -TERM "$pid" >/dev/null 2>&1 || true
done done
sleep 2 sleep 2
for pid in $pids; do for pid in $pids; do
kill -KILL "$pid" || true kill -KILL "$pid" >/dev/null 2>&1 || true
done done
} }
@@ -125,9 +125,9 @@ run_with_inactivity_watchdog() {
last_activity=$(get_file_mtime "$stdout_log") last_activity=$(get_file_mtime "$stdout_log")
current_err_activity=$(get_file_mtime "$stderr_log") current_err_activity=$(get_file_mtime "$stderr_log")
[ "$current_err_activity" -gt "$last_activity" ] && last_activity="$current_err_activity" [ "$current_err_activity" -gt "$last_activity" ] && last_activity="$current_err_activity"
while kill -0 "$command_pid" ; do while kill -0 "$command_pid" >/dev/null 2>&1; do
sleep "$poll_secs" sleep "$poll_secs"
kill -0 "$command_pid" || break kill -0 "$command_pid" >/dev/null 2>&1 || break
now=$(date +%s) now=$(date +%s)
active_timeout_secs="$timeout_secs" active_timeout_secs="$timeout_secs"
building_from_source=false building_from_source=false
@@ -158,7 +158,7 @@ run_with_inactivity_watchdog() {
wait "$command_pid" || exit_code=$? wait "$command_pid" || exit_code=$?
# Let timeout cleanup finish killing source-build descendants before retrying. # Let timeout cleanup finish killing source-build descendants before retrying.
if [ ! -e "$timeout_file" ]; then if [ ! -e "$timeout_file" ]; then
kill "$monitor_pid" || true kill "$monitor_pid" >/dev/null 2>&1 || true
fi fi
wait "$monitor_pid" 2>/dev/null || true wait "$monitor_pid" 2>/dev/null || true
wait "$stdout_reader_pid" 2>/dev/null || true wait "$stdout_reader_pid" 2>/dev/null || true
@@ -205,7 +205,7 @@ add_brew() {
brew_prefix="$(get_brew_prefix)" brew_prefix="$(get_brew_prefix)"
if ! [ -d "$brew_prefix"/bin ]; then if ! [ -d "$brew_prefix"/bin ]; then
step_log "Setup Brew" step_log "Setup Brew"
get -s "" "/tmp/install.sh" "https://raw.githubusercontent.com/Homebrew/install/main/install.sh" | bash -s get -s "" "/tmp/install.sh" "https://raw.githubusercontent.com/Homebrew/install/main/install.sh" | bash -s >/dev/null 2>&1
add_log "${tick:?}" "Brew" "Installed Homebrew" add_log "${tick:?}" "Brew" "Installed Homebrew"
fi fi
add_brew_bins_to_path "$brew_prefix" add_brew_bins_to_path "$brew_prefix"
@@ -225,6 +225,11 @@ configure_brew() {
tap_dir="$brew_repo"/Library/Taps tap_dir="$brew_repo"/Library/Taps
core_repo="$tap_dir"/homebrew/homebrew-core core_repo="$tap_dir"/homebrew/homebrew-core
if [ -d "$core_repo" ]; then
export HOMEBREW_NO_INSTALL_FROM_API=1
else
unset HOMEBREW_NO_INSTALL_FROM_API
fi
export HOMEBREW_CHANGE_ARCH_TO_ARM=1 export HOMEBREW_CHANGE_ARCH_TO_ARM=1
export HOMEBREW_NO_AUTO_UPDATE=1 export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_ENV_HINTS=1 export HOMEBREW_NO_ENV_HINTS=1
+2 -2
View File
@@ -1,7 +1,7 @@
Function Add-Msys2() { Function Add-Msys2() {
$msys_location = 'C:\msys64' $msys_location = 'C:\msys64'
if (-not(Test-Path $msys_location)) { if (-not(Test-Path $msys_location)) {
choco install msys2 -y choco install msys2 -y >$null 2>&1
$msys_location = 'C:\tools\msys64' $msys_location = 'C:\tools\msys64'
} }
return $msys_location return $msys_location
@@ -15,7 +15,7 @@ Function Add-GrpcPhpPlugin() {
} else { } else {
$grpc_package = 'mingw-w64-x86_64-grpc' $grpc_package = 'mingw-w64-x86_64-grpc'
} }
$logs = . $msys_location\usr\bin\bash -l -c "pacman -S --noconfirm $grpc_package" $logs = . $msys_location\usr\bin\bash -l -c "pacman -S --noconfirm $grpc_package" >$null 2>&1
$grpc_version = Get-ToolVersion 'Write-Output' "$logs" $grpc_version = Get-ToolVersion 'Write-Output' "$logs"
Add-Path $msys_location\mingw64\bin Add-Path $msys_location\mingw64\bin
Set-Output grpc_php_plugin_path "$msys_location\mingw64\bin\grpc_php_plugin.exe" Set-Output grpc_php_plugin_path "$msys_location\mingw64\bin\grpc_php_plugin.exe"
+3 -3
View File
@@ -26,7 +26,7 @@ add_grpc_php_plugin_brew() {
configure_brew configure_brew
[ -e /usr/local/bin/protoc ] && sudo mv /usr/local/bin/protoc /tmp/protoc && sudo mv /usr/local/include/google /tmp [ -e /usr/local/bin/protoc ] && sudo mv /usr/local/bin/protoc /tmp/protoc && sudo mv /usr/local/include/google /tmp
safe_brew install grpc safe_brew install grpc
brew link --force --overwrite grpc brew link --force --overwrite grpc >/dev/null 2>&1
[ -e /tmp/protoc ] && sudo mv /tmp/protoc /usr/local/bin/protoc && sudo mv /tmp/google /usr/local/include/ [ -e /tmp/protoc ] && sudo mv /tmp/protoc /usr/local/bin/protoc && sudo mv /tmp/google /usr/local/include/
grpc_tag="v$(brew info grpc | grep "grpc:" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")" grpc_tag="v$(brew info grpc | grep "grpc:" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")"
license_path="$(brew --prefix grpc)/LICENSE" license_path="$(brew --prefix grpc)/LICENSE"
@@ -50,9 +50,9 @@ add_grpc_php_plugin() {
grpc_tag=$1 grpc_tag=$1
license_path="" license_path=""
if [ "$grpc_tag" = "latest" ]; then if [ "$grpc_tag" = "latest" ]; then
add_grpc_php_plugin_brew add_grpc_php_plugin_brew >/dev/null 2>&1
else else
add_grpc_php_plugin_compile add_grpc_php_plugin_compile >/dev/null 2>&1
fi fi
set_output grpc_php_plugin_path "$(command -v grpc_php_plugin)" set_output grpc_php_plugin_path "$(command -v grpc_php_plugin)"
add_log "${tick:?}" "grpc_php_plugin" "Added grpc_php_plugin ${grpc_tag:1}" add_log "${tick:?}" "grpc_php_plugin" "Added grpc_php_plugin ${grpc_tag:1}"
+2 -2
View File
@@ -28,8 +28,8 @@ Function Add-Mago() {
$arch_name = 'i686' $arch_name = 'i686'
} }
$url = "https://github.com/carthage-software/mago/releases/download/$mago_tag/mago-$mago_tag-$arch_name-pc-windows-msvc.zip" $url = "https://github.com/carthage-software/mago/releases/download/$mago_tag/mago-$mago_tag-$arch_name-pc-windows-msvc.zip"
Get-File -Url $url -OutFile $bin_dir\mago.zip Get-File -Url $url -OutFile $bin_dir\mago.zip >$null 2>&1
Expand-Archive -Path $bin_dir\mago.zip -DestinationPath $bin_dir\mago -Force Expand-Archive -Path $bin_dir\mago.zip -DestinationPath $bin_dir\mago -Force >$null 2>&1
Move-Item -Path $bin_dir\mago\mago-$mago_tag-$arch_name-pc-windows-msvc\mago.exe -Destination $bin_dir\mago.exe -Force Move-Item -Path $bin_dir\mago\mago-$mago_tag-$arch_name-pc-windows-msvc\mago.exe -Destination $bin_dir\mago.exe -Force
Add-ToProfile $current_profile 'mago' "New-Alias mago $bin_dir\mago.exe" Add-ToProfile $current_profile 'mago' "New-Alias mago $bin_dir\mago.exe"
Add-Log $tick "mago" "Added mago $mago_tag" Add-Log $tick "mago" "Added mago $mago_tag"
+1 -1
View File
@@ -24,6 +24,6 @@ add_mago() {
sudo tar -xzf /tmp/mago.tar.gz -C /tmp/ sudo tar -xzf /tmp/mago.tar.gz -C /tmp/
sudo mv /tmp/mago-$mago_tag-$arch-$platform/mago /usr/local/bin/mago sudo mv /tmp/mago-$mago_tag-$arch-$platform/mago /usr/local/bin/mago
sudo chmod +x /usr/local/bin/mago sudo chmod +x /usr/local/bin/mago
) ) >/dev/null 2>&1
add_log "${tick:?}" "mago" "Added mago $mago_tag" add_log "${tick:?}" "mago" "Added mago $mago_tag"
} }
+5 -5
View File
@@ -31,7 +31,7 @@ set_base_version() {
else else
set_base_version_codename set_base_version_codename
set_base_version_id set_base_version_id
printf "ID=%s\nVERSION_ID=%s\nVERSION_CODENAME=%s\n" "$ID" "$VERSION_ID" "$VERSION_CODENAME" | tee /tmp/os-release printf "ID=%s\nVERSION_ID=%s\nVERSION_CODENAME=%s\n" "$ID" "$VERSION_ID" "$VERSION_CODENAME" | tee /tmp/os-release >/dev/null 2>&1
fi fi
} }
@@ -70,8 +70,8 @@ update_lists() {
list="$list_file" list="$list_file"
fi fi
if [ ! -e "$status_file" ]; then if [ ! -e "$status_file" ]; then
update_lists_helper "$list" update_lists_helper "$list" >/dev/null 2>&1
echo '' | tee "$status_file" echo '' | tee "$status_file" >/dev/null 2>&1
fi fi
} }
@@ -186,7 +186,7 @@ add_key() {
key_urls+=("$ppa_sp/keys/$ppa.gpg") key_urls+=("$ppa_sp/keys/$ppa.gpg")
[ ! -e "$key_source" ] && get -q -n "$key_file" "${key_urls[@]}" [ ! -e "$key_source" ] && get -q -n "$key_file" "${key_urls[@]}"
if [[ "$(file "$key_file")" =~ .*('Public-Key (old)'|'Secret-Key') ]]; then if [[ "$(file "$key_file")" =~ .*('Public-Key (old)'|'Secret-Key') ]]; then
sudo gpg --batch --yes --dearmor "$key_file" && sudo mv "$key_file".gpg "$key_file" sudo gpg --batch --yes --dearmor "$key_file" >/dev/null 2>&1 && sudo mv "$key_file".gpg "$key_file"
fi fi
} }
@@ -230,7 +230,7 @@ Architectures: $arch
Signed-By: $key_file Signed-By: $key_file
EOF EOF
else else
echo "deb [arch=$arch signed-by=$key_file] $url $suite $components" | sudo tee "$list_dir"/"$list_basename".list echo "deb [arch=$arch signed-by=$key_file] $url $suite $components" | sudo tee "$list_dir"/"$list_basename".list >/dev/null 2>&1
fi fi
} }
+2 -2
View File
@@ -29,8 +29,8 @@ Function Add-Protoc() {
$arch_num = '32' $arch_num = '32'
} }
$url = "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-$($protobuf_tag -replace 'v', '')-win$arch_num.zip" $url = "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-$($protobuf_tag -replace 'v', '')-win$arch_num.zip"
Get-File -Url $url -OutFile $bin_dir\protoc.zip Get-File -Url $url -OutFile $bin_dir\protoc.zip >$null 2>&1
Expand-Archive -Path $bin_dir\protoc.zip -DestinationPath $bin_dir\protoc -Force Expand-Archive -Path $bin_dir\protoc.zip -DestinationPath $bin_dir\protoc -Force >$null 2>&1
Move-Item -Path $bin_dir\protoc\bin\protoc.exe -Destination $bin_dir\protoc.exe Move-Item -Path $bin_dir\protoc\bin\protoc.exe -Destination $bin_dir\protoc.exe
Add-ToProfile $current_profile 'protoc' "New-Alias protoc $bin_dir\protoc.exe" Add-ToProfile $current_profile 'protoc' "New-Alias protoc $bin_dir\protoc.exe"
Add-Log $tick "protoc" "Added protoc $($protobuf_tag -replace 'v', '')" Add-Log $tick "protoc" "Added protoc $($protobuf_tag -replace 'v', '')"
+1 -1
View File
@@ -22,7 +22,7 @@ add_protoc() {
get -q -n /tmp/protobuf.zip "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-${protobuf_tag:1}-$platform-$arch.zip" get -q -n /tmp/protobuf.zip "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-${protobuf_tag:1}-$platform-$arch.zip"
sudo unzip /tmp/protobuf.zip -d /usr/local/ sudo unzip /tmp/protobuf.zip -d /usr/local/
sudo chmod -R 777 /usr/local/bin/protoc /usr/local/include/google sudo chmod -R 777 /usr/local/bin/protoc /usr/local/include/google
) ) >/dev/null 2>&1
add_log "${tick:?}" "protoc" "Added protoc ${protobuf_tag:1}" add_log "${tick:?}" "protoc" "Added protoc ${protobuf_tag:1}"
printf "$GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information" printf "$GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
curl "${curl_opts[@]:?}" https://raw.githubusercontent.com/protocolbuffers/protobuf/main/LICENSE curl "${curl_opts[@]:?}" https://raw.githubusercontent.com/protocolbuffers/protobuf/main/LICENSE
+1 -1
View File
@@ -31,7 +31,7 @@ add_symfony() {
if ! [[ "$symfony_tag" =~ ^[0-9]+(\.[0-9]+)*$ || "$symfony_tag" == 'latest' ]]; then if ! [[ "$symfony_tag" =~ ^[0-9]+(\.[0-9]+)*$ || "$symfony_tag" == 'latest' ]]; then
add_log "${cross:?}" "symfony-cli" "Version '$symfony_tag' is not valid for symfony-cli" add_log "${cross:?}" "symfony-cli" "Version '$symfony_tag' is not valid for symfony-cli"
else else
add_symfony_helper "$symfony_tag" add_symfony_helper "$symfony_tag" >/dev/null 2>&1
symfony_path="$(command -v symfony)" symfony_path="$(command -v symfony)"
if [[ -n "$symfony_path" ]]; then if [[ -n "$symfony_path" ]]; then
sudo ln -s "$symfony_path" "${tool_path_dir:?}"/symfony-cli sudo ln -s "$symfony_path" "${tool_path_dir:?}"/symfony-cli
+10 -10
View File
@@ -46,7 +46,7 @@ set_output() {
name=$1 name=$1
value=$2 value=$2
if [ "${GITHUB_ACTIONS}" = "true" ]; then if [ "${GITHUB_ACTIONS}" = "true" ]; then
echo "${name}=${value}" | tee -a "$GITHUB_OUTPUT" echo "${name}=${value}" | tee -a "$GITHUB_OUTPUT" >/dev/null 2>&1
fi fi
} }
@@ -68,7 +68,7 @@ check_builds_cache_runner() {
if [[ "$executable" = */bin/Runner.Worker ]]; then if [[ "$executable" = */bin/Runner.Worker ]]; then
jq -e --arg name "${RUNNER_NAME:-}" \ jq -e --arg name "${RUNNER_NAME:-}" \
'.AgentName == $name and (.AgentName | test("^(blacksmith|depot)-"))' \ '.AgentName == $name and (.AgentName | test("^(blacksmith|depot)-"))' \
"${executable%/bin/Runner.Worker}/.runner" "${executable%/bin/Runner.Worker}/.runner" >/dev/null 2>&1
return $? return $?
fi fi
pid="$(awk '$1 == "PPid:" {print $2}' "/proc/$pid/status")" || return 1 pid="$(awk '$1 == "PPid:" {print $2}' "/proc/$pid/status")" || return 1
@@ -110,7 +110,7 @@ read_env() {
if [[ "$runner" = "github" && "${ImageOS}" =~ ubuntu.* ]]; then if [[ "$runner" = "github" && "${ImageOS}" =~ ubuntu.* ]]; then
if ! check_ppa ondrej/php; then if ! check_ppa ondrej/php; then
update=true update=true
echo '' | sudo tee /tmp/sp_update echo '' | sudo tee /tmp/sp_update >/dev/null 2>&1
elif [ -e /tmp/sp_update ]; then elif [ -e /tmp/sp_update ]; then
update=true update=true
fi fi
@@ -134,7 +134,7 @@ acquire_lock() {
else else
if sudo test -f "$lock_path/pid"; then if sudo test -f "$lock_path/pid"; then
lock_pid=$(sudo cat "$lock_path/pid") lock_pid=$(sudo cat "$lock_path/pid")
if ! ps -p "$lock_pid" ; then if ! ps -p "$lock_pid" >/dev/null 2>&1; then
sudo rm -rf "$lock_path" sudo rm -rf "$lock_path"
continue continue
fi fi
@@ -237,7 +237,7 @@ add_path() {
printf '%s\n%s' "$path_to_add" "$(grep -v "^${path_to_add}$" "$GITHUB_PATH" 2>/dev/null)" > "$GITHUB_PATH" printf '%s\n%s' "$path_to_add" "$(grep -v "^${path_to_add}$" "$GITHUB_PATH" 2>/dev/null)" > "$GITHUB_PATH"
else else
profile=$(get_shell_profile) profile=$(get_shell_profile)
([ -e "$profile" ] && grep -q ":$path_to_add\"" "$profile" 2>/dev/null) || echo "export PATH=\"\${PATH:+\${PATH}:}\"$path_to_add" | sudo tee -a "$profile" ([ -e "$profile" ] && grep -q ":$path_to_add\"" "$profile" 2>/dev/null) || echo "export PATH=\"\${PATH:+\${PATH}:}\"$path_to_add" | sudo tee -a "$profile" >/dev/null 2>&1
fi fi
[[ ":$PATH:" == *":$path_to_add:"* ]] || export PATH="${PATH:+${PATH}:}$path_to_add" [[ ":$PATH:" == *":$path_to_add:"* ]] || export PATH="${PATH:+${PATH}:}$path_to_add"
} }
@@ -259,10 +259,10 @@ add_env() {
env_name=$1 env_name=$1
env_value=$2 env_value=$2
if [[ -n "$GITHUB_ENV" ]]; then if [[ -n "$GITHUB_ENV" ]]; then
echo "$env_name=$env_value" | tee -a "$GITHUB_ENV" echo "$env_name=$env_value" | tee -a "$GITHUB_ENV" >/dev/null 2>&1
else else
profile=$(get_shell_profile) profile=$(get_shell_profile)
echo "export $env_name=\"$env_value\"" | sudo tee -a "$profile" echo "export $env_name=\"$env_value\"" | sudo tee -a "$profile" >/dev/null 2>&1
fi fi
export "$env_name"="$env_value" export "$env_name"="$env_value"
} }
@@ -283,7 +283,7 @@ self_hosted_setup() {
add_log "$cross" "PHP" "PHP $version is not supported on self-hosted runner" add_log "$cross" "PHP" "PHP $version is not supported on self-hosted runner"
exit 1 exit 1
else else
self_hosted_helper self_hosted_helper >/dev/null 2>&1
add_env RUNNER_TOOL_CACHE /opt/hostedtoolcache add_env RUNNER_TOOL_CACHE /opt/hostedtoolcache
fi fi
fi fi
@@ -311,8 +311,8 @@ configure_php() {
[[ "$arch" = "arm64" || "$arch" = "aarch64" ]] && jit_ini="$ini_config_dir"/jit_aarch64.ini || jit_ini="$ini_config_dir"/jit.ini [[ "$arch" = "arm64" || "$arch" = "aarch64" ]] && jit_ini="$ini_config_dir"/jit_aarch64.ini || jit_ini="$ini_config_dir"/jit.ini
jit_config_files=("$jit_ini") jit_config_files=("$jit_ini")
[[ "$version" =~ $xdebug3_versions ]] && ini_config_files+=("$ini_config_dir"/xdebug.ini) [[ "$version" =~ $xdebug3_versions ]] && ini_config_files+=("$ini_config_dir"/xdebug.ini)
cat "${ini_config_files[@]}" | sudo tee -a "${ini_file[@]:?}" cat "${ini_config_files[@]}" | sudo tee -a "${ini_file[@]:?}" >/dev/null 2>&1
[[ "$version" =~ $jit_versions ]] && cat "${jit_config_files[@]}" | sudo tee -a "${pecl_file:-${ini_file[@]}}" [[ "$version" =~ $jit_versions ]] && cat "${jit_config_files[@]}" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1
} }
# Function to get PHP version in semver format. # Function to get PHP version in semver format.
+10 -8
View File
@@ -20,6 +20,8 @@ Function Step-Log($message) {
Function Add-Log($mark, $subject, $message) { Function Add-Log($mark, $subject, $message) {
if ($mark -eq $tick) { if ($mark -eq $tick) {
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $mark $subject $message printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $mark $subject $message
} elseif ($mark -eq "!") {
printf "\033[33;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $mark $subject $message
} else { } else {
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $mark $subject $message printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $mark $subject $message
if($env:fail_fast -eq 'true') { if($env:fail_fast -eq 'true') {
@@ -379,7 +381,7 @@ if(-not($env:ImageOS) -and -not($env:ImageVersion)) {
$bin_dir = 'C:\tools\bin' $bin_dir = 'C:\tools\bin'
$php_dir = "$php_dir$version" $php_dir = "$php_dir$version"
$ext_dir = "$php_dir\ext" $ext_dir = "$php_dir\ext"
Get-CleanPSProfile Get-CleanPSProfile >$null 2>&1
New-Item $bin_dir -Type Directory -Force > $null 2>&1 New-Item $bin_dir -Type Directory -Force > $null 2>&1
Add-Path -PathItem $bin_dir Add-Path -PathItem $bin_dir
if($version -lt 5.6) { if($version -lt 5.6) {
@@ -392,12 +394,12 @@ if(-not($env:ImageOS) -and -not($env:ImageVersion)) {
} }
New-Item $php_dir -Type Directory -Force > $null 2>&1 New-Item $php_dir -Type Directory -Force > $null 2>&1
Add-Path -PathItem $php_dir Add-Path -PathItem $php_dir
setx PHPROOT $php_dir setx PHPROOT $php_dir >$null 2>&1
Add-Env -EnvName RUNNER_TOOL_CACHE -EnvValue $env:TEMP Add-Env -EnvName RUNNER_TOOL_CACHE -EnvValue $env:TEMP
} else { } else {
$current_profile = "$PSHOME\Profile.ps1" $current_profile = "$PSHOME\Profile.ps1"
if(-not(Test-Path -LiteralPath $current_profile)) { if(-not(Test-Path -LiteralPath $current_profile)) {
New-Item -Path $current_profile -ItemType "file" -Force New-Item -Path $current_profile -ItemType "file" -Force >$null 2>&1
} }
Add-Path -PathItem $bin_dir -Force Add-Path -PathItem $bin_dir -Force
} }
@@ -406,9 +408,9 @@ $src = Join-Path -Path $PSScriptRoot -ChildPath \..
. $src\scripts\tools\add_tools.ps1 . $src\scripts\tools\add_tools.ps1
. $src\scripts\extensions\add_extensions.ps1 . $src\scripts\extensions\add_extensions.ps1
Add-Printf Add-Printf >$null 2>&1
Step-Log "Setup PhpManager" Step-Log "Setup PhpManager"
Install-PSPackage PhpManager PhpManager\PhpManager "$github/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip" Get-Php Install-PSPackage PhpManager PhpManager\PhpManager "$github/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip" Get-Php >$null 2>&1
Add-Log $tick "PhpManager" "Installed" Add-Log $tick "PhpManager" "Installed"
Step-Log "Setup PHP" Step-Log "Setup PHP"
@@ -437,7 +439,7 @@ if($version -eq 'pre') {
} }
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) { if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
if ($version -lt '7.0' -and ($null -eq (Get-Module -ListAvailable -Name VcRedist))) { if ($version -lt '7.0' -and ($null -eq (Get-Module -ListAvailable -Name VcRedist))) {
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList >$null 2>&1
} }
try { try {
if ($version -match $nightly_versions) { if ($version -match $nightly_versions) {
@@ -453,7 +455,7 @@ if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version
} catch { } } catch { }
} else { } else {
if($env:update -eq 'true') { if($env:update -eq 'true') {
Update-Php $php_dir Update-Php $php_dir >$null 2>&1
$status = "Updated to" $status = "Updated to"
} else { } else {
$status = "Found" $status = "Found"
@@ -471,7 +473,7 @@ if($installed.MajorMinorVersion -ne $version) {
Write-Error "Could not setup PHP $version" -ErrorAction Stop Write-Error "Could not setup PHP $version" -ErrorAction Stop
} }
if($version -lt "5.5") { if($version -lt "5.5") {
('libeay32.dll', 'ssleay32.dll') | ForEach-Object -Parallel { Invoke-WebRequest -Uri "$using:php_builder/releases/download/openssl-1.0.2u/$_" -OutFile $using:php_dir\$_ } ('libeay32.dll', 'ssleay32.dll') | ForEach-Object -Parallel { Invoke-WebRequest -Uri "$using:php_builder/releases/download/openssl-1.0.2u/$_" -OutFile $using:php_dir\$_ >$null 2>&1 }
} elseif($version -lt "8.5") { } elseif($version -lt "8.5") {
$enable_extensions += ('opcache') $enable_extensions += ('opcache')
} }
+42 -8
View File
@@ -1,9 +1,12 @@
import {fileURLToPath} from 'url';
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
import * as cv from 'compare-versions'; import * as cv from 'compare-versions';
import * as fetch from './fetch'; import * as fetch from './fetch.js';
import * as packagist from './packagist'; import * as packagist from './packagist.js';
import * as utils from './utils'; import * as utils from './utils.js';
const dirname = path.dirname(fileURLToPath(import.meta.url));
/** /**
* Valid function names for custom tool handlers * Valid function names for custom tool handlers
@@ -48,6 +51,7 @@ export interface ToolData {
url: string; url: string;
uri?: string; uri?: string;
error?: string; error?: string;
fallback?: ToolFallback;
} }
/** /**
@@ -72,8 +76,19 @@ interface ToolConfig {
version_parameter?: string; version_parameter?: string;
version_prefix?: string; version_prefix?: string;
packagist?: string; packagist?: string;
fallback?: ToolFallback;
} }
type ToolFallback = Pick<
ToolConfig,
| 'repository'
| 'domain'
| 'extension'
| 'fetch_latest'
| 'version_parameter'
| 'version_prefix'
> & {type: 'phar'};
/** /**
* Regex to match a checksum suffix in a tool release - tool:version@sha256:<hash> * Regex to match a checksum suffix in a tool release - tool:version@sha256:<hash>
*/ */
@@ -155,7 +170,7 @@ export function skipGitHubAuthForComposerVersion(version: string): boolean {
} }
return fs return fs
.readFileSync( .readFileSync(
path.join(__dirname, '../src/configs/composer-gh-auth-no-op'), path.join(dirname, '../src/configs/composer-gh-auth-no-op'),
'utf8' 'utf8'
) )
.trim() .trim()
@@ -414,7 +429,23 @@ export async function addPackage(data: ToolData): Promise<string> {
const args = [parts[1], data.release, parts[0] + '/', data.scope] const args = [parts[1], data.release, parts[0] + '/', data.scope]
.map(a => utils.safeArg(a, data.os)) .map(a => utils.safeArg(a, data.os))
.join(' '); .join(' ');
return command + args; if (!data.fallback) return command + args;
const fallback = await getData(
data.release.replace(/\.\*$/, ''),
data.php_version,
data.os,
data.fallback
);
// A failed version lookup must not prevent a successful Composer install.
if (fallback.error) return command + args;
return (
command +
args +
' ' +
utils.safeArg(fallback.url, data.os) +
' ' +
(fallback.version_parameter || '""')
);
} }
/** /**
@@ -670,9 +701,10 @@ export async function addWPCLI(data: ToolData): Promise<string> {
export async function getData( export async function getData(
release: string, release: string,
php_version: string, php_version: string,
os: string os: string,
overrides: ToolConfig = {}
): Promise<ToolData> { ): Promise<ToolData> {
const json_file_path = path.join(__dirname, '../src/configs/tools.json'); const json_file_path = path.join(dirname, '../src/configs/tools.json');
const json_file: string = fs.readFileSync(json_file_path, 'utf8'); const json_file: string = fs.readFileSync(json_file_path, 'utf8');
const json_objects: Record<string, ToolConfig> = JSON.parse(json_file); const json_objects: Record<string, ToolConfig> = JSON.parse(json_file);
release = release.replace(/\s+/g, ''); release = release.replace(/\s+/g, '');
@@ -702,6 +734,7 @@ export async function getData(
config = {tool}; config = {tool};
} }
} }
config = {...config, ...overrides};
const github = 'https://github.com'; const github = 'https://github.com';
const domain = config.domain ?? github; const domain = config.domain ?? github;
const data: ToolData = { const data: ToolData = {
@@ -727,7 +760,8 @@ export async function getData(
packagist: config.packagist ?? config.repository ?? '', packagist: config.packagist ?? config.repository ?? '',
type: config.type, type: config.type,
function: config.function, function: config.function,
alias: config.alias alias: config.alias,
fallback: config.fallback
}; };
data.checksum = checksum_data.checksum; data.checksum = checksum_data.checksum;
data.error = checksum_data.error; data.error = checksum_data.error;
+11 -11
View File
@@ -1,7 +1,10 @@
import {fileURLToPath} from 'url';
import fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as core from './core'; import * as core from './core.js';
import * as fetch from './fetch'; import * as fetch from './fetch.js';
const dirname = path.dirname(fileURLToPath(import.meta.url));
/** /**
* Function to read environment variable and return a string value. * Function to read environment variable and return a string value.
@@ -88,12 +91,9 @@ export async function parseVersion(version: string): Promise<string> {
if (!/^\d+(\.\d+){0,2}$/.test(version)) { if (!/^\d+(\.\d+){0,2}$/.test(version)) {
throw new Error(`Invalid PHP version: ${version.slice(0, 20)}`); throw new Error(`Invalid PHP version: ${version.slice(0, 20)}`);
} }
switch (true) { return version.includes('.')
case version.length > 1: ? version.split('.').slice(0, 2).join('.')
return version.slice(0, 3); : version + '.0';
default:
return version + '.0';
}
} }
} }
@@ -321,10 +321,10 @@ export async function getExtensionPrefix(extension: string): Promise<string> {
export async function suppressOutput(os: string): Promise<string> { export async function suppressOutput(os: string): Promise<string> {
switch (os) { switch (os) {
case 'win32': case 'win32':
return ' '; return ' >$null 2>&1';
case 'linux': case 'linux':
case 'darwin': case 'darwin':
return ' '; return ' >/dev/null 2>&1';
default: default:
return await log('Platform ' + os + ' is not supported', os, 'error'); return await log('Platform ' + os + ' is not supported', os, 'error');
} }
@@ -480,7 +480,7 @@ export async function customPackage(
const pkg_name: string = pkg.replace(/\d+|(pdo|pecl)[_-]|[_-]db2/, ''); const pkg_name: string = pkg.replace(/\d+|(pdo|pecl)[_-]|[_-]db2/, '');
const script_extension: string = await scriptExtension(os); const script_extension: string = await scriptExtension(os);
const script: string = path.join( const script: string = path.join(
__dirname, dirname,
'../src/scripts/' + type + '/' + pkg_name + script_extension '../src/scripts/' + type + '/' + pkg_name + script_extension
); );
const command: string = await getCommand(os, pkg_name); const command: string = await getCommand(os, pkg_name);
+2 -2
View File
@@ -5,8 +5,8 @@
"lib": [ "lib": [
"ES2025" "ES2025"
], ],
"module": "Node20", "module": "NodeNext",
"moduleResolution": "Node16", "moduleResolution": "NodeNext",
"noImplicitAny": true, "noImplicitAny": true,
"outDir": "./lib", "outDir": "./lib",
"removeComments": true, "removeComments": true,