bump-cli 2.9.4 → 2.9.6
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 +11 -3
- package/dist/api/models.d.ts +1 -0
- package/dist/commands/deploy.d.ts +2 -1
- package/dist/commands/deploy.js +9 -6
- package/dist/commands/diff.d.ts +1 -0
- package/dist/commands/diff.js +4 -2
- package/dist/commands/overlay.js +3 -3
- package/dist/commands/preview.js +1 -1
- package/dist/core/deploy.d.ts +1 -1
- package/dist/core/deploy.js +3 -11
- package/dist/core/diff.d.ts +3 -3
- package/dist/core/diff.js +7 -7
- package/dist/core/overlay.js +19 -0
- package/dist/definition.d.ts +1 -1
- package/dist/definition.js +17 -2
- package/dist/flags.d.ts +2 -1
- package/dist/flags.js +9 -1
- package/oclif.manifest.json +16 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -88,7 +88,7 @@ $ bump --help
|
|
|
88
88
|
The Bump.sh CLI is used to interact with your API documentation hosted on Bump.sh by using the API of developers.bump.sh
|
|
89
89
|
|
|
90
90
|
VERSION
|
|
91
|
-
bump-cli/2.9.
|
|
91
|
+
bump-cli/2.9.5 linux-x64 node-v20.18.1
|
|
92
92
|
|
|
93
93
|
USAGE
|
|
94
94
|
$ bump [COMMAND]
|
|
@@ -178,7 +178,7 @@ Please check `bump deploy --help` for more usage details.
|
|
|
178
178
|
### The `diff` command
|
|
179
179
|
|
|
180
180
|
Using the `diff` command can help to spot differences between the local API
|
|
181
|
-
document and the latest deployed version.
|
|
181
|
+
document and the latest deployed version.
|
|
182
182
|
|
|
183
183
|
#### Public API diffs
|
|
184
184
|
|
|
@@ -196,7 +196,7 @@ Modified: GET /consommations
|
|
|
196
196
|
By default the command will always exit with a successful return code. If you
|
|
197
197
|
want to use this command in a CI environment and want the command to fail **in
|
|
198
198
|
case of a breaking change**, you will need to add the `--fail-on-breaking` flag
|
|
199
|
-
to your diff command.
|
|
199
|
+
to your diff command.
|
|
200
200
|
|
|
201
201
|
By default if the environment variable `CI=1` is present (in most continuous
|
|
202
202
|
integration environment), the flag will be enabled. In that case you can disable
|
|
@@ -230,6 +230,14 @@ bump diff path/to/your/file.yml path/to/your/next-file.yml --doc my-documentatio
|
|
|
230
230
|
|
|
231
231
|
Please check `bump diff --help` for full usage details.
|
|
232
232
|
|
|
233
|
+
#### Diffs with overlayed source files
|
|
234
|
+
|
|
235
|
+
The `bump diff` command also supports [overlays](#the-overlay-command). This means you can pass the `--overlay my-overlay-file.yml` flag to the command and it will apply the overlay on both files **before** running the diff. E.g.:
|
|
236
|
+
|
|
237
|
+
```shell
|
|
238
|
+
bump diff --overlay my-overlay.yml path/to/your/file.yml path/to/your/next-file.yml
|
|
239
|
+
```
|
|
240
|
+
|
|
233
241
|
### The `preview` command
|
|
234
242
|
|
|
235
243
|
When writing documentation, you might want to preview how it renders on Bump.sh.
|
package/dist/api/models.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -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>');
|
package/dist/commands/diff.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export default class Diff extends BaseCommand<typeof Diff> {
|
|
|
14
14
|
'fail-on-breaking': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
15
|
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
16
|
hub: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
overlay: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
18
|
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
19
|
};
|
|
19
20
|
displayCompareResult(result: DiffResponse, format: string, failOnBreaking: boolean): Promise<void>;
|
package/dist/commands/diff.js
CHANGED
|
@@ -48,6 +48,7 @@ export default class Diff extends BaseCommand {
|
|
|
48
48
|
'fail-on-breaking': flagsBuilder.failOnBreaking({ allowNo: true }),
|
|
49
49
|
format: flagsBuilder.format(),
|
|
50
50
|
hub: flagsBuilder.hub(),
|
|
51
|
+
overlay: flagsBuilder.overlay(),
|
|
51
52
|
token: flagsBuilder.token({ required: false }),
|
|
52
53
|
};
|
|
53
54
|
async displayCompareResult(result, format, failOnBreaking) {
|
|
@@ -78,13 +79,14 @@ export default class Diff extends BaseCommand {
|
|
|
78
79
|
*/
|
|
79
80
|
async run() {
|
|
80
81
|
const { args, flags } = await this.parse(Diff);
|
|
81
|
-
const [documentation, hub, branch, token, format, expires] = [
|
|
82
|
+
const [documentation, hub, branch, token, format, expires, overlays] = [
|
|
82
83
|
flags.doc,
|
|
83
84
|
flags.hub,
|
|
84
85
|
flags.branch,
|
|
85
86
|
flags.token,
|
|
86
87
|
flags.format,
|
|
87
88
|
flags.expires,
|
|
89
|
+
flags.overlay,
|
|
88
90
|
];
|
|
89
91
|
if (format === 'text') {
|
|
90
92
|
if (args.otherFile) {
|
|
@@ -98,7 +100,7 @@ export default class Diff extends BaseCommand {
|
|
|
98
100
|
throw new CLIError('Please provide a second file argument or login with an existing token');
|
|
99
101
|
}
|
|
100
102
|
ux.action.status = '...diff on Bump.sh in progress';
|
|
101
|
-
const diff = await new CoreDiff(this.config).run(args.file, args.otherFile, documentation, hub, branch, token, format, expires);
|
|
103
|
+
const diff = await new CoreDiff(this.config).run(args.file, args.otherFile, documentation, hub, branch, token, format, expires, overlays);
|
|
102
104
|
ux.action.stop();
|
|
103
105
|
if (diff) {
|
|
104
106
|
await this.displayCompareResult(diff, format, flags['fail-on-breaking']);
|
package/dist/commands/overlay.js
CHANGED
|
@@ -29,12 +29,12 @@ ${chalk.dim('$ bump overlay DEFINITION_FILE OVERLAY_FILE > destination/file.json
|
|
|
29
29
|
async run() {
|
|
30
30
|
const { args, flags } = await this.parse(Overlay);
|
|
31
31
|
const outputPath = flags.out;
|
|
32
|
+
const { file, overlay } = args;
|
|
32
33
|
ux.action.start("* Let's apply the overlay to the main definition");
|
|
33
34
|
ux.action.status = '...loading definition file';
|
|
34
|
-
const api = await API.load(
|
|
35
|
+
const api = await API.load(file);
|
|
35
36
|
ux.action.status = '...applying overlay';
|
|
36
|
-
await api.
|
|
37
|
-
const [overlayedDefinition] = api.extractDefinition(outputPath);
|
|
37
|
+
const [overlayedDefinition] = await api.extractDefinition(outputPath, [overlay]);
|
|
38
38
|
ux.action.stop();
|
|
39
39
|
if (outputPath) {
|
|
40
40
|
await mkdir(dirname(outputPath), { recursive: true });
|
package/dist/commands/preview.js
CHANGED
|
@@ -37,7 +37,7 @@ export default class Preview extends BaseCommand {
|
|
|
37
37
|
}
|
|
38
38
|
async preview(file, open = false, currentPreview = undefined) {
|
|
39
39
|
const api = await API.load(file);
|
|
40
|
-
const [definition, references] = api.extractDefinition();
|
|
40
|
+
const [definition, references] = await api.extractDefinition();
|
|
41
41
|
this.d(`${file} looks like an ${api.specName} spec version ${api.version}`);
|
|
42
42
|
const request = {
|
|
43
43
|
definition,
|
package/dist/core/deploy.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/core/deploy.js
CHANGED
|
@@ -26,18 +26,9 @@ 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
|
-
|
|
32
|
-
/* eslint-disable no-await-in-loop */
|
|
33
|
-
// Alternatively we can apply all overlays in parallel
|
|
34
|
-
// https://stackoverflow.com/questions/48957022/unexpected-await-inside-a-loop-no-await-in-loop
|
|
35
|
-
for (const overlayFile of overlay) {
|
|
36
|
-
await api.applyOverlay(overlayFile);
|
|
37
|
-
}
|
|
38
|
-
/* eslint-enable no-await-in-loop */
|
|
39
|
-
}
|
|
40
|
-
const [definition, references] = api.extractDefinition();
|
|
31
|
+
const [definition, references] = await api.extractDefinition(undefined, overlay);
|
|
41
32
|
const request = {
|
|
42
33
|
auto_create_documentation: autoCreate && !dryRun,
|
|
43
34
|
branch_name: branch,
|
|
@@ -46,6 +37,7 @@ export class Deploy {
|
|
|
46
37
|
documentation_name: documentationName,
|
|
47
38
|
hub,
|
|
48
39
|
references,
|
|
40
|
+
temporary,
|
|
49
41
|
};
|
|
50
42
|
if (dryRun) {
|
|
51
43
|
await this.validateVersion(request, token);
|
package/dist/core/diff.d.ts
CHANGED
|
@@ -8,14 +8,14 @@ export declare class Diff {
|
|
|
8
8
|
constructor(config?: Config);
|
|
9
9
|
get bumpClient(): BumpApi;
|
|
10
10
|
get pollingPeriod(): number;
|
|
11
|
-
createDiff(file1: string, file2: string, expires: string | undefined): Promise<DiffResponse | undefined>;
|
|
12
|
-
createVersion(file: string, documentation: string, token: string, hub: string | undefined, branch_name: string | undefined, previous_version_id?: string | undefined): Promise<VersionResponse | undefined>;
|
|
11
|
+
createDiff(file1: string, file2: string, expires: string | undefined, overlays?: string[] | undefined): Promise<DiffResponse | undefined>;
|
|
12
|
+
createVersion(file: string, documentation: string, token: string, hub: string | undefined, branch_name: string | undefined, previous_version_id?: string | undefined, overlays?: string[] | undefined): Promise<VersionResponse | undefined>;
|
|
13
13
|
d(formatter: any, ...args: any[]): void;
|
|
14
14
|
extractDiff(versionWithDiff: VersionResponse & WithDiff): DiffResponse;
|
|
15
15
|
isVersion(result: DiffResponse | VersionResponse): result is VersionResponse;
|
|
16
16
|
isVersionWithDiff(result: DiffResponse | (VersionResponse & WithDiff)): result is VersionResponse & WithDiff;
|
|
17
17
|
pollingDelay(): Promise<void>;
|
|
18
|
-
run(file1: string, file2: string | undefined, documentation: string | undefined, hub: string | undefined, branch: string | undefined, token: string | undefined, format: string, expires: string | undefined): Promise<DiffResponse | undefined>;
|
|
18
|
+
run(file1: string, file2: string | undefined, documentation: string | undefined, hub: string | undefined, branch: string | undefined, token: string | undefined, format: string, expires: string | undefined, overlays: string[] | undefined): Promise<DiffResponse | undefined>;
|
|
19
19
|
waitResult(result: DiffResponse | VersionResponse, token: string | undefined, opts: {
|
|
20
20
|
format: string;
|
|
21
21
|
timeout: number;
|
package/dist/core/diff.js
CHANGED
|
@@ -22,11 +22,11 @@ export class Diff {
|
|
|
22
22
|
get pollingPeriod() {
|
|
23
23
|
return process.env.BUMP_POLLING_PERIOD ? Number(process.env.BUMP_POLLING_PERIOD) : 1000;
|
|
24
24
|
}
|
|
25
|
-
async createDiff(file1, file2, expires) {
|
|
25
|
+
async createDiff(file1, file2, expires, overlays) {
|
|
26
26
|
const api = await API.load(file1);
|
|
27
|
-
const [previous_definition, previous_references] = api.extractDefinition();
|
|
27
|
+
const [previous_definition, previous_references] = await api.extractDefinition(undefined, overlays);
|
|
28
28
|
const api2 = await API.load(file2);
|
|
29
|
-
const [definition, references] = api2.extractDefinition();
|
|
29
|
+
const [definition, references] = await api2.extractDefinition(undefined, overlays);
|
|
30
30
|
const request = {
|
|
31
31
|
definition,
|
|
32
32
|
expires_at: expires,
|
|
@@ -47,9 +47,9 @@ export class Diff {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
async createVersion(file, documentation, token, hub, branch_name, previous_version_id = undefined) {
|
|
50
|
+
async createVersion(file, documentation, token, hub, branch_name, previous_version_id = undefined, overlays) {
|
|
51
51
|
const api = await API.load(file);
|
|
52
|
-
const [definition, references] = api.extractDefinition();
|
|
52
|
+
const [definition, references] = await api.extractDefinition(undefined, overlays);
|
|
53
53
|
const request = {
|
|
54
54
|
branch_name,
|
|
55
55
|
definition,
|
|
@@ -98,12 +98,12 @@ export class Diff {
|
|
|
98
98
|
async pollingDelay() {
|
|
99
99
|
await this.delay(this.pollingPeriod);
|
|
100
100
|
}
|
|
101
|
-
async run(file1, file2, documentation, hub, branch, token, format, expires) {
|
|
101
|
+
async run(file1, file2, documentation, hub, branch, token, format, expires, overlays) {
|
|
102
102
|
if (!this._config)
|
|
103
103
|
this._config = await Config.load(resolve(import.meta.dirname, './../../'));
|
|
104
104
|
let diffVersion;
|
|
105
105
|
if (file2 && (!documentation || !token)) {
|
|
106
|
-
diffVersion = await this.createDiff(file1, file2, expires);
|
|
106
|
+
diffVersion = await this.createDiff(file1, file2, expires, overlays);
|
|
107
107
|
}
|
|
108
108
|
else {
|
|
109
109
|
if (!documentation || !token) {
|
package/dist/core/overlay.js
CHANGED
|
@@ -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/definition.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ declare class API {
|
|
|
19
19
|
static isOpenAPIOverlay(definition: JSONSchema4Object | JSONSchema6Object): definition is OpenAPIOverlay;
|
|
20
20
|
static load(path: string): Promise<API>;
|
|
21
21
|
applyOverlay(overlayPath: string): Promise<void>;
|
|
22
|
-
extractDefinition(outputPath?: string): [string, APIReference[]]
|
|
22
|
+
extractDefinition(outputPath?: string, overlays?: string[] | undefined): Promise<[string, APIReference[]]>;
|
|
23
23
|
getSpec(definition: APIDefinition): SpecSchema;
|
|
24
24
|
getSpecName(definition: APIDefinition): string;
|
|
25
25
|
getVersion(definition: APIDefinition): string;
|
package/dist/definition.js
CHANGED
|
@@ -124,9 +124,24 @@ class API {
|
|
|
124
124
|
if (!API.isOpenAPIOverlay(overlayDefinition)) {
|
|
125
125
|
throw new Error(`${overlayPath} does not look like an OpenAPI overlay`);
|
|
126
126
|
}
|
|
127
|
+
for (const reference of overlay.references) {
|
|
128
|
+
// Keep overlay reference data only if there's no existing refs with the same location
|
|
129
|
+
if (this.references.every((existing) => existing.location !== reference.location)) {
|
|
130
|
+
this.references.push(reference);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
127
133
|
this.overlayedDefinition = await new Overlay().run(currentDefinition, overlayDefinition);
|
|
128
134
|
}
|
|
129
|
-
extractDefinition(outputPath) {
|
|
135
|
+
async extractDefinition(outputPath, overlays) {
|
|
136
|
+
if (overlays) {
|
|
137
|
+
/* eslint-disable no-await-in-loop */
|
|
138
|
+
// Alternatively we can apply all overlays in parallel
|
|
139
|
+
// https://stackoverflow.com/questions/48957022/unexpected-await-inside-a-loop-no-await-in-loop
|
|
140
|
+
for (const overlayFile of overlays) {
|
|
141
|
+
await this.applyOverlay(overlayFile);
|
|
142
|
+
}
|
|
143
|
+
/* eslint-enable no-await-in-loop */
|
|
144
|
+
}
|
|
130
145
|
const references = [];
|
|
131
146
|
for (let i = 0; i < this.references.length; i++) {
|
|
132
147
|
const reference = this.references[i];
|
|
@@ -220,7 +235,7 @@ class API {
|
|
|
220
235
|
serializeDefinition(outputPath) {
|
|
221
236
|
if (this.overlayedDefinition) {
|
|
222
237
|
const { comments } = parseWithPointers(this.rawDefinition, { attachComments: true });
|
|
223
|
-
const dumpOptions = { comments, lineWidth: Number.POSITIVE_INFINITY };
|
|
238
|
+
const dumpOptions = { comments, lineWidth: Number.POSITIVE_INFINITY, noRefs: true };
|
|
224
239
|
return this.guessFormat(outputPath) === 'json'
|
|
225
240
|
? JSON.stringify(this.overlayedDefinition)
|
|
226
241
|
: safeStringify(this.overlayedDefinition, dumpOptions);
|
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, };
|
package/oclif.manifest.json
CHANGED
|
@@ -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"
|
|
@@ -186,12 +192,19 @@
|
|
|
186
192
|
"multiple": false,
|
|
187
193
|
"type": "option"
|
|
188
194
|
},
|
|
195
|
+
"overlay": {
|
|
196
|
+
"char": "o",
|
|
197
|
+
"description": "Path or URL of overlay file(s) to apply before deploying",
|
|
198
|
+
"name": "overlay",
|
|
199
|
+
"hasDynamicHelp": false,
|
|
200
|
+
"multiple": true,
|
|
201
|
+
"type": "option"
|
|
202
|
+
},
|
|
189
203
|
"token": {
|
|
190
204
|
"char": "t",
|
|
191
205
|
"description": "Documentation or Hub token. Can be provided via BUMP_TOKEN environment variable",
|
|
192
206
|
"name": "token",
|
|
193
207
|
"required": false,
|
|
194
|
-
"default": "99f52837852249b328c0a00249f846a3",
|
|
195
208
|
"hasDynamicHelp": false,
|
|
196
209
|
"multiple": false,
|
|
197
210
|
"type": "option"
|
|
@@ -279,5 +292,5 @@
|
|
|
279
292
|
"strict": true
|
|
280
293
|
}
|
|
281
294
|
},
|
|
282
|
-
"version": "2.9.
|
|
295
|
+
"version": "2.9.6"
|
|
283
296
|
}
|
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
|
+
"version": "2.9.6",
|
|
5
5
|
"author": "Paul Bonaud <paulr@bump.sh>",
|
|
6
6
|
"bin": {
|
|
7
7
|
"bump": "./bin/run.js"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"np": "^10.1.0",
|
|
30
30
|
"nyc": "^17.1.0",
|
|
31
31
|
"oclif": "^4",
|
|
32
|
-
"shx": "^0.
|
|
32
|
+
"shx": "^0.4.0",
|
|
33
33
|
"sinon": "^19.0.2",
|
|
34
34
|
"ts-node": "^10",
|
|
35
35
|
"typescript": "^5"
|