create-noderize
Advanced tools
Comparing version 0.1.2 to 0.1.3
#!/usr/bin/env node | ||
!function(c){var n={};function e(l){if(n[l])return n[l].exports;var a=n[l]={i:l,l:!1,exports:{}};return c[l].call(a.exports,a,a.exports,e),a.l=!0,a.exports}e.m=c,e.c=n,e.d=function(c,n,l){e.o(c,n)||Object.defineProperty(c,n,{configurable:!1,enumerable:!0,get:l})},e.n=function(c){var n=c&&c.__esModule?function(){return c.default}:function(){return c};return e.d(n,"a",n),n},e.o=function(c,n){return Object.prototype.hasOwnProperty.call(c,n)},e.p="",e(e.s=0)}([function(module,exports,__webpack_require__){"use strict";eval('\n\nvar _ncp = __webpack_require__(1);\n\nvar _chalk = _interopRequireDefault(__webpack_require__(2));\n\nvar _util = __webpack_require__(3);\n\nvar _path = __webpack_require__(4);\n\nvar _fs = _interopRequireDefault(__webpack_require__(5));\n\nvar _child_process = __webpack_require__(6);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); 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 { Promise.resolve(value).then(_next, _throw); } } function _next(value) { step("next", value); } function _throw(err) { step("throw", err); } _next(); }); }; }\n\n_asyncToGenerator(function* () {\n // Get name/path from CLI\n const name = process.argv[2];\n\n if (!name) {\n console.log(`${_chalk.default.red("[INFO]")} No path given!`);\n return;\n } // Get absolute path\n\n\n const path = (0, _path.resolve)(_fs.default.realpathSync(process.cwd()), name);\n\n if (_fs.default.existsSync(path)) {\n console.log(`${_chalk.default.red("[INFO]")} Path exists!`);\n return;\n }\n\n console.log(`${_chalk.default.yellowBright("[INFO]")} Copying...`); // Copy from template\n\n try {\n yield (0, _util.promisify)(_ncp.ncp)((0, _path.resolve)(__dirname, "..", "template"), path);\n } catch (error) {\n console.error(`${_chalk.default.redBright("[ERROR]")} Error copying.`);\n console.error(error);\n return;\n }\n\n console.log(`${_chalk.default.yellowBright("[INFO]")} Setting up...`); // Set the "name" field in package.json\n\n try {\n const childPackagePath = (0, _path.resolve)(path, "package.json"); // Read\n\n const childPackage = JSON.parse(_fs.default.readFileSync(childPackagePath));\n\n const newChildPackage = _extends({\n name\n }, childPackage); // Hack to put name at front\n // Write\n\n\n _fs.default.writeFileSync(childPackagePath, JSON.stringify(newChildPackage, null, "\\t"));\n } catch (error) {\n console.error(`${_chalk.default.redBright("[ERROR]")} Error setting name.`);\n console.error(error);\n } // Move "gitignore" to ".gitignore"\n\n\n try {\n _fs.default.renameSync((0, _path.resolve)(path, "gitignore"), (0, _path.resolve)(path, ".gitignore"));\n } catch (error) {\n console.error(`${_chalk.default.redBright("[ERROR]")} Error moving .gitignore.`);\n console.error(error);\n }\n\n console.log(`${_chalk.default.yellowBright("[INFO]")} Installing packages...`);\n const useYarn = shouldUseYarn();\n\n try {\n // Install using yarn/npm\n if (useYarn) {\n (0, _child_process.execSync)("yarn", {\n cwd: path\n });\n } else {\n (0, _child_process.execSync)("npm install", {\n cwd: path\n });\n }\n } catch (error) {\n console.error(`${_chalk.default.redBright("[ERROR]")} Error installing packages.`);\n console.error(error);\n }\n\n const runCommand = useYarn ? "yarn" : "npm run";\n console.log(`${_chalk.default.greenBright("[INFO]")} Done!`);\n console.log(`${_chalk.default.greenBright("[INFO]")} You may visit your app with ${_chalk.default.cyan(`cd ${name}`)}`);\n console.log(`${_chalk.default.greenBright("[INFO]")} Develop by using ${_chalk.default.cyan(`${runCommand} watch`)}`);\n console.log(`${_chalk.default.greenBright("[INFO]")} Build a production version using ${_chalk.default.cyan(`${runCommand} build`)}`);\n})();\n\nfunction shouldUseYarn() {\n try {\n (0, _child_process.execSync)("yarn --version", {\n stdio: "ignore"\n });\n return true;\n } catch (e) {\n return false;\n }\n}//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9zcmMvaW5kZXguanM/MWZkZiJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBuY3AgfSBmcm9tIFwibmNwXCI7XG5pbXBvcnQgY2hhbGsgZnJvbSBcImNoYWxrXCI7XG5pbXBvcnQgeyBwcm9taXNpZnkgfSBmcm9tIFwidXRpbFwiO1xuaW1wb3J0IHsgcmVzb2x2ZSB9IGZyb20gXCJwYXRoXCI7XG5pbXBvcnQgZnMgZnJvbSBcImZzXCI7XG5pbXBvcnQgeyBleGVjU3luYyB9IGZyb20gXCJjaGlsZF9wcm9jZXNzXCI7XG5cbihhc3luYyAoKSA9PiB7XG5cdC8vIEdldCBuYW1lL3BhdGggZnJvbSBDTElcblx0Y29uc3QgbmFtZSA9IHByb2Nlc3MuYXJndlsyXTtcblxuXHRpZiAoIW5hbWUpIHtcblx0XHRjb25zb2xlLmxvZyhgJHtjaGFsay5yZWQoXCJbSU5GT11cIil9IE5vIHBhdGggZ2l2ZW4hYCk7XG5cdFx0cmV0dXJuO1xuXHR9XG5cblx0Ly8gR2V0IGFic29sdXRlIHBhdGhcblx0Y29uc3QgcGF0aCA9IHJlc29sdmUoZnMucmVhbHBhdGhTeW5jKHByb2Nlc3MuY3dkKCkpLCBuYW1lKTtcblxuXHRpZiAoZnMuZXhpc3RzU3luYyhwYXRoKSkge1xuXHRcdGNvbnNvbGUubG9nKGAke2NoYWxrLnJlZChcIltJTkZPXVwiKX0gUGF0aCBleGlzdHMhYCk7XG5cdFx0cmV0dXJuO1xuXHR9XG5cblx0Y29uc29sZS5sb2coYCR7Y2hhbGsueWVsbG93QnJpZ2h0KFwiW0lORk9dXCIpfSBDb3B5aW5nLi4uYCk7X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FBQ0E7QUFDQTtBQUNBO0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQUE7QUFBQTtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBREE7QUFJQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBRUE7QUFDQTtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQUE7QUFBQTtBQUNBO0FBQ0E7QUFBQTtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFBQTtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///0\n')},function(module,exports){eval('module.exports = require("ncp");//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9leHRlcm5hbCBcIm5jcFwiP2U4MTkiXSwic291cmNlc0NvbnRlbnQiOlsibW9kdWxlLmV4cG9ydHMgPSByZXF1aXJlKFwibmNwXCIpO1xuXG5cbi8vLy8vLy8vLy8vLy8vLy8vL1xuLy8gV0VCUEFDSyBGT09URVJcbi8vIGV4dGVybmFsIFwibmNwXCJcbi8vIG1vZHVsZSBpZCA9IDFcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///1\n')},function(module,exports){eval('module.exports = require("chalk");//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMi5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9leHRlcm5hbCBcImNoYWxrXCI/NTNmNyJdLCJzb3VyY2VzQ29udGVudCI6WyJtb2R1bGUuZXhwb3J0cyA9IHJlcXVpcmUoXCJjaGFsa1wiKTtcblxuXG4vLy8vLy8vLy8vLy8vLy8vLy9cbi8vIFdFQlBBQ0sgRk9PVEVSXG4vLyBleHRlcm5hbCBcImNoYWxrXCJcbi8vIG1vZHVsZSBpZCA9IDJcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///2\n')},function(module,exports){eval('module.exports = require("util");//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMy5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9leHRlcm5hbCBcInV0aWxcIj83MGM1Il0sInNvdXJjZXNDb250ZW50IjpbIm1vZHVsZS5leHBvcnRzID0gcmVxdWlyZShcInV0aWxcIik7XG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gZXh0ZXJuYWwgXCJ1dGlsXCJcbi8vIG1vZHVsZSBpZCA9IDNcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///3\n')},function(module,exports){eval('module.exports = require("path");//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9leHRlcm5hbCBcInBhdGhcIj81YjJhIl0sInNvdXJjZXNDb250ZW50IjpbIm1vZHVsZS5leHBvcnRzID0gcmVxdWlyZShcInBhdGhcIik7XG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gZXh0ZXJuYWwgXCJwYXRoXCJcbi8vIG1vZHVsZSBpZCA9IDRcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///4\n')},function(module,exports){eval('module.exports = require("fs");//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9leHRlcm5hbCBcImZzXCI/MmUwOSJdLCJzb3VyY2VzQ29udGVudCI6WyJtb2R1bGUuZXhwb3J0cyA9IHJlcXVpcmUoXCJmc1wiKTtcblxuXG4vLy8vLy8vLy8vLy8vLy8vLy9cbi8vIFdFQlBBQ0sgRk9PVEVSXG4vLyBleHRlcm5hbCBcImZzXCJcbi8vIG1vZHVsZSBpZCA9IDVcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///5\n')},function(module,exports){eval('module.exports = require("child_process");//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNi5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9leHRlcm5hbCBcImNoaWxkX3Byb2Nlc3NcIj80MzA4Il0sInNvdXJjZXNDb250ZW50IjpbIm1vZHVsZS5leHBvcnRzID0gcmVxdWlyZShcImNoaWxkX3Byb2Nlc3NcIik7XG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gZXh0ZXJuYWwgXCJjaGlsZF9wcm9jZXNzXCJcbi8vIG1vZHVsZSBpZCA9IDZcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///6\n')}]); | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ (function (module) { | ||
/******/ if (module.exports | ||
/******/ && !module.exports.__esModule | ||
/******/ && module.exports.default === undefined | ||
/******/ ) { | ||
/******/ if (module.exports.headers | ||
/******/ && module.exports.headers.common | ||
/******/ && module.exports.headers.common.Accept | ||
/******/ && module.exports.adapter | ||
/******/ && module.exports.transformRequest | ||
/******/ && module.exports.transformResponse | ||
/******/ ) { | ||
/******/ return; | ||
/******/ } | ||
/******/ module.exports.default = module.exports; | ||
/******/ } | ||
/******/ })(module); | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var _ncp = __webpack_require__(1); | ||
var _chalk = _interopRequireDefault(__webpack_require__(2)); | ||
var _util = __webpack_require__(3); | ||
var _path = __webpack_require__(4); | ||
var _fs = _interopRequireDefault(__webpack_require__(5)); | ||
var _child_process = __webpack_require__(6); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); 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 { Promise.resolve(value).then(_next, _throw); } } function _next(value) { step("next", value); } function _throw(err) { step("throw", err); } _next(); }); }; } | ||
_asyncToGenerator(function* () { | ||
// Get name/path from CLI | ||
const name = process.argv[2]; | ||
if (!name) { | ||
console.log(`${_chalk.default.red("[INFO]")} No path given!`); | ||
return; | ||
} // Get absolute path | ||
const path = (0, _path.resolve)(_fs.default.realpathSync(process.cwd()), name); | ||
if (_fs.default.existsSync(path)) { | ||
console.log(`${_chalk.default.red("[INFO]")} Path exists!`); | ||
return; | ||
} | ||
console.log(`${_chalk.default.yellowBright("[INFO]")} Copying...`); // Copy from template | ||
try { | ||
yield (0, _util.promisify)(_ncp.ncp)((0, _path.resolve)(__dirname, "..", "template"), path); | ||
} catch (error) { | ||
console.error(`${_chalk.default.redBright("[ERROR]")} Error copying.`); | ||
console.error(error); | ||
return; | ||
} | ||
console.log(`${_chalk.default.yellowBright("[INFO]")} Setting up...`); // Set the "name" field in package.json | ||
try { | ||
const childPackagePath = (0, _path.resolve)(path, "package.json"); // Read | ||
const childPackage = JSON.parse(_fs.default.readFileSync(childPackagePath)); | ||
const newChildPackage = _extends({ | ||
name | ||
}, childPackage); // Hack to put name at front | ||
// Write | ||
_fs.default.writeFileSync(childPackagePath, JSON.stringify(newChildPackage, null, "\t")); | ||
} catch (error) { | ||
console.error(`${_chalk.default.redBright("[ERROR]")} Error setting name.`); | ||
console.error(error); | ||
} // Move "gitignore" to ".gitignore" | ||
try { | ||
_fs.default.renameSync((0, _path.resolve)(path, "gitignore"), (0, _path.resolve)(path, ".gitignore")); | ||
} catch (error) { | ||
console.error(`${_chalk.default.redBright("[ERROR]")} Error moving .gitignore.`); | ||
console.error(error); | ||
} | ||
console.log(`${_chalk.default.yellowBright("[INFO]")} Installing packages...`); | ||
const useYarn = shouldUseYarn(); | ||
try { | ||
// Install using yarn/npm | ||
if (useYarn) { | ||
(0, _child_process.execSync)("yarn", { | ||
cwd: path | ||
}); | ||
} else { | ||
(0, _child_process.execSync)("npm install", { | ||
cwd: path | ||
}); | ||
} | ||
} catch (error) { | ||
console.error(`${_chalk.default.redBright("[ERROR]")} Error installing packages.`); | ||
console.error(error); | ||
} | ||
const runCommand = useYarn ? "yarn" : "npm run"; | ||
console.log(`${_chalk.default.greenBright("[INFO]")} Done!`); | ||
console.log(`${_chalk.default.greenBright("[INFO]")} You may visit your app with ${_chalk.default.cyan(`cd ${name}`)}`); | ||
console.log(`${_chalk.default.greenBright("[INFO]")} Develop by using ${_chalk.default.cyan(`${runCommand} watch`)}`); | ||
console.log(`${_chalk.default.greenBright("[INFO]")} Build a production version using ${_chalk.default.cyan(`${runCommand} build`)}`); | ||
})(); | ||
function shouldUseYarn() { | ||
try { | ||
(0, _child_process.execSync)("yarn --version", { | ||
stdio: "ignore" | ||
}); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("ncp"); | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("chalk"); | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("util"); | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("path"); | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("fs"); | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("child_process"); | ||
/***/ }) | ||
/******/ ]); |
@@ -10,3 +10,3 @@ { | ||
}, | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"license": "MIT", | ||
@@ -13,0 +13,0 @@ "bin": "dist/index.js", |
@@ -80,5 +80,17 @@ import { ncp } from "ncp"; | ||
console.log(`${chalk.greenBright("[INFO]")} Done!`); | ||
console.log(`${chalk.greenBright("[INFO]")} You may visit your app with ${chalk.cyan(`cd ${name}`)}`); | ||
console.log(`${chalk.greenBright("[INFO]")} Develop by using ${chalk.cyan(`${runCommand} watch`)}`); | ||
console.log(`${chalk.greenBright("[INFO]")} Build a production version using ${chalk.cyan(`${runCommand} build`)}`); | ||
console.log( | ||
`${chalk.greenBright("[INFO]")} You may visit your app with ${chalk.cyan( | ||
`cd ${name}` | ||
)}` | ||
); | ||
console.log( | ||
`${chalk.greenBright("[INFO]")} Develop by using ${chalk.cyan( | ||
`${runCommand} watch` | ||
)}` | ||
); | ||
console.log( | ||
`${chalk.greenBright( | ||
"[INFO]" | ||
)} Build a production version using ${chalk.cyan(`${runCommand} build`)}` | ||
); | ||
})(); | ||
@@ -85,0 +97,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
285
12999
2
3