bump-cli 2.8.2 → 2.9.0-0

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.
Files changed (72) hide show
  1. package/README.md +12 -12
  2. package/bin/dev.cmd +3 -0
  3. package/bin/dev.js +6 -0
  4. package/bin/run.js +5 -0
  5. package/{lib → dist}/api/error.d.ts +6 -9
  6. package/dist/api/error.js +97 -0
  7. package/{lib → dist}/api/index.d.ts +13 -13
  8. package/dist/api/index.js +46 -0
  9. package/dist/api/models.js +1 -0
  10. package/{lib → dist}/api/vars.js +10 -14
  11. package/dist/args.d.ts +4 -0
  12. package/{lib → dist}/args.js +11 -15
  13. package/dist/base-command.d.ts +7 -0
  14. package/dist/base-command.js +18 -0
  15. package/dist/commands/deploy.d.ts +24 -0
  16. package/dist/commands/deploy.js +158 -0
  17. package/dist/commands/diff.d.ts +21 -0
  18. package/dist/commands/diff.js +110 -0
  19. package/dist/commands/overlay.d.ts +13 -0
  20. package/dist/commands/overlay.js +53 -0
  21. package/dist/commands/preview.d.ts +15 -0
  22. package/dist/commands/preview.js +83 -0
  23. package/{lib/core/definition_directory.d.ts → dist/core/definition-directory.d.ts} +10 -8
  24. package/dist/core/definition-directory.js +149 -0
  25. package/{lib → dist}/core/deploy.d.ts +7 -10
  26. package/{lib → dist}/core/deploy.js +39 -47
  27. package/{lib → dist}/core/diff.d.ts +12 -15
  28. package/{lib → dist}/core/diff.js +88 -97
  29. package/{lib → dist}/core/overlay.d.ts +2 -2
  30. package/{lib → dist}/core/overlay.js +36 -41
  31. package/{lib → dist}/core/utils/file.d.ts +4 -4
  32. package/dist/core/utils/file.js +36 -0
  33. package/dist/core/utils/prompts.d.ts +1 -0
  34. package/dist/core/utils/prompts.js +13 -0
  35. package/{lib → dist}/definition.d.ts +31 -30
  36. package/dist/definition.js +240 -0
  37. package/dist/flags.d.ts +48 -0
  38. package/dist/flags.js +120 -0
  39. package/dist/index.d.ts +16 -0
  40. package/dist/index.js +15 -0
  41. package/oclif.manifest.json +281 -1
  42. package/package.json +62 -56
  43. package/bin/run +0 -5
  44. package/lib/api/error.js +0 -96
  45. package/lib/api/index.js +0 -64
  46. package/lib/api/models.js +0 -2
  47. package/lib/args.d.ts +0 -15
  48. package/lib/cli/index.d.ts +0 -31
  49. package/lib/cli/index.js +0 -14
  50. package/lib/cli/styled/success.d.ts +0 -1
  51. package/lib/cli/styled/success.js +0 -11
  52. package/lib/command.d.ts +0 -9
  53. package/lib/command.js +0 -31
  54. package/lib/commands/deploy.d.ts +0 -27
  55. package/lib/commands/deploy.js +0 -164
  56. package/lib/commands/diff.d.ts +0 -24
  57. package/lib/commands/diff.js +0 -119
  58. package/lib/commands/overlay.d.ts +0 -16
  59. package/lib/commands/overlay.js +0 -56
  60. package/lib/commands/preview.d.ts +0 -19
  61. package/lib/commands/preview.js +0 -83
  62. package/lib/core/definition_directory.js +0 -138
  63. package/lib/core/utils/file.js +0 -41
  64. package/lib/core/utils/prompts.d.ts +0 -1
  65. package/lib/core/utils/prompts.js +0 -21
  66. package/lib/definition.js +0 -218
  67. package/lib/flags.d.ts +0 -20
  68. package/lib/flags.js +0 -116
  69. package/lib/index.d.ts +0 -7
  70. package/lib/index.js +0 -14
  71. package/{lib → dist}/api/models.d.ts +20 -20
  72. package/{lib → dist}/api/vars.d.ts +3 -3
@@ -1,31 +0,0 @@
1
- import { CliUx } from '@oclif/core';
2
- import success from './styled/success';
3
- declare const cli: {
4
- styledSuccess: typeof success;
5
- config: CliUx.Config;
6
- warn: typeof import("@oclif/core/lib/errors").warn;
7
- error: typeof import("@oclif/core/lib/errors").error;
8
- exit: typeof import("@oclif/core/lib/errors").exit;
9
- prompt: typeof import("@oclif/core/lib/cli-ux/prompt").prompt;
10
- anykey: typeof import("@oclif/core/lib/cli-ux/prompt").anykey;
11
- confirm: typeof import("@oclif/core/lib/cli-ux/prompt").confirm;
12
- action: CliUx.ActionBase;
13
- prideAction: CliUx.ActionBase;
14
- styledObject(obj: any, keys?: string[] | undefined): void;
15
- styledHeader: typeof import("@oclif/core/lib/cli-ux/styled/header").default;
16
- styledJSON: typeof import("@oclif/core/lib/cli-ux/styled/json").default;
17
- table: typeof CliUx.Table.table;
18
- tree: typeof import("@oclif/core/lib/cli-ux/styled/tree").default;
19
- open: typeof import("@oclif/core/lib/cli-ux/open").default;
20
- wait: (ms?: number | undefined) => Promise<unknown>;
21
- progress: typeof import("@oclif/core/lib/cli-ux/styled/progress").default;
22
- done(): Promise<void>;
23
- trace(format: string, ...args: string[]): void;
24
- debug(format: string, ...args: string[]): void;
25
- info(format: string, ...args: string[]): void;
26
- log(format?: string | undefined, ...args: string[]): void;
27
- url(text: string, uri: string, params?: {} | undefined): void;
28
- annotation(text: string, annotation: string): void;
29
- flush(ms?: number | undefined): Promise<void>;
30
- };
31
- export { cli };
package/lib/cli/index.js DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cli = void 0;
4
- const tslib_1 = require("tslib");
5
- const core_1 = require("@oclif/core");
6
- const success_1 = (0, tslib_1.__importDefault)(require("./styled/success"));
7
- if (process.env.BUMP_LOG_LEVEL) {
8
- const logLevel = process.env.BUMP_LOG_LEVEL;
9
- core_1.CliUx.config['outputLevel'] = logLevel;
10
- }
11
- const cli = Object.assign(Object.assign({}, core_1.CliUx.ux), { get styledSuccess() {
12
- return success_1.default;
13
- } });
14
- exports.cli = cli;
@@ -1 +0,0 @@
1
- export default function styledSuccess(message: string): void;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
5
- function styledSuccess(message) {
6
- const lines = message.split('\n');
7
- for (let i = 0; i < lines.length; i++) {
8
- process.stdout.write(chalk_1.default.green(`* ${lines[i]}\n`));
9
- }
10
- }
11
- exports.default = styledSuccess;
package/lib/command.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import { Command as Base } from '@oclif/command';
2
- import { BumpApi } from './api';
3
- export default abstract class Command extends Base {
4
- private base;
5
- _bump: BumpApi;
6
- get bump(): BumpApi;
7
- catch(error?: Error): Promise<void>;
8
- d(formatter: any, ...args: any[]): void;
9
- }
package/lib/command.js DELETED
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const command_1 = require("@oclif/command");
5
- const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
6
- const api_1 = require("./api");
7
- const package_json_1 = (0, tslib_1.__importDefault)(require("../package.json"));
8
- class Command extends command_1.Command {
9
- constructor() {
10
- super(...arguments);
11
- this.base = `${package_json_1.default.name}@${package_json_1.default.version}`;
12
- }
13
- get bump() {
14
- if (!this._bump)
15
- this._bump = new api_1.BumpApi(this.config);
16
- return this._bump;
17
- }
18
- async catch(error) {
19
- if (error && api_1.APIError.is(error)) {
20
- this.error(error.message, { exit: error.exitCode });
21
- }
22
- throw error;
23
- }
24
- // Function signature type taken from @types/debug
25
- // Debugger(formatter: any, ...args: any[]): void;
26
- /* eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any */
27
- d(formatter, ...args) {
28
- return (0, debug_1.default)(`bump-cli:command:${this.constructor.name.toLowerCase()}`)(formatter, ...args);
29
- }
30
- }
31
- exports.default = Command;
@@ -1,27 +0,0 @@
1
- import Command from '../command';
2
- import * as flagsBuilder from '../flags';
3
- export default class Deploy extends Command {
4
- static description: string;
5
- static examples: string[];
6
- static flags: {
7
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
8
- doc: flagsBuilder.IOptionFlag<string | undefined>;
9
- 'doc-name': flagsBuilder.IOptionFlag<string | undefined>;
10
- hub: flagsBuilder.IOptionFlag<string | undefined>;
11
- branch: flagsBuilder.IOptionFlag<string | undefined>;
12
- token: flagsBuilder.IOptionFlag<string | undefined>;
13
- 'auto-create': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
14
- interactive: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
15
- 'filename-pattern': flagsBuilder.IOptionFlag<string | undefined>;
16
- 'dry-run': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
17
- overlay: flagsBuilder.IOptionFlag<string | undefined>;
18
- };
19
- static args: {
20
- name: string;
21
- required: boolean;
22
- description: string;
23
- }[];
24
- run(): Promise<void>;
25
- private deployDirectory;
26
- private deploySingleFile;
27
- }
@@ -1,164 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
5
- const errors_1 = require("@oclif/parser/lib/errors");
6
- const errors_2 = require("@oclif/errors");
7
- const command_1 = (0, tslib_1.__importDefault)(require("../command"));
8
- const flagsBuilder = (0, tslib_1.__importStar)(require("../flags"));
9
- const definition_directory_1 = require("../core/definition_directory");
10
- const deploy_1 = require("../core/deploy");
11
- const prompts_1 = require("../core/utils/prompts");
12
- const file_1 = require("../core/utils/file");
13
- const args_1 = require("../args");
14
- const cli_1 = require("../cli");
15
- const definition_1 = require("../definition");
16
- class Deploy extends command_1.default {
17
- /*
18
- Oclif doesn't type parsed args & flags correctly and especially
19
- required-ness which is not known by the compiler, thus the use of
20
- the non-null assertion '!' in this command.
21
- See https://github.com/oclif/oclif/issues/301 for details
22
- */
23
- async run() {
24
- const { args, flags } = this.parse(Deploy);
25
- const [dryRun, documentation, token, hub, autoCreate, interactive, filenamePattern, documentationName, branch, overlay,] = [
26
- flags['dry-run'],
27
- flags.doc,
28
- /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
29
- flags.token,
30
- flags.hub,
31
- flags['auto-create'],
32
- flags.interactive,
33
- /* Flags.filenamePattern has a default value, so it's always defined. But
34
- * oclif types doesn't detect it */
35
- /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
36
- flags['filename-pattern'],
37
- flags['doc-name'],
38
- flags.branch,
39
- flags.overlay,
40
- ];
41
- if ((0, file_1.isDir)(args.FILE)) {
42
- if (hub) {
43
- await this.deployDirectory(args.FILE, dryRun, token, hub, autoCreate, interactive, filenamePattern, documentationName, branch);
44
- }
45
- else {
46
- throw new errors_1.RequiredFlagError({ flag: Deploy.flags.hub, parse: {} });
47
- }
48
- }
49
- else {
50
- if (documentation) {
51
- const api = await definition_1.API.load(args.FILE);
52
- this.d(`${args.FILE} looks like an ${api.specName} spec version ${api.version}`);
53
- await this.deploySingleFile(api, dryRun, documentation, token, hub, autoCreate, documentationName, branch, overlay);
54
- }
55
- else {
56
- throw new errors_1.RequiredFlagError({ flag: Deploy.flags.doc, parse: {} });
57
- }
58
- }
59
- return;
60
- }
61
- async deployDirectory(dir, dryRun, token, hub, autoCreate, interactive, filenamePattern, documentationName, branch) {
62
- const definitionDirectory = new definition_directory_1.DefinitionDirectory(dir, filenamePattern);
63
- const action = dryRun ? 'validate' : 'deploy';
64
- await definitionDirectory.readDefinitions();
65
- // In “interactive” mode we ask the user if he wants to add more
66
- // definitions to deploy. He is thus presented a form to select
67
- // some files from the target directory.
68
- if (interactive) {
69
- let confirm = true;
70
- if (definitionDirectory.definitionsExists()) {
71
- await (0, prompts_1.confirm)('Do you want to add more files to deploy?').catch(() => {
72
- confirm = false;
73
- });
74
- }
75
- if (confirm) {
76
- await definitionDirectory.interactiveSelection();
77
- }
78
- }
79
- if (definitionDirectory.definitionsExists()) {
80
- cli_1.cli.info(chalk_1.default.underline(`Let's ${action} those documentations to your ${hub} hub on Bump.sh`));
81
- await definitionDirectory.sequentialMap(async (definition) => {
82
- if (interactive) {
83
- await definitionDirectory.renameToConvention(definition);
84
- }
85
- await this.deploySingleFile(definition.definition, dryRun, definition.slug, token, hub, autoCreate, definition.slug || documentationName, branch);
86
- return definition;
87
- });
88
- }
89
- else {
90
- throw new errors_2.CLIError(`No documentation found in ${dir} with the pattern '${filenamePattern}'.\nYou should check with the ${chalk_1.default.dim('--filename-pattern')} flag to select your files from your naming convention.\nIf you don't have a naming convention we can help naming your API definition files:\nTry the ${chalk_1.default.dim('--interactive')} flag for that.`);
91
- }
92
- return;
93
- }
94
- async deploySingleFile(api, dryRun, documentation, token, hub, autoCreate, documentationName, branch, overlay) {
95
- const action = dryRun ? 'validate' : 'deploy';
96
- cli_1.cli.action.start(`Let's ${action} a new version to your ${documentation} documentation on Bump.sh`);
97
- const response = await new deploy_1.Deploy(this.config).run(api, dryRun, documentation, token, hub, autoCreate, documentationName, branch, overlay);
98
- if (dryRun) {
99
- await cli_1.cli.styledSuccess('Definition is valid');
100
- }
101
- else {
102
- if (response) {
103
- await cli_1.cli.styledSuccess(`Your new documentation version will soon be ready at ${response.doc_public_url}`);
104
- }
105
- else {
106
- await cli_1.cli.warn('Your documentation has not changed');
107
- }
108
- }
109
- cli_1.cli.action.stop();
110
- return;
111
- }
112
- }
113
- exports.default = Deploy;
114
- Deploy.description = 'Create a new version of your documentation from the given file or URL.';
115
- Deploy.examples = [
116
- `Deploy a new version of ${chalk_1.default.underline('an existing documentation')}
117
-
118
- ${chalk_1.default.dim('$ bump deploy FILE --doc <your_doc_id_or_slug> --token <your_doc_token>')}
119
- * Let's deploy a new documentation version on Bump... done
120
- * Your new documentation version will soon be ready
121
- `,
122
- `Deploy a new version of ${chalk_1.default.underline('an existing documentation attached to a hub')}
123
-
124
- ${chalk_1.default.dim('$ bump deploy FILE --doc <doc_slug> --hub <your_hub_id_or_slug> --token <your_doc_token>')}
125
- * Let's deploy a new documentation version on Bump... done
126
- * Your new documentation version will soon be ready
127
- `,
128
- `Deploy a whole directory of ${chalk_1.default.underline('API definitions files to a hub')}
129
-
130
- ${chalk_1.default.dim('$ bump deploy DIR --filename-pattern *-{slug}-api --hub <hub_slug> --token <hub_token>')}
131
- We've found 2 valid API definitions to deploy
132
- └─ DIR
133
- └─ source-my-service-api.yml (OpenAPI spec version 3.1.0)
134
- └─ source-my-jobs-service-api.yml (AsyncAPI spec version 2.6.0)
135
-
136
- Let's deploy those documentations to your <hub_slug> hub on Bump.sh
137
-
138
- * Your new documentation version will soon be ready
139
- Let's deploy a new version to your my-service documentation on Bump.sh... done
140
-
141
- * Your new documentation version will soon be ready
142
- Let's deploy a new version to your my-jobs-service documentation on Bump.sh... done
143
- `,
144
- `${chalk_1.default.underline('Validate a new documentation version')} before deploying it
145
-
146
- ${chalk_1.default.dim('$ bump deploy FILE --dry-run --doc <doc_slug> --token <your_doc_token>')}
147
- * Let's validate a new documentation version on Bump... done
148
- * Definition is valid
149
- `,
150
- ];
151
- Deploy.flags = {
152
- help: flagsBuilder.help({ char: 'h' }),
153
- doc: flagsBuilder.doc(),
154
- 'doc-name': flagsBuilder.docName(),
155
- hub: flagsBuilder.hub(),
156
- branch: flagsBuilder.branch(),
157
- token: flagsBuilder.token(),
158
- 'auto-create': flagsBuilder.autoCreate(),
159
- interactive: flagsBuilder.interactive(),
160
- 'filename-pattern': flagsBuilder.filenamePattern(),
161
- 'dry-run': flagsBuilder.dryRun(),
162
- overlay: flagsBuilder.overlay(),
163
- };
164
- Deploy.args = [args_1.fileArg];
@@ -1,24 +0,0 @@
1
- import Command from '../command';
2
- import * as flagsBuilder from '../flags';
3
- import { DiffResponse } from '../api/models';
4
- export default class Diff extends Command {
5
- static description: string;
6
- static examples: string[];
7
- static flags: {
8
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
9
- doc: flagsBuilder.IOptionFlag<string | undefined>;
10
- hub: flagsBuilder.IOptionFlag<string | undefined>;
11
- branch: flagsBuilder.IOptionFlag<string | undefined>;
12
- token: flagsBuilder.IOptionFlag<string | undefined>;
13
- open: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
14
- 'fail-on-breaking': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
15
- format: flagsBuilder.IOptionFlag<string | undefined>;
16
- expires: flagsBuilder.IOptionFlag<string | undefined>;
17
- };
18
- static args: {
19
- name: string;
20
- description: string;
21
- }[];
22
- run(): Promise<void>;
23
- displayCompareResult(result: DiffResponse, format: string, open: boolean, failOnBreaking: boolean): Promise<void>;
24
- }
@@ -1,119 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const errors_1 = require("@oclif/errors");
5
- const command_1 = (0, tslib_1.__importDefault)(require("../command"));
6
- const flagsBuilder = (0, tslib_1.__importStar)(require("../flags"));
7
- const diff_1 = require("../core/diff");
8
- const args_1 = require("../args");
9
- const cli_1 = require("../cli");
10
- class Diff extends command_1.default {
11
- /*
12
- Oclif doesn't type parsed args & flags correctly and especially
13
- required-ness which is not known by the compiler, thus the use of
14
- the non-null assertion '!' in this command.
15
- See https://github.com/oclif/oclif/issues/301 for details
16
- */
17
- async run() {
18
- const { args, flags } = this.parse(Diff);
19
- /* Flags.format has a default value, so it's always defined. But
20
- * oclif types doesn't detect it */
21
- const [documentation, hub, branch, token, format, expires] = [
22
- flags.doc,
23
- flags.hub,
24
- flags.branch,
25
- flags.token,
26
- /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
27
- flags.format,
28
- flags.expires,
29
- ];
30
- if (format === 'text') {
31
- if (args.FILE2) {
32
- cli_1.cli.action.start('* Comparing the two given definition files');
33
- }
34
- else {
35
- cli_1.cli.action.start('* Comparing the given definition file with the currently deployed one');
36
- }
37
- }
38
- if (!args.FILE2 && (!documentation || !token)) {
39
- throw new errors_1.CLIError('Please provide a second file argument or login with an existing token');
40
- }
41
- const diff = await new diff_1.Diff(this.config).run(args.FILE, args.FILE2, documentation, hub, branch, token, format, expires);
42
- cli_1.cli.action.stop();
43
- if (diff) {
44
- await this.displayCompareResult(diff, format, flags.open, flags['fail-on-breaking']);
45
- }
46
- else {
47
- await cli_1.cli.log('No changes detected.');
48
- }
49
- return;
50
- }
51
- async displayCompareResult(result, format, open, failOnBreaking) {
52
- if (format == 'text' && result.text) {
53
- await cli_1.cli.log(result.text);
54
- }
55
- else if (format == 'markdown' && result.markdown) {
56
- await cli_1.cli.log(result.markdown);
57
- }
58
- else if (format == 'json' && result.details) {
59
- await cli_1.cli.log(JSON.stringify(result.details, null, 2));
60
- }
61
- else if (format == 'html' && result.html) {
62
- await cli_1.cli.log(result.html);
63
- }
64
- else {
65
- await cli_1.cli.log('No structural changes detected.');
66
- }
67
- if (open && result.public_url) {
68
- await cli_1.cli.open(result.public_url);
69
- }
70
- if (failOnBreaking && result.breaking) {
71
- this.exit(1);
72
- }
73
- }
74
- }
75
- exports.default = Diff;
76
- Diff.description = 'Get a comparison diff with your documentation from the given file or URL.';
77
- Diff.examples = [
78
- `Compare a potential new version with the currently published one:
79
-
80
- $ bump diff FILE --doc <your_doc_id_or_slug> --token <your_doc_token>
81
- * Comparing the given definition file with the currently deployed one... done
82
- Removed: GET /compare
83
- Added: GET /versions/{versionId}
84
- `,
85
- `Store the diff in a dedicated file:
86
-
87
- $ bump diff FILE --doc <doc_slug> --token <doc_token> > /tmp/my-saved-diff
88
- * Comparing the given definition file with the currently deployed one... done
89
-
90
- $ cat /tmp/my-saved-diff
91
- Removed: GET /compare
92
- Added: GET /versions/{versionId}
93
- `,
94
- `In case of a non modified definition FILE compared to your existing documentation, no changes are output:
95
-
96
- $ bump diff FILE --doc <doc_slug> --token <your_doc_token>
97
- * Comparing the given definition file with the currently deployed one... done
98
- › Warning: Your documentation has not changed
99
- `,
100
- `Compare two different input files or URL independently to the one published on bump.sh
101
-
102
- $ bump diff FILE FILE2 --doc <doc_slug> --token <your_doc_token>
103
- * Comparing the two given definition files... done
104
- Updated: POST /versions
105
- Body attribute added: previous_version_id
106
- `,
107
- ];
108
- Diff.flags = {
109
- help: flagsBuilder.help({ char: 'h' }),
110
- doc: flagsBuilder.doc(),
111
- hub: flagsBuilder.hub(),
112
- branch: flagsBuilder.branch(),
113
- token: flagsBuilder.token({ required: false }),
114
- open: flagsBuilder.open({ description: 'Open the visual diff in your browser' }),
115
- 'fail-on-breaking': flagsBuilder.failOnBreaking(),
116
- format: flagsBuilder.format(),
117
- expires: flagsBuilder.expires(),
118
- };
119
- Diff.args = [args_1.fileArg, args_1.otherFileArg];
@@ -1,16 +0,0 @@
1
- import Command from '../command';
2
- import * as flagsBuilder from '../flags';
3
- export default class Overlay extends Command {
4
- static description: string;
5
- static examples: string[];
6
- static flags: {
7
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
8
- out: flagsBuilder.IOptionFlag<string | undefined>;
9
- };
10
- static args: {
11
- name: string;
12
- required: boolean;
13
- description: string;
14
- }[];
15
- run(): Promise<void>;
16
- }
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
5
- const promises_1 = require("node:fs/promises");
6
- const node_fs_1 = require("node:fs");
7
- const path_1 = require("path");
8
- const definition_1 = require("../definition");
9
- const prompts_1 = require("../core/utils/prompts");
10
- const command_1 = (0, tslib_1.__importDefault)(require("../command"));
11
- const flagsBuilder = (0, tslib_1.__importStar)(require("../flags"));
12
- const args_1 = require("../args");
13
- const cli_1 = require("../cli");
14
- class Overlay extends command_1.default {
15
- async run() {
16
- const { args, flags } = this.parse(Overlay);
17
- const outputPath = flags.out;
18
- cli_1.cli.action.start("* Let's apply the overlay to the main definition");
19
- const api = await definition_1.API.load(args.FILE);
20
- await api.applyOverlay(args.OVERLAY_FILE);
21
- const [overlayedDefinition] = api.extractDefinition(outputPath);
22
- cli_1.cli.action.stop();
23
- if (outputPath) {
24
- await (0, promises_1.mkdir)((0, path_1.dirname)(outputPath), { recursive: true });
25
- let confirm = true;
26
- if ((0, node_fs_1.existsSync)(outputPath)) {
27
- await (0, prompts_1.confirm)(`Do you want to override the existing destination file? (${outputPath})`).catch(() => {
28
- confirm = false;
29
- });
30
- }
31
- if (confirm) {
32
- await (0, promises_1.writeFile)(outputPath, overlayedDefinition);
33
- }
34
- }
35
- else {
36
- cli_1.cli.log(overlayedDefinition);
37
- }
38
- return;
39
- }
40
- }
41
- exports.default = Overlay;
42
- Overlay.description = 'Apply an OpenAPI specified overlay to your API definition.';
43
- Overlay.examples = [
44
- `Apply the OVERLAY_FILE to the existing DEFINITION_FILE. The resulting
45
- definition is output on stdout meaning you can redirect it to a new
46
- file.
47
-
48
- ${chalk_1.default.dim('$ bump overlay DEFINITION_FILE OVERLAY_FILE > destination/file.json')}
49
- * Let's apply the overlay to the main definition... done
50
- `,
51
- ];
52
- Overlay.flags = {
53
- help: flagsBuilder.help({ char: 'h' }),
54
- out: flagsBuilder.out(),
55
- };
56
- Overlay.args = [args_1.fileArg, args_1.overlayFileArg];
@@ -1,19 +0,0 @@
1
- import Command from '../command';
2
- import { PreviewResponse } from '../api/models';
3
- export default class Preview extends Command {
4
- static description: string;
5
- static examples: string[];
6
- static flags: {
7
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
8
- live: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
9
- open: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
10
- };
11
- static args: {
12
- name: string;
13
- required: boolean;
14
- description: string;
15
- }[];
16
- run(): Promise<void>;
17
- preview(file: string, open?: boolean, currentPreview?: PreviewResponse | undefined): Promise<PreviewResponse>;
18
- waitForChanges(file: string, preview: PreviewResponse): Promise<void>;
19
- }
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const definition_1 = require("../definition");
5
- const command_1 = (0, tslib_1.__importDefault)(require("../command"));
6
- const flagsBuilder = (0, tslib_1.__importStar)(require("../flags"));
7
- const args_1 = require("../args");
8
- const cli_1 = require("../cli");
9
- const fs_1 = require("fs");
10
- const async_mutex_1 = require("async-mutex");
11
- class Preview extends command_1.default {
12
- async run() {
13
- const { args, flags } = this.parse(Preview);
14
- const currentPreview = await this.preview(args.FILE, flags.open);
15
- if (flags.live) {
16
- await this.waitForChanges(args.FILE, currentPreview);
17
- }
18
- return;
19
- }
20
- async preview(file, open = false, currentPreview = undefined) {
21
- const api = await definition_1.API.load(file);
22
- const [definition, references] = api.extractDefinition();
23
- this.d(`${file} looks like an ${api.specName} spec version ${api.version}`);
24
- if (!currentPreview) {
25
- cli_1.cli.action.start("* Let's render a preview on Bump.sh");
26
- }
27
- const request = {
28
- definition,
29
- references,
30
- };
31
- const response = currentPreview
32
- ? await this.bump.putPreview(currentPreview.id, request)
33
- : await this.bump.postPreview(request);
34
- if (!currentPreview) {
35
- cli_1.cli.action.stop();
36
- cli_1.cli.styledSuccess(`Your preview is visible at: ${response.data.public_url} (Expires at ${response.data.expires_at})`);
37
- }
38
- if (open && response.data.public_url) {
39
- await cli_1.cli.open(response.data.public_url);
40
- }
41
- return response.data;
42
- }
43
- async waitForChanges(file, preview) {
44
- const mutex = new async_mutex_1.Mutex();
45
- let currentPreview = preview;
46
- cli_1.cli.action.start(`Waiting for changes on file ${file}...`);
47
- (0, fs_1.watch)(file, async () => {
48
- if (!mutex.isLocked()) {
49
- const release = await mutex.acquire();
50
- this.preview(file, false, currentPreview)
51
- .then((preview) => {
52
- currentPreview = preview;
53
- cli_1.cli.action.start(`Waiting for changes on file ${file}`);
54
- })
55
- .catch((err) => {
56
- this.warn(err);
57
- })
58
- .finally(() => {
59
- setTimeout(() => {
60
- release();
61
- }, 1000); // Prevent previewing faster than once per second
62
- });
63
- }
64
- });
65
- }
66
- }
67
- exports.default = Preview;
68
- Preview.description = 'Create a documentation preview from the given file or URL.';
69
- Preview.examples = [
70
- `$ bump preview FILE
71
- * Your preview is visible at: https://bump.sh/preview/45807371-9a32-48a7-b6e4-1cb7088b5b9b
72
- `,
73
- ];
74
- Preview.flags = {
75
- help: flagsBuilder.help({ char: 'h' }),
76
- live: flagsBuilder.live({
77
- description: 'Generate a preview each time you save the given file',
78
- }),
79
- open: flagsBuilder.open({
80
- description: 'Open the generated preview URL in your browser',
81
- }),
82
- };
83
- Preview.args = [args_1.fileArg];