Luigit
repositories / Unfugwart

Unfugwart

Discord caretaker for Abteilung Unfug

owned by admin

scripts/generate-settings.js

Raw
import { readFile, writeFile } from 'node:fs/promises';

const root = new URL('../', import.meta.url);
const source = await readFile(new URL('installer.js', root));
const command = `node --input-type=module --eval "import 'data:text/javascript;base64,${source.toString('base64')}'"`;
const settings = {
  type: 'discord',
  id: '61b39066',
  display: 'Unfugwart',
  data: {
    'bot-js-file': { type: 'string', value: 'bot.js', display: 'Main bot file', desc: 'The main bot file.', required: true, userEdit: false }
  },
  install: [{ type: 'command', commands: [command] }],
  uninstall: null,
  run: { command: 'node ./${bot-js-file}', stopCode: 2, stdin: { type: 'stdin' }, autostart: true, autorecover: true, autorestart: false },
  environment: { type: 'docker', bindings: {}, containerRoot: '', image: 'node:24-bookworm-slim', networkName: 'bridge', portBindings: [] },
  supportedEnvironments: [{ type: 'docker', image: 'node:24-bookworm-slim' }],
  requirements: { binaries: ['node', 'npm'] },
  stats: { type: '' },
  query: { type: '' },
  keepAlive: { frequency: '', command: '' }
};
const rendered = `${JSON.stringify(settings, null, 2)}\n`;
if (process.argv[2] === '--check') {
  if (await readFile(new URL('settings.json', root), 'utf8') !== rendered) throw new Error('settings.json is not generated from installer.js');
} else {
  await writeFile(new URL('settings.json', root), rendered);
}

export { command, settings };