Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"files": [
"dist",
"!dist/sea",
"postinstall.mjs",
"README.md",
"LICENSE"
],
Expand All @@ -24,6 +25,7 @@
"scripts": {
"build": "tsup",
"build:sea": "tsup --config tsup.sea.config.ts",
"postinstall": "node postinstall.mjs",
"prepack": "cp ../../README.md ../../LICENSE .",
"typecheck": "tsc",
"test": "vitest run",
Expand Down
50 changes: 50 additions & 0 deletions packages/cli/postinstall.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/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);
Loading