UNPKG

@capawesome/cli

Version:

The Capawesome Cloud Command Line Interface (CLI) to manage Live Updates and more.

52 lines (51 loc) 2.25 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const citty_1 = require("citty"); const consola_1 = __importDefault(require("consola")); const file_1 = require("../../utils/file"); const manifest_1 = require("../../utils/manifest"); const prompt_1 = require("../../utils/prompt"); exports.default = (0, citty_1.defineCommand)({ meta: { description: 'Generate a manifest file.', }, args: { path: { type: 'string', description: 'Path to the web assets folder (e.g. `www` or `dist`).', }, }, run: (ctx) => __awaiter(void 0, void 0, void 0, function* () { let path = ctx.args.path; if (!path) { path = yield (0, prompt_1.prompt)('Enter the path to the web assets folder:', { type: 'text', }); if (!path) { consola_1.default.error('You must provide a path to the web assets folder.'); process.exit(1); } } // Check if the path exists const pathExists = yield (0, file_1.fileExistsAtPath)(path); if (!pathExists) { consola_1.default.error(`The path does not exist.`); process.exit(1); } // Generate the manifest file yield (0, manifest_1.generateManifestJson)(path); consola_1.default.success('Manifest file generated.'); }), });