mirror of
https://github.com/shivammathur/setup-php.git
synced 2026-10-15 20:06:58 +00:00
Migrate the action and tests to ES modules
This commit is contained in:
21 files changed
+95
-97
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import * as config from '../src/config';
|
||||
import * as config from '../src/config.js';
|
||||
|
||||
describe('Config tests', () => {
|
||||
it.each`
|
||||
|
||||
@@ -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', () => {
|
||||
const originalEnv = process.env;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as coverage from '../src/coverage';
|
||||
import * as coverage from '../src/coverage.js';
|
||||
|
||||
describe('Config tests', () => {
|
||||
it.each`
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as fs from 'fs';
|
||||
import * as extensions from '../src/extensions';
|
||||
import * as extensions from '../src/extensions.js';
|
||||
|
||||
describe('Extension tests', () => {
|
||||
it.each`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as fetch from '../src/fetch';
|
||||
import * as fetch from '../src/fetch.js';
|
||||
import nock from 'nock';
|
||||
|
||||
beforeAll(() => nock.disableNetConnect());
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import * as install from '../src/install';
|
||||
import * as utils from '../src/utils';
|
||||
import {jest} from '@jest/globals';
|
||||
|
||||
/**
|
||||
* Mock install.ts
|
||||
*/
|
||||
jest.mock('../src/install', () => ({
|
||||
jest.unstable_mockModule('../src/install.js', () => ({
|
||||
getScript: jest
|
||||
.fn()
|
||||
.fn<typeof import('../src/install.js').getScript>()
|
||||
.mockImplementation(async (os: string): Promise<string> => {
|
||||
const filename = os + (await utils.scriptExtension(os));
|
||||
const version: string = await utils.parseVersion(
|
||||
@@ -36,7 +35,7 @@ jest.mock('../src/install', () => ({
|
||||
/**
|
||||
* Mock fetch.ts
|
||||
*/
|
||||
jest.mock('../src/fetch', () => ({
|
||||
jest.unstable_mockModule('../src/fetch.js', () => ({
|
||||
fetch: jest.fn().mockImplementation(() => {
|
||||
return {
|
||||
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', () => {
|
||||
it.each`
|
||||
version | os | extension_csv | ini_file | ini_values_csv | coverage_driver | tools | output
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as packagist from '../src/packagist';
|
||||
import * as packagist from '../src/packagist.js';
|
||||
import nock from 'nock';
|
||||
|
||||
beforeAll(() => nock.disableNetConnect());
|
||||
|
||||
+23
-50
@@ -1,6 +1,6 @@
|
||||
import * as fs from 'fs';
|
||||
import * as tools from '../src/tools';
|
||||
import {ToolData, ToolInput} from '../src/tools';
|
||||
import {jest} from '@jest/globals';
|
||||
import fs from 'fs';
|
||||
import type {ToolData, ToolInput} from '../src/tools.js';
|
||||
|
||||
function getData(data: Partial<ToolData>): ToolData {
|
||||
const tool = data.tool || 'tool';
|
||||
@@ -40,9 +40,9 @@ function unsetComposerAuthEnv(): void {
|
||||
/**
|
||||
* Mock fetch.ts
|
||||
*/
|
||||
jest.mock('../src/fetch', () => ({
|
||||
jest.unstable_mockModule('../src/fetch.js', () => ({
|
||||
fetch: jest
|
||||
.fn()
|
||||
.fn<typeof import('../src/fetch.js').fetch>()
|
||||
.mockImplementation(
|
||||
async (url: string, token?: string): Promise<Record<string, string>> => {
|
||||
if (url.includes('deployer')) {
|
||||
@@ -86,9 +86,9 @@ jest.mock('../src/fetch', () => ({
|
||||
)
|
||||
}));
|
||||
|
||||
jest.mock('../src/packagist', () => ({
|
||||
jest.unstable_mockModule('../src/packagist.js', () => ({
|
||||
search: jest
|
||||
.fn()
|
||||
.fn<typeof import('../src/packagist.js').search>()
|
||||
.mockImplementation(
|
||||
async (
|
||||
package_name: string,
|
||||
@@ -102,6 +102,10 @@ jest.mock('../src/packagist', () => ({
|
||||
)
|
||||
}));
|
||||
|
||||
const tools = await import('../src/tools.js');
|
||||
|
||||
afterEach(() => jest.restoreAllMocks());
|
||||
|
||||
describe('Tools tests', () => {
|
||||
it.each`
|
||||
token | version
|
||||
@@ -527,30 +531,11 @@ describe('Tools tests', () => {
|
||||
});
|
||||
|
||||
it('checking affected composer version with CRLF ranges', async () => {
|
||||
let affected = false;
|
||||
let fixed = true;
|
||||
await jest.isolateModulesAsync(async () => {
|
||||
jest.doMock('fs', () => ({
|
||||
...jest.requireActual('fs'),
|
||||
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);
|
||||
jest
|
||||
.spyOn(fs, 'readFileSync')
|
||||
.mockReturnValue('1.0.0-0 1.10.28\r\n2.0.0-0 2.2.28\r\n2.3.0-0 2.9.8');
|
||||
expect(tools.skipGitHubAuthForComposerVersion('2.9.7')).toBe(true);
|
||||
expect(tools.skipGitHubAuthForComposerVersion('2.9.8')).toBe(false);
|
||||
});
|
||||
|
||||
it.each`
|
||||
@@ -948,26 +933,14 @@ describe('Tools tests', () => {
|
||||
}
|
||||
});
|
||||
|
||||
let result: string = '';
|
||||
await jest.isolateModulesAsync(async () => {
|
||||
jest.doMock('fs', () => ({
|
||||
...jest.requireActual('fs'),
|
||||
readFileSync: (
|
||||
filePath: fs.PathOrFileDescriptor,
|
||||
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 readFileSync = fs.readFileSync;
|
||||
jest.spyOn(fs, 'readFileSync').mockImplementation((filePath, options) => {
|
||||
if (String(filePath).includes('tools.json')) {
|
||||
return brokenToolsJson;
|
||||
}
|
||||
return readFileSync(filePath, options);
|
||||
});
|
||||
const result = await tools.addTools('broken-tool', '7.4', 'linux');
|
||||
|
||||
expect(result).toContain(
|
||||
'add_log "$cross" "broken-tool" "broken-tool has no function defined. Please report this issue."'
|
||||
|
||||
+13
-8
@@ -1,8 +1,13 @@
|
||||
import {fileURLToPath} from 'url';
|
||||
import {jest} from '@jest/globals';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as utils from '../src/utils';
|
||||
import * as fetchModule from '../src/fetch';
|
||||
const fetchMock = jest.fn<typeof import('../src/fetch.js').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', () => {
|
||||
it('checking readEnv', async () => {
|
||||
@@ -40,9 +45,9 @@ describe('Utils tests', () => {
|
||||
});
|
||||
|
||||
it('checking parseVersion', async () => {
|
||||
const fetchSpy = jest.spyOn(fetchModule, 'fetch').mockResolvedValue({
|
||||
const fetchSpy = fetchMock.mockResolvedValue({
|
||||
data: fs.readFileSync(
|
||||
path.join(__dirname, '../src/configs/php-versions.json'),
|
||||
path.join(dirname, '../src/configs/php-versions.json'),
|
||||
'utf8'
|
||||
)
|
||||
});
|
||||
@@ -324,8 +329,8 @@ describe('Utils tests', () => {
|
||||
"Could not find '.phpenv-version' file."
|
||||
);
|
||||
|
||||
const existsSync = jest.spyOn(fs, 'existsSync').mockImplementation();
|
||||
const readFileSync = jest.spyOn(fs, 'readFileSync').mockImplementation();
|
||||
const existsSync = jest.spyOn(fs, 'existsSync').mockReturnValue(false);
|
||||
const readFileSync = jest.spyOn(fs, 'readFileSync').mockReturnValue('');
|
||||
|
||||
existsSync.mockReturnValue(true);
|
||||
readFileSync.mockReturnValue('8.1');
|
||||
@@ -391,8 +396,8 @@ describe('Utils tests', () => {
|
||||
});
|
||||
|
||||
it('readPHPVersion rejects unsupported values from each source', async () => {
|
||||
const existsSync = jest.spyOn(fs, 'existsSync').mockImplementation();
|
||||
const readFileSync = jest.spyOn(fs, 'readFileSync').mockImplementation();
|
||||
const existsSync = jest.spyOn(fs, 'existsSync').mockReturnValue(false);
|
||||
const readFileSync = jest.spyOn(fs, 'readFileSync').mockReturnValue('');
|
||||
|
||||
process.env['php-version'] = '$0';
|
||||
await expect(utils.readPHPVersion()).rejects.toThrow('php-version input');
|
||||
|
||||
Vendored
+1
-1
@@ -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[@]}}" >/dev/null 2>&1'+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:Line 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:$,symlink:b,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 $(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
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
+6
-2
@@ -1,11 +1,15 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
extensionsToTreatAsEsm: ['.ts'],
|
||||
moduleNameMapper: {
|
||||
'^(\\.{1,2}/.*)\\.js$': '$1'
|
||||
},
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
transform: {
|
||||
'^.+\\.ts$': ['ts-jest', {tsconfig: 'tsconfig.test.json'}]
|
||||
'^.+\\.ts$': ['ts-jest', {tsconfig: 'tsconfig.test.json', useESM: true}]
|
||||
},
|
||||
verbose: true,
|
||||
collectCoverage: true
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"version": "2.40.0",
|
||||
"private": false,
|
||||
"description": "Setup PHP for use with GitHub Actions",
|
||||
"type": "module",
|
||||
"main": "lib/install.js",
|
||||
"types": "lib/install.d.ts",
|
||||
"directories": {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import * as utils from './utils';
|
||||
import * as utils from './utils.js';
|
||||
|
||||
/**
|
||||
* Add script to set custom ini values for unix
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import * as utils from './utils';
|
||||
import * as extensions from './extensions';
|
||||
import * as config from './config';
|
||||
import * as utils from './utils.js';
|
||||
import * as extensions from './extensions.js';
|
||||
import * as config from './config.js';
|
||||
|
||||
export async function checkXdebugError(
|
||||
extension: string,
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import * as utils from './utils';
|
||||
import * as utils from './utils.js';
|
||||
|
||||
/**
|
||||
* Install and enable extensions for darwin
|
||||
|
||||
+11
-8
@@ -1,11 +1,15 @@
|
||||
import {fileURLToPath} from 'url';
|
||||
import path from 'path';
|
||||
import {exec} from '@actions/exec';
|
||||
import fs from 'fs';
|
||||
import * as config from './config';
|
||||
import * as core from './core';
|
||||
import * as coverage from './coverage';
|
||||
import * as extensions from './extensions';
|
||||
import * as tools from './tools';
|
||||
import * as utils from './utils';
|
||||
import * as config from './config.js';
|
||||
import * as core from './core.js';
|
||||
import * as coverage from './coverage.js';
|
||||
import * as extensions from './extensions.js';
|
||||
import * as tools from './tools.js';
|
||||
import * as utils from './utils.js';
|
||||
|
||||
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
/**
|
||||
* Build the script
|
||||
@@ -15,7 +19,7 @@ import * as utils from './utils';
|
||||
export async function getScript(os: string): Promise<string> {
|
||||
const url = 'https://setup-php.com/sponsor';
|
||||
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 extension_csv: string = utils.sanitizeShellInput(
|
||||
await utils.getInput('extensions', false),
|
||||
@@ -65,7 +69,6 @@ export async function run(): Promise<void> {
|
||||
const os: string = process.platform;
|
||||
const tool = await utils.scriptTool(os);
|
||||
const run_path = await getScript(os);
|
||||
const {exec} = await import(/* webpackMode: "eager" */ '@actions/exec');
|
||||
await exec(tool + run_path);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import * as cv from 'compare-versions';
|
||||
import * as fetch from './fetch';
|
||||
import * as fetch from './fetch.js';
|
||||
|
||||
type RS = Record<string, string>;
|
||||
type RSRS = Record<string, RS>;
|
||||
|
||||
+8
-5
@@ -1,9 +1,12 @@
|
||||
import {fileURLToPath} from 'url';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import * as cv from 'compare-versions';
|
||||
import * as fetch from './fetch';
|
||||
import * as packagist from './packagist';
|
||||
import * as utils from './utils';
|
||||
import * as fetch from './fetch.js';
|
||||
import * as packagist from './packagist.js';
|
||||
import * as utils from './utils.js';
|
||||
|
||||
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
/**
|
||||
* Valid function names for custom tool handlers
|
||||
@@ -155,7 +158,7 @@ export function skipGitHubAuthForComposerVersion(version: string): boolean {
|
||||
}
|
||||
return fs
|
||||
.readFileSync(
|
||||
path.join(__dirname, '../src/configs/composer-gh-auth-no-op'),
|
||||
path.join(dirname, '../src/configs/composer-gh-auth-no-op'),
|
||||
'utf8'
|
||||
)
|
||||
.trim()
|
||||
@@ -672,7 +675,7 @@ export async function getData(
|
||||
php_version: string,
|
||||
os: string
|
||||
): 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_objects: Record<string, ToolConfig> = JSON.parse(json_file);
|
||||
release = release.replace(/\s+/g, '');
|
||||
|
||||
+6
-3
@@ -1,7 +1,10 @@
|
||||
import {fileURLToPath} from 'url';
|
||||
import fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as core from './core';
|
||||
import * as fetch from './fetch';
|
||||
import * as core from './core.js';
|
||||
import * as fetch from './fetch.js';
|
||||
|
||||
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
/**
|
||||
* Function to read environment variable and return a string value.
|
||||
@@ -480,7 +483,7 @@ export async function customPackage(
|
||||
const pkg_name: string = pkg.replace(/\d+|(pdo|pecl)[_-]|[_-]db2/, '');
|
||||
const script_extension: string = await scriptExtension(os);
|
||||
const script: string = path.join(
|
||||
__dirname,
|
||||
dirname,
|
||||
'../src/scripts/' + type + '/' + pkg_name + script_extension
|
||||
);
|
||||
const command: string = await getCommand(os, pkg_name);
|
||||
|
||||
+3
-3
@@ -5,11 +5,11 @@
|
||||
"lib": [
|
||||
"ES2025"
|
||||
],
|
||||
"module": "Node20",
|
||||
"moduleResolution": "Node16",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"noImplicitAny": true,
|
||||
"outDir": "./lib",
|
||||
"removeComments": false,
|
||||
"removeComments": true,
|
||||
"rootDir": "./src",
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
|
||||
Reference in new issue
Block a user