-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauralog.js
executable file
·68 lines (60 loc) · 1.79 KB
/
auralog.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env node
/**
* @format
* @todo Overhaul app to use Highcharts dashboard and Highcharts calendar heatmap, removing need for Lit or D3.
* @todo Support merging vite configs.
*/
import {Command} from "commander";
import {build, createServer, preview} from "vite";
import {Plop, run} from "plop";
import pkg from "./package.json" with {type: "json"};
import auralogViteConfig from "./vite.config.js";
import MoveIndexFile from "./src/lib/MoveIndexFile.js";
import {dirname, resolve} from "node:path";
import {fileURLToPath} from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const program = new Command();
program.name(pkg.name).description(pkg.description).version(pkg.version);
/**
* @todo Figure out why `npx auralog add` attempts to pass "add" as the first input value which fails the validator
*/
program
.command("add", {isDefault: true})
.alias("write")
.description("Add a new entry to your log.")
.action(() => {
Plop.prepare(
{
configPath: resolve(__dirname, "plopfile.js"),
},
(env) => Plop.execute(env, run),
);
});
program
.command("build")
.description(
"Build your Aura Log for production. Files are output into `dist`.",
)
.action(async () => {
await build(auralogViteConfig);
MoveIndexFile.move();
});
program
.command("preview")
.description("Preview your generated Aura Log. Requires initial build first.")
.action(async () => {
const server = await preview(auralogViteConfig);
server.printUrls();
server.bindCLIShortcuts({print: true});
});
program
.command("dev")
.alias("start")
.description("Run the Aura Log dev server.")
.action(async () => {
const server = await createServer(auralogViteConfig);
await server.listen();
server.printUrls();
server.bindCLIShortcuts({print: true});
});
program.parse();