Skip to content

Commit

Permalink
add simple and temporary bin script for indexing folder
Browse files Browse the repository at this point in the history
  • Loading branch information
olayway committed Apr 5, 2023
1 parent fa5ccba commit a030f40
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 43 deletions.
11 changes: 7 additions & 4 deletions packages/markdowndb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"name": "@flowershow/markdowndb",
"version": "0.0.3",
"description": "Parse markdown files and store them in an SQL database.",
"bin": {
"mddb": "./src/bin/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/flowershow/flowershow.git",
Expand All @@ -24,12 +27,12 @@
},
"type": "module",
"dependencies": {
"@flowershow/remark-wiki-link": "^1.1.2",
"gray-matter": "^4.0.3",
"knex": "^2.4.2",
"sqlite3": "^5.1.6"
},
"peerDependencies": {
"@flowershow/remark-wiki-link": "^1.1.2",
"remark-gfm": "^3.0.1",
"remark-parse": "^10.0.1",
"sqlite3": "^5.1.6",
"unist-util-select": "^4.0.3"
}
}
28 changes: 28 additions & 0 deletions packages/markdowndb/src/bin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env node

import { MarkdownDB } from "@flowershow/markdowndb";

// TODO get these from markdowndb.config.js or something
const dbPath = "markdown.db";
const ignorePatterns = [/Excalidraw/, /.obsidian/, /DS_Store/];
const [contentPath] = process.argv.slice(2);

if (!contentPath) {
throw new Error("Invalid/Missing path to markdown content folder");
}

const client = new MarkdownDB({
client: "sqlite3",
connection: {
filename: dbPath,
},
});

await client.init();

await client.indexFolder({
folderPath: contentPath,
ignorePatterns: ignorePatterns,
});

process.exit();
46 changes: 7 additions & 39 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a030f40

Please sign in to comment.