Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Breck Yunits authored and Breck Yunits committed Jun 19, 2024
1 parent 0c95f8b commit 65cc81e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
40 changes: 23 additions & 17 deletions ScrollSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -84,7 +89,7 @@ class ScrollSetCLI {
console.log(lodash.pickBy(this.searchForConcept(query), lodash.identity))
}

grammarFile = ""
parsersFile = ""
scrollSetName = "myScrollSet"

get concepts() {
Expand All @@ -93,27 +98,28 @@ 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 `,
`import ../code/conceptPage.scroll
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)))
Expand All @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion code/measures.parsers
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion readme.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 65cc81e

Please sign in to comment.