Skip to content
← Public packages

@kentcdodds/package-app-kit

Design tokens, PWA install/update, About/version, cache helpers, and optional realtime notes sync for Kody package apps.

FollowFork

starter-remix/scripts/publish.mjs

22 lines · 1.0 KB · JavaScript
#!/usr/bin/env node
// Publish what is pushed: `kody package publish <ref>`.
// <ref> 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 -- <package_id>
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 -- <package_id>\n(or set KODY_PACKAGE_ID).`,
	)
}
process.exit(result.status ?? 1)