next.js
e4a6b647 - fix(create-next-app): support renamed repositories (#68802)

Commit
1 year ago
fix(create-next-app): support renamed repositories (#68802) ### What? Fix bug in `create-next-app` that prevents using an example from a renamed repository. Right now we assume the tar of the downloaded repository will always match the format `{repo}-{branch}`. However, if a repository is specified that has been renamed, and the _old_ name is used, the download will work as it is automatically redirected, but the filter will break as it will be expecting the old name. For example: If you request: ``` npx create-next-app@latest -e https://github.com/tknickman/turbo/tree/main/examples/basic my-cool-example ``` You will get an empty directory, with the following console output: ``` Creating a new Next.js app in /Users/knickman/Developer/vercel/tmp/my-cool-example. Downloading files from repo https://github.com/tknickman/turbo/tree/main/examples/basic. This might take a moment. Initialized a git repository. Success! Created my-cool-example at /Users/knickman/Developer/vercel/tmp/my-cool-example ``` This happens because the repo `https://github.com/tknickman/turbo` has been renamed to `https://github.com/tknickman/turborepo`. The tar download works, as it follows the redirect. But the file that is created is `turborepo-main` instead of `turbo-main` (what we expect because we inferred the name from the url). This results in all files being filtered out, and an empty directory being created. ### Why? Repositories can be seamlessly renamed on Github (we've done this ourselves with `vercel/turborepo` > `vercel/turbo` etc.) `create-next-app` should support this as well to ensure old code examples work as expected ### How? instead of hardcoding the expected result of the repo download, we infer it dynamically as part of the filter process.
Author
Parents
Loading