From 65cc81e39272a8855c136cb879626068f62f9808 Mon Sep 17 00:00:00 2001 From: Breck Yunits Date: Wed, 19 Jun 2024 08:26:12 -1000 Subject: [PATCH] checkpoint --- ScrollSet.js | 40 +++++++++++++++++++++++----------------- cli.js | 2 +- code/measures.parsers | 2 +- package.json | 4 ++-- readme.scroll | 2 +- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/ScrollSet.js b/ScrollSet.js index e008cef3b4..8105ef5e2a 100644 --- a/ScrollSet.js +++ b/ScrollSet.js @@ -4,6 +4,8 @@ const lodash = require("lodash") const { TreeNode } = require("scrollsdk/products/TreeNode.js") const { Utils } = require("scrollsdk/products/Utils.js") const { Disk } = require("scrollsdk/products/Disk.node.js") +const { ScrollFile, ScrollFileSystem } = require("scroll-cli") +const scrollFs = new ScrollFileSystem() class ScrollSetCLI { constructor() { @@ -48,12 +50,15 @@ class ScrollSetCLI { setAndSave(file, measurementPath, measurementValue) { const tree = this.getTree(file) tree.set(measurementPath, measurementValue) - return this.save(file, tree) + return this.formatAndSave(file, tree) } - save(file, tree) { - const dest = this.makeFilePath(file.id) - return Disk.write(dest, tree.toString()) + formatAndSave(file, tree) { + return new ScrollFile( + tree.toString(), + this.makeFilePath(file.id), + scrollFs + ).formatAndSave() } makeNameSearchIndex(files = this.concepts.slice(0).reverse()) { @@ -84,7 +89,7 @@ class ScrollSetCLI { console.log(lodash.pickBy(this.searchForConcept(query), lodash.identity)) } - grammarFile = "" + parsersFile = "" scrollSetName = "myScrollSet" get concepts() { @@ -93,7 +98,8 @@ class ScrollSetCLI { async updateIdsCommand() { this.concepts.forEach((file) => { - const tree = this.getTree(file) + const dest = path.join(this.conceptsFolder, file.filename) + const tree = new TreeNode(Disk.read(dest)) const newTree = tree.toString().replace( `import ../code/conceptPage.scroll id `, @@ -101,19 +107,19 @@ id `, id ${file.filename.replace(".scroll", "")} name ` ) - this.save(file, newTree.toString()) + Disk.write(dest, newTree.toString()) }) } - buildGrammarFileCommand() { - const code = `node_modules/scroll-cli/grammar/cellTypes.grammar -node_modules/scroll-cli/grammar/root.grammar -node_modules/scroll-cli/grammar/comments.grammar -node_modules/scroll-cli/grammar/blankLine.grammar -node_modules/scroll-cli/grammar/measures.grammar -node_modules/scroll-cli/grammar/import.grammar -node_modules/scroll-cli/grammar/errors.grammar -${this.grammarFile}` + buildParsersFile() { + const code = `node_modules/scroll-cli/parsers/cellTypes.parsers +node_modules/scroll-cli/parsers/root.parsers +node_modules/scroll-cli/parsers/comments.parsers +node_modules/scroll-cli/parsers/blankLine.parsers +node_modules/scroll-cli/parsers/measures.parsers +node_modules/scroll-cli/parsers/import.parsers +node_modules/scroll-cli/parsers/errors.parsers +${this.parsersFile}` .trim() .split("\n") .map((filepath) => Disk.read(path.join(__dirname, filepath))) @@ -124,7 +130,7 @@ ${this.grammarFile}` ) .replace(/^importOnly\n/gm, "") .replace(/^import .+/gm, "") - Disk.write(path.join(__dirname, `${this.scrollSetName}.grammar`), code) + Disk.write(path.join(__dirname, `${this.scrollSetName}.parsers`), code) } } diff --git a/cli.js b/cli.js index 0eaeb140c4..cab776a627 100755 --- a/cli.js +++ b/cli.js @@ -6,7 +6,7 @@ const { ScrollSetCLI } = require("./ScrollSet.js") class CancerDBCli extends ScrollSetCLI { conceptsFolder = path.join(__dirname, "concepts") - grammarFile = "code/measures.parsers" + parsersFile = "code/measures.parsers" scrollSetName = "cancerdb" compiledConcepts = "./cancerdb.json" } diff --git a/code/measures.parsers b/code/measures.parsers index f8c0dce969..d296c2788d 100644 --- a/code/measures.parsers +++ b/code/measures.parsers @@ -460,7 +460,7 @@ rumbleParser // socialMedia abstractSocialMediaParser extends abstractUrlMeasureParser - // todo remove the need for the below from grammar + // todo remove the need for the below from parsers string sortKey abstractSocialMediaParser contentKey url float sortIndex 10 diff --git a/package.json b/package.json index 4a18217f1a..2cb5f67a49 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "homepage": "https://cancerdb.com", "devDependencies": { "lodash": "^4.17.21", - "scroll-cli": "^96.0.0", - "scrollsdk": "^78.0.0" + "scroll-cli": "^97.0.0", + "scrollsdk": "^80.0.0" } } diff --git a/readme.scroll b/readme.scroll index 7b712ca96f..bb90e130a6 100644 --- a/readme.scroll +++ b/readme.scroll @@ -31,7 +31,7 @@ code npm run build ## To explore this repo -The most important folder is `concepts`, which contains a file for each concept. The folder `measures` contains the grammar files (schema) for the ScrollSet. +The most important folder is `concepts`, which contains a file for each concept. The folder `measures` contains the parsers files (schema) for the ScrollSet. ## To cite CancerDB CancerDB content is published to the public domain and you can use it freely. If needed, here are 3 options for citing CancerDB: