-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(create-turbo): better error when GH is down #5900
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import { | |
import { | ||
getAvailablePackageManagers, | ||
createProject, | ||
DownloadError, | ||
logger, | ||
} from "@turbo/utils"; | ||
import { tryGitCommit, tryGitInit } from "../../utils/git"; | ||
|
@@ -33,8 +34,15 @@ function handleErrors(err: unknown) { | |
} else if (err instanceof ConvertError && err.type !== "unknown") { | ||
error(chalk.red(err.message)); | ||
process.exit(1); | ||
// handle unknown errors (no special handling, just re-throw to catch at root) | ||
} else { | ||
// handle download errors from @turbo/utils | ||
} else if (err instanceof DownloadError) { | ||
error(chalk.red("Unable to download template from Github")); | ||
error(chalk.red(err.message)); | ||
process.exit(1); | ||
} | ||
|
||
// handle unknown errors (no special handling, just re-throw to catch at root) | ||
else { | ||
throw err; | ||
} | ||
} | ||
|
@@ -85,12 +93,20 @@ export async function create( | |
|
||
const { example, examplePath } = opts; | ||
const exampleName = example && example !== "default" ? example : "basic"; | ||
const { hasPackageJson, availableScripts, repoInfo } = await createProject({ | ||
appPath: root, | ||
example: exampleName, | ||
isDefaultExample: isDefaultExample(exampleName), | ||
examplePath, | ||
}); | ||
|
||
let projectData = {} as Awaited<ReturnType<typeof createProject>>; | ||
try { | ||
projectData = await createProject({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This eventually hits The failure mode for the last outage didn't return a 500 unicorn, it just hung indefinitely. This is definitely an improvement, but it doesn't address all failure modes. |
||
appPath: root, | ||
example: exampleName, | ||
isDefaultExample: isDefaultExample(exampleName), | ||
examplePath, | ||
}); | ||
} catch (err) { | ||
handleErrors(err); | ||
} | ||
|
||
const { hasPackageJson, availableScripts, repoInfo } = projectData; | ||
|
||
// create a new git repo after creating the project | ||
tryGitInit(root, `feat(create-turbo): create ${exampleName}`); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub