committed by
Bastian
parent
8d28e4c3a3
commit
70ea8d5bcd
@@ -1,8 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { copyFileSync, mkdirSync, existsSync } from "fs";
|
||||
import { copyFileSync, mkdirSync, existsSync, readFileSync } from "fs";
|
||||
import { createRadar } from "./generateJson/radar";
|
||||
import { quadrants } from "../src/config";
|
||||
|
||||
// Do this as the first thing so that any code reading it knows the right env.
|
||||
process.env.BABEL_ENV = "production";
|
||||
@@ -22,8 +21,9 @@ process.on("unhandledRejection", (err) => {
|
||||
|
||||
copyFileSync("build/index.html", "build/overview.html");
|
||||
copyFileSync("build/index.html", "build/help-and-about-tech-radar.html");
|
||||
|
||||
quadrants.forEach((quadrant) => {
|
||||
const rawConf = readFileSync("build/config.json", "utf-8");
|
||||
const config = JSON.parse(rawConf);
|
||||
Object.keys(config.quadrants).forEach((quadrant) => {
|
||||
const destFolder = `build/${quadrant}`;
|
||||
copyFileSync("build/index.html", `${destFolder}.html`);
|
||||
if (!existsSync(destFolder)) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { readFile } from "fs-extra";
|
||||
import { readFileSync } from "fs";
|
||||
import * as path from "path";
|
||||
import frontMatter from "front-matter";
|
||||
// @ts-ignore esModuleInterop is activated in tsconfig.scripts.json, but IDE typescript uses default typescript config
|
||||
@@ -6,8 +7,8 @@ import marked from "marked";
|
||||
import highlight from "highlight.js";
|
||||
|
||||
import { radarPath, getAllMarkdownFiles } from "./file";
|
||||
import { quadrants, rings } from "../../src/config";
|
||||
import { Item, Revision, ItemAttributes, Radar } from "../../src/model";
|
||||
import { appBuild } from "../paths";
|
||||
|
||||
type FMAttributes = ItemAttributes;
|
||||
|
||||
@@ -29,12 +30,16 @@ export const createRadar = async (): Promise<Radar> => {
|
||||
};
|
||||
|
||||
const checkAttributes = (fileName: string, attributes: FMAttributes) => {
|
||||
if (attributes.ring && !rings.includes(attributes.ring)) {
|
||||
const rawConf = readFileSync(path.resolve(appBuild, 'config.json'), 'utf-8');
|
||||
const config = JSON.parse(rawConf);
|
||||
|
||||
if (attributes.ring && !config.rings.includes(attributes.ring)) {
|
||||
throw new Error(
|
||||
`Error: ${fileName} has an illegal value for 'ring' - must be one of ${rings}`
|
||||
`Error: ${fileName} has an illegal value for 'ring' - must be one of ${config.rings}`
|
||||
);
|
||||
}
|
||||
|
||||
const quadrants = Object.keys(config.quadrants);
|
||||
if (attributes.quadrant && !quadrants.includes(attributes.quadrant)) {
|
||||
throw new Error(
|
||||
`Error: ${fileName} has an illegal value for 'quadrant' - must be one of ${quadrants}`
|
||||
@@ -50,7 +55,7 @@ const createRevisionsFromFiles = (fileNames: string[]) => {
|
||||
fileNames.map(
|
||||
(fileName) =>
|
||||
new Promise<Revision>((resolve, reject) => {
|
||||
readFile(fileName, "utf8", (err, data) => {
|
||||
readFile(fileName, "utf8", async (err, data) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user