@redocly/cli
Advanced tools
Comparing version 1.0.0-beta.107 to 1.0.0-beta.108
@@ -76,4 +76,4 @@ "use strict"; | ||
} | ||
let joinedDef = {}; | ||
let potentialConflicts = { | ||
const joinedDef = {}; | ||
const potentialConflicts = { | ||
tags: {}, | ||
@@ -240,5 +240,3 @@ paths: {}, | ||
} | ||
for (const operation of Object.keys(paths[path])) { | ||
// @ts-ignore | ||
const pathOperation = paths[path][operation]; | ||
for (const [operation, pathOperation] of Object.entries(paths[path])) { | ||
joinedDef.paths[path][operation] = pathOperation; | ||
@@ -259,3 +257,3 @@ potentialConflicts.paths[path][operation] = [ | ||
} | ||
let { tags, security } = joinedDef.paths[path][operation]; | ||
const { tags, security } = joinedDef.paths[path][operation]; | ||
if (tags) { | ||
@@ -301,3 +299,3 @@ joinedDef.paths[path][operation].tags = tags.map((tag) => addPrefix(tag, tagsPrefix)); | ||
} | ||
for (const component of Object.keys(components)) { | ||
for (const [component, componentObj] of Object.entries(components)) { | ||
if (!potentialConflicts[COMPONENTS].hasOwnProperty(component)) { | ||
@@ -307,4 +305,2 @@ potentialConflicts[COMPONENTS][component] = {}; | ||
} | ||
// @ts-ignore | ||
const componentObj = components[component]; | ||
for (const item of Object.keys(componentObj)) { | ||
@@ -323,3 +319,2 @@ const componentPrefix = addPrefix(item, componentsPrefix); | ||
const xWebhooks = 'x-webhooks'; | ||
// @ts-ignore | ||
const openapiXWebhooks = openapi[xWebhooks]; | ||
@@ -342,3 +337,3 @@ if (openapiXWebhooks) { | ||
for (const operationKey of Object.keys(joinedDef[xWebhooks][webhook])) { | ||
let { tags } = joinedDef[xWebhooks][webhook][operationKey]; | ||
const { tags } = joinedDef[xWebhooks][webhook][operationKey]; | ||
if (tags) { | ||
@@ -383,3 +378,3 @@ joinedDef[xWebhooks][webhook][operationKey].tags = tags.map((tag) => addPrefix(tag, tagsPrefix)); | ||
for (let i = 0, len = files.length; i < len; i++) { | ||
let next = files[i + 1]; | ||
const next = files[i + 1]; | ||
if (next && doesComponentsDiffer(files[i], next)) { | ||
@@ -386,0 +381,0 @@ isDiffer = true; |
@@ -50,3 +50,3 @@ "use strict"; | ||
if (argv['generate-ignore-file']) { | ||
for (let m of results) { | ||
for (const m of results) { | ||
config.styleguide.addIgnore(m); | ||
@@ -53,0 +53,0 @@ totalIgnored++; |
@@ -97,3 +97,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let config = yield openapi_core_1.loadConfig(argv.config); | ||
const config = yield openapi_core_1.loadConfig(argv.config); | ||
const redoclyClient = new openapi_core_1.RedoclyClient(); | ||
@@ -116,3 +116,5 @@ isAuthorizedWithRedocly = yield redoclyClient.isAuthorizedWithRedocly(); | ||
return function executedFunction(...args) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
const context = this; | ||
@@ -119,0 +121,0 @@ const later = () => { |
@@ -82,2 +82,3 @@ "use strict"; | ||
let filePath = | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
@@ -116,3 +117,3 @@ { | ||
}); | ||
let wsPort = yield portfinder.getPortPromise({ port: 32201 }); | ||
const wsPort = yield portfinder.getPortPromise({ port: 32201 }); | ||
const server = server_1.startHttpServer(port, host, handler); | ||
@@ -119,0 +120,0 @@ server.on('listening', () => { |
@@ -78,3 +78,3 @@ "use strict"; | ||
let uploaded = 0; | ||
for (let file of filesToUpload.files) { | ||
for (const file of filesToUpload.files) { | ||
const { signedUploadUrl, filePath } = yield client.registryApi.prepareFileUpload({ | ||
@@ -146,3 +146,3 @@ organizationId, | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let files = []; | ||
const files = []; | ||
const [{ path: apiPath }] = yield utils_1.getFallbackApisOrExit([api], config); | ||
@@ -178,3 +178,3 @@ process.stdout.write('Bundling definition\n'); | ||
} | ||
let pluginFiles = new Set(); | ||
const pluginFiles = new Set(); | ||
for (const plugin of config.styleguide.pluginPaths) { | ||
@@ -213,3 +213,3 @@ if (typeof plugin !== 'string') | ||
function hashFiles(filePaths) { | ||
let sum = crypto_1.createHash('sha256'); | ||
const sum = crypto_1.createHash('sha256'); | ||
filePaths.forEach((file) => sum.update(fs.readFileSync(file.filePath))); | ||
@@ -236,3 +236,3 @@ return sum.digest('hex'); | ||
var { maybeApiOrDestination, maybeDestination, maybeBranchName, branch } = _a, rest = __rest(_a, ["maybeApiOrDestination", "maybeDestination", "maybeBranchName", "branch"]); | ||
if (!!maybeBranchName) { | ||
if (maybeBranchName) { | ||
process.stderr.write(colorette_1.yellow('Deprecation warning: Do not use the third parameter as a branch name. Please use a separate --branch option instead.')); | ||
@@ -255,3 +255,3 @@ } | ||
: filePathOrBuffer.byteLength; | ||
let readStream = typeof filePathOrBuffer === 'string' ? fs.createReadStream(filePathOrBuffer) : filePathOrBuffer; | ||
const readStream = typeof filePathOrBuffer === 'string' ? fs.createReadStream(filePathOrBuffer) : filePathOrBuffer; | ||
return node_fetch_1.default(url, { | ||
@@ -258,0 +258,0 @@ method: 'PUT', |
@@ -201,4 +201,4 @@ "use strict"; | ||
inherits = (((_b = (_a = components === null || components === void 0 ? void 0 : components[componentType]) === null || _a === void 0 ? void 0 : _a[componentName]) === null || _b === void 0 ? void 0 : _b.allOf) || []) | ||
.map((s) => s.$ref) | ||
.filter(Boolean); | ||
.map(({ $ref }) => $ref) | ||
.filter(openapi_core_1.isTruthy); | ||
} | ||
@@ -229,2 +229,3 @@ componentsFiles[componentType] = componentsFiles[componentType] || {}; | ||
fs.writeFileSync(sampleFileName, sample.source); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
@@ -252,2 +253,3 @@ sample.source = { | ||
componentTypes.forEach(iterateComponentTypes); | ||
// eslint-disable-next-line no-inner-declarations | ||
function iterateAndGatherComponentsFiles(componentType) { | ||
@@ -260,2 +262,3 @@ const componentDirPath = path.join(componentsDir, componentType); | ||
} | ||
// eslint-disable-next-line no-inner-declarations | ||
function iterateComponentTypes(componentType) { | ||
@@ -262,0 +265,0 @@ var _a, _b, _c; |
@@ -36,3 +36,6 @@ #!/usr/bin/env node | ||
}, | ||
}), stats_1.handleStats) | ||
}), (argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'stats'; | ||
stats_1.handleStats(argv); | ||
}) | ||
.command('split [api]', 'Split definition into a multi-file structure.', (yargs) => yargs | ||
@@ -56,3 +59,6 @@ .positional('api', { | ||
}) | ||
.demandOption('api'), split_1.handleSplit) | ||
.demandOption('api'), (argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'split'; | ||
split_1.handleSplit(argv); | ||
}) | ||
.command('join [apis...]', 'Join definitions [experimental].', (yargs) => yargs | ||
@@ -86,2 +92,3 @@ .positional('apis', { | ||
}), (argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'join'; | ||
join_1.handleJoin(argv, version); | ||
@@ -118,3 +125,6 @@ }) | ||
.implies('batch-id', 'batch-size') | ||
.implies('batch-size', 'batch-id'), push_1.transformPush(push_1.handlePush)) | ||
.implies('batch-size', 'batch-id'), (argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'push'; | ||
push_1.transformPush(push_1.handlePush)(argv); | ||
}) | ||
.command('lint [apis...]', 'Lint definition.', (yargs) => yargs.positional('apis', { array: true, type: 'string', demandOption: true }).option({ | ||
@@ -169,2 +179,3 @@ format: { | ||
}), (argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'lint'; | ||
lint_1.handleLint(argv, version); | ||
@@ -240,2 +251,3 @@ }) | ||
}), (argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'bundle'; | ||
bundle_1.handleBundle(argv, version); | ||
@@ -255,4 +267,8 @@ }) | ||
}); | ||
}), login_1.handleLogin) | ||
}), (argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'login'; | ||
login_1.handleLogin(argv); | ||
}) | ||
.command('logout', 'Clear your stored credentials for the Redocly API registry.', (yargs) => yargs, () => __awaiter(void 0, void 0, void 0, function* () { | ||
process.env.REDOCLY_CLI_COMMAND = 'logout'; | ||
const client = new openapi_core_1.RedoclyClient(); | ||
@@ -298,5 +314,8 @@ client.logout(); | ||
}, | ||
}), preview_docs_1.previewDocs) | ||
}), (argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'preview-docs'; | ||
preview_docs_1.previewDocs(argv); | ||
}) | ||
.completion('completion', 'Generate completion script.') | ||
.demandCommand(1) | ||
.strict().argv; |
@@ -178,3 +178,2 @@ "use strict"; | ||
else { | ||
// @ts-ignore | ||
if (e instanceof CircularJSONNotSupportedError) { | ||
@@ -181,0 +180,0 @@ process.stderr.write(colorette_1.red(`Detected circular reference which can't be converted to JSON.\n`) + |
{ | ||
"name": "@redocly/cli", | ||
"version": "1.0.0-beta.107", | ||
"version": "1.0.0-beta.108", | ||
"description": "", | ||
@@ -38,3 +38,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@redocly/openapi-core": "1.0.0-beta.107", | ||
"@redocly/openapi-core": "1.0.0-beta.108", | ||
"assert-node-version": "^1.0.3", | ||
@@ -41,0 +41,0 @@ "chokidar": "^3.5.1", |
@@ -134,4 +134,4 @@ import * as path from 'path'; | ||
let joinedDef: any = {}; | ||
let potentialConflicts = { | ||
const joinedDef: any = {}; | ||
const potentialConflicts = { | ||
tags: {}, | ||
@@ -347,5 +347,3 @@ paths: {}, | ||
} | ||
for (const operation of Object.keys(paths[path])) { | ||
// @ts-ignore | ||
const pathOperation = paths[path][operation]; | ||
for (const [operation, pathOperation] of Object.entries(paths[path])) { | ||
joinedDef.paths[path][operation] = pathOperation; | ||
@@ -366,3 +364,3 @@ potentialConflicts.paths[path][operation] = [ | ||
} | ||
let { tags, security } = joinedDef.paths[path][operation]; | ||
const { tags, security } = joinedDef.paths[path][operation]; | ||
if (tags) { | ||
@@ -418,3 +416,3 @@ joinedDef.paths[path][operation].tags = tags.map((tag: string) => | ||
} | ||
for (const component of Object.keys(components)) { | ||
for (const [component, componentObj] of Object.entries(components)) { | ||
if (!potentialConflicts[COMPONENTS].hasOwnProperty(component)) { | ||
@@ -424,4 +422,2 @@ potentialConflicts[COMPONENTS][component] = {}; | ||
} | ||
// @ts-ignore | ||
const componentObj = components[component]; | ||
for (const item of Object.keys(componentObj)) { | ||
@@ -444,3 +440,2 @@ const componentPrefix = addPrefix(item, componentsPrefix!); | ||
const xWebhooks = 'x-webhooks'; | ||
// @ts-ignore | ||
const openapiXWebhooks = openapi[xWebhooks]; | ||
@@ -464,3 +459,3 @@ if (openapiXWebhooks) { | ||
for (const operationKey of Object.keys(joinedDef[xWebhooks][webhook])) { | ||
let { tags } = joinedDef[xWebhooks][webhook][operationKey]; | ||
const { tags } = joinedDef[xWebhooks][webhook][operationKey]; | ||
if (tags) { | ||
@@ -508,3 +503,3 @@ joinedDef[xWebhooks][webhook][operationKey].tags = tags.map((tag: string) => | ||
for (let i = 0, len = files.length; i < len; i++) { | ||
let next = files[i + 1]; | ||
const next = files[i + 1]; | ||
if (next && doesComponentsDiffer(files[i], next)) { | ||
@@ -511,0 +506,0 @@ isDiffer = true; |
@@ -87,3 +87,3 @@ import { | ||
if (argv['generate-ignore-file']) { | ||
for (let m of results) { | ||
for (const m of results) { | ||
config.styleguide.addIgnore(m); | ||
@@ -90,0 +90,0 @@ totalIgnored++; |
@@ -26,3 +26,3 @@ import * as colorette from 'colorette'; | ||
) { | ||
let isAuthorizedWithRedocly: boolean = false; | ||
let isAuthorizedWithRedocly = false; | ||
let redocOptions: any = {}; | ||
@@ -133,3 +133,3 @@ let config = await reloadConfig(); | ||
async function reloadConfig() { | ||
let config = await loadConfig(argv.config); | ||
const config = await loadConfig(argv.config); | ||
const redoclyClient = new RedoclyClient(); | ||
@@ -157,3 +157,5 @@ isAuthorizedWithRedocly = await redoclyClient.isAuthorizedWithRedocly(); | ||
return function executedFunction(...args: any[]) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
const context = this; | ||
@@ -160,0 +162,0 @@ |
@@ -102,2 +102,3 @@ import { compile } from 'handlebars'; | ||
let filePath = | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
@@ -146,3 +147,3 @@ { | ||
let wsPort = await portfinder.getPortPromise({ port: 32201 }); | ||
const wsPort = await portfinder.getPortPromise({ port: 32201 }); | ||
@@ -149,0 +150,0 @@ const server = startHttpServer(port, host, handler); |
@@ -122,3 +122,3 @@ import * as fs from 'fs'; | ||
for (let file of filesToUpload.files) { | ||
for (const file of filesToUpload.files) { | ||
const { signedUploadUrl, filePath } = await client.registryApi.prepareFileUpload({ | ||
@@ -210,3 +210,3 @@ organizationId, | ||
async function collectFilesToUpload(api: string, config: Config) { | ||
let files: { filePath: string; keyOnS3: string; contents?: Buffer }[] = []; | ||
const files: { filePath: string; keyOnS3: string; contents?: Buffer }[] = []; | ||
const [{ path: apiPath }] = await getFallbackApisOrExit([api], config); | ||
@@ -251,3 +251,3 @@ | ||
} | ||
let pluginFiles = new Set<string>(); | ||
const pluginFiles = new Set<string>(); | ||
for (const plugin of config.styleguide.pluginPaths) { | ||
@@ -288,3 +288,3 @@ if (typeof plugin !== 'string') continue; | ||
function hashFiles(filePaths: { filePath: string }[]) { | ||
let sum = createHash('sha256'); | ||
const sum = createHash('sha256'); | ||
filePaths.forEach((file) => sum.update(fs.readFileSync(file.filePath))); | ||
@@ -325,3 +325,3 @@ return sum.digest('hex'); | ||
({ maybeApiOrDestination, maybeDestination, maybeBranchName, branch, ...rest }: BarePushArgs) => { | ||
if (!!maybeBranchName) { | ||
if (maybeBranchName) { | ||
process.stderr.write( | ||
@@ -361,3 +361,3 @@ yellow( | ||
: filePathOrBuffer.byteLength; | ||
let readStream = | ||
const readStream = | ||
typeof filePathOrBuffer === 'string' ? fs.createReadStream(filePathOrBuffer) : filePathOrBuffer; | ||
@@ -364,0 +364,0 @@ |
import { red, blue, yellow, green } from 'colorette'; | ||
import * as fs from 'fs'; | ||
import { parseYaml, slash, isRef } from '@redocly/openapi-core'; | ||
import { parseYaml, slash, isRef, isTruthy } from '@redocly/openapi-core'; | ||
import type { OasRef } from '@redocly/openapi-core'; | ||
import * as path from 'path'; | ||
@@ -270,7 +271,7 @@ import { performance } from 'perf_hooks'; | ||
) { | ||
let inherits = []; | ||
let inherits: string[] = []; | ||
if (componentType === OPENAPI3_COMPONENT.Schemas) { | ||
inherits = ((components?.[componentType]?.[componentName] as Oas3Schema)?.allOf || []) | ||
.map((s: any) => s.$ref) | ||
.filter(Boolean); | ||
.map(({ $ref }) => $ref) | ||
.filter(isTruthy); | ||
} | ||
@@ -305,3 +306,3 @@ componentsFiles[componentType] = componentsFiles[componentType] || {}; | ||
for (const sample of methodDataXCode) { | ||
if (sample.source && (sample.source as any).$ref) continue; | ||
if (sample.source && (sample.source as unknown as OasRef).$ref) continue; | ||
const sampleFileName = path.join( | ||
@@ -317,2 +318,3 @@ openapiDir, | ||
fs.writeFileSync(sampleFileName, sample.source); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
@@ -346,2 +348,3 @@ sample.source = { | ||
// eslint-disable-next-line no-inner-declarations | ||
function iterateAndGatherComponentsFiles(componentType: Oas3ComponentName) { | ||
@@ -355,2 +358,3 @@ const componentDirPath = path.join(componentsDir, componentType); | ||
// eslint-disable-next-line no-inner-declarations | ||
function iterateComponentTypes(componentType: Oas3ComponentName) { | ||
@@ -357,0 +361,0 @@ const componentDirPath = path.join(componentsDir, componentType); |
@@ -32,3 +32,6 @@ #!/usr/bin/env node | ||
}), | ||
handleStats | ||
(argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'stats'; | ||
handleStats(argv); | ||
} | ||
) | ||
@@ -58,3 +61,6 @@ .command( | ||
.demandOption('api'), | ||
handleSplit | ||
(argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'split'; | ||
handleSplit(argv); | ||
} | ||
) | ||
@@ -94,2 +100,3 @@ .command( | ||
(argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'join'; | ||
handleJoin(argv, version); | ||
@@ -133,3 +140,6 @@ } | ||
.implies('batch-size', 'batch-id'), | ||
transformPush(handlePush) | ||
(argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'push'; | ||
transformPush(handlePush)(argv); | ||
} | ||
) | ||
@@ -190,2 +200,3 @@ .command( | ||
(argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'lint'; | ||
handleLint(argv, version); | ||
@@ -267,2 +278,3 @@ } | ||
(argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'bundle'; | ||
handleBundle(argv, version); | ||
@@ -286,3 +298,6 @@ } | ||
}), | ||
handleLogin | ||
(argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'login'; | ||
handleLogin(argv); | ||
} | ||
) | ||
@@ -294,2 +309,3 @@ .command( | ||
async () => { | ||
process.env.REDOCLY_CLI_COMMAND = 'logout'; | ||
const client = new RedoclyClient(); | ||
@@ -341,3 +357,6 @@ client.logout(); | ||
}), | ||
previewDocs | ||
(argv) => { | ||
process.env.REDOCLY_CLI_COMMAND = 'preview-docs'; | ||
previewDocs(argv); | ||
} | ||
) | ||
@@ -344,0 +363,0 @@ .completion('completion', 'Generate completion script.') |
@@ -180,3 +180,2 @@ import { basename, dirname, extname, join, resolve } from 'path'; | ||
} else { | ||
// @ts-ignore | ||
if (e instanceof CircularJSONNotSupportedError) { | ||
@@ -183,0 +182,0 @@ process.stderr.write( |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
327210
7394
26
+ Added@redocly/openapi-core@1.0.0-beta.108(transitive)
- Removed@redocly/openapi-core@1.0.0-beta.107(transitive)