UNPKG

masson

Version:

Module execution engine for cluster deployments.

82 lines (80 loc) 2.22 kB
// Generated by CoffeeScript 2.7.0 import { shell } from "shell"; import params from "masson/params"; import load from "masson/config/load"; import normalize from "masson/config/normalize"; import store from "masson/config/store"; import { merge, mutate } from "mixme"; export default async function (processOrArgv, shellConfig={}) { var i, len, ref; if (!processOrArgv) { throw Error("Required Argument: process or arguments is not provided"); } // Parse the first part of the arguments, without the user command const orgparams = shell( merge( params, { main: { name: "main", }, }, shellConfig ) ).parse(processOrArgv); // Read configuration // Normalize configuration const config = await load(orgparams.config).then((config) => normalize(config)); // Normalize configuration // config = await normalize(config); // Enrich configuration with command discovery const commands = {}; ref = store(config).commands(); for (i = 0, len = ref.length; i < len; i++) { const command = ref[i]; commands[command] = { description: `Run the ${command} command on the clusters`, route: "masson/lib/commands/clusters", options: { cluster: { shortcut: "c", type: "array", description: "Limit to a list of clusters", }, nodes: { shortcut: "n", type: "array", description: "Limit to a list of server FQDNs", }, tags: { shortcut: "t", type: "array", description: "Limit to servers that honor a list of tags", }, modules: { shortcut: "m", type: "array", description: "Limit to a list of modules", }, resume: { shortcut: "r", type: "boolean", description: "Resume from previous run", // Merge default shell with discovered shell and user shell }, }, }; } mutate( params, shellConfig, { commands: { clusters: { commands: commands, }, }, }, config.params ); return await shell(params).route(processOrArgv, config); }