diff --git a/tools/automated-tests/collect-urls.mjs b/tools/automated-tests/collect-urls.mjs index 82ef695db30..e850935298e 100644 --- a/tools/automated-tests/collect-urls.mjs +++ b/tools/automated-tests/collect-urls.mjs @@ -14,14 +14,14 @@ import { readFileSync, existsSync, readdirSync } from "fs"; import { join, dirname } from "path"; import { fileURLToPath } from "url"; -import yaml from "js-yaml"; +import { load } from "js-yaml"; const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url)); const REPO_ROOT = join(SCRIPT_DIR, "../.."); const VERSION_DIR = /^v\d+$/i; function defaultBaseUrl() { - const testsConfig = yaml.load( + const testsConfig = load( readFileSync(join(SCRIPT_DIR, "config/tests.yaml"), "utf8"), ); return testsConfig.baseUrl; @@ -44,7 +44,7 @@ function parseFrontmatter(content) { const m = content.match(/^---\r?\n([\s\S]*?)\r?\n---/); if (!m) return {}; try { - return yaml.load(m[1]) ?? {}; + return load(m[1]) ?? {}; } catch { return {}; } diff --git a/tools/automated-tests/generate-instructions-files.js b/tools/automated-tests/generate-instructions-files.js index 6fae45c2b09..5cf26024ae7 100644 --- a/tools/automated-tests/generate-instructions-files.js +++ b/tools/automated-tests/generate-instructions-files.js @@ -1,4 +1,4 @@ -import yaml from "js-yaml"; +import { load } from "js-yaml"; import fs from "fs/promises"; import minimist from "minimist"; import { generateInstructionFiles } from "./instructions/extractor.js"; @@ -10,7 +10,7 @@ import { collectUrls } from "./collect-urls.mjs"; try { const args = minimist(process.argv.slice(2)); const fileContent = await fs.readFile("./config/tests.yaml", "utf8"); - const testsConfig = yaml.load(fileContent); + const testsConfig = load(fileContent); let urlsToTest; let howToFiles; let haltOnSeriesError = true; diff --git a/tools/automated-tests/instructions-file.js b/tools/automated-tests/instructions-file.js index 43fa4b6f9b1..cc18c365a59 100644 --- a/tools/automated-tests/instructions-file.js +++ b/tools/automated-tests/instructions-file.js @@ -2,7 +2,7 @@ import fs from "fs/promises"; import { glob } from "tinyglobby"; import matter from "gray-matter"; import path from "path"; -import yaml from "js-yaml"; +import { dump } from "js-yaml"; function fileToUrl(file) { return file.replace("../../app/_how-tos/", "").replace(".md", "/"); @@ -94,7 +94,7 @@ export async function testeableUrlsFromFiles(config, files, { explicit = false } } } } - await fs.writeFile(".automated-tests", yaml.dump(skipped), "utf-8"); + await fs.writeFile(".automated-tests", dump(skipped), "utf-8"); return howTosUrls; } diff --git a/tools/automated-tests/instructions/extractor.js b/tools/automated-tests/instructions/extractor.js index 8b96fd35d79..f9e35fd98f0 100644 --- a/tools/automated-tests/instructions/extractor.js +++ b/tools/automated-tests/instructions/extractor.js @@ -1,7 +1,7 @@ import { chromium } from "playwright"; import fs from "fs/promises"; import path from "path"; -import yaml from "js-yaml"; +import { dump } from "js-yaml"; class NonFirstSeriesPageError extends Error {} @@ -283,7 +283,7 @@ async function writeInstructionsToFile(url, config, platform, product, instructi const instructionsDir = path.dirname(instructionsFile); await fs.mkdir(instructionsDir, { recursive: true }); - await fs.writeFile(instructionsFile, yaml.dump(instructions), "utf-8"); + await fs.writeFile(instructionsFile, dump(instructions), "utf-8"); return instructionsFile; } diff --git a/tools/automated-tests/instructions/runner.js b/tools/automated-tests/instructions/runner.js index 7f7363fb6c1..605b6575c58 100644 --- a/tools/automated-tests/instructions/runner.js +++ b/tools/automated-tests/instructions/runner.js @@ -1,5 +1,5 @@ import fs from "fs/promises"; -import yaml from "js-yaml"; +import { load } from "js-yaml"; import debug from "debug"; import { processPrereqs } from "./prereqs.js"; import { processCleanup } from "./cleanup.js"; @@ -228,7 +228,7 @@ export async function runInstructionsFile(file, runtimeConfig, container) { const start = Date.now(); log(`Running file: ${file}`); const fileContent = await fs.readFile(file, "utf8"); - const instructions = yaml.load(fileContent); + const instructions = load(fileContent); const { status, assertions, name } = await runInstructions( instructions, runtimeConfig, diff --git a/tools/automated-tests/instructions/validations.js b/tools/automated-tests/instructions/validations.js index 9907c3485b3..4e506d17b7c 100644 --- a/tools/automated-tests/instructions/validations.js +++ b/tools/automated-tests/instructions/validations.js @@ -8,7 +8,7 @@ import path from "path"; import { dirname } from "path"; import { fileURLToPath } from "url"; -import yaml from "js-yaml"; +import { load } from "js-yaml"; import { setEnvVariable, @@ -20,7 +20,7 @@ const log = debug("tests:runner"); const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -const testsConfig = yaml.load(fs.readFileSync("./config/tests.yaml", "utf-8")); +const testsConfig = load(fs.readFileSync("./config/tests.yaml", "utf-8")); const skipEnvVariables = new Set( testsConfig.validations?.skip_env_variables ?? [], ); diff --git a/tools/automated-tests/package-lock.json b/tools/automated-tests/package-lock.json index 6bf51ded284..48a6b430010 100644 --- a/tools/automated-tests/package-lock.json +++ b/tools/automated-tests/package-lock.json @@ -15,7 +15,7 @@ "fetch-cookie": "^3.1.0", "formdata-node": "^6.0.3", "gray-matter": "^4.0.3", - "js-yaml": "^4.1.0", + "js-yaml": "^5.0.0", "minimist": "^1.2.8", "node-fetch": "^3.3.2", "playwright": "^1.54.2", @@ -987,9 +987,9 @@ } }, "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==", + "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", @@ -1005,7 +1005,7 @@ "argparse": "^2.0.1" }, "bin": { - "js-yaml": "bin/js-yaml.js" + "js-yaml": "bin/js-yaml.mjs" } }, "node_modules/json-schema-traverse": { diff --git a/tools/automated-tests/package.json b/tools/automated-tests/package.json index 3016705bbc1..f70db60428e 100644 --- a/tools/automated-tests/package.json +++ b/tools/automated-tests/package.json @@ -17,7 +17,7 @@ "fetch-cookie": "^3.1.0", "formdata-node": "^6.0.3", "gray-matter": "^4.0.3", - "js-yaml": "^4.1.0", + "js-yaml": "^5.0.0", "minimist": "^1.2.8", "node-fetch": "^3.3.2", "playwright": "^1.54.2", diff --git a/tools/automated-tests/reporting.js b/tools/automated-tests/reporting.js index fe34b12c4ef..05250c7b3a7 100644 --- a/tools/automated-tests/reporting.js +++ b/tools/automated-tests/reporting.js @@ -1,7 +1,7 @@ import fs from "fs/promises"; -import yaml from "js-yaml"; +import { load } from "js-yaml"; -const expectedFailures = yaml.load( +const expectedFailures = load( await fs.readFile("./config/expected_failures.yaml", "utf-8") ); @@ -128,9 +128,8 @@ export async function logResults( if (includeGlobalSkips) { let skippedInstructions; try { - skippedInstructions = yaml.load( - await fs.readFile("./.automated-tests", "utf-8") - ); + const content = await fs.readFile("./.automated-tests", "utf-8"); + skippedInstructions = content.trim() ? load(content) : []; } catch (error) { if (error.code !== "ENOENT") throw error; } diff --git a/tools/automated-tests/run.js b/tools/automated-tests/run.js index 8c4b7a67ea6..e8d05a572ae 100644 --- a/tools/automated-tests/run.js +++ b/tools/automated-tests/run.js @@ -1,5 +1,5 @@ import fs from "fs/promises"; -import yaml from "js-yaml"; +import { load } from "js-yaml"; import Dockerode from "dockerode"; import minimist from "minimist"; import { logResult, logResults, isFailureExpected } from "./reporting.js"; @@ -40,7 +40,7 @@ export async function loadConfig() { const configFile = "./config/tests.yaml"; const fileContent = await fs.readFile(configFile, "utf8"); - const config = yaml.load(fileContent); + const config = load(fileContent); return config; } @@ -52,7 +52,7 @@ export async function loadConfig() { // ever starts, then boot it once for the rest of the batch as usual. async function usesStandaloneGateway(file) { const fileContent = await fs.readFile(file, "utf8"); - const instructions = yaml.load(fileContent); + const instructions = load(fileContent); const { standaloneGateway } = await getSetupConfig(instructions.setup); return Boolean(standaloneGateway); } diff --git a/tools/automated-tests/runtimes.js b/tools/automated-tests/runtimes.js index 673dad5490a..7fc0d5a3b21 100644 --- a/tools/automated-tests/runtimes.js +++ b/tools/automated-tests/runtimes.js @@ -1,6 +1,6 @@ import debug from "debug"; import fs from "fs/promises"; -import yaml from "js-yaml"; +import { load } from "js-yaml"; import { executeCommand, fetchImage, setEnvVariable } from "./docker-helper.js"; import path from "path"; import { dirname } from "path"; @@ -12,7 +12,7 @@ const __dirname = dirname(__filename); export async function getRuntimeConfig(deploymentModel, product) { const fileContent = await fs.readFile(`./config/runtimes.yaml`, "utf8"); - const configs = yaml.load(fileContent); + const configs = load(fileContent); const imageName = `automated-tests`; if (!configs[deploymentModel]) { diff --git a/tools/changelog-generator/changelog.js b/tools/changelog-generator/changelog.js index cb25e383949..df95b929b8b 100644 --- a/tools/changelog-generator/changelog.js +++ b/tools/changelog-generator/changelog.js @@ -1,5 +1,5 @@ import fs from "fs"; -import yaml from "js-yaml"; +import { load } from "js-yaml"; import path from "path"; import { globSync } from "tinyglobby"; import mergeWith from "lodash.mergewith"; @@ -61,7 +61,7 @@ function generateChangelog(product) { .map((file) => "./" + path.join(versionPath, file)); const entries = files.flatMap((f) => - yaml.load(fs.readFileSync(f, "utf-8")) + load(fs.readFileSync(f, "utf-8")) ); entries_by_version[version] = entries; } diff --git a/tools/changelog-generator/package-lock.json b/tools/changelog-generator/package-lock.json index 47771d8bc46..f60f29d5315 100644 --- a/tools/changelog-generator/package-lock.json +++ b/tools/changelog-generator/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "js-yaml": "^4.1.0", + "js-yaml": "^5.0.0", "lodash.mergewith": "^4.6.2", "minimist": "^1.2.8", "tinyglobby": "^0.2.12" @@ -39,9 +39,9 @@ } }, "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==", + "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", @@ -57,7 +57,7 @@ "argparse": "^2.0.1" }, "bin": { - "js-yaml": "bin/js-yaml.js" + "js-yaml": "bin/js-yaml.mjs" } }, "node_modules/lodash.mergewith": { diff --git a/tools/changelog-generator/package.json b/tools/changelog-generator/package.json index 5f0c01ecb00..05718cb755b 100644 --- a/tools/changelog-generator/package.json +++ b/tools/changelog-generator/package.json @@ -8,7 +8,7 @@ "license": "MIT", "dependencies": { "tinyglobby": "^0.2.12", - "js-yaml": "^4.1.0", + "js-yaml": "^5.0.0", "lodash.mergewith": "^4.6.2", "minimist": "^1.2.8" } diff --git a/tools/changelog-generator/run.js b/tools/changelog-generator/run.js index 4c758f5925d..3da00b116d4 100644 --- a/tools/changelog-generator/run.js +++ b/tools/changelog-generator/run.js @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { globSync } from "tinyglobby"; import minimist from "minimist"; -import yaml from "js-yaml"; +import { load } from "js-yaml"; import { compareVersions } from "./compare-versions.js"; function generateChangelogsByVersion(folderPath, version, product) { @@ -19,13 +19,13 @@ function generateChangelogsByVersion(folderPath, version, product) { }); let changelog = {}; - const setup = yaml.load(fs.readFileSync("./config/setup.yaml", "utf-8")); + const setup = load(fs.readFileSync("./config/setup.yaml", "utf-8")); folders.forEach((folder) => { const key = path.basename(folder); changelog[key] = []; const entries = globSync(`${folder}/*`); entries.forEach((entry) => { - const change = yaml.load(fs.readFileSync(entry, "utf-8")); + const change = load(fs.readFileSync(entry, "utf-8")); if (!change.hasOwnProperty("scope")) { change.scope = setup.defaults.scope; } diff --git a/tools/missing-redirects/index.js b/tools/missing-redirects/index.js index 6123759df0d..dd4d9aa67f2 100644 --- a/tools/missing-redirects/index.js +++ b/tools/missing-redirects/index.js @@ -2,7 +2,7 @@ import { execSync } from "node:child_process"; import fs from "node:fs"; import path from "node:path"; import matter from "gray-matter"; -import yaml from "js-yaml"; +import { load } from "js-yaml"; import minimist from "minimist"; const argv = minimist(process.argv.slice(2)); @@ -30,7 +30,7 @@ const collectionPermalinks = (function () { const configFile = "../../jekyll.yml"; let permalinks = {}; if (fs.existsSync(configFile)) { - const config = yaml.load(fs.readFileSync(configFile, "utf8")); + const config = load(fs.readFileSync(configFile, "utf8")); if (config.defaults) { for (const def of config.defaults) { if (def.scope?.path?.startsWith("_") && def.values?.permalink) { diff --git a/tools/missing-redirects/package-lock.json b/tools/missing-redirects/package-lock.json index c9509b90aed..0ea9d3dc786 100644 --- a/tools/missing-redirects/package-lock.json +++ b/tools/missing-redirects/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "gray-matter": "^4.0.3", - "js-yaml": "^4.1.0", + "js-yaml": "^5.0.0", "minimist": "^1.2.8" } }, @@ -92,9 +92,9 @@ } }, "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==", + "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", @@ -110,7 +110,7 @@ "argparse": "^2.0.1" }, "bin": { - "js-yaml": "bin/js-yaml.js" + "js-yaml": "bin/js-yaml.mjs" } }, "node_modules/kind-of": { diff --git a/tools/missing-redirects/package.json b/tools/missing-redirects/package.json index 22139e41e2e..96374e5712b 100644 --- a/tools/missing-redirects/package.json +++ b/tools/missing-redirects/package.json @@ -11,7 +11,7 @@ "license": "MIT", "dependencies": { "gray-matter": "^4.0.3", - "js-yaml": "^4.1.0", + "js-yaml": "^5.0.0", "minimist": "^1.2.8" } } diff --git a/tools/plugins-changelog-generator/package-lock.json b/tools/plugins-changelog-generator/package-lock.json index 8c84e562853..bc084e558fb 100644 --- a/tools/plugins-changelog-generator/package-lock.json +++ b/tools/plugins-changelog-generator/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "gray-matter": "^4.0.3", - "js-yaml": "^4.1.1", + "js-yaml": "^5.0.0", "minimist": "^1.2.8", "semver": "^7.7.2", "tinyglobby": "^0.2.12" @@ -111,9 +111,9 @@ } }, "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==", + "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", @@ -129,7 +129,7 @@ "argparse": "^2.0.1" }, "bin": { - "js-yaml": "bin/js-yaml.js" + "js-yaml": "bin/js-yaml.mjs" } }, "node_modules/kind-of": { diff --git a/tools/plugins-changelog-generator/package.json b/tools/plugins-changelog-generator/package.json index 2389594633e..920ad941b9d 100644 --- a/tools/plugins-changelog-generator/package.json +++ b/tools/plugins-changelog-generator/package.json @@ -9,7 +9,7 @@ "dependencies": { "tinyglobby": "^0.2.12", "gray-matter": "^4.0.3", - "js-yaml": "^4.1.1", + "js-yaml": "^5.0.0", "minimist": "^1.2.8", "semver": "^7.7.2" } diff --git a/tools/plugins-changelog-generator/run.js b/tools/plugins-changelog-generator/run.js index a64f3908589..cae357c750c 100644 --- a/tools/plugins-changelog-generator/run.js +++ b/tools/plugins-changelog-generator/run.js @@ -3,14 +3,14 @@ import { existsSync, writeFileSync } from "fs"; import { glob } from "tinyglobby"; import matter from "gray-matter"; import path from "path"; -import yaml from "js-yaml"; +import { load } from "js-yaml"; import semver from "semver"; import minimist from "minimist"; const PLUGIN_DOCS = "improved plugin documentation"; const file = await fs.readFile("./config/mappings.yaml", "utf8"); -const mappings = yaml.load(file); +const mappings = load(file); function findPluginMapping(plugin) { return Object.entries(mappings)