#!/usr/bin/env node // Bootstrap. A global `npm install -g @tlecommunity/super-ui` invokes this file // as a plain `node super-cli.js` - without the `--import=extensionless/register` // flag the dev npm scripts always pass. Every downstream module relies on it: the // whole CLI (and `@tlecommunity/super-tasks`, which this entry pulls in) uses // extension-less relative imports, which bare Node cannot resolve. // // This file therefore imports ONLY `node:` builtins (so its own module graph // loads with no flag), re-execs itself once with the flag applied via // NODE_OPTIONS, and only then dynamically imports the real entry point. Passing // the flag through NODE_OPTIONS (rather than argv) also makes it reach the // `super-cli-` child processes commander spawns - it does not forward // execArgv to them. import { spawnSync } from 'node:child_process' import { createRequire } from 'node:module' import { pathToFileURL } from 'node:url' if (process.env.SUPER_UI_BOOTSTRAPPED !== '1') { const nodeMajor = Number(process.versions.node.split('.')[0]) if (Number.isNaN(nodeMajor) || nodeMajor < 24) { process.stderr.write(`super-ui requires Node >= 24 (running ${process.versions.node})\n`) process.exit(1) } const require = createRequire(import.meta.url) const flags = [`--import=${pathToFileURL(require.resolve('extensionless/register')).href}`] const nodeOptions = [process.env.NODE_OPTIONS, ...flags].filter(Boolean).join(' ') const result = spawnSync(process.execPath, [process.argv[1], ...process.argv.slice(2)], { stdio: 'inherit', env: { ...process.env, SUPER_UI_BOOTSTRAPPED: '1', NODE_OPTIONS: nodeOptions }, }) if (result.error) { throw result.error } process.exit(result.status ?? 1) } await import('./super-cli.main.js')