xref: /expo/docs/scripts/resource-specs-sync.mjs (revision bcc59125)
1import fs from 'fs';
2import fetch from 'node-fetch';
3
4async function run() {
5  const resourceSpecsSource =
6    'https://raw.githubusercontent.com/expo/eas-build/main/public/resource-specs/current.json';
7
8  console.log(`Fetching resource specs from ${resourceSpecsSource}`);
9
10  const response = await fetch(resourceSpecsSource);
11  if (!response.ok) {
12    console.error(`Failed to fetch resource specs from ${resourceSpecsSource}`);
13    console.error(`Response status: ${response.status}`);
14    console.error(`Response body: ${await response.text()}`);
15    return;
16  }
17
18  const data = await response.text();
19
20  // TODO: is public the correct place for this?
21  const resourcePath = 'public/static/resource-specs.json';
22
23  console.log(`Writing resource specs to ${resourcePath}`);
24  await fs.writeFile(resourcePath, data, { encoding: 'utf8' }, () => {});
25}
26
27run();
28