From f4fb77a09ea02b5f0a2676dd2c66a57f569ab168 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sat, 14 Nov 2026 12:54:43 +0100 Subject: [PATCH] fix: write YAML config files in block style #85 switched the generated config files to JSON, which is valid YAML but leaves pnpm-workspace.yaml as a multi-line flow collection. pnpm 12 edits that file in place (`--allow-build` records `allowBuilds` there) and refuses to edit a flow collection, so bootstrapping the installer failed with ERR_PNPM_WORKSPACE_MANIFEST_WRITER_UNSUPPORTED_INLINE_BLOCK. yamlText now serializes with js-yaml's dump, which still quotes and escapes every value but emits block style. `noRefs` keeps shared objects from becoming aliases, which pnpm cannot edit either. Co-Authored-By: Claude Opus 5.5 --- benchmarkFixture.js | 15 +++++++++++---- package.json | 1 + pnpm-lock.yaml | 3 +++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/benchmarkFixture.js b/benchmarkFixture.js index 3c434b9..c6381d2 100644 --- a/benchmarkFixture.js +++ b/benchmarkFixture.js @@ -5,6 +5,7 @@ import { fileURLToPath } from 'node:url' import spawn from 'cross-spawn' import getFolderSize from 'get-folder-size' +import YAML from 'js-yaml' import pathKey from 'path-key' import rimraf from 'rimraf' import tempy from 'tempy' @@ -247,12 +248,18 @@ export function pnpmWorkspaceYaml (opts = {}) { } /** - * Serializes a config file that is read as YAML. JSON is valid YAML, and - * `JSON.stringify` quotes and escapes every value correctly, which - * hand-written YAML does only for values that happen not to need it. + * Serializes a config file that is read as YAML. A serializer quotes and + * escapes every value correctly, which hand-written YAML does only for values + * that happen not to need it. + * + * The output must be block-style YAML, not JSON: pnpm edits + * `pnpm-workspace.yaml` in place (`--allow-build` records `allowBuilds` + * there), and it refuses to edit a document that is a multi-line flow + * collection. `noRefs` keeps shared objects from being written as aliases, + * which pnpm cannot edit either. */ export function yamlText (value) { - return `${JSON.stringify(value, null, 2)}\n` + return YAML.dump(value, { noRefs: true }) } /** diff --git a/package.json b/package.json index 0e1d5de..7600c78 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "dependencies": { "cross-spawn": "^7.0.3", "get-folder-size": "^3.1.0", + "js-yaml": "^4.3.2", "load-yaml-file": "^1.0.0", "path-key": "^4.0.0", "rimraf": "^4.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4862936..f0f9d2e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -172,6 +172,9 @@ importers: get-folder-size: specifier: ^3.1.0 version: 3.1.0 + js-yaml: + specifier: ^4.3.2 + version: 4.3.2 load-yaml-file: specifier: ^1.0.0 version: 1.0.0