@jondeodat/claude-setup-cli 0.2.1 → 0.2.2
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/README.md +4 -0
- package/dist/claude-setup-cli.js +24 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -153,6 +153,10 @@ npm run push
|
|
|
153
153
|
- `npm run push` runs `npm publish`, whose `prepublishOnly` script first runs `npm run typecheck`,
|
|
154
154
|
`npm test`, `npm run format:check` and `npm run build`, and stops if one fails; then it publishes the
|
|
155
155
|
package, publicly, on registry.npmjs.org.
|
|
156
|
+
- With `ignore-scripts` set, `npm publish` skips `prepublishOnly` and ships whatever `dist/` holds, stale
|
|
157
|
+
or missing: `npm run push` passes `--ignore-scripts=false`, so publish with it rather than with
|
|
158
|
+
`npm publish`. A publish installs nothing, so this only lets the scripts of this `package.json` run, no
|
|
159
|
+
dependency's.
|
|
156
160
|
|
|
157
161
|
## License
|
|
158
162
|
|
package/dist/claude-setup-cli.js
CHANGED
|
@@ -13,12 +13,32 @@ than the min-release-age npm reads for the project (.npmrc).
|
|
|
13
13
|
|
|
14
14
|
The claude CLI rewrites .claude/settings.json in its own format: this tool puts the file back as it was.
|
|
15
15
|
It does nothing in CI (CI set), with CLAUDE_SETUP_SKIP set, or without the claude CLI, and never fails.
|
|
16
|
+
The claude CLI is the one CLAUDE_CODE_EXECPATH names, set by Claude Code in a hook, or else the one on
|
|
17
|
+
the PATH, whichever first answers --version as Claude Code.
|
|
16
18
|
|
|
17
19
|
Options:
|
|
18
20
|
--hook prints its report as the JSON output of a SessionStart hook, and nothing when there
|
|
19
21
|
is nothing to report
|
|
20
22
|
--max-age <hours> refreshes the marketplaces only when the last refresh is older (default: every run)
|
|
21
23
|
-h, --help prints this help`;
|
|
24
|
+
/**
|
|
25
|
+
* Finds the claude CLI to run: the one of the Claude Code session that started this tool, as a hook,
|
|
26
|
+
* which Claude Code names in CLAUDE_CODE_EXECPATH even when it is only installed as an IDE extension and
|
|
27
|
+
* puts no claude on the PATH; or else the claude on the PATH. CLAUDE_CODE_EXECPATH is not documented: it
|
|
28
|
+
* can name a binary removed by an update since, or one that is not the claude CLI, so each candidate must
|
|
29
|
+
* answer `--version` as Claude Code does
|
|
30
|
+
*/
|
|
31
|
+
function findClaude() {
|
|
32
|
+
const candidates = [process.env.CLAUDE_CODE_EXECPATH, 'claude'].filter((candidate) => !!candidate);
|
|
33
|
+
return candidates.find((candidate) => {
|
|
34
|
+
const probe = spawnSync(candidate, ['--version'], { encoding: 'utf8' });
|
|
35
|
+
return !probe.error && probe.status === 0 && probe.stdout.includes('Claude Code');
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The claude CLI to run, that main() finds before anything runs it
|
|
40
|
+
*/
|
|
41
|
+
let claude = 'claude';
|
|
22
42
|
/**
|
|
23
43
|
* A `claude plugin` command can clone a marketplace
|
|
24
44
|
*/
|
|
@@ -27,7 +47,7 @@ const CLAUDE_TIMEOUT_MS = 180_000;
|
|
|
27
47
|
* Runs `claude <args> --json` from the project root
|
|
28
48
|
*/
|
|
29
49
|
function runClaude(root, args) {
|
|
30
|
-
const child = spawnSync(
|
|
50
|
+
const child = spawnSync(claude, [...args, '--json'], { cwd: root, encoding: 'utf8', timeout: CLAUDE_TIMEOUT_MS });
|
|
31
51
|
if (child.error) {
|
|
32
52
|
return { error: `claude ${args.join(' ')}: ${child.error.message}` };
|
|
33
53
|
}
|
|
@@ -287,10 +307,11 @@ function main() {
|
|
|
287
307
|
const report = createReport();
|
|
288
308
|
const original = readFileSync(settingsPath, 'utf8');
|
|
289
309
|
try {
|
|
290
|
-
const
|
|
291
|
-
if (
|
|
310
|
+
const found = findClaude();
|
|
311
|
+
if (!found) {
|
|
292
312
|
return;
|
|
293
313
|
}
|
|
314
|
+
claude = found;
|
|
294
315
|
setUp(root, JSON.parse(original), maxAgeHours, report);
|
|
295
316
|
}
|
|
296
317
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jondeodat/claude-setup-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Registers the Claude Code marketplaces and installs the plugins that a project declares in .claude/settings.json, at project scope.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"format": "prettier --write .",
|
|
48
48
|
"format:check": "prettier --check .",
|
|
49
49
|
"prepublishOnly": "npm run typecheck && npm test && npm run format:check && npm run build",
|
|
50
|
-
"push": "npm publish"
|
|
50
|
+
"push": "npm publish --ignore-scripts=false"
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
53
53
|
"claude",
|