CoolFace
Apppublic

delqhi/sin-github-issues

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
init-github-app-routing-local.mjs55 linesDownload Raw Back to scripts
1#!/usr/bin/env node2 3import { access, copyFile, mkdir } from 'node:fs/promises';4import path from 'node:path';5 6const cwd = process.cwd();7 8function parseArgs(argv) {9  const out = {};10  for (let i = 0; i < argv.length; i += 1) {11    const token = argv[i];12    if (!token.startsWith('--')) continue;13    const key = token.slice(2);14    const next = argv[i + 1];15    if (!next || next.startsWith('--')) {16      out[key] = 'true';17      continue;18    }19    out[key] = next;20    i += 1;21  }22  return out;23}24 25async function exists(filePath) {26  try {27    await access(filePath);28    return true;29  } catch {30    return false;31  }32}33 34async function main() {35  const args = parseArgs(process.argv.slice(2));36  const configDir = path.resolve(cwd, 'config');37  const source = path.resolve(configDir, 'github-app-routing.example.json');38  const target = path.resolve(configDir, args.target || 'github-app-routing.local.json');39  const force = args.force === 'true';40 41  await mkdir(configDir, { recursive: true });42  if (!force && (await exists(target))) {43    console.log(JSON.stringify({ ok: true, created: false, source, target, message: 'local routing config already exists' }, null, 2));44    return;45  }46 47  await copyFile(source, target);48  console.log(JSON.stringify({ ok: true, created: true, source, target }, null, 2));49}50 51main().catch((error) => {52  console.error(error instanceof Error ? error.message : String(error));53  process.exit(1);54});55