-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathinstall-global.js
More file actions
executable file
·89 lines (75 loc) · 2.61 KB
/
install-global.js
File metadata and controls
executable file
·89 lines (75 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env node
/**
* Install WebPerf Skills globally to ~/.claude/skills
*
* This allows the skills to be used across any Claude Code session,
* not just within this project.
*
* Run: npm run install-global
* Or: node scripts/install-global.js
*/
const fs = require('fs')
const path = require('path')
const os = require('os')
const { execSync } = require('child_process')
const ROOT = path.join(__dirname, '..')
const SKILLS_SRC = path.join(ROOT, 'skills')
const HOME_CLAUDE_SKILLS = path.join(os.homedir(), '.claude', 'skills')
function main() {
console.log('🌍 Installing WebPerf Skills globally...\n')
// Step 1: Generate skills
console.log('1️⃣ Generating skills...')
try {
execSync('node scripts/generate-skills.js', { cwd: ROOT, stdio: 'inherit' })
} catch {
console.error('❌ Failed to generate skills')
process.exit(1)
}
// Step 2: Create ~/.claude/skills directory
console.log('\n2️⃣ Creating ~/.claude/skills directory...')
fs.mkdirSync(HOME_CLAUDE_SKILLS, { recursive: true })
// Step 3: Copy skills to ~/.claude/skills
console.log('3️⃣ Copying skills to ~/.claude/skills/...')
const skillDirs = fs.readdirSync(SKILLS_SRC).filter((f) => {
const stat = fs.statSync(path.join(SKILLS_SRC, f))
return stat.isDirectory()
})
for (const skillDir of skillDirs) {
const src = path.join(SKILLS_SRC, skillDir)
const dest = path.join(HOME_CLAUDE_SKILLS, skillDir)
// Remove existing skill directory
if (fs.existsSync(dest)) {
fs.rmSync(dest, { recursive: true, force: true })
}
// Copy skill directory recursively
copyDir(src, dest)
console.log(` ✓ ${skillDir}`)
}
console.log('\n✅ Skills installed globally to ~/.claude/skills!')
console.log('\n📝 To use these skills in Claude Code, ensure they are registered in')
console.log(' your project\'s .claude/settings.json:')
console.log('\n {')
console.log(' "skills": [')
skillDirs.forEach((name, idx) => {
const comma = idx < skillDirs.length - 1 ? ',' : ''
console.log(` { "path": "~/.claude/skills/${name}" }${comma}`)
})
console.log(' ]')
console.log(' }')
console.log('\nAvailable skills:')
skillDirs.forEach((name) => console.log(` - ${name}`))
}
function copyDir(src, dest) {
fs.mkdirSync(dest, { recursive: true })
for (const entry of fs.readdirSync(src)) {
const srcPath = path.join(src, entry)
const destPath = path.join(dest, entry)
const stat = fs.statSync(srcPath)
if (stat.isDirectory()) {
copyDir(srcPath, destPath)
} else {
fs.copyFileSync(srcPath, destPath)
}
}
}
main()