diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 7e24c3b..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index c44b1a6..1410632 100644 --- a/.gitignore +++ b/.gitignore @@ -129,3 +129,5 @@ dist .yarn/install-state.gz .pnp.* package-lock.json + +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index d29b06f..b54c8dd 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,10 @@ npm install . ``` +## Development/contributing + +Run `npm run dev` to start a development server at `http://localhost:8000/`. It will rebuild and reload the preview webpages when changes are made to `template.html`. + ## Usage ``` diff --git a/dev.js b/dev.js new file mode 100644 index 0000000..8ffc8dc --- /dev/null +++ b/dev.js @@ -0,0 +1,129 @@ +import * as fs from "node:fs"; +import * as http from "node:http"; +import * as path from "node:path"; +import { Readable } from 'node:stream'; +import { spawn } from 'node:child_process'; + +const PORT = 8000; + +const MIME_TYPES = { + default: "application/octet-stream", + html: "text/html; charset=UTF-8", + js: "text/javascript", + css: "text/css", + png: "image/png", + jpg: "image/jpeg", + gif: "image/gif", + ico: "image/x-icon", + svg: "image/svg+xml", +}; + +const toBool = [() => true, () => false]; + +const STATIC_PATH = path.join(process.cwd(), "./test_data"); + +const PAGES = [] + +try { + const dir = await fs.opendirSync(STATIC_PATH); + for await (const dirent of dir) + if (fs.existsSync(path.join(STATIC_PATH, dirent.name, "ro-crate-preview.html"))) { + PAGES.push({ + name: dirent.name, + link: path.join(dirent.name, "ro-crate-preview.html") + }) + } +} catch (err) { + console.error(err); +} + +function indexPage() { + let contents = ` + + +
RO Crate HTML Lite development server
+