Skip to content
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

fix(create-astro): use CLI version tag to determine astro version #12529

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

apatel369
Copy link
Contributor

@apatel369 apatel369 commented Nov 26, 2024

Changes

Closes #12506

This PR fixes issues with installation messages in create-astro by using the tag provided in CLI arguments (e.g. @beta) for determining astro version.

All these commands now show the correct version of Astro in installation.

pnpm create astro@beta
pnpm create-astro@beta
npm create astro@beta
npm create-astro@beta
yarn create astro@beta
yarn create-astro@beta

[

installation.message.fix.mov

](url)

Testing

Manually tested by running local package with and without @beta

Docs

N/A bug fix

@github-actions github-actions bot added the pkg: create-astro Related to the `create-astro` package (scope) label Nov 26, 2024
@apatel369 apatel369 changed the title Fix: Use ref passed by user to get version in create astro Fix: use ref passed by user to get version in create astro Nov 26, 2024
@apatel369 apatel369 changed the title Fix: use ref passed by user to get version in create astro Fix: use ref passed by user to get version in create-astro Nov 26, 2024
@apatel369 apatel369 changed the title Fix: use ref passed by user to get version in create-astro Fix: use ref passed by user to get version in create-astro Nov 26, 2024
@apatel369 apatel369 marked this pull request as draft November 26, 2024 05:33
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is quite right. The ref is a specifier for a git ref, eg the "next" branch. The specifier used to fetch versions is the npm tag, so it doesn't necessarily match

@apatel369
Copy link
Contributor Author

apatel369 commented Nov 26, 2024

I don't think this is quite right. The ref is a specifier for a git ref, eg the "next" branch. The specifier used to fetch versions is the npm tag, so it doesn't necessarily match

Thanks for reviewing this! Could you clarify what should be the correct tag value for the next branch? I was under the impression that the 'next' tag is currently being used for pre-releases. I referred to the CONTRIBUTING.md

@apatel369 apatel369 marked this pull request as ready for review November 27, 2024 03:17
@apatel369
Copy link
Contributor Author

I don't think this is quite right. The ref is a specifier for a git ref, eg the "next" branch. The specifier used to fetch versions is the npm tag, so it doesn't necessarily match

Currently, we are using beta tag for next branch so using that solves the issue as seen in the video.

@apatel369 apatel369 changed the title Fix: use ref passed by user to get version in create-astro fix(create-astro): use ref passed by user to get version in create-astro Nov 27, 2024
Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @bluwy: the --ref flag is intended to select the version of templates from GitHub based on branch naming. For example, if there was a 2025 template being developed on a new-template branch, you could use pnpm create astro --ref new-template --template 2025 to scaffold a project using it.

In the current moment, the next branch happens to align with the beta tag on npm (more or less, because the branch can also be slightly ahead), but it's not always the case.

Is there a situation where the current use of --ref next doesn't already pick up the beta version of Astro? I'd expect the versions specified in the template package.json to be used. (edit: I should read the issue first) I think Bjorn's suggestion there is to use the tag in the command create astro@beta. Not sure if we'd have direct access to that — might need parsing from the raw args.

@apatel369
Copy link
Contributor Author

I agree with @bluwy: the --ref flag is intended to select the version of templates from GitHub based on branch naming. For example, if there was a 2025 template being developed on a new-template branch, you could use pnpm create astro --ref new-template --template 2025 to scaffold a project using it.

In the current moment, the next branch happens to align with the beta tag on npm (more or less, because the branch can also be slightly ahead), but it's not always the case.

Is there a situation where the current use of --ref next doesn't already pick up the beta version of Astro? I'd expect the versions specified in the template package.json to be used. (edit: I should read the issue first) I think Bjorn's suggestion there is to use the tag in the command create astro@beta. Not sure if we'd have direct access to that — might need parsing from the raw args.

Makes sense.
Does this mean we have incorrect dos right now?
Currently starting a new beta project asks you to run these commands: npm create astro@latest -- --ref next, pnpm create astro --ref next, yarn create astro --ref next. None of these includes @beta

@delucis
Copy link
Member

delucis commented Nov 27, 2024

Does this mean we have incorrect docs right now?

This does work (apart from the “Welcome” message from Houston saying v4) — it pulls the templates from the next branch on GH, which have dependencies updated to beta versions, so running that command does give you a new project using the beta release. For example, I ran it and got a package.json with the ^5.0.0-beta.12 version of Astro.

Running create astro@beta gives you the beta version of the create-astro package, which includes the recent changes to the questions the wizard asks.

One fix might be to remove the version from the “Welcome to Astro vX.X.X, NAME” message. At that point in the process we don’t know the Astro version yet. That said, it’s only an issue right now because we’re in a beta stage. But once Astro v5 is released, that message will again be correct for almost all users again. (Outside of this pre-release period, using --ref next is pretty rare.)

@apatel369
Copy link
Contributor Author

One fix might be to remove the version from the “Welcome to Astro vX.X.X, NAME” message. At that point in the process we don’t know the Astro version yet. That said, it’s only an issue right now because we’re in a beta stage. But once Astro v5 is released, that message will again be correct for almost all users again. (Outside of this pre-release period, using --ref next is pretty rare.)

Thanks for the detailed explanation. Is there a way to determine the correct version to installed later in the process? If so, perhaps we could remove the Astro version number at the start and display it later in the process?

@delucis
Copy link
Member

delucis commented Nov 27, 2024

Is there a way to determine the correct version to installed later in the process?

I guess once the template is downloaded we'd know from the package.json?

@bluwy
Copy link
Member

bluwy commented Nov 28, 2024

I think my initial idea for pnpm create astro@beta and knowing the "beta" part is by having that information inlined into create-astro at build time. But I think reading from package.json also works, whichever is simpler to implement.

That way we're reading the npm tag for create-astro and we can find the same for astro, not using --ref.

@apatel369 apatel369 changed the title fix(create-astro): use ref passed by user to get version in create-astro fix(create-astro): use tag passed by user instead of 'ref' for beta installations Nov 30, 2024
@apatel369 apatel369 changed the title fix(create-astro): use tag passed by user instead of 'ref' for beta installations fix(create-astro): use tag passed by user instead for determine astro version Nov 30, 2024
@apatel369 apatel369 changed the title fix(create-astro): use tag passed by user instead for determine astro version fix(create-astro): use CLI version tag to determine astro version Nov 30, 2024
@apatel369
Copy link
Contributor Author

Thanks to both of you for your great suggestions.
I am now parsing args to get the tag and fetching the Astro version based on that tag name. There is an edge case, though, where the user can pass the version number instead of the tag, i.e. [email protected]. How should we handle this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: create-astro Related to the `create-astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(minor) pnpm create astro --ref next ⇒ Houston: v4.16.14 instead of v5.0.0-beta.10
3 participants