-
-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathcli.ts
More file actions
103 lines (99 loc) · 2.88 KB
/
cli.ts
File metadata and controls
103 lines (99 loc) · 2.88 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import { Command } from "./deps/cliffy.ts";
import { getCurrentVersion } from "./core/utils/lume_version.ts";
const upgrade = new Command()
.description("Upgrade your Lume executable to the latest version.")
.option(
"--version <version:string>",
"The version to upgrade to.",
)
.option(
"-d, --dev",
"Install the latest development version (last Git commit).",
)
.example("lume upgrade -g", "Upgrades to the latest stable version.")
.example("lume upgrade --dev", "Upgrades to the latest development version.")
.action(async ({ dev, version }) => {
const { default: upgrade } = await import("./cli/upgrade.ts");
await upgrade(dev, version);
});
const create = new Command()
.description("Run an archetype to create more files.")
.example(
"lume new post 'Post title'",
"Create a new post file using the _archetypes/post.ts archetype.",
)
// @ts-ignore: todo: fix this
.action(async ({ config }, name, ...args) => {
const { create } = await import("./cli/create.ts");
await create(config, name, args);
});
const lume = new Command()
.name("🔥lume")
.version(() => getCurrentVersion())
.description(
"A static site generator for Deno. \nDocs: https://lume.land",
)
.example("lume", "Builds the site.")
.example("lume --serve", "Serves the site in localhost.")
.example("lume upgrade", "Upgrades Lume to the latest version.")
.example("lume run <script>", "Runs a custom script.")
.example("lume [COMMAND] --help", "Shows the help for a command.")
.option(
"--config <config:string>",
"The config file path.",
)
.option(
"--src <src:string>",
"The source directory for your site.",
{ default: "./" },
)
.option(
"--dest <dest:string>",
"The build destination.",
{ default: "_site" },
)
.option(
"--location <type:string>",
"The URL location of the site.",
{ default: "http://localhost" },
)
.option(
"-s, --serve",
"Start a live-reloading web server and watch changes.",
)
.option(
"--no-cms",
"Don't start LumeCMS if _cms.ts file is detected.",
{ depends: ["serve"] },
)
.option(
"-p, --port <port:number>",
"The port where the server runs.",
{ default: 3000, depends: ["serve"] },
)
.option(
"--hostname <hostname>",
"The hostname where the server runs.",
{ default: "localhost", depends: ["serve"] },
)
.option(
"-o, --open",
"Open the site in a browser.",
{ depends: ["serve"] },
)
.option(
"-w, --watch",
"Build and watch changes.",
)
.action(async ({ config, serve, watch, cms }) => {
const { build } = await import("./cli/build.ts");
build(config, serve, watch, cms);
})
.command("new <archetype> [arguments...]", create)
.command("upgrade", upgrade);
try {
await lume.parse(Deno.args);
} catch (error) {
console.error(Deno.inspect(error, { colors: true }));
Deno.exit(1);
}