Files
bensandler-stripe 45d2839fe8 Auto-install skill files on npm install (#212)
Add a postinstall script that copies the SKILL.md into
~/.claude/skills/ and ~/.codex/skills/ so the skill is
available globally without being inside the repo. Updated
prepack to bundle the skills directory into dist/.


Committed-By-Agent: claude

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-07-21 12:42:40 -04:00

51 lines
1.2 KiB
JavaScript

#!/usr/bin/env node
// Refresh the create-payment-credential skill whenever the CLI is (re)installed
// or upgraded via npm. Delegates to the openclaw `skills` CLI so the skill file
// stays in sync with the installed CLI version. Must never fail the install.
import { spawnSync } from 'node:child_process';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
const REPO = 'stripe/link-cli';
function run() {
// Skip when running from the source monorepo (dev `pnpm install`). Installed
// copies live under node_modules; the dev tree does not.
if (!fileURLToPath(import.meta.url).includes('node_modules')) {
return;
}
if (process.env.CI || process.env.LINK_CLI_SKIP_SKILL_INSTALL) {
return;
}
process.stdout.write(
'link-cli: refreshing the create-payment-credential skill…\n',
);
const result = spawnSync(
'npx',
['--yes', 'skills', 'add', REPO, '-g', '-y'],
{
stdio: 'inherit',
timeout: 60_000,
},
);
if (result.error || result.status !== 0) {
process.stdout.write(
`link-cli: skipped skill refresh; run 'npx skills add ${REPO}' manually.\n`,
);
}
}
try {
run();
} catch {
// Never fail the install.
}
process.exit(0);