bump-cli 2.3.0 → 2.3.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 +2 -2
- package/lib/api/index.d.ts +2 -2
- package/lib/api/models.d.ts +12 -0
- package/lib/commands/diff.d.ts +4 -3
- package/lib/commands/diff.js +30 -18
- package/lib/core/diff.d.ts +4 -4
- package/lib/core/diff.js +12 -10
- package/lib/flags.d.ts +2 -1
- package/lib/flags.js +8 -1
- package/lib/index.d.ts +2 -2
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,7 +114,7 @@ From a Bump documentation, the `diff` command will retrieve a comparaison change
|
|
|
114
114
|
|
|
115
115
|
```sh-session
|
|
116
116
|
$ bump diff path/to/your/file.yml --doc DOC_ID_OR_SLUG --token DOC_TOKEN
|
|
117
|
-
*
|
|
117
|
+
* Comparing the given definition file with the currently deployed one... done
|
|
118
118
|
|
|
119
119
|
Updated: POST /validations
|
|
120
120
|
Body attribute modified: documentation
|
|
@@ -124,7 +124,7 @@ If you want to compare two unpublished versions of your definition file, the `di
|
|
|
124
124
|
|
|
125
125
|
```sh-session
|
|
126
126
|
$ bump diff path/to/your/file.yml path/to/your/next-file.yml --doc <doc_slug> --token <your_doc_token>
|
|
127
|
-
*
|
|
127
|
+
* Comparing the two given definition files... done
|
|
128
128
|
|
|
129
129
|
Updated: POST /versions
|
|
130
130
|
Body attribute added: previous_version_id
|
package/lib/api/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as Config from '@oclif/config';
|
|
2
2
|
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
3
|
-
import { PingResponse, PreviewRequest, PreviewResponse, VersionRequest, VersionResponse } from './models';
|
|
3
|
+
import { PingResponse, PreviewRequest, PreviewResponse, VersionRequest, VersionResponse, WithDiff } from './models';
|
|
4
4
|
import APIError from './error';
|
|
5
5
|
declare class BumpApi {
|
|
6
6
|
protected config: Config.IConfig;
|
|
7
7
|
protected readonly client: AxiosInstance;
|
|
8
8
|
constructor(config: Config.IConfig);
|
|
9
9
|
getPing: () => Promise<AxiosResponse<PingResponse>>;
|
|
10
|
-
getVersion: (versionId: string, token: string) => Promise<AxiosResponse<VersionResponse>>;
|
|
10
|
+
getVersion: (versionId: string, token: string) => Promise<AxiosResponse<VersionResponse & WithDiff>>;
|
|
11
11
|
postPreview: (body?: PreviewRequest | undefined) => Promise<AxiosResponse<PreviewResponse>>;
|
|
12
12
|
putPreview: (versionId: string, body?: PreviewRequest | undefined) => Promise<AxiosResponse<PreviewResponse>>;
|
|
13
13
|
postVersion: (body: VersionRequest, token: string) => Promise<AxiosResponse<VersionResponse>>;
|
package/lib/api/models.d.ts
CHANGED
|
@@ -33,7 +33,19 @@ export interface VersionRequest {
|
|
|
33
33
|
export interface VersionResponse {
|
|
34
34
|
id: string;
|
|
35
35
|
doc_public_url?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface WithDiff {
|
|
36
38
|
diff_public_url?: string;
|
|
37
39
|
diff_summary?: string;
|
|
40
|
+
diff_markdown?: string;
|
|
41
|
+
diff_details?: DiffItem[];
|
|
38
42
|
diff_breaking?: boolean;
|
|
39
43
|
}
|
|
44
|
+
export interface DiffItem {
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
status: string;
|
|
48
|
+
type: string;
|
|
49
|
+
breaking: boolean;
|
|
50
|
+
children: DiffItem[];
|
|
51
|
+
}
|
package/lib/commands/diff.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Command from '../command';
|
|
2
2
|
import * as flags from '../flags';
|
|
3
|
-
import {
|
|
3
|
+
import { WithDiff } from '../api/models';
|
|
4
4
|
export default class Diff extends Command {
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -10,11 +10,12 @@ export default class Diff extends Command {
|
|
|
10
10
|
hub: flags.IOptionFlag<string | undefined>;
|
|
11
11
|
token: flags.IOptionFlag<string | undefined>;
|
|
12
12
|
open: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
13
|
+
format: flags.IOptionFlag<string | undefined>;
|
|
13
14
|
};
|
|
14
15
|
static args: {
|
|
15
16
|
name: string;
|
|
16
17
|
description: string;
|
|
17
18
|
}[];
|
|
18
|
-
run(): Promise<
|
|
19
|
-
displayCompareResult(
|
|
19
|
+
run(): Promise<void>;
|
|
20
|
+
displayCompareResult(result: WithDiff, format: string, open: boolean): Promise<void>;
|
|
20
21
|
}
|
package/lib/commands/diff.js
CHANGED
|
@@ -17,32 +17,43 @@ class Diff extends command_1.default {
|
|
|
17
17
|
const { args, flags } = this.parse(Diff);
|
|
18
18
|
/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
|
|
19
19
|
const [documentation, hub, token] = [flags.doc, flags.hub, flags.token];
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
if (flags.format == 'text') {
|
|
21
|
+
if (args.FILE2) {
|
|
22
|
+
cli_1.cli.action.start('* Comparing the two given definition files');
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
cli_1.cli.action.start('* Comparing the given definition file with the currently deployed one');
|
|
26
|
+
}
|
|
25
27
|
}
|
|
26
|
-
const
|
|
28
|
+
const diff = await new diff_1.Diff(this.config).run(args.FILE, args.FILE2, documentation, hub, token);
|
|
27
29
|
cli_1.cli.action.stop();
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
+
if (diff) {
|
|
31
|
+
/* Flags format has a default value, so it's always defined. But
|
|
32
|
+
* oclif types can"t detect it */
|
|
33
|
+
/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
|
|
34
|
+
await this.displayCompareResult(diff, flags.format, flags.open);
|
|
30
35
|
}
|
|
31
36
|
else {
|
|
32
37
|
await cli_1.cli.log('No changes detected.');
|
|
33
38
|
}
|
|
34
39
|
return;
|
|
35
40
|
}
|
|
36
|
-
async displayCompareResult(
|
|
37
|
-
if (
|
|
38
|
-
await cli_1.cli.log(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
async displayCompareResult(result, format, open) {
|
|
42
|
+
if (format == 'text' && result.diff_summary) {
|
|
43
|
+
await cli_1.cli.log(result.diff_summary);
|
|
44
|
+
}
|
|
45
|
+
else if (format == 'markdown' && result.diff_markdown) {
|
|
46
|
+
await cli_1.cli.log(result.diff_markdown);
|
|
47
|
+
}
|
|
48
|
+
else if (format == 'json' && result.diff_details) {
|
|
49
|
+
await cli_1.cli.log(JSON.stringify(result.diff_details, null, 2));
|
|
42
50
|
}
|
|
43
51
|
else {
|
|
44
52
|
await cli_1.cli.log('No structural changes detected.');
|
|
45
53
|
}
|
|
54
|
+
if (open && result.diff_public_url) {
|
|
55
|
+
await cli_1.cli.open(result.diff_public_url);
|
|
56
|
+
}
|
|
46
57
|
}
|
|
47
58
|
}
|
|
48
59
|
exports.default = Diff;
|
|
@@ -51,14 +62,14 @@ Diff.examples = [
|
|
|
51
62
|
`Compare a potential new version with the currently published one:
|
|
52
63
|
|
|
53
64
|
$ bump diff FILE --doc <your_doc_id_or_slug> --token <your_doc_token>
|
|
54
|
-
*
|
|
65
|
+
* Comparing the given definition file with the currently deployed one... done
|
|
55
66
|
Removed: GET /compare
|
|
56
67
|
Added: GET /versions/{versionId}
|
|
57
68
|
`,
|
|
58
69
|
`Store the diff in a dedicated file:
|
|
59
70
|
|
|
60
71
|
$ bump diff FILE --doc <doc_slug> --token <doc_token> > /tmp/my-saved-diff
|
|
61
|
-
*
|
|
72
|
+
* Comparing the given definition file with the currently deployed one... done
|
|
62
73
|
|
|
63
74
|
$ cat /tmp/my-saved-diff
|
|
64
75
|
Removed: GET /compare
|
|
@@ -67,13 +78,13 @@ Diff.examples = [
|
|
|
67
78
|
`In case of a non modified definition FILE compared to your existing documentation, no changes are output:
|
|
68
79
|
|
|
69
80
|
$ bump diff FILE --doc <doc_slug> --token <your_doc_token>
|
|
70
|
-
*
|
|
81
|
+
* Comparing the given definition file with the currently deployed one... done
|
|
71
82
|
› Warning: Your documentation has not changed
|
|
72
83
|
`,
|
|
73
84
|
`Compare two different input files or URL independently to the one published on bump.sh
|
|
74
85
|
|
|
75
86
|
$ bump diff FILE FILE2 --doc <doc_slug> --token <your_doc_token>
|
|
76
|
-
*
|
|
87
|
+
* Comparing the two given definition files... done
|
|
77
88
|
Updated: POST /versions
|
|
78
89
|
Body attribute added: previous_version_id
|
|
79
90
|
`,
|
|
@@ -84,5 +95,6 @@ Diff.flags = {
|
|
|
84
95
|
hub: flags.hub(),
|
|
85
96
|
token: flags.token(),
|
|
86
97
|
open: flags.open({ description: 'Open the visual diff in your browser' }),
|
|
98
|
+
format: flags.format(),
|
|
87
99
|
};
|
|
88
100
|
Diff.args = [args_1.fileArg, args_1.otherFileArg];
|
package/lib/core/diff.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as Config from '@oclif/config';
|
|
2
2
|
import { BumpApi } from '../api';
|
|
3
|
-
import { VersionResponse } from '../api/models';
|
|
3
|
+
import { VersionResponse, WithDiff } from '../api/models';
|
|
4
4
|
export declare class Diff {
|
|
5
5
|
_bump: BumpApi;
|
|
6
6
|
_config: Config.IConfig;
|
|
7
7
|
constructor(config: Config.IConfig);
|
|
8
|
-
run(file1: string, file2: string | undefined, documentation: string, hub: string | undefined, token: string): Promise<
|
|
8
|
+
run(file1: string, file2: string | undefined, documentation: string, hub: string | undefined, token: string): Promise<WithDiff | undefined>;
|
|
9
9
|
get bumpClient(): BumpApi;
|
|
10
10
|
get pollingPeriod(): number;
|
|
11
11
|
createVersion(file: string, documentation: string, token: string, hub: string | undefined, previous_version_id?: string | undefined): Promise<VersionResponse | undefined>;
|
|
12
|
-
waitResult(
|
|
12
|
+
waitResult(result: VersionResponse, token: string, opts: {
|
|
13
13
|
timeout: number;
|
|
14
|
-
}): Promise<
|
|
14
|
+
}): Promise<WithDiff>;
|
|
15
15
|
pollingDelay(): Promise<void>;
|
|
16
16
|
private delay;
|
|
17
17
|
d(formatter: any, ...args: any[]): void;
|
package/lib/core/diff.js
CHANGED
|
@@ -20,11 +20,13 @@ class Diff {
|
|
|
20
20
|
diffVersion = version;
|
|
21
21
|
}
|
|
22
22
|
if (diffVersion) {
|
|
23
|
-
|
|
23
|
+
return await this.waitResult(diffVersion, token, {
|
|
24
24
|
timeout: 30,
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
else {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
31
|
get bumpClient() {
|
|
30
32
|
if (!this._bump)
|
|
@@ -56,22 +58,22 @@ class Diff {
|
|
|
56
58
|
}
|
|
57
59
|
return;
|
|
58
60
|
}
|
|
59
|
-
async waitResult(
|
|
60
|
-
const diffResponse = await this.bumpClient.getVersion(
|
|
61
|
+
async waitResult(result, token, opts) {
|
|
62
|
+
const diffResponse = await this.bumpClient.getVersion(result.id, token);
|
|
61
63
|
if (opts.timeout <= 0) {
|
|
62
64
|
throw new errors_1.CLIError('We were unable to compute your documentation diff. Sorry about that. Please try again later');
|
|
63
65
|
}
|
|
64
66
|
switch (diffResponse.status) {
|
|
65
67
|
case 200:
|
|
66
|
-
const
|
|
67
|
-
this.d(
|
|
68
|
-
this.d(
|
|
69
|
-
return
|
|
68
|
+
const diff = diffResponse.data;
|
|
69
|
+
this.d('Received diff:');
|
|
70
|
+
this.d(diff);
|
|
71
|
+
return diff;
|
|
70
72
|
break;
|
|
71
73
|
case 202:
|
|
72
|
-
this.d('Waiting 1 sec before next
|
|
74
|
+
this.d('Waiting 1 sec before next poll');
|
|
73
75
|
await this.pollingDelay();
|
|
74
|
-
return await this.waitResult(
|
|
76
|
+
return await this.waitResult(result, token, {
|
|
75
77
|
timeout: opts.timeout - 1,
|
|
76
78
|
});
|
|
77
79
|
break;
|
package/lib/flags.d.ts
CHANGED
|
@@ -9,4 +9,5 @@ declare const autoCreate: (options?: {}) => Parser.flags.IBooleanFlag<boolean>;
|
|
|
9
9
|
declare const dryRun: (options?: {}) => Parser.flags.IBooleanFlag<boolean>;
|
|
10
10
|
declare const open: (options?: {}) => Parser.flags.IBooleanFlag<boolean>;
|
|
11
11
|
declare const live: (options?: {}) => Parser.flags.IBooleanFlag<boolean>;
|
|
12
|
-
|
|
12
|
+
declare const format: flags.Definition<string>;
|
|
13
|
+
export { doc, docName, hub, token, autoCreate, dryRun, open, live, format };
|
package/lib/flags.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.live = exports.open = exports.dryRun = exports.autoCreate = exports.token = exports.hub = exports.docName = exports.doc = void 0;
|
|
3
|
+
exports.format = exports.live = exports.open = exports.dryRun = exports.autoCreate = exports.token = exports.hub = exports.docName = exports.doc = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const command_1 = require("@oclif/command");
|
|
6
6
|
// Re-export oclif flags https://oclif.io/docs/flags
|
|
@@ -62,3 +62,10 @@ const live = (options = {}) => {
|
|
|
62
62
|
return command_1.flags.boolean(Object.assign({ char: 'l', default: false }, options));
|
|
63
63
|
};
|
|
64
64
|
exports.live = live;
|
|
65
|
+
const format = command_1.flags.build({
|
|
66
|
+
char: 'f',
|
|
67
|
+
description: 'Format in which to provide the diff result',
|
|
68
|
+
default: 'text',
|
|
69
|
+
options: ['text', 'markdown', 'json'],
|
|
70
|
+
});
|
|
71
|
+
exports.format = format;
|
package/lib/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import { run } from '@oclif/command';
|
|
|
2
2
|
import { Diff } from './core/diff';
|
|
3
3
|
import Deploy from './commands/deploy';
|
|
4
4
|
import Preview from './commands/preview';
|
|
5
|
-
import { VersionResponse } from './api/models';
|
|
6
|
-
export { run, Deploy, Diff, Preview, VersionResponse };
|
|
5
|
+
import { VersionResponse, WithDiff } from './api/models';
|
|
6
|
+
export { run, Deploy, Diff, Preview, VersionResponse, WithDiff };
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.3.
|
|
1
|
+
{"version":"2.3.1","commands":{"deploy":{"id":"deploy","description":"create a new version of your documentation from the given file or URL","pluginName":"bump-cli","pluginType":"core","aliases":[],"examples":["Deploy a new version of an existing documentation\n\n$ bump deploy FILE --doc <your_doc_id_or_slug> --token <your_doc_token>\n* Let's deploy a new documentation version on Bump... done\n* Your new documentation version will soon be ready\n","Deploy a new version of an existing documentation attached to a hub\n\n$ bump deploy FILE --doc <doc_slug> --hub <your_hub_id_or_slug> --token <your_doc_token>\n* Let's deploy a new documentation version on Bump... done\n* Your new documentation version will soon be ready\n","Validate a new documentation version before deploying it\n\n$ bump deploy FILE --dry-run --doc <doc_slug> --token <your_doc_token>\n* Let's validate a new documentation version on Bump... done\n* Definition is valid\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"doc":{"name":"doc","type":"option","char":"d","description":"Documentation public id or slug. Can be provided via BUMP_ID environment variable","required":true},"doc-name":{"name":"doc-name","type":"option","char":"n","description":"Documentation name. Used with --auto-create flag."},"hub":{"name":"hub","type":"option","char":"b","description":"Hub id or slug. Can be provided via BUMP_HUB_ID environment variable"},"token":{"name":"token","type":"option","char":"t","description":"Documentation or Hub token. Can be provided via BUMP_TOKEN environment variable","required":true},"auto-create":{"name":"auto-create","type":"boolean","description":"Automatically create the documentation if needed (only available with a --hub flag). Documentation name can be provided with --doc-name flag. Default: false","allowNo":false},"dry-run":{"name":"dry-run","type":"boolean","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","allowNo":false}},"args":[{"name":"FILE","description":"Path or URL to your API documentation file. OpenAPI (2.0 to 3.1.0) and AsyncAPI (2.0 to 2.2) specifications are currently supported.","required":true}]},"diff":{"id":"diff","description":"Get a comparaison diff with your documentation from the given file or URL","pluginName":"bump-cli","pluginType":"core","aliases":[],"examples":["Compare a potential new version with the currently published one:\n\n $ bump diff FILE --doc <your_doc_id_or_slug> --token <your_doc_token>\n * Comparing the given definition file with the currently deployed one... done\n Removed: GET /compare\n Added: GET /versions/{versionId}\n","Store the diff in a dedicated file:\n\n $ bump diff FILE --doc <doc_slug> --token <doc_token> > /tmp/my-saved-diff\n * Comparing the given definition file with the currently deployed one... done\n\n $ cat /tmp/my-saved-diff\n Removed: GET /compare\n Added: GET /versions/{versionId}\n","In case of a non modified definition FILE compared to your existing documentation, no changes are output:\n\n $ bump diff FILE --doc <doc_slug> --token <your_doc_token>\n * Comparing the given definition file with the currently deployed one... done\n › Warning: Your documentation has not changed\n","Compare two different input files or URL independently to the one published on bump.sh\n\n $ bump diff FILE FILE2 --doc <doc_slug> --token <your_doc_token>\n * Comparing the two given definition files... done\n Updated: POST /versions\n Body attribute added: previous_version_id\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"doc":{"name":"doc","type":"option","char":"d","description":"Documentation public id or slug. Can be provided via BUMP_ID environment variable","required":true},"hub":{"name":"hub","type":"option","char":"b","description":"Hub id or slug. Can be provided via BUMP_HUB_ID environment variable"},"token":{"name":"token","type":"option","char":"t","description":"Documentation or Hub token. Can be provided via BUMP_TOKEN environment variable","required":true},"open":{"name":"open","type":"boolean","char":"o","description":"Open the visual diff in your browser","allowNo":false},"format":{"name":"format","type":"option","char":"f","description":"Format in which to provide the diff result","options":["text","markdown","json"],"default":"text"}},"args":[{"name":"FILE","description":"Path or URL to your API documentation file. OpenAPI (2.0 to 3.1.0) and AsyncAPI (2.0 to 2.2) specifications are currently supported.","required":true},{"name":"FILE2","description":"Path or URL to a second API documentation file to compute its diff"}]},"preview":{"id":"preview","description":"create a documentation preview from the given file or URL","pluginName":"bump-cli","pluginType":"core","aliases":[],"examples":["$ bump preview FILE\n* Your preview is visible at: https://bump.sh/preview/45807371-9a32-48a7-b6e4-1cb7088b5b9b\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"live":{"name":"live","type":"boolean","char":"l","description":"Generate a preview each time you save the given file","allowNo":false},"open":{"name":"open","type":"boolean","char":"o","description":"Open the generated preview URL in your browser","allowNo":false}},"args":[{"name":"FILE","description":"Path or URL to your API documentation file. OpenAPI (2.0 to 3.1.0) and AsyncAPI (2.0 to 2.2) specifications are currently supported.","required":true}]}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bump-cli",
|
|
3
3
|
"description": "The Bump CLI is used to interact with your API documentation hosted on Bump by using the API of developers.bump.sh",
|
|
4
|
-
"version": "2.3.
|
|
4
|
+
"version": "2.3.1",
|
|
5
5
|
"author": "Paul Bonaud <paulr@bump.sh>",
|
|
6
6
|
"bin": {
|
|
7
7
|
"bump": "./bin/run"
|