api 6.1.1 → 7.0.0-alpha.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.
- package/LICENSE +1 -1
- package/README.md +0 -12
- package/package.json +14 -32
- package/src/bin.ts +1 -1
- package/src/{cli/codegen → codegen}/language.ts +3 -2
- package/src/{cli/codegen → codegen}/languages/typescript/util.ts +1 -1
- package/src/{cli/codegen → codegen}/languages/typescript.ts +31 -32
- package/src/{cli/commands → commands}/install.ts +1 -1
- package/src/fetcher.ts +4 -5
- package/src/packageInfo.ts +1 -1
- package/src/{cli/storage.ts → storage.ts} +13 -9
- package/tsconfig.json +3 -13
- package/dist/bin.d.ts +0 -1
- package/dist/bin.js +0 -91
- package/dist/cache.d.ts +0 -68
- package/dist/cache.js +0 -198
- package/dist/cli/codegen/index.d.ts +0 -4
- package/dist/cli/codegen/index.js +0 -23
- package/dist/cli/codegen/language.d.ts +0 -27
- package/dist/cli/codegen/language.js +0 -32
- package/dist/cli/codegen/languages/typescript/util.d.ts +0 -20
- package/dist/cli/codegen/languages/typescript/util.js +0 -176
- package/dist/cli/codegen/languages/typescript.d.ts +0 -111
- package/dist/cli/codegen/languages/typescript.js +0 -821
- package/dist/cli/commands/index.d.ts +0 -4
- package/dist/cli/commands/index.js +0 -9
- package/dist/cli/commands/install.d.ts +0 -3
- package/dist/cli/commands/install.js +0 -236
- package/dist/cli/lib/prompt.d.ts +0 -9
- package/dist/cli/lib/prompt.js +0 -81
- package/dist/cli/logger.d.ts +0 -1
- package/dist/cli/logger.js +0 -16
- package/dist/cli/storage.d.ts +0 -105
- package/dist/cli/storage.js +0 -277
- package/dist/core/errors/fetchError.d.ts +0 -12
- package/dist/core/errors/fetchError.js +0 -36
- package/dist/core/getJSONSchemaDefaults.d.ts +0 -14
- package/dist/core/getJSONSchemaDefaults.js +0 -61
- package/dist/core/index.d.ts +0 -40
- package/dist/core/index.js +0 -168
- package/dist/core/parseResponse.d.ts +0 -6
- package/dist/core/parseResponse.js +0 -71
- package/dist/core/prepareAuth.d.ts +0 -5
- package/dist/core/prepareAuth.js +0 -84
- package/dist/core/prepareParams.d.ts +0 -21
- package/dist/core/prepareParams.js +0 -425
- package/dist/core/prepareServer.d.ts +0 -10
- package/dist/core/prepareServer.js +0 -47
- package/dist/fetcher.d.ts +0 -54
- package/dist/fetcher.js +0 -164
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -259
- package/dist/packageInfo.d.ts +0 -2
- package/dist/packageInfo.js +0 -6
- package/src/.sink.d.ts +0 -1
- package/src/cache.ts +0 -193
- package/src/core/errors/fetchError.ts +0 -31
- package/src/core/getJSONSchemaDefaults.ts +0 -74
- package/src/core/index.ts +0 -148
- package/src/core/parseResponse.ts +0 -26
- package/src/core/prepareAuth.ts +0 -109
- package/src/core/prepareParams.ts +0 -415
- package/src/core/prepareServer.ts +0 -48
- package/src/index.ts +0 -203
- package/src/typings.d.ts +0 -2
- /package/src/{cli/codegen → codegen}/index.ts +0 -0
- /package/src/{cli/commands → commands}/index.ts +0 -0
- /package/src/{cli/lib → lib}/prompt.ts +0 -0
- /package/src/{cli/logger.ts → logger.ts} +0 -0
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
exports.__esModule = true;
|
|
6
|
-
var install_1 = __importDefault(require("./install"));
|
|
7
|
-
exports["default"] = {
|
|
8
|
-
install: install_1["default"]
|
|
9
|
-
};
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
exports.__esModule = true;
|
|
42
|
-
var commander_1 = require("commander");
|
|
43
|
-
var figures_1 = __importDefault(require("figures"));
|
|
44
|
-
var oas_1 = __importDefault(require("oas"));
|
|
45
|
-
var ora_1 = __importDefault(require("ora"));
|
|
46
|
-
var fetcher_1 = __importDefault(require("../../fetcher"));
|
|
47
|
-
var codegen_1 = __importDefault(require("../codegen"));
|
|
48
|
-
var prompt_1 = __importDefault(require("../lib/prompt"));
|
|
49
|
-
var logger_1 = __importDefault(require("../logger"));
|
|
50
|
-
var storage_1 = __importDefault(require("../storage"));
|
|
51
|
-
// @todo log logs to `.api/.logs` and have `.logs` ignored
|
|
52
|
-
var cmd = new commander_1.Command();
|
|
53
|
-
cmd
|
|
54
|
-
.name('install')
|
|
55
|
-
.description('install an API SDK into your codebase')
|
|
56
|
-
.argument('<uri>', 'an API to install')
|
|
57
|
-
.option('-i, --identifier <identifier>', 'API identifier (eg. `@api/petstore`)')
|
|
58
|
-
.addOption(new commander_1.Option('-l, --lang <language>', 'SDK language').choices([
|
|
59
|
-
'js',
|
|
60
|
-
'js-cjs',
|
|
61
|
-
'js-esm',
|
|
62
|
-
'ts',
|
|
63
|
-
]))
|
|
64
|
-
.addOption(new commander_1.Option('-y, --yes', 'Automatically answer "yes" to any prompts printed'))
|
|
65
|
-
.action(function (uri, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
66
|
-
var language, identifier, spinner, storage, oas, generator, sdkSource, err_1;
|
|
67
|
-
return __generator(this, function (_a) {
|
|
68
|
-
switch (_a.label) {
|
|
69
|
-
case 0:
|
|
70
|
-
if (!options.lang) return [3 /*break*/, 1];
|
|
71
|
-
language = options.lang;
|
|
72
|
-
return [3 /*break*/, 3];
|
|
73
|
-
case 1: return [4 /*yield*/, (0, prompt_1["default"])({
|
|
74
|
-
type: 'select',
|
|
75
|
-
name: 'value',
|
|
76
|
-
message: 'What language would you like to generate an SDK for?',
|
|
77
|
-
choices: [
|
|
78
|
-
{ title: 'TypeScript', value: 'ts' },
|
|
79
|
-
{ title: 'JavaScript', value: 'js' },
|
|
80
|
-
],
|
|
81
|
-
initial: 1
|
|
82
|
-
})];
|
|
83
|
-
case 2:
|
|
84
|
-
(language = (_a.sent()).value);
|
|
85
|
-
_a.label = 3;
|
|
86
|
-
case 3:
|
|
87
|
-
if (!(language === 'js')) return [3 /*break*/, 5];
|
|
88
|
-
return [4 /*yield*/, (0, prompt_1["default"])({
|
|
89
|
-
type: 'select',
|
|
90
|
-
name: 'value',
|
|
91
|
-
message: 'How are your project imports and exports structured?',
|
|
92
|
-
choices: [
|
|
93
|
-
{ title: 'CommonJS', description: 'require/exports', value: 'cjs' },
|
|
94
|
-
{ title: 'ECMAScript Modules', description: 'import/export', value: 'esm' },
|
|
95
|
-
],
|
|
96
|
-
initial: 0,
|
|
97
|
-
format: function (sel) { return (sel === 'cjs' ? 'js-cjs' : 'js-esm'); }
|
|
98
|
-
})];
|
|
99
|
-
case 4:
|
|
100
|
-
(language = (_a.sent()).value);
|
|
101
|
-
_a.label = 5;
|
|
102
|
-
case 5:
|
|
103
|
-
// @todo let them know that we're going to be creating a `.api/ directory
|
|
104
|
-
// @todo detect if they have a gitigore and .npmignore and if .api woudl be ignored by that
|
|
105
|
-
// @todo don't support swagger files without upconverting them
|
|
106
|
-
if (storage_1["default"].isInLockFile({ source: uri })) {
|
|
107
|
-
// @todo
|
|
108
|
-
// logger(`It looks like you already have this API installed. Would you like to update it?`);
|
|
109
|
-
}
|
|
110
|
-
if (!options.identifier) return [3 /*break*/, 6];
|
|
111
|
-
// `Storage.isIdentifierValid` will throw an exception if an identifier is invalid.
|
|
112
|
-
if (storage_1["default"].isIdentifierValid(options.identifier)) {
|
|
113
|
-
identifier = options.identifier;
|
|
114
|
-
}
|
|
115
|
-
return [3 /*break*/, 9];
|
|
116
|
-
case 6:
|
|
117
|
-
if (!fetcher_1["default"].isAPIRegistryUUID(uri)) return [3 /*break*/, 7];
|
|
118
|
-
identifier = fetcher_1["default"].getProjectPrefixFromRegistryUUID(uri);
|
|
119
|
-
return [3 /*break*/, 9];
|
|
120
|
-
case 7: return [4 /*yield*/, (0, prompt_1["default"])({
|
|
121
|
-
type: 'text',
|
|
122
|
-
name: 'value',
|
|
123
|
-
message: 'What would you like to identify this API as? This will be how you import the SDK. (e.g. entering `petstore` would result in `@api/petstore`)',
|
|
124
|
-
validate: function (value) {
|
|
125
|
-
if (!value) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
try {
|
|
129
|
-
return storage_1["default"].isIdentifierValid(value, true);
|
|
130
|
-
}
|
|
131
|
-
catch (err) {
|
|
132
|
-
return err.message;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
})];
|
|
136
|
-
case 8:
|
|
137
|
-
(identifier = (_a.sent()).value);
|
|
138
|
-
_a.label = 9;
|
|
139
|
-
case 9:
|
|
140
|
-
if (!identifier) {
|
|
141
|
-
(0, logger_1["default"])('You must tell us what you would like to identify this API as in order to install it.', true);
|
|
142
|
-
process.exit(1);
|
|
143
|
-
}
|
|
144
|
-
spinner = (0, ora_1["default"])('Fetching your API').start();
|
|
145
|
-
storage = new storage_1["default"](uri, identifier);
|
|
146
|
-
return [4 /*yield*/, storage
|
|
147
|
-
.load()
|
|
148
|
-
.then(function (res) {
|
|
149
|
-
spinner.succeed(spinner.text);
|
|
150
|
-
return res;
|
|
151
|
-
})
|
|
152
|
-
.then(oas_1["default"].init)["catch"](function (err) {
|
|
153
|
-
// @todo cleanup installed files
|
|
154
|
-
spinner.fail(spinner.text);
|
|
155
|
-
(0, logger_1["default"])(err.message, true);
|
|
156
|
-
process.exit(1);
|
|
157
|
-
})];
|
|
158
|
-
case 10:
|
|
159
|
-
oas = _a.sent();
|
|
160
|
-
// @todo look for a prettier config and if we find one ask them if we should use it
|
|
161
|
-
spinner = (0, ora_1["default"])('Generating your SDK').start();
|
|
162
|
-
generator = (0, codegen_1["default"])(language, oas, './openapi.json', identifier);
|
|
163
|
-
return [4 /*yield*/, generator
|
|
164
|
-
.generator()
|
|
165
|
-
.then(function (res) {
|
|
166
|
-
spinner.succeed(spinner.text);
|
|
167
|
-
return res;
|
|
168
|
-
})["catch"](function (err) {
|
|
169
|
-
// @todo cleanup installed files
|
|
170
|
-
spinner.fail(spinner.text);
|
|
171
|
-
(0, logger_1["default"])(err.message, true);
|
|
172
|
-
process.exit(1);
|
|
173
|
-
})];
|
|
174
|
-
case 11:
|
|
175
|
-
sdkSource = _a.sent();
|
|
176
|
-
spinner = (0, ora_1["default"])('Saving your SDK into your codebase').start();
|
|
177
|
-
return [4 /*yield*/, storage
|
|
178
|
-
.saveSourceFiles(sdkSource)
|
|
179
|
-
.then(function () {
|
|
180
|
-
spinner.succeed(spinner.text);
|
|
181
|
-
})["catch"](function (err) {
|
|
182
|
-
// @todo cleanup installed files
|
|
183
|
-
spinner.fail(spinner.text);
|
|
184
|
-
(0, logger_1["default"])(err.message, true);
|
|
185
|
-
process.exit(1);
|
|
186
|
-
})];
|
|
187
|
-
case 12:
|
|
188
|
-
_a.sent();
|
|
189
|
-
if (!generator.hasRequiredPackages()) return [3 /*break*/, 18];
|
|
190
|
-
(0, logger_1["default"])("".concat(figures_1["default"].warning, " This generator requires some packages to be installed alongside it:"));
|
|
191
|
-
Object.entries(generator.requiredPackages).forEach(function (_a) {
|
|
192
|
-
var pkg = _a[0], pkgInfo = _a[1];
|
|
193
|
-
(0, logger_1["default"])(" ".concat(figures_1["default"].pointerSmall, " ").concat(pkg, ": ").concat(pkgInfo.reason, " ").concat(pkgInfo.url));
|
|
194
|
-
});
|
|
195
|
-
if (!!options.yes) return [3 /*break*/, 14];
|
|
196
|
-
return [4 /*yield*/, (0, prompt_1["default"])({
|
|
197
|
-
type: 'confirm',
|
|
198
|
-
name: 'value',
|
|
199
|
-
message: 'OK to proceed with package installation?',
|
|
200
|
-
initial: true
|
|
201
|
-
}).then(function (_a) {
|
|
202
|
-
var value = _a.value;
|
|
203
|
-
if (!value) {
|
|
204
|
-
// @todo cleanup installed files
|
|
205
|
-
(0, logger_1["default"])('Installation cancelled.', true);
|
|
206
|
-
process.exit(1);
|
|
207
|
-
}
|
|
208
|
-
})];
|
|
209
|
-
case 13:
|
|
210
|
-
_a.sent();
|
|
211
|
-
_a.label = 14;
|
|
212
|
-
case 14:
|
|
213
|
-
spinner = (0, ora_1["default"])('Installing required packages').start();
|
|
214
|
-
_a.label = 15;
|
|
215
|
-
case 15:
|
|
216
|
-
_a.trys.push([15, 17, , 18]);
|
|
217
|
-
return [4 /*yield*/, generator.installer(storage)];
|
|
218
|
-
case 16:
|
|
219
|
-
_a.sent();
|
|
220
|
-
spinner.succeed(spinner.text);
|
|
221
|
-
return [3 /*break*/, 18];
|
|
222
|
-
case 17:
|
|
223
|
-
err_1 = _a.sent();
|
|
224
|
-
// @todo cleanup installed files
|
|
225
|
-
spinner.fail(spinner.text);
|
|
226
|
-
(0, logger_1["default"])(err_1.message, true);
|
|
227
|
-
process.exit(1);
|
|
228
|
-
return [3 /*break*/, 18];
|
|
229
|
-
case 18:
|
|
230
|
-
(0, logger_1["default"])('🚀 All done!');
|
|
231
|
-
return [2 /*return*/];
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
}); })
|
|
235
|
-
.addHelpText('after', "\nExamples:\n $ api install @developers/v2.0#nysezql0wwo236\n $ api install https://raw.githubusercontent.com/readmeio/oas-examples/main/3.0/json/petstore-simple.json\n $ api install ./petstore.json");
|
|
236
|
-
exports["default"] = cmd;
|
package/dist/cli/lib/prompt.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import prompts from 'prompts';
|
|
2
|
-
/**
|
|
3
|
-
* The `prompts` library doesn't always interpret CTRL+C and release the terminal back to the user
|
|
4
|
-
* so we need handle this ourselves. This function is just a simple overload of the main `prompts`
|
|
5
|
-
* import that we use.
|
|
6
|
-
*
|
|
7
|
-
* @see {@link https://github.com/terkelg/prompts/issues/252}
|
|
8
|
-
*/
|
|
9
|
-
export default function promptTerminal<T extends string = string>(question: prompts.PromptObject<T>, options?: prompts.Options): Promise<prompts.Answers<T>>;
|
package/dist/cli/lib/prompt.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
exports.__esModule = true;
|
|
53
|
-
var prompts_1 = __importDefault(require("prompts"));
|
|
54
|
-
/**
|
|
55
|
-
* The `prompts` library doesn't always interpret CTRL+C and release the terminal back to the user
|
|
56
|
-
* so we need handle this ourselves. This function is just a simple overload of the main `prompts`
|
|
57
|
-
* import that we use.
|
|
58
|
-
*
|
|
59
|
-
* @see {@link https://github.com/terkelg/prompts/issues/252}
|
|
60
|
-
*/
|
|
61
|
-
function promptTerminal(question, options) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
-
var enableTerminalCursor, onState;
|
|
64
|
-
return __generator(this, function (_a) {
|
|
65
|
-
enableTerminalCursor = function () {
|
|
66
|
-
process.stdout.write('\x1B[?25h');
|
|
67
|
-
};
|
|
68
|
-
onState = function (state) {
|
|
69
|
-
if (state.aborted) {
|
|
70
|
-
// If we don't re-enable the terminal cursor before exiting the program, the cursor will
|
|
71
|
-
// remain hidden.
|
|
72
|
-
enableTerminalCursor();
|
|
73
|
-
process.stdout.write('\n');
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
return [2 /*return*/, (0, prompts_1["default"])(__assign(__assign({}, question), { onState: onState }), options)];
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
exports["default"] = promptTerminal;
|
package/dist/cli/logger.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function logger(log: string, error?: boolean): void;
|
package/dist/cli/logger.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
exports.__esModule = true;
|
|
6
|
-
/* eslint-disable no-console */
|
|
7
|
-
var chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
function logger(log, error) {
|
|
9
|
-
if (error) {
|
|
10
|
-
console.error(chalk_1["default"].red(log));
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
console.log(log);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports["default"] = logger;
|
package/dist/cli/storage.d.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import type { OASDocument } from 'oas/dist/rmoas.types';
|
|
2
|
-
import Fetcher from '../fetcher';
|
|
3
|
-
export default class Storage {
|
|
4
|
-
static dir: string;
|
|
5
|
-
static lockfile: false | Lockfile;
|
|
6
|
-
/**
|
|
7
|
-
* This is the original source that the file came from (relative/absolute file path, URL, ReadMe
|
|
8
|
-
* registry UUID, etc.).
|
|
9
|
-
*/
|
|
10
|
-
source: string;
|
|
11
|
-
identifier: string;
|
|
12
|
-
fetcher: Fetcher;
|
|
13
|
-
constructor(source: string, identifier?: string);
|
|
14
|
-
static getLockfilePath(): string;
|
|
15
|
-
static getAPIsDir(): string;
|
|
16
|
-
static setStorageDir(dir?: string): void;
|
|
17
|
-
/**
|
|
18
|
-
* Reset the state of the entire storage system.
|
|
19
|
-
*
|
|
20
|
-
* This will completely destroy the contents of the `.api/` directory!
|
|
21
|
-
*/
|
|
22
|
-
static reset(): Promise<void>;
|
|
23
|
-
static getDefaultLockfile(): Lockfile;
|
|
24
|
-
static generateIntegrityHash(definition: OASDocument): string;
|
|
25
|
-
static getLockfile(): Lockfile;
|
|
26
|
-
static isIdentifierValid(identifier: string, prefixWithAPINamespace?: boolean): boolean;
|
|
27
|
-
static isInLockFile(search: {
|
|
28
|
-
identifier?: string;
|
|
29
|
-
source?: string;
|
|
30
|
-
}): false | LockfileAPI;
|
|
31
|
-
setIdentifier(identifier: string): void;
|
|
32
|
-
/**
|
|
33
|
-
* Determine if the current spec + identifier we're working with is already in the lockfile.
|
|
34
|
-
*/
|
|
35
|
-
isInLockfile(): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Retrieve the lockfile record for the current spec + identifier if it exists in the lockfile.
|
|
38
|
-
*/
|
|
39
|
-
getFromLockfile(): LockfileAPI;
|
|
40
|
-
getIdentifierStorageDir(): string;
|
|
41
|
-
getAPIDefinition(): any;
|
|
42
|
-
saveSourceFiles(files: Record<string, string>): Promise<unknown>;
|
|
43
|
-
load(): Promise<OASDocument>;
|
|
44
|
-
/**
|
|
45
|
-
* @example <caption>Storage directory structure</caption>
|
|
46
|
-
* .api/
|
|
47
|
-
* ├── api.json // The `package-lock.json` equivalent that records everything that's
|
|
48
|
-
* | // installed, when it was installed, what the original source was,
|
|
49
|
-
* | // and what version of `api` was used.
|
|
50
|
-
* └── apis/
|
|
51
|
-
* ├── readme/
|
|
52
|
-
* | ├── node_modules/
|
|
53
|
-
* │ ├── index.js // We may offer the option to export a raw TS file for folks who want
|
|
54
|
-
* | | // that, but for now it'll be a compiled JS file.
|
|
55
|
-
* │ ├── index.d.ts // All types for their SDK, ready to use in an IDE.
|
|
56
|
-
* │ |── openapi.json
|
|
57
|
-
* │ └── package.json
|
|
58
|
-
* └── petstore/
|
|
59
|
-
* ├── node_modules/
|
|
60
|
-
* ├── index.js
|
|
61
|
-
* ├── index.d.ts
|
|
62
|
-
* ├── openapi.json
|
|
63
|
-
* └── package.json
|
|
64
|
-
*
|
|
65
|
-
*/
|
|
66
|
-
save(spec: OASDocument): OASDocument;
|
|
67
|
-
}
|
|
68
|
-
export interface Lockfile {
|
|
69
|
-
apis: LockfileAPI[];
|
|
70
|
-
/**
|
|
71
|
-
* The `api.json` schema version. This will only ever change if we introduce breaking changes to
|
|
72
|
-
* this store.
|
|
73
|
-
*/
|
|
74
|
-
version: '1.0';
|
|
75
|
-
}
|
|
76
|
-
export interface LockfileAPI {
|
|
77
|
-
/**
|
|
78
|
-
* A unique identifier of the API. This'll be used to do requires on `@api/<identifier>` and also
|
|
79
|
-
* where the SDK code will be located in `.api/apis/<identifier>`.
|
|
80
|
-
*
|
|
81
|
-
* @example petstore
|
|
82
|
-
*/
|
|
83
|
-
identifier: string;
|
|
84
|
-
/**
|
|
85
|
-
* The version of `api` that was used to install this SDK.
|
|
86
|
-
*
|
|
87
|
-
* @example 5.0.0
|
|
88
|
-
*/
|
|
89
|
-
installerVersion: string;
|
|
90
|
-
/**
|
|
91
|
-
* An integrity hash that will be used to determine on `npx api update` calls if the API has
|
|
92
|
-
* changed since the SDK was last generated.
|
|
93
|
-
*
|
|
94
|
-
* @example sha512-ld+djZk8uRWmzXC+JYla1PTBScg0NjP/8x9vOOKRW+DuJ3NNMRjrpfbY7T77Jgnc87dZZsU49robbQfYe3ukug==
|
|
95
|
-
*/
|
|
96
|
-
integrity: string;
|
|
97
|
-
/**
|
|
98
|
-
* The original source that was used to generate the SDK with.
|
|
99
|
-
*
|
|
100
|
-
* @example https://raw.githubusercontent.com/readmeio/oas-examples/main/3.0/json/petstore-simple.json
|
|
101
|
-
* @example ./petstore.json
|
|
102
|
-
* @example @developers/v2.0#nysezql0wwo236
|
|
103
|
-
*/
|
|
104
|
-
source: string;
|
|
105
|
-
}
|