From 7399c5e871c92d5b957b766329258c652f378e9a Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 10 Jun 2021 20:55:00 -0700 Subject: [PATCH 1/5] Update means of determining bento support for component --- bin/amphtml-update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/amphtml-update.py b/bin/amphtml-update.py index 09dbcf91aa1..712497356a0 100755 --- a/bin/amphtml-update.py +++ b/bin/amphtml-update.py @@ -412,7 +412,7 @@ def ParseRules(repo_directory, out_dir): if extension_versions[ extension['name'] ]['latest'] is not None and extension_versions[ extension['name'] ]['latest'] != extension['latestVersion']: logging.info('Warning: latestVersion mismatch for ' + extension['name']) extension_versions[ extension['name'] ]['latest'] = extension['latestVersion'] - if 'options' in extension and 'npm' in extension['options'] and extension['options']['npm'] == True: + if 'options' in extension and 'wrapper' in extension['options'] and extension['options']['wrapper'] == 'bento': extension_versions[ extension['name'] ]['bento'] = { 'version': extension['version'], 'has_css': extension['options'].get( 'hasCss', False ), From 17302f62ec076988ef2ddd29082cd30755891c14 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Fri, 11 Jun 2021 11:11:52 -0700 Subject: [PATCH 2/5] Regenerate spec after wrapper:bento prop added --- .../class-amp-allowed-tags-generated.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/includes/sanitizers/class-amp-allowed-tags-generated.php b/includes/sanitizers/class-amp-allowed-tags-generated.php index 93569848de2..02a7dc93b23 100644 --- a/includes/sanitizers/class-amp-allowed-tags-generated.php +++ b/includes/sanitizers/class-amp-allowed-tags-generated.php @@ -15922,6 +15922,10 @@ class AMP_Allowed_Tags_Generated { ), 'tag_spec' => array( 'extension_spec' => array( + 'bento' => array( + 'has_css' => true, + 'version' => '1.0', + ), 'latest' => '0.1', 'name' => 'amp-facebook', 'requires_usage' => true, @@ -15953,6 +15957,10 @@ class AMP_Allowed_Tags_Generated { ), 'tag_spec' => array( 'extension_spec' => array( + 'bento' => array( + 'has_css' => false, + 'version' => '1.0', + ), 'latest' => '0.1', 'name' => 'amp-facebook-comments', 'requires_usage' => true, @@ -16020,6 +16028,10 @@ class AMP_Allowed_Tags_Generated { ), 'tag_spec' => array( 'extension_spec' => array( + 'bento' => array( + 'has_css' => true, + 'version' => '1.0', + ), 'latest' => '0.1', 'name' => 'amp-facebook-page', 'requires_usage' => true, @@ -17656,6 +17668,10 @@ class AMP_Allowed_Tags_Generated { ), 'tag_spec' => array( 'extension_spec' => array( + 'bento' => array( + 'has_css' => false, + 'version' => '1.0', + ), 'latest' => '1.0', 'name' => 'amp-render', 'requires_usage' => true, @@ -17785,6 +17801,10 @@ class AMP_Allowed_Tags_Generated { ), 'tag_spec' => array( 'extension_spec' => array( + 'bento' => array( + 'has_css' => true, + 'version' => '1.0', + ), 'latest' => '0.1', 'name' => 'amp-sidebar', 'requires_usage' => true, From d7c2d99086f4d1ef4a5850c1b7f5e757b2d00cf2 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Fri, 11 Jun 2021 11:16:19 -0700 Subject: [PATCH 3/5] Omit bento for components whose versions are not yet valid --- bin/amphtml-update.py | 2 +- .../class-amp-allowed-tags-generated.php | 16 ---------------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/bin/amphtml-update.py b/bin/amphtml-update.py index 712497356a0..4a230eb475d 100755 --- a/bin/amphtml-update.py +++ b/bin/amphtml-update.py @@ -437,7 +437,7 @@ def ParseRules(repo_directory, out_dir): validator_versions = sorted( validator_versions, key=lambda version: map(int, version.split('.') ) ) extension_script_list[0]['tag_spec']['extension_spec']['version'] = validator_versions - if 'bento' in extension_versions[extension_name]: + if 'bento' in extension_versions[extension_name] and extension_versions[extension_name]['bento']['version'] in validator_versions: extension_script_list[0]['tag_spec']['extension_spec']['bento'] = extension_versions[extension_name]['bento'] extension_script_list[0]['tag_spec']['extension_spec']['latest'] = extension_versions[extension_name]['latest'] diff --git a/includes/sanitizers/class-amp-allowed-tags-generated.php b/includes/sanitizers/class-amp-allowed-tags-generated.php index 02a7dc93b23..6b7ed4388a9 100644 --- a/includes/sanitizers/class-amp-allowed-tags-generated.php +++ b/includes/sanitizers/class-amp-allowed-tags-generated.php @@ -15922,10 +15922,6 @@ class AMP_Allowed_Tags_Generated { ), 'tag_spec' => array( 'extension_spec' => array( - 'bento' => array( - 'has_css' => true, - 'version' => '1.0', - ), 'latest' => '0.1', 'name' => 'amp-facebook', 'requires_usage' => true, @@ -15957,10 +15953,6 @@ class AMP_Allowed_Tags_Generated { ), 'tag_spec' => array( 'extension_spec' => array( - 'bento' => array( - 'has_css' => false, - 'version' => '1.0', - ), 'latest' => '0.1', 'name' => 'amp-facebook-comments', 'requires_usage' => true, @@ -16028,10 +16020,6 @@ class AMP_Allowed_Tags_Generated { ), 'tag_spec' => array( 'extension_spec' => array( - 'bento' => array( - 'has_css' => true, - 'version' => '1.0', - ), 'latest' => '0.1', 'name' => 'amp-facebook-page', 'requires_usage' => true, @@ -17801,10 +17789,6 @@ class AMP_Allowed_Tags_Generated { ), 'tag_spec' => array( 'extension_spec' => array( - 'bento' => array( - 'has_css' => true, - 'version' => '1.0', - ), 'latest' => '0.1', 'name' => 'amp-sidebar', 'requires_usage' => true, From 835a217ad1defe681f2c86d3d7daa73187a6dd94 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 15 Jun 2021 18:01:48 -0700 Subject: [PATCH 4/5] Update spec to include https://github.com/ampproject/amphtml/pull/34769 --- includes/sanitizers/class-amp-allowed-tags-generated.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/sanitizers/class-amp-allowed-tags-generated.php b/includes/sanitizers/class-amp-allowed-tags-generated.php index 6b7ed4388a9..d85782261d9 100644 --- a/includes/sanitizers/class-amp-allowed-tags-generated.php +++ b/includes/sanitizers/class-amp-allowed-tags-generated.php @@ -15509,7 +15509,7 @@ class AMP_Allowed_Tags_Generated { 'extension_spec' => array( 'latest' => '0.1', 'name' => 'amp-cache-url', - 'requires_usage' => true, + 'requires_usage' => false, 'version' => array( '0.1', ), From 0b72eefc3f43e2522610568c76624f55c419e4a8 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 15 Jun 2021 20:25:16 -0700 Subject: [PATCH 5/5] Omit Bento from components when version is not valid --- bin/amphtml-update.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/amphtml-update.py b/bin/amphtml-update.py index 4a230eb475d..6473c3ed37e 100755 --- a/bin/amphtml-update.py +++ b/bin/amphtml-update.py @@ -434,6 +434,10 @@ def ParseRules(repo_directory, out_dir): if not validator_versions.issubset( bundle_versions ): logging.info( 'Validator versions are not a subset of bundle versions: ' + extension_name ) + if 'bento' in extension_versions[extension_name] and extension_versions[extension_name]['bento']['version'] not in validator_versions: + logging.info( 'Skipping bento for ' + extension_name + ' since version ' + extension_versions[extension_name]['bento']['version'] + ' is not yet valid' ) + del extension_versions[extension_name]['bento'] + validator_versions = sorted( validator_versions, key=lambda version: map(int, version.split('.') ) ) extension_script_list[0]['tag_spec']['extension_spec']['version'] = validator_versions