Skip to content

Commit

Permalink
Merge pull request #56 from samply/feature/add-json-schema
Browse files Browse the repository at this point in the history
Feature/add json schema
  • Loading branch information
MatsJohansen87 authored Jun 3, 2024
2 parents 2ed5b2e + 31e89a8 commit 473a213
Show file tree
Hide file tree
Showing 11 changed files with 469 additions and 342 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ COPY package.json package-lock.json ./
RUN npm install
COPY ./vite.config.ts ./vite.demo.config.ts ./extensions.json ./tsconfig.json ./tsconfig.node.json ./
COPY ./packages ./packages
COPY ./options_tester.cjs ./options_tester.cjs

RUN VITE_TARGET_ENVIRONMENT=${TARGET_ENVIRONMENT} npm run build
RUN VITE_TARGET_ENVIRONMENT=${TARGET_ENVIRONMENT} npm run build:demo

Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tsc --resolveJsonModule --esModuleInterop options_tester.ts
mv options_tester.js options_tester.cjs
21 changes: 21 additions & 0 deletions options_tester.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var options_schema_json_1 = __importDefault(require("./packages/lib/src/interfaces/options.schema.json"));
var schemasafe_1 = require("@exodus/schemasafe");
var options_json_1 = __importDefault(require("./packages/demo/public/options.json"));
console.log("Checking Lens options");
var parse = (0, schemasafe_1.parser)(options_schema_json_1.default, {
includeErrors: true,
allErrors: true,
});
var validJSON = parse(JSON.stringify(options_json_1.default));
if (validJSON.valid === true) {
console.log("Options are valid");
}
else if (typeof options_json_1.default === "object") {
console.error("Lens-Options are not conform with the JSON schema", validJSON.errors);
process.exit(1);
}
21 changes: 21 additions & 0 deletions options_tester.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import optionsSchema from "./packages/lib/src/interfaces/options.schema.json";
import { parser } from "@exodus/schemasafe";

import options from "./packages/demo/public/options.json";

console.log("Checking Lens options");

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);
}
Loading

0 comments on commit 473a213

Please sign in to comment.