From 397411d555194a4e7e1fb471fd9e4a0bc41c1da7 Mon Sep 17 00:00:00 2001 From: Dean Harel Date: Wed, 17 Jun 2026 18:49:22 +0300 Subject: [PATCH] fix(publish): create spec dir on first publish into a pristine hub publish.ts assumed spec/ already existed (the hub was bootstrapped with a committed spec). On a first publish into a pristine hub the directory is absent and copyFileSync fails with ENOENT. mkdir -p the spec dir before writing. Validated locally end-to-end: pristine hub -> clean 'Initial published spec.' baseline, files written, commit+push OK. --- scripts/publish.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/publish.ts b/scripts/publish.ts index aa79483..ca4f080 100644 --- a/scripts/publish.ts +++ b/scripts/publish.ts @@ -5,6 +5,7 @@ // Run inside a clone of this repo with GH_TOKEN set (a contents:write token) and git configured to push. // Decision logic is in publish-logic.ts (unit-tested); this file is the I/O around it. import fs from 'node:fs'; +import path from 'node:path'; import { execFileSync } from 'node:child_process'; import { dump as toYaml } from 'js-yaml'; import { releaseTag } from './release-tag'; @@ -119,6 +120,8 @@ async function main(): Promise { fs.writeFileSync(CHANGELOG_FILE, `${CHANGELOG_HEADER}\n\n${entry}\n${priorEntries}`); // Write both formats: JSON for tooling, YAML for human-readable diffs and language-agnostic codegen. + // Ensure the spec dir exists: on the first publish into a pristine hub it may not yet. + fs.mkdirSync(path.dirname(SPEC_JSON), { recursive: true }); fs.copyFileSync(specPath, SPEC_JSON); fs.writeFileSync(SPEC_YAML, toYaml(incoming, { lineWidth: -1, noRefs: true })); fs.writeFileSync(PROVENANCE_FILE, `${JSON.stringify({ sequence, sha, timestamp: isoDate, tag } satisfies Provenance, null, 2)}\n`);