这是indexloc提供的服务,不要输入任何密码
Skip to content

Add update checker #282

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

Closed
wants to merge 9 commits into from
Closed

Add update checker #282

wants to merge 9 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Dec 15, 2021

closes #178

@ghost ghost requested a review from jaredpalmer as a code owner December 15, 2021 00:54
@vercel
Copy link

vercel bot commented Dec 15, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/vercel/turbo-site/Dh6z4ccGeZepNSmM7fnXywXYyeQq
✅ Preview: https://turbo-site-git-fork-ayoubbenal1-main.vercel.sh

Copy link
Contributor

@jaredpalmer jaredpalmer left a comment

Choose a reason for hiding this comment

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

Pretty close, I guess could be just as easy to directly copy pscale's and then add the necessary config GetConfigDir functions to config_file.go

"https://api.github.com/repos/vercel/turborepo/releases/latest",
)
if newRelease != nil {
color.Yellow("A new version of `create-turbo` is available! %s")
Copy link
Contributor

Choose a reason for hiding this comment

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

Use util.printf here.

This is also for turbo and not create-turbo

color.Yellow("A new version of `create-turbo` is available! %s")
fmt.Println("You can update by running: ")
// TODO: show only one method depending on the user chosen package manager
color.Cyan("yarn global add create-turbo Or npm i -g create-turbo")
Copy link
Contributor

Choose a reason for hiding this comment

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

We can move this message to after config is loaded so that we can give correct installation instructions based on the detected pacakge manager.

We also should not suggest global installation at the moment.


// ReleaseInfo stores information about a release
type ReleaseInfo struct {
VERSION string `json:"tag_name"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
VERSION string `json:"tag_name"`
Version string `json:"tagName"`

// ReleaseInfo stores information about a release
type ReleaseInfo struct {
VERSION string `json:"tag_name"`
URL string `json:"html_url"`
Copy link
Contributor

Choose a reason for hiding this comment

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

use camel case for consistency

return nil, err
}
req.Header.Set("Content-Type", "application/json; charset=utf-8")

Copy link
Contributor

Choose a reason for hiding this comment

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

}
req.Header.Set("Content-Type", "application/json; charset=utf-8")

client := &http.Client{Timeout: time.Second * 10}
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

it is possible. But should we store it in a .env file or is there any other approach you have in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

use os.GetEnv like planet scale does, if it's not there that's fine. don't worry about .env

// used to decide whether to check for a new version or not.
type StateEntry struct {
CheckedForUpdateAt time.Time `yaml:"checked_for_update_at"`
LatestRelease ReleaseInfo `yaml:"latest_release"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Use dash case instead of snake case for these.

return nil, err
}

if versionGreaterThan(releaseInfo.VERSION, currentVersion) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if versionGreaterThan(releaseInfo.VERSION, currentVersion) {
if versionGreaterThan(releaseInfo.Version, currentVersion) {

return err
}

func versionGreaterThan(v, w string) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

@jaredpalmer jaredpalmer assigned ghost Dec 18, 2021
@ghost
Copy link
Author

ghost commented Dec 18, 2021

@jaredpalmer thanks for the review, I'll start working on the suggested changes soon.

@ghost
Copy link
Author

ghost commented Dec 19, 2021

Clsoing this to open a new one with all the changes

@ghost ghost closed this Dec 19, 2021
sokra added a commit that referenced this pull request Oct 25, 2022
Before it showed only some issues in the dev server, now it aggregates issues from all sources
sokra pushed a commit that referenced this pull request Oct 25, 2022
…#282)

This fixes `http://localhost:3000/layouts/electronics` trying to load
`http://localhost:3000/layouts/_chunks/*` when it shows the fallback
page.
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add update checker to turbo
1 participant