Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@redocly/cli

Package Overview
Dependencies
Maintainers
7
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@redocly/cli - npm Package Compare versions

Comparing version 1.0.0-beta.98 to 1.0.0-beta.99

lib/__mocks__/@redocly/openapi-core.d.ts

1

lib/commands/bundle.d.ts

@@ -19,2 +19,3 @@ import { OutputFormat } from '@redocly/openapi-core';

'remove-unused-components'?: boolean;
'keep-url-references'?: boolean;
}, version: string): Promise<void>;

@@ -71,2 +71,3 @@ "use strict";

removeUnusedComponents,
keepUrlRefs: argv['keep-url-references'],
}), { bundle: result, problems } = _e, meta = __rest(_e, ["bundle", "problems"]);

@@ -73,0 +74,0 @@ const fileTotals = openapi_core_1.getTotals(problems);

@@ -16,2 +16,3 @@ "use strict";

const colorette_1 = require("colorette");
const utils = require('../../../utils');
jest.mock('../../../utils', () => (Object.assign(Object.assign({}, jest.requireActual('../../../utils')), { writeYaml: jest.fn() })));

@@ -23,3 +24,3 @@ jest.mock('@redocly/openapi-core', () => (Object.assign(Object.assign({}, jest.requireActual('@redocly/openapi-core')), { isRef: jest.fn() })));

it('should split the file and show the success message', () => __awaiter(void 0, void 0, void 0, function* () {
const filePath = "./packages/cli/src/commands/split/__tests__/fixtures/spec.json";
const filePath = "packages/cli/src/commands/split/__tests__/fixtures/spec.json";
jest.spyOn(process.stderr, 'write').mockImplementation(() => true);

@@ -37,4 +38,3 @@ yield index_1.handleSplit({

it('should use the correct separator', () => __awaiter(void 0, void 0, void 0, function* () {
const filePath = "./packages/cli/src/commands/split/__tests__/fixtures/spec.json";
const utils = require('../../../utils');
const filePath = "packages/cli/src/commands/split/__tests__/fixtures/spec.json";
jest.spyOn(utils, 'pathToFilename').mockImplementation(() => 'newFilePath');

@@ -73,2 +73,15 @@ yield index_1.handleSplit({

});
it('should create correct folder name for code samples', () => __awaiter(void 0, void 0, void 0, function* () {
const openapi = require("./fixtures/samples.json");
jest.spyOn(utils, 'escapeLanguageName');
index_1.iteratePathItems(openapi.paths, openapiDir, path.join(openapiDir, 'paths'), componentsFiles, '_');
expect(utils.escapeLanguageName).nthCalledWith(1, 'C#');
expect(utils.escapeLanguageName).nthReturnedWith(1, 'C_sharp');
expect(utils.escapeLanguageName).nthCalledWith(2, 'C/AL');
expect(utils.escapeLanguageName).nthReturnedWith(2, 'C_AL');
expect(utils.escapeLanguageName).nthCalledWith(3, 'Visual Basic');
expect(utils.escapeLanguageName).nthReturnedWith(3, 'VisualBasic');
expect(utils.escapeLanguageName).toBeCalledTimes(3);
utils.escapeLanguageName.mockRestore();
}));
});

2

lib/commands/split/index.js

@@ -224,3 +224,3 @@ "use strict";

continue;
const sampleFileName = path.join(openapiDir, 'code_samples', sample.lang, codeSamplesPathPrefix + utils_1.pathToFilename(pathName, pathSeparator), method + langToExt(sample.lang));
const sampleFileName = path.join(openapiDir, 'code_samples', utils_1.escapeLanguageName(sample.lang), codeSamplesPathPrefix + utils_1.pathToFilename(pathName, pathSeparator), method + langToExt(sample.lang));
fs.mkdirSync(path.dirname(sampleFileName), { recursive: true });

@@ -227,0 +227,0 @@ fs.writeFileSync(sampleFileName, sample.source);

@@ -7,2 +7,3 @@ import { BundleOutputFormat, Config, LintConfig } from '@redocly/openapi-core';

export declare function pathToFilename(path: string, pathSeparator: string): string;
export declare function escapeLanguageName(lang: string): string;
export declare class CircularJSONNotSupportedError extends Error {

@@ -9,0 +10,0 @@ originalError: Error;

@@ -12,3 +12,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.isSubdir = exports.exitWithError = exports.printUnusedWarnings = exports.getOutputFileName = exports.printLintTotals = exports.handleError = exports.pluralize = exports.writeYaml = exports.readYaml = exports.promptUser = exports.saveBundle = exports.dumpBundle = exports.CircularJSONNotSupportedError = exports.pathToFilename = exports.printExecutionTime = exports.getExecutionTime = exports.getFallbackEntryPointsOrExit = void 0;
exports.isSubdir = exports.exitWithError = exports.printUnusedWarnings = exports.getOutputFileName = exports.printLintTotals = exports.handleError = exports.pluralize = exports.writeYaml = exports.readYaml = exports.promptUser = exports.saveBundle = exports.dumpBundle = exports.CircularJSONNotSupportedError = exports.escapeLanguageName = exports.pathToFilename = exports.printExecutionTime = exports.getExecutionTime = exports.getFallbackEntryPointsOrExit = void 0;
const path_1 = require("path");

@@ -82,2 +82,9 @@ const colorette_1 = require("colorette");

exports.pathToFilename = pathToFilename;
function escapeLanguageName(lang) {
return lang
.replace(/#/g, "_sharp")
.replace(/\//, '_')
.replace(/\s/g, '');
}
exports.escapeLanguageName = escapeLanguageName;
class CircularJSONNotSupportedError extends Error {

@@ -84,0 +91,0 @@ constructor(originalError) {

{
"name": "@redocly/cli",
"version": "1.0.0-beta.98",
"version": "1.0.0-beta.99",
"description": "",

@@ -38,3 +38,3 @@ "license": "MIT",

"dependencies": {
"@redocly/openapi-core": "1.0.0-beta.98",
"@redocly/openapi-core": "1.0.0-beta.99",
"assert-node-version": "^1.0.3",

@@ -41,0 +41,0 @@ "chokidar": "^3.5.1",

@@ -42,2 +42,3 @@ import {

'remove-unused-components'?: boolean;
'keep-url-references'?: boolean;
},

@@ -102,2 +103,3 @@ version: string,

removeUnusedComponents,
keepUrlRefs: argv['keep-url-references'],
});

@@ -104,0 +106,0 @@

@@ -9,2 +9,4 @@ import { iteratePathItems, handleSplit } from '../index';

const utils = require('../../../utils');
jest.mock('../../../utils', () => ({

@@ -25,3 +27,3 @@ ...jest.requireActual('../../../utils'),

it('should split the file and show the success message', async () => {
const filePath = "./packages/cli/src/commands/split/__tests__/fixtures/spec.json";
const filePath = "packages/cli/src/commands/split/__tests__/fixtures/spec.json";
jest.spyOn(process.stderr, 'write').mockImplementation(() => true);

@@ -49,5 +51,4 @@

it('should use the correct separator', async () => {
const filePath = "./packages/cli/src/commands/split/__tests__/fixtures/spec.json";
const filePath = "packages/cli/src/commands/split/__tests__/fixtures/spec.json";
const utils = require('../../../utils');
jest.spyOn(utils, 'pathToFilename').mockImplementation(() => 'newFilePath');

@@ -99,2 +100,22 @@

});
it('should create correct folder name for code samples', async () => {
const openapi = require("./fixtures/samples.json");
jest.spyOn(utils, 'escapeLanguageName');
iteratePathItems(openapi.paths, openapiDir, path.join(openapiDir, 'paths'), componentsFiles, '_');
expect(utils.escapeLanguageName).nthCalledWith(1, 'C#');
expect(utils.escapeLanguageName).nthReturnedWith(1, 'C_sharp');
expect(utils.escapeLanguageName).nthCalledWith(2, 'C/AL');
expect(utils.escapeLanguageName).nthReturnedWith(2, 'C_AL');
expect(utils.escapeLanguageName).nthCalledWith(3, 'Visual Basic');
expect(utils.escapeLanguageName).nthReturnedWith(3, 'VisualBasic');
expect(utils.escapeLanguageName).toBeCalledTimes(3);
utils.escapeLanguageName.mockRestore();
});
});

@@ -8,3 +8,3 @@ import { red, blue, yellow, green } from 'colorette';

import { printExecutionTime, pathToFilename, readYaml, writeYaml, exitWithError } from '../../utils';
import { printExecutionTime, pathToFilename, readYaml, writeYaml, exitWithError, escapeLanguageName } from '../../utils';
import { isString, isObject, isEmptyObject } from '../../js-utils';

@@ -275,3 +275,3 @@ import {

'code_samples',
sample.lang,
escapeLanguageName(sample.lang),
codeSamplesPathPrefix + pathToFilename(pathName, pathSeparator),

@@ -278,0 +278,0 @@ method + langToExt(sample.lang),

@@ -77,2 +77,9 @@ import { basename, dirname, extname, join, resolve } from 'path';

export function escapeLanguageName(lang: string) {
return lang
.replace(/#/g, "_sharp")
.replace(/\//, '_')
.replace(/\s/g, '');
}
export class CircularJSONNotSupportedError extends Error {

@@ -79,0 +86,0 @@ constructor(public originalError: Error) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc