{"version":65,"agent":"infra-pipeline","message":"Pipelines: a built-in npm-publish step. It publishes the npm packages a job's kept .tgz files hold, and needs from: plus a packages list of the names it may publish; a name that isn't an npm package name is refused.","time":1791602951177,"timeIso":"2026-10-10T03:29:11.177Z","changes":2,"change":824,"files":["src/pipeline/pipeline.ts","src/pipeline/test/pipeline.test.ts"],"draft":null,"diff":[{"path":"src/pipeline/pipeline.ts","added":18,"removed":1,"diff":"--- a/src/pipeline/pipeline.ts\n+++ b/src/pipeline/pipeline.ts\n@@ -68,7 +68,7 @@\n \t| { readonly ok: true; readonly file: PipelineFile }\n \t| { readonly ok: false; readonly problems: readonly Problem[] };\n \n-export const BUILT_INS = [\"deploy\", \"preview\", \"notify\"] as const;\n+export const BUILT_INS = [\"deploy\", \"preview\", \"notify\", \"npm-publish\"] as const;\n export type BuiltIn = (typeof BUILT_INS)[number];\n \n /** Each built-in step's own settings, beside the keys every job has. */\n@@ -76,8 +76,13 @@\n \tdeploy: [\"worker\", \"staging\", \"live\"],\n \tpreview: [],\n \tnotify: [\"to\"],\n+\t// The npm packages it may publish, from the .tgz files its from: job kept.\n+\t\"npm-publish\": [\"packages\"],\n };\n \n+/** An npm package name: lower case, URL-safe, optionally under a @scope/. */\n+const NPM_NAME = /^(@[a-z0-9-~][a-z0-9-._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$/;\n+\n const TRIGGERS = [\"publish\", \"draft\", \"green\", \"land\", \"hand\"] as const;\n const SIZES: readonly Size[] = [\"small\", \"standard\", \"large\"];\n const MACHINE_KEYS = [\"image\", \"dockerfile\", \"size\"] as const;\n@@ -277,6 +282,18 @@\n \tfor (const k of settings) if (j[k] !== undefined) withs[k] = j[k];\n \tif (uses === \"deploy\" && typeof j.worker !== \"string\")\n \t\tsay(`${at}.worker`, \"names the Worker deploy ships, and is missing\");\n+\tif (uses === \"npm-publish\") {\n+\t\tif (j.from === undefined)\n+\t\t\tsay(`${at}.from`, \"names the job whose kept .tgz files npm-publish publishes, and is missing\");\n+\t\tconst packages = j.packages;\n+\t\tif (!Array.isArray(packages) || packages.length === 0)\n+\t\t\tsay(`${at}.packages`, \"lists the npm packages npm-publish may publish, and is missing\");\n+\t\telse\n+\t\t\tpackages.forEach((p, i) => {\n+\t\t\t\tif (typeof p !== \"string\" || p.length > 214 || !NPM_NAME.test(p))\n+\t\t\t\t\tsay(`${at}.packages[${i}]`, `${q(p)} isn't an npm package name`);\n+\t\t\t});\n+\t}\n \treturn {\n \t\tname,\n \t\tneeds: list(j.needs, `${at}.needs`, say, \"a list of job names\"),"},{"path":"src/pipeline/test/pipeline.test.ts","added":29,"removed":0,"diff":"--- a/src/pipeline/test/pipeline.test.ts\n+++ b/src/pipeline/test/pipeline.test.ts\n@@ -216,6 +216,35 @@\n \t\tok(checkPipelines(one({ a: { run: \"npm test\" } }, { on: [\"draft\"] })));\n \t});\n \n+\tit(\"npm-publish: the packages it may publish, from a job's kept files\", () => {\n+\t\tconst pack = { run: \"npm pack --pack-destination out\", keep: [\"out\"] };\n+\t\tconst read = checkPipelines(\n+\t\t\tone({\n+\t\t\t\tpack,\n+\t\t\t\tpublish: { uses: \"npm-publish\", from: \"p.pack\", needs: [\"pack\"], packages: [\"@scope/tool\", \"tool\"] },\n+\t\t\t}),\n+\t\t);\n+\t\tok(read);\n+\t\tconst job = read.ok ? read.file.pipelines[0]!.jobs.find((j) => j.name === \"publish\") : undefined;\n+\t\tassert.equal(job?.uses, \"npm-publish\");\n+\t\tassert.deepEqual(job?.with, { packages: [\"@scope/tool\", \"tool\"] });\n+\t\tconst ps = problems(\n+\t\t\tcheckPipelines(\n+\t\t\t\tone({\n+\t\t\t\t\tpack,\n+\t\t\t\t\ta: { uses: \"npm-publish\", packages: [\"tool\"] },\n+\t\t\t\t\tb: { uses: \"npm-publish\", from: \"p.pack\" },\n+\t\t\t\t\tc: { uses: \"npm-publish\", from: \"p.pack\", packages: [\"Tool\", \"@scope\", 7] },\n+\t\t\t\t}),\n+\t\t\t),\n+\t\t);\n+\t\thas(ps, \"pipelines.p.jobs.a.from\", /is missing/);\n+\t\thas(ps, \"pipelines.p.jobs.b.packages\", /is missing/);\n+\t\thas(ps, \"pipelines.p.jobs.c.packages[0]\", /isn't an npm package name/);\n+\t\thas(ps, \"pipelines.p.jobs.c.packages[1]\", /isn't an npm package name/);\n+\t\thas(ps, \"pipelines.p.jobs.c.packages[2]\", /isn't an npm package name/);\n+\t});\n+\n \tit(\"keys it doesn't know, at every level\", () => {\n \t\tconst ps = problems(\n \t\t\tcheckPipelines({"}],"ci":null}