diff --git a/README.md b/README.md index fae504fad..a8f1ef21c 100644 --- a/README.md +++ b/README.md @@ -224,7 +224,7 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string` These tools can be set up globally using the `tools` input. It accepts a string in csv-format. -[`behat`], [`blackfire`], [`blackfire-player`], [`churn`], [`codeception`], [`composer`], [`composer-normalize`], [`composer-prefetcher`], [`composer-require-checker`], [`composer-unused`], [`cs2pr`], [`deployer`], [`flex`], [`grpc_php_plugin`], [`infection`], [`parallel-lint`], [`pecl`], [`phan`], [`phing`], [`phinx`], [`phive`], [`php-config`], [`php-cs-fixer`], [`phpcbf`], [`phpcpd`], [`phpcs`], [`phpdoc`] or [`phpDocumentor`], [`phpize`], [`phplint`], [`phpmd`], [`phpspec`], [`phpstan`], [`phpunit`], [`phpunit-bridge`], [`phpunit-polyfills`], [`pint`], [`prestissimo`], [`protoc`], [`psalm`], [`rector`], [`symfony`] or [`symfony-cli`], [`vapor`] or [`vapor-cli`], [`wp`] or [`wp-cli`] +[`behat`], [`blackfire`], [`blackfire-player`], [`castor`], [`churn`], [`codeception`], [`composer`], [`composer-normalize`], [`composer-prefetcher`], [`composer-require-checker`], [`composer-unused`], [`cs2pr`], [`deployer`], [`flex`], [`grpc_php_plugin`], [`infection`], [`parallel-lint`], [`pecl`], [`phan`], [`phing`], [`phinx`], [`phive`], [`php-config`], [`php-cs-fixer`], [`phpcbf`], [`phpcpd`], [`phpcs`], [`phpdoc`] or [`phpDocumentor`], [`phpize`], [`phplint`], [`phpmd`], [`phpspec`], [`phpstan`], [`phpunit`], [`phpunit-bridge`], [`phpunit-polyfills`], [`pint`], [`prestissimo`], [`protoc`], [`psalm`], [`rector`], [`symfony`] or [`symfony-cli`], [`vapor`] or [`vapor-cli`], [`wp`] or [`wp-cli`] ```yaml - name: Setup PHP with tools @@ -1028,6 +1028,7 @@ These companies generously provide setup-php their products and services to aid [`behat`]: https://docs.behat.org/en/latest/ [`blackfire`]: https://blackfire.io/docs/php/index [`blackfire-player`]: https://blackfire.io/docs/builds-cookbooks/player +[`castor`]: https://github.com/jolicode/castor [`churn`]: https://github.com/bmitch/churn-php [`codeception`]: https://codeception.com/ [`composer`]: https://getcomposer.org/ diff --git a/__tests__/tools.test.ts b/__tests__/tools.test.ts index 33ef7b1eb..b98ad2892 100644 --- a/__tests__/tools.test.ts +++ b/__tests__/tools.test.ts @@ -526,6 +526,25 @@ describe('Tools tests', () => { } ); + it.each` + version | os | uri + ${'latest'} | ${'linux'} | ${'releases/latest/download/castor.linux-amd64.phar'} + ${'0.5.1'} | ${'linux'} | ${'releases/download/v0.5.1/castor.linux-amd64.phar'} + ${'latest'} | ${'darwin'} | ${'releases/latest/download/castor.darwin-amd64.phar'} + ${'0.5.1'} | ${'darwin'} | ${'releases/download/v0.5.1/castor.darwin-amd64.phar'} + ${'latest'} | ${'win32'} | ${'releases/latest/download/castor.windows-amd64.phar'} + ${'0.5.1'} | ${'win32'} | ${'releases/download/v0.5.1/castor.windows-amd64.phar'} + ${'latest'} | ${'openbsd'} | ${'Platform openbsd is not supported'} + `('checking addCastor: $version, $os', async ({version, os, uri}) => { + const data = getData({ + tool: 'castor', + php_version: '8.1', + version: version, + os: os + }); + expect(await tools.addCastor(data)).toContain(uri); + }); + it.each` tools_csv | script ${'none'} | ${''} diff --git a/dist/index.js b/dist/index.js index 758ab8839..d96be9e7f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -682,7 +682,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.addTools = exports.functionRecord = exports.getData = exports.addWPCLI = exports.addPHPUnitTools = exports.addPhive = exports.addPhing = exports.addPECL = exports.addDevTools = exports.addDeployer = exports.addComposer = exports.addBlackfirePlayer = exports.addPackage = exports.addArchive = exports.getPharUrl = exports.getUrl = exports.filterList = exports.getRelease = exports.getVersion = exports.getLatestVersion = exports.getSemverVersion = void 0; +exports.addTools = exports.functionRecord = exports.getData = exports.addWPCLI = exports.addPHPUnitTools = exports.addPhive = exports.addPhing = exports.addPECL = exports.addDevTools = exports.addDeployer = exports.addComposer = exports.addCastor = exports.addBlackfirePlayer = exports.addPackage = exports.addArchive = exports.getPharUrl = exports.getUrl = exports.filterList = exports.getRelease = exports.getVersion = exports.getLatestVersion = exports.getSemverVersion = void 0; const path_1 = __importDefault(__nccwpck_require__(1017)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const fetch = __importStar(__nccwpck_require__(2387)); @@ -837,6 +837,29 @@ async function addBlackfirePlayer(data) { return addArchive(data); } exports.addBlackfirePlayer = addBlackfirePlayer; +async function addCastor(data) { + let filename; + switch (data['os']) { + case 'linux': + case 'darwin': + filename = 'castor.' + data['os'] + '-amd64.phar'; + break; + case 'win32': + filename = 'castor.windows-amd64.phar'; + break; + default: + return await utils.log('Platform ' + data['os'] + ' is not supported', data['os'], 'error'); + } + if (data['version'] === 'latest') { + data['uri'] = ['releases/latest/download', filename].join('/'); + } + else { + data['uri'] = ['releases/download', 'v' + data['version'], filename].join('/'); + } + data['url'] = [data['domain'], data['repository'], data['uri']].join('/'); + return await addArchive(data); +} +exports.addCastor = addCastor; async function addComposer(data) { const channel = data['version'].replace('latest', 'stable'); const github = data['github']; @@ -1015,6 +1038,7 @@ async function getData(release, php_version, os) { } exports.getData = getData; exports.functionRecord = { + castor: addCastor, composer: addComposer, deployer: addDeployer, dev_tools: addDevTools, diff --git a/src/configs/tools.json b/src/configs/tools.json index 0833ae5d2..378bc0fdd 100644 --- a/src/configs/tools.json +++ b/src/configs/tools.json @@ -222,6 +222,12 @@ "version_prefix": "v", "version_parameter": "-V" }, + "castor": { + "type": "custom-function", + "domain": "https://github.com", + "repository": "jolicode/castor", + "function": "castor" + }, "composer": { "type": "custom-function", "domain": "https://getcomposer.org", diff --git a/src/tools.ts b/src/tools.ts index ba923f6a7..e046ed241 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -230,6 +230,39 @@ export async function addBlackfirePlayer(data: RS): Promise { return addArchive(data); } +/** + * Function to add Castor + * + * @param data + */ +export async function addCastor(data: RS): Promise { + let filename: string; + switch (data['os']) { + case 'linux': + case 'darwin': + filename = 'castor.' + data['os'] + '-amd64.phar'; + break; + case 'win32': + filename = 'castor.windows-amd64.phar'; + break; + default: + return await utils.log( + 'Platform ' + data['os'] + ' is not supported', + data['os'], + 'error' + ); + } + if (data['version'] === 'latest') { + data['uri'] = ['releases/latest/download', filename].join('/'); + } else { + data['uri'] = ['releases/download', 'v' + data['version'], filename].join( + '/' + ); + } + data['url'] = [data['domain'], data['repository'], data['uri']].join('/'); + return await addArchive(data); +} + /** * Function to add composer * @@ -479,6 +512,7 @@ export async function getData( } export const functionRecord: Record Promise> = { + castor: addCastor, composer: addComposer, deployer: addDeployer, dev_tools: addDevTools,