Socket
Socket
Sign inDemoInstall

bump-cli

Package Overview
Dependencies
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bump-cli - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1

4

lib/api/index.d.ts
import * as Config from '@oclif/config';
import { AxiosInstance, AxiosResponse } from 'axios';
import { PingResponse, PreviewRequest, PreviewResponse, VersionRequest, VersionResponse } from './models';
import { PingResponse, PreviewRequest, PreviewResponse, VersionRequest, VersionResponse, WithDiff } from './models';
import APIError from './error';

@@ -10,3 +10,3 @@ declare class BumpApi {

getPing: () => Promise<AxiosResponse<PingResponse>>;
getVersion: (versionId: string, token: string) => Promise<AxiosResponse<VersionResponse>>;
getVersion: (versionId: string, token: string) => Promise<AxiosResponse<VersionResponse & WithDiff>>;
postPreview: (body?: PreviewRequest | undefined) => Promise<AxiosResponse<PreviewResponse>>;

@@ -13,0 +13,0 @@ putPreview: (versionId: string, body?: PreviewRequest | undefined) => Promise<AxiosResponse<PreviewResponse>>;

@@ -36,5 +36,17 @@ export interface PingResponse {

doc_public_url?: string;
}
export interface WithDiff {
diff_public_url?: string;
diff_summary?: string;
diff_markdown?: string;
diff_details?: DiffItem[];
diff_breaking?: boolean;
}
export interface DiffItem {
id: string;
name: string;
status: string;
type: string;
breaking: boolean;
children: DiffItem[];
}
import Command from '../command';
import * as flags from '../flags';
import { VersionResponse } from '../api/models';
import { WithDiff } from '../api/models';
export default class Diff extends Command {

@@ -13,2 +13,3 @@ static description: string;

open: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
format: flags.IOptionFlag<string | undefined>;
};

@@ -19,4 +20,4 @@ static args: {

}[];
run(): Promise<VersionResponse | void>;
displayCompareResult(version: VersionResponse, open: boolean): Promise<void>;
run(): Promise<void>;
displayCompareResult(result: WithDiff, format: string, open: boolean): Promise<void>;
}

@@ -20,12 +20,17 @@ "use strict";

