build: enable TypeScript strict configuration (#395)

* feat: utilize catched-error-message to parse catched error

* test: fix typing in `inputs.test.ts`

* build: enable TypeScript strict configuration

* build: configure TypeScript to skip library check
This commit is contained in:
Alfi Maulana 2024-08-06 15:41:09 +07:00 committed by GitHub
parent eb127dc7da
commit fe729787d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 26 additions and 5 deletions

7
dist/index.js generated vendored
View File

@ -26698,6 +26698,10 @@ var __webpack_exports__ = {};
// EXTERNAL MODULE: ../../../.yarn/berry/cache/@actions-core-npm-1.10.1-3cb1000b4d-10c0.zip/node_modules/@actions/core/lib/core.js // EXTERNAL MODULE: ../../../.yarn/berry/cache/@actions-core-npm-1.10.1-3cb1000b4d-10c0.zip/node_modules/@actions/core/lib/core.js
var core = __nccwpck_require__(2340); var core = __nccwpck_require__(2340);
;// CONCATENATED MODULE: ../../../.yarn/berry/cache/catched-error-message-npm-0.0.1-9126a73d25-10c0.zip/node_modules/catched-error-message/dist/index.esm.js
function r(r){return function(r){if("object"==typeof(e=r)&&null!==e&&"message"in e&&"string"==typeof e.message)return r;var e;try{return new Error(JSON.stringify(r))}catch(e){return new Error(String(r))}}(r).message}
//# sourceMappingURL=index.esm.js.map
;// CONCATENATED MODULE: external "node:child_process" ;// CONCATENATED MODULE: external "node:child_process"
const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:child_process"); const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:child_process");
;// CONCATENATED MODULE: ./src/cmake.ts ;// CONCATENATED MODULE: ./src/cmake.ts
@ -26770,6 +26774,7 @@ function getInputs() {
try { try {
const inputs = getInputs(); const inputs = getInputs();
configureProject(inputs); configureProject(inputs);
@ -26779,7 +26784,7 @@ try {
} }
} }
catch (err) { catch (err) {
core.setFailed(err); core.setFailed(r(err));
} }
})(); })();

View File

@ -9,7 +9,8 @@
"test": "jest" "test": "jest"
}, },
"dependencies": { "dependencies": {
"@actions/core": "^1.10.1" "@actions/core": "^1.10.1",
"catched-error-message": "^0.0.1"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.8.0", "@eslint/js": "^9.8.0",

View File

@ -1,4 +1,5 @@
import * as core from "@actions/core"; import * as core from "@actions/core";
import { getErrorMessage } from "catched-error-message";
import { buildProject, configureProject } from "./cmake.js"; import { buildProject, configureProject } from "./cmake.js";
import { getInputs } from "./inputs.js"; import { getInputs } from "./inputs.js";
@ -13,5 +14,5 @@ try {
buildProject(inputs); buildProject(inputs);
} }
} catch (err) { } catch (err) {
core.setFailed(err); core.setFailed(getErrorMessage(err));
} }

View File

@ -134,7 +134,10 @@ describe("get action inputs", () => {
const { getInputs } = await import("./inputs.js"); const { getInputs } = await import("./inputs.js");
const core = await import("@actions/core"); const core = await import("@actions/core");
const booleanInputs = { "run-build": true, ...testCase.booleanInputs }; const booleanInputs: Record<string, boolean> = {
"run-build": true,
...testCase.booleanInputs,
};
jest.mocked(core.getBooleanInput).mockImplementation((name) => { jest.mocked(core.getBooleanInput).mockImplementation((name) => {
return booleanInputs[name] ?? false; return booleanInputs[name] ?? false;
}); });

View File

@ -2,9 +2,12 @@
"include": ["src"], "include": ["src"],
"exclude": ["**/*.test.ts"], "exclude": ["**/*.test.ts"],
"compilerOptions": { "compilerOptions": {
"exactOptionalPropertyTypes": true,
"strict": true,
"module": "node16", "module": "node16",
"moduleResolution": "node16", "moduleResolution": "node16",
"esModuleInterop": true, "esModuleInterop": true,
"target": "es2022" "target": "es2022",
"skipLibCheck": true
} }
} }

8
yarn.lock generated
View File

@ -1521,6 +1521,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"catched-error-message@npm:^0.0.1":
version: 0.0.1
resolution: "catched-error-message@npm:0.0.1"
checksum: 10c0/1f10cd4323a73bec7a57b7495730e5dad9995120b04e85b5f654f7b40dc6a36320d95cc55e49cdf78753158e18790ef725e2ec7309ebced3acd6c9a557ac075b
languageName: node
linkType: hard
"chalk@npm:^2.4.2": "chalk@npm:^2.4.2":
version: 2.4.2 version: 2.4.2
resolution: "chalk@npm:2.4.2" resolution: "chalk@npm:2.4.2"
@ -3890,6 +3897,7 @@ __metadata:
"@types/jest": "npm:^29.5.12" "@types/jest": "npm:^29.5.12"
"@types/node": "npm:^22.1.0" "@types/node": "npm:^22.1.0"
"@vercel/ncc": "npm:^0.38.1" "@vercel/ncc": "npm:^0.38.1"
catched-error-message: "npm:^0.0.1"
eslint: "npm:^9.8.0" eslint: "npm:^9.8.0"
jest: "npm:^29.7.0" jest: "npm:^29.7.0"
prettier: "npm:^3.3.3" prettier: "npm:^3.3.3"