UNPKG

@mornya/vessel

Version:

Creates/publishes a Node.js module with no build configuration.

1 lines 3.64 kB
var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},i=(Object.defineProperty(exports,"__esModule",{value:!0}),exports.initializeCommander=function initializeCommander(){try{o.program.command("build").alias("b").description("Builds application in production mode").action(function(e){return launchAction("build",e)}).helpOption("-h, --help","Display help for command action").option("-w, --watch","Enables watch mode",!1).option("-e --esm","Builds with ESM module",!1).addHelpText("beforeAll",commonHelpText),o.program.command("check").alias("k").description("Checks if there are any errors in the source code using the TypeScript compiler").action(function(e){return launchAction("check",e)}).helpOption("-h, --help","Display help for command action").option("-D, --diagnostics","Checks with diagnostics",!1).addHelpText("beforeAll",commonHelpText),o.program.command("clean").alias("c").description("Clean your build directory").argument("[dirs...]","Directories to remove directly").action(function(e){return launchAction("clean",e)}).helpOption("-h, --help","Display help for command action").option("-d, --debug","Enables debug mode",!1).addHelpText("beforeAll",commonHelpText),o.program.command("init").description("Initialize your application with library template").action(function(e){a.CLI.displayTitle(),launchAction("init",e)}).helpOption("-h, --help","Display help for command action").option("-n, --name <value>","Specifies application (package.json) name","").option("-D, --desc <value>","Specifies application (package.json) description","").addHelpText("beforeAll",commonHelpText),o.program.command("login").alias("l").description("Login NPM for publish your library").action(function(e){return launchAction("login",e)}).helpOption("-h, --help","Display help for command action").addHelpText("beforeAll",commonHelpText),o.program.command("prepublish").alias("pp").description("Actions for before publish your library").action(function(e){return launchAction("prepublish",e)}).helpOption("-h, --help","Display help for command action").addHelpText("beforeAll",commonHelpText),o.program.version(a.CLI.ownPackageJson.version,"-v, --version","Prints vessel version").usage("<action> [options]").helpCommand("help [command]","Display help for command action").helpOption("-h, --help","Display help for command action").addHelpText("beforeAll",commonHelpText).configureOutput({writeOut:function(e){e=e.replace(/\n/g,"\n ").replace("Usage:",n.chalk.magenta("Usage:")).replace("Options:",n.chalk.magenta("Options »")).replace("Commands:",n.chalk.magenta("Available action »")).replace(/\|/g,n.chalk.gray("|"));n.Log.out(" ".concat(e))},writeErr:function(e){var e=e.match(/['"`]([^'"`]*)['"`]/);e&&(n.Log.bad('Invalid command line action "'.concat(null!=(e=e[1])?e:"",'"')),n.Log.linefeed()),o.program.help()}}).parse(process.argv)}catch(e){console.error(e)}},e(require("path"))),n=require("@mornya/cli-libs"),o=require("commander"),a=require("./cli"),t=require("./paths");function commonHelpText(){return a.CLI.displayTitle(),""}function launchAction(e,o){"init"===e||n.Files.isExist(t.paths.appPackageJson)?["clean","start"].includes(e)||n.Upgrade.checkLazyEmitBeforeExit("@mornya/vessel",a.CLI.ownPackageJson.version,{install:"none-global"}):(n.Log.linefeed(),n.Log.info(["No package.json file found.","If not initialized project yet, please run below first!","",n.chalk.magenta("$ npm init && vessel init")]),n.Log.linefeed(),process.exit(1));e=require(i.default.resolve(__dirname,"..","dist","scripts",e)).default;e&&!1===new e(o,process.argv.slice(3).filter(Boolean)).run()&&process.exit(1)}