This commit is contained in:
Morten Olsen
2024-12-10 20:59:29 +01:00
commit ede2d56b7c
54 changed files with 6955 additions and 0 deletions

2
packages/tools-cli/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/node_modules/
/dist/

2
packages/tools-cli/bin/cli.mjs Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env node
import '../dist/cli.js';

View File

@@ -0,0 +1,27 @@
{
"name": "@plaindb/tools-cli",
"version": "1.0.0",
"type": "module",
"main": "dist/exports.js",
"bin": {
"plaindb": "bin/cli.mjs"
},
"files": [
"bin",
"dist"
],
"scripts": {
"build": "tsc --build"
},
"dependencies": {
"@plaindb/fs-system": "workspace:*",
"@plaindb/plaindb": "workspace:*",
"@plaindb/plugin-core": "workspace:*",
"@plaindb/plugin-markdown": "workspace:*",
"sqlite3": "^5.1.7"
},
"devDependencies": {
"@types/node": "^22.10.1",
"typescript": "^5.7.2"
}
}

View File

@@ -0,0 +1,53 @@
import { SystemFileSystem } from '@plaindb/fs-system';
import { CorePlugin } from '@plaindb/plugin-core';
import { MarkdownPlugin } from '@plaindb/plugin-markdown';
import { resolve } from 'path';
import { PlainDB } from '../../plaindb/dist/exports.js';
const fs = new SystemFileSystem({
cwd: resolve('/Users/alice/Documents/Exo'),
});
const { plugins, documents, close } = new PlainDB({
fs,
getDBConfig: () => ({
client: 'sqlite',
useNullAsDefault: false,
connection: {
filename: ':memory:',
},
}),
});
await plugins.add([MarkdownPlugin]);
await fs.update();
const tags1 = await plugins.action(CorePlugin, 'getTags', undefined);
console.log('Done', tags1);
const demoDocument = await documents.get('hello/world.md');
demoDocument.data = Buffer.from(`
# Hello World
:tag[hello]
`);
await demoDocument.save();
const tags2 = await plugins.action(CorePlugin, 'getTags', undefined);
console.log('Done', tags2);
demoDocument.data = Buffer.from(`
# Hello World
:tag[world]
`);
await demoDocument.save();
const tags3 = await plugins.action(CorePlugin, 'getTags', undefined);
console.log('Done', tags3);
await close();

View File

@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "dist"
},
"include": [
"src"
]
}