diff --git a/cli/init.go b/cli/init.go index cbbad50..74ddfff 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,16 +283,11 @@ func initCommand() *cobra.Command { cmd := &cobra.Command{ Use: "init