53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { spawnSync } from 'node:child_process'
|
|
import { existsSync, lstatSync, readFileSync } from 'node:fs'
|
|
import { dirname, join } from 'node:path'
|
|
import test from 'node:test'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { cleanup, tempDir, write } from './helpers.mjs'
|
|
|
|
const here = dirname(fileURLToPath(import.meta.url))
|
|
const script = join(here, '..', 'install.sh')
|
|
|
|
test('install.sh copies skills and roles instead of linking into ~/.claude', () => {
|
|
const home = tempDir()
|
|
try {
|
|
const dshHome = join(home, '.dsh')
|
|
const cache = join(
|
|
home,
|
|
'.claude',
|
|
'plugins',
|
|
'cache',
|
|
'claude-plugins-official',
|
|
'superpowers',
|
|
'7.0.0',
|
|
'skills',
|
|
)
|
|
write(join(cache, 'using-superpowers', 'SKILL.md'), '---\nname: using-superpowers\n---\nbody\n')
|
|
write(join(cache, 'brainstorming', 'SKILL.md'), '---\nname: brainstorming\n---\nbody\n')
|
|
|
|
const env = { ...process.env, HOME: home, DSH_HOME: dshHome }
|
|
const run = () => spawnSync('bash', [script, '--skills', '--roles'], { env, encoding: 'utf8' })
|
|
|
|
const first = run()
|
|
assert.equal(first.status, 0, first.stderr)
|
|
assert.match(first.stdout, /copied 2 superpowers skills/)
|
|
assert.match(first.stdout, /installed 4 roles/)
|
|
|
|
const skill = join(dshHome, 'skills', 'using-superpowers')
|
|
assert.equal(lstatSync(skill).isSymbolicLink(), false)
|
|
assert.equal(lstatSync(skill).isDirectory(), true)
|
|
assert.match(readFileSync(join(skill, 'SKILL.md'), 'utf8'), /body/)
|
|
|
|
for (const role of ['dev', 'admin', 'analyst', 'qa']) {
|
|
assert.ok(existsSync(join(dshHome, 'roles', `${role}.md`)), `missing ${role}.md`)
|
|
}
|
|
|
|
const second = run()
|
|
assert.equal(second.status, 0, second.stderr)
|
|
assert.equal(lstatSync(skill).isSymbolicLink(), false)
|
|
} finally {
|
|
cleanup(home)
|
|
}
|
|
})
|