hookstack-cli 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.mjs +7 -10
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs'
|
|
3
3
|
import { homedir } from 'os'
|
|
4
|
-
import { join } from 'path'
|
|
4
|
+
import { join, dirname } from 'path'
|
|
5
5
|
import { fileURLToPath } from 'url'
|
|
6
6
|
import * as p from '@clack/prompts'
|
|
7
7
|
import pc from 'picocolors'
|
|
@@ -16,7 +16,9 @@ import {
|
|
|
16
16
|
} from './core.mjs'
|
|
17
17
|
|
|
18
18
|
const API_BASE = process.env.HOOKSTACK_API_BASE || 'https://hookstack.vercel.app'
|
|
19
|
-
const
|
|
19
|
+
const REPO_URL = 'github.com/steve-magne/hookstack'
|
|
20
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
21
|
+
const VERSION = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8')).version
|
|
20
22
|
|
|
21
23
|
async function fetchHooks(slugs) {
|
|
22
24
|
const url = `${API_BASE}/api/hooks?slugs=${slugs.map(encodeURIComponent).join(',')}`
|
|
@@ -171,6 +173,7 @@ async function interactiveInstall(slugs, args) {
|
|
|
171
173
|
}
|
|
172
174
|
s2.stop(`Wrote ${plural(result.scriptCount, 'script')} + patched settings.json`)
|
|
173
175
|
|
|
176
|
+
p.log.info(`⭐ star us → ${pc.cyan(REPO_URL)}`)
|
|
174
177
|
p.outro(pc.green(`✓ Installed ${plural(result.hookCount, 'hook')} — restart Claude Code to activate.`))
|
|
175
178
|
}
|
|
176
179
|
|
|
@@ -194,7 +197,7 @@ async function directInstall(slugs, args) {
|
|
|
194
197
|
const log = { warn: m => console.warn(` ! ${m}`) }
|
|
195
198
|
const result = doInstall(hooks, dirs, args.scope, log)
|
|
196
199
|
console.log(` ✓ ${dirs.settingsPath}`)
|
|
197
|
-
console.log(`\n✅
|
|
200
|
+
console.log(`\n✅ ${plural(result.hookCount, 'hook')} installed · star us → ${REPO_URL}`)
|
|
198
201
|
console.log(' Restart Claude Code to activate.\n')
|
|
199
202
|
}
|
|
200
203
|
|
|
@@ -220,7 +223,7 @@ async function main() {
|
|
|
220
223
|
const args = parseArgs(process.argv)
|
|
221
224
|
|
|
222
225
|
if (args.version) { console.log(VERSION); return }
|
|
223
|
-
if (args.help ||
|
|
226
|
+
if (args.help || args.hooks.length === 0) { console.log(HELP); return }
|
|
224
227
|
|
|
225
228
|
const command = args.command ?? 'install'
|
|
226
229
|
if (command !== 'install') {
|
|
@@ -229,12 +232,6 @@ async function main() {
|
|
|
229
232
|
process.exit(1)
|
|
230
233
|
}
|
|
231
234
|
|
|
232
|
-
if (args.hooks.length === 0) {
|
|
233
|
-
console.error('✗ No hooks specified. Use --hooks=<slug1>,<slug2>')
|
|
234
|
-
console.error(' Browse hooks at https://hookstack.vercel.app')
|
|
235
|
-
process.exit(1)
|
|
236
|
-
}
|
|
237
|
-
|
|
238
235
|
const interactive = Boolean(process.stdout.isTTY) && !args.yes
|
|
239
236
|
if (interactive) await interactiveInstall(args.hooks, args)
|
|
240
237
|
else await directInstall(args.hooks, args)
|