Files
stripe__link-cli/packages/cli/postinstall.mjs
Ben Sandler 9f20e4b8b2 cli: migrate legacy Incur skills
- Remove only Incur-recorded link-cli generated skills after authored-skill installation succeeds.
- Clear stale Incur metadata so unrelated commands stop advertising a recurring sync CTA.
- Force the child skills installer to resolve the public GitHub repository under Stripe GH_HOST settings.
- Cover successful migration, failed installation, and authored-skill preservation.

Committed-By-Agent: codex
Co-authored-by: codex <noreply@openai.com>
2026-09-11 11:40:18 -04:00

52 lines
1.3 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'],
{
env: { ...process.env, GH_HOST: 'github.com' },
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);