diff --git a/package.json b/package.json index 32e020b..e8158d8 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/schema.ts b/src/schema.ts index 5f04e02..533eca2 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -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, diff --git a/src/type/Include.ts b/src/type/Include.ts index 738fcec..33fb21b 100644 --- a/src/type/Include.ts +++ b/src/type/Include.ts @@ -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, diff --git a/test/type/TestInclude.ts b/test/type/TestInclude.ts index 61c4d29..33478df 100644 --- a/test/type/TestInclude.ts +++ b/test/type/TestInclude.ts @@ -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 () => { diff --git a/yarn.lock b/yarn.lock index c83f552..7f8dc81 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"