Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.1 KB
Raw Blame
import path from 'node:path'
import { pathToFileURL } from 'node:url'
import {
  collectProcessHostSources,
  main as checkProcessHostImports
} from './check-process-host-imports.mjs'
import { main as checkCompatBoundaryImports } from './check-compat-boundary-imports.mjs'
import { collectModuleSpecifiers } from './static-module-specifiers.mjs'

export function main(
  root = process.cwd(),
  { collectSources = collectProcessHostSources, parseSpecifiers = collectModuleSpecifiers } = {}
) {
  const sources = collectSources(root)
  // These results belong only to this immutable source inventory and this invocation.
  const specifiers = new Map()
  const specifiersFor = (file, contents) => {
    if (!specifiers.has(file)) {
      specifiers.set(file, parseSpecifiers(file, contents))
    }
    return specifiers.get(file)
  }
  const processHost = checkProcessHostImports(root, sources, specifiersFor)
  const compatibility = checkCompatBoundaryImports(root, sources, specifiersFor)
  return Math.max(processHost, compatibility)
}

if (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) {
  process.exitCode = main()
}