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: add npm tag lookup to determineChannel correctly #563

Merged
merged 5 commits into from
Jun 5, 2023

Conversation

WillieRuemmele
Copy link
Contributor

@W-12152081@

adds an npm registry lookup to find if the desired version number corresponds to a tag. defaults to stable

mshanemc
mshanemc previously approved these changes May 31, 2023
Copy link
Member

@mshanemc mshanemc left a comment

Choose a reason for hiding this comment

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

approved with 1 suggestion

@@ -1,27 +0,0 @@
// import HTTP from 'http-call'
Copy link
Member

Choose a reason for hiding this comment

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

thank you!

src/update.ts Outdated
return String(channel).trim()
private async determineChannel(version:string|undefined): Promise<string> {
try {
const {body} = await HTTP.get(`https://registry.npmjs.org/${this.config.pjson.name}/`)
Copy link
Member

Choose a reason for hiding this comment

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

proxy should be ok. That library looks to have implemented it
https://github.com/search?q=repo%3Aheroku%2Fhttp-call%20proxy&type=code

src/update.ts Outdated
if (fs.existsSync(channelPath)) {
const channel = await fs.readFile(channelPath, 'utf8')
return String(channel).trim()
private async determineChannel(version:string|undefined): Promise<string> {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
private async determineChannel(version:string|undefined): Promise<string> {
private async determineChannel(version?:string): Promise<string> {

src/update.ts Outdated
if (tag === 'latest-rc') return 'stable-rc'
return tag
} catch {
return 'stable'
Copy link
Member

@mshanemc mshanemc May 31, 2023

Choose a reason for hiding this comment

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

is stable the right default? Would it be more accurate to fall back to what's in the channel file, like the original implementation did, then stable as a last resort?

src/update.ts Outdated
const channel = fs.existsSync(channelPath) ? (await fs.readFile(channelPath, 'utf8')).trim() : 'stable'

try {
const {body} = await HTTP.get<{'dist-tags':Record<string, string>}>(`https://registry.npmjs.org/${this.config.pjson.name}/`)
Copy link
Member

Choose a reason for hiding this comment

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

@mshanemc
Copy link
Member

mshanemc commented Jun 5, 2023

QA notes:

using sfv2(beta) via mac installer for update

updated without channel (went to v1)
updated back to beta
looked at version with --available

📓 giving an invalid registry SF_NPM_REGISTRY=foo really messes up the plugins update part of update

Couldn't find any way to break this, so 🚢

@mshanemc mshanemc merged commit 2e5f943 into main Jun 5, 2023
@mshanemc mshanemc deleted the wr/fixUpdateVersionTag branch June 5, 2023 18:46
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.

2 participants