diff --git a/cli/init.go b/cli/init.go index cbbad50..77dae08 100644 --- a/cli/init.go +++ b/cli/init.go @@ -16,25 +16,20 @@ import ( ) const ( - githubTarballURL = "https://github.com/dispatchrun/%s/tarball/main" - githubAPIURL = "https://api.github.com/repos/dispatchrun/%s/branches/main" - repo = "dispatch-examples" + githubTarballURL = "https://github.com/%s/tarball/main" + githubAPIURL = "https://api.github.com/repos/%s/branches/main" + repo = "dispatchrun/dispatch-examples" dispatchUserDir = "dispatch" ) -// TODO: versioning for different SDKs? - func directoryExists(path string) (bool, error) { info, err := os.Stat(path) if os.IsNotExist(err) { - // The directory does not exist return false, nil } if err != nil { - // Some other error occurred return false, err } - // Check if the path is a directory return info.IsDir(), nil } @@ -96,6 +91,8 @@ func extractTarball(r io.Reader, destDir string) error { continue } + // We need to strip the top-level directory from the file paths + // It contains the repository name and the commit SHA which we don't need // Get the top-level directory name if topLevelDir == "" { parts := strings.Split(header.Name, "/") @@ -286,18 +283,15 @@ func initCommand() *cobra.Command { cmd := &cobra.Command{ Use: "init