feat(cli): add initial CLI implementation with argument parsing and prompt handling
- Created package.json and package-lock.json for CLI package. - Implemented argument parsing in args.ts to handle various flags and commands. - Developed main CLI logic in cli.ts to execute commands and handle errors. - Added configuration loading from a JSON file in config.ts, with environment variable support. - Implemented prompt resolution and provider interaction in prompt.ts. - Added usage documentation for the CLI. - Configured TypeScript settings in tsconfig.json for the CLI package. - Updated README in vscode package to reflect the new CLI functionality. - Refactored root tsconfig.json to streamline project structure.
This commit is contained in:
35
packages/cli/esbuild.mjs
Normal file
35
packages/cli/esbuild.mjs
Normal file
@@ -0,0 +1,35 @@
|
||||
import * as esbuild from 'esbuild';
|
||||
import { resolve, dirname } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const watch = process.argv.includes('--watch');
|
||||
const libRoot = resolve(__dirname, '../../src/lib');
|
||||
|
||||
/** @type {import('esbuild').BuildOptions} */
|
||||
const options = {
|
||||
entryPoints: [resolve(__dirname, 'src/cli.ts')],
|
||||
bundle: true,
|
||||
outfile: resolve(__dirname, 'out/cli.js'),
|
||||
format: 'esm',
|
||||
platform: 'node',
|
||||
target: 'node22',
|
||||
sourcemap: true,
|
||||
sourcesContent: false,
|
||||
logLevel: 'info',
|
||||
banner: {
|
||||
js: '#!/usr/bin/env node',
|
||||
},
|
||||
alias: {
|
||||
'@lib': libRoot,
|
||||
},
|
||||
};
|
||||
|
||||
if (watch) {
|
||||
const ctx = await esbuild.context(options);
|
||||
await ctx.watch();
|
||||
console.log('[lexai-cli] watching…');
|
||||
} else {
|
||||
await esbuild.build(options);
|
||||
console.log('[lexai-cli] compiled → out/cli.js');
|
||||
}
|
||||
Reference in New Issue
Block a user