Update dependencies

Update to Jest 27

Set sourceMap to true in tsconfig.json
This commit is contained in:
Shivam Mathur 2021-05-31 02:29:23 +05:30
parent baab28a534
commit 32c1436247
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
8 changed files with 2791 additions and 6039 deletions

View File

@ -4,7 +4,9 @@ import * as install from '../src/install';
* Mock install.ts * Mock install.ts
*/ */
jest.mock('../src/install', () => ({ jest.mock('../src/install', () => ({
build: jest.fn().mockImplementation( build: jest
.fn()
.mockImplementation(
async ( async (
filename: string, filename: string,
version: string, version: string,
@ -36,8 +38,7 @@ jest.mock('../src/install', () => ({
return script; return script;
} }
), ),
run: jest.fn().mockImplementation( run: jest.fn().mockImplementation(async (): Promise<string> => {
async (): Promise<string> => {
const os_version: string = process.env['RUNNER_OS'] || ''; const os_version: string = process.env['RUNNER_OS'] || '';
let version: string = process.env['php-version'] || ''; let version: string = process.env['php-version'] || '';
version = version.length > 1 ? version.slice(0, 3) : version + '.0'; version = version.length > 1 ? version.slice(0, 3) : version + '.0';
@ -57,8 +58,7 @@ jest.mock('../src/install', () => ({
} }
return script; return script;
} })
)
})); }));
/** /**

View File

@ -163,9 +163,9 @@ describe('Tools tests', () => {
'a', 'a',
'b' 'b'
]); ]);
expect( expect(await tools.addComposer(['a', 'b', 'composer:1.2.3'])).toStrictEqual(
await tools.addComposer(['a', 'b', 'composer:1.2.3']) ['composer:1.2.3', 'a', 'b']
).toStrictEqual(['composer:1.2.3', 'a', 'b']); );
expect( expect(
await tools.addComposer(['a', 'b', 'composer:v1.2.3']) await tools.addComposer(['a', 'b', 'composer:v1.2.3'])
).toStrictEqual(['composer:1.2.3', 'a', 'b']); ).toStrictEqual(['composer:1.2.3', 'a', 'b']);

View File

@ -8,11 +8,9 @@ jest.mock('@actions/core', () => ({
}) })
})); }));
jest.spyOn(utils, 'fetch').mockImplementation( jest.spyOn(utils, 'fetch').mockImplementation(async (url): Promise<string> => {
async (url): Promise<string> => {
return `{ "latest": "8.0", "5.x": "5.6", "url": "${url}" }`; return `{ "latest": "8.0", "5.x": "5.6", "url": "${url}" }`;
} });
);
async function cleanup(path: string): Promise<void> { async function cleanup(path: string): Promise<void> {
fs.unlink(path, error => { fs.unlink(path, error => {

103
dist/index.js vendored
View File

@ -76,7 +76,7 @@ async function addINIValues(ini_values_csv, os_version, no_step = false) {
} }
} }
exports.addINIValues = addINIValues; exports.addINIValues = addINIValues;
//# sourceMappingURL=config.js.map
/***/ }), /***/ }),
@ -180,7 +180,7 @@ async function addCoverage(coverage_driver, version, os_version) {
} }
} }
exports.addCoverage = addCoverage; exports.addCoverage = addCoverage;
//# sourceMappingURL=coverage.js.map
/***/ }), /***/ }),
@ -374,7 +374,7 @@ async function addExtension(extension_csv, version, os_version, no_step = false)
} }
} }
exports.addExtension = addExtension; exports.addExtension = addExtension;
//# sourceMappingURL=extensions.js.map
/***/ }), /***/ }),
@ -476,7 +476,7 @@ exports.run = run;
})().catch(error => { })().catch(error => {
core.setFailed(error.message); core.setFailed(error.message);
}); });
//# sourceMappingURL=install.js.map
/***/ }), /***/ }),
@ -786,7 +786,7 @@ async function addTools(tools_csv, php_version, os_version) {
return script; return script;
} }
exports.addTools = addTools; exports.addTools = addTools;
//# sourceMappingURL=tools.js.map
/***/ }), /***/ }),
@ -997,7 +997,7 @@ async function suppressOutput(os_version) {
} }
} }
exports.suppressOutput = suppressOutput; exports.suppressOutput = suppressOutput;
//# sourceMappingURL=utils.js.map
/***/ }), /***/ }),
@ -1005,14 +1005,27 @@ exports.suppressOutput = suppressOutput;
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
result["default"] = mod; __setModuleDefault(result, mod);
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.issue = exports.issueCommand = void 0;
const os = __importStar(__nccwpck_require__(87)); const os = __importStar(__nccwpck_require__(87));
const utils_1 = __nccwpck_require__(278); const utils_1 = __nccwpck_require__(278);
/** /**
@ -1090,6 +1103,25 @@ function escapeProperty(s) {
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
@ -1099,14 +1131,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
const command_1 = __nccwpck_require__(241); const command_1 = __nccwpck_require__(241);
const file_command_1 = __nccwpck_require__(717); const file_command_1 = __nccwpck_require__(717);
const utils_1 = __nccwpck_require__(278); const utils_1 = __nccwpck_require__(278);
@ -1173,7 +1199,9 @@ function addPath(inputPath) {
} }
exports.addPath = addPath; exports.addPath = addPath;
/** /**
* Gets the value of an input. The value is also trimmed. * Gets the value of an input.
* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
* Returns an empty string if the value is not defined.
* *
* @param name name of the input to get * @param name name of the input to get
* @param options optional. See InputOptions. * @param options optional. See InputOptions.
@ -1184,9 +1212,34 @@ function getInput(name, options) {
if (options && options.required && !val) { if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`); throw new Error(`Input required and not supplied: ${name}`);
} }
if (options && options.trimWhitespace === false) {
return val;
}
return val.trim(); return val.trim();
} }
exports.getInput = getInput; exports.getInput = getInput;
/**
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
* Support boolean input list: `true | True | TRUE | false | False | FALSE` .
* The return value is also in boolean type.
* ref: https://yaml.org/spec/1.2/spec.html#id2804923
*
* @param name name of the input to get
* @param options optional. See InputOptions.
* @returns boolean
*/
function getBooleanInput(name, options) {
const trueValue = ['true', 'True', 'TRUE'];
const falseValue = ['false', 'False', 'FALSE'];
const val = getInput(name, options);
if (trueValue.includes(val))
return true;
if (falseValue.includes(val))
return false;
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
}
exports.getBooleanInput = getBooleanInput;
/** /**
* Sets the value of an output. * Sets the value of an output.
* *
@ -1336,14 +1389,27 @@ exports.getState = getState;
// For internal use, subject to change. // For internal use, subject to change.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
result["default"] = mod; __setModuleDefault(result, mod);
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.issueCommand = void 0;
// We use any as a valid input type // We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
const fs = __importStar(__nccwpck_require__(747)); const fs = __importStar(__nccwpck_require__(747));
@ -1373,6 +1439,7 @@ exports.issueCommand = issueCommand;
// We use any as a valid input type // We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.toCommandValue = void 0;
/** /**
* Sanitizes an input into a string so it can be passed into issueCommand safely * Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string * @param input input to sanitize into a string

8560
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -24,28 +24,28 @@
"author": "shivammathur", "author": "shivammathur",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.7", "@actions/core": "^1.3.0",
"@actions/exec": "^1.0.4", "@actions/exec": "^1.0.4",
"@actions/io": "^1.1.0", "@actions/io": "^1.1.0",
"fs": "0.0.1-security" "fs": "0.0.1-security"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^26.0.22", "@types/jest": "^26.0.23",
"@types/node": "^14.14.41", "@types/node": "^15.6.1",
"@typescript-eslint/eslint-plugin": "^4.22.0", "@typescript-eslint/eslint-plugin": "^4.25.0",
"@typescript-eslint/parser": "^4.22.0", "@typescript-eslint/parser": "^4.25.0",
"@vercel/ncc": "^0.28.3", "@vercel/ncc": "^0.28.6",
"eslint": "^7.24.0", "eslint": "^7.27.0",
"eslint-config-prettier": "^8.2.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.22.1", "eslint-plugin-import": "^2.23.4",
"eslint-plugin-jest": "^24.3.5", "eslint-plugin-jest": "^24.3.6",
"eslint-plugin-prettier": "^3.4.0", "eslint-plugin-prettier": "^3.4.0",
"husky": "^4.3.8", "husky": "^4.3.8",
"jest": "^26.6.3", "jest": "^27.0.3",
"jest-circus": "^26.6.3", "jest-circus": "^27.0.3",
"prettier": "^2.2.1", "prettier": "^2.3.0",
"ts-jest": "^26.5.5", "ts-jest": "^27.0.1",
"typescript": "^4.2.4" "typescript": "^4.3.2"
}, },
"husky": { "husky": {
"skipCI": true, "skipCI": true,

View File

@ -32,7 +32,8 @@ export async function getCommand(
*/ */
export async function getToolVersion(version: string): Promise<string> { export async function getToolVersion(version: string): Promise<string> {
// semver_regex - https://semver.org/ // semver_regex - https://semver.org/
const semver_regex = /^(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-]+)*))?$/; const semver_regex =
/^(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-]+)*))?$/;
const composer_regex = /^stable$|^preview$|^snapshot$|^v?[1|2]$/; const composer_regex = /^stable$|^preview$|^snapshot$|^v?[1|2]$/;
version = version.replace(/[><=^]*/, ''); version = version.replace(/[><=^]*/, '');
switch (true) { switch (true) {
@ -215,8 +216,10 @@ export async function getSymfonyUri(
*/ */
export async function addComposer(tools_list: string[]): Promise<string[]> { export async function addComposer(tools_list: string[]): Promise<string[]> {
const regex_any = /^composer($|:.*)/; const regex_any = /^composer($|:.*)/;
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$|v?\d+\.\d+\.\d+[\w-]*$)/; const regex_valid =
const regex_composer1_tools = /hirak|prestissimo|narrowspark|composer-prefetcher/; /^composer:?($|preview$|snapshot$|v?[1-2]$|v?\d+\.\d+\.\d+[\w-]*$)/;
const regex_composer1_tools =
/hirak|prestissimo|narrowspark|composer-prefetcher/;
const matches: string[] = tools_list.filter(tool => regex_valid.test(tool)); const matches: string[] = tools_list.filter(tool => regex_valid.test(tool));
let composer = 'composer'; let composer = 'composer';
tools_list = tools_list.filter(tool => !regex_any.test(tool)); tools_list = tools_list.filter(tool => !regex_any.test(tool));

View File

@ -10,7 +10,7 @@
"outDir": "./lib", "outDir": "./lib",
"removeComments": true, "removeComments": true,
"rootDir": "./src", "rootDir": "./src",
"sourceMap": false, "sourceMap": true,
"strict": true, "strict": true,
"target": "ESNext" "target": "ESNext"
}, },