2022-10-10 12:50:21 +00:00
|
|
|
import * as flags from "https://deno.land/std@0.158.0/flags/mod.ts";
|
|
|
|
import * as path from "https://deno.land/std@0.158.0/path/mod.ts";
|
|
|
|
import { HttpServer } from "./http_server.ts";
|
|
|
|
|
|
|
|
const args = flags.parse(Deno.args, {
|
|
|
|
string: ["port", "password", "builtins"],
|
|
|
|
alias: { p: "port" },
|
|
|
|
default: {
|
|
|
|
port: "3000",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!args._.length) {
|
|
|
|
console.error(
|
|
|
|
"Usage: silverbullet [--port 3000] [--password mysecretpassword] <path-to-pages>",
|
|
|
|
);
|
|
|
|
Deno.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
const pagesPath = path.resolve(Deno.cwd(), args._[0] as string);
|
|
|
|
const port = +args.port;
|
|
|
|
|
|
|
|
import assetBundle from "../dist/asset_bundle.json" assert { type: "json" };
|
2022-10-12 09:47:13 +00:00
|
|
|
import { AssetBundle, AssetJson } from "../plugos/asset_bundle/bundle.ts";
|
2022-10-10 12:50:21 +00:00
|
|
|
|
2022-10-10 14:20:29 +00:00
|
|
|
console.log("Pages folder:", pagesPath);
|
2022-10-10 12:50:21 +00:00
|
|
|
|
2022-10-10 13:09:56 +00:00
|
|
|
const httpServer = new HttpServer({
|
2022-10-10 12:50:21 +00:00
|
|
|
port: port,
|
|
|
|
pagesPath: pagesPath,
|
2022-10-12 09:47:13 +00:00
|
|
|
assetBundle: new AssetBundle(assetBundle as AssetJson),
|
2022-10-10 12:50:21 +00:00
|
|
|
password: args.password,
|
|
|
|
});
|
2022-10-10 13:09:56 +00:00
|
|
|
httpServer.start().catch((e) => {
|
2022-10-10 12:50:21 +00:00
|
|
|
console.error(e);
|
|
|
|
});
|