- iapl-skills: --dest is compared with the project root after resolving links; a folder that is the root or holds it (.., /) is refused - starter: collectBundle refuses symbolic links (their target would ship in the published bundle); writeFiles refuses absolute or escaping paths - form files: a program inside a DOCX/XLSX is found with trailing dots or spaces (Windows drops them) - proxy matcher: (?!(?:api|admin|_next)(?:/|$)|...) so /administracja, /apis get the proxy; doctor rule proxy-matcher reports the old literal - pnpm: @swc/core in ignoredBuiltDependencies (its postinstall only checks the native binary, already installed) Co-Authored-By: Claude Opus 5.5 <[email protected]>
61 lines
2.8 KiB
TypeScript
61 lines
2.8 KiB
TypeScript
/**
|
|
* `iapl-skills --dest`: the "not the project root" rule is checked on RESOLVED paths. Before 1.17.1 the check
|
|
* compared the paths as typed, so `--dest root-link` (a link to `.`), `--dest ..` or `--dest /` passed it, and the
|
|
* run removed the `iapl-*` folders of the project root, its parent or the filesystem root (IAWL idea 13).
|
|
*/
|
|
import { spawnSync } from 'node:child_process'
|
|
import { existsSync, mkdirSync, mkdtempSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import path from 'node:path'
|
|
import { afterAll, describe, expect, test } from 'vitest'
|
|
|
|
const bin = path.resolve(import.meta.dirname, '../bin/iapl-skills.mjs')
|
|
const made: string[] = []
|
|
afterAll(() => {
|
|
for (const dir of made) {rmSync(dir, { force: true, recursive: true })}
|
|
})
|
|
|
|
/** A throw-away project: a parent folder holding `project/` with an `iapl-mine` folder in its root. */
|
|
function project() {
|
|
const parent = realpathSync(mkdtempSync(path.join(tmpdir(), 'iapl-skills-dest-')))
|
|
made.push(parent)
|
|
const dir = path.join(parent, 'project')
|
|
mkdirSync(path.join(dir, 'iapl-mine'), { recursive: true })
|
|
writeFileSync(path.join(dir, 'iapl-mine', 'keep.txt'), 'the project root holds this folder')
|
|
mkdirSync(path.join(parent, 'iapl-next-door'))
|
|
return { dir, parent }
|
|
}
|
|
|
|
const run = (cwd: string, dest: string) =>
|
|
spawnSync(process.execPath, [bin, '--dest', dest, '--no-pointer'], { cwd, encoding: 'utf8' })
|
|
|
|
describe('iapl-skills --dest is judged after the path is resolved', () => {
|
|
test('a link to the project root is refused and the root keeps its iapl-* folders', () => {
|
|
const { dir } = project()
|
|
symlinkSync('.', path.join(dir, 'root-link'))
|
|
const result = run(dir, 'root-link')
|
|
expect(result.status, result.stdout).toBe(1)
|
|
expect(result.stderr).toMatch(/not the project root/)
|
|
expect(existsSync(path.join(dir, 'iapl-mine', 'keep.txt'))).toBe(true)
|
|
})
|
|
|
|
test('a folder that holds the project (the parent, the filesystem root) is refused', () => {
|
|
const { dir, parent } = project()
|
|
for (const dest of ['..', '/', parent]) {
|
|
const result = run(dir, dest)
|
|
expect([dest, result.status]).toEqual([dest, 1])
|
|
}
|
|
expect(existsSync(path.join(parent, 'iapl-next-door'))).toBe(true)
|
|
})
|
|
|
|
test('a folder inside the project, a new one, or one elsewhere still works', () => {
|
|
const { dir, parent } = project()
|
|
expect(run(dir, '.agents/skills').status).toBe(0)
|
|
expect(existsSync(path.join(dir, '.agents/skills/iapl-setup/SKILL.md'))).toBe(true)
|
|
const shared = path.join(parent, 'shared-skills')
|
|
expect(run(dir, shared).status).toBe(0)
|
|
expect(existsSync(path.join(shared, 'iapl-setup/SKILL.md'))).toBe(true)
|
|
expect(existsSync(path.join(dir, 'iapl-mine', 'keep.txt'))).toBe(true)
|
|
})
|
|
})
|