@orion-js/core 4.3.3 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/build/build.d.ts +3 -0
- package/dist/build/checkTs.d.ts +1 -0
- package/dist/build/index.d.ts +3 -0
- package/dist/check/checkTs.d.ts +1 -0
- package/dist/check/index.d.ts +1 -0
- package/dist/create/index.d.ts +4 -0
- package/dist/dev/index.d.ts +2 -0
- package/dist/dev/runner/getArgs.d.ts +5 -0
- package/dist/dev/runner/index.d.ts +12 -0
- package/dist/dev/runner/startProcess.d.ts +2 -0
- package/dist/dev/watchAndCompile/cleanDirectory.d.ts +1 -0
- package/dist/dev/watchAndCompile/ensureConfigComplies.d.ts +1 -0
- package/dist/dev/watchAndCompile/getConfigPath.d.ts +1 -0
- package/dist/dev/watchAndCompile/getHost.d.ts +2 -0
- package/dist/dev/watchAndCompile/index.d.ts +2 -0
- package/dist/dev/watchAndCompile/writeEnvFile.d.ts +2 -0
- package/dist/handleErrors.d.ts +1 -0
- package/dist/helpers/ensureDirectory.d.ts +2 -0
- package/dist/helpers/execute.d.ts +1 -0
- package/dist/helpers/getFileContents.d.ts +1 -0
- package/dist/helpers/writeFile.d.ts +1 -0
- package/dist/index.cjs +104 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +91 -101
- package/dist/index.js.map +1 -1
- package/dist/info.d.ts +1 -0
- package/dist/prod/index.d.ts +5 -0
- package/dist/prod/runProd.d.ts +2 -0
- package/dist/repl/index.d.ts +5 -0
- package/dist/version.d.ts +2 -0
- package/package.json +12 -13
- package/dist/index.d.cts +0 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/helpers/execute.ts","../src/create/index.ts","../src/dev/index.ts","../src/dev/runner/index.ts","../src/helpers/writeFile.ts","../src/helpers/ensureDirectory.ts","../src/dev/runner/startProcess.ts","../src/dev/runner/getArgs.ts","../src/dev/watchAndCompile/index.ts","../src/dev/watchAndCompile/cleanDirectory.ts","../src/dev/watchAndCompile/getHost.ts","../src/dev/watchAndCompile/getConfigPath.ts","../src/dev/watchAndCompile/ensureConfigComplies.ts","../src/helpers/getFileContents.ts","../src/dev/watchAndCompile/reports.ts","../src/dev/watchAndCompile/writeEnvFile.ts","../src/prod/index.ts","../src/build/index.ts","../src/build/build.ts","../src/build/checkTs.ts","../src/prod/runProd.ts","../src/handleErrors.ts","../src/version.ts","../src/check/index.ts","../src/check/checkTs.ts","../src/info.ts","../src/repl/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport chalk from 'chalk'\nimport {Command} from 'commander'\nimport create from './create'\nimport dev from './dev'\nimport prod from './prod'\nimport './handleErrors'\nimport version from './version'\nimport 'dotenv/config'\nimport build from './build'\nimport check from './check'\nimport info from './info'\nimport repl from './repl'\n\nconst program = new Command()\n\nconst run =\n action =>\n async (...args) => {\n try {\n await action(...args)\n } catch (e) {\n console.error(chalk.red(`Error: ${e.message}`))\n }\n }\n\nprogram\n .command('dev')\n .description('Run the Orionjs app in development mode')\n .option('--node', 'Use Node.js runtime instead of Bun')\n .option('--repl', 'Enable REPL endpoint for orion repl')\n .allowUnknownOption()\n .action(run(dev))\n\nprogram.command('check').description('Runs a typescript check').action(run(check))\n\nprogram\n .command('build')\n .description('Build the Orionjs app for production')\n .option('--output [path]', 'Path of the output file')\n .action(run(build))\n\nprogram\n .command('prod')\n .allowUnknownOption()\n .option('--node', 'Use Node.js runtime instead of Bun')\n .option(\n '--path [path]',\n 'Path of the compiled Orionjs app. If not provided, the app will be compiled and then run',\n )\n .description('Run the Orionjs app in production mode')\n .action(run(prod))\n\nprogram\n .command('create')\n .description('Creates a new Orionjs project')\n .option('--name [name]', 'Name of the project')\n .option('--kit [kit]', 'Which starter kit to use')\n .action(run(create))\n\nprogram.command('info').description('Print runtime and version info').action(run(info))\n\nprogram\n .command('repl')\n .description('Evaluate an expression against a running Orionjs dev server')\n .requiredOption('-e, --expression <expression>', 'Expression to evaluate')\n .option('--port <port>', 'Port of the dev server (default: auto-detect from .orion/port)')\n .action(run(repl))\n\nprogram.version(version, '-v --version')\n\nprogram.parse(process.argv)\n\nif (!process.argv.slice(2).length) {\n program.outputHelp()\n}\n","import {exec} from 'node:child_process'\n\nexport default async function (command) {\n return new Promise((resolve, reject) => {\n exec(command, (error, stdout, stderr) => {\n if (error) {\n reject(error)\n } else {\n resolve({stdout, stderr})\n }\n })\n })\n}\n","import execute from '../helpers/execute'\n\nexport default async function ({name, kit}) {\n if (!name) {\n throw new Error('Please set the name of the app')\n }\n if (!kit) {\n throw new Error('Please select which kit to use')\n }\n const repo = `https://github.com/siturra/boilerplate-orionjs-${kit}`\n console.log('Downloading starter kit...')\n await execute(`git clone ${repo} ${name}`)\n await execute(`cd ${name} && rm -rf .git`)\n console.log('Your starter kit is ready')\n}\n","import chalk from 'chalk'\nimport {getRunner, RunnerOptions} from './runner'\nimport watchAndCompile from './watchAndCompile'\n\nexport default async function (options: RunnerOptions, command: any) {\n console.log(chalk.bold(`\\nOrionjs App ${chalk.green(chalk.bold('V4'))} Dev mode \\n`))\n\n const runner = getRunner(options, command)\n\n watchAndCompile(runner)\n}\n","import chalk from 'chalk'\nimport writeFile from '../../helpers/writeFile'\nimport {startProcess} from './startProcess'\n\nexport interface RunnerOptions {\n shell: boolean\n clean: boolean\n node: boolean\n repl: boolean\n}\n\nexport interface Runner {\n start: () => void\n restart: () => void\n stop: () => void\n}\n\nexport function getRunner(options: RunnerOptions, command: any): Runner {\n let appProcess = null\n\n if (options.clean) {\n console.log(chalk.bold('=> Cleaning directory...\\n'))\n }\n\n const startApp = () => {\n appProcess = startProcess(options, command)\n\n appProcess.on('exit', (code: number, signal: string) => {\n if (!code || code === 143 || code === 0 || signal === 'SIGTERM' || signal === 'SIGINT') {\n } else {\n console.log(chalk.bold(`=> Error running app. Exit code: ${code}`))\n }\n })\n\n writeFile('.orion/process', `${appProcess.pid}`)\n }\n\n const stop = () => {\n if (appProcess) {\n appProcess.kill()\n appProcess = null\n }\n }\n\n const restart = () => {\n console.log(chalk.bold('=> Restarting app...\\n'))\n stop()\n startApp()\n }\n\n const start = () => {\n // check if the app is already running\n if (appProcess) {\n // console.log(chalk.bold('=> App is already running. Restarting...\\n'))\n } else {\n startApp()\n }\n }\n\n return {\n restart,\n stop,\n start,\n }\n}\n","import fs from 'node:fs'\nimport ensureDirectory from '../helpers/ensureDirectory'\n\nexport default async function (path: string, content: string): Promise<void> {\n ensureDirectory(path)\n fs.writeFileSync(path, content)\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nconst ensureDirectory = filePath => {\n const dirname = path.dirname(filePath)\n if (fs.existsSync(dirname)) return true\n ensureDirectory(dirname)\n fs.mkdirSync(dirname)\n}\n\nexport default ensureDirectory\n","import {spawn} from 'node:child_process'\nimport chalk from 'chalk'\nimport {getArgs} from './getArgs'\nimport {RunnerOptions} from './index'\n\nexport function startProcess(options: RunnerOptions, command: any) {\n const {startCommand, args} = getArgs(options, command)\n\n console.log(chalk.bold(`=> Starting app with command: ${startCommand} ${args.join(' ')}...\\n`))\n return spawn(startCommand, args, {\n env: {\n ORION_DEV: 'local',\n ...process.env,\n ...(options.repl ? {ORION_REPL: 'true'} : {}),\n },\n cwd: process.cwd(),\n stdio: 'inherit',\n detached: false,\n })\n}\n","import {RunnerOptions} from './index'\n\nexport function getArgs(options: RunnerOptions, command: any) {\n if (options.node) {\n const startCommand = 'tsx'\n const args = ['watch', '--clear-screen=false', ...command.args, './app/index.ts']\n return {startCommand, args}\n }\n\n const startCommand = 'bun'\n const args = ['--watch', ...command.args, './app/index.ts']\n return {startCommand, args}\n}\n","import ts from 'typescript'\nimport {Runner} from '../runner'\nimport cleanDirectory from './cleanDirectory'\nimport {getHost} from './getHost'\nimport {watchEnvFile} from './writeEnvFile'\n\nexport default async function watchAndCompile(runner: Runner) {\n await cleanDirectory()\n const host = getHost(runner)\n ts.createWatchProgram(host)\n watchEnvFile(runner)\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\n/**\n * Remove directory recursively\n * @param {string} dir_path\n * @see https://stackoverflow.com/a/42505874/3027390\n */\nfunction rimraf(dir_path: string) {\n if (fs.existsSync(dir_path)) {\n fs.readdirSync(dir_path).map(entry => {\n const entry_path = path.join(dir_path, entry)\n if (fs.lstatSync(entry_path).isDirectory()) {\n rimraf(entry_path)\n } else {\n fs.unlinkSync(entry_path)\n }\n })\n fs.rmdirSync(dir_path)\n }\n}\n\nexport default async function cleanDirectory(directory?: string) {\n try {\n const dirPath = directory ? directory : path.join(process.cwd(), '.orion', 'build')\n rimraf(dirPath)\n } catch (_) {\n // Ignore errors during cleanup\n }\n}\n","import ts from 'typescript'\nimport {getConfigPath} from './getConfigPath'\nimport {reportDiagnostic} from './reports'\nimport {Runner} from '../runner'\nimport chalk from 'chalk'\n\nexport function getHost(runner: Runner) {\n let isStopped = true\n const reportWatchStatusChanged = (diagnostic: ts.Diagnostic) => {\n if (diagnostic.category !== 3) return\n if (diagnostic.code === 6031 || diagnostic.code === 6032) {\n // file change detected, starting compilation\n // console.log(chalk.bold(`=> ${diagnostic.messageText}`))\n return\n }\n\n if (diagnostic.code === 6193) {\n runner.stop()\n isStopped = true\n return\n }\n\n if (diagnostic.code === 6194) {\n /**\n * Sometimes diagnostic code is 6194 even with errors\n */\n if (/^Found .+ errors?/.test(diagnostic.messageText.toString())) {\n if (!diagnostic.messageText.toString().includes('Found 0 errors.')) {\n runner.stop()\n isStopped = true\n return\n }\n }\n\n if (isStopped) {\n isStopped = false\n runner.start()\n }\n return\n }\n\n console.log(chalk.bold(`=> ${diagnostic.messageText} [${diagnostic.code}]`))\n }\n\n const configPath = getConfigPath()\n const createProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram\n\n const host = ts.createWatchCompilerHost(\n configPath,\n {},\n ts.sys,\n createProgram,\n reportDiagnostic,\n reportWatchStatusChanged,\n )\n\n return host\n}\n","import ts from 'typescript'\nimport {ensureConfigComplies} from './ensureConfigComplies'\n\nexport function getConfigPath() {\n const appBasePath = process.cwd()\n\n const configPath =\n ts.findConfigFile(appBasePath, ts.sys.fileExists, 'tsconfig.server.json') ||\n ts.findConfigFile(appBasePath, ts.sys.fileExists, 'tsconfig.json')\n\n if (!configPath) {\n throw new Error(\"Could not find a valid 'tsconfig.json'.\")\n }\n\n ensureConfigComplies(configPath)\n\n return configPath\n}\n","import {parse, stringify} from 'comment-json'\nimport getFileContents from '../../helpers/getFileContents'\nimport writeFile from '../../helpers/writeFile'\n\n// Define TypeScript config interface\ninterface TSConfig {\n compilerOptions?: {\n baseUrl?: string\n rootDir?: string\n rootDirs?: string[]\n [key: string]: any\n }\n [key: string]: any\n}\n\nexport function ensureConfigComplies(configPath: string) {\n try {\n const configJSON = getFileContents(configPath)\n const config = parse(configJSON) as TSConfig\n\n const newConfig = {\n ...config,\n compilerOptions: {\n ...config.compilerOptions,\n baseUrl: './',\n noEmit: true,\n },\n }\n\n if (!config.compilerOptions?.rootDir && !config.compilerOptions?.rootDirs) {\n newConfig.compilerOptions.rootDir = './app'\n }\n\n // are the same, no write\n if (JSON.stringify(config) === JSON.stringify(newConfig)) {\n return\n }\n\n writeFile(configPath, stringify(newConfig, null, 2))\n } catch (error) {\n console.log(`Error reading tsconfig: ${error.message}`)\n }\n}\n","import fs from 'node:fs'\n\nexport default function readFile(filePath: string) {\n if (!fs.existsSync(filePath)) return null\n\n return fs.readFileSync(filePath).toString()\n}\n","import ts from 'typescript'\n\nconst format = {\n getCanonicalFileName: fileName => fileName,\n getCurrentDirectory: () => process.cwd(),\n getNewLine: () => ts.sys.newLine,\n}\nexport function reportDiagnostic(diagnostic: ts.Diagnostic) {\n console.log(ts.formatDiagnosticsWithColorAndContext([diagnostic], format))\n}\n","import {writeDtsFileFromConfigFile} from '@orion-js/env'\nimport chalk from 'chalk'\nimport chokidar from 'chokidar'\nimport {Runner} from '../runner'\n\nconst envFilePath = process.env.ORION_ENV_FILE_PATH\nconst dtsFilePath = './app/env.d.ts'\n\nexport const watchEnvFile = async (runner: Runner) => {\n if (!envFilePath) return\n\n writeDtsFileFromConfigFile(envFilePath, dtsFilePath)\n\n chokidar.watch(envFilePath, {ignoreInitial: true}).on('change', async () => {\n console.log(chalk.bold('=> Environment file changed. Restarting...'))\n writeDtsFileFromConfigFile(envFilePath, dtsFilePath)\n runner.restart()\n })\n}\n","import chalk from 'chalk'\nimport build from '../build'\nimport {runProd} from './runProd'\n\nexport interface ProdOptions {\n path?: string\n node?: boolean\n}\n\nexport default async function (options: ProdOptions, command: any) {\n console.log(chalk.bold(`\\nOrionjs App ${chalk.green(chalk.bold('V4'))} Prod mode\\n`))\n\n if (options.node) {\n if (!options.path) {\n await build({output: './build'})\n options.path = './build'\n }\n }\n\n runProd(options, command)\n}\n","import chalk from 'chalk'\nimport {build} from './build'\nimport cleanDirectory from '../dev/watchAndCompile/cleanDirectory'\nimport {checkTs} from './checkTs'\n\nexport default async function (options: {output?: string}) {\n console.log(chalk.bold(`Building Orionjs App ${chalk.green(chalk.bold('V4'))}...`))\n\n if (!options.output) {\n options.output = './build'\n }\n\n await cleanDirectory(options.output)\n\n await checkTs()\n await build(options)\n\n console.log(chalk.bold('Build completed'))\n}\n","import chalk from 'chalk'\nimport * as esbuild from 'esbuild'\n\nexport async function build(options: {output?: string}) {\n const {output} = options\n\n console.log(`Building with esbuild to ${output}`)\n\n await esbuild.build({\n entryPoints: ['./app/index.ts'],\n tsconfig: './tsconfig.json',\n format: 'esm',\n platform: 'node',\n outdir: output,\n bundle: true,\n target: 'node22',\n sourcemap: true,\n allowOverwrite: true,\n minify: true,\n packages: 'external',\n })\n\n console.log(chalk.green.bold('Build successful'))\n}\n","import chalk from 'chalk'\nimport {exec} from 'node:child_process'\nimport {promisify} from 'node:util'\n\nconst execPromise = promisify(exec)\n\nexport async function checkTs(): Promise<void> {\n try {\n console.log('Checking TypeScript...')\n await execPromise('tsc --noEmit', {\n cwd: process.cwd(),\n env: {\n ...process.env,\n },\n gid: process.getgid(),\n uid: process.getuid(),\n })\n console.log(chalk.green.bold('TypeScript check passed'))\n } catch (error) {\n console.log(chalk.red.bold('TypeScript compilation failed'))\n console.log(error.stderr || error.stdout || error.message)\n process.exit(1)\n }\n}\n","import {spawn} from 'node:child_process'\nimport {ProdOptions} from './index'\n\nexport function runProd(options: ProdOptions, command: any) {\n if (options.node) {\n const indexPath = `${options.path}/index.js`\n const args = ['--import=tsx', ...command.args, indexPath]\n spawn('node', args, {\n env: {\n NODE_ENV: 'production',\n ...process.env,\n },\n cwd: process.cwd(),\n stdio: 'inherit',\n gid: process.getgid(),\n uid: process.getuid(),\n detached: false,\n })\n return\n }\n\n const args = [...command.args, './app/index.ts']\n spawn('bun', args, {\n env: {\n NODE_ENV: 'production',\n ...process.env,\n },\n cwd: process.cwd(),\n stdio: 'inherit',\n gid: process.getgid(),\n uid: process.getuid(),\n detached: false,\n })\n}\n","import chalk from 'chalk'\n\ninterface ErrorWithCodeFrame extends Error {\n codeFrame?: string\n}\n\nprocess\n .on('unhandledRejection', (error: ErrorWithCodeFrame) => {\n if (error.codeFrame) {\n console.error(chalk.red(error.message))\n console.log(error.codeFrame)\n } else {\n console.error(chalk.red(error.message), chalk.red('Unhandled promise rejection'))\n }\n })\n .on('uncaughtException', (error: Error) => {\n console.error(chalk.red(error.message))\n process.exit(1)\n })\n","import {readFileSync} from 'node:fs'\nimport {dirname, resolve} from 'node:path'\nimport {fileURLToPath} from 'node:url'\n\nfunction getVersion(): string {\n try {\n const dir = dirname(fileURLToPath(import.meta.url))\n const pkgPath = resolve(dir, '..', 'package.json')\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))\n return pkg.version\n } catch {\n return 'unknown'\n }\n}\n\nexport default getVersion()\n","import chalk from 'chalk'\nimport {checkTs} from './checkTs'\n\nexport default async function () {\n console.log(chalk.bold(`Orionjs App ${chalk.green(chalk.bold('V4'))}\\n`))\n console.log('Checking typescript...')\n\n checkTs()\n\n console.log(chalk.bold.green('Check passed\\n'))\n}\n","import chalk from 'chalk'\nimport {execSync} from 'node:child_process'\n\nexport function checkTs() {\n try {\n execSync('tsc --noEmit', {\n cwd: process.cwd(),\n env: {\n ...process.env,\n },\n gid: process.getgid(),\n uid: process.getuid(),\n stdio: 'inherit',\n })\n } catch {\n console.log(chalk.red.bold('TypeScript compilation failed'))\n process.exit(1)\n }\n}\n","import chalk from 'chalk'\nimport {execSync} from 'node:child_process'\nimport version from './version'\n\nfunction detectRuntime(): string {\n const runtimes: string[] = []\n\n try {\n const bunVersion = execSync('bun --version', {encoding: 'utf-8'}).trim()\n runtimes.push(`Bun ${bunVersion}`)\n } catch {}\n\n runtimes.push(`Node ${process.versions.node}`)\n\n return runtimes.join(', ')\n}\n\nexport default function info() {\n console.log(`Orion CLI v${version} — Available runtimes: ${chalk.bold(detectRuntime())}`)\n console.log(`Default runtime: ${chalk.bold('Bun')} (use --node flag to switch to Node.js)`)\n}\n","import {readFileSync} from 'node:fs'\nimport {resolve} from 'node:path'\nimport chalk from 'chalk'\n\nexport interface ReplOptions {\n expression?: string\n port?: string\n}\n\nfunction resolvePort(options: ReplOptions): number {\n if (options.port) {\n return Number(options.port)\n }\n\n try {\n const portFile = resolve(process.cwd(), '.orion/port')\n const port = readFileSync(portFile, 'utf-8').trim()\n return Number(port)\n } catch {}\n\n if (process.env.PORT) {\n return Number(process.env.PORT)\n }\n\n return 3000\n}\n\nexport default async function repl(options: ReplOptions) {\n const expression = options.expression\n\n if (!expression) {\n console.error(chalk.red('Error: expression is required. Use -e \"<expression>\"'))\n process.exit(1)\n }\n\n const port = resolvePort(options)\n\n try {\n const response = await fetch(`http://localhost:${port}/__repl`, {\n method: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify({expression}),\n })\n\n const data = await response.json()\n\n if (!data.success) {\n console.error(chalk.red(`Error: ${data.error}`))\n if (data.stack) {\n console.error(chalk.dim(data.stack))\n }\n process.exit(1)\n }\n\n if (data.result !== undefined) {\n console.log(\n typeof data.result === 'string' ? data.result : JSON.stringify(data.result, null, 2),\n )\n }\n } catch (error) {\n if (error.code === 'ECONNREFUSED' || error.cause?.code === 'ECONNREFUSED') {\n console.error(\n chalk.red(\n `Could not connect to dev server on port ${port}. Make sure \"orion dev --repl\" is running.`,\n ),\n )\n } else {\n console.error(chalk.red(`Error: ${error.message}`))\n }\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,iBAAkB;AAClB,uBAAsB;;;ACFtB,gCAAmB;AAEnB,eAAO,gBAAwB,SAAS;AACtC,SAAO,IAAI,QAAQ,CAACC,UAAS,WAAW;AACtC,wCAAK,SAAS,CAAC,OAAO,QAAQ,WAAW;AACvC,UAAI,OAAO;AACT,eAAO,KAAK;AAAA,MACd,OAAO;AACL,QAAAA,SAAQ,EAAC,QAAQ,OAAM,CAAC;AAAA,MAC1B;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;;;ACVA,eAAO,eAAwB,EAAC,MAAM,IAAG,GAAG;AAC1C,MAAI,CAAC,MAAM;AACT,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AACA,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AACA,QAAM,OAAO,kDAAkD,GAAG;AAClE,UAAQ,IAAI,4BAA4B;AACxC,QAAM,gBAAQ,aAAa,IAAI,IAAI,IAAI,EAAE;AACzC,QAAM,gBAAQ,MAAM,IAAI,iBAAiB;AACzC,UAAQ,IAAI,2BAA2B;AACzC;;;ACdA,IAAAC,gBAAkB;;;ACAlB,IAAAC,gBAAkB;;;ACAlB,IAAAC,kBAAe;;;ACAf,qBAAe;AACf,uBAAiB;AAEjB,IAAM,kBAAkB,cAAY;AAClC,QAAMC,WAAU,iBAAAC,QAAK,QAAQ,QAAQ;AACrC,MAAI,eAAAC,QAAG,WAAWF,QAAO,EAAG,QAAO;AACnC,kBAAgBA,QAAO;AACvB,iBA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;AAErB,QAAQ,QAAQ,MAAM,EAAE,YAAY,gCAAgC,EAAE,OAAO,IAAI,IAAI,CAAC;AAEtF,QACG,QAAQ,MAAM,EACd,YAAY,6DAA6D,EACzE,eAAe,iCAAiC,wBAAwB,EACxE,OAAO,iBAAiB,gEAAgE,EACxF,OAAO,IAAI,IAAI,CAAC;AAEnB,QAAQ,QAAQ,iBAAS,cAAc;AAEvC,QAAQ,MAAM,QAAQ,IAAI;AAE1B,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,EAAE,QAAQ;AACjC,UAAQ,WAAW;AACrB;","names":["import_chalk","resolve","import_chalk","import_chalk","import_node_fs","dirname","path","fs","path","fs","import_node_child_process","startCommand","args","chalk","chalk","import_typescript","import_node_fs","import_node_path","fs","path","import_typescript","import_node_fs","fs","ts","import_typescript","ts","import_chalk","chalk","ts","import_chalk","chokidar","chalk","ts","chalk","import_chalk","import_chalk","import_chalk","build","chalk","import_chalk","import_node_child_process","chalk","chalk","build","import_node_child_process","args","chalk","import_chalk","chalk","import_node_fs","import_node_path","import_chalk","import_chalk","import_node_child_process","checkTs","chalk","chalk","checkTs","import_chalk","import_node_child_process","chalk","import_node_fs","import_node_path","import_chalk","chalk","chalk"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/helpers/execute.ts","../src/create/index.ts","../src/dev/index.ts","../src/dev/runner/index.ts","../src/helpers/writeFile.ts","../src/helpers/ensureDirectory.ts","../src/dev/runner/startProcess.ts","../src/dev/runner/getArgs.ts","../src/dev/watchAndCompile/cleanDirectory.ts","../src/dev/watchAndCompile/getHost.ts","../src/dev/watchAndCompile/getConfigPath.ts","../src/dev/watchAndCompile/ensureConfigComplies.ts","../src/helpers/getFileContents.ts","../src/dev/watchAndCompile/writeEnvFile.ts","../src/dev/watchAndCompile/index.ts","../src/prod/index.ts","../src/build/index.ts","../src/build/build.ts","../src/build/checkTs.ts","../src/prod/runProd.ts","../src/handleErrors.ts","../src/version.ts","../src/check/index.ts","../src/check/checkTs.ts","../src/info.ts","../src/repl/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport chalk from 'chalk'\nimport {Command} from 'commander'\nimport create from './create'\nimport dev from './dev'\nimport prod from './prod'\nimport './handleErrors'\nimport version from './version'\nimport 'dotenv/config'\nimport build from './build'\nimport check from './check'\nimport info from './info'\nimport repl from './repl'\n\nconst program = new Command()\n\nconst run =\n action =>\n async (...args) => {\n try {\n await action(...args)\n } catch (e) {\n console.error(chalk.red(`Error: ${e.message}`))\n }\n }\n\nprogram\n .command('dev')\n .description('Run the Orionjs app in development mode')\n .option('--node', 'Use Node.js runtime instead of Bun')\n .option('--repl', 'Enable REPL endpoint for orion repl')\n .allowUnknownOption()\n .action(run(dev))\n\nprogram.command('check').description('Runs a typescript check').action(run(check))\n\nprogram\n .command('build')\n .description('Build the Orionjs app for production')\n .option('--output [path]', 'Path of the output file')\n .action(run(build))\n\nprogram\n .command('prod')\n .allowUnknownOption()\n .option('--node', 'Use Node.js runtime instead of Bun')\n .option(\n '--path [path]',\n 'Path of the compiled Orionjs app. If not provided, the app will be compiled and then run',\n )\n .description('Run the Orionjs app in production mode')\n .action(run(prod))\n\nprogram\n .command('create')\n .description('Creates a new Orionjs project')\n .option('--name [name]', 'Name of the project')\n .option('--kit [kit]', 'Which starter kit to use')\n .action(run(create))\n\nprogram.command('info').description('Print runtime and version info').action(run(info))\n\nprogram\n .command('repl')\n .description('Evaluate an expression against a running Orionjs dev server')\n .requiredOption('-e, --expression <expression>', 'Expression to evaluate')\n .option('--port <port>', 'Port of the dev server (default: auto-detect from .orion/port)')\n .action(run(repl))\n\nprogram.version(version, '-v --version')\n\nprogram.parse(process.argv)\n\nif (!process.argv.slice(2).length) {\n program.outputHelp()\n}\n","import {exec} from 'node:child_process'\n\nexport default async function (command) {\n return new Promise((resolve, reject) => {\n exec(command, (error, stdout, stderr) => {\n if (error) {\n reject(error)\n } else {\n resolve({stdout, stderr})\n }\n })\n })\n}\n","import execute from '../helpers/execute'\n\nexport default async function ({name, kit}) {\n if (!name) {\n throw new Error('Please set the name of the app')\n }\n if (!kit) {\n throw new Error('Please select which kit to use')\n }\n const repo = `https://github.com/siturra/boilerplate-orionjs-${kit}`\n console.log('Downloading starter kit...')\n await execute(`git clone ${repo} ${name}`)\n await execute(`cd ${name} && rm -rf .git`)\n console.log('Your starter kit is ready')\n}\n","import chalk from 'chalk'\nimport {getRunner, RunnerOptions} from './runner'\nimport watchAndCompile from './watchAndCompile'\n\nexport default async function (options: RunnerOptions, command: any) {\n console.log(chalk.bold(`\\nOrionjs App ${chalk.green(chalk.bold('V4'))} Dev mode \\n`))\n\n const runner = getRunner(options, command)\n\n watchAndCompile(runner)\n}\n","import chalk from 'chalk'\nimport writeFile from '../../helpers/writeFile'\nimport {startProcess} from './startProcess'\n\nexport interface RunnerOptions {\n shell: boolean\n clean: boolean\n node: boolean\n repl: boolean\n}\n\nexport interface Runner {\n start: () => void\n restart: () => void\n stop: () => void\n}\n\nexport function getRunner(options: RunnerOptions, command: any): Runner {\n let appProcess = null\n\n if (options.clean) {\n console.log(chalk.bold('=> Cleaning directory...\\n'))\n }\n\n const startApp = () => {\n appProcess = startProcess(options, command)\n\n appProcess.on('exit', (code: number, signal: string) => {\n if (!code || code === 143 || code === 0 || signal === 'SIGTERM' || signal === 'SIGINT') {\n } else {\n console.log(chalk.bold(`=> Error running app. Exit code: ${code}`))\n }\n })\n\n writeFile('.orion/process', `${appProcess.pid}`)\n }\n\n const stop = () => {\n if (appProcess) {\n appProcess.kill()\n appProcess = null\n }\n }\n\n const restart = () => {\n console.log(chalk.bold('=> Restarting app...\\n'))\n stop()\n startApp()\n }\n\n const start = () => {\n // check if the app is already running\n if (appProcess) {\n // console.log(chalk.bold('=> App is already running. Restarting...\\n'))\n } else {\n startApp()\n }\n }\n\n return {\n restart,\n stop,\n start,\n }\n}\n","import fs from 'node:fs'\nimport ensureDirectory from '../helpers/ensureDirectory'\n\nexport default async function (path: string, content: string): Promise<void> {\n ensureDirectory(path)\n fs.writeFileSync(path, content)\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nconst ensureDirectory = filePath => {\n const dirname = path.dirname(filePath)\n if (fs.existsSync(dirname)) return true\n ensureDirectory(dirname)\n fs.mkdirSync(dirname)\n}\n\nexport default ensureDirectory\n","import {spawn} from 'node:child_process'\nimport chalk from 'chalk'\nimport {getArgs} from './getArgs'\nimport {RunnerOptions} from './index'\n\nexport function startProcess(options: RunnerOptions, command: any) {\n const {startCommand, args} = getArgs(options, command)\n\n console.log(chalk.bold(`=> Starting app with command: ${startCommand} ${args.join(' ')}...\\n`))\n return spawn(startCommand, args, {\n env: {\n ORION_DEV: 'local',\n ...process.env,\n ...(options.repl ? {ORION_REPL: 'true'} : {}),\n },\n cwd: process.cwd(),\n stdio: 'inherit',\n detached: false,\n })\n}\n","import {RunnerOptions} from './index'\n\nexport function getArgs(options: RunnerOptions, command: any) {\n if (options.node) {\n const startCommand = 'tsx'\n const args = ['watch', '--clear-screen=false', ...command.args, './app/index.ts']\n return {startCommand, args}\n }\n\n const startCommand = 'bun'\n const args = ['--watch', ...command.args, './app/index.ts']\n return {startCommand, args}\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\n/**\n * Remove directory recursively\n * @param {string} dir_path\n * @see https://stackoverflow.com/a/42505874/3027390\n */\nfunction rimraf(dir_path: string) {\n if (fs.existsSync(dir_path)) {\n fs.readdirSync(dir_path).map(entry => {\n const entry_path = path.join(dir_path, entry)\n if (fs.lstatSync(entry_path).isDirectory()) {\n rimraf(entry_path)\n } else {\n fs.unlinkSync(entry_path)\n }\n })\n fs.rmdirSync(dir_path)\n }\n}\n\nexport default async function cleanDirectory(directory?: string) {\n try {\n const dirPath = directory ? directory : path.join(process.cwd(), '.orion', 'build')\n rimraf(dirPath)\n } catch (_) {\n // Ignore errors during cleanup\n }\n}\n","import {spawn} from 'node:child_process'\nimport {createInterface} from 'node:readline'\nimport type {Runner} from '../runner'\nimport {getConfigPath} from './getConfigPath'\n\nexport function getHost(runner: Runner) {\n const configPath = getConfigPath()\n const watcher = spawn('tsc', ['--watch', '--noEmit', '--project', configPath], {\n env: process.env,\n stdio: ['ignore', 'pipe', 'pipe'],\n })\n\n const output = createInterface({input: watcher.stdout})\n output.on('line', line => {\n console.log(line)\n\n if (line.includes('Starting compilation') || line.includes('File change detected')) {\n runner.stop()\n return\n }\n\n if (line.includes('Found 0 errors.')) {\n runner.start()\n return\n }\n\n if (/Found [1-9]\\d* errors?\\./.test(line)) {\n runner.stop()\n }\n })\n\n const errors = createInterface({input: watcher.stderr})\n errors.on('line', line => console.error(line))\n\n watcher.on('error', error => {\n runner.stop()\n console.error(`Unable to start TypeScript: ${error.message}`)\n })\n\n return watcher\n}\n","import {existsSync} from 'node:fs'\nimport {dirname, join} from 'node:path'\nimport {ensureConfigComplies} from './ensureConfigComplies'\n\nfunction findConfigFile(startDirectory: string, fileName: string): string | undefined {\n let directory = startDirectory\n\n while (true) {\n const candidate = join(directory, fileName)\n if (existsSync(candidate)) return candidate\n\n const parent = dirname(directory)\n if (parent === directory) return undefined\n directory = parent\n }\n}\n\nexport function getConfigPath() {\n const appBasePath = process.cwd()\n\n const configPath =\n findConfigFile(appBasePath, 'tsconfig.server.json') ||\n findConfigFile(appBasePath, 'tsconfig.json')\n\n if (!configPath) {\n throw new Error(\"Could not find a valid 'tsconfig.json'.\")\n }\n\n ensureConfigComplies(configPath)\n\n return configPath\n}\n","import {parse, stringify} from 'comment-json'\nimport getFileContents from '../../helpers/getFileContents'\nimport writeFile from '../../helpers/writeFile'\n\n// Define TypeScript config interface\ninterface TSConfig {\n compilerOptions?: {\n paths?: Record<string, string[]>\n rootDir?: string\n rootDirs?: string[]\n [key: string]: any\n }\n [key: string]: any\n}\n\nexport function ensureConfigComplies(configPath: string) {\n try {\n const configJSON = getFileContents(configPath)\n const config = parse(configJSON) as TSConfig\n const {baseUrl: _baseUrl, ...compilerOptions} = config.compilerOptions ?? {}\n\n const newConfig = {\n ...config,\n compilerOptions: {\n ...compilerOptions,\n paths: {\n '*': ['./*'],\n ...compilerOptions.paths,\n },\n noEmit: true,\n },\n }\n\n if (!config.compilerOptions?.rootDir && !config.compilerOptions?.rootDirs) {\n newConfig.compilerOptions.rootDir = './app'\n }\n\n // are the same, no write\n if (JSON.stringify(config) === JSON.stringify(newConfig)) {\n return\n }\n\n writeFile(configPath, stringify(newConfig, null, 2))\n } catch (error) {\n console.log(`Error reading tsconfig: ${error.message}`)\n }\n}\n","import fs from 'node:fs'\n\nexport default function readFile(filePath: string) {\n if (!fs.existsSync(filePath)) return null\n\n return fs.readFileSync(filePath).toString()\n}\n","import {writeDtsFileFromConfigFile} from '@orion-js/env'\nimport chalk from 'chalk'\nimport chokidar from 'chokidar'\nimport {Runner} from '../runner'\n\nconst envFilePath = process.env.ORION_ENV_FILE_PATH\nconst dtsFilePath = './app/env.d.ts'\n\nexport const watchEnvFile = async (runner: Runner) => {\n if (!envFilePath) return\n\n writeDtsFileFromConfigFile(envFilePath, dtsFilePath)\n\n chokidar.watch(envFilePath, {ignoreInitial: true}).on('change', async () => {\n console.log(chalk.bold('=> Environment file changed. Restarting...'))\n writeDtsFileFromConfigFile(envFilePath, dtsFilePath)\n runner.restart()\n })\n}\n","import {Runner} from '../runner'\nimport cleanDirectory from './cleanDirectory'\nimport {getHost} from './getHost'\nimport {watchEnvFile} from './writeEnvFile'\n\nexport default async function watchAndCompile(runner: Runner) {\n await cleanDirectory()\n getHost(runner)\n watchEnvFile(runner)\n}\n","import chalk from 'chalk'\nimport build from '../build'\nimport {runProd} from './runProd'\n\nexport interface ProdOptions {\n path?: string\n node?: boolean\n}\n\nexport default async function (options: ProdOptions, command: any) {\n console.log(chalk.bold(`\\nOrionjs App ${chalk.green(chalk.bold('V4'))} Prod mode\\n`))\n\n if (options.node) {\n if (!options.path) {\n await build({output: './build'})\n options.path = './build'\n }\n }\n\n runProd(options, command)\n}\n","import chalk from 'chalk'\nimport {build} from './build'\nimport cleanDirectory from '../dev/watchAndCompile/cleanDirectory'\nimport {checkTs} from './checkTs'\n\nexport default async function (options: {output?: string}) {\n console.log(chalk.bold(`Building Orionjs App ${chalk.green(chalk.bold('V4'))}...`))\n\n if (!options.output) {\n options.output = './build'\n }\n\n await cleanDirectory(options.output)\n\n await checkTs()\n await build(options)\n\n console.log(chalk.bold('Build completed'))\n}\n","import chalk from 'chalk'\nimport * as esbuild from 'esbuild'\n\nexport async function build(options: {output?: string}) {\n const {output} = options\n\n console.log(`Building with esbuild to ${output}`)\n\n await esbuild.build({\n entryPoints: ['./app/index.ts'],\n tsconfig: './tsconfig.json',\n format: 'esm',\n platform: 'node',\n outdir: output,\n bundle: true,\n target: 'node22',\n sourcemap: true,\n allowOverwrite: true,\n minify: true,\n packages: 'external',\n })\n\n console.log(chalk.green.bold('Build successful'))\n}\n","import chalk from 'chalk'\nimport {exec} from 'node:child_process'\nimport {promisify} from 'node:util'\n\nconst execPromise = promisify(exec)\n\nexport async function checkTs(): Promise<void> {\n try {\n console.log('Checking TypeScript...')\n await execPromise('tsc --noEmit', {\n cwd: process.cwd(),\n env: {\n ...process.env,\n },\n gid: process.getgid(),\n uid: process.getuid(),\n })\n console.log(chalk.green.bold('TypeScript check passed'))\n } catch (error) {\n console.log(chalk.red.bold('TypeScript compilation failed'))\n console.log(error.stderr || error.stdout || error.message)\n process.exit(1)\n }\n}\n","import {spawn} from 'node:child_process'\nimport {ProdOptions} from './index'\n\nexport function runProd(options: ProdOptions, command: any) {\n if (options.node) {\n const indexPath = `${options.path}/index.js`\n const args = ['--import=tsx', ...command.args, indexPath]\n spawn('node', args, {\n env: {\n NODE_ENV: 'production',\n ...process.env,\n },\n cwd: process.cwd(),\n stdio: 'inherit',\n gid: process.getgid(),\n uid: process.getuid(),\n detached: false,\n })\n return\n }\n\n const args = [...command.args, './app/index.ts']\n spawn('bun', args, {\n env: {\n NODE_ENV: 'production',\n ...process.env,\n },\n cwd: process.cwd(),\n stdio: 'inherit',\n gid: process.getgid(),\n uid: process.getuid(),\n detached: false,\n })\n}\n","import chalk from 'chalk'\n\ninterface ErrorWithCodeFrame extends Error {\n codeFrame?: string\n}\n\nprocess\n .on('unhandledRejection', (error: ErrorWithCodeFrame) => {\n if (error.codeFrame) {\n console.error(chalk.red(error.message))\n console.log(error.codeFrame)\n } else {\n console.error(chalk.red(error.message), chalk.red('Unhandled promise rejection'))\n }\n })\n .on('uncaughtException', (error: Error) => {\n console.error(chalk.red(error.message))\n process.exit(1)\n })\n","import {readFileSync} from 'node:fs'\nimport {dirname, resolve} from 'node:path'\nimport {fileURLToPath} from 'node:url'\n\nfunction getVersion(): string {\n try {\n const dir = dirname(fileURLToPath(import.meta.url))\n const pkgPath = resolve(dir, '..', 'package.json')\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))\n return pkg.version\n } catch {\n return 'unknown'\n }\n}\n\nexport default getVersion()\n","import chalk from 'chalk'\nimport {checkTs} from './checkTs'\n\nexport default async function () {\n console.log(chalk.bold(`Orionjs App ${chalk.green(chalk.bold('V4'))}\\n`))\n console.log('Checking typescript...')\n\n checkTs()\n\n console.log(chalk.bold.green('Check passed\\n'))\n}\n","import chalk from 'chalk'\nimport {execSync} from 'node:child_process'\n\nexport function checkTs() {\n try {\n execSync('tsc --noEmit', {\n cwd: process.cwd(),\n env: {\n ...process.env,\n },\n gid: process.getgid(),\n uid: process.getuid(),\n stdio: 'inherit',\n })\n } catch {\n console.log(chalk.red.bold('TypeScript compilation failed'))\n process.exit(1)\n }\n}\n","import chalk from 'chalk'\nimport {execSync} from 'node:child_process'\nimport version from './version'\n\nfunction detectRuntime(): string {\n const runtimes: string[] = []\n\n try {\n const bunVersion = execSync('bun --version', {encoding: 'utf-8'}).trim()\n runtimes.push(`Bun ${bunVersion}`)\n } catch {}\n\n runtimes.push(`Node ${process.versions.node}`)\n\n return runtimes.join(', ')\n}\n\nexport default function info() {\n console.log(`Orion CLI v${version} — Available runtimes: ${chalk.bold(detectRuntime())}`)\n console.log(`Default runtime: ${chalk.bold('Bun')} (use --node flag to switch to Node.js)`)\n}\n","import {readFileSync} from 'node:fs'\nimport {resolve} from 'node:path'\nimport chalk from 'chalk'\n\nexport interface ReplOptions {\n expression?: string\n port?: string\n}\n\ninterface ReplResponse {\n success: boolean\n error?: string\n stack?: string\n result?: unknown\n}\n\nfunction resolvePort(options: ReplOptions): number {\n if (options.port) {\n return Number(options.port)\n }\n\n try {\n const portFile = resolve(process.cwd(), '.orion/port')\n const port = readFileSync(portFile, 'utf-8').trim()\n return Number(port)\n } catch {}\n\n if (process.env.PORT) {\n return Number(process.env.PORT)\n }\n\n return 3000\n}\n\nexport default async function repl(options: ReplOptions) {\n const expression = options.expression\n\n if (!expression) {\n console.error(chalk.red('Error: expression is required. Use -e \"<expression>\"'))\n process.exit(1)\n }\n\n const port = resolvePort(options)\n\n try {\n const response = await fetch(`http://localhost:${port}/__repl`, {\n method: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify({expression}),\n })\n\n const data = (await response.json()) as ReplResponse\n\n if (!data.success) {\n console.error(chalk.red(`Error: ${data.error}`))\n if (data.stack) {\n console.error(chalk.dim(data.stack))\n }\n process.exit(1)\n }\n\n if (data.result !== undefined) {\n console.log(\n typeof data.result === 'string' ? data.result : JSON.stringify(data.result, null, 2),\n )\n }\n } catch (error) {\n const nodeError = error as Error & {code?: string; cause?: {code?: string}}\n if (nodeError.code === 'ECONNREFUSED' || nodeError.cause?.code === 'ECONNREFUSED') {\n console.error(\n chalk.red(\n `Could not connect to dev server on port ${port}. Make sure \"orion dev --repl\" is running.`,\n ),\n )\n } else {\n console.error(chalk.red(`Error: ${nodeError.message}`))\n }\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,iBAAkB;AAClB,uBAAsB;;;ACFtB,gCAAmB;AAEnB,eAAO,gBAAwB,SAAS;AACtC,SAAO,IAAI,QAAQ,CAACC,UAAS,WAAW;AACtC,wCAAK,SAAS,CAAC,OAAO,QAAQ,WAAW;AACvC,U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,UAAM,OAAO,GAAG,IAAI;AAAA,EACtB,SAAS,GAAG;AACV,YAAQ,MAAM,eAAAC,QAAM,IAAI,UAAU,EAAE,OAAO,EAAE,CAAC;AAAA,EAChD;AACF;AAEF,QACG,QAAQ,KAAK,EACb,YAAY,yCAAyC,EACrD,OAAO,UAAU,oCAAoC,EACrD,OAAO,UAAU,qCAAqC,EACtD,mBAAmB,EACnB,OAAO,IAAI,WAAG,CAAC;AAElB,QAAQ,QAAQ,OAAO,EAAE,YAAY,yBAAyB,EAAE,OAAO,IAAI,aAAK,CAAC;AAEjF,QACG,QAAQ,OAAO,EACf,YAAY,sCAAsC,EAClD,OAAO,mBAAmB,yBAAyB,EACnD,OAAO,IAAI,aAAK,CAAC;AAEpB,QACG,QAAQ,MAAM,EACd,mBAAmB,EACnB,OAAO,UAAU,oCAAoC,EACrD;AAAA,EACC;AAAA,EACA;AACF,EACC,YAAY,wCAAwC,EACpD,OAAO,IAAI,YAAI,CAAC;AAEnB,QACG,QAAQ,QAAQ,EAChB,YAAY,+BAA+B,EAC3C,OAAO,iBAAiB,qBAAqB,EAC7C,OAAO,eAAe,0BAA0B,EAChD,OAAO,IAAI,cAAM,CAAC;AAErB,QAAQ,QAAQ,MAAM,EAAE,YAAY,gCAAgC,EAAE,OAAO,IAAI,IAAI,CAAC;AAEtF,QACG,QAAQ,MAAM,EACd,YAAY,6DAA6D,EACzE,eAAe,iCAAiC,wBAAwB,EACxE,OAAO,iBAAiB,gEAAgE,EACxF,OAAO,IAAI,IAAI,CAAC;AAEnB,QAAQ,QAAQ,iBAAS,cAAc;AAEvC,QAAQ,MAAM,QAAQ,IAAI;AAE1B,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,EAAE,QAAQ;AACjC,UAAQ,WAAW;AACrB;","names":["import_chalk","resolve","import_chalk","import_chalk","import_node_fs","dirname","path","fs","path","fs","import_node_child_process","startCommand","args","chalk","chalk","import_node_fs","import_node_path","fs","path","import_node_child_process","import_node_fs","import_node_path","import_node_fs","fs","import_chalk","chokidar","chalk","chalk","import_chalk","import_chalk","import_chalk","build","chalk","import_chalk","import_node_child_process","chalk","chalk","build","import_node_child_process","args","chalk","import_chalk","chalk","import_node_fs","import_node_path","import_chalk","import_chalk","import_node_child_process","checkTs","chalk","chalk","checkTs","import_chalk","import_node_child_process","chalk","import_node_fs","import_node_path","import_chalk","chalk","chalk"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import
|
|
4
|
+
import chalk14 from "chalk";
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
|
|
7
7
|
// src/helpers/execute.ts
|
|
@@ -34,7 +34,7 @@ async function create_default({ name, kit }) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// src/dev/index.ts
|
|
37
|
-
import
|
|
37
|
+
import chalk4 from "chalk";
|
|
38
38
|
|
|
39
39
|
// src/dev/runner/index.ts
|
|
40
40
|
import chalk2 from "chalk";
|
|
@@ -46,10 +46,10 @@ import fs2 from "fs";
|
|
|
46
46
|
import fs from "fs";
|
|
47
47
|
import path from "path";
|
|
48
48
|
var ensureDirectory = (filePath) => {
|
|
49
|
-
const
|
|
50
|
-
if (fs.existsSync(
|
|
51
|
-
ensureDirectory(
|
|
52
|
-
fs.mkdirSync(
|
|
49
|
+
const dirname3 = path.dirname(filePath);
|
|
50
|
+
if (fs.existsSync(dirname3)) return true;
|
|
51
|
+
ensureDirectory(dirname3);
|
|
52
|
+
fs.mkdirSync(dirname3);
|
|
53
53
|
};
|
|
54
54
|
var ensureDirectory_default = ensureDirectory;
|
|
55
55
|
|
|
@@ -132,9 +132,6 @@ function getRunner(options, command) {
|
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
// src/dev/watchAndCompile/index.ts
|
|
136
|
-
import ts4 from "typescript";
|
|
137
|
-
|
|
138
135
|
// src/dev/watchAndCompile/cleanDirectory.ts
|
|
139
136
|
import fs3 from "fs";
|
|
140
137
|
import path2 from "path";
|
|
@@ -160,10 +157,12 @@ async function cleanDirectory(directory) {
|
|
|
160
157
|
}
|
|
161
158
|
|
|
162
159
|
// src/dev/watchAndCompile/getHost.ts
|
|
163
|
-
import
|
|
160
|
+
import { spawn as spawn2 } from "child_process";
|
|
161
|
+
import { createInterface } from "readline";
|
|
164
162
|
|
|
165
163
|
// src/dev/watchAndCompile/getConfigPath.ts
|
|
166
|
-
import
|
|
164
|
+
import { existsSync } from "fs";
|
|
165
|
+
import { dirname, join } from "path";
|
|
167
166
|
|
|
168
167
|
// src/dev/watchAndCompile/ensureConfigComplies.ts
|
|
169
168
|
import { parse, stringify } from "comment-json";
|
|
@@ -181,11 +180,15 @@ function ensureConfigComplies(configPath) {
|
|
|
181
180
|
try {
|
|
182
181
|
const configJSON = readFile(configPath);
|
|
183
182
|
const config = parse(configJSON);
|
|
183
|
+
const { baseUrl: _baseUrl, ...compilerOptions } = config.compilerOptions ?? {};
|
|
184
184
|
const newConfig = {
|
|
185
185
|
...config,
|
|
186
186
|
compilerOptions: {
|
|
187
|
-
...
|
|
188
|
-
|
|
187
|
+
...compilerOptions,
|
|
188
|
+
paths: {
|
|
189
|
+
"*": ["./*"],
|
|
190
|
+
...compilerOptions.paths
|
|
191
|
+
},
|
|
189
192
|
noEmit: true
|
|
190
193
|
}
|
|
191
194
|
};
|
|
@@ -202,9 +205,19 @@ function ensureConfigComplies(configPath) {
|
|
|
202
205
|
}
|
|
203
206
|
|
|
204
207
|
// src/dev/watchAndCompile/getConfigPath.ts
|
|
208
|
+
function findConfigFile(startDirectory, fileName) {
|
|
209
|
+
let directory = startDirectory;
|
|
210
|
+
while (true) {
|
|
211
|
+
const candidate = join(directory, fileName);
|
|
212
|
+
if (existsSync(candidate)) return candidate;
|
|
213
|
+
const parent = dirname(directory);
|
|
214
|
+
if (parent === directory) return void 0;
|
|
215
|
+
directory = parent;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
205
218
|
function getConfigPath() {
|
|
206
219
|
const appBasePath = process.cwd();
|
|
207
|
-
const configPath =
|
|
220
|
+
const configPath = findConfigFile(appBasePath, "tsconfig.server.json") || findConfigFile(appBasePath, "tsconfig.json");
|
|
208
221
|
if (!configPath) {
|
|
209
222
|
throw new Error("Could not find a valid 'tsconfig.json'.");
|
|
210
223
|
}
|
|
@@ -212,63 +225,40 @@ function getConfigPath() {
|
|
|
212
225
|
return configPath;
|
|
213
226
|
}
|
|
214
227
|
|
|
215
|
-
// src/dev/watchAndCompile/reports.ts
|
|
216
|
-
import ts2 from "typescript";
|
|
217
|
-
var format = {
|
|
218
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
219
|
-
getCurrentDirectory: () => process.cwd(),
|
|
220
|
-
getNewLine: () => ts2.sys.newLine
|
|
221
|
-
};
|
|
222
|
-
function reportDiagnostic(diagnostic) {
|
|
223
|
-
console.log(ts2.formatDiagnosticsWithColorAndContext([diagnostic], format));
|
|
224
|
-
}
|
|
225
|
-
|
|
226
228
|
// src/dev/watchAndCompile/getHost.ts
|
|
227
|
-
import chalk3 from "chalk";
|
|
228
229
|
function getHost(runner) {
|
|
229
|
-
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
230
|
+
const configPath = getConfigPath();
|
|
231
|
+
const watcher = spawn2("tsc", ["--watch", "--noEmit", "--project", configPath], {
|
|
232
|
+
env: process.env,
|
|
233
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
234
|
+
});
|
|
235
|
+
const output = createInterface({ input: watcher.stdout });
|
|
236
|
+
output.on("line", (line) => {
|
|
237
|
+
console.log(line);
|
|
238
|
+
if (line.includes("Starting compilation") || line.includes("File change detected")) {
|
|
236
239
|
runner.stop();
|
|
237
|
-
isStopped = true;
|
|
238
240
|
return;
|
|
239
241
|
}
|
|
240
|
-
if (
|
|
241
|
-
|
|
242
|
-
if (!diagnostic.messageText.toString().includes("Found 0 errors.")) {
|
|
243
|
-
runner.stop();
|
|
244
|
-
isStopped = true;
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
if (isStopped) {
|
|
249
|
-
isStopped = false;
|
|
250
|
-
runner.start();
|
|
251
|
-
}
|
|
242
|
+
if (line.includes("Found 0 errors.")) {
|
|
243
|
+
runner.start();
|
|
252
244
|
return;
|
|
253
245
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
);
|
|
266
|
-
return host;
|
|
246
|
+
if (/Found [1-9]\d* errors?\./.test(line)) {
|
|
247
|
+
runner.stop();
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
const errors = createInterface({ input: watcher.stderr });
|
|
251
|
+
errors.on("line", (line) => console.error(line));
|
|
252
|
+
watcher.on("error", (error) => {
|
|
253
|
+
runner.stop();
|
|
254
|
+
console.error(`Unable to start TypeScript: ${error.message}`);
|
|
255
|
+
});
|
|
256
|
+
return watcher;
|
|
267
257
|
}
|
|
268
258
|
|
|
269
259
|
// src/dev/watchAndCompile/writeEnvFile.ts
|
|
270
260
|
import { writeDtsFileFromConfigFile } from "@orion-js/env";
|
|
271
|
-
import
|
|
261
|
+
import chalk3 from "chalk";
|
|
272
262
|
import chokidar from "chokidar";
|
|
273
263
|
var envFilePath = process.env.ORION_ENV_FILE_PATH;
|
|
274
264
|
var dtsFilePath = "./app/env.d.ts";
|
|
@@ -276,7 +266,7 @@ var watchEnvFile = async (runner) => {
|
|
|
276
266
|
if (!envFilePath) return;
|
|
277
267
|
writeDtsFileFromConfigFile(envFilePath, dtsFilePath);
|
|
278
268
|
chokidar.watch(envFilePath, { ignoreInitial: true }).on("change", async () => {
|
|
279
|
-
console.log(
|
|
269
|
+
console.log(chalk3.bold("=> Environment file changed. Restarting..."));
|
|
280
270
|
writeDtsFileFromConfigFile(envFilePath, dtsFilePath);
|
|
281
271
|
runner.restart();
|
|
282
272
|
});
|
|
@@ -285,28 +275,27 @@ var watchEnvFile = async (runner) => {
|
|
|
285
275
|
// src/dev/watchAndCompile/index.ts
|
|
286
276
|
async function watchAndCompile(runner) {
|
|
287
277
|
await cleanDirectory();
|
|
288
|
-
|
|
289
|
-
ts4.createWatchProgram(host);
|
|
278
|
+
getHost(runner);
|
|
290
279
|
watchEnvFile(runner);
|
|
291
280
|
}
|
|
292
281
|
|
|
293
282
|
// src/dev/index.ts
|
|
294
283
|
async function dev_default(options, command) {
|
|
295
|
-
console.log(
|
|
296
|
-
Orionjs App ${
|
|
284
|
+
console.log(chalk4.bold(`
|
|
285
|
+
Orionjs App ${chalk4.green(chalk4.bold("V4"))} Dev mode
|
|
297
286
|
`));
|
|
298
287
|
const runner = getRunner(options, command);
|
|
299
288
|
watchAndCompile(runner);
|
|
300
289
|
}
|
|
301
290
|
|
|
302
291
|
// src/prod/index.ts
|
|
303
|
-
import
|
|
292
|
+
import chalk8 from "chalk";
|
|
304
293
|
|
|
305
294
|
// src/build/index.ts
|
|
306
|
-
import
|
|
295
|
+
import chalk7 from "chalk";
|
|
307
296
|
|
|
308
297
|
// src/build/build.ts
|
|
309
|
-
import
|
|
298
|
+
import chalk5 from "chalk";
|
|
310
299
|
import * as esbuild from "esbuild";
|
|
311
300
|
async function build2(options) {
|
|
312
301
|
const { output } = options;
|
|
@@ -324,11 +313,11 @@ async function build2(options) {
|
|
|
324
313
|
minify: true,
|
|
325
314
|
packages: "external"
|
|
326
315
|
});
|
|
327
|
-
console.log(
|
|
316
|
+
console.log(chalk5.green.bold("Build successful"));
|
|
328
317
|
}
|
|
329
318
|
|
|
330
319
|
// src/build/checkTs.ts
|
|
331
|
-
import
|
|
320
|
+
import chalk6 from "chalk";
|
|
332
321
|
import { exec as exec2 } from "child_process";
|
|
333
322
|
import { promisify } from "util";
|
|
334
323
|
var execPromise = promisify(exec2);
|
|
@@ -343,9 +332,9 @@ async function checkTs() {
|
|
|
343
332
|
gid: process.getgid(),
|
|
344
333
|
uid: process.getuid()
|
|
345
334
|
});
|
|
346
|
-
console.log(
|
|
335
|
+
console.log(chalk6.green.bold("TypeScript check passed"));
|
|
347
336
|
} catch (error) {
|
|
348
|
-
console.log(
|
|
337
|
+
console.log(chalk6.red.bold("TypeScript compilation failed"));
|
|
349
338
|
console.log(error.stderr || error.stdout || error.message);
|
|
350
339
|
process.exit(1);
|
|
351
340
|
}
|
|
@@ -353,23 +342,23 @@ async function checkTs() {
|
|
|
353
342
|
|
|
354
343
|
// src/build/index.ts
|
|
355
344
|
async function build_default(options) {
|
|
356
|
-
console.log(
|
|
345
|
+
console.log(chalk7.bold(`Building Orionjs App ${chalk7.green(chalk7.bold("V4"))}...`));
|
|
357
346
|
if (!options.output) {
|
|
358
347
|
options.output = "./build";
|
|
359
348
|
}
|
|
360
349
|
await cleanDirectory(options.output);
|
|
361
350
|
await checkTs();
|
|
362
351
|
await build2(options);
|
|
363
|
-
console.log(
|
|
352
|
+
console.log(chalk7.bold("Build completed"));
|
|
364
353
|
}
|
|
365
354
|
|
|
366
355
|
// src/prod/runProd.ts
|
|
367
|
-
import { spawn as
|
|
356
|
+
import { spawn as spawn3 } from "child_process";
|
|
368
357
|
function runProd(options, command) {
|
|
369
358
|
if (options.node) {
|
|
370
359
|
const indexPath = `${options.path}/index.js`;
|
|
371
360
|
const args2 = ["--import=tsx", ...command.args, indexPath];
|
|
372
|
-
|
|
361
|
+
spawn3("node", args2, {
|
|
373
362
|
env: {
|
|
374
363
|
NODE_ENV: "production",
|
|
375
364
|
...process.env
|
|
@@ -383,7 +372,7 @@ function runProd(options, command) {
|
|
|
383
372
|
return;
|
|
384
373
|
}
|
|
385
374
|
const args = [...command.args, "./app/index.ts"];
|
|
386
|
-
|
|
375
|
+
spawn3("bun", args, {
|
|
387
376
|
env: {
|
|
388
377
|
NODE_ENV: "production",
|
|
389
378
|
...process.env
|
|
@@ -398,8 +387,8 @@ function runProd(options, command) {
|
|
|
398
387
|
|
|
399
388
|
// src/prod/index.ts
|
|
400
389
|
async function prod_default(options, command) {
|
|
401
|
-
console.log(
|
|
402
|
-
Orionjs App ${
|
|
390
|
+
console.log(chalk8.bold(`
|
|
391
|
+
Orionjs App ${chalk8.green(chalk8.bold("V4"))} Prod mode
|
|
403
392
|
`));
|
|
404
393
|
if (options.node) {
|
|
405
394
|
if (!options.path) {
|
|
@@ -411,26 +400,26 @@ Orionjs App ${chalk9.green(chalk9.bold("V4"))} Prod mode
|
|
|
411
400
|
}
|
|
412
401
|
|
|
413
402
|
// src/handleErrors.ts
|
|
414
|
-
import
|
|
403
|
+
import chalk9 from "chalk";
|
|
415
404
|
process.on("unhandledRejection", (error) => {
|
|
416
405
|
if (error.codeFrame) {
|
|
417
|
-
console.error(
|
|
406
|
+
console.error(chalk9.red(error.message));
|
|
418
407
|
console.log(error.codeFrame);
|
|
419
408
|
} else {
|
|
420
|
-
console.error(
|
|
409
|
+
console.error(chalk9.red(error.message), chalk9.red("Unhandled promise rejection"));
|
|
421
410
|
}
|
|
422
411
|
}).on("uncaughtException", (error) => {
|
|
423
|
-
console.error(
|
|
412
|
+
console.error(chalk9.red(error.message));
|
|
424
413
|
process.exit(1);
|
|
425
414
|
});
|
|
426
415
|
|
|
427
416
|
// src/version.ts
|
|
428
417
|
import { readFileSync } from "fs";
|
|
429
|
-
import { dirname, resolve } from "path";
|
|
418
|
+
import { dirname as dirname2, resolve } from "path";
|
|
430
419
|
import { fileURLToPath } from "url";
|
|
431
420
|
function getVersion() {
|
|
432
421
|
try {
|
|
433
|
-
const dir =
|
|
422
|
+
const dir = dirname2(fileURLToPath(import.meta.url));
|
|
434
423
|
const pkgPath = resolve(dir, "..", "package.json");
|
|
435
424
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
436
425
|
return pkg.version;
|
|
@@ -444,10 +433,10 @@ var version_default = getVersion();
|
|
|
444
433
|
import "dotenv/config";
|
|
445
434
|
|
|
446
435
|
// src/check/index.ts
|
|
447
|
-
import
|
|
436
|
+
import chalk11 from "chalk";
|
|
448
437
|
|
|
449
438
|
// src/check/checkTs.ts
|
|
450
|
-
import
|
|
439
|
+
import chalk10 from "chalk";
|
|
451
440
|
import { execSync } from "child_process";
|
|
452
441
|
function checkTs2() {
|
|
453
442
|
try {
|
|
@@ -461,22 +450,22 @@ function checkTs2() {
|
|
|
461
450
|
stdio: "inherit"
|
|
462
451
|
});
|
|
463
452
|
} catch {
|
|
464
|
-
console.log(
|
|
453
|
+
console.log(chalk10.red.bold("TypeScript compilation failed"));
|
|
465
454
|
process.exit(1);
|
|
466
455
|
}
|
|
467
456
|
}
|
|
468
457
|
|
|
469
458
|
// src/check/index.ts
|
|
470
459
|
async function check_default() {
|
|
471
|
-
console.log(
|
|
460
|
+
console.log(chalk11.bold(`Orionjs App ${chalk11.green(chalk11.bold("V4"))}
|
|
472
461
|
`));
|
|
473
462
|
console.log("Checking typescript...");
|
|
474
463
|
checkTs2();
|
|
475
|
-
console.log(
|
|
464
|
+
console.log(chalk11.bold.green("Check passed\n"));
|
|
476
465
|
}
|
|
477
466
|
|
|
478
467
|
// src/info.ts
|
|
479
|
-
import
|
|
468
|
+
import chalk12 from "chalk";
|
|
480
469
|
import { execSync as execSync2 } from "child_process";
|
|
481
470
|
function detectRuntime() {
|
|
482
471
|
const runtimes = [];
|
|
@@ -489,14 +478,14 @@ function detectRuntime() {
|
|
|
489
478
|
return runtimes.join(", ");
|
|
490
479
|
}
|
|
491
480
|
function info() {
|
|
492
|
-
console.log(`Orion CLI v${version_default} \u2014 Available runtimes: ${
|
|
493
|
-
console.log(`Default runtime: ${
|
|
481
|
+
console.log(`Orion CLI v${version_default} \u2014 Available runtimes: ${chalk12.bold(detectRuntime())}`);
|
|
482
|
+
console.log(`Default runtime: ${chalk12.bold("Bun")} (use --node flag to switch to Node.js)`);
|
|
494
483
|
}
|
|
495
484
|
|
|
496
485
|
// src/repl/index.ts
|
|
497
486
|
import { readFileSync as readFileSync2 } from "fs";
|
|
498
487
|
import { resolve as resolve2 } from "path";
|
|
499
|
-
import
|
|
488
|
+
import chalk13 from "chalk";
|
|
500
489
|
function resolvePort(options) {
|
|
501
490
|
if (options.port) {
|
|
502
491
|
return Number(options.port);
|
|
@@ -516,7 +505,7 @@ async function repl(options) {
|
|
|
516
505
|
var _a;
|
|
517
506
|
const expression = options.expression;
|
|
518
507
|
if (!expression) {
|
|
519
|
-
console.error(
|
|
508
|
+
console.error(chalk13.red('Error: expression is required. Use -e "<expression>"'));
|
|
520
509
|
process.exit(1);
|
|
521
510
|
}
|
|
522
511
|
const port = resolvePort(options);
|
|
@@ -528,9 +517,9 @@ async function repl(options) {
|
|
|
528
517
|
});
|
|
529
518
|
const data = await response.json();
|
|
530
519
|
if (!data.success) {
|
|
531
|
-
console.error(
|
|
520
|
+
console.error(chalk13.red(`Error: ${data.error}`));
|
|
532
521
|
if (data.stack) {
|
|
533
|
-
console.error(
|
|
522
|
+
console.error(chalk13.dim(data.stack));
|
|
534
523
|
}
|
|
535
524
|
process.exit(1);
|
|
536
525
|
}
|
|
@@ -540,14 +529,15 @@ async function repl(options) {
|
|
|
540
529
|
);
|
|
541
530
|
}
|
|
542
531
|
} catch (error) {
|
|
543
|
-
|
|
532
|
+
const nodeError = error;
|
|
533
|
+
if (nodeError.code === "ECONNREFUSED" || ((_a = nodeError.cause) == null ? void 0 : _a.code) === "ECONNREFUSED") {
|
|
544
534
|
console.error(
|
|
545
|
-
|
|
535
|
+
chalk13.red(
|
|
546
536
|
`Could not connect to dev server on port ${port}. Make sure "orion dev --repl" is running.`
|
|
547
537
|
)
|
|
548
538
|
);
|
|
549
539
|
} else {
|
|
550
|
-
console.error(
|
|
540
|
+
console.error(chalk13.red(`Error: ${nodeError.message}`));
|
|
551
541
|
}
|
|
552
542
|
process.exit(1);
|
|
553
543
|
}
|
|
@@ -559,7 +549,7 @@ var run = (action) => async (...args) => {
|
|
|
559
549
|
try {
|
|
560
550
|
await action(...args);
|
|
561
551
|
} catch (e) {
|
|
562
|
-
console.error(
|
|
552
|
+
console.error(chalk14.red(`Error: ${e.message}`));
|
|
563
553
|
}
|
|
564
554
|
};
|
|
565
555
|
program.command("dev").description("Run the Orionjs app in development mode").option("--node", "Use Node.js runtime instead of Bun").option("--repl", "Enable REPL endpoint for orion repl").allowUnknownOption().action(run(dev_default));
|