Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Pull latest component versions from amphtml repo #1235

Merged
merged 3 commits into from
May 27, 2021

Conversation

sebastianbenz
Copy link
Collaborator

@sebastianbenz sebastianbenz commented May 21, 2021

This will ensure that we'll always use the correct component version when auto importing scripts.

this.bentoComponentInfo[bentoComponent.name] = bentoComponent;
}
}
this.componentVersions = params.componentVersions || {};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since optional chaining is supported in node 14, Would you ever want to use it rather than this type of syntax? Or do you prefer this type of format

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How does optional chaining help here? Do you mean nullish coalescing operator?

@@ -15,7 +15,7 @@
*/
'mode strict';

const URL_BENTO_COMPONENT_INFO = 'https://amp.dev/static/bento-components.json';
const URL_COMPONENT_VERSIONS = 'https://amp.dev/static/files/component-versions.json';
Copy link
Member

Choose a reason for hiding this comment

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

Does this correspond to the latest version of each component?

Copy link
Member

Choose a reason for hiding this comment

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

It seems some extensions are missing, namely:

  1. amp-action-macro
  2. amp-base-carousel
  3. amp-cache-url (this lacks a latest in the spec)
  4. amp-google-assistant-assistjs
  5. amp-mega-menu
  6. amp-story-panning-media
  7. amp-stream-gallery
  8. amp-truncate-text

Copy link
Member

Choose a reason for hiding this comment

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

Also, it doesn't seem accurate. It has this:

"amp-lightbox-gallery": "1.0",

And yet 1.0 is not even a valid version in the spec.

Copy link
Member

Choose a reason for hiding this comment

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

The invalid latest version appears to be an issue with:

  1. amp-facebook-comments (has 1.0 but should be 0.1)
  2. amp-lightbox-gallery (has 1.0 but should be 0.1)
  3. amp-twitter (has 1.0 but should be 0.1)

Copy link
Member

@westonruter westonruter May 25, 2021

Choose a reason for hiding this comment

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

Also, it seems bento-components.json is not complete. Namely, it is missing these Bento components:

Copy link

Choose a reason for hiding this comment

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

@westonruter Drive-by comment to suggest an alternative to https://amp.dev/static/bento-components.json:

  • The source of truth for Bento components is in this file (search for "npm": true).
  • These are the components that will be automatically published to npm (see design doc).
  • In case it helps, we have a wrapper node script that can extract the raw list of components.

/cc @estherkim @jridgewell @kristoferbaxter for visibility / additional comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rsimha this is perfect! Exactly what I was looking for. Am I right, that latestVerstion will always point to the latest valid prod version?

Background: Bento components have been causing the problem here, but the real problem is that it's not possible to determine experimental components from the validation rules.

Copy link

Choose a reason for hiding this comment

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

Am I right, that latestVerstion will always point to the latest valid prod version?

Yep!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Excellent! Updated the PR to use this correct endpoint.

One question: is it OK to simply strip the first two chars from an AMP release version to get the matching git tag? See https://github.com/ampproject/amp-toolbox/pull/1235/files#diff-87058858680239b88e937b9d753fde89d596c23045e56288ac0d4487e65f4567R113

Choose a reason for hiding this comment

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

Yes! Git tags are created as part of the nightly cuts.

@sebastianbenz sebastianbenz changed the title Use different endpoint to fetch latest component prod versions Pull latest component versions from amphtml repo May 27, 2021
@sebastianbenz sebastianbenz merged commit df4466d into main May 27, 2021
@sebastianbenz sebastianbenz deleted the improve-auto-import branch May 27, 2021 20:19
@sebastianbenz
Copy link
Collaborator Author

Thanks everyone for the feedback and help!

sebastianbenz added a commit that referenced this pull request May 31, 2021
* Use different endpoint to fetch latest component prod versions

* Use extension config from amphtml repo

* update boilerplate error handler to fix validation errors
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants