Skip to content

Commit 3f79437

Browse files
committed
remove debugger statements
1 parent 8e63654 commit 3f79437

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

packages/optimizer/build/downloadRuntimeParameters.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const fetch = require('node-fetch');
2020
const fs = require('fs').promises;
2121
const path = require('path');
2222
const fetchRuntimeParameters = require('../lib/fetchRuntimeParameters');
23+
const JSON5 = require('json5');
2324

2425
(async () => {
2526
const runtimeParameters = await fetchRuntimeParameters({
@@ -42,11 +43,31 @@ const fetchRuntimeParameters = require('../lib/fetchRuntimeParameters');
4243

4344
const extensionConfigUrl =
4445
'https://raw.githubusercontent.com/ampproject/amphtml/main/build-system/compile/bundles.config.extensions.json';
45-
const response = await fetch(extensionConfigUrl);
46-
if (!response.ok) {
47-
throw new Error(`Failed downloading ${extensionConfigUrl} with status ${response.status}`);
46+
const latestVersionsUrl = `https://raw.githubusercontent.com/ampproject/amphtml/main/build-system/compile/bundles.legacy-latest-versions.jsonc`;
47+
48+
const configResponse = await fetch(extensionConfigUrl);
49+
const latestVersionsConfigResponse = await fetch(latestVersionsUrl);
50+
51+
if (!configResponse.ok) {
52+
throw new Error(
53+
`Failed downloading ${extensionConfigUrl} with status ${configResponse.status}`
54+
);
4855
}
49-
const extensionConfig = await response.json();
56+
// If the fetch for the latestVersion jsonc file fails, we try again using the
57+
// main branch since it might not exist yet in the old releaseTag. The latestVersion's
58+
// are frozen so its unlikely to have changed.
59+
if (!latestVersionsConfigResponse.ok) {
60+
throw new Error(
61+
`Failed fetching latest component versions from ${latestVersionsUrl} with status: ${latestVersionsConfigResponse.status}`
62+
);
63+
}
64+
const extensionConfig = await configResponse.json();
65+
const latestVersionsConfig = JSON5.parse(await latestVersionsConfigResponse.text());
66+
// We add back the "latestVersion" field so that the auto importer
67+
// code knows what "stable" version of the extension to use.
68+
extensionConfig.forEach((entry) => {
69+
entry['latestVersion'] = latestVersionsConfig[entry.name];
70+
});
5071
fs.writeFile(
5172
path.join(__dirname, '../lib/extensionConfig.json'),
5273
JSON.stringify(extensionConfig),

packages/optimizer/lib/extensionConfig.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

packages/optimizer/spec/transformers/valid/AutoExtensionImporter/amp-carousel/expected_output.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
</amp-carousel>
1717
</body>
1818

19-
</html>
19+
</html>

packages/optimizer/spec/transformers/valid/AutoExtensionImporter/auto-imports-missing-extensions/expected_output.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ <h1>Hello AMPHTML World!</h1>
4747
</template>
4848
</amp-list>
4949
</body>
50-
</html>
50+
</html>

packages/optimizer/spec/transformers/valid/AutoExtensionImporter/uses-non-experimental-versions/expected_output.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
</template>
2323
</amp-date-display>
2424
</body>
25-
</html>
25+
</html>

0 commit comments

Comments
 (0)