-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.ts
executable file
·61 lines (59 loc) · 1.3 KB
/
cli.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
#!/usr/bin/env node
import * as sealpage from './index';
import path from 'path';
import { Argv } from 'yargs';
require('yargs')
.command(
'build [sitemap_path] [output_dir]',
'start builder',
(yargs: Argv) => {
return yargs
.positional('sitemap_path', {
describe: 'The path to sitemap config',
type: 'string',
default: 'index.js',
})
.positional('output_dir', {
describe: 'The directory to output',
type: 'string',
default: 'public',
});
},
async (argv: any) => {
await sealpage.build(
path.resolve(process.env.PWD as string, argv.sitemap_path),
path.resolve(process.env.PWD as string, argv.output_dir)
);
process.exit(0);
}
)
.command(
'admin [sitemap_path]',
'starts admin panel',
(yargs: Argv) => {
return yargs
.positional('sitemap_path', {
describe: 'The path to sitemap config',
type: 'string',
required: true,
default: 'index.js',
})
.positional('debug', {
describe: 'Enables detailed output about compilation',
type: 'boolean',
default: 'false',
});
},
async (argv: any) => {
await sealpage.runAdmin(
path.resolve(
process.env.PWD as string,
argv.sitemap_path as string
),
argv.debug
);
}
)
.demandCommand()
.help()
.wrap(80).argv;