|
| 1 | +import assert from 'node:assert/strict'; |
| 2 | +import { mkdtemp, mkdir, writeFile, rm } from 'node:fs/promises'; |
| 3 | +import os from 'node:os'; |
| 4 | +import path from 'node:path'; |
| 5 | + |
| 6 | +import { discoverSkillPackageFiles } from '../bin/lib/package-files.mjs'; |
| 7 | + |
| 8 | +const tempRoot = await mkdtemp(path.join(os.tmpdir(), 'skill-publish-test-')); |
| 9 | + |
| 10 | +try { |
| 11 | + await writeFile(path.join(tempRoot, 'SKILL.md'), '# Test skill\n'); |
| 12 | + await writeFile(path.join(tempRoot, 'skill.json'), '{"name":"test-skill","version":"1.0.0"}\n'); |
| 13 | + await mkdir(path.join(tempRoot, '.github', 'workflows'), { recursive: true }); |
| 14 | + await writeFile(path.join(tempRoot, '.github', 'workflows', 'publish.yml'), 'name: publish\n'); |
| 15 | + await mkdir(path.join(tempRoot, '.hidden-cache'), { recursive: true }); |
| 16 | + await writeFile(path.join(tempRoot, '.hidden-cache', 'artifact.txt'), 'secret-ish\n'); |
| 17 | + await mkdir(path.join(tempRoot, 'docs'), { recursive: true }); |
| 18 | + await writeFile(path.join(tempRoot, 'docs', 'guide.md'), 'Guide\n'); |
| 19 | + await writeFile(path.join(tempRoot, '.env.local'), 'RB_API_KEY=should-not-ship\n'); |
| 20 | + |
| 21 | + const result = await discoverSkillPackageFiles(tempRoot); |
| 22 | + const included = result.includedFiles.map((file) => file.relativePath).sort(); |
| 23 | + const excluded = result.excludedFiles.map((file) => `${file.relativePath}:${file.reason}`).sort(); |
| 24 | + |
| 25 | + assert.deepEqual(included, ['SKILL.md', 'docs/guide.md', 'skill.json']); |
| 26 | + assert.ok(excluded.includes('.github/:blocked-directory')); |
| 27 | + assert.ok(excluded.includes('.hidden-cache/:hidden-path')); |
| 28 | + assert.ok(excluded.includes('.env.local:hidden-path')); |
| 29 | + |
| 30 | + process.stdout.write('package-files discovery test passed\n'); |
| 31 | +} finally { |
| 32 | + await rm(tempRoot, { recursive: true, force: true }); |
| 33 | +} |
0 commit comments