Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Has been cancelled
28 lines
1.1 KiB
JavaScript
28 lines
1.1 KiB
JavaScript
#!/usr/bin/env node
|
|
require('dotenv').config();
|
|
const DIRECTUS_URL = process.env.DIRECTUS_URL || 'https://cms.dk0.dev';
|
|
const DIRECTUS_TOKEN = process.env.DIRECTUS_STATIC_TOKEN;
|
|
|
|
async function api(endpoint, method = 'GET', body = null) {
|
|
const url = `${DIRECTUS_URL}/${endpoint}`;
|
|
const options = {
|
|
method,
|
|
headers: { 'Authorization': `Bearer ${DIRECTUS_TOKEN}`, 'Content-Type': 'application/json' }
|
|
};
|
|
if (body) options.body = JSON.stringify(body);
|
|
const response = await fetch(url, options);
|
|
const data = await response.json().catch(() => ({}));
|
|
return { ok: response.ok, data };
|
|
}
|
|
|
|
async function emergencyFix() {
|
|
console.log('Fixing...');
|
|
await api('collections/book_reviews', 'PATCH', { meta: { hidden: true } });
|
|
await api('collections/book_reviews', 'PATCH', { meta: { hidden: false, icon: 'book' } });
|
|
await api('fields/book_reviews/translations', 'PATCH', {
|
|
meta: { interface: 'translations', options: { languageField: 'languages_code' } }
|
|
});
|
|
console.log('Done. Please reload in Incognito.');
|
|
}
|
|
emergencyFix().catch(console.error);
|