Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Has been cancelled
38 lines
1.5 KiB
JavaScript
38 lines
1.5 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();
|
|
return { ok: response.ok, data, status: response.status };
|
|
}
|
|
|
|
async function fix() {
|
|
console.log('🔧 Fixing Directus Book Reviews...');
|
|
await api('collections/book_reviews', 'PATCH', { meta: { icon: 'menu_book', display_template: '{{book_title}}', hidden: false } });
|
|
|
|
// Link to system languages
|
|
await api('relations', 'POST', {
|
|
collection: 'book_reviews_translations',
|
|
field: 'languages_code',
|
|
related_collection: 'languages',
|
|
meta: { interface: 'select-dropdown' }
|
|
});
|
|
|
|
// UI Improvements
|
|
await api('fields/book_reviews/status', 'PATCH', { meta: { interface: 'select-dropdown', display: 'labels' } });
|
|
await api('fields/book_reviews/rating', 'PATCH', { meta: { interface: 'rating', display: 'rating' } });
|
|
await api('fields/book_reviews_translations/review', 'PATCH', { meta: { interface: 'input-rich-text-html' } });
|
|
|
|
console.log('✅ Fix applied! Bitte lade Directus neu und setze die Permissions auf Public.');
|
|
}
|
|
fix().catch(console.error);
|