Skip to content

Commit cdb8c1a

Browse files
committed
temp
1 parent f5728c5 commit cdb8c1a

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"jest": "27.0.6",
5656
"jimp": "0.16.1",
5757
"js-beautify": "1.14.0",
58+
"json5": "2.2.0",
5859
"karma": "6.3.4",
5960
"karma-chrome-launcher": "3.1.0",
6061
"karma-jasmine": "4.0.1",

packages/optimizer/lib/fetchRuntimeParameters.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717

1818
const URL_COMPONENT_VERSIONS =
1919
'https://raw.githubusercontent.com/ampproject/amphtml/main/build-system/compile/bundles.config.extensions.json';
20+
const URL_COMPONENT_LATEST_VERSIONS = 'https://raw.githubusercontent.com/ampproject/amphtml/main/build-system/compile/bundles.legacy-latest-versions.jsonc';
2021
const validatorRulesProvider = require('@ampproject/toolbox-validator-rules');
2122
const {MaxAge} = require('@ampproject/toolbox-core');
23+
const JSON5 = require('json5');
2224
let fallbackRuntime;
2325

2426
try {
@@ -111,15 +113,29 @@ async function fetchComponentVersionsFromCache_(config, runtimeParameters) {
111113
async function fetchComponentVersions_(config, runtimeParameters) {
112114
// Strip the leading two chars from the version identifier to get the release tag
113115
const releaseTag = runtimeParameters.ampRuntimeVersion.substring(2);
116+
console.log('releaseTag', releaseTag);
114117
const componentConfigUrl = `https://raw.githubusercontent.com/ampproject/amphtml/${releaseTag}/build-system/compile/bundles.config.extensions.json`;
118+
const componentLatestVersionsUrl = `https://raw.githubusercontent.com/ampproject/amphtml/${releaseTag}/build-system/compile/bundles.legacy-latest-versions.jsonc`;
115119

116-
const response = await config.fetch(componentConfigUrl);
117-
if (!response.ok) {
120+
const configResponse = await config.fetch(componentConfigUrl);
121+
const latestVersionsConfigResponse = await config.fetch(componentLatestVersionsUrl);
122+
if (!configResponse.ok) {
123+
console.log('a');
124+
debugger;
125+
throw new Error(
126+
`Failed fetching latest component versions from ${URL_COMPONENT_VERSIONS} with status: ${configResponse.status}`
127+
);
128+
}
129+
if (!latestVersionsConfig.ok) {
130+
console.log('b');
131+
debugger;
118132
throw new Error(
119-
`Failed fetching latest component versions from ${URL_COMPONENT_VERSIONS} with status: ${response.status}`
133+
`Failed fetching latest component versions from ${URL_COMPONENT_LATEST_VERSIONS} with status: ${latestVersionsConfig.status}`
120134
);
121135
}
122-
return response.json();
136+
console.log('c');
137+
debugger;
138+
return configResponse.json();
123139
}
124140

125141
/**

packages/optimizer/lib/transformers/AutoExtensionImporter.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,7 @@ class AutoExtensionImporter {
141141
if (!this.componentVersions) {
142142
this.componentVersions = {};
143143
for (const component of params.componentVersions) {
144-
if (Array.isArray(component.version)) {
145-
// If version is an array then we need to find the highest value.
146-
// Note we need to preserve the "stringy"ness of these versions
147-
// so make sure we don't do any coercion or casting of the value
148-
// we assign.
149-
this.componentVersions[component.name] = component.version.reduce((prev, cur) => {
150-
return Number(prev) > Number(cur) ? prev : cur;
151-
});
152-
} else {
153-
this.componentVersions[component.name] =
154-
Number(component.version) >
155-
// Make sure to guard if the entry doesn't exist yet. We default
156-
// comparing to 0.
157-
Number(this.componentVersions[component.name] || 0)
158-
? component.version
159-
: this.componentVersions[component.name];
160-
}
144+
this.componentVersions[component.name] = component.latestVersion;
161145
}
162146
}
163147
if (!this.extensionSpec_) {

0 commit comments

Comments
 (0)