diff --git a/scripts/aggregate-manifests.ts b/scripts/aggregate-manifests.ts index 4305f4a..a9e86d7 100644 --- a/scripts/aggregate-manifests.ts +++ b/scripts/aggregate-manifests.ts @@ -1,6 +1,6 @@ import { readFileSync, writeFileSync } from "fs"; import { glob } from "glob"; -import yaml from "js-yaml"; +import { load, dump } from "js-yaml"; import path from "path"; import { fileURLToPath } from "url"; @@ -64,7 +64,7 @@ async function main() { for (const file of manifestFiles.sort()) { const fullPath = path.join(SAMPLES, file); const content = readFileSync(fullPath, "utf-8"); - const manifest = yaml.load(content) as FrameworkManifest; + const manifest = load(content) as FrameworkManifest; frameworks[manifest.framework] = { label: manifest.label, @@ -110,10 +110,10 @@ async function main() { ); const output = { frameworks: orderedFrameworks, scenarios }; - const yamlStr = yaml.dump(output, { + const yamlStr = dump(output, { lineWidth: 120, noRefs: true, - quotingType: '"', + quoteStyle: "double", }); const outputPath = path.join(ROOT, "snippet-manifest.yaml"); writeFileSync( diff --git a/scripts/extract-snippets.ts b/scripts/extract-snippets.ts index ea65883..5826e2d 100644 --- a/scripts/extract-snippets.ts +++ b/scripts/extract-snippets.ts @@ -1,6 +1,6 @@ import { readdirSync, readFileSync, writeFileSync } from "fs"; import { glob } from "glob"; -import yaml from "js-yaml"; +import { load } from "js-yaml"; import path from "path"; import { fileURLToPath } from "url"; @@ -62,7 +62,7 @@ function getPlaceholderMap(): PlaceholderMap { path.join(ROOT, "placeholder-map.yaml"), "utf-8", ); - return yaml.load(content) as PlaceholderMap; + return load(content) as PlaceholderMap; } function applyPlaceholders( @@ -84,7 +84,7 @@ function getLibVersion( manifestDir: string, libOverride?: string, ): string { - const manifest = yaml.load( + const manifest = load( readFileSync(path.join(manifestDir, "manifest.yaml"), "utf-8"), ) as FrameworkManifest; const lib = libOverride ?? manifest.lib; @@ -135,7 +135,7 @@ function getLibVersion( // Flutter — pubspec.yaml dependencies try { - const pubspec = yaml.load( + const pubspec = load( readFileSync(path.join(scenarioDir, "pubspec.yaml"), "utf-8"), ) as { dependencies?: Record }; const dep = pubspec?.dependencies?.[lib]; @@ -223,9 +223,11 @@ function getLibVersion( // lives inside *.xcworkspace/, which is typically gitignored, so CI checkouts // can't see it; project.yml is the committed source of truth for SPM pins. try { - const projectYml = yaml.load( + const projectYml = load( readFileSync(path.join(scenarioDir, "project.yml"), "utf-8"), - ) as { packages?: Record }; + ) as { + packages?: Record; + }; const libLower = lib.toLowerCase(); for (const [name, pkg] of Object.entries(projectYml?.packages ?? {})) { const url = (pkg?.url || "").toLowerCase(); @@ -291,7 +293,9 @@ function getLibVersion( if (module === libLower) { // Extract version.ref or version from this entry const entry = libMatch[0]; - const versionRefMatch = entry.match(/version\.ref\s*=\s*["']([^"']+)["']/); + const versionRefMatch = entry.match( + /version\.ref\s*=\s*["']([^"']+)["']/, + ); if (versionRefMatch) { const ref = versionRefMatch[1]; const versionLineRegex = new RegExp( @@ -301,7 +305,9 @@ function getLibVersion( const vMatch = versionsBlock.match(versionLineRegex); if (vMatch) return vMatch[1]; } - const versionMatch = entry.match(/version\s*=\s*["']([0-9][^"']+)["']/); + const versionMatch = entry.match( + /version\s*=\s*["']([0-9][^"']+)["']/, + ); if (versionMatch) return versionMatch[1]; } } @@ -439,7 +445,7 @@ async function main() { for (const manifestFile of manifestFiles.sort()) { const frameworkDir = path.join(SAMPLES, path.dirname(manifestFile)); const content = readFileSync(path.join(SAMPLES, manifestFile), "utf-8"); - const manifest = yaml.load(content) as FrameworkManifest; + const manifest = load(content) as FrameworkManifest; const fw = manifest.framework; const lang = manifest.lang; diff --git a/scripts/package.json b/scripts/package.json index de2c93f..833e2ae 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -11,11 +11,10 @@ }, "dependencies": { "glob": "13.0.6", - "js-yaml": "4.2.0", + "js-yaml": "5.1.0", "tsx": "4.22.4" }, "devDependencies": { - "@types/js-yaml": "4.0.9", "@types/node": "26.0.1", "typescript": "6.0.3" } diff --git a/scripts/validate-structure.ts b/scripts/validate-structure.ts index b109c37..40ef08e 100644 --- a/scripts/validate-structure.ts +++ b/scripts/validate-structure.ts @@ -1,6 +1,6 @@ import { existsSync, readFileSync } from "fs"; import { glob } from "glob"; -import yaml from "js-yaml"; +import { load } from "js-yaml"; import path from "path"; import { fileURLToPath } from "url"; @@ -41,7 +41,7 @@ async function main() { for (const manifestFile of manifestFiles) { const frameworkDir = path.join(SAMPLES, path.dirname(manifestFile)); const content = readFileSync(path.join(SAMPLES, manifestFile), "utf-8"); - const manifest = yaml.load(content) as FrameworkManifest; + const manifest = load(content) as FrameworkManifest; for (const scenarioId of Object.keys(manifest.scenarios)) { const dirName = scenarioId.replace(/^[^_]+_/, "").replaceAll("_", "-"); diff --git a/scripts/yarn.lock b/scripts/yarn.lock index 7e0a640..1ba24e3 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock @@ -9,10 +9,9 @@ __metadata: version: 0.0.0-use.local resolution: "@ciam-quickstart/scripts@workspace:." dependencies: - "@types/js-yaml": "npm:4.0.9" "@types/node": "npm:26.0.1" glob: "npm:13.0.6" - js-yaml: "npm:4.2.0" + js-yaml: "npm:5.1.0" tsx: "npm:4.22.4" typescript: "npm:6.0.3" languageName: unknown @@ -245,13 +244,6 @@ __metadata: languageName: node linkType: hard -"@types/js-yaml@npm:4.0.9": - version: 4.0.9 - resolution: "@types/js-yaml@npm:4.0.9" - checksum: 10c0/24de857aa8d61526bbfbbaa383aa538283ad17363fcd5bb5148e2c7f604547db36646440e739d78241ed008702a8920665d1add5618687b6743858fae00da211 - languageName: node - linkType: hard - "@types/node@npm:26.0.1": version: 26.0.1 resolution: "@types/node@npm:26.0.1" @@ -546,14 +538,14 @@ __metadata: languageName: node linkType: hard -"js-yaml@npm:4.2.0": - version: 4.2.0 - resolution: "js-yaml@npm:4.2.0" +"js-yaml@npm:5.1.0": + version: 5.1.0 + resolution: "js-yaml@npm:5.1.0" dependencies: argparse: "npm:^2.0.1" bin: - js-yaml: bin/js-yaml.js - checksum: 10c0/1916456c118746603b067d74bbcbb0445d9a1d5e474ad4ae775e7b20525bed902e01d9d97dd0c81fcd8d4f596162309d0eb057f4aa38f3e9647f14075e9dea45 + js-yaml: bin/js-yaml.mjs + checksum: 10c0/a21c3817fb736ab3215c9d1ffb0a94823d02ecb51b481e88ab4bf0f9522baccbe9168bdf265bc315124d5087e2261de93e56176c2a7cd589d8275a18d7b3316e languageName: node linkType: hard