mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-03 05:55:03 +01:00
31 lines
827 B
JavaScript
31 lines
827 B
JavaScript
/* eslint-disable no-console */
|
|
// @ts-check
|
|
import { writeFile } from 'fs/promises';
|
|
import { join } from 'path';
|
|
|
|
async function fetchSpec() {
|
|
const response = await fetch('https://api.yield.xyz/docs.yaml', {
|
|
headers: {
|
|
Accept: 'application/yaml',
|
|
},
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`Failed to fetch spec: ${response.statusText}`);
|
|
}
|
|
|
|
return await response.text();
|
|
}
|
|
|
|
async function updateSpec() {
|
|
console.log('⏳ Fetching Yield XYZ API spec...');
|
|
const specPath = join(process.cwd(), 'openapi.yaml');
|
|
const spec = await fetchSpec();
|
|
|
|
console.log('⏳ Saving Yield XYZ API spec to ', specPath);
|
|
await writeFile(specPath, spec, 'utf-8');
|
|
console.log('✅ Yield XYZ API spec updated successfully');
|
|
}
|
|
|
|
updateSpec().catch(console.error);
|