bump-cli 2.8.4 → 2.9.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.
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 -98
  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 +283 -1
  42. package/package.json +65 -57
  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,138 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefinitionDirectory = void 0;
4
- const tslib_1 = require("tslib");
5
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
6
- const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
7
- const fs_1 = require("fs");
8
- const node_path_1 = require("node:path");
9
- const p = (0, tslib_1.__importStar)(require("@clack/prompts"));
10
- const errors_1 = require("@oclif/errors");
11
- const cli_1 = require("../cli");
12
- const definition_1 = require("../definition");
13
- const file_1 = require("./utils/file");
14
- const prompts_1 = require("../core/utils/prompts");
15
- class DefinitionDirectory {
16
- constructor(directory, filenamePattern) {
17
- this.path = (0, node_path_1.resolve)(directory);
18
- this.definitions = [];
19
- // Transform basic patterns '*' or '{text}' into a real RegExp
20
- this.filenamePattern = new RegExp('^' + filenamePattern.replace('*', '.*?').replace(/{.*?}/, '(?<slug>.+?)') + '$');
21
- this.buildNewFilename = (slug) => filenamePattern.replace('*', '').replace(/{.*?}/, slug);
22
- this.humanFilenamePattern = filenamePattern.replace(/{(.*?)}/, `${chalk_1.default.inverse('{$1}')}`);
23
- }
24
- async readDefinitions() {
25
- var e_1, _a;
26
- try {
27
- for (var _b = (0, tslib_1.__asyncValues)(file_1.File.listValidConventionFiles(this.path, this.filenamePattern)), _c; _c = await _b.next(), !_c.done;) {
28
- const { value, filename } = _c.value;
29
- const file = (0, node_path_1.join)(this.path, value);
30
- /* We already check the filenamePattern match inside the
31
- `File.listValidConventionFiles` method so we are sure the group
32
- matched exists. */
33
- /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
34
- const slug = filename.match(this.filenamePattern).groups.slug;
35
- const definition = await definition_1.API.load(file);
36
- this.definitions.push({
37
- file,
38
- definition,
39
- slug,
40
- });
41
- }
42
- }
43
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
44
- finally {
45
- try {
46
- if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
47
- }
48
- finally { if (e_1) throw e_1.error; }
49
- }
50
- if (this.definitions.length) {
51
- cli_1.cli.info(chalk_1.default.underline(`We've found ${this.definitions.length} valid API definitions to deploy`));
52
- const subtree = cli_1.cli.tree();
53
- this.definitions.forEach(({ file, definition }) => subtree.insert(`${(0, node_path_1.basename)(file)} (${definition.specName} spec version ${definition.version})`));
54
- const tree = cli_1.cli.tree();
55
- tree.insert(this.path, subtree);
56
- tree.display();
57
- cli_1.cli.info('');
58
- }
59
- return this.definitions;
60
- }
61
- definitionsExists() {
62
- return !!this.definitions.length;
63
- }
64
- async sequentialMap(callback) {
65
- for (const definition of this.definitions) {
66
- await callback(definition);
67
- }
68
- return;
69
- }
70
- async renameToConvention(documentation) {
71
- const { file, slug } = documentation;
72
- if ((0, node_path_1.basename)(file, (0, node_path_1.extname)(file)).match(this.filenamePattern))
73
- return;
74
- // Default convention is defined in the flags.ts file for the
75
- // 'filenamePattern' flag.
76
- const newFilename = this.buildNewFilename(slug);
77
- const newFile = `${(0, node_path_1.dirname)(file)}/${newFilename}${(0, node_path_1.extname)(file)}`;
78
- let confirm = true;
79
- await (0, prompts_1.confirm)(`Do you want to rename ${file} to ${newFile} (for later deployments)?`).catch(() => {
80
- confirm = false;
81
- });
82
- if (confirm) {
83
- await (0, fs_1.rename)(file, newFile, (err) => {
84
- if (err)
85
- throw err;
86
- cli_1.cli.styledSuccess(`Renamed ${file} to ${newFile}.`);
87
- });
88
- }
89
- return;
90
- }
91
- async interactiveSelection() {
92
- p.intro(`This interactive form will help you rename your API contrat files to follow the expected naming convention.\n${chalk_1.default.gray('│ ')}Once finished, the selected files will be deployed to Bump.sh.\n${chalk_1.default.gray('│ ')}\n${chalk_1.default.gray('│ ')}File naming convention: ${this.humanFilenamePattern}${chalk_1.default.dim('.[json|yml|yaml]')}\n`);
93
- const fileOptions = file_1.File.listInvalidConventionFiles(this.path, this.filenamePattern);
94
- if (!fileOptions.length) {
95
- throw new errors_1.CLIError(`No JSON or YAML files needing a rename were found in ${this.path}.\nAre you sure you need the ${chalk_1.default.dim('--interactive')} flag?`);
96
- }
97
- let shouldContinue = true;
98
- while (shouldContinue) {
99
- const filePrompt = {
100
- fileName: () => p.select({
101
- message: `Which file do you want to deploy from ${chalk_1.default.dim(this.path)}?`,
102
- options: fileOptions,
103
- }),
104
- };
105
- const groupPrompt = {
106
- /* Results type should be taken from the previous prompts
107
- * defined with clack/prompt */
108
- slug: ({ results }) => p.text({
109
- message: `What is the ${chalk_1.default.inverse('documentation slug')} for this ${chalk_1.default.dim(results.fileName)} file?`,
110
- }),
111
- };
112
- const prompt = await p.group(Object.assign(Object.assign(Object.assign({}, filePrompt), groupPrompt), { shouldContinue: () => p.confirm({ message: 'Do you want to select another file?' }) }), {
113
- onCancel: () => {
114
- p.cancel('Deploy cancelled.');
115
- process.exit(0);
116
- },
117
- });
118
- const file = (0, node_path_1.join)(this.path, prompt.fileName);
119
- const definition = await definition_1.API.load(file);
120
- this.d(`${file} looks like an ${definition.specName} spec version ${definition.version}`);
121
- this.definitions.push({
122
- file,
123
- definition,
124
- slug: prompt.slug,
125
- });
126
- shouldContinue = prompt.shouldContinue;
127
- }
128
- p.outro(`You're all set. Your deployments will start soon.`);
129
- return this.definitions;
130
- }
131
- // Function signature type taken from @types/debug
132
- // Debugger(formatter: any, ...args: any[]): void;
133
- /* eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any */
134
- d(formatter, ...args) {
135
- return (0, debug_1.default)(`bump-cli:core:interactive`)(formatter, ...args);
136
- }
137
- }
138
- exports.DefinitionDirectory = DefinitionDirectory;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.File = exports.isDir = void 0;
4
- const fs_1 = require("fs");
5
- const path_1 = require("path");
6
- const isDir = (path) => {
7
- try {
8
- return (0, fs_1.statSync)(path).isDirectory();
9
- }
10
- catch (e) {
11
- return false;
12
- }
13
- };
14
- exports.isDir = isDir;
15
- class File {
16
- static listValidConventionFiles(path, regex) {
17
- return File.listValidFormatFiles(path).filter(({ filename }) => {
18
- return filename.match(regex);
19
- });
20
- }
21
- static listInvalidConventionFiles(path, regex) {
22
- return File.listValidFormatFiles(path).filter(({ filename }) => {
23
- return !filename.match(regex);
24
- });
25
- }
26
- static listValidFormatFiles(path) {
27
- return (0, fs_1.readdirSync)(path)
28
- .filter((file) => {
29
- return File.supportedFormats.includes((0, path_1.extname)(file));
30
- })
31
- .map((file) => {
32
- return {
33
- value: file,
34
- label: (0, path_1.basename)(file),
35
- filename: (0, path_1.basename)(file, (0, path_1.extname)(file)),
36
- };
37
- });
38
- }
39
- }
40
- exports.File = File;
41
- File.supportedFormats = ['.yml', '.yaml', '.json'];
@@ -1 +0,0 @@
1
- export declare const confirm: (message?: string) => Promise<void>;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.confirm = void 0;
4
- const tslib_1 = require("tslib");
5
- const errors_1 = require("@oclif/errors");
6
- const p = (0, tslib_1.__importStar)(require("@clack/prompts"));
7
- const confirm = async (message = 'Continue?') => {
8
- const prompt = await p.group({
9
- shouldContinue: () => p.confirm({ message: message }),
10
- }, {
11
- onCancel: () => {
12
- p.cancel('Cancelled.');
13
- process.exit(0);
14
- },
15
- });
16
- if (!prompt.shouldContinue) {
17
- throw new errors_1.CLIError(`Cancelled`);
18
- }
19
- return;
20
- };
21
- exports.confirm = confirm;
package/lib/definition.js DELETED
@@ -1,218 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SupportedFormat = exports.API = void 0;
4
- const tslib_1 = require("tslib");
5
- const errors_1 = require("@oclif/errors");
6
- const json_schema_ref_parser_1 = (0, tslib_1.__importDefault)(require("@apidevtools/json-schema-ref-parser"));
7
- const options_1 = require("@apidevtools/json-schema-ref-parser/lib/options");
8
- const specs_1 = (0, tslib_1.__importDefault)(require("@asyncapi/specs"));
9
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
10
- const yaml_1 = require("@stoplight/yaml");
11
- const overlay_1 = require("./core/overlay");
12
- class SupportedFormat {
13
- }
14
- exports.SupportedFormat = SupportedFormat;
15
- SupportedFormat.openapi = {
16
- '2.0': require('oas-schemas/schemas/v2.0/schema.json'),
17
- '3.0': require('oas-schemas/schemas/v3.0/schema.json'),
18
- '3.1': require('oas-schemas/schemas/v3.1/schema.json'),
19
- };
20
- SupportedFormat.asyncapi = {
21
- '2.0': specs_1.default.schemas['2.0.0'],
22
- '2.1': specs_1.default.schemas['2.1.0'],
23
- '2.2': specs_1.default.schemas['2.2.0'],
24
- '2.3': specs_1.default.schemas['2.3.0'],
25
- '2.4': specs_1.default.schemas['2.4.0'],
26
- '2.5': specs_1.default.schemas['2.5.0'],
27
- '2.6': specs_1.default.schemas['2.6.0'],
28
- };
29
- class UnsupportedFormat extends errors_1.CLIError {
30
- constructor(message = '') {
31
- const compatOpenAPI = Object.keys(SupportedFormat.openapi).join(', ');
32
- const compatAsyncAPI = Object.keys(SupportedFormat.asyncapi).join(', ');
33
- const errorMsgs = [
34
- `Unsupported API specification (${message})`,
35
- `Please try again with an OpenAPI ${compatOpenAPI} or AsyncAPI ${compatAsyncAPI} file.`,
36
- ];
37
- super(errorMsgs.join('\n'));
38
- }
39
- }
40
- class API {
41
- constructor(location, $refs) {
42
- this.location = location;
43
- this.references = [];
44
- const [raw, parsed] = this.resolveContent($refs);
45
- this.rawDefinition = raw;
46
- this.definition = parsed;
47
- this.specName = this.getSpecName(parsed);
48
- this.version = this.getVersion(parsed);
49
- this.spec = this.getSpec(parsed);
50
- if (this.spec === undefined) {
51
- throw new UnsupportedFormat(`${this.specName} ${this.version}`);
52
- }
53
- }
54
- getSpec(definition) {
55
- if (API.isAsyncAPI(definition)) {
56
- return SupportedFormat.asyncapi[this.versionWithoutPatch()];
57
- }
58
- else if (API.isOpenAPIOverlay(definition)) {
59
- return { overlay: { type: 'string' } };
60
- }
61
- else {
62
- return SupportedFormat.openapi[this.versionWithoutPatch()];
63
- }
64
- }
65
- getSpecName(definition) {
66
- if (API.isAsyncAPI(definition)) {
67
- return 'AsyncAPI';
68
- }
69
- else {
70
- return 'OpenAPI';
71
- }
72
- }
73
- getVersion(definition) {
74
- if (API.isAsyncAPI(definition)) {
75
- return definition.asyncapi;
76
- }
77
- else {
78
- return (definition.openapi || definition.swagger);
79
- }
80
- }
81
- guessFormat(output) {
82
- return (output || this.location).endsWith('.json') ? 'json' : 'yaml';
83
- }
84
- versionWithoutPatch() {
85
- const [major, minor] = this.version.split('.', 3);
86
- return `${major}.${minor}`;
87
- }
88
- /* Resolve reference absolute paths to the main api location when possible */
89
- resolveRelativeLocation(absPath) {
90
- const url = (location) => {
91
- try {
92
- return new URL(location);
93
- }
94
- catch (_a) {
95
- return { hostname: '' };
96
- }
97
- };
98
- const definitionUrl = url(this.location);
99
- const refUrl = url(absPath);
100
- if (absPath.match(/^\//) || // Unix style filesystem path
101
- absPath.match(/^[a-zA-Z]+\:\\/) || // Windows style filesystem path
102
- (absPath.match(/^https?:\/\//) && definitionUrl.hostname === refUrl.hostname) // Same domain URLs
103
- ) {
104
- return path_1.default.relative(path_1.default.dirname(this.location), absPath);
105
- }
106
- else {
107
- return absPath;
108
- }
109
- }
110
- resolveContent($refs) {
111
- const values = $refs.values();
112
- let mainReference = { parsed: {}, raw: '' };
113
- for (const [absPath, reference] of Object.entries(values)) {
114
- if (absPath === this.location || absPath === path_1.default.resolve(this.location)) {
115
- // $refs.values is not properly typed so we need to force it
116
- // with the resulting type of our custom defined parser
117
- mainReference = reference;
118
- }
119
- else {
120
- // $refs.values is not properly typed so we need to force it
121
- // with the resulting type of our custom defined parser
122
- const { raw } = reference;
123
- if (!raw) {
124
- throw new UnsupportedFormat('Reference ${absPath} is empty');
125
- }
126
- this.references.push({
127
- location: this.resolveRelativeLocation(absPath),
128
- content: raw,
129
- });
130
- }
131
- }
132
- const { raw, parsed } = mainReference;
133
- if (!parsed || !(parsed instanceof Object) || !('info' in parsed)) {
134
- throw new UnsupportedFormat("Definition needs to be an object with at least an 'info' key");
135
- }
136
- if (!API.isOpenAPI(parsed) &&
137
- !API.isAsyncAPI(parsed) &&
138
- !API.isOpenAPIOverlay(parsed)) {
139
- throw new UnsupportedFormat();
140
- }
141
- return [raw, parsed];
142
- }
143
- serializeDefinition(outputPath) {
144
- if (this.overlayedDefinition) {
145
- let serializedDefinition;
146
- if (this.guessFormat(outputPath) == 'json') {
147
- serializedDefinition = JSON.stringify(this.overlayedDefinition);
148
- }
149
- else {
150
- serializedDefinition = (0, yaml_1.safeStringify)(this.overlayedDefinition);
151
- }
152
- return serializedDefinition;
153
- }
154
- else {
155
- return this.rawDefinition;
156
- }
157
- }
158
- static isOpenAPI(definition) {
159
- return (typeof definition.openapi === 'string' || typeof definition.swagger === 'string');
160
- }
161
- static isAsyncAPI(definition) {
162
- return 'asyncapi' in definition;
163
- }
164
- static isOpenAPIOverlay(definition) {
165
- return 'overlay' in definition;
166
- }
167
- extractDefinition(outputPath) {
168
- const references = [];
169
- for (let i = 0; i < this.references.length; i++) {
170
- const reference = this.references[i];
171
- references.push({
172
- location: reference.location,
173
- content: reference.content,
174
- });
175
- }
176
- return [this.serializeDefinition(outputPath), references];
177
- }
178
- async applyOverlay(overlayPath) {
179
- const overlay = await API.load(overlayPath);
180
- const overlayDefinition = overlay.definition;
181
- if (!API.isOpenAPIOverlay(overlayDefinition)) {
182
- throw new Error(`${overlayPath} does not look like an OpenAPI overlay`);
183
- }
184
- this.overlayedDefinition = await new overlay_1.Overlay().run(this.definition, overlayDefinition);
185
- }
186
- static async load(path) {
187
- const JSONParser = options_1.defaults.parse.json;
188
- const YAMLParser = options_1.defaults.parse.yaml;
189
- const TextParser = options_1.defaults.parse.text;
190
- // We override the default parsers from $RefParser to be able
191
- // to keep the raw content of the files parsed
192
- const withRawTextParser = (parser) => {
193
- return Object.assign(Object.assign({}, parser), { parse: async (file) => {
194
- const parsed = (await parser.parse(file));
195
- return { parsed, raw: TextParser.parse(file) };
196
- } });
197
- };
198
- return json_schema_ref_parser_1.default
199
- .resolve(path, {
200
- parse: {
201
- json: withRawTextParser(JSONParser),
202
- yaml: withRawTextParser(YAMLParser),
203
- text: Object.assign(Object.assign({}, TextParser), { parse: async (file) => {
204
- const parsed = await TextParser.parse(file);
205
- return { parsed, raw: parsed };
206
- }, canParse: ['.md', '.markdown'], encoding: 'utf8' }),
207
- },
208
- dereference: { circular: false },
209
- })
210
- .then(($refs) => {
211
- return new API(path, $refs);
212
- })
213
- .catch((err) => {
214
- throw new errors_1.CLIError(err);
215
- });
216
- }
217
- }
218
- exports.API = API;
package/lib/flags.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import { flags } from '@oclif/command';
2
- import * as Parser from '@oclif/parser';
3
- export * from '@oclif/command/lib/flags';
4
- declare const doc: flags.Definition<string>;
5
- declare const docName: flags.Definition<string>;
6
- declare const hub: flags.Definition<string>;
7
- declare const filenamePattern: flags.Definition<string>;
8
- declare const branch: flags.Definition<string>;
9
- declare const token: flags.Definition<string>;
10
- declare const autoCreate: (options?: {}) => Parser.flags.IBooleanFlag<boolean>;
11
- declare const interactive: (options?: {}) => Parser.flags.IBooleanFlag<boolean>;
12
- declare const dryRun: (options?: {}) => Parser.flags.IBooleanFlag<boolean>;
13
- declare const open: (options?: {}) => Parser.flags.IBooleanFlag<boolean>;
14
- declare const failOnBreaking: (options?: {}) => Parser.flags.IBooleanFlag<boolean>;
15
- declare const live: (options?: {}) => Parser.flags.IBooleanFlag<boolean>;
16
- declare const format: flags.Definition<string>;
17
- declare const expires: flags.Definition<string>;
18
- declare const out: flags.Definition<string>;
19
- declare const overlay: flags.Definition<string>;
20
- export { doc, docName, hub, branch, token, autoCreate, interactive, filenamePattern, dryRun, open, failOnBreaking, live, format, expires, out, overlay, };
package/lib/flags.js DELETED
@@ -1,116 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.overlay = exports.out = exports.expires = exports.format = exports.live = exports.failOnBreaking = exports.open = exports.dryRun = exports.filenamePattern = exports.interactive = exports.autoCreate = exports.token = exports.branch = exports.hub = exports.docName = exports.doc = void 0;
4
- const tslib_1 = require("tslib");
5
- const command_1 = require("@oclif/command");
6
- // Re-export oclif flags https://oclif.io/docs/flags
7
- (0, tslib_1.__exportStar)(require("@oclif/command/lib/flags"), exports);
8
- // Custom flags for bump-cli
9
- const doc = command_1.flags.build({
10
- char: 'd',
11
- description: 'Documentation public id or slug. Can be provided via BUMP_ID environment variable',
12
- default: () => {
13
- const envDoc = process.env.BUMP_ID;
14
- if (envDoc)
15
- return envDoc;
16
- // Search doc id in .bump/config.json file?
17
- },
18
- });
19
- exports.doc = doc;
20
- const docName = command_1.flags.build({
21
- char: 'n',
22
- description: 'Documentation name. Used with --auto-create flag.',
23
- dependsOn: ['auto-create'],
24
- });
25
- exports.docName = docName;
26
- const hub = command_1.flags.build({
27
- char: 'b',
28
- description: 'Hub id or slug. Can be provided via BUMP_HUB_ID environment variable',
29
- default: () => {
30
- const envHub = process.env.BUMP_HUB_ID;
31
- if (envHub)
32
- return envHub;
33
- // Search hub id in .bump/config.json file?
34
- },
35
- });
36
- exports.hub = hub;
37
- const filenamePattern = command_1.flags.build({
38
- description: `Pattern to extract the documentation slug from filenames when deploying a DIRECTORY. Pattern uses only '*' and '{slug}' as special characters to extract the slug from a filename without extension. Used with --hub flag only.`,
39
- default: '{slug}-api',
40
- });
41
- exports.filenamePattern = filenamePattern;
42
- const branch = command_1.flags.build({
43
- char: 'B',
44
- description: 'Branch name. Can be provided via BUMP_BRANCH_NAME environment variable',
45
- default: () => {
46
- const envBranch = process.env.BUMP_BRANCH_NAME;
47
- if (envBranch)
48
- return envBranch;
49
- },
50
- });
51
- exports.branch = branch;
52
- const token = command_1.flags.build({
53
- char: 't',
54
- required: true,
55
- description: 'Documentation or Hub token. Can be provided via BUMP_TOKEN environment variable',
56
- default: () => {
57
- const envToken = process.env.BUMP_TOKEN;
58
- if (envToken)
59
- return envToken;
60
- },
61
- });
62
- exports.token = token;
63
- const autoCreate = (options = {}) => {
64
- return command_1.flags.boolean(Object.assign({ description: 'Automatically create the documentation if needed (only available with a --hub flag). Documentation name can be provided with --doc-name flag. Default: false', dependsOn: ['hub'] }, options));
65
- };
66
- exports.autoCreate = autoCreate;
67
- const interactive = (options = {}) => {
68
- return command_1.flags.boolean(Object.assign({ description: "Interactively create a configuration file to deploy a Hub (only available with a --hub flag). This will start an interactive process if you don't have a CLI configuration file. Default: false", dependsOn: ['hub'] }, options));
69
- };
70
- exports.interactive = interactive;
71
- const dryRun = (options = {}) => {
72
- return command_1.flags.boolean(Object.assign({ 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' }, options));
73
- };
74
- exports.dryRun = dryRun;
75
- const open = (options = {}) => {
76
- return command_1.flags.boolean(Object.assign({ char: 'o', default: false }, options));
77
- };
78
- exports.open = open;
79
- const failOnBreaking = (options = {}) => {
80
- return command_1.flags.boolean(Object.assign({ char: 'F', description: 'Fail when diff contains a breaking change', default: () => {
81
- const envCi = process.env.CI;
82
- if (envCi) {
83
- return true;
84
- }
85
- else {
86
- return false;
87
- }
88
- } }, options));
89
- };
90
- exports.failOnBreaking = failOnBreaking;
91
- const live = (options = {}) => {
92
- return command_1.flags.boolean(Object.assign({ char: 'l', default: false }, options));
93
- };
94
- exports.live = live;
95
- const format = command_1.flags.build({
96
- char: 'f',
97
- description: 'Format in which to provide the diff result',
98
- default: 'text',
99
- options: ['text', 'markdown', 'json', 'html'],
100
- });
101
- exports.format = format;
102
- const expires = command_1.flags.build({
103
- char: 'e',
104
- description: "Specify a longer expiration date for public diffs (defaults to 1 day). Use iso8601 format to provide a date, or you can use `--expires 'never'` to keep the result live indefinitely.",
105
- });
106
- exports.expires = expires;
107
- const out = command_1.flags.build({
108
- char: 'o',
109
- description: 'Output file path',
110
- });
111
- exports.out = out;
112
- const overlay = command_1.flags.build({
113
- char: 'o',
114
- description: 'Path or URL of an overlay file to apply before deploying',
115
- });
116
- exports.overlay = overlay;
package/lib/index.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import { run } from '@oclif/command';
2
- import { Diff } from './core/diff';
3
- import { Overlay } from './core/overlay';
4
- import Deploy from './commands/deploy';
5
- import Preview from './commands/preview';
6
- export { VersionResponse, PreviewResponse, DiffResponse, WithDiff } from './api/models';
7
- export { run, Deploy, Diff, Preview, Overlay };
package/lib/index.js DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Overlay = exports.Preview = exports.Diff = exports.Deploy = exports.run = void 0;
4
- const tslib_1 = require("tslib");
5
- const command_1 = require("@oclif/command");
6
- Object.defineProperty(exports, "run", { enumerable: true, get: function () { return command_1.run; } });
7
- const diff_1 = require("./core/diff");
8
- Object.defineProperty(exports, "Diff", { enumerable: true, get: function () { return diff_1.Diff; } });
9
- const overlay_1 = require("./core/overlay");
10
- Object.defineProperty(exports, "Overlay", { enumerable: true, get: function () { return overlay_1.Overlay; } });
11
- const deploy_1 = (0, tslib_1.__importDefault)(require("./commands/deploy"));
12
- exports.Deploy = deploy_1.default;
13
- const preview_1 = (0, tslib_1.__importDefault)(require("./commands/preview"));
14
- exports.Preview = preview_1.default;
@@ -2,67 +2,67 @@ export interface PingResponse {
2
2
  pong?: string;
3
3
  }
4
4
  export interface PreviewResponse {
5
- id: string;
6
5
  expires_at?: string;
6
+ id: string;
7
7
  public_url?: string;
8
8
  }
9
9
  export interface InvalidDefinitionError {
10
- message?: string;
11
10
  errors: {
12
11
  [keys: string]: unknown;
13
12
  };
13
+ message?: string;
14
14
  }
15
15
  export interface PreviewRequest {
16
16
  definition: string;
17
17
  references?: Reference[];
18
18
  }
19
19
  export interface Reference {
20
- location?: string;
21
20
  content?: string;
21
+ location?: string;
22
22
  }
23
23
  export interface VersionRequest {
24
- documentation: string;
24
+ auto_create_documentation?: boolean;
25
+ branch_name?: string;
25
26
  definition: string;
26
- hub?: string;
27
+ documentation: string;
27
28
  documentation_name?: string;
28
- auto_create_documentation?: boolean;
29
+ hub?: string;
30
+ previous_version_id?: string;
29
31
  references?: Reference[];
30
32
  unpublished?: boolean;
31
- previous_version_id?: string;
32
- branch_name?: string;
33
33
  }
34
34
  export interface VersionResponse {
35
- id: string;
36
35
  doc_public_url?: string;
36
+ id: string;
37
37
  }
38
38
  export interface WithDiff {
39
+ diff_breaking?: boolean;
40
+ diff_details?: DiffItem[];
41
+ diff_markdown?: string;
39
42
  diff_public_url?: string;
40
43
  diff_summary?: string;
41
- diff_markdown?: string;
42
- diff_details?: DiffItem[];
43
- diff_breaking?: boolean;
44
44
  }
45
45
  export interface DiffRequest {
46
46
  definition: string;
47
- references?: Reference[];
47
+ expires_at?: string;
48
48
  previous_definition: string;
49
49
  previous_references?: Reference[];
50
- expires_at?: string;
50
+ references?: Reference[];
51
51
  }
52
52
  export interface DiffResponse {
53
- id: string;
54
- public_url?: string;
55
53
  breaking?: boolean;
56
- text?: string;
57
- markdown?: string;
58
54
  details?: DiffItem[];
59
55
  html?: string;
56
+ id: string;
57
+ markdown?: string;
58
+ public_url?: string;
59
+ text?: string;
60
60
  }
61
61
  export interface DiffItem {
62
+ breaking: boolean;
63
+ children: DiffItem[];
62
64
  id: string;
63
65
  name: string;
64
66
  status: string;
65
67
  type: string;
66
- breaking: boolean;
67
- children: DiffItem[];
68
68
  }