Skip to content

Commit 3184843

Browse files
committed
fix(schema-pack): 安装 schema 时跳过 examples 目录
1 parent ef60cdd commit 3184843

2 files changed

Lines changed: 46 additions & 3 deletions

File tree

plugins/aisee-plugin/skills/aisee-schema-pack/scripts/setup-schemas.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ function copySchema(sourceDir, targetDir, force) {
112112
removeDirRecursive(targetDir);
113113
}
114114
ensureDir(path.dirname(targetDir));
115-
copyDirRecursive(sourceDir, targetDir);
115+
copyDirRecursive(sourceDir, targetDir, {
116+
shouldSkipDir: (sourcePath, relativePath) => relativePath === 'examples'
117+
});
116118
return 'installed';
117119
}
118120

@@ -129,13 +131,16 @@ function removeDirRecursive(dir) {
129131
fs.rmdirSync(dir);
130132
}
131133

132-
function copyDirRecursive(sourceDir, targetDir) {
134+
function copyDirRecursive(sourceDir, targetDir, options = {}) {
135+
const { shouldSkipDir = () => false } = options;
133136
ensureDir(targetDir);
134137
for (const entry of fs.readdirSync(sourceDir, { withFileTypes: true })) {
135138
const sourcePath = path.join(sourceDir, entry.name);
136139
const targetPath = path.join(targetDir, entry.name);
140+
const relativePath = path.relative(sourceDir, sourcePath);
137141
if (entry.isDirectory()) {
138-
copyDirRecursive(sourcePath, targetPath);
142+
if (shouldSkipDir(sourcePath, relativePath)) continue;
143+
copyDirRecursive(sourcePath, targetPath, options);
139144
} else if (entry.isFile()) {
140145
fs.copyFileSync(sourcePath, targetPath);
141146
}

tests/test_setup_schemas.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from __future__ import annotations
2+
3+
import subprocess
4+
from pathlib import Path
5+
6+
7+
ROOT = Path(__file__).resolve().parents[1]
8+
SCRIPT = ROOT / "plugins" / "aisee-plugin" / "skills" / "aisee-schema-pack" / "scripts" / "setup-schemas.js"
9+
10+
11+
def write(path: Path, text: str) -> None:
12+
path.parent.mkdir(parents=True, exist_ok=True)
13+
path.write_text(text, encoding="utf-8")
14+
15+
16+
def create_openspec_project(root: Path) -> None:
17+
write(root / "openspec" / "config.yaml", "schema: quick-fix\n")
18+
write(root / "openspec" / "changes" / ".gitkeep", "")
19+
20+
21+
def test_setup_schemas_skips_examples_directory(tmp_path: Path) -> None:
22+
create_openspec_project(tmp_path)
23+
24+
result = subprocess.run(
25+
["node", str(SCRIPT), "--schema", "aisee-app-spec-driven", "--no-validate"],
26+
cwd=tmp_path,
27+
check=True,
28+
stdout=subprocess.PIPE,
29+
stderr=subprocess.PIPE,
30+
text=True,
31+
)
32+
33+
installed_schema = tmp_path / "openspec" / "schemas" / "aisee-app-spec-driven"
34+
35+
assert "installed aisee-app-spec-driven" in result.stdout
36+
assert (installed_schema / "schema.yaml").exists()
37+
assert (installed_schema / "templates").is_dir()
38+
assert not (installed_schema / "examples").exists()

0 commit comments

Comments
 (0)