diff --git a/.gitignore b/.gitignore index b4a76b7..9403c40 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ node_modules src/day* ./ligma.config.js dist +stats.json diff --git a/.jest.config.json b/.jest.config.json index a81ee2c..e6cbbbe 100644 --- a/.jest.config.json +++ b/.jest.config.json @@ -2,7 +2,7 @@ "clearMocks": true, "moduleNameMapper": { "@code/(.*)": [ - "/src/day9/$1" + "/src/day1/$1" ] }, "preset": "ts-jest" diff --git a/package.json b/package.json index 919d9f2..33e801e 100644 --- a/package.json +++ b/package.json @@ -19,15 +19,5 @@ "prettier": "prettier --write ./src", "generate": "./scripts/generate", "day": "echo /home/mpaulson/personal/kata/src/day9" - }, - "kata_stats": { - "ArrayList": 3, - "DijkstraList": 5, - "InsertionSort": 4, - "MergeSort": 4, - "Queue": 4, - "Stack": 4, - "QuickSort": 4, - "PrimsList": 1 } -} \ No newline at end of file +} diff --git a/scripts/align-configs.js b/scripts/align-configs.js index 26edef8..d228862 100644 --- a/scripts/align-configs.js +++ b/scripts/align-configs.js @@ -1,19 +1,31 @@ const fs = require("fs"); const path = require("path"); -module.exports.package_json = function(config, day_path) { - const package_json = require("../package.json"); - package_json.scripts.test = `jest ${config.dsa.join(" ")}`; - package_json.scripts.day = `echo ${day_path}`; +module.exports.stats = function(config, day_path) { + let stats; + try { + stats = require("../stats.json"); + } catch(e) { + stats = undefined; + } - package_json.kata_stats = config.dsa.reduce((acc, ds) => { + stats = config.dsa.reduce((acc, ds) => { if (!acc[ds]) { acc[ds] = 0; } acc[ds]++; return acc; - }, package_json.kata_stats || {}); + }, stats || {}); + fs.writeFileSync( + path.join(__dirname, "..", "stats.json"), + JSON.stringify(package_json, null, 4)); +} + +module.exports.package_json = function(config, day_path) { + const package_json = require("../package.json"); + package_json.scripts.test = `jest ${config.dsa.join(" ")}`; + package_json.scripts.day = `echo ${day_path}`; fs.writeFileSync( path.join(__dirname, "..", "package.json"), diff --git a/scripts/generate b/scripts/generate index 8746cb5..a9e228b 100755 --- a/scripts/generate +++ b/scripts/generate @@ -78,4 +78,5 @@ const align = require("./align-configs"); align.jest(day_name); align.ts_config(day_name); align.package_json(config, day_path); +align.stats(config, day_path); diff --git a/tsconfig.json b/tsconfig.json index 6021687..0079bd7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,7 @@ "baseUrl": "src", "paths": { "@code/*": [ - "day9/*" + "day1/*" ] } },