Skip to content

Conversation

joehan
Copy link
Contributor

@joehan joehan commented Aug 13, 2021

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:
Screen Shot 2021-08-12 at 5 02 08 PM

Update without a major version:
Screen Shot 2021-08-12 at 5 03 43 PM

Updating when releaseNotes is not returned by the backend:
Screen Shot 2021-08-12 at 5 54 50 PM

@google-cla google-cla bot added the cla: yes Manual indication that this has passed CLA. label Aug 13, 2021
@joehan joehan requested a review from huangjeff5 August 13, 2021 00:56
@joehan joehan requested a review from elvisun August 16, 2021 17:27
newSourceOrigin === SourceOrigin.OFFICIAL_EXTENSION_VERSION;
await displayChanges(existingSpec, newSpec, isOfficial);

await displayChanges(existingSpec, newSpec, false);
Copy link
Contributor

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()

Copy link
Contributor Author

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!

@elvisun
Copy link
Contributor

elvisun commented Aug 18, 2021

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?

* @param toVersion the version you are upodating to
* @returns a Record of version number to releaseNotes for that version
*/
export async function getReleaseNotesForUpdate(
Copy link
Contributor

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) {
Copy link
Contributor

@elvisun elvisun Aug 18, 2021

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

*/
export function displayReleaseNotes(releaseNotes: Record<string, string>, fromVersion: string) {
const versions = [fromVersion].concat(Object.keys(releaseNotes));
const breaks = breakingChangesInUpdate(versions);
Copy link
Contributor

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?

Comment on lines 76 to 79
semvers[i - 1].major < semvers[i].major ||
(semvers[i - 1].major == 0 &&
semvers[i].major == 0 &&
semvers[i - 1].minor < semvers[i].minor)
Copy link
Contributor

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

} catch (err) {
sourceOrigin = SourceOrigin.PUBLISHED_EXTENSION;
// Ignore errors if we can't fetch the registry
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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 () => {
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

sgtm, thanks!

@joehan
Copy link
Contributor Author

joehan commented Aug 18, 2021

@elvisun There is! firebase ext:update 0.1.26 -P my-proj

@joehan joehan requested review from elvisun and huangjeff5 August 18, 2021 21:47
Comment on lines +43 to +44
testExtensionVersion("0.1.1", "foo"),
testExtensionVersion("0.1.2", "bar"),
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oooh, good idea!

Copy link
Contributor Author

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.

@joehan joehan merged commit dd4dc12 into master Aug 31, 2021
@joehan joehan deleted the jh-changelogs branch August 31, 2021 23:30
devpeerapong pushed a commit to devpeerapong/firebase-tools that referenced this pull request Dec 14, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Manual indication that this has passed CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants