Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Failing after 7m26s
Remove unused imports, replace `any` types with proper interfaces in directus.ts and i18n-loader.ts, exclude scripts/ and coverage/ from ESLint, and fix unused variable warnings across the codebase. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
80 lines
2.8 KiB
JavaScript
80 lines
2.8 KiB
JavaScript
|
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
const fetch = require('node-fetch');
|
|
require('dotenv').config();
|
|
|
|
const DIRECTUS_URL = process.env.DIRECTUS_URL || 'https://cms.dk0.dev';
|
|
const DIRECTUS_TOKEN = process.env.DIRECTUS_STATIC_TOKEN;
|
|
|
|
async function setupSnippets() {
|
|
console.log('📦 Setting up Snippets collection...');
|
|
|
|
// 1. Create Collection
|
|
try {
|
|
await fetch(`${DIRECTUS_URL}/collections`, {
|
|
method: 'POST',
|
|
headers: { 'Authorization': `Bearer ${DIRECTUS_TOKEN}`, 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
collection: 'snippets',
|
|
meta: { icon: 'terminal', display_template: '{{title}}' },
|
|
schema: { name: 'snippets' }
|
|
})
|
|
});
|
|
} catch (_e) {}
|
|
|
|
// 2. Add Fields
|
|
const fields = [
|
|
{ field: 'status', type: 'string', meta: { interface: 'select-dropdown' }, schema: { default_value: 'published' } },
|
|
{ field: 'title', type: 'string', meta: { interface: 'input' } },
|
|
{ field: 'category', type: 'string', meta: { interface: 'input' } },
|
|
{ field: 'code', type: 'text', meta: { interface: 'input-code' } },
|
|
{ field: 'description', type: 'text', meta: { interface: 'textarea' } },
|
|
{ field: 'language', type: 'string', meta: { interface: 'input' }, schema: { default_value: 'javascript' } },
|
|
{ field: 'featured', type: 'boolean', meta: { interface: 'boolean' }, schema: { default_value: false } }
|
|
];
|
|
|
|
for (const f of fields) {
|
|
try {
|
|
await fetch(`${DIRECTUS_URL}/fields/snippets`, {
|
|
method: 'POST',
|
|
headers: { 'Authorization': `Bearer ${DIRECTUS_TOKEN}`, 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(f)
|
|
});
|
|
} catch (_e) {}
|
|
}
|
|
|
|
// 3. Add Example Data
|
|
const exampleSnippets = [
|
|
{
|
|
title: 'Traefik SSL Config',
|
|
category: 'Docker',
|
|
language: 'yaml',
|
|
featured: true,
|
|
description: "Meine Standard-Konfiguration für automatisches SSL via Let's Encrypt in Docker Swarm.",
|
|
code: "labels:\n - \"traefik.enable=true\"\n - \"traefik.http.routers.myapp.rule=Host(`example.com`)\"\n - \"traefik.http.routers.myapp.entrypoints=websecure\"\n - \"traefik.http.routers.myapp.tls.certresolver=myresolver\""
|
|
},
|
|
{
|
|
title: 'Docker Cleanup Alias',
|
|
category: 'ZSH',
|
|
language: 'bash',
|
|
featured: true,
|
|
description: 'Ein einfacher Alias, um ungenutzte Docker-Container, Images und Volumes schnell zu entfernen.',
|
|
code: "alias dclean='docker system prune -af --volumes'"
|
|
}
|
|
];
|
|
|
|
for (const s of exampleSnippets) {
|
|
try {
|
|
await fetch(`${DIRECTUS_URL}/items/snippets`, {
|
|
method: 'POST',
|
|
headers: { 'Authorization': `Bearer ${DIRECTUS_TOKEN}`, 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(s)
|
|
});
|
|
} catch (_e) {}
|
|
}
|
|
|
|
console.log('✅ Snippets setup complete!');
|
|
}
|
|
|
|
setupSnippets();
|