@redocly/cli
Advanced tools
Comparing version 1.0.0-beta.104 to 1.0.0-beta.105
@@ -49,1 +49,2 @@ /// <reference types="jest" /> | ||
export declare const findConfig: jest.Mock<any, any>; | ||
export declare const doesYamlFileExist: jest.Mock<any, any>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.findConfig = exports.slash = exports.formatProblems = exports.getTotals = exports.bundle = exports.lint = exports.getMergedConfig = exports.loadConfig = exports.RedoclyClient = exports.__redoclyClient = void 0; | ||
exports.doesYamlFileExist = exports.findConfig = exports.slash = exports.formatProblems = exports.getTotals = exports.bundle = exports.lint = exports.getMergedConfig = exports.loadConfig = exports.RedoclyClient = exports.__redoclyClient = void 0; | ||
const config_1 = require("./../../__tests__/fixtures/config"); | ||
@@ -28,1 +28,2 @@ exports.__redoclyClient = { | ||
exports.findConfig = jest.fn(); | ||
exports.doesYamlFileExist = jest.fn(); |
@@ -39,2 +39,3 @@ "use strict"; | ||
getMergedConfigMock.mockReturnValue(config_1.ConfigFixture); | ||
openapi_core_1.doesYamlFileExist.mockImplementation((path) => path === 'redocly.yaml'); | ||
}); | ||
@@ -45,3 +46,8 @@ afterEach(() => { | ||
describe('loadConfig and getEnrtypoints stage', () => { | ||
it('shoul call loadConfig and getFallbackEntryPointsOrExit', () => __awaiter(void 0, void 0, void 0, function* () { | ||
it('should fail if config file does not exist', () => __awaiter(void 0, void 0, void 0, function* () { | ||
yield lint_1.handleLint(Object.assign(Object.assign({}, argvMock), { config: 'config.yaml' }), versionMock); | ||
expect(utils_1.exitWithError).toHaveBeenCalledWith('Please, provide valid path to the configuration file'); | ||
expect(openapi_core_1.loadConfig).toHaveBeenCalledTimes(0); | ||
})); | ||
it('should call loadConfig and getFallbackEntryPointsOrExit', () => __awaiter(void 0, void 0, void 0, function* () { | ||
yield lint_1.handleLint(argvMock, versionMock); | ||
@@ -52,4 +58,4 @@ expect(openapi_core_1.loadConfig).toHaveBeenCalledWith(undefined, undefined, undefined); | ||
it('should call loadConfig with args if such exist', () => __awaiter(void 0, void 0, void 0, function* () { | ||
yield lint_1.handleLint(Object.assign(Object.assign({}, argvMock), { config: '/path/redocly.yaml', extends: ['some/path'] }), versionMock); | ||
expect(openapi_core_1.loadConfig).toHaveBeenCalledWith('/path/redocly.yaml', ['some/path'], undefined); | ||
yield lint_1.handleLint(Object.assign(Object.assign({}, argvMock), { config: 'redocly.yaml', extends: ['some/path'] }), versionMock); | ||
expect(openapi_core_1.loadConfig).toHaveBeenCalledWith('redocly.yaml', ['some/path'], undefined); | ||
})); | ||
@@ -56,0 +62,0 @@ it('should call mergedConfig with clear ignore if `generate-ignore-file` argv', () => __awaiter(void 0, void 0, void 0, function* () { |
@@ -19,2 +19,5 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (argv.config && !openapi_core_1.doesYamlFileExist(argv.config)) { | ||
return utils_1.exitWithError('Please, provide valid path to the configuration file'); | ||
} | ||
const config = yield openapi_core_1.loadConfig(argv.config, argv.extends, lintConfigCallback(argv, version)); | ||
@@ -21,0 +24,0 @@ const entrypoints = yield utils_1.getFallbackEntryPointsOrExit(argv.entrypoints, config); |
{ | ||
"name": "@redocly/cli", | ||
"version": "1.0.0-beta.104", | ||
"version": "1.0.0-beta.105", | ||
"description": "", | ||
@@ -38,3 +38,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@redocly/openapi-core": "1.0.0-beta.104", | ||
"@redocly/openapi-core": "1.0.0-beta.105", | ||
"assert-node-version": "^1.0.3", | ||
@@ -41,0 +41,0 @@ "chokidar": "^3.5.1", |
@@ -27,1 +27,2 @@ import { ConfigFixture } from './../../__tests__/fixtures/config'; | ||
export const findConfig = jest.fn(); | ||
export const doesYamlFileExist = jest.fn(); |
@@ -8,2 +8,3 @@ import { handleLint, LintOptions } from '../../commands/lint'; | ||
formatProblems, | ||
doesYamlFileExist, | ||
} from '@redocly/openapi-core'; | ||
@@ -15,2 +16,3 @@ import { | ||
handleError, | ||
exitWithError, | ||
} from '../../utils'; | ||
@@ -46,2 +48,3 @@ import { ConfigFixture } from '../fixtures/config'; | ||
getMergedConfigMock.mockReturnValue(ConfigFixture); | ||
(doesYamlFileExist as jest.Mock<any, any>).mockImplementation((path) => path === 'redocly.yaml') | ||
}); | ||
@@ -54,3 +57,11 @@ | ||
describe('loadConfig and getEnrtypoints stage', () => { | ||
it('shoul call loadConfig and getFallbackEntryPointsOrExit', async () => { | ||
it('should fail if config file does not exist', async () => { | ||
await handleLint({ ...argvMock, config: 'config.yaml' }, versionMock); | ||
expect(exitWithError).toHaveBeenCalledWith( | ||
'Please, provide valid path to the configuration file' | ||
); | ||
expect(loadConfig).toHaveBeenCalledTimes(0); | ||
}); | ||
it('should call loadConfig and getFallbackEntryPointsOrExit', async () => { | ||
await handleLint(argvMock, versionMock); | ||
@@ -63,6 +74,6 @@ expect(loadConfig).toHaveBeenCalledWith(undefined, undefined, undefined); | ||
await handleLint( | ||
{ ...argvMock, config: '/path/redocly.yaml', extends: ['some/path'] }, | ||
versionMock, | ||
{ ...argvMock, config: 'redocly.yaml', extends: ['some/path'] }, | ||
versionMock | ||
); | ||
expect(loadConfig).toHaveBeenCalledWith('/path/redocly.yaml', ['some/path'], undefined); | ||
expect(loadConfig).toHaveBeenCalledWith('redocly.yaml', ['some/path'], undefined); | ||
}); | ||
@@ -93,3 +104,3 @@ | ||
}, | ||
versionMock, | ||
versionMock | ||
); | ||
@@ -96,0 +107,0 @@ expect(ConfigFixture.lint.skipRules).toHaveBeenCalledWith(['rule']); |
@@ -16,2 +16,3 @@ import { | ||
ProblemSeverity, | ||
doesYamlFileExist | ||
} from '@redocly/openapi-core'; | ||
@@ -25,3 +26,4 @@ import { | ||
printConfigLintTotals, | ||
printUnusedWarnings | ||
printUnusedWarnings, | ||
exitWithError | ||
} from '../utils'; | ||
@@ -45,2 +47,7 @@ import { Totals } from '../types'; | ||
export async function handleLint(argv: LintOptions, version: string) { | ||
if (argv.config && !doesYamlFileExist(argv.config)) { | ||
return exitWithError('Please, provide valid path to the configuration file'); | ||
} | ||
const config: Config = await loadConfig( | ||
@@ -47,0 +54,0 @@ argv.config, |
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
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
323347
7105
+ Added@redocly/openapi-core@1.0.0-beta.105(transitive)
- Removed@redocly/openapi-core@1.0.0-beta.104(transitive)