start.ts 831 B

12345678910111213141516171819202122232425
  1. import { pathToFileURL } from 'node:url'
  2. import { Context } from 'cordis'
  3. import Loader from '@cordisjs/plugin-loader'
  4. // Load DEEPSEEK_API_KEY / DEEPSEEK_BASE_URL from a gitignored repo-root .env
  5. // (Node >= 21.7 native). Absent file is fine — the environment may already
  6. // carry the variables; cordis.yml reads them via the `!!js` tag.
  7. try {
  8. process.loadEnvFile(new URL('../../.env', import.meta.url).pathname)
  9. } catch {
  10. // no .env — rely on the ambient environment
  11. }
  12. // Boot a Cordis app from this example's cordis.yml — the same shape as the
  13. // upstream `cordis` bin, pinned to this directory.
  14. const ctx = new Context()
  15. ctx.baseUrl = pathToFileURL(import.meta.dirname).href + '/'
  16. await ctx.plugin(Loader)
  17. await ctx.loader.create({
  18. name: '@cordisjs/plugin-include',
  19. config: {
  20. path: './cordis.yml',
  21. },
  22. })