UNPKG

frontity

Version:

Frontity cli and entry point to other packages

98 lines (97 loc) 4.92 kB
#! /usr/bin/env node "use strict"; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); require("./dotenv"); const commander_1 = __importDefault(require("commander")); const create_1 = __importDefault(require("./create")); const create_package_1 = __importDefault(require("./create-package")); const dev_1 = __importDefault(require("./dev")); const build_1 = __importDefault(require("./build")); const serve_1 = __importDefault(require("./serve")); const subscribe_1 = __importDefault(require("./subscribe")); const unknown_1 = __importDefault(require("./unknown")); const info_1 = __importDefault(require("./info")); const package_json_1 = __importDefault(require("../../package.json")); // Sets the version and the description of the program. commander_1.default .version(package_json_1.default.version, "-v, --version") .usage("<command> [options]") .description("Frontity CLI"); // Registers a `create` command that takes an optional // parameter called `name`. It also accepts the following // options: --typescript, --use-cwd. commander_1.default .command("create [name]") .option("--theme <theme>", "The theme to use") .option("--typescript", "Adds support for TypeScript") .option("--no-git", "Skips creating a git repository for a new project.") .option("--use-cwd", "Generates the project in the current directory.") .option("--no-prompt", "Skips prompting the user for options") .description("Creates a new Frontity project.") .action((name, _a) => { var args = __rest(_a, []); return (0, create_1.default)(Object.assign({ name }, args)); }); commander_1.default .command("create-package [name]") .option("--namespace <value>", "Sets the namespace for this package") .option("--no-prompt", "Skips prompting the user for options") .description("Creates a new Frontity package in a project.") .action((name, _a) => { var args = __rest(_a, []); return (0, create_package_1.default)(Object.assign({ name }, args)); }); commander_1.default .command("dev") .option("--prod, --production", "Builds the project for production.") .option("--port <port>", "Runs the server on a custom port. Default is 3000.") .option("--https", "Runs the server using https.") .option("--dont-open-browser", "Don't open a browser window with the localhost.") .option("--target <target>", 'create bundles with "es5" or "module". Default target is "module".') .option("--publicPath <path>", "DEPRECATED, use --public-path instead.") .option("--public-path <path>", 'set the public path for static assets. Default path is "/static/".') .option("--analyze", 'Create HTML files for bundle analyzing, available at "/build/analyze/"') .description("Starts a server in development mode.") .action(dev_1.default); commander_1.default .command("build") .option("--dev, --development", "Builds the project for development.") .option("--target <target>", 'create bundles with "es5", "module" or "both". Default target is "both".') .option("--publicPath <path>", "DEPRECATED, use --public-path instead.") .option("--public-path <path>", 'set the public path for static assets. Default path is "/static/".') .option("--analyze", 'Create HTML files for bundle analyzing, available at "/build/analyze/"') .description("Builds the project for production.") .action(build_1.default); commander_1.default .command("serve") .option("--port <port>", "Runs the server on a custom port. Default is 3000.") .option("--https", "Runs the server using https.") .description("Starts a server in production mode.") .action(serve_1.default); commander_1.default .command("subscribe [email]") .description("Subscribe to Frontity newsletter.") .action((email) => (0, subscribe_1.default)({ email })); commander_1.default .command("info") .description("Get environment information for debugging and issue reporting.") .action(info_1.default); commander_1.default.on("command:*", ([command]) => (0, unknown_1.default)(command, commander_1.default)); // Parses the arguments and adds them to the `command` object. commander_1.default.parse(process.argv); if (commander_1.default.rawArgs.length < 3) commander_1.default.help();