/** * CLI entry point for Stack.Gallery Registry */ import * as plugins from './plugins.ts'; import { StackGalleryRegistry, createRegistryFromEnv, createRegistryFromEnvFile } from './registry.ts'; import { initDb } from './models/db.ts'; import { User, Organization, OrganizationMember, Repository } from './models/index.ts'; import { AuthService } from './services/auth.service.ts'; export async function runCli(): Promise { const smartcliInstance = new plugins.smartcli.Smartcli(); // Server command smartcliInstance.addCommand('server').subscribe(async (argsParsed) => { const isEphemeral = argsParsed.ephemeral || argsParsed.e; console.log('Starting Stack.Gallery Registry...'); if (isEphemeral) { console.log('[CLI] Ephemeral mode enabled - loading config from .nogit/env.json'); } // Use env file in ephemeral/dev mode, otherwise use environment variables const registry = isEphemeral ? await createRegistryFromEnvFile() : createRegistryFromEnv(); await registry.start(); // Handle shutdown gracefully const shutdown = async () => { console.log('\nShutting down...'); await registry.stop(); Deno.exit(0); }; Deno.addSignalListener('SIGINT', shutdown); Deno.addSignalListener('SIGTERM', shutdown); }); // Status command smartcliInstance.addCommand('status').subscribe(async () => { console.log('Stack.Gallery Registry Status'); console.log('============================='); // TODO: Implement status check console.log('Status check not yet implemented'); }); // User commands smartcliInstance.addCommand('user').subscribe(async (argsParsed) => { const subCommand = argsParsed.commandArgs[0]; switch (subCommand) { case 'create': console.log('Creating user...'); // TODO: Implement user creation break; case 'list': console.log('Listing users...'); // TODO: Implement user listing break; default: console.log('Usage: user [create|list]'); } }); // Organization commands smartcliInstance.addCommand('org').subscribe(async (argsParsed) => { const subCommand = argsParsed.commandArgs[0]; switch (subCommand) { case 'create': console.log('Creating organization...'); // TODO: Implement org creation break; case 'list': console.log('Listing organizations...'); // TODO: Implement org listing break; default: console.log('Usage: org [create|list]'); } }); // Default/help command smartcliInstance.addCommand('help').subscribe(() => { console.log(` Stack.Gallery Registry - Enterprise Package Registry Usage: registry [options] Commands: server [--ephemeral] [--monitor] Start the registry server status Check registry status user User management org Organization management help Show this help message Options: --ephemeral Run in ephemeral mode (in-memory database) --monitor Enable performance monitoring Environment Variables: MONGODB_URL MongoDB connection string S3_ENDPOINT S3-compatible storage endpoint S3_ACCESS_KEY S3 access key S3_SECRET_KEY S3 secret key S3_BUCKET S3 bucket name JWT_SECRET JWT signing secret PORT HTTP server port (default: 3000) `); }); // Parse CLI arguments smartcliInstance.startParse(); }