#!/usr/bin/env node // Publish what is pushed: `kody package publish `. // is, in order: the first CLI argument, KODY_PACKAGE_ID, or package.json#name. // Some CLI versions only accept the package UUID; if publishing by name fails, // pass the id (search `@owner/name` in Kody or open the package page to find it): // npm run publish:kody -- import { spawnSync } from 'node:child_process' import fs from 'node:fs' const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')) const ref = process.argv[2] || process.env.KODY_PACKAGE_ID || pkg.name const result = spawnSync('npx', ['--no-install', 'kody', 'package', 'publish', ref], { encoding: 'utf8', stdio: ['inherit', 'inherit', 'pipe'], }) if (result.stderr) process.stderr.write(result.stderr) if (result.status !== 0 && /package_id/.test(result.stderr ?? '') && ref === pkg.name) { console.error( `\nThis CLI version needs the package id. Re-run with: npm run publish:kody -- \n(or set KODY_PACKAGE_ID).`, ) } process.exit(result.status ?? 1)