feat: init

This commit is contained in:
Morten Olsen
2022-12-06 09:12:53 +01:00
commit 3f5e941446
115 changed files with 13148 additions and 0 deletions

5
packages/goodwrites-cli/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
/node_modules/
/*.logs
/.yarn/
/dist/

View File

@@ -0,0 +1,2 @@
#!/usr/bin/env node
require('../dist/index.js');

View File

@@ -0,0 +1,20 @@
{
"name": "@morten-olsen/goodwrites-cli",
"packageManager": "yarn@3.1.0",
"bin": {
"goodwrites": "./bin/index.js"
},
"scripts": {
"cli": "./bin/index.js"
},
"dependencies": {
"@morten-olsen/goodwrites": "workspace:^",
"@morten-olsen/goodwrites-viewer": "workspace:^",
"commander": "^9.4.1",
"fs-extra": "^11.1.0",
"yaml": "^2.1.3"
},
"devDependencies": {
"@types/fs-extra": "^9.0.13"
}
}

View File

@@ -0,0 +1,31 @@
import { program } from 'commander';
import { resolve, dirname } from 'path';
import { createServer } from '@morten-olsen/goodwrites-viewer';
import { readFile } from 'fs-extra';
import yaml from 'yaml';
import { parseDocument } from '@morten-olsen/goodwrites';
const dev = program.command('dev <file>');
dev.action(async (file) => {
const fileLocation = resolve(process.cwd(), file);
const server = createServer({
dev: true,
documentLocation: resolve(fileLocation),
});
server.listen(4005);
});
const build = program.command('build <file>');
build.action(async (file) => {
const fileLocation = resolve(process.cwd(), file);
const location = dirname(fileLocation);
const content = await readFile(fileLocation, 'utf-8');
const document = yaml.parse(content);
const parsed = await parseDocument({
document,
location,
});
console.log(parsed.content);
});
program.parse(process.argv);

View File

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