Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
Update to Jest 27

Set sourceMap to true in tsconfig.json
  • Loading branch information
shivammathur committed May 30, 2021
1 parent baab28a commit 32c1436
Show file tree
Hide file tree
Showing 8 changed files with 2,947 additions and 6,195 deletions.
104 changes: 52 additions & 52 deletions __tests__/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,61 @@ import * as install from '../src/install';
* Mock install.ts
*/
jest.mock('../src/install', () => ({
build: jest.fn().mockImplementation(
async (
filename: string,
version: string,
os_version: string
): Promise<string> => {
const extension_csv: string = process.env['extensions'] || '';
const ini_values_csv: string = process.env['ini-values'] || '';
const coverage_driver: string = process.env['coverage'] || '';
let tools_csv: string = process.env['tools'] || '';
const pecl: string = process.env['pecl'] || '';
if (pecl == 'true') {
tools_csv = 'pecl, ' + tools_csv;
build: jest
.fn()
.mockImplementation(
async (
filename: string,
version: string,
os_version: string
): Promise<string> => {
const extension_csv: string = process.env['extensions'] || '';
const ini_values_csv: string = process.env['ini-values'] || '';
const coverage_driver: string = process.env['coverage'] || '';
let tools_csv: string = process.env['tools'] || '';
const pecl: string = process.env['pecl'] || '';
if (pecl == 'true') {
tools_csv = 'pecl, ' + tools_csv;
}

let script = 'initial script ' + filename + version + os_version;
if (tools_csv) {
script += 'add_tool';
}
if (extension_csv) {
script += 'install extensions';
}
if (coverage_driver) {
script += 'set coverage driver';
}
if (ini_values_csv) {
script += 'edit php.ini';
}

return script;
}

let script = 'initial script ' + filename + version + os_version;
if (tools_csv) {
script += 'add_tool';
}
if (extension_csv) {
script += 'install extensions';
}
if (coverage_driver) {
script += 'set coverage driver';
}
if (ini_values_csv) {
script += 'edit php.ini';
}

return script;
),
run: jest.fn().mockImplementation(async (): Promise<string> => {
const os_version: string = process.env['RUNNER_OS'] || '';
let version: string = process.env['php-version'] || '';
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
let script = '';
switch (os_version) {
case 'darwin':
case 'linux':
script = await install.build(os_version + '.sh', version, os_version);
script += 'bash script.sh ' + version + ' ' + __dirname;
break;
case 'win32':
script = await install.build(os_version + '.sh', version, os_version);
script += 'pwsh script.ps1 ' + version + ' ' + __dirname;
break;
default:
script += os_version + ' is not supported';
}
),
run: jest.fn().mockImplementation(
async (): Promise<string> => {
const os_version: string = process.env['RUNNER_OS'] || '';
let version: string = process.env['php-version'] || '';
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
let script = '';
switch (os_version) {
case 'darwin':
case 'linux':
script = await install.build(os_version + '.sh', version, os_version);
script += 'bash script.sh ' + version + ' ' + __dirname;
break;
case 'win32':
script = await install.build(os_version + '.sh', version, os_version);
script += 'pwsh script.ps1 ' + version + ' ' + __dirname;
break;
default:
script += os_version + ' is not supported';
}

return script;
}
)
return script;
})
}));

/**
Expand Down
6 changes: 3 additions & 3 deletions __tests__/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ describe('Tools tests', () => {
'a',
'b'
]);
expect(
await tools.addComposer(['a', 'b', 'composer:1.2.3'])
).toStrictEqual(['composer:1.2.3', 'a', 'b']);
expect(await tools.addComposer(['a', 'b', 'composer:1.2.3'])).toStrictEqual(
['composer:1.2.3', 'a', 'b']
);
expect(
await tools.addComposer(['a', 'b', 'composer:v1.2.3'])
).toStrictEqual(['composer:1.2.3', 'a', 'b']);
Expand Down
8 changes: 3 additions & 5 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ jest.mock('@actions/core', () => ({
})
}));

jest.spyOn(utils, 'fetch').mockImplementation(
async (url): Promise<string> => {
return `{ "latest": "8.0", "5.x": "5.6", "url": "${url}" }`;
}
);
jest.spyOn(utils, 'fetch').mockImplementation(async (url): Promise<string> => {
return `{ "latest": "8.0", "5.x": "5.6", "url": "${url}" }`;
});

async function cleanup(path: string): Promise<void> {
fs.unlink(path, error => {
Expand Down
103 changes: 85 additions & 18 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async function addINIValues(ini_values_csv, os_version, no_step = false) {
}
}
exports.addINIValues = addINIValues;

//# sourceMappingURL=config.js.map

/***/ }),

Expand Down Expand Up @@ -180,7 +180,7 @@ async function addCoverage(coverage_driver, version, os_version) {
}
}
exports.addCoverage = addCoverage;

//# sourceMappingURL=coverage.js.map

/***/ }),

Expand Down Expand Up @@ -374,7 +374,7 @@ async function addExtension(extension_csv, version, os_version, no_step = false)
}
}
exports.addExtension = addExtension;

//# sourceMappingURL=extensions.js.map

/***/ }),

Expand Down Expand Up @@ -476,7 +476,7 @@ exports.run = run;
})().catch(error => {
core.setFailed(error.message);
});

//# sourceMappingURL=install.js.map

/***/ }),

Expand Down Expand Up @@ -786,7 +786,7 @@ async function addTools(tools_csv, php_version, os_version) {
return script;
}
exports.addTools = addTools;

//# sourceMappingURL=tools.js.map

/***/ }),

Expand Down Expand Up @@ -997,22 +997,35 @@ async function suppressOutput(os_version) {
}
}
exports.suppressOutput = suppressOutput;

//# sourceMappingURL=utils.js.map

/***/ }),

/***/ 241:
/***/ (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 (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
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;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.issue = exports.issueCommand = void 0;
const os = __importStar(__nccwpck_require__(87));
const utils_1 = __nccwpck_require__(278);
/**
Expand Down Expand Up @@ -1090,6 +1103,25 @@ function escapeProperty(s) {
/***/ (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) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
Expand All @@ -1099,14 +1131,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
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 }));
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 file_command_1 = __nccwpck_require__(717);
const utils_1 = __nccwpck_require__(278);
Expand Down Expand Up @@ -1173,7 +1199,9 @@ function addPath(inputPath) {
}
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 options optional. See InputOptions.
Expand All @@ -1184,9 +1212,34 @@ function getInput(name, options) {
if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`);
}
if (options && options.trimWhitespace === false) {
return val;
}
return val.trim();
}
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.
*
Expand Down Expand Up @@ -1336,14 +1389,27 @@ exports.getState = getState;


// 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) {
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;
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;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.issueCommand = void 0;
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
const fs = __importStar(__nccwpck_require__(747));
Expand Down Expand Up @@ -1373,6 +1439,7 @@ exports.issueCommand = issueCommand;
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.toCommandValue = void 0;
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
Expand Down
Loading

0 comments on commit 32c1436

Please sign in to comment.