diff --git a/compat/js-yaml-safe-api/index.js b/compat/js-yaml-safe-api/index.js new file mode 100644 index 0000000..9d8c9f7 --- /dev/null +++ b/compat/js-yaml-safe-api/index.js @@ -0,0 +1,17 @@ +"use strict"; + +const yaml = require("js-yaml-upstream"); + +function safeLoad(input, options) { + if (input == null || String(input).trim() === "") { + return undefined; + } + return yaml.load(input, options); +} + +module.exports = Object.assign({}, yaml, { + load: yaml.load, + dump: yaml.dump, + safeLoad, + safeDump: yaml.dump, +}); diff --git a/compat/js-yaml-safe-api/package.json b/compat/js-yaml-safe-api/package.json new file mode 100644 index 0000000..7194324 --- /dev/null +++ b/compat/js-yaml-safe-api/package.json @@ -0,0 +1,10 @@ +{ + "name": "js-yaml", + "version": "5.4.2", + "private": true, + "description": "js-yaml 5 with safeLoad/safeDump aliases for gray-matter 4.x and a CJS default export for Eleventy.", + "main": "index.js", + "dependencies": { + "js-yaml-upstream": "npm:js-yaml@5.4.2" + } +} diff --git a/package-lock.json b/package-lock.json index ba39814..c1d4c5c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,15 @@ "version": "1.0.0", "license": "UNLICENSED", "dependencies": { - "@11ty/eleventy": "3.1.6" + "@11ty/eleventy": "3.1.6", + "js-yaml": "file:compat/js-yaml-safe-api" + } + }, + "compat/js-yaml-safe-api": { + "name": "js-yaml", + "version": "5.4.2", + "dependencies": { + "js-yaml-upstream": "npm:js-yaml@5.4.2" } }, "node_modules/@11ty/dependency-tree": { @@ -145,6 +153,28 @@ "url": "https://opencollective.com/11ty" } }, + "node_modules/@11ty/eleventy/node_modules/js-yaml": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz", + "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/@11ty/lodash-custom": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/@11ty/lodash-custom/-/lodash-custom-4.17.21.tgz", @@ -720,27 +750,10 @@ "node": ">=6.0" } }, + "node_modules/gray-matter/compat/js-yaml-safe-api": {}, "node_modules/gray-matter/node_modules/js-yaml": { - "version": "5.4.2", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.4.2.tgz", - "integrity": "sha512-m+aqu+LwO1O6sIopafj8HUVl5aawITwZQe/yHpMCKjaWBaA/d07B/QdMb3529REftiU+RMMHL3Vlsw3hON7vWg==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/puzrin" - }, - { - "type": "github", - "url": "https://github.com/sponsors/nodeca" - } - ], - "license": "MIT", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.mjs" - } + "resolved": "node_modules/gray-matter/compat/js-yaml-safe-api", + "link": true }, "node_modules/htmlparser2": { "version": "7.2.0", @@ -909,9 +922,14 @@ } }, "node_modules/js-yaml": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz", - "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==", + "resolved": "compat/js-yaml-safe-api", + "link": true + }, + "node_modules/js-yaml-upstream": { + "name": "js-yaml", + "version": "5.4.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.4.2.tgz", + "integrity": "sha512-m+aqu+LwO1O6sIopafj8HUVl5aawITwZQe/yHpMCKjaWBaA/d07B/QdMb3529REftiU+RMMHL3Vlsw3hON7vWg==", "funding": [ { "type": "github", @@ -927,7 +945,7 @@ "argparse": "^2.0.1" }, "bin": { - "js-yaml": "bin/js-yaml.js" + "js-yaml": "bin/js-yaml.mjs" } }, "node_modules/junk": { diff --git a/package.json b/package.json index 5faf444..fd87118 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,12 @@ }, "license": "UNLICENSED", "dependencies": { - "@11ty/eleventy": "3.1.6" + "@11ty/eleventy": "3.1.6", + "js-yaml": "file:compat/js-yaml-safe-api" }, "overrides": { "gray-matter": { - "js-yaml": "^5.4.2" + "js-yaml": "$js-yaml" } } }