2022-03-27 07:55:29 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
2022-03-20 08:56:28 +00:00
|
|
|
import yargs from "yargs";
|
2022-04-01 15:32:03 +00:00
|
|
|
import { hideBin } from "yargs/helpers";
|
|
|
|
import { ExpressServer } from "./api_server";
|
2022-04-21 11:57:45 +00:00
|
|
|
import path from "path";
|
2022-03-20 08:56:28 +00:00
|
|
|
|
|
|
|
let args = yargs(hideBin(process.argv))
|
2022-04-01 15:32:03 +00:00
|
|
|
.option("port", {
|
|
|
|
type: "number",
|
|
|
|
default: 3000,
|
|
|
|
})
|
|
|
|
.parse();
|
2022-03-20 08:56:28 +00:00
|
|
|
|
2022-03-27 07:55:29 +00:00
|
|
|
if (!args._.length) {
|
2022-04-01 15:32:03 +00:00
|
|
|
console.error("Usage: silverbullet <path-to-pages>");
|
|
|
|
process.exit(1);
|
2022-03-27 07:55:29 +00:00
|
|
|
}
|
|
|
|
|
2022-03-21 14:21:34 +00:00
|
|
|
const pagesPath = args._[0] as string;
|
|
|
|
|
2022-03-20 08:56:28 +00:00
|
|
|
const port = args.port;
|
2022-04-21 11:57:45 +00:00
|
|
|
const distDir = path.resolve(`${__dirname}/../../silverbullet-web/dist`);
|
2022-03-20 08:56:28 +00:00
|
|
|
|
2022-04-24 16:06:34 +00:00
|
|
|
const expressServer = new ExpressServer(port, pagesPath, distDir);
|
|
|
|
expressServer.start().catch((e) => {
|
|
|
|
console.error(e);
|
|
|
|
});
|