UNPKG

@webda/shell

Version:

Deploy a Webda app or configure it

265 lines (264 loc) 7.28 kB
import { CancelablePromise, Logger, PackageDescriptorAuthor } from "@webda/core"; import { WorkerLogLevel, WorkerOutput } from "@webda/workout"; import { ChildProcess } from "child_process"; import { JSONSchema7 } from "json-schema"; import yargs from "yargs"; import { SourceApplication } from "../code/sourceapplication.js"; import { WebdaServer } from "../handlers/http.js"; import { WebdaTerminal } from "./terminal.js"; export type WebdaCommand = (argv: any[]) => void; export interface WebdaShellExtension { require: string; export?: string; description: string; terminal?: string; command?: string; yargs?: any; relPath?: string; } export interface ApplicationExportFormat { application: { name: string; version: string; author?: PackageDescriptorAuthor; }; } /** * Webda Cache file description */ export interface WebdaCache { /** * Digest of source code to know if compilation is needed */ digest?: string; } export interface OperationsExportFormat extends ApplicationExportFormat { operations: { [key: string]: { input?: string; output?: string; permission?: string; id: string; }; }; schemas: { [key: string]: JSONSchema7; }; } export interface ModelsExportFormat extends ApplicationExportFormat { models: { [key: string]: JSONSchema7; }; } export declare enum DebuggerStatus { Stopped = "STOPPED", Stopping = "STOPPING", Compiling = "COMPILING", Launching = "LAUNCHING", Serving = "SERVING" } export default class WebdaConsole { static webda: WebdaServer; static serverProcess: ChildProcess; static tscCompiler: ChildProcess; static logger: Logger; static terminal: WebdaTerminal; static app: SourceApplication; static debuggerStatus: DebuggerStatus; static onSIGINT: () => never; static extensions: { [key: string]: WebdaShellExtension; }; static parser(_args: any): Promise<yargs.Argv>; static serve(argv: any): CancelablePromise; /** * Get a service configuration * * @param argv */ static serviceConfig(argv: any): Promise<number>; static getApplicationExport(): { application: { name: string; version: string; author: PackageDescriptorAuthor; }; }; /** * * @param argv */ static models(argv: yargs.Arguments): Promise<void>; /** * * @param argv */ static operations(argv: yargs.Arguments): Promise<void>; /** * Run a method of a service * * @param argv */ static worker(argv: yargs.Arguments): Promise<void | -1>; /** * Launch debug on application * * Compiling application as it is modified * Relaunching the serve command on any new modification * * @param argv */ static debug(argv: yargs.Arguments): Promise<void>; /** * Watch for configuration changes * * @param callback * @param deployment */ static configurationWatch(callback: any, deployment?: string): void; /** * Get shell package version */ static getVersion(): any; /** * Add a system to recompile if needed * @returns */ static requireCompilation(): boolean; /** * If deployment in argument: display or export the configuration * Otherwise launch the configuration UI * * @param argv */ static config(argv: yargs.Arguments): Promise<number>; /** * If deployment in argument: display or export the configuration * Otherwise launch the configuration UI * * @param argv */ static configEncrypt(argv: yargs.Arguments): Promise<number>; /** * Rotate crypto keys */ static rotateKeys(): Promise<number>; /** * Deploy the new code * @param argv */ static deploy(argv: yargs.Arguments): Promise<number>; /*** * Get yeoman */ static getYeoman(): Promise<any>; /** * Generate a new Webda Application based on yeoman * * @param argv * @param generatorName */ static init(argv: yargs.Arguments, generatorName?: string): Promise<any>; /** * Init loggers * @param argv */ static initLogger(argv: yargs.Arguments): Promise<void>; /** * Main command switch * * Parse arguments * Init logger * Create Webda Application * Run the command or display help * * @param args */ static handleCommand(args: any, versions: any, output?: WorkerOutput): Promise<number>; static loadExtensions(appPath: any): number; /** * Generate a JSON Schema for a symbol */ static schema(argv: yargs.Arguments): Promise<void>; /** * Print a Fake Terminal to play with @webda/workout * * This is a non-supported method therefore no specific unit test * as there is no value in it */ static fakeTerm(): Promise<void>; /** * Generate the webda.module.json */ static build(argv: any): Promise<void | -1>; /** * Generate a diagram for the application * @param argv * @returns */ static diagram(argv: any): Promise<0 | -1>; /** * Return the default builin command map */ static builtinCommands(): { [name: string]: { command?: string; handler: Function; description: string; module?: any; }; }; /** * Output all types of Deployers, Services and Models */ static types(): Promise<void>; /** * Return if a package is within minor version of each others * @param package1 * @param package2 */ static withinMinorVersion(package1: string, package2: string): boolean; static handleCommandInternal(args: any, versions: any, output?: WorkerOutput): Promise<number>; /** * Display help for parser * * Separated into a method to allow override * @param parser */ static displayHelp(parser: any): void; /** * * @param ext extension to execute * @param relPath relative path of the extension * @param argv arguments passed to the shell */ static executeShellExtension(ext: WebdaShellExtension, relPath: string, argv: any): Promise<any>; /** * Display stores and their managed models */ static stores(): Promise<number>; /** * Manage store * @param argv */ static store(argv: yargs.Arguments): Promise<number>; /** * Generate the OpenAPI definition in a file * * If filename can end with .yml or .json to select the format * @param argv */ static generateOpenAPI(argv: yargs.Arguments): Promise<void>; /** * Stop the debugger and wait for its complete stop */ static stopDebugger(): Promise<void>; /** * Get debugger current status */ static getDebuggerStatus(): DebuggerStatus; static setDebuggerStatus(status: DebuggerStatus): void; static output(...args: any[]): void; static log(level: WorkerLogLevel, ...args: any[]): void; } export { WebdaConsole };