const [documentation, hub, token] = [flags.doc, flags.hub, flags.token];
if (args.FILE2) {
cli_1.cli.action.start("* Let's compare the two given definition files");
if (flags.format == 'text') {
if (args.FILE2) {
cli_1.cli.action.start('* Comparing the two given definition files');
}
else {
cli_1.cli.action.start('* Comparing the given definition file with the currently deployed one');
}
}
else {
cli_1.cli.action.start("* Let's compare the given definition file with the currently deployed one");
}
const version = await new diff_1.Diff(this.config).run(args.FILE, args.FILE2, documentation, hub, token);
const diff = await new diff_1.Diff(this.config).run(args.FILE, args.FILE2, documentation, hub, token);
cli_1.cli.action.stop();
if (version) {
await this.displayCompareResult(version, flags.open);
if (diff) {
/* Flags format has a default value, so it's always defined. But
* oclif types can"t detect it */
/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
await this.displayCompareResult(diff, flags.format, flags.open);
}

@@ -37,12 +42,18 @@ else {

}
async displayCompareResult(version, open) {
if (version && version.diff_summary) {
await cli_1.cli.log(version.diff_summary);
if (open && version.diff_public_url) {
await cli_1.cli.open(version.diff_public_url);
}
async displayCompareResult(result, format, open) {
if (format == 'text' && result.diff_summary) {
await cli_1.cli.log(result.diff_summary);
}
else if (format == 'markdown' && result.diff_markdown) {
await cli_1.cli.log(result.diff_markdown);
}
else if (format == 'json' && result.diff_details) {
await cli_1.cli.log(JSON.stringify(result.diff_details, null, 2));
}
else {
await cli_1.cli.log('No structural changes detected.');
}
if (open && result.diff_public_url) {
await cli_1.cli.open(result.diff_public_url);
}
}

@@ -56,3 +67,3 @@ }

$ bump diff FILE --doc <your_doc_id_or_slug> --token <your_doc_token>
* Let's compare the given definition file with the currently deployed one... done
* Comparing the given definition file with the currently deployed one... done
Removed: GET /compare

@@ -64,3 +75,3 @@ Added: GET /versions/{versionId}

$ bump diff FILE --doc <doc_slug> --token <doc_token> > /tmp/my-saved-diff
* Let's compare the given definition file with the currently deployed one... done
* Comparing the given definition file with the currently deployed one... done

@@ -74,3 +85,3 @@ $ cat /tmp/my-saved-diff

$ bump diff FILE --doc <doc_slug> --token <your_doc_token>
* Let's compare the given definition file with the currently deployed one... done
* Comparing the given definition file with the currently deployed one... done
› Warning: Your documentation has not changed

@@ -81,3 +92,3 @@ `,

$ bump diff FILE FILE2 --doc <doc_slug> --token <your_doc_token>
* Let's compare the two given definition files... done
* Comparing the two given definition files... done
Updated: POST /versions

@@ -93,3 +104,4 @@ Body attribute added: previous_version_id

open: flags.open({ description: 'Open the visual diff in your browser' }),
format: flags.format(),
};
Diff.args = [args_1.fileArg, args_1.otherFileArg];
import * as Config from '@oclif/config';
import { BumpApi } from '../api';
import { VersionResponse } from '../api/models';
import { VersionResponse, WithDiff } from '../api/models';
export declare class Diff {

@@ -8,9 +8,9 @@ _bump: BumpApi;

constructor(config: Config.IConfig);
run(file1: string, file2: string | undefined, documentation: string, hub: string | undefined, token: string): Promise<VersionResponse | undefined>;
run(file1: string, file2: string | undefined, documentation: string, hub: string | undefined, token: string): Promise<WithDiff | undefined>;
get bumpClient(): BumpApi;
get pollingPeriod(): number;
createVersion(file: string, documentation: string, token: string, hub: string | undefined, previous_version_id?: string | undefined): Promise<VersionResponse | undefined>;
waitResult(versionId: string, token: string, opts: {
waitResult(result: VersionResponse, token: string, opts: {
timeout: number;
}): Promise<VersionResponse>;
}): Promise<WithDiff>;
pollingDelay(): Promise<void>;

@@ -17,0 +17,0 @@ private delay;

@@ -23,7 +23,9 @@ "use strict";

if (diffVersion) {
diffVersion = await this.waitResult(diffVersion.id, token, {
return await this.waitResult(diffVersion, token, {
timeout: 30,
});
}
return diffVersion;
else {
return undefined;
}
}

@@ -60,4 +62,4 @@ get bumpClient() {

}
async waitResult(versionId, token, opts) {
const diffResponse = await this.bumpClient.getVersion(versionId, token);
async waitResult(result, token, opts) {
const diffResponse = await this.bumpClient.getVersion(result.id, token);
if (opts.timeout <= 0) {

@@ -68,11 +70,11 @@ throw new errors_1.CLIError('We were unable to compute your documentation diff. Sorry about that. Please try again later');

case 200:
const version = diffResponse.data;
this.d(`Received version:`);
this.d(version);
return version;
const diff = diffResponse.data;
this.d('Received diff:');
this.d(diff);
return diff;
break;
case 202:
this.d('Waiting 1 sec before next pool');
this.d('Waiting 1 sec before next poll');
await this.pollingDelay();
return await this.waitResult(versionId, token, {
return await this.waitResult(result, token, {
timeout: opts.timeout - 1,

@@ -79,0 +81,0 @@ });

@@ -12,2 +12,3 @@ import { flags } from '@oclif/command';

declare const live: (options?: {}) => Parser.flags.IBooleanFlag<boolean>;
export { doc, docName, hub, token, autoCreate, dryRun, open, live };
declare const format: flags.Definition<string>;
export { doc, docName, hub, token, autoCreate, dryRun, open, live, format };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.live = exports.open = exports.dryRun = exports.autoCreate = exports.token = exports.hub = exports.docName = exports.doc = void 0;
exports.format = exports.live = exports.open = exports.dryRun = exports.autoCreate = exports.token = exports.hub = exports.docName = exports.doc = void 0;
const tslib_1 = require("tslib");

@@ -65,1 +65,8 @@ const command_1 = require("@oclif/command");

exports.live = live;
const format = command_1.flags.build({
char: 'f',
description: 'Format in which to provide the diff result',
default: 'text',
options: ['text', 'markdown', 'json'],
});
exports.format = format;

@@ -5,3 +5,3 @@ import { run } from '@oclif/command';

import Preview from './commands/preview';
import { VersionResponse } from './api/models';
export { run, Deploy, Diff, Preview, VersionResponse };
import { VersionResponse, WithDiff } from './api/models';
export { run, Deploy, Diff, Preview, VersionResponse, WithDiff };

@@ -1,1 +0,1 @@

{"version":"2.3.0","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 * Let's compare 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 * Let's compare 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 * Let's compare 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 * Let's compare 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}},"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}]}}}
{"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}]}}}
{
"name": "bump-cli",
"description": "The Bump CLI is used to interact with your API documentation hosted on Bump by using the API of developers.bump.sh",
"version": "2.3.0",
"version": "2.3.1",
"author": "Paul Bonaud <paulr@bump.sh>",

@@ -6,0 +6,0 @@ "bin": {

@@ -117,3 +117,3 @@ # Bump cli

$ bump diff path/to/your/file.yml --doc DOC_ID_OR_SLUG --token DOC_TOKEN
* Let's compare the given definition file with the currently deployed one... done
* Comparing the given definition file with the currently deployed one... done

@@ -128,3 +128,3 @@ Updated: POST /validations

$ bump diff path/to/your/file.yml path/to/your/next-file.yml --doc <doc_slug> --token <your_doc_token>
* Let's compare the two given definition files... done
* Comparing the two given definition files... done

@@ -131,0 +131,0 @@ Updated: POST /versions

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc