bump-cli 2.8.4 → 2.9.1
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/README.md +12 -12
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +6 -0
- package/bin/run.js +5 -0
- package/{lib → dist}/api/error.d.ts +6 -9
- package/dist/api/error.js +97 -0
- package/{lib → dist}/api/index.d.ts +13 -13
- package/dist/api/index.js +46 -0
- package/dist/api/models.js +1 -0
- package/{lib → dist}/api/vars.js +10 -14
- package/dist/args.d.ts +4 -0
- package/{lib → dist}/args.js +11 -15
- package/dist/base-command.d.ts +7 -0
- package/dist/base-command.js +18 -0
- package/dist/commands/deploy.d.ts +24 -0
- package/dist/commands/deploy.js +158 -0
- package/dist/commands/diff.d.ts +21 -0
- package/dist/commands/diff.js +110 -0
- package/dist/commands/overlay.d.ts +13 -0
- package/dist/commands/overlay.js +53 -0
- package/dist/commands/preview.d.ts +15 -0
- package/dist/commands/preview.js +83 -0
- package/{lib/core/definition_directory.d.ts → dist/core/definition-directory.d.ts} +10 -8
- package/dist/core/definition-directory.js +149 -0
- package/{lib → dist}/core/deploy.d.ts +7 -10
- package/{lib → dist}/core/deploy.js +39 -47
- package/{lib → dist}/core/diff.d.ts +12 -15
- package/{lib → dist}/core/diff.js +88 -98
- package/{lib → dist}/core/overlay.d.ts +2 -2
- package/{lib → dist}/core/overlay.js +36 -41
- package/{lib → dist}/core/utils/file.d.ts +4 -4
- package/dist/core/utils/file.js +36 -0
- package/dist/core/utils/prompts.d.ts +1 -0
- package/dist/core/utils/prompts.js +13 -0
- package/{lib → dist}/definition.d.ts +31 -30
- package/dist/definition.js +240 -0
- package/dist/flags.d.ts +48 -0
- package/dist/flags.js +120 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +15 -0
- package/oclif.manifest.json +283 -1
- package/package.json +65 -57
- package/bin/run +0 -5
- package/lib/api/error.js +0 -96
- package/lib/api/index.js +0 -64
- package/lib/api/models.js +0 -2
- package/lib/args.d.ts +0 -15
- package/lib/cli/index.d.ts +0 -31
- package/lib/cli/index.js +0 -14
- package/lib/cli/styled/success.d.ts +0 -1
- package/lib/cli/styled/success.js +0 -11
- package/lib/command.d.ts +0 -9
- package/lib/command.js +0 -31
- package/lib/commands/deploy.d.ts +0 -27
- package/lib/commands/deploy.js +0 -164
- package/lib/commands/diff.d.ts +0 -24
- package/lib/commands/diff.js +0 -119
- package/lib/commands/overlay.d.ts +0 -16
- package/lib/commands/overlay.js +0 -56
- package/lib/commands/preview.d.ts +0 -19
- package/lib/commands/preview.js +0 -83
- package/lib/core/definition_directory.js +0 -138
- package/lib/core/utils/file.js +0 -41
- package/lib/core/utils/prompts.d.ts +0 -1
- package/lib/core/utils/prompts.js +0 -21
- package/lib/definition.js +0 -218
- package/lib/flags.d.ts +0 -20
- package/lib/flags.js +0 -116
- package/lib/index.d.ts +0 -7
- package/lib/index.js +0 -14
- package/{lib → dist}/api/models.d.ts +20 -20
- package/{lib → dist}/api/vars.d.ts +3 -3
|
@@ -1,107 +1,123 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
constructor(config) {
|
|
11
|
-
this._config = config;
|
|
12
|
-
}
|
|
13
|
-
async run(file1, file2, documentation, hub, branch, token, format, expires) {
|
|
14
|
-
let diffVersion = undefined;
|
|
15
|
-
if (file2 && (!documentation || !token)) {
|
|
16
|
-
diffVersion = await this.createDiff(file1, file2, expires);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
if (!documentation || !token) {
|
|
20
|
-
throw new Error('Please login to bump (with documentation & token) when using a single file argument');
|
|
21
|
-
}
|
|
22
|
-
diffVersion = await this.createVersion(file1, documentation, token, hub, branch);
|
|
23
|
-
if (file2) {
|
|
24
|
-
diffVersion = await this.createVersion(file2, documentation, token, hub, branch, diffVersion && diffVersion.id);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (diffVersion) {
|
|
28
|
-
return await this.waitResult(diffVersion, token, {
|
|
29
|
-
timeout: Diff.TIMEOUT,
|
|
30
|
-
format,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
get bumpClient() {
|
|
38
|
-
if (!this._bump)
|
|
39
|
-
this._bump = new api_1.BumpApi(this._config);
|
|
40
|
-
return this._bump;
|
|
1
|
+
import { CLIError } from '@oclif/core/errors';
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
import { API } from '../definition.js';
|
|
4
|
+
export class Diff {
|
|
5
|
+
// 120 seconds = 2 minutes
|
|
6
|
+
static TIMEOUT = 120;
|
|
7
|
+
_bump;
|
|
8
|
+
constructor(bumpClient) {
|
|
9
|
+
this._bump = bumpClient;
|
|
41
10
|
}
|
|
42
11
|
get pollingPeriod() {
|
|
43
|
-
return 1000;
|
|
12
|
+
return process.env.BUMP_POLLING_PERIOD ? Number(process.env.BUMP_POLLING_PERIOD) : 1000;
|
|
44
13
|
}
|
|
45
14
|
async createDiff(file1, file2, expires) {
|
|
46
|
-
const api = await
|
|
15
|
+
const api = await API.load(file1);
|
|
47
16
|
const [previous_definition, previous_references] = api.extractDefinition();
|
|
48
|
-
const api2 = await
|
|
17
|
+
const api2 = await API.load(file2);
|
|
49
18
|
const [definition, references] = api2.extractDefinition();
|
|
50
19
|
const request = {
|
|
20
|
+
definition,
|
|
21
|
+
expires_at: expires,
|
|
51
22
|
previous_definition,
|
|
52
23
|
previous_references,
|
|
53
|
-
definition,
|
|
54
24
|
references,
|
|
55
|
-
expires_at: expires,
|
|
56
25
|
};
|
|
57
|
-
const response = await this.
|
|
26
|
+
const response = await this._bump.postDiff(request);
|
|
58
27
|
switch (response.status) {
|
|
59
|
-
case 201:
|
|
28
|
+
case 201: {
|
|
60
29
|
this.d(`Diff created with ID ${response.data.id}`);
|
|
61
30
|
this.d(response.data);
|
|
62
31
|
return response.data;
|
|
63
32
|
break;
|
|
64
|
-
|
|
33
|
+
}
|
|
34
|
+
case 204: {
|
|
65
35
|
break;
|
|
36
|
+
}
|
|
66
37
|
}
|
|
67
|
-
return;
|
|
68
38
|
}
|
|
69
39
|
async createVersion(file, documentation, token, hub, branch_name, previous_version_id = undefined) {
|
|
70
|
-
const api = await
|
|
40
|
+
const api = await API.load(file);
|
|
71
41
|
const [definition, references] = api.extractDefinition();
|
|
72
42
|
const request = {
|
|
43
|
+
branch_name,
|
|
44
|
+
definition,
|
|
73
45
|
documentation,
|
|
74
46
|
hub,
|
|
75
|
-
|
|
47
|
+
previous_version_id,
|
|
76
48
|
references,
|
|
77
49
|
unpublished: true,
|
|
78
|
-
previous_version_id,
|
|
79
|
-
branch_name,
|
|
80
50
|
};
|
|
81
|
-
const response = await this.
|
|
51
|
+
const response = await this._bump.postVersion(request, token);
|
|
82
52
|
switch (response.status) {
|
|
83
|
-
case 201:
|
|
53
|
+
case 201: {
|
|
84
54
|
this.d(`Unpublished version created with ID ${response.data.id}`);
|
|
85
55
|
return response.data;
|
|
86
56
|
break;
|
|
87
|
-
|
|
57
|
+
}
|
|
58
|
+
case 204: {
|
|
88
59
|
break;
|
|
60
|
+
}
|
|
89
61
|
}
|
|
90
|
-
return;
|
|
91
62
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
63
|
+
// Function signature type taken from @types/debug
|
|
64
|
+
// Debugger(formatter: any, ...args: any[]): void;
|
|
65
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
66
|
+
d(formatter, ...args) {
|
|
67
|
+
return debug(`bump-cli:core:diff`)(formatter, ...args);
|
|
68
|
+
}
|
|
69
|
+
extractDiff(versionWithDiff) {
|
|
70
|
+
// TODO: return a real diff_id in the GET /version API
|
|
71
|
+
return {
|
|
72
|
+
breaking: versionWithDiff.diff_breaking,
|
|
73
|
+
details: versionWithDiff.diff_details,
|
|
74
|
+
id: versionWithDiff.id,
|
|
75
|
+
markdown: versionWithDiff.diff_markdown,
|
|
76
|
+
public_url: versionWithDiff.diff_public_url,
|
|
77
|
+
text: versionWithDiff.diff_summary,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
isVersion(result) {
|
|
81
|
+
return result.doc_public_url !== undefined;
|
|
82
|
+
}
|
|
83
|
+
isVersionWithDiff(result) {
|
|
84
|
+
const { diff_details, diff_markdown, diff_summary } = result;
|
|
85
|
+
return (diff_summary || diff_markdown || diff_details) !== undefined;
|
|
86
|
+
}
|
|
87
|
+
async pollingDelay() {
|
|
88
|
+
await this.delay(this.pollingPeriod);
|
|
89
|
+
}
|
|
90
|
+
async run(file1, file2, documentation, hub, branch, token, format, expires) {
|
|
91
|
+
let diffVersion;
|
|
92
|
+
if (file2 && (!documentation || !token)) {
|
|
93
|
+
diffVersion = await this.createDiff(file1, file2, expires);
|
|
96
94
|
}
|
|
97
95
|
else {
|
|
98
|
-
|
|
96
|
+
if (!documentation || !token) {
|
|
97
|
+
throw new Error('Please login to bump (with documentation & token) when using a single file argument');
|
|
98
|
+
}
|
|
99
|
+
diffVersion = await this.createVersion(file1, documentation, token, hub, branch);
|
|
100
|
+
if (file2) {
|
|
101
|
+
diffVersion = await this.createVersion(file2, documentation, token, hub, branch, diffVersion && diffVersion.id);
|
|
102
|
+
}
|
|
99
103
|
}
|
|
104
|
+
if (diffVersion) {
|
|
105
|
+
return this.waitResult(diffVersion, token, {
|
|
106
|
+
format,
|
|
107
|
+
timeout: Diff.TIMEOUT,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
async waitResult(result, token, opts) {
|
|
113
|
+
const pollingResponse = await (this.isVersion(result) && token
|
|
114
|
+
? this._bump.getVersion(result.id, token)
|
|
115
|
+
: this._bump.getDiff(result.id, opts.format));
|
|
100
116
|
if (opts.timeout <= 0) {
|
|
101
|
-
throw new
|
|
117
|
+
throw new CLIError('We were unable to compute your documentation diff. Sorry about that. Please try again later. If the error persists, please contact support at https://bump.sh.');
|
|
102
118
|
}
|
|
103
119
|
switch (pollingResponse.status) {
|
|
104
|
-
case 200:
|
|
120
|
+
case 200: {
|
|
105
121
|
let diff = pollingResponse.data;
|
|
106
122
|
if (this.isVersionWithDiff(diff)) {
|
|
107
123
|
diff = this.extractDiff(diff);
|
|
@@ -110,48 +126,22 @@ class Diff {
|
|
|
110
126
|
this.d(diff);
|
|
111
127
|
return diff;
|
|
112
128
|
break;
|
|
113
|
-
|
|
129
|
+
}
|
|
130
|
+
case 202: {
|
|
114
131
|
this.d('Waiting 1 sec before next poll');
|
|
115
132
|
await this.pollingDelay();
|
|
116
|
-
return
|
|
117
|
-
timeout: opts.timeout - 1,
|
|
133
|
+
return this.waitResult(result, token, {
|
|
118
134
|
format: opts.format,
|
|
135
|
+
timeout: opts.timeout - 1,
|
|
119
136
|
});
|
|
120
137
|
break;
|
|
138
|
+
}
|
|
121
139
|
}
|
|
122
140
|
return {};
|
|
123
141
|
}
|
|
124
|
-
async pollingDelay() {
|
|
125
|
-
return await this.delay(this.pollingPeriod);
|
|
126
|
-
}
|
|
127
142
|
async delay(ms) {
|
|
128
|
-
return new Promise((resolve) =>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// Debugger(formatter: any, ...args: any[]): void;
|
|
132
|
-
/* eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any */
|
|
133
|
-
d(formatter, ...args) {
|
|
134
|
-
return (0, debug_1.default)(`bump-cli:core:diff`)(formatter, ...args);
|
|
135
|
-
}
|
|
136
|
-
isVersion(result) {
|
|
137
|
-
return result.doc_public_url !== undefined;
|
|
138
|
-
}
|
|
139
|
-
isVersionWithDiff(result) {
|
|
140
|
-
const { diff_summary, diff_markdown, diff_details } = result;
|
|
141
|
-
return (diff_summary || diff_markdown || diff_details) !== undefined;
|
|
142
|
-
}
|
|
143
|
-
extractDiff(versionWithDiff) {
|
|
144
|
-
// TODO: return a real diff_id in the GET /version API
|
|
145
|
-
return {
|
|
146
|
-
id: versionWithDiff.id,
|
|
147
|
-
public_url: versionWithDiff.diff_public_url,
|
|
148
|
-
text: versionWithDiff.diff_summary,
|
|
149
|
-
markdown: versionWithDiff.diff_markdown,
|
|
150
|
-
details: versionWithDiff.diff_details,
|
|
151
|
-
breaking: versionWithDiff.diff_breaking,
|
|
152
|
-
};
|
|
143
|
+
return new Promise((resolve) => {
|
|
144
|
+
setTimeout(resolve, ms);
|
|
145
|
+
});
|
|
153
146
|
}
|
|
154
147
|
}
|
|
155
|
-
exports.Diff = Diff;
|
|
156
|
-
// 120 seconds = 2 minutes
|
|
157
|
-
Diff.TIMEOUT = 120;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { APIDefinition, OpenAPIOverlay } from '../definition';
|
|
1
|
+
import { APIDefinition, OpenAPIOverlay } from '../definition.js';
|
|
2
2
|
export declare class Overlay {
|
|
3
|
-
run(spec: APIDefinition, overlay: OpenAPIOverlay): APIDefinition;
|
|
4
3
|
d(formatter: any, ...args: any[]): void;
|
|
4
|
+
run(spec: APIDefinition, overlay: OpenAPIOverlay): APIDefinition;
|
|
5
5
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const jsonpath_1 = (0, tslib_1.__importDefault)(require("jsonpath"));
|
|
7
|
-
const mergician_1 = (0, tslib_1.__importDefault)(require("mergician"));
|
|
8
|
-
class Overlay {
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
/* eslint-disable-next-line import/default */
|
|
3
|
+
import jsonpath from 'jsonpath';
|
|
4
|
+
import { mergician } from 'mergician';
|
|
5
|
+
export class Overlay {
|
|
9
6
|
// WIP @github.com/lornajane/openapi-overlays-js
|
|
10
7
|
//
|
|
11
8
|
// I couldn't get the upstream lib to be imported properly due to
|
|
@@ -13,31 +10,40 @@ class Overlay {
|
|
|
13
10
|
// from github.com/lornajane/openapi-overlays-js and has been
|
|
14
11
|
// adapted to make our Typescript build happy.
|
|
15
12
|
//
|
|
13
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
14
|
+
d(formatter, ...args) {
|
|
15
|
+
return debug(`bump-cli:core:overlay`)(formatter, ...args);
|
|
16
|
+
}
|
|
17
|
+
// Function signature type taken from @types/debug
|
|
18
|
+
// Debugger(formatter: any, ...args: any[]): void;
|
|
16
19
|
// If you make any changes here, PLEASE ALSO MAKE THEM UPSTREAM.
|
|
17
20
|
run(spec, overlay) {
|
|
18
21
|
// Use jsonpath.apply to do the changes
|
|
19
|
-
if (overlay.actions && overlay.actions.length
|
|
20
|
-
overlay.actions
|
|
22
|
+
if (overlay.actions && overlay.actions.length > 0)
|
|
23
|
+
for (const a of overlay.actions) {
|
|
21
24
|
const action = a;
|
|
22
25
|
if (!action.target) {
|
|
23
26
|
process.stderr.write('Action with a missing target\n');
|
|
24
|
-
|
|
27
|
+
continue;
|
|
25
28
|
}
|
|
26
29
|
const target = action.target;
|
|
27
30
|
// Is it a remove?
|
|
28
|
-
if (
|
|
31
|
+
if (Object.hasOwn(action, 'remove')) {
|
|
32
|
+
/* eslint-disable-next-line no-constant-condition */
|
|
29
33
|
while (true) {
|
|
30
|
-
const path =
|
|
31
|
-
if (path.length
|
|
34
|
+
const path = jsonpath.paths(spec, target);
|
|
35
|
+
if (path.length === 0) {
|
|
32
36
|
break;
|
|
33
37
|
}
|
|
34
|
-
const parent =
|
|
35
|
-
const thingToRemove = path[0]
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const parent = jsonpath.parent(spec, target);
|
|
39
|
+
const thingToRemove = path[0].at(-1);
|
|
40
|
+
if (thingToRemove !== undefined) {
|
|
41
|
+
if (Array.isArray(parent)) {
|
|
42
|
+
parent.splice(thingToRemove, 1);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
delete parent[thingToRemove];
|
|
46
|
+
}
|
|
41
47
|
}
|
|
42
48
|
}
|
|
43
49
|
}
|
|
@@ -45,7 +51,7 @@ class Overlay {
|
|
|
45
51
|
try {
|
|
46
52
|
// It must be an update
|
|
47
53
|
// Deep merge objects using a module (built-in spread operator is only shallow)
|
|
48
|
-
const merger = (
|
|
54
|
+
const merger = mergician({ appendArrays: true });
|
|
49
55
|
if (target === '$') {
|
|
50
56
|
// You can't actually merge an update on a root object
|
|
51
57
|
// target with the jsonpath lib, this is just us merging
|
|
@@ -53,34 +59,23 @@ class Overlay {
|
|
|
53
59
|
spec = merger(spec, action.update);
|
|
54
60
|
}
|
|
55
61
|
else {
|
|
56
|
-
|
|
62
|
+
jsonpath.apply(spec, target, (chunk) => {
|
|
57
63
|
if (typeof chunk === 'object' && typeof action.update === 'object') {
|
|
58
64
|
if (Array.isArray(chunk) && Array.isArray(action.update)) {
|
|
59
|
-
return chunk
|
|
65
|
+
return [...chunk, ...action.update];
|
|
60
66
|
}
|
|
61
|
-
|
|
62
|
-
return merger(chunk, action.update);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
return action.update;
|
|
67
|
+
return merger(chunk, action.update);
|
|
67
68
|
}
|
|
69
|
+
return action.update;
|
|
68
70
|
});
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
|
-
catch (
|
|
72
|
-
process.stderr.write(`Error applying overlay: ${
|
|
73
|
-
//return chunk
|
|
73
|
+
catch (error) {
|
|
74
|
+
process.stderr.write(`Error applying overlay: ${error.message}\n`);
|
|
75
|
+
// return chunk
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
|
-
}
|
|
78
|
+
}
|
|
77
79
|
return spec;
|
|
78
80
|
}
|
|
79
|
-
// Function signature type taken from @types/debug
|
|
80
|
-
// Debugger(formatter: any, ...args: any[]): void;
|
|
81
|
-
/* eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any */
|
|
82
|
-
d(formatter, ...args) {
|
|
83
|
-
return (0, debug_1.default)(`bump-cli:core:overlay`)(formatter, ...args);
|
|
84
|
-
}
|
|
85
81
|
}
|
|
86
|
-
exports.Overlay = Overlay;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
value: string;
|
|
3
|
-
label: string;
|
|
1
|
+
type FileDescription = {
|
|
4
2
|
filename: string;
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
5
|
};
|
|
6
6
|
export declare const isDir: (path: string) => boolean;
|
|
7
7
|
export declare class File {
|
|
8
8
|
protected static readonly supportedFormats: string[];
|
|
9
|
-
static listValidConventionFiles(path: string, regex: RegExp): FileDescription[];
|
|
10
9
|
static listInvalidConventionFiles(path: string, regex: RegExp): FileDescription[];
|
|
10
|
+
static listValidConventionFiles(path: string, regex: RegExp): FileDescription[];
|
|
11
11
|
private static listValidFormatFiles;
|
|
12
12
|
}
|
|
13
13
|
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { readdirSync, statSync } from 'node:fs';
|
|
2
|
+
import { basename, extname } from 'node:path';
|
|
3
|
+
export const isDir = (path) => {
|
|
4
|
+
try {
|
|
5
|
+
return statSync(path).isDirectory();
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export class File {
|
|
12
|
+
static supportedFormats = ['.yml', '.yaml', '.json'];
|
|
13
|
+
static listInvalidConventionFiles(path, regex) {
|
|
14
|
+
return File.listValidFormatFiles(path).filter(({ filename }) => {
|
|
15
|
+
return !regex.test(filename);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
static listValidConventionFiles(path, regex) {
|
|
19
|
+
return File.listValidFormatFiles(path).filter(({ filename }) => {
|
|
20
|
+
return regex.test(filename);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
static listValidFormatFiles(path) {
|
|
24
|
+
return readdirSync(path)
|
|
25
|
+
.filter((file) => {
|
|
26
|
+
return File.supportedFormats.includes(extname(file));
|
|
27
|
+
})
|
|
28
|
+
.map((file) => {
|
|
29
|
+
return {
|
|
30
|
+
filename: basename(file, extname(file)),
|
|
31
|
+
label: basename(file),
|
|
32
|
+
value: file,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const confirm: (message?: string) => Promise<boolean>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import { ExitError } from '@oclif/core/errors';
|
|
3
|
+
export const confirm = async (message = 'Continue?') => {
|
|
4
|
+
const prompt = await p.group({
|
|
5
|
+
shouldContinue: () => p.confirm({ message }),
|
|
6
|
+
}, {
|
|
7
|
+
onCancel() {
|
|
8
|
+
p.cancel('Cancelled.');
|
|
9
|
+
throw new ExitError(1);
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
return prompt.shouldContinue;
|
|
13
|
+
};
|
|
@@ -1,57 +1,58 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
declare type SpecSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
|
|
1
|
+
import { JSONSchema4, JSONSchema4Array, JSONSchema4Object, JSONSchema6, JSONSchema6Object, JSONSchema7 } from 'json-schema';
|
|
2
|
+
type SpecSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
|
|
4
3
|
declare class SupportedFormat {
|
|
5
|
-
static readonly openapi: Record<string, SpecSchema>;
|
|
6
4
|
static readonly asyncapi: Record<string, SpecSchema>;
|
|
5
|
+
static readonly openapi: Record<string, SpecSchema>;
|
|
7
6
|
}
|
|
8
7
|
declare class API {
|
|
9
|
-
readonly location: string;
|
|
10
|
-
readonly rawDefinition: string;
|
|
11
8
|
readonly definition: APIDefinition;
|
|
9
|
+
readonly location: string;
|
|
12
10
|
overlayedDefinition: APIDefinition | undefined;
|
|
11
|
+
readonly rawDefinition: string;
|
|
13
12
|
readonly references: APIReference[];
|
|
14
|
-
readonly version: string;
|
|
15
|
-
readonly specName: string;
|
|
16
13
|
readonly spec?: SpecSchema;
|
|
17
|
-
|
|
14
|
+
readonly specName: string;
|
|
15
|
+
readonly version: string;
|
|
16
|
+
constructor(location: string, values: SpecSchema);
|
|
17
|
+
static isAsyncAPI(definition: JSONSchema4Object | JSONSchema6Object): definition is AsyncAPI;
|
|
18
|
+
static isOpenAPI(definition: JSONSchema4Object | JSONSchema6Object): definition is OpenAPI;
|
|
19
|
+
static isOpenAPIOverlay(definition: JSONSchema4Object | JSONSchema6Object): definition is OpenAPIOverlay;
|
|
20
|
+
static load(path: string): Promise<API>;
|
|
21
|
+
applyOverlay(overlayPath: string): Promise<void>;
|
|
22
|
+
extractDefinition(outputPath?: string): [string, APIReference[]];
|
|
18
23
|
getSpec(definition: APIDefinition): SpecSchema;
|
|
19
24
|
getSpecName(definition: APIDefinition): string;
|
|
20
25
|
getVersion(definition: APIDefinition): string;
|
|
21
26
|
guessFormat(output?: string): string;
|
|
22
|
-
|
|
27
|
+
isMainRefPath(path: string): boolean;
|
|
28
|
+
resolveContent(values: SpecSchema): [string, APIDefinition];
|
|
23
29
|
resolveRelativeLocation(absPath: string): string;
|
|
24
|
-
resolveContent($refs: $RefParser.$Refs): [string, APIDefinition];
|
|
25
30
|
serializeDefinition(outputPath?: string): string;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
static isOpenAPIOverlay(definition: JSONSchema4Object | JSONSchema6Object): definition is OpenAPIOverlay;
|
|
29
|
-
extractDefinition(outputPath?: string): [string, APIReference[]];
|
|
30
|
-
applyOverlay(overlayPath: string): Promise<void>;
|
|
31
|
-
static load(path: string): Promise<API>;
|
|
31
|
+
versionWithoutPatch(): string;
|
|
32
|
+
private url;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
location: string;
|
|
34
|
+
type APIReference = {
|
|
35
35
|
content: string;
|
|
36
|
+
location: string;
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
type APIDefinition = AsyncAPI | OpenAPI | OpenAPIOverlay;
|
|
39
|
+
type InfoObject = {
|
|
40
|
+
readonly description?: string;
|
|
39
41
|
readonly title: string;
|
|
40
42
|
readonly version: string;
|
|
41
|
-
readonly description?: string;
|
|
42
43
|
};
|
|
43
|
-
|
|
44
|
+
type OpenAPI = {
|
|
45
|
+
readonly info: InfoObject;
|
|
44
46
|
readonly openapi?: string;
|
|
45
47
|
readonly swagger?: string;
|
|
48
|
+
} & JSONSchema4Object;
|
|
49
|
+
type OpenAPIOverlay = {
|
|
50
|
+
readonly actions: JSONSchema4Array;
|
|
46
51
|
readonly info: InfoObject;
|
|
47
|
-
};
|
|
48
|
-
declare type OpenAPIOverlay = JSONSchema4Object & {
|
|
49
52
|
readonly overlay: string;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
53
|
-
declare type AsyncAPI = JSONSchema4Object & {
|
|
53
|
+
} & JSONSchema4Object;
|
|
54
|
+
type AsyncAPI = {
|
|
54
55
|
readonly asyncapi: string;
|
|
55
56
|
readonly info: InfoObject;
|
|
56
|
-
};
|
|
57
|
+
} & JSONSchema4Object;
|
|
57
58
|
export { API, APIDefinition, OpenAPIOverlay, SupportedFormat };
|