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

Improve handling of latest extension versions in spec #232

Open
3 tasks
schlessera opened this issue Jun 6, 2021 · 5 comments
Open
3 tasks

Improve handling of latest extension versions in spec #232

schlessera opened this issue Jun 6, 2021 · 5 comments
Assignees

Comments

@schlessera
Copy link
Collaborator

schlessera commented Jun 6, 2021

Multiple TODOs are still open in the ExtensionSpec template. These need to be resolved be generally improving the handling of latest versions of extensions.

/**
* Get the latest available version of the extension.
*
* phpcs:disable Generic.Files.LineLength.TooLong
* @todo This will need to be adapted to be informed by <https://github.com/ampproject/amphtml/blob/main/build-system/compile/bundles.config.extensions.json>, where the latestVersion is stored with the spec (and the highest version is not always the same as latest), as well as any additional Bento metadata.
* @return string Latest available version.
*/
public function getLatestVersion()
{
// @todo There is one case where an extension lacks a 'latest' version, but maybe not for long. See <https://github.com/ampproject/amphtml/pull/34636>.
if (! array_key_exists(SpecRule::VERSION, self::EXTENSION_SPEC)) {
return 'latest';
}
$versions = self::EXTENSION_SPEC[SpecRule::VERSION];
// @todo Why isn't this sorting done at ingestion time? Then getLatestVersion could just be doing something like `return self::LATEST_VERSION`.
// Sort versions in descending order so that the latest version ends up to be the first element in the array.
usort(
$versions,
static function ($a, $b) {
if ($a === $b) {
return 0;
}
if ($a === 'latest') {
return 1;
}
if ($b === 'latest') {
return -1;
}
return version_compare($a, $b, '<');
}
);
return $versions[0];
}

@westonruter
Copy link
Member

See ampproject/amphtml#34838 for the latest on where the Bento information is stored.

@westonruter
Copy link
Member

westonruter commented Jun 16, 2021

In order to determine which Bento versions are stable enough to be used, we have to cross-reference to make sure the version is among the versions which are present in the validator spec. See ampproject/amp-wp#6373.

@schlessera
Copy link
Collaborator Author

@ediamin Some of the above TODOs should already be solved by #297. Can you check in detail what was done, and what is still missing to update the issue description?

@ediamin
Copy link
Collaborator

ediamin commented Nov 8, 2021

Here are my findings about the current state of this issue:

  1. The spec has adapted the bundles.config.extensions.json well from the ampproject/amphtml project. The latestVersion is stored with the spec as well as additional Bento metadata. It was handled in #297 .
  2. The ampproject/amphtm#34636 PR is still open and need to be merged.
  3. In PR#358 TagWithExtensionSpec was introduced. In which getLatestVersion() simply returns self::LATEST_VERSION.

@westonruter
Copy link
Member

  1. The spec has adapted the bundles.config.extensions.json well from the ampproject/amphtml project. The latestVersion is stored with the spec as well as additional Bento metadata. It was handled in #297 .

The Bento version is also now indicated in the validator spec via a bento_supported_version attribute: ampproject/amphtml#35757. The plugin is still using the version data in bundles.config.extensions.json, but I believe we could skip consuming that JSON file now that the validator has the data as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants