feat: custom .env
This commit is contained in:
parent
7315233c34
commit
6568b87786
|
|
@ -12,10 +12,9 @@ const colors = {
|
|||
};
|
||||
|
||||
// Load .env file if it exists
|
||||
function loadEnvFile() {
|
||||
const envPath = '.env';
|
||||
function loadEnvFile(envPath: string = '.env') {
|
||||
if (existsSync(envPath)) {
|
||||
console.log(`${colors.blue}📄 Loading .env file...${colors.reset}`);
|
||||
console.log(`${colors.blue}📄 Loading .env file from: ${envPath}${colors.reset}`);
|
||||
const envContent = readFileSync(envPath, 'utf-8');
|
||||
const lines = envContent.split('\n');
|
||||
|
||||
|
|
@ -35,6 +34,10 @@ function loadEnvFile() {
|
|||
}
|
||||
}
|
||||
console.log(`${colors.green}✅ Environment variables loaded${colors.reset}`);
|
||||
} else if (envPath !== '.env') {
|
||||
// Only error if a custom path was specified but not found
|
||||
console.error(`${colors.red}❌ .env file not found at: ${envPath}${colors.reset}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -63,13 +66,13 @@ function isPortInUse(port: number): boolean {
|
|||
}
|
||||
|
||||
// Dev command - Start complete development environment
|
||||
export async function runDevCommand(cliDir: string) {
|
||||
export async function runDevCommand(cliDir: string, envPath?: string) {
|
||||
console.log(`${colors.blue}════════════════════════════════════════════════════════${colors.reset}`);
|
||||
console.log(`${colors.blue} Natural Language Agreement Oracle - Quick Setup${colors.reset}`);
|
||||
console.log(`${colors.blue}════════════════════════════════════════════════════════${colors.reset}\n`);
|
||||
|
||||
// Load .env file first
|
||||
loadEnvFile();
|
||||
loadEnvFile(envPath);
|
||||
console.log('');
|
||||
|
||||
// Check prerequisites
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ Options (vary by command):
|
|||
--arbitration-provider <name> Arbitration provider (create, default: OpenAI)
|
||||
--arbitration-model <model> Arbitration model (create, default: gpt-4o-mini)
|
||||
--arbitration-prompt <text> Custom arbitration prompt (create, optional)
|
||||
--env <file> Path to .env file (dev, default: .env)
|
||||
|
||||
Environment Variables:
|
||||
PRIVATE_KEY Private key for transactions
|
||||
|
|
@ -58,6 +59,9 @@ Examples:
|
|||
# Start development environment
|
||||
nla dev
|
||||
|
||||
# Start development with custom .env file
|
||||
nla dev --env /path/to/.env.production
|
||||
|
||||
# Deploy contracts
|
||||
nla deploy
|
||||
|
||||
|
|
@ -122,6 +126,7 @@ function parseCliArgs() {
|
|||
"arbitration-provider": { type: "string" },
|
||||
"arbitration-model": { type: "string" },
|
||||
"arbitration-prompt": { type: "string" },
|
||||
"env": { type: "string" },
|
||||
},
|
||||
strict: true,
|
||||
});
|
||||
|
|
@ -150,7 +155,7 @@ async function main() {
|
|||
|
||||
// Handle dev and stop commands
|
||||
if (command === "dev") {
|
||||
await runDevCommand(__dirname);
|
||||
await runDevCommand(__dirname, args.env as string | undefined);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue