Return error code when any tsc typecheck fails (#5459)

* Return error code when any tsc typecheck fails

* Try with bash

`sh ./scripts/test-types.s` resulted in errors missing `[[`,
which is a bash builtin. It's possible the ubuntu runner is using
some other shell.

* Fix spec type errors

* Switch to node for Windows compatibility
This commit is contained in:
Matt Gibson 2023-05-16 10:20:40 -04:00 committed by GitHub
parent 1caae996ff
commit c58b0c0753
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 15 deletions

View File

@ -27,3 +27,5 @@ apps/cli/config/config.js
tailwind.config.js
libs/components/tailwind.config.base.js
libs/components/tailwind.config.js
scripts/*.js

View File

@ -7,7 +7,7 @@ import {
describe("ServerConfigData", () => {
describe("fromJSON", () => {
it("should create a ServerConfigData from a JSON object", () => {
const serverConfigData = ServerConfigData.fromJSON({
const json = {
version: "1.0.0",
gitHash: "1234567890",
server: {
@ -22,18 +22,11 @@ describe("ServerConfigData", () => {
sso: "https://sso.com",
},
utcDate: "2020-01-01T00:00:00.000Z",
});
featureStates: { feature: "state" },
};
const serverConfigData = ServerConfigData.fromJSON(json);
expect(serverConfigData.version).toEqual("1.0.0");
expect(serverConfigData.gitHash).toEqual("1234567890");
expect(serverConfigData.server.name).toEqual("test");
expect(serverConfigData.server.url).toEqual("https://test.com");
expect(serverConfigData.environment.vault).toEqual("https://vault.com");
expect(serverConfigData.environment.api).toEqual("https://api.com");
expect(serverConfigData.environment.identity).toEqual("https://identity.com");
expect(serverConfigData.environment.notifications).toEqual("https://notifications.com");
expect(serverConfigData.environment.sso).toEqual("https://sso.com");
expect(serverConfigData.utcDate).toEqual("2020-01-01T00:00:00.000Z");
expect(serverConfigData).toEqual(json);
});
it("should be an instance of ServerConfigData", () => {

View File

@ -62,8 +62,9 @@ describe("ImportService", () => {
});
it("has the promptForPassword_callback set", async () => {
expect(importer.promptForPassword_callback).not.toBeNull();
expect(await importer.promptForPassword_callback()).toEqual(password);
// Cast to any to access private property. Note: assumes instance of BitwardenPasswordProtectedImporter
expect((importer as any).promptForPassword_callback).not.toBeNull();
expect(await (importer as any).promptForPassword_callback()).toEqual(password);
});
it("has the appropriate organization Id", () => {

View File

@ -21,7 +21,7 @@
"test": "jest",
"test:watch": "jest --clearCache && jest --watch",
"test:watch:all": "jest --watchAll",
"test:types": "for p in libs/**/tsconfig.spec.json; do echo \"Typechecking $p\"; tsc --noEmit --project $p; done",
"test:types": "node ./scripts/test-types.js",
"docs:json": "compodoc -p ./tsconfig.json -e json -d .",
"storybook": "npm run docs:json && start-storybook -p 6006",
"build-storybook": "npm run docs:json && build-storybook",

29
scripts/test-types.js Normal file
View File

@ -0,0 +1,29 @@
const concurrently = require("concurrently");
const path = require("path");
const fs = require("fs");
function getFiles(dir) {
results = [];
fs.readdirSync(dir).forEach((file) => {
file = path.join(dir, file);
const stat = fs.statSync(file);
if (stat && stat.isDirectory()) {
results = results.concat(getFiles(file));
} else {
results.push(file);
}
});
return results;
}
const files = getFiles(path.join(__dirname, "..", "libs")).filter((file) => {
const name = path.basename(file);
return name === "tsconfig.spec.json";
});
concurrently(
files.map((file) => ({
name: path.basename(path.dirname(file)),
command: `npx tsc --noEmit --project ${file}`,
}))
);