-
Notifications
You must be signed in to change notification settings - Fork 4
/
flags.ts
156 lines (137 loc) · 4.37 KB
/
flags.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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import {Flags, Interfaces} from '@oclif/core'
// import * as Parser from '@oclif/parser';
// Re-export oclif flags https://oclif.io/docs/flags
// export * from '@oclif/command/lib/flags';
// Custom flags for bump-cli
const doc = Flags.custom<string>({
char: 'd',
async default(): Promise<string | undefined> {
const envDoc = process.env.BUMP_ID
if (envDoc) return envDoc
// Search doc id in .bump/config.json file?
},
description: 'Documentation public id or slug. Can be provided via BUMP_ID environment variable',
})
const docName = Flags.custom<string>({
char: 'n',
dependsOn: ['auto-create'],
description: 'Documentation name. Used with --auto-create flag.',
})
const hub = Flags.custom<string>({
char: 'b',
async default(): Promise<string | undefined> {
const envHub = process.env.BUMP_HUB_ID
if (envHub) return envHub
// Search hub id in .bump/config.json file?
},
description: 'Hub id or slug. Can be provided via BUMP_HUB_ID environment variable',
})
const filenamePattern = Flags.custom<string>({
default: '{slug}-api',
description: `Pattern to extract the documentation slug from filenames when deploying a DIRECTORY. Pattern uses only '*' and '{slug}' as special characters to extract the slug from a filename without extension. Used with --hub flag only.`,
})
const branch = Flags.custom<string>({
char: 'B',
async default(): Promise<string | undefined> {
const envBranch = process.env.BUMP_BRANCH_NAME
if (envBranch) return envBranch
},
description: 'Branch name. Can be provided via BUMP_BRANCH_NAME environment variable',
})
const token = Flags.custom<string>({
char: 't',
async default(): Promise<string | undefined> {
const envToken = process.env.BUMP_TOKEN
if (envToken) return envToken
},
description: 'Documentation or Hub token. Can be provided via BUMP_TOKEN environment variable',
required: true,
})
const autoCreate = (opts: Partial<Interfaces.BooleanFlag<boolean>> = {}) => {
return Flags.boolean({
...opts,
dependsOn: ['hub'],
description:
'Automatically create the documentation if needed (only available with a --hub flag). Documentation name can be provided with --doc-name flag. Default: false',
})
}
const interactive = (opts: Partial<Interfaces.BooleanFlag<boolean>> = {}) => {
return Flags.boolean({
...opts,
dependsOn: ['hub'],
description:
"Interactively create a configuration file to deploy a Hub (only available with a --hub flag). This will start an interactive process if you don't have a CLI configuration file. Default: false",
})
}
const dryRun = (opts: Partial<Interfaces.BooleanFlag<boolean>> = {}) => {
return Flags.boolean({
...opts,
description:
'Validate a new documentation version. Does everything a normal deploy would do except publishing the new version. Useful in automated environments such as test platforms or continuous integration. Default: false',
})
}
const open = (opts: Partial<Interfaces.BooleanFlag<boolean>> = {}) => {
return Flags.boolean({
...opts,
char: 'o',
default: false,
})
}
const failOnBreaking = (opts: Partial<Interfaces.BooleanFlag<boolean>> = {}) => {
return Flags.boolean({
...opts,
char: 'F',
async default(): Promise<boolean> {
const envCi = process.env.CI
if (envCi) {
return true
}
return false
},
description: 'Fail when diff contains a breaking change',
})
}
const live = (opts: Partial<Interfaces.BooleanFlag<boolean>> = {}) => {
return Flags.boolean({
...opts,
char: 'l',
default: false,
})
}
const format = Flags.custom<string>({
char: 'f',
default: 'text',
description: 'Format in which to provide the diff result',
options: ['text', 'markdown', 'json', 'html'],
})
const expires = Flags.custom<string>({
char: 'e',
description:
"Specify a longer expiration date for public diffs (defaults to 1 day). Use iso8601 format to provide a date, or you can use `--expires 'never'` to keep the result live indefinitely.",
})
const out = Flags.custom<string>({
char: 'o',
description: 'Output file path',
})
const overlay = Flags.custom<string>({
char: 'o',
description: 'Path or URL of an overlay file to apply before deploying',
})
export {
autoCreate,
branch,
doc,
docName,
dryRun,
expires,
failOnBreaking,
filenamePattern,
format,
hub,
interactive,
live,
open,
out,
overlay,
token,
}