feat: upgrade js-yaml package (#403)

* feat: upgraded js-yaml package from v.3 to v.4 with YAML 1.2 support

* feat: removed timestamp type from YAML schema
This commit is contained in:
Yaroslav Shuhailo
2021-10-12 11:52:08 +03:00
committed by GitHub
parent 4cbd04ecae
commit 35fc48c667
25 changed files with 291 additions and 314 deletions

View File

@@ -2,7 +2,6 @@ import { basename, dirname, extname, join, resolve } from 'path';
import { blue, gray, green, red, yellow } from 'colorette';
import { performance } from "perf_hooks";
import * as glob from 'glob-promise';
import * as yaml from 'js-yaml';
import * as fs from 'fs';
import * as path from 'path';
import * as readline from 'readline';
@@ -13,6 +12,8 @@ import {
LintConfig,
ResolveError,
YamlParseError,
parseYaml,
stringifyYaml
} from '@redocly/openapi-core';
import { Totals, outputExtensions } from './types';
@@ -87,7 +88,7 @@ export function dumpBundle(obj: any, format: BundleOutputFormat, dereference?: b
throw e;
}
} else {
return yaml.safeDump(obj, {
return stringifyYaml(obj, {
noRefs: !dereference,
});
}
@@ -131,11 +132,11 @@ export async function promptUser(query: string, hideUserInput = false): Promise<
}
export function readYaml(filename: string) {
return yaml.safeLoad(fs.readFileSync(filename, 'utf-8'), { filename });
return parseYaml(fs.readFileSync(filename, 'utf-8'), { filename });
}
export function writeYaml(data: any, filename: string, noRefs = false) {
const content = yaml.safeDump(data, { noRefs });
const content = stringifyYaml(data, { noRefs });
if (process.env.NODE_ENV === 'test') {
process.stderr.write(content);