1
0
Fork 0

feat: update to js-yaml 4, default schema

BREAKING CHANGE: updates the underlying js-yaml from v3 to v4,
thus including all of the breaking changes from that:
https://github.com/nodeca/js-yaml/blob/master/migrate_v3_to_v4.md.
The API of this module has not changed, but some documents
may be parsed differently, so this is breaking.
This commit is contained in:
ssube 2021-03-27 18:34:47 -05:00
parent 9399ce68cb
commit fc1f4d01a2
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
5 changed files with 12 additions and 20 deletions

View File

@ -17,7 +17,7 @@
"@microsoft/api-extractor": "7.13.2",
"@types/chai": "4.2.15",
"@types/chai-as-promised": "7.1.3",
"@types/js-yaml": "3.12.6",
"@types/js-yaml": "4.0.0",
"@types/lodash": "4.14.168",
"@types/mocha": "8.2.2",
"@types/sinon-chai": "3.2.5",
@ -36,7 +36,7 @@
"eslint-plugin-no-null": "1.0.2",
"eslint-plugin-sonarjs": "0.6.0",
"esm": "3.2.25",
"js-yaml": "3.14.1",
"js-yaml": "4.0.0",
"mocha": "8.3.2",
"noicejs": "3.1.0",
"nyc": "15.1.0",

View File

@ -1,4 +1,4 @@
import { DEFAULT_SAFE_SCHEMA, Schema } from 'js-yaml';
import { DEFAULT_SCHEMA } from 'js-yaml';
import { envType } from './type/Env';
import { createInclude, IncludeOptions } from './type/Include';
@ -16,7 +16,7 @@ export interface SchemaOptions {
*/
export function createSchema(options: SchemaOptions) {
const includeType = createInclude(options.include);
const schema = Schema.create([DEFAULT_SAFE_SCHEMA], [
const schema = DEFAULT_SCHEMA.extend([
envType,
includeType,
regexpType,

View File

@ -1,5 +1,5 @@
import { InvalidArgumentError, NotFoundError } from '@apextoaster/js-utils';
import { safeLoad, Schema, Type as YamlType } from 'js-yaml';
import { load, Schema, Type as YamlType } from 'js-yaml';
export type ReaderEncoding = 'ascii' | 'utf-8';
export interface ReaderOptions {
@ -40,7 +40,7 @@ export function createInclude(options: IncludeOptions) {
construct(path: string): unknown {
try {
const abs = options.resolve(path);
return safeLoad(options.read(abs, {
return load(options.read(abs, {
encoding: 'utf-8',
}), {
schema: options.schema,

View File

@ -1,6 +1,6 @@
import { InvalidArgumentError, NotFoundError } from '@apextoaster/js-utils';
import { expect } from 'chai';
import { DEFAULT_SAFE_SCHEMA } from 'js-yaml';
import { DEFAULT_SCHEMA } from 'js-yaml';
import { join } from 'path';
import { createInclude, IncludeOptions } from '../../src/type/Include';
@ -12,7 +12,7 @@ const TEST_OPTIONS: IncludeOptions = {
join: (...path) => path.join('/'),
read: () => 'test',
resolve: (path: string) => path,
schema: DEFAULT_SAFE_SCHEMA,
schema: DEFAULT_SCHEMA,
};
describe('include config type', async () => {

View File

@ -386,10 +386,10 @@
resolved "https://artifacts.apextoaster.com/repository/group-npm/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==
"@types/js-yaml@3.12.6":
version "3.12.6"
resolved "https://artifacts.apextoaster.com/repository/group-npm/@types/js-yaml/-/js-yaml-3.12.6.tgz#7f10c926aa41e189a2755c4c7fcf8e4573bd7ac1"
integrity sha512-cK4XqrLvP17X6c0C8n4iTbT59EixqyXL3Fk8/Rsk4dF3oX4dg70gYUXrXVUUHpnsGMPNlTQMqf+TVmNPX6FmSQ==
"@types/js-yaml@4.0.0":
version "4.0.0"
resolved "https://artifacts.apextoaster.com/repository/group-npm/@types/js-yaml/-/js-yaml-4.0.0.tgz#d1a11688112091f2c711674df3a65ea2f47b5dfb"
integrity sha512-4vlpCM5KPCL5CfGmTbpjwVKbISRYhduEJvvUWsH5EB7QInhEj94XPZ3ts/9FPiLZFqYO0xoW4ZL8z2AabTGgJA==
"@types/json-schema@^7.0.3":
version "7.0.3"
@ -2583,14 +2583,6 @@ js-tokens@^4.0.0:
resolved "https://artifacts.apextoaster.com/repository/group-npm/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
js-yaml@3.14.1:
version "3.14.1"
resolved "https://artifacts.apextoaster.com/repository/group-npm/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537"
integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"
js-yaml@4.0.0:
version "4.0.0"
resolved "https://artifacts.apextoaster.com/repository/group-npm/js-yaml/-/js-yaml-4.0.0.tgz#f426bc0ff4b4051926cd588c71113183409a121f"