@redocly/cli 1.0.0-beta.126 → 1.0.0-beta.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__tests__/utils.test.js +7 -0
- package/lib/index.js +4 -0
- package/lib/update-version-notifier.d.ts +2 -0
- package/lib/update-version-notifier.js +100 -0
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +7 -2
- package/package.json +5 -3
- package/src/__mocks__/@redocly/openapi-core.ts +0 -80
- package/src/__mocks__/documents.ts +0 -63
- package/src/__mocks__/fs.ts +0 -6
- package/src/__mocks__/perf_hooks.ts +0 -3
- package/src/__mocks__/redoc.ts +0 -2
- package/src/__mocks__/utils.ts +0 -19
- package/src/__tests__/commands/build-docs.test.ts +0 -61
- package/src/__tests__/commands/bundle.test.ts +0 -169
- package/src/__tests__/commands/join.test.ts +0 -114
- package/src/__tests__/commands/lint.test.ts +0 -166
- package/src/__tests__/commands/push-region.test.ts +0 -51
- package/src/__tests__/commands/push.test.ts +0 -364
- package/src/__tests__/fixtures/config.ts +0 -21
- package/src/__tests__/utils.test.ts +0 -441
- package/src/assert-node-version.ts +0 -8
- package/src/commands/build-docs/index.ts +0 -56
- package/src/commands/build-docs/template.hbs +0 -23
- package/src/commands/build-docs/types.ts +0 -26
- package/src/commands/build-docs/utils.ts +0 -112
- package/src/commands/bundle.ts +0 -170
- package/src/commands/join.ts +0 -810
- package/src/commands/lint.ts +0 -161
- package/src/commands/login.ts +0 -21
- package/src/commands/preview-docs/index.ts +0 -183
- package/src/commands/preview-docs/preview-server/default.hbs +0 -24
- package/src/commands/preview-docs/preview-server/hot.js +0 -42
- package/src/commands/preview-docs/preview-server/oauth2-redirect.html +0 -21
- package/src/commands/preview-docs/preview-server/preview-server.ts +0 -156
- package/src/commands/preview-docs/preview-server/server.ts +0 -91
- package/src/commands/push.ts +0 -387
- package/src/commands/split/__tests__/fixtures/samples.json +0 -61
- package/src/commands/split/__tests__/fixtures/spec.json +0 -70
- package/src/commands/split/__tests__/fixtures/webhooks.json +0 -88
- package/src/commands/split/__tests__/index.test.ts +0 -137
- package/src/commands/split/index.ts +0 -378
- package/src/commands/split/types.ts +0 -85
- package/src/commands/stats.ts +0 -117
- package/src/custom.d.ts +0 -1
- package/src/index.ts +0 -431
- package/src/js-utils.ts +0 -17
- package/src/types.ts +0 -28
- package/src/utils.ts +0 -472
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
package/src/commands/stats.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { performance } from 'perf_hooks';
|
|
2
|
-
import * as colors from 'colorette';
|
|
3
|
-
import {
|
|
4
|
-
Config,
|
|
5
|
-
StyleguideConfig,
|
|
6
|
-
normalizeTypes,
|
|
7
|
-
Oas3Types,
|
|
8
|
-
Oas2Types,
|
|
9
|
-
StatsAccumulator,
|
|
10
|
-
StatsName,
|
|
11
|
-
BaseResolver,
|
|
12
|
-
resolveDocument,
|
|
13
|
-
detectOpenAPI,
|
|
14
|
-
OasMajorVersion,
|
|
15
|
-
openAPIMajor,
|
|
16
|
-
normalizeVisitors,
|
|
17
|
-
WalkContext,
|
|
18
|
-
walkDocument,
|
|
19
|
-
Stats,
|
|
20
|
-
bundle,
|
|
21
|
-
} from '@redocly/openapi-core';
|
|
22
|
-
|
|
23
|
-
import { getFallbackApisOrExit, loadConfigAndHandleErrors } from '../utils';
|
|
24
|
-
import { printExecutionTime } from '../utils';
|
|
25
|
-
|
|
26
|
-
const statsAccumulator: StatsAccumulator = {
|
|
27
|
-
refs: { metric: '🚗 References', total: 0, color: 'red', items: new Set() },
|
|
28
|
-
externalDocs: { metric: '📦 External Documents', total: 0, color: 'magenta' },
|
|
29
|
-
schemas: { metric: '📈 Schemas', total: 0, color: 'white' },
|
|
30
|
-
parameters: { metric: '👉 Parameters', total: 0, color: 'yellow', items: new Set() },
|
|
31
|
-
links: { metric: '🔗 Links', total: 0, color: 'cyan', items: new Set() },
|
|
32
|
-
pathItems: { metric: '➡️ Path Items', total: 0, color: 'green' },
|
|
33
|
-
operations: { metric: '👷 Operations', total: 0, color: 'yellow' },
|
|
34
|
-
tags: { metric: '🔖 Tags', total: 0, color: 'white', items: new Set() },
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
function printStatsStylish(statsAccumulator: StatsAccumulator) {
|
|
38
|
-
for (const node in statsAccumulator) {
|
|
39
|
-
const { metric, total, color } = statsAccumulator[node as StatsName];
|
|
40
|
-
process.stderr.write(colors[color](`${metric}: ${total} \n`));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function printStatsJson(statsAccumulator: StatsAccumulator) {
|
|
45
|
-
const json: any = {};
|
|
46
|
-
for (const key of Object.keys(statsAccumulator)) {
|
|
47
|
-
json[key] = {
|
|
48
|
-
metric: statsAccumulator[key as StatsName].metric,
|
|
49
|
-
total: statsAccumulator[key as StatsName].total,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
process.stdout.write(JSON.stringify(json, null, 2));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function printStats(statsAccumulator: StatsAccumulator, api: string, format: string) {
|
|
56
|
-
process.stderr.write(`Document: ${colors.magenta(api)} stats:\n\n`);
|
|
57
|
-
switch (format) {
|
|
58
|
-
case 'stylish':
|
|
59
|
-
printStatsStylish(statsAccumulator);
|
|
60
|
-
break;
|
|
61
|
-
case 'json':
|
|
62
|
-
printStatsJson(statsAccumulator);
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export async function handleStats(argv: { config?: string; api?: string; format: string }) {
|
|
68
|
-
const config: Config = await loadConfigAndHandleErrors({ configPath: argv.config });
|
|
69
|
-
const [{ path }] = await getFallbackApisOrExit(argv.api ? [argv.api] : [], config);
|
|
70
|
-
const externalRefResolver = new BaseResolver(config.resolve);
|
|
71
|
-
const { bundle: document } = await bundle({ config, ref: path });
|
|
72
|
-
const lintConfig: StyleguideConfig = config.styleguide;
|
|
73
|
-
const oasVersion = detectOpenAPI(document.parsed);
|
|
74
|
-
const oasMajorVersion = openAPIMajor(oasVersion);
|
|
75
|
-
const types = normalizeTypes(
|
|
76
|
-
lintConfig.extendTypes(
|
|
77
|
-
oasMajorVersion === OasMajorVersion.Version3 ? Oas3Types : Oas2Types,
|
|
78
|
-
oasVersion
|
|
79
|
-
),
|
|
80
|
-
lintConfig
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
const startedAt = performance.now();
|
|
84
|
-
const ctx: WalkContext = {
|
|
85
|
-
problems: [],
|
|
86
|
-
oasVersion: oasVersion,
|
|
87
|
-
visitorsData: {},
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const resolvedRefMap = await resolveDocument({
|
|
91
|
-
rootDocument: document,
|
|
92
|
-
rootType: types.Root,
|
|
93
|
-
externalRefResolver,
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
const statsVisitor = normalizeVisitors(
|
|
97
|
-
[
|
|
98
|
-
{
|
|
99
|
-
severity: 'warn',
|
|
100
|
-
ruleId: 'stats',
|
|
101
|
-
visitor: Stats(statsAccumulator),
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
types
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
walkDocument({
|
|
108
|
-
document,
|
|
109
|
-
rootType: types.Root,
|
|
110
|
-
normalizedVisitors: statsVisitor,
|
|
111
|
-
resolvedRefMap,
|
|
112
|
-
ctx,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
printStats(statsAccumulator, path, argv.format);
|
|
116
|
-
printExecutionTime('stats', startedAt, path);
|
|
117
|
-
}
|
package/src/custom.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
type GenericObject = Record<string, any>;
|
package/src/index.ts
DELETED
|
@@ -1,431 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import './assert-node-version';
|
|
4
|
-
import * as yargs from 'yargs';
|
|
5
|
-
import { outputExtensions, regionChoices } from './types';
|
|
6
|
-
import { RedoclyClient, OutputFormat, RuleSeverity } from '@redocly/openapi-core';
|
|
7
|
-
import { previewDocs } from './commands/preview-docs';
|
|
8
|
-
import { handleStats } from './commands/stats';
|
|
9
|
-
import { handleSplit } from './commands/split';
|
|
10
|
-
import { handleJoin } from './commands/join';
|
|
11
|
-
import { handlePush, transformPush } from './commands/push';
|
|
12
|
-
import { handleLint } from './commands/lint';
|
|
13
|
-
import { handleBundle } from './commands/bundle';
|
|
14
|
-
import { handleLogin } from './commands/login';
|
|
15
|
-
import { handlerBuildCommand } from './commands/build-docs';
|
|
16
|
-
import type { BuildDocsArgv } from './commands/build-docs/types';
|
|
17
|
-
const version = require('../package.json').version;
|
|
18
|
-
|
|
19
|
-
yargs
|
|
20
|
-
.version('version', 'Show version number.', version)
|
|
21
|
-
.help('help', 'Show help.')
|
|
22
|
-
.command(
|
|
23
|
-
'stats [api]',
|
|
24
|
-
'Gathering statistics for a document.',
|
|
25
|
-
(yargs) =>
|
|
26
|
-
yargs.positional('api', { type: 'string' }).option({
|
|
27
|
-
config: { description: 'Specify path to the config file.', type: 'string' },
|
|
28
|
-
format: {
|
|
29
|
-
description: 'Use a specific output format.',
|
|
30
|
-
choices: ['stylish', 'json'] as ReadonlyArray<OutputFormat>,
|
|
31
|
-
default: 'stylish' as OutputFormat,
|
|
32
|
-
},
|
|
33
|
-
}),
|
|
34
|
-
(argv) => {
|
|
35
|
-
process.env.REDOCLY_CLI_COMMAND = 'stats';
|
|
36
|
-
handleStats(argv);
|
|
37
|
-
}
|
|
38
|
-
)
|
|
39
|
-
.command(
|
|
40
|
-
'split [api]',
|
|
41
|
-
'Split definition into a multi-file structure.',
|
|
42
|
-
(yargs) =>
|
|
43
|
-
yargs
|
|
44
|
-
.positional('api', {
|
|
45
|
-
description: 'API definition file that you want to split',
|
|
46
|
-
type: 'string',
|
|
47
|
-
})
|
|
48
|
-
.option({
|
|
49
|
-
outDir: {
|
|
50
|
-
description: 'Output directory where files will be saved.',
|
|
51
|
-
required: true,
|
|
52
|
-
type: 'string',
|
|
53
|
-
},
|
|
54
|
-
separator: {
|
|
55
|
-
description: 'File path separator used while splitting.',
|
|
56
|
-
required: false,
|
|
57
|
-
type: 'string',
|
|
58
|
-
default: '_',
|
|
59
|
-
},
|
|
60
|
-
})
|
|
61
|
-
.demandOption('api'),
|
|
62
|
-
(argv) => {
|
|
63
|
-
process.env.REDOCLY_CLI_COMMAND = 'split';
|
|
64
|
-
handleSplit(argv);
|
|
65
|
-
}
|
|
66
|
-
)
|
|
67
|
-
.command(
|
|
68
|
-
'join [apis...]',
|
|
69
|
-
'Join definitions [experimental].',
|
|
70
|
-
(yargs) =>
|
|
71
|
-
yargs
|
|
72
|
-
.positional('apis', {
|
|
73
|
-
array: true,
|
|
74
|
-
type: 'string',
|
|
75
|
-
demandOption: true,
|
|
76
|
-
})
|
|
77
|
-
.option({
|
|
78
|
-
lint: { description: 'Lint definitions', type: 'boolean', default: false },
|
|
79
|
-
decorate: { description: 'Run decorators', type: 'boolean', default: false },
|
|
80
|
-
preprocess: { description: 'Run preprocessors', type: 'boolean', default: false },
|
|
81
|
-
'prefix-tags-with-info-prop': {
|
|
82
|
-
description: 'Prefix tags with property value from info object.',
|
|
83
|
-
requiresArg: true,
|
|
84
|
-
type: 'string',
|
|
85
|
-
},
|
|
86
|
-
'prefix-tags-with-filename': {
|
|
87
|
-
description: 'Prefix tags with property value from file name.',
|
|
88
|
-
type: 'boolean',
|
|
89
|
-
default: false,
|
|
90
|
-
},
|
|
91
|
-
'prefix-components-with-info-prop': {
|
|
92
|
-
description: 'Prefix components with property value from info object.',
|
|
93
|
-
requiresArg: true,
|
|
94
|
-
type: 'string',
|
|
95
|
-
},
|
|
96
|
-
'without-x-tag-groups': {
|
|
97
|
-
description: 'Skip automated x-tagGroups creation',
|
|
98
|
-
type: 'boolean',
|
|
99
|
-
},
|
|
100
|
-
output: {
|
|
101
|
-
describe: 'Output file',
|
|
102
|
-
alias: 'o',
|
|
103
|
-
type: 'string',
|
|
104
|
-
default: 'openapi.yaml',
|
|
105
|
-
},
|
|
106
|
-
}),
|
|
107
|
-
(argv) => {
|
|
108
|
-
process.env.REDOCLY_CLI_COMMAND = 'join';
|
|
109
|
-
handleJoin(argv, version);
|
|
110
|
-
}
|
|
111
|
-
)
|
|
112
|
-
.command(
|
|
113
|
-
'push [maybeApiOrDestination] [maybeDestination] [maybeBranchName]',
|
|
114
|
-
'Push an API definition to the Redocly API registry.',
|
|
115
|
-
(yargs) =>
|
|
116
|
-
yargs
|
|
117
|
-
.positional('maybeApiOrDestination', { type: 'string' })
|
|
118
|
-
.positional('maybeDestination', { type: 'string' })
|
|
119
|
-
.positional('maybeBranchName', { type: 'string' })
|
|
120
|
-
.option({
|
|
121
|
-
branch: { type: 'string', alias: 'b' },
|
|
122
|
-
upsert: { type: 'boolean', alias: 'u' },
|
|
123
|
-
'batch-id': {
|
|
124
|
-
description:
|
|
125
|
-
'Specifies the ID of the CI job that the current push will be associated with.',
|
|
126
|
-
type: 'string',
|
|
127
|
-
requiresArg: true,
|
|
128
|
-
},
|
|
129
|
-
'batch-size': {
|
|
130
|
-
description: 'Specifies the total number of CI jobs planned to be pushed.',
|
|
131
|
-
type: 'number',
|
|
132
|
-
requiresArg: true,
|
|
133
|
-
},
|
|
134
|
-
region: { description: 'Specify a region.', alias: 'r', choices: regionChoices },
|
|
135
|
-
'skip-decorator': {
|
|
136
|
-
description: 'Ignore certain decorators.',
|
|
137
|
-
array: true,
|
|
138
|
-
type: 'string',
|
|
139
|
-
},
|
|
140
|
-
public: {
|
|
141
|
-
description: 'Make API registry available to the public',
|
|
142
|
-
type: 'boolean',
|
|
143
|
-
},
|
|
144
|
-
files: {
|
|
145
|
-
description: 'List of other folders and files to upload',
|
|
146
|
-
array: true,
|
|
147
|
-
type: 'string',
|
|
148
|
-
},
|
|
149
|
-
})
|
|
150
|
-
.implies('batch-id', 'batch-size')
|
|
151
|
-
.implies('batch-size', 'batch-id'),
|
|
152
|
-
(argv) => {
|
|
153
|
-
process.env.REDOCLY_CLI_COMMAND = 'push';
|
|
154
|
-
transformPush(handlePush)(argv);
|
|
155
|
-
}
|
|
156
|
-
)
|
|
157
|
-
.command(
|
|
158
|
-
'lint [apis...]',
|
|
159
|
-
'Lint definition.',
|
|
160
|
-
(yargs) =>
|
|
161
|
-
yargs.positional('apis', { array: true, type: 'string', demandOption: true }).option({
|
|
162
|
-
format: {
|
|
163
|
-
description: 'Use a specific output format.',
|
|
164
|
-
choices: [
|
|
165
|
-
'stylish',
|
|
166
|
-
'codeframe',
|
|
167
|
-
'json',
|
|
168
|
-
'checkstyle',
|
|
169
|
-
'codeclimate',
|
|
170
|
-
'summary',
|
|
171
|
-
] as ReadonlyArray<OutputFormat>,
|
|
172
|
-
default: 'codeframe' as OutputFormat,
|
|
173
|
-
},
|
|
174
|
-
'max-problems': {
|
|
175
|
-
requiresArg: true,
|
|
176
|
-
description: 'Reduce output to max N problems.',
|
|
177
|
-
type: 'number',
|
|
178
|
-
default: 100,
|
|
179
|
-
},
|
|
180
|
-
'generate-ignore-file': {
|
|
181
|
-
description: 'Generate ignore file.',
|
|
182
|
-
type: 'boolean',
|
|
183
|
-
},
|
|
184
|
-
'skip-rule': {
|
|
185
|
-
description: 'Ignore certain rules.',
|
|
186
|
-
array: true,
|
|
187
|
-
type: 'string',
|
|
188
|
-
},
|
|
189
|
-
'skip-preprocessor': {
|
|
190
|
-
description: 'Ignore certain preprocessors.',
|
|
191
|
-
array: true,
|
|
192
|
-
type: 'string',
|
|
193
|
-
},
|
|
194
|
-
'lint-config': {
|
|
195
|
-
description: 'Apply severity for linting the config file.',
|
|
196
|
-
choices: ['warn', 'error', 'off'] as ReadonlyArray<RuleSeverity>,
|
|
197
|
-
default: 'warn' as RuleSeverity,
|
|
198
|
-
},
|
|
199
|
-
config: {
|
|
200
|
-
description: 'Specify path to the config file.',
|
|
201
|
-
requiresArg: true,
|
|
202
|
-
type: 'string',
|
|
203
|
-
},
|
|
204
|
-
extends: {
|
|
205
|
-
description: 'Override extends configurations (defaults or config file settings).',
|
|
206
|
-
requiresArg: true,
|
|
207
|
-
array: true,
|
|
208
|
-
type: 'string',
|
|
209
|
-
},
|
|
210
|
-
}),
|
|
211
|
-
(argv) => {
|
|
212
|
-
process.env.REDOCLY_CLI_COMMAND = 'lint';
|
|
213
|
-
handleLint(argv, version);
|
|
214
|
-
}
|
|
215
|
-
)
|
|
216
|
-
.command(
|
|
217
|
-
'bundle [apis...]',
|
|
218
|
-
'Bundle definition.',
|
|
219
|
-
(yargs) =>
|
|
220
|
-
yargs.positional('apis', { array: true, type: 'string', demandOption: true }).options({
|
|
221
|
-
output: { type: 'string', alias: 'o' },
|
|
222
|
-
format: {
|
|
223
|
-
description: 'Use a specific output format.',
|
|
224
|
-
choices: ['stylish', 'codeframe', 'json', 'checkstyle'] as ReadonlyArray<OutputFormat>,
|
|
225
|
-
default: 'codeframe' as OutputFormat,
|
|
226
|
-
},
|
|
227
|
-
'max-problems': {
|
|
228
|
-
requiresArg: true,
|
|
229
|
-
description: 'Reduce output to max N problems.',
|
|
230
|
-
type: 'number',
|
|
231
|
-
default: 100,
|
|
232
|
-
},
|
|
233
|
-
ext: {
|
|
234
|
-
description: 'Bundle file extension.',
|
|
235
|
-
requiresArg: true,
|
|
236
|
-
choices: outputExtensions,
|
|
237
|
-
},
|
|
238
|
-
'skip-rule': {
|
|
239
|
-
description: 'Ignore certain rules.',
|
|
240
|
-
array: true,
|
|
241
|
-
type: 'string',
|
|
242
|
-
},
|
|
243
|
-
'skip-preprocessor': {
|
|
244
|
-
description: 'Ignore certain preprocessors.',
|
|
245
|
-
array: true,
|
|
246
|
-
type: 'string',
|
|
247
|
-
},
|
|
248
|
-
'skip-decorator': {
|
|
249
|
-
description: 'Ignore certain decorators.',
|
|
250
|
-
array: true,
|
|
251
|
-
type: 'string',
|
|
252
|
-
},
|
|
253
|
-
dereferenced: {
|
|
254
|
-
alias: 'd',
|
|
255
|
-
type: 'boolean',
|
|
256
|
-
description: 'Produce fully dereferenced bundle.',
|
|
257
|
-
},
|
|
258
|
-
force: {
|
|
259
|
-
alias: 'f',
|
|
260
|
-
type: 'boolean',
|
|
261
|
-
description: 'Produce bundle output even when errors occur.',
|
|
262
|
-
},
|
|
263
|
-
config: {
|
|
264
|
-
description: 'Specify path to the config file.',
|
|
265
|
-
type: 'string',
|
|
266
|
-
},
|
|
267
|
-
lint: {
|
|
268
|
-
description: 'Lint definitions',
|
|
269
|
-
type: 'boolean',
|
|
270
|
-
default: false,
|
|
271
|
-
},
|
|
272
|
-
metafile: {
|
|
273
|
-
description: 'Produce metadata about the bundle',
|
|
274
|
-
type: 'string',
|
|
275
|
-
},
|
|
276
|
-
extends: {
|
|
277
|
-
description: 'Override extends configurations (defaults or config file settings).',
|
|
278
|
-
requiresArg: true,
|
|
279
|
-
array: true,
|
|
280
|
-
type: 'string',
|
|
281
|
-
},
|
|
282
|
-
'remove-unused-components': {
|
|
283
|
-
description: 'Remove unused components.',
|
|
284
|
-
type: 'boolean',
|
|
285
|
-
default: false,
|
|
286
|
-
},
|
|
287
|
-
'keep-url-references': {
|
|
288
|
-
description: 'Keep absolute url references.',
|
|
289
|
-
type: 'boolean',
|
|
290
|
-
alias: 'k',
|
|
291
|
-
},
|
|
292
|
-
}),
|
|
293
|
-
(argv) => {
|
|
294
|
-
process.env.REDOCLY_CLI_COMMAND = 'bundle';
|
|
295
|
-
handleBundle(argv, version);
|
|
296
|
-
}
|
|
297
|
-
)
|
|
298
|
-
.command(
|
|
299
|
-
'login',
|
|
300
|
-
'Login to the Redocly API registry with an access token.',
|
|
301
|
-
async (yargs) =>
|
|
302
|
-
yargs.options({
|
|
303
|
-
verbose: {
|
|
304
|
-
description: 'Include additional output.',
|
|
305
|
-
type: 'boolean',
|
|
306
|
-
},
|
|
307
|
-
region: {
|
|
308
|
-
description: 'Specify a region.',
|
|
309
|
-
alias: 'r',
|
|
310
|
-
choices: regionChoices,
|
|
311
|
-
},
|
|
312
|
-
}),
|
|
313
|
-
(argv) => {
|
|
314
|
-
process.env.REDOCLY_CLI_COMMAND = 'login';
|
|
315
|
-
handleLogin(argv);
|
|
316
|
-
}
|
|
317
|
-
)
|
|
318
|
-
.command(
|
|
319
|
-
'logout',
|
|
320
|
-
'Clear your stored credentials for the Redocly API registry.',
|
|
321
|
-
(yargs) => yargs,
|
|
322
|
-
async () => {
|
|
323
|
-
process.env.REDOCLY_CLI_COMMAND = 'logout';
|
|
324
|
-
const client = new RedoclyClient();
|
|
325
|
-
client.logout();
|
|
326
|
-
process.stdout.write('Logged out from the Redocly account. ✋\n');
|
|
327
|
-
}
|
|
328
|
-
)
|
|
329
|
-
.command(
|
|
330
|
-
'preview-docs [api]',
|
|
331
|
-
'Preview API reference docs for the specified definition.',
|
|
332
|
-
(yargs) =>
|
|
333
|
-
yargs.positional('api', { type: 'string' }).options({
|
|
334
|
-
port: {
|
|
335
|
-
alias: 'p',
|
|
336
|
-
type: 'number',
|
|
337
|
-
default: 8080,
|
|
338
|
-
description: 'Preview port.',
|
|
339
|
-
},
|
|
340
|
-
host: {
|
|
341
|
-
alias: 'h',
|
|
342
|
-
type: 'string',
|
|
343
|
-
default: '127.0.0.1',
|
|
344
|
-
description: 'Preview host.',
|
|
345
|
-
},
|
|
346
|
-
'skip-preprocessor': {
|
|
347
|
-
description: 'Ignore certain preprocessors.',
|
|
348
|
-
array: true,
|
|
349
|
-
type: 'string',
|
|
350
|
-
},
|
|
351
|
-
'skip-decorator': {
|
|
352
|
-
description: 'Ignore certain decorators.',
|
|
353
|
-
array: true,
|
|
354
|
-
type: 'string',
|
|
355
|
-
},
|
|
356
|
-
'use-community-edition': {
|
|
357
|
-
description: 'Force using Redoc CE for docs preview.',
|
|
358
|
-
type: 'boolean',
|
|
359
|
-
},
|
|
360
|
-
force: {
|
|
361
|
-
alias: 'f',
|
|
362
|
-
type: 'boolean',
|
|
363
|
-
description: 'Produce bundle output even when errors occur.',
|
|
364
|
-
},
|
|
365
|
-
config: {
|
|
366
|
-
description: 'Specify path to the config file.',
|
|
367
|
-
type: 'string',
|
|
368
|
-
},
|
|
369
|
-
}),
|
|
370
|
-
(argv) => {
|
|
371
|
-
process.env.REDOCLY_CLI_COMMAND = 'preview-docs';
|
|
372
|
-
previewDocs(argv);
|
|
373
|
-
}
|
|
374
|
-
)
|
|
375
|
-
.command(
|
|
376
|
-
'build-docs [api]',
|
|
377
|
-
'build definition into zero-dependency HTML-file',
|
|
378
|
-
(yargs) =>
|
|
379
|
-
yargs
|
|
380
|
-
.positional('api', { type: 'string' })
|
|
381
|
-
.options({
|
|
382
|
-
o: {
|
|
383
|
-
describe: 'Output file',
|
|
384
|
-
alias: 'output',
|
|
385
|
-
type: 'string',
|
|
386
|
-
default: 'redoc-static.html',
|
|
387
|
-
},
|
|
388
|
-
title: {
|
|
389
|
-
describe: 'Page Title',
|
|
390
|
-
type: 'string',
|
|
391
|
-
},
|
|
392
|
-
disableGoogleFont: {
|
|
393
|
-
describe: 'Disable Google Font',
|
|
394
|
-
type: 'boolean',
|
|
395
|
-
default: false,
|
|
396
|
-
},
|
|
397
|
-
cdn: {
|
|
398
|
-
describe: 'Do not include Redoc source code into html page, use link to CDN instead',
|
|
399
|
-
type: 'boolean',
|
|
400
|
-
default: false,
|
|
401
|
-
},
|
|
402
|
-
t: {
|
|
403
|
-
alias: 'template',
|
|
404
|
-
describe: 'Path to handlebars page template, see https://git.io/vh8fP for the example',
|
|
405
|
-
type: 'string',
|
|
406
|
-
},
|
|
407
|
-
templateOptions: {
|
|
408
|
-
describe:
|
|
409
|
-
'Additional options that you want pass to template. Use dot notation, e.g. templateOptions.metaDescription',
|
|
410
|
-
},
|
|
411
|
-
theme: {
|
|
412
|
-
describe: 'Redoc theme.openapi, use dot notation, e.g. theme.openapi.nativeScrollbars',
|
|
413
|
-
},
|
|
414
|
-
config: {
|
|
415
|
-
describe: 'Specify path to the config file.',
|
|
416
|
-
type: 'string',
|
|
417
|
-
},
|
|
418
|
-
})
|
|
419
|
-
.check((argv: any) => {
|
|
420
|
-
if (argv.theme && !argv.theme?.openapi)
|
|
421
|
-
throw Error('Invalid option: theme.openapi not set');
|
|
422
|
-
return true;
|
|
423
|
-
}),
|
|
424
|
-
async (argv) => {
|
|
425
|
-
process.env.REDOCLY_CLI_COMMAND = 'build-docs';
|
|
426
|
-
handlerBuildCommand(argv as unknown as BuildDocsArgv);
|
|
427
|
-
}
|
|
428
|
-
)
|
|
429
|
-
.completion('completion', 'Generate completion script.')
|
|
430
|
-
.demandCommand(1)
|
|
431
|
-
.strict().argv;
|
package/src/js-utils.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export function isObject(obj: any) {
|
|
2
|
-
const type = typeof obj;
|
|
3
|
-
return type === 'function' || (type === 'object' && !!obj);
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export function isEmptyObject(obj: any) {
|
|
7
|
-
return !!obj && Object.keys(obj).length === 0;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function isString(str: string) {
|
|
11
|
-
return Object.prototype.toString.call(str) === '[object String]';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function keysOf<T>(obj: T) {
|
|
15
|
-
if (!obj) return [];
|
|
16
|
-
return Object.keys(obj) as (keyof T)[];
|
|
17
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { BundleOutputFormat, OutputFormat, Region, Config } from '@redocly/openapi-core';
|
|
2
|
-
|
|
3
|
-
export type Totals = {
|
|
4
|
-
errors: number;
|
|
5
|
-
warnings: number;
|
|
6
|
-
ignored: number;
|
|
7
|
-
};
|
|
8
|
-
export type Entrypoint = {
|
|
9
|
-
path: string;
|
|
10
|
-
alias?: string;
|
|
11
|
-
};
|
|
12
|
-
export const outputExtensions = ['json', 'yaml', 'yml'] as ReadonlyArray<BundleOutputFormat>;
|
|
13
|
-
export type OutputExtensions = 'json' | 'yaml' | 'yml' | undefined;
|
|
14
|
-
export const regionChoices = ['us', 'eu'] as ReadonlyArray<Region>;
|
|
15
|
-
export type CommonOptions = {
|
|
16
|
-
apis: string[];
|
|
17
|
-
'max-problems'?: number;
|
|
18
|
-
extends?: string[];
|
|
19
|
-
config?: string;
|
|
20
|
-
format: OutputFormat;
|
|
21
|
-
};
|
|
22
|
-
export type Skips = {
|
|
23
|
-
'skip-rule'?: string[];
|
|
24
|
-
'skip-decorator'?: string[];
|
|
25
|
-
'skip-preprocessor'?: string[];
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type ConfigApis = Pick<Config, 'apis' | 'configFile'>;
|