UNPKG

mega-pkg

Version:

> This readme is written by the author of this package [amanuel](https://github.com/amanuel15)

99 lines (88 loc) 2.23 kB
"use strict"; const figlet = require("figlet"); const chalkAnimation = require("chalk-animation"); const chalk = require("chalk"); const flags = require("./flags"); const inquire = require("./src/inquire"); const createApp = require("./src/create_app"); const gradient = require("gradient-string"); const clear = require("clear"); const { installPkg, removePkg, startApp, bundleApp, debug, } = require("./src/command_handler"); const medaLogo = require("./meda_logo"); const App = (args, flag) => { // console.log("Inputs: ", args); if (!Object.keys(flags).includes(args[0]) && args.length > 0) { console.log("Unknow command: ", chalk.red(args[0])); console.log( "To see a list of supported npm commands,\nrun:", chalk.yellow("mega-pkg"), "--help" ); return; } if (args.length == 0 || args[0] == "create_app" || args[0] == "c") { clear(); // console.log( // gradient("red", "orange", "yellow", "green").multiline( // figlet.textSync("Mega cli", { // // font: "Ghost", // horizontalLayout: "full", // verticalLayout: "default", // width: 80, // whitespaceBreak: true, // }) // ) // ); medaLogo(); createApp(); return; } // console.log( // gradient("red", "orange", "yellow", "green").multiline( // figlet.textSync("Mega cli", { // // font: "Ghost", // horizontalLayout: "full", // verticalLayout: "default", // width: 80, // whitespaceBreak: true, // }) // ) // ); medaLogo(); if (args[0] == "pkg" && args.length > 1) { installPkg(args.slice(1).reduce((ac, cur) => ac + " " + cur)); return; } if (args[0] == "unpkg" && args.length > 1) { removePkg(args.slice(1).reduce((ac, cur) => ac + " " + cur)); return; } if (args[0] == "start" && args.length == 1) { console.log("Starting the miniapp..."); startApp(); return; } if (args[0] == "bundle" && args.length == 1) { console.log("\tStarting the bundling process\n"); bundleApp(); return; } if (args[0] == "debug") { console.log( gradient("red", "orange", "yellow", "green").multiline( figlet.textSync("Mega Debbuger", { // horizontalLayout: "full", }) ) ); debug(); return; } }; module.exports = App;