-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Display releaseNotes during ext:update, and streamline ext:update code #3672
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
Conversation
src/commands/ext-update.ts
Outdated
newSourceOrigin === SourceOrigin.OFFICIAL_EXTENSION_VERSION; | ||
await displayChanges(existingSpec, newSpec, isOfficial); | ||
|
||
await displayChanges(existingSpec, newSpec, false); |
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.
I remember this logic was supposed to display before/after sources only if the extension wasn't official, I believe. Worth checking with Sonakshi to see if it's okay to deprecate this logic.
If it is okay to deprecate that logic, then I think we can remove the last parameter altogether from displayChanges()
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.
Cleaned this up as well, good eye!
UX Question: If I see 0.2.0 and don't want to upgrade to that, but want to upgrade to 0.1.26 instead, is that a supported flow? |
src/extensions/changelog.ts
Outdated
* @param toVersion the version you are upodating to | ||
* @returns a Record of version number to releaseNotes for that version | ||
*/ | ||
export async function getReleaseNotesForUpdate( |
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.
prefer named params to reduce confusion at call site
go/tsstyle#comments-when-calling-a-function
const releaseNotes: Record<string, string> = {}; | ||
const filter = `id<="${toVersion}" AND id>"${fromVersion}"`; | ||
const extensionVersions = await listExtensionVersions(extensionRef, filter); | ||
for (const extensionVersion of extensionVersions) { |
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.
This assumes listExtensionVersions
returns in a sorted manner, which is not part of the contract from our backend
So it'd be safer to sort it here so users are guaranteed to see all versions in incremental order
src/extensions/changelog.ts
Outdated
*/ | ||
export function displayReleaseNotes(releaseNotes: Record<string, string>, fromVersion: string) { | ||
const versions = [fromVersion].concat(Object.keys(releaseNotes)); | ||
const breaks = breakingChangesInUpdate(versions); |
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.
this is kinda confusing with break
, maybe breakingVersions
?
src/extensions/changelog.ts
Outdated
semvers[i - 1].major < semvers[i].major || | ||
(semvers[i - 1].major == 0 && | ||
semvers[i].major == 0 && | ||
semvers[i - 1].minor < semvers[i].minor) |
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.
This is pretty scary to read, can you extract the variables in if
to const with some meaningful names? Something like:
hasMajorBump || hasMinorBumpInPreview
src/extensions/updateHelper.ts
Outdated
} catch (err) { | ||
sourceOrigin = SourceOrigin.PUBLISHED_EXTENSION; | ||
// Ignore errors if we can't fetch the registry |
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.
is this registry.json?
silently failing worries me... do we have some kind of error reporting for the CLI?
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.
Adding a debug log here, but I think this is necessary to ignore. We want to be able to take down the registry at some point without breaking this. In the case of an outage before then, this would just accidentally allow updates below minVersion, which is a small corner case that we're already in the process of migrating to the backend.
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.
sg with noop just wanted to get some logs here in case we need to figure out how often this happens
expect(got).to.deep.equal(want); | ||
}); | ||
|
||
it("should exclude versions that don't have releaseNotes", async () => { |
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.
Or should we say no release note? providers forgetting to write release note might be pretty common
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.
Gonna leave this as is since:
- We're gonna check for a CHANGELOG entry and enforce that it should be there on ext:publish, so this should not happen frequently
- In the case where an extension doesn't have release notes populated on the backend, it may still have release notes available elsewhere, so it could be misleading.
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.
sgtm, thanks!
@elvisun There is! firebase ext:update 0.1.26 -P my-proj |
testExtensionVersion("0.1.1", "foo"), | ||
testExtensionVersion("0.1.2", "bar"), |
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.
flip this to test the sort
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.
Oooh, good idea!
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.
Ahhh, on second though it won't actually cover that - the sorting happens in a different method that the one under test.
* save my place * implement parseChangelog * check for changelog on ext:dev:publish
firebase#3672) * Display releaseNotes during ext:update, and streamline ext:update code in general * Add typing to silence linter issues * adding jsdoc comments * bolding after UX feedback * pr fixes * Check for and display CHANGELOG.md during ext:dev:publish (firebase#3693) * save my place * implement parseChangelog * check for changelog on ext:dev:publish * adding changelog
Description
Display releaseNotes during ext:update if they exist.
I also removed most of the code supporting old official extensions. @huangjeff5 and I checked the backend, and all instances have been migrated to the new registry, so these code paths should be totally unused and safe to remove at this point.
Scenarios Tested
Update containing a major version:

Update without a major version:

Updating when releaseNotes is not returned by the backend:
