Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

1.3 KB
Raw Blame
/** Keep the isolated settings bridge executable on Hermes without runtime source serialization. */
import fs from "node:fs";
import ts from "typescript";
import { fileURLToPath } from "node:url";
const source = fileURLToPath(
  new URL(
    "../apps/mobile/src/plugins/pluginSettingsBootstrap.ts",
    import.meta.url,
  ),
);
const target = fileURLToPath(
  new URL(
    "../apps/mobile/src/plugins/pluginSettingsBootstrap.generated.ts",
    import.meta.url,
  ),
);
const compiled = ts
  .transpileModule(fs.readFileSync(source, "utf8"), {
    compilerOptions: {
      target: ts.ScriptTarget.ES2022,
      module: ts.ModuleKind.ESNext,
    },
  })
  .outputText.replace(
    "export function settingsBootstrap(",
    "function settingsBootstrap(",
  )
  .replace(/export \{\};?\s*$/, "");
const output =
  "// Generated by scripts/generate-mobile-settings-bootstrap.mjs. Edit pluginSettingsBootstrap.ts.\n" +
  "export const PLUGIN_SETTINGS_BOOTSTRAP = " +
  JSON.stringify(compiled) +
  ";\n";
if (process.argv.includes("--check")) {
  if (!fs.existsSync(target) || fs.readFileSync(target, "utf8") !== output) {
    process.stderr.write(
      "Mobile settings bootstrap is stale; run node scripts/generate-mobile-settings-bootstrap.mjs\n",
    );
    process.exitCode = 1;
  }
} else fs.writeFileSync(target, output);