mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 20:34:19 +00:00
Restructure the install package to reduce install.go size and isolate responsibilities without changing exported API signatures. Changes: - convert internal/install/install.go into a thin facade (types, test hook, exported wrappers) - extract install flows into install_apply.go - extract discovery flows into install_discovery.go - extract update flow into install_update.go - extract audit logic into install_audit.go - extract git helpers into install_git.go - extract tracked repo flow into install_tracked.go - extract updatable/tracked query helpers into install_queries.go - extract copy helpers into copy.go Compatibility: - exported API signatures are unchanged - package remains flat as package install - behavior is intended to remain equivalent; only code organization changed Verification run before and after split: - go test ./internal/install -count=1 - go test ./cmd/skillshare -run 'TestRenderInstallWarnings_CompactSuppressesExtraDetails|TestRenderBlockedAuditError_TrackedRepositoryContext' -count=1 - go build -o bin/skillshare ./cmd/skillshare && SKILLSHARE_TEST_BINARY=/Users/williehung/Developer/Apps/github/skillshare/bin/skillshare go test ./tests/integration -run 'TestInstall_Subdir|TestInstall_Track_BlocksCritical' -count=1 - go test ./...
53 lines
926 B
Go
53 lines
926 B
Go
package install
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func copyDir(src, dst string) error {
|
|
return filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
relPath, _ := filepath.Rel(src, path)
|
|
dstPath := filepath.Join(dst, relPath)
|
|
|
|
// Skip .git directory
|
|
if info.IsDir() && info.Name() == ".git" {
|
|
return filepath.SkipDir
|
|
}
|
|
|
|
if info.IsDir() {
|
|
return os.MkdirAll(dstPath, info.Mode())
|
|
}
|
|
|
|
return copyFile(path, dstPath)
|
|
})
|
|
}
|
|
|
|
// copyFile copies a single file
|
|
func copyFile(src, dst string) error {
|
|
srcFile, err := os.Open(src)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer srcFile.Close()
|
|
|
|
srcInfo, err := srcFile.Stat()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
dstFile, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, srcInfo.Mode())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer dstFile.Close()
|
|
|
|
_, err = io.Copy(dstFile, srcFile)
|
|
return err
|
|
}
|