diff --git a/scripts/buildCompendia.mjs b/scripts/buildCompendia.mjs index 41b8eac..2b39aa3 100644 --- a/scripts/buildCompendia.mjs +++ b/scripts/buildCompendia.mjs @@ -29,4 +29,4 @@ async function main() { console.log(`Finished packing compendia`) }; -main(); \ No newline at end of file +main(); diff --git a/scripts/extractCompendia.mjs b/scripts/extractCompendia.mjs index 9e58a7f..32935c9 100644 --- a/scripts/extractCompendia.mjs +++ b/scripts/extractCompendia.mjs @@ -24,4 +24,4 @@ async function main() { console.log(`Finished unpacking compendia`); }; -main(); \ No newline at end of file +main(); diff --git a/scripts/preventLocalizationCycles.mjs b/scripts/preventLocalizationCycles.mjs index 0d3b427..0271122 100644 --- a/scripts/preventLocalizationCycles.mjs +++ b/scripts/preventLocalizationCycles.mjs @@ -4,3 +4,73 @@ that there are no cycles in them to prevent infinite recursion. This must pull the pattern to match subkeys on via the config, otherwise this could result in inconsistencies with the localizer logic. */ + +import { readFile } from "fs/promises"; + +class Node { + /** @type {Array} */ + connectsTo = []; + + /** @type {boolean} */ + visited = false; + + /** @type {boolean} */ + finished = false; + + id; + constructor(data) { this.id = data; }; +}; + +/** + * @param {object | string} lang The localization object to convert into a graph + * @returns {Promise | Node>} + */ +async function createGraph(data) { + throw new Error(`createGraph not Implemented Yet`); +}; + +/** + * @param {Node} from + * @returns {Promise} + */ +async function depthFirstSearch(from) { + if (from.finished) return false; + if (from.visited) return true; + from.visited = true; + for (const neighbour of from.connectsTo) { + if (depthFirstSearch(neighbour)) return true; + }; + from.finished = true; + return false; +}; + +/** + * @param {Array} graph + */ +async function checkForCycles(graph) { + for (const node of graph) { + if (node.finished) { + console.log(`skipping node: ${node.id}`); + continue; + } + if (depthFirstSearch(node)) { + console.log(`cycle found in node: ${node.id}`); + }; + }; +}; + +async function main() { + /* + Process: + - Load the system.json to identify all lang files + - Iterate through defined languages + - Construct a graph from the language file + - Iterate through nodes checking for a cycle + */ + const lang = JSON.parse(await readFile("test.lang") ?? "{}"); + const graph = await createGraph(lang); + console.log(graph) + // await checkForCycles(graph); +}; + +main(); diff --git a/scripts/updateSystem.mjs b/scripts/updateSystem.mjs new file mode 100644 index 0000000..9670675 --- /dev/null +++ b/scripts/updateSystem.mjs @@ -0,0 +1,13 @@ +/* +Takes the system.json and updates all the release-specific properties in it to +help prevent erroneous updates from being made when using the local package for +development. + +--- + +Set the "manifest" property to: + "url" property + "/releases/latest/download/system.json" + +Set the "download" property to: + "url" property + "/releases/download/{version number}/{zip_name}.zip" +*/