UNPKG

tyr-cli

Version:

A command line interface for hammer-io.

34 lines (25 loc) 3.19 kB
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.generateExpressFiles = undefined; /** * Generate the files needed for supporting the express framework. This includes the index.html * file, the index.js file, and the routes.js file. It also updates the package.json file by * adding express as a dependency. * @returns {Promise<void>} */let generateExpressFiles = exports.generateExpressFiles = (() => {var _ref = _asyncToGenerator( function* (projectPath) { log.verbose('Express Service - generateExpressFiles()'); const path = `${projectPath}/src`; // generate the index.html file const indexHTMLContents = file.loadTemplate('./../../templates/express/index.html'); file.writeFile(`${path}/index.html`, indexHTMLContents); log.info(`Successfully generated file: ${path}/index.html`); // generate the index.js file const indexJSContents = file.loadTemplate('./../../templates/express/index.js'); file.writeFile(`${path}/index.js`, indexJSContents); log.info(`Successfully generated file: ${path}/index.js`); // generate the routes.js file const routesJSContents = file.loadTemplate('./../../templates/express/routes.js'); file.writeFile(`${path}/routes.js`, routesJSContents); log.info(`Successfully generated file: ${path}/routes.js`); // add express.js as a dependency to the package.json packageJsonUtil.addDependencyToPackageJsonFile(projectPath, 'express', '^4.16.0'); });return function generateExpressFiles(_x) {return _ref.apply(this, arguments);};})();var _file = require('../utils/file');var file = _interopRequireWildcard(_file);var _packageJsonUtil = require('../utils/package-json-util');var packageJsonUtil = _interopRequireWildcard(_packageJsonUtil);var _winston = require('../utils/winston');function _interopRequireWildcard(obj) {if (obj && obj.__esModule) {return obj;} else {var newObj = {};if (obj != null) {for (var key in obj) {if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];}}newObj.default = obj;return newObj;}}function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};} /* eslint-disable import/prefer-default-export */const log = (0, _winston.getActiveLogger)();