bump-cli 2.9.4 → 2.9.5

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.
@@ -29,6 +29,7 @@ export interface VersionRequest {
29
29
  hub?: string;
30
30
  previous_version_id?: string;
31
31
  references?: Reference[];
32
+ temporary?: boolean;
32
33
  unpublished?: boolean;
33
34
  }
34
35
  export interface VersionResponse {
@@ -16,9 +16,10 @@ export default class Deploy extends BaseCommand<typeof Deploy> {
16
16
  hub: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
17
17
  interactive: import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
18
  overlay: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ preview: import("@oclif/core/interfaces").BooleanFlag<boolean>;
19
20
  token: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
20
21
  };
21
22
  protected deployDirectory(dir: string, dryRun: boolean, token: string, hub: string, autoCreate: boolean, interactive: boolean, filenamePattern: string, documentationName: string | undefined, branch: string | undefined): Promise<void>;
22
- protected deploySingleFile(api: API, dryRun: boolean, documentation: string, token: string, hub: string | undefined, autoCreate: boolean, documentationName: string | undefined, branch: string | undefined, overlay?: string[] | undefined): Promise<void>;
23
+ protected deploySingleFile(api: API, dryRun: boolean, documentation: string, token: string, hub: string | undefined, autoCreate: boolean, documentationName: string | undefined, branch: string | undefined, overlay?: string[] | undefined, temporary?: boolean | undefined): Promise<void>;
23
24
  run(): Promise<void>;
24
25
  }
@@ -58,6 +58,7 @@ ${chalk.dim('$ bump deploy FILE --dry-run --doc <doc_slug> --token <your_doc_tok
58
58
  hub: flagsBuilder.hub(),
59
59
  interactive: flagsBuilder.interactive(),
60
60
  overlay: flagsBuilder.overlay(),
61
+ preview: flagsBuilder.preview(),
61
62
  token: flagsBuilder.token(),
62
63
  };
63
64
  async deployDirectory(dir, dryRun, token, hub, autoCreate, interactive, filenamePattern, documentationName, branch) {
@@ -98,15 +99,15 @@ ${chalk.dim('$ bump deploy FILE --dry-run --doc <doc_slug> --token <your_doc_tok
98
99
  throw new CLIError(`No documentation found in ${dir} with the pattern '${filenamePattern}'.\nYou should check with the ${chalk.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.dim('--interactive')} flag for that.`);
99
100
  }
100
101
  }
101
- async deploySingleFile(api, dryRun, documentation, token, hub, autoCreate, documentationName, branch, overlay) {
102
+ async deploySingleFile(api, dryRun, documentation, token, hub, autoCreate, documentationName, branch, overlay, temporary) {
102
103
  ux.action.status = `...a new version to your ${documentation} documentation`;
103
- const response = await new CoreDeploy(this.bump).run(api, dryRun, documentation, token, hub, autoCreate, documentationName, branch, overlay);
104
+ const response = await new CoreDeploy(this.bump).run(api, dryRun, documentation, token, hub, autoCreate, documentationName, branch, overlay, temporary);
104
105
  if (dryRun) {
105
106
  ux.stdout(ux.colorize('green', 'Definition is valid'));
106
107
  }
107
108
  else if (response) {
108
109
  process.stdout.write(ux.colorize('green', `Your ${documentation} documentation...`));
109
- ux.stdout(ux.colorize('green', `has received a new deployment which will soon be ready at:`));
110
+ ux.stdout(ux.colorize('green', `has received a new ${temporary ? 'preview' : 'deployment'} which will soon be ready at:`));
110
111
  ux.stdout(ux.colorize('underline', response.doc_public_url));
111
112
  }
112
113
  else {
@@ -121,7 +122,7 @@ ${chalk.dim('$ bump deploy FILE --dry-run --doc <doc_slug> --token <your_doc_tok
121
122
  */
122
123
  async run() {
123
124
  const { args, flags } = await this.parse(Deploy);
124
- const [dryRun, documentation, token, hub, autoCreate, interactive, filenamePattern, documentationName, branch, overlay,] = [
125
+ const [dryRun, documentation, token, hub, autoCreate, interactive, filenamePattern, documentationName, branch, overlay, temporary,] = [
125
126
  flags['dry-run'],
126
127
  flags.doc,
127
128
  flags.token,
@@ -134,8 +135,10 @@ ${chalk.dim('$ bump deploy FILE --dry-run --doc <doc_slug> --token <your_doc_tok
134
135
  flags['doc-name'],
135
136
  flags.branch,
136
137
  flags.overlay,
138
+ /* when --preview is provided, generate temporary version */
139
+ flags.preview,
137
140
  ];
138
- const action = dryRun ? 'validate' : 'deploy';
141
+ const action = dryRun ? 'validate' : temporary ? 'preview' : 'deploy';
139
142
  ux.action.start(`Let's ${action} on Bump.sh`);
140
143
  if (isDir(args.file)) {
141
144
  if (hub) {
@@ -148,7 +151,7 @@ ${chalk.dim('$ bump deploy FILE --dry-run --doc <doc_slug> --token <your_doc_tok
148
151
  else if (documentation) {
149
152
  const api = await API.load(args.file);
150
153
  this.d(`${args.file} looks like an ${api.specName} spec version ${api.version}`);
151
- await this.deploySingleFile(api, dryRun, documentation, token, hub, autoCreate, documentationName, branch, overlay);
154
+ await this.deploySingleFile(api, dryRun, documentation, token, hub, autoCreate, documentationName, branch, overlay, temporary);
152
155
  }
153
156
  else {
154
157
  throw new CLIError('Missing required flag --doc=<slug>');
@@ -6,6 +6,6 @@ export declare class Deploy {
6
6
  constructor(bumpClient: BumpApi);
7
7
  protected createVersion(request: VersionRequest, token: string): Promise<VersionResponse | undefined>;
8
8
  d(formatter: any, ...args: any[]): void;
9
- run(api: API, dryRun: boolean, documentation: string, token: string, hub: string | undefined, autoCreate: boolean, documentationName: string | undefined, branch: string | undefined, overlay?: string[] | undefined): Promise<VersionResponse | undefined>;
9
+ run(api: API, dryRun: boolean, documentation: string, token: string, hub: string | undefined, autoCreate: boolean, documentationName: string | undefined, branch: string | undefined, overlay?: string[] | undefined, temporary?: boolean | false): Promise<VersionResponse | undefined>;
10
10
  validateVersion(version: VersionRequest, token: string): Promise<undefined>;
11
11
  }
@@ -26,7 +26,7 @@ export class Deploy {
26
26
  d(formatter, ...args) {
27
27
  return debug(`bump-cli:core:deploy`)(formatter, ...args);
28
28
  }
29
- async run(api, dryRun, documentation, token, hub, autoCreate, documentationName, branch, overlay) {
29
+ async run(api, dryRun, documentation, token, hub, autoCreate, documentationName, branch, overlay, temporary) {
30
30
  let version;
31
31
  if (overlay) {
32
32
  /* eslint-disable no-await-in-loop */
@@ -46,6 +46,7 @@ export class Deploy {
46
46
  documentation_name: documentationName,
47
47
  hub,
48
48
  references,
49
+ temporary,
49
50
  };
50
51
  if (dryRun) {
51
52
  await this.validateVersion(request, token);
@@ -36,6 +36,23 @@ export class Overlay {
36
36
  process.stderr.write(`WARNING: Action target '${target}' has no matching elements\n`);
37
37
  continue;
38
38
  }
39
+ // When we execute a 'remove' action we need to be careful if
40
+ // the targets are elements of an array. Because the list of
41
+ // paths contains an index of each element.
42
+ //
43
+ // E.g.
44
+ // ["servers"][0]
45
+ // ["servers"][1]
46
+ // ["servers"][2]
47
+ //
48
+ // And if we remove elements starting from the 0, the array
49
+ // will be reindexed and thus the '2' index won't be valid
50
+ // anymore.
51
+ //
52
+ // Thus, in that case we revers the list of paths
53
+ if (action.remove) {
54
+ paths.reverse();
55
+ }
39
56
  for (const path of paths) {
40
57
  // The 'executeAction' will mutate the passed spec object in
41
58
  // place.
@@ -71,9 +88,11 @@ export class Overlay {
71
88
  // Do the overlay action
72
89
  // Is it a remove?
73
90
  if (Object.hasOwn(action, 'remove')) {
91
+ this.d(`Executing 'remove' on target path: ${path}`);
74
92
  this.remove(parent, thingToActUpon);
75
93
  }
76
94
  else if (Object.hasOwn(action, 'update')) {
95
+ this.d(`Executing 'update' on target path: ${path}`);
77
96
  spec = this.update(spec, parent, action.update, thingToActUpon);
78
97
  }
79
98
  else {
package/dist/flags.d.ts CHANGED
@@ -29,6 +29,7 @@ declare const dryRun: (opts?: Partial<Interfaces.BooleanFlag<boolean>>) => Inter
29
29
  declare const open: (opts?: Partial<Interfaces.BooleanFlag<boolean>>) => Interfaces.BooleanFlag<boolean>;
30
30
  declare const failOnBreaking: (opts?: Partial<Interfaces.BooleanFlag<boolean>>) => Interfaces.BooleanFlag<boolean>;
31
31
  declare const live: (opts?: Partial<Interfaces.BooleanFlag<boolean>>) => Interfaces.BooleanFlag<boolean>;
32
+ declare const preview: (opts?: Partial<Interfaces.BooleanFlag<boolean>>) => Interfaces.BooleanFlag<boolean>;
32
33
  declare const format: Interfaces.FlagDefinition<string, Interfaces.CustomOptions, {
33
34
  multiple: false;
34
35
  requiredOrDefaulted: true;
@@ -45,4 +46,4 @@ declare const overlay: Interfaces.FlagDefinition<string[], Interfaces.CustomOpti
45
46
  multiple: true;
46
47
  requiredOrDefaulted: false;
47
48
  }>;
48
- export { autoCreate, branch, doc, docName, dryRun, expires, failOnBreaking, filenamePattern, format, hub, interactive, live, open, out, overlay, token, };
49
+ export { autoCreate, branch, doc, docName, dryRun, expires, failOnBreaking, filenamePattern, format, hub, interactive, live, open, out, overlay, preview, token, };
package/dist/flags.js CHANGED
@@ -96,6 +96,14 @@ const live = (opts = {}) => {
96
96
  default: false,
97
97
  });
98
98
  };
99
+ const preview = (opts = {}) => {
100
+ return Flags.boolean({
101
+ ...opts,
102
+ char: 'p',
103
+ default: false,
104
+ description: 'Generate a preview in your API context. The resulting version is temporary and not visible by your documentation viewers.',
105
+ });
106
+ };
99
107
  const format = Flags.custom({
100
108
  char: 'f',
101
109
  default: 'text',
@@ -115,4 +123,4 @@ const overlay = Flags.custom({
115
123
  description: 'Path or URL of overlay file(s) to apply before deploying',
116
124
  multiple: true,
117
125
  });
118
- export { autoCreate, branch, doc, docName, dryRun, expires, failOnBreaking, filenamePattern, format, hub, interactive, live, open, out, overlay, token, };
126
+ export { autoCreate, branch, doc, docName, dryRun, expires, failOnBreaking, filenamePattern, format, hub, interactive, live, open, out, overlay, preview, token, };
@@ -92,12 +92,18 @@
92
92
  "multiple": true,
93
93
  "type": "option"
94
94
  },
95
+ "preview": {
96
+ "char": "p",
97
+ "description": "Generate a preview in your API context. The resulting version is temporary and not visible by your documentation viewers.",
98
+ "name": "preview",
99
+ "allowNo": false,
100
+ "type": "boolean"
101
+ },
95
102
  "token": {
96
103
  "char": "t",
97
104
  "description": "Documentation or Hub token. Can be provided via BUMP_TOKEN environment variable",
98
105
  "name": "token",
99
106
  "required": true,
100
- "default": "99f52837852249b328c0a00249f846a3",
101
107
  "hasDynamicHelp": false,
102
108
  "multiple": false,
103
109
  "type": "option"
@@ -191,7 +197,6 @@
191
197
  "description": "Documentation or Hub token. Can be provided via BUMP_TOKEN environment variable",
192
198
  "name": "token",
193
199
  "required": false,
194
- "default": "99f52837852249b328c0a00249f846a3",
195
200
  "hasDynamicHelp": false,
196
201
  "multiple": false,
197
202
  "type": "option"
@@ -279,5 +284,5 @@
279
284
  "strict": true
280
285
  }
281
286
  },
282
- "version": "2.9.4"
287
+ "version": "2.9.5"
283
288
  }
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.sh by using the API of developers.bump.sh",
4
- "version": "2.9.4",
4
+ "version": "2.9.5",
5
5
  "author": "Paul Bonaud <paulr@bump.sh>",
6
6
  "bin": {
7
7
  "bump": "./bin/run.js"