-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstackbit.ts
More file actions
110 lines (106 loc) · 3.39 KB
/
stackbit.ts
File metadata and controls
110 lines (106 loc) · 3.39 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
104
105
106
107
108
109
110
#!/usr/bin/env node
import path from 'path';
import yargs from 'yargs';
import { validate } from './validate';
import { init } from './init';
import { analyzeRepo } from './analyze-repo';
import * as telemetry from './telemetry';
import { setupUncaughtExceptionHandler } from './utils';
setupUncaughtExceptionHandler();
yargs(process.argv.slice(2))
.command(
'validate',
'validates stackbit configuration and any content against the schema defined in configuration',
(yargs) =>
yargs
.option('input-dir', {
alias: 'i',
description: 'input dir with stackbit.yaml',
default: '.'
})
.options('config-only', {
boolean: true,
description: 'validate configuration only, do not load and validate content',
default: false
})
.options('quiet', {
alias: 'q',
boolean: true,
description: 'validate with less verbosity',
default: false
}),
async (argv) => {
await validate({
inputDir: path.resolve(argv['input-dir']),
configOnly: argv['config-only'],
quiet: argv['quiet']
});
}
)
.command(
'init',
'Generates stackbit.yaml by introspecting website project files',
(yargs) =>
yargs
.option('input-dir', {
alias: 'i',
description: 'project dir',
default: '.'
})
.option('dry-run', {
description: 'print configuration instead of writing it to stackbit.yaml',
boolean: true,
default: false
}),
async (argv) => {
await init({
inputDir: path.resolve(argv['input-dir']),
dryRun: argv['dry-run']
});
}
)
.command(
'analyze-repo',
'Analyze GitHub repository for SSG and CMS, use to debug repositories imported via stackbit.com/import',
(yargs) =>
yargs
.option('repo-url', {
alias: 'u',
description: 'repository URL',
demandOption: true,
string: true
})
.option('branch', {
alias: 'b',
description: 'repository branch',
string: true,
default: 'main'
})
.option('auth', {
alias: 'a',
description: 'authentication token',
string: true
}),
async (argv) => {
await analyzeRepo({
repoUrl: argv['repo-url'],
branch: argv['branch'],
auth: argv['auth']
});
}
)
.command({
command: 'telemetry-enable',
describe: 'Enable telemetry',
handler: () => {
telemetry.enable();
}
})
.command({
command: 'telemetry-disable',
describe: 'Disable telemetry',
handler: () => {
telemetry.disable();
}
})
.demandCommand().argv;