mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 20:34:19 +00:00
Project targets now use the same short names as global targets (e.g., "claude" instead of "claude-code"). Old project_name values are preserved as aliases so existing configs continue to work. - Add Aliases field to targetSpec (deprecated, remove once safe) - Update 11 targets in targets.yaml: project_name = global_name - LookupProjectTarget falls back to alias lookup - Fix 3 callers that bypassed LookupProjectTarget - Extend MatchesTargetName and KnownTargetNames with alias support - Add TestLookupProjectTarget_Alias - Update all integration tests, docs, CLI help, and FAQ
90 lines
2.8 KiB
Go
90 lines
2.8 KiB
Go
//go:build !online
|
|
|
|
package integration
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"skillshare/internal/testutil"
|
|
)
|
|
|
|
func TestGitignoreProject_InstallAddsEntry(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
projectRoot := sb.SetupProjectDir("claude")
|
|
|
|
sourceSkill := filepath.Join(sb.Root, "ext")
|
|
os.MkdirAll(sourceSkill, 0755)
|
|
os.WriteFile(filepath.Join(sourceSkill, "SKILL.md"), []byte("---\nname: ext\n---\n# E"), 0644)
|
|
|
|
sb.RunCLIInDir(projectRoot, "install", sourceSkill, "-p").AssertSuccess(t)
|
|
|
|
gitignore := sb.ReadFile(filepath.Join(projectRoot, ".skillshare", ".gitignore"))
|
|
if !strings.Contains(gitignore, "skills/ext/") {
|
|
t.Errorf("gitignore should contain skills/ext/, got:\n%s", gitignore)
|
|
}
|
|
if !strings.Contains(gitignore, "BEGIN SKILLSHARE MANAGED") {
|
|
t.Error("gitignore should contain marker block")
|
|
}
|
|
}
|
|
|
|
func TestGitignoreProject_UninstallRemovesEntry(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
projectRoot := sb.SetupProjectDir("claude")
|
|
|
|
// Create remote skill with meta
|
|
skillDir := sb.CreateProjectSkill(projectRoot, "removable", map[string]string{
|
|
"SKILL.md": "# Removable",
|
|
})
|
|
meta := map[string]interface{}{"source": "org/removable", "type": "github"}
|
|
metaJSON, _ := json.Marshal(meta)
|
|
os.WriteFile(filepath.Join(skillDir, ".skillshare-meta.json"), metaJSON, 0644)
|
|
|
|
// Write gitignore with the entry
|
|
sb.WriteFile(filepath.Join(projectRoot, ".skillshare", ".gitignore"),
|
|
"# BEGIN SKILLSHARE MANAGED - DO NOT EDIT\nskills/removable/\n# END SKILLSHARE MANAGED\n")
|
|
|
|
sb.WriteProjectConfig(projectRoot, `targets:
|
|
- claude
|
|
skills:
|
|
- name: removable
|
|
source: org/removable
|
|
`)
|
|
|
|
sb.RunCLIInDir(projectRoot, "uninstall", "removable", "--force", "-p").AssertSuccess(t)
|
|
|
|
gitignore := sb.ReadFile(filepath.Join(projectRoot, ".skillshare", ".gitignore"))
|
|
if strings.Contains(gitignore, "skills/removable/") {
|
|
t.Errorf("gitignore should not contain removed entry, got:\n%s", gitignore)
|
|
}
|
|
}
|
|
|
|
func TestGitignoreProject_PreservesUserEntries(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
projectRoot := sb.SetupProjectDir("claude")
|
|
|
|
// Write gitignore with user entries
|
|
sb.WriteFile(filepath.Join(projectRoot, ".skillshare", ".gitignore"),
|
|
"# my custom rule\n*.tmp\n")
|
|
|
|
sourceSkill := filepath.Join(sb.Root, "ext2")
|
|
os.MkdirAll(sourceSkill, 0755)
|
|
os.WriteFile(filepath.Join(sourceSkill, "SKILL.md"), []byte("---\nname: ext2\n---\n# E"), 0644)
|
|
|
|
sb.RunCLIInDir(projectRoot, "install", sourceSkill, "-p").AssertSuccess(t)
|
|
|
|
gitignore := sb.ReadFile(filepath.Join(projectRoot, ".skillshare", ".gitignore"))
|
|
if !strings.Contains(gitignore, "*.tmp") {
|
|
t.Error("user entries should be preserved")
|
|
}
|
|
if !strings.Contains(gitignore, "skills/ext2/") {
|
|
t.Error("new entry should be added")
|
|
}
|
|
}
|