-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptions_tester.ts
35 lines (31 loc) · 1.03 KB
/
options_tester.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import optionsSchema from "./packages/lib/src/types/options.schema.json";
import { parser } from "@exodus/schemasafe";
import devOptions from "./packages/demo/public/options-dev.json";
import demoOptions from "./packages/demo/public/options-ccp-demo.json";
import prodOptions from "./packages/demo/public/options-ccp-prod.json";
console.log(
"Checking Lens options for ",
import.meta.env.VITE_TARGET_ENVIRONMENT,
);
let options = {};
if (import.meta.env.VITE_TARGET_ENVIRONMENT === "production") {
options = prodOptions;
} else if (import.meta.env.VITE_TARGET_ENVIRONMENT === "staging") {
options = demoOptions;
} else {
options = devOptions;
}
const parse = parser(optionsSchema, {
includeErrors: true,
allErrors: true,
});
const validJSON = parse(JSON.stringify(options));
if (validJSON.valid === true) {
console.log("Options are valid");
} else if (typeof options === "object") {
console.error(
"Lens-Options are not conform with the JSON schema",
validJSON.errors,
);
process.exit(1);
}