feat: Added scripts to auto-update to latest version
This commit is contained in:
parent
087371b3ce
commit
26d518fb8e
@ -26,6 +26,8 @@
|
||||
"build:lib": "openapi --input ./openapi.json --output ./lib --client fetch",
|
||||
"build:compile": "tsc",
|
||||
"build:cleanup": "rimraf ./lib",
|
||||
"update:openapi": "rimraf ./openapi.json && node ./scripts/getliveopenapi.js",
|
||||
"update": "npm run update:openapi && npm run build && npm run release",
|
||||
"release": "release-it"
|
||||
},
|
||||
"bugs": {
|
||||
|
27
scripts/getliveopenapi.js
Normal file
27
scripts/getliveopenapi.js
Normal file
@ -0,0 +1,27 @@
|
||||
const https = require('https');
|
||||
const fs = require('fs');
|
||||
|
||||
const url = 'https://run.lauf-fuer-kaya.de/api/docs/openapi.json';
|
||||
const output = 'openapi.json';
|
||||
|
||||
https.get(url, (res) => {
|
||||
if (res.statusCode !== 200) {
|
||||
console.error(`Request Failed. Status Code: ${res.statusCode}`);
|
||||
res.resume();
|
||||
return;
|
||||
}
|
||||
|
||||
let data = '';
|
||||
res.on('data', chunk => data += chunk);
|
||||
res.on('end', () => {
|
||||
fs.writeFile(output, data, (err) => {
|
||||
if (err) {
|
||||
console.error('Error writing file:', err);
|
||||
} else {
|
||||
console.log(`Saved latest OpenAPI JSON to ${output}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}).on('error', (e) => {
|
||||
console.error(`Got error: ${e.message}`);
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user