-
Notifications
You must be signed in to change notification settings - Fork 1
/
mod.ts
66 lines (58 loc) · 1.78 KB
/
mod.ts
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
import { parseArgs } from "./deps.ts";
import { Init, type InitConfig } from "./init.ts";
import cms from "./steps/cms.ts";
import start from "./steps/start.ts";
import themes from "./steps/themes.ts";
import save from "./steps/save.ts";
import plugins from "./steps/plugins.ts";
import success from "./steps/success.ts";
import git from "./steps/git.ts";
export default function init(initConfig: InitConfig) {
const init = new Init(initConfig);
init.use(start());
init.use(themes());
init.use(plugins());
init.use(git());
init.use(cms());
init.use(save(), 10);
init.use(success(), 100);
return init;
}
export function run(args: string[] = Deno.args) {
const parsed = parseArgs(args, {
string: ["src", "theme", "plugins", "version"],
boolean: ["dev", "help", "no-cms", "cms", "javascript"],
alias: { dev: "d", help: "h", version: "v" },
});
if (parsed.help) {
console.log(`
Usage:
init.ts [path] [options]
Options:
-h, --help Show this help
-d, --dev Use the development version
-v, --version The version of Lume to install
--src The source directory
--theme The theme to install
--plugins The plugins to install
--cms To install the CMS (use --no-cms to disable)
--javascript Use JavaScript (_config.js) instead of TypeScript (_config.ts)
`);
Deno.exit();
}
const path = parsed._[0] || ".";
const process = init({
path: String(path),
src: parsed.src,
version: parsed.version,
theme: parsed.theme,
dev: parsed.dev,
cms: parsed.cms || (parsed["no-cms"] ? false : undefined),
plugins: parsed.plugins ? parsed.plugins.split(",") : undefined,
javascript: parsed.javascript,
});
process.run();
}
if (import.meta.main) {
run();
}