UNPKG

@happy-coders/fun-cli

Version:

Be your project management more fun!

88 lines (87 loc) 5.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DELETE_FAIL_JOKE = exports.ADD_PROJECT_HELP = exports.PROJECT_DETAILS_HELP = exports.RUN_COMMAND_HELP = exports.LIST_PROJECTS_HELP = exports.NOT_CONFIRMED_DELETION = exports.PROJECT_DELETED_WITH_SUCCESS = exports.LIST_PROJECTS = exports.TASK_EXECUTION_FAILED = exports.TASK_EXECUTED_WITH_SUCCESS = exports.TASK_EXECUTION_STARTED = exports.WITH_ACTION_DONE = exports.WITH_ACTION_STARTED = exports.ADD_ACTION_SUCCESS = exports.UNEXPECTED_ERROR = exports.EMPTY_PROJECTS = exports.PROJECT_ALREADY_EXISTS = exports.PROJECT_NOT_FOUND = void 0; var tslib_1 = require("tslib"); var chalk_1 = tslib_1.__importDefault(require("chalk")); var node_emoji_1 = tslib_1.__importDefault(require("node-emoji")); var prefixes_1 = require("./prefixes"); var mountEmojiPrefixedMessage = function (emojiName, message, options) { return mountPrefixedMessage(node_emoji_1.default.get(emojiName), message, options); }; var mountSuccessPrefixedMessage = function (message) { return mountEmojiPrefixedMessage('tada', message); }; var mountErrorPrefixedMessage = function (message) { return mountPrefixedMessage(prefixes_1.ERROR_PREFIX, message); }; var mountPrefixedMessage = function (prefix, message, options) { var _a = (options !== null && options !== void 0 ? options : {}).startWithNewLine, startWithNewLine = _a === void 0 ? true : _a; return "" + (startWithNewLine ? '\n' : '') + prefix + " " + message + "\n"; }; // Errors exports.PROJECT_NOT_FOUND = function (projectAlias) { return mountErrorPrefixedMessage("Not found a project with alias: " + chalk_1.default.red(projectAlias)); }; exports.PROJECT_ALREADY_EXISTS = function (projectAlias) { return mountErrorPrefixedMessage("Already exists a project with alias \"" + chalk_1.default.yellow(projectAlias) + "\""); }; exports.EMPTY_PROJECTS = mountEmojiPrefixedMessage('disappointed', "No fun projects found! " + node_emoji_1.default.get('face_palm')); exports.UNEXPECTED_ERROR = mountEmojiPrefixedMessage('disappointed_relieved', "Whoops, something went wrong! It's not fun..."); // Actions // Add action exports.ADD_ACTION_SUCCESS = function (project) { return mountSuccessPrefixedMessage("Wow! Your project \"" + chalk_1.default.yellow(project.getAlias()) + "\" has been created with success!"); }; // With action exports.WITH_ACTION_STARTED = "\nRunning your funny project tasks...\n"; exports.WITH_ACTION_DONE = function (project) { return mountSuccessPrefixedMessage("All tasks for " + chalk_1.default.yellow(project.getAlias()) + " has been executed!"); }; // Task execution exports.TASK_EXECUTION_STARTED = function (task) { return TASK_EXECUTION_STATUS_CHANGED(task, 'Executing...', { endOfLine: '\r', }); }; exports.TASK_EXECUTED_WITH_SUCCESS = function (task) { return TASK_EXECUTION_STATUS_CHANGED(task, prefixes_1.SUCCESS_PREFIX, { amountOfWhitespaces: 5, }); }; exports.TASK_EXECUTION_FAILED = function (task) { return TASK_EXECUTION_STATUS_CHANGED(task, prefixes_1.ERROR_PREFIX, { amountOfWhitespaces: 7, }); }; var TASK_EXECUTION_STATUS_CHANGED = function (task, status, options) { var _a = options.amountOfWhitespaces, amountOfWhitespaces = _a === void 0 ? 0 : _a, _b = options.endOfLine, endOfLine = _b === void 0 ? '\n' : _b; return "Task to " + chalk_1.default.yellow(task.getLabel()) + ": " + status + ' '.repeat(amountOfWhitespaces) + endOfLine; }; // List action exports.LIST_PROJECTS = function (projects) { var listItemMarker = '\n- '; var projectsAliasesWithHelpCmd = projects.map(function (project) { return project.getAlias() + ": fun with " + project.getAlias(); }); return mountPrefixedMessage(node_emoji_1.default.emojify(':grimacing: :clap:'), "You have " + chalk_1.default.yellow(projects.length) + " projects to have fun:" + listItemMarker + projectsAliasesWithHelpCmd.join(listItemMarker)); }; // Delete action exports.PROJECT_DELETED_WITH_SUCCESS = function (project) { return mountEmojiPrefixedMessage('disappointed', "The project \"" + project.getAlias() + "\" is not fun anymore, it happens..."); }; exports.NOT_CONFIRMED_DELETION = mountEmojiPrefixedMessage('sweat_smile', 'Phew, that was close...'); // Help messages exports.LIST_PROJECTS_HELP = "Run \"" + chalk_1.default.yellow('fun list') + "\" for a list of existent commands.\n"; exports.RUN_COMMAND_HELP = function (project) { return mountEmojiPrefixedMessage('point_right', "Run \"" + chalk_1.default.yellow("fun with " + project.getAlias()) + "\" command and be happy!", { startWithNewLine: false, }); }; exports.PROJECT_DETAILS_HELP = function (projectAlias) { return mountEmojiPrefixedMessage('point_right', "Run \"" + chalk_1.default.yellow("fun details " + (projectAlias !== null && projectAlias !== void 0 ? projectAlias : '<project-alias>')) + "\" for more details about project.", { startWithNewLine: false, }); }; exports.ADD_PROJECT_HELP = mountEmojiPrefixedMessage('point_right', "Run \"" + chalk_1.default.yellow('fun add <project-alias> --path <path-to-project>') + "\" to add a fun project!", { startWithNewLine: false, }); // Jokes exports.DELETE_FAIL_JOKE = function (project) { return mountEmojiPrefixedMessage('thought_balloon', "Be positive! At least you can have fun with \"" + project.getAlias() + "\" for the last time..."); };