venmjs
Version:
This is a tool ๐ง that can be installed in your terminal at any time โ๏ธ it was made for beginners and even for experts, for his utilities, and for a simple creation process ๐งจ. Every web developer knows how frustrating is to deal with the creation of a ne
557 lines (433 loc) โข 20 kB
JavaScript
/* eslint-disable no-unused-vars */
/* eslint-disable prettier/prettier */
/* eslint-disable no-undef */
/* eslint-disable no-useless-escape */
'use strict';
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.frontend = frontend;
var _inquirer = _interopRequireDefault(require("inquirer"));
var logger = _interopRequireWildcard(require("../../../utils/logger"));
var _exec = _interopRequireDefault(require("../../../utils/exec"));
var _validate = require("../../../utils/validate");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, 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 _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
var nomedir = require('../index');
var requireServerSide = require('../index');
var isWin = process.platform === 'win32';
var isLinux = process.platform === 'linux';
var isMac = process.platform === 'darwin';
var shell = require('shelljs');
function frontend(_x) {
return _frontend.apply(this, arguments);
}
function _frontend() {
_frontend = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(appName) {
var dir, dirr, dirrr, dirstring, _yield$inquirer$promp, template_FRONTEND, _yield$inquirer$promp2, template_SSG_Jam, _yield$inquirer$promp3, template_SSR, _yield$inquirer$promp4, template_Mobile;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
//#region FRONTEND CLIENT
console.log(JSON.stringify(requireServerSide), nomedir);
dir = JSON.stringify(nomedir);
dirr = dir.replace(/[^\w\s]/gi, '');
dirrr = dirr.replace('appName', '');
dirstring = dirrr.replace(/[^\w\s]/gi, '');
_context.next = 7;
return _inquirer["default"].prompt([{
name: 'template_FRONTEND',
type: 'list',
message: 'Please choose a FRONTEND template โจ',
choices: ['SSG/Jamstack', 'SSR', 'Vue', 'Mobile', 'Multi Platform']
}]);
case 7:
_yield$inquirer$promp = _context.sent;
template_FRONTEND = _yield$inquirer$promp.template_FRONTEND;
if (!(template_FRONTEND === 'SSG/Jamstack')) {
_context.next = 56;
break;
}
_context.next = 12;
return _inquirer["default"].prompt([{
name: 'template_SSG_Jam',
type: 'list',
message: 'Please choose a SSG framework โจ',
choices: ['Vuepress', 'Gridsome']
}]);
case 12:
_yield$inquirer$promp2 = _context.sent;
template_SSG_Jam = _yield$inquirer$promp2.template_SSG_Jam;
if (!(template_SSG_Jam === 'Vuepress')) {
_context.next = 33;
break;
}
logger.info('Creating the Vuepress project ๐');
if (!isWin) {
_context.next = 22;
break;
}
shell.exec('wt -w 0 -d . -p "Command Prompt" cmd /k "cd .. && yarn create vuepress-site client && cd client && npm add --dev vitepress && exit";');
_context.next = 20;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 20:
_context.next = 32;
break;
case 22:
if (!isMac) {
_context.next = 28;
break;
}
shell.exec("osascript -e 'tell app \"Terminal\"\n do script \"yarn create vuepress-site client; cd client; npm add --dev vitepress; killall Terminal\"\n end tell'");
_context.next = 26;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 26:
_context.next = 32;
break;
case 28:
if (!isLinux) {
_context.next = 32;
break;
}
shell.exec("gnome-terminal -- /bin/bash -c \"cd .. && yarn create vuepress-site client && npm add --dev vitepress\"");
_context.next = 32;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 32:
module.exports.template = 'Vuepress';
case 33:
if (!(template_SSG_Jam === 'Gridsome')) {
_context.next = 54;
break;
}
logger.info('Creating the Gridsome project ๐');
_context.next = 37;
return (0, _validate.validateInstallation)('gridsome -v');
case 37:
if (!isWin) {
_context.next = 43;
break;
}
shell.exec('wt -w 0 -d . -p "Command Prompt" cmd /k "cd .. && gridsome create client && cd client && exit";');
_context.next = 41;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 41:
_context.next = 53;
break;
case 43:
if (!isMac) {
_context.next = 49;
break;
}
shell.exec("osascript -e 'tell app \"Terminal\"\n do script \"gridsome create client; cd client; killall Terminal\"\n end tell'");
_context.next = 47;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 47:
_context.next = 53;
break;
case 49:
if (!isLinux) {
_context.next = 53;
break;
}
shell.exec("gnome-terminal -- /bin/bash -c \"cd .. && gridsome create client\"");
_context.next = 53;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 53:
module.exports.template = 'Gridsome';
case 54:
_context.next = 201;
break;
case 56:
if (!(template_FRONTEND === 'SSR')) {
_context.next = 106;
break;
}
_context.next = 59;
return _inquirer["default"].prompt([{
name: 'template_SSR',
type: 'list',
message: 'Please choose a SSR framework โจ',
choices: ['Nuxt', 'Quasar']
}]);
case 59:
_yield$inquirer$promp3 = _context.sent;
template_SSR = _yield$inquirer$promp3.template_SSR;
if (!(template_SSR === 'Nuxt')) {
_context.next = 83;
break;
}
logger.info('Creating the Nuxt-Vite project ๐');
_context.next = 65;
return (0, _validate.validateInstallation)('nuxt -v');
case 65:
if (!isWin) {
_context.next = 71;
break;
}
shell.exec('wt -w 0 -d . -p "Command Prompt" cmd /k "cd .. && npm init nuxt-app@latest client && cd client && npm i -D nuxt-vite && exit";');
_context.next = 69;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 69:
_context.next = 81;
break;
case 71:
if (!isMac) {
_context.next = 77;
break;
}
shell.exec("osascript -e 'tell app \"Terminal\" to do script \"npm init nuxt-app@latest client; cd client; npm i -D nuxt-vite; killall Terminal\"'");
_context.next = 75;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 75:
_context.next = 81;
break;
case 77:
if (!isLinux) {
_context.next = 81;
break;
}
shell.exec("gnome-terminal -- /bin/bash -c \"cd .. && npm init nuxt-app@latest client && npm i -D nuxt-vite\"");
_context.next = 81;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 81:
logger.info("Insert in nuxt.config \uD83D\uDC49 buildModules: ['nuxt-vite']");
module.exports.template = 'Nuxt';
case 83:
if (!(template_SSR === 'Quasar')) {
_context.next = 104;
break;
}
logger.info('Creating the Quasar project ๐');
_context.next = 87;
return (0, _validate.validateInstallation)('quasar -v');
case 87:
if (!isWin) {
_context.next = 93;
break;
}
shell.exec('wt -w 0 -d . -p "Command Prompt" cmd /k "cd .. && quasar create client && cd client && exit";');
_context.next = 91;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 91:
_context.next = 103;
break;
case 93:
if (!isMac) {
_context.next = 99;
break;
}
shell.exec("osascript -e 'tell app \"Terminal\"\n do script \"quasar create client; cd client; killall Terminal\"\n end tell'");
_context.next = 97;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 97:
_context.next = 103;
break;
case 99:
if (!isLinux) {
_context.next = 103;
break;
}
shell.exec("gnome-terminal -- /bin/bash -c \"cd .. && quasar create client\"");
_context.next = 103;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 103:
module.exports.template = 'Quasar';
case 104:
_context.next = 201;
break;
case 106:
if (!(template_FRONTEND === 'Vue')) {
_context.next = 129;
break;
}
logger.info('Creating the Vue-Vite project ๐');
_context.next = 110;
return (0, _validate.validateInstallation)('vue -V');
case 110:
if (!isWin) {
_context.next = 116;
break;
}
shell.exec('wt -w 0 -d . -p "Command Prompt" cmd /k "cd .. && vue create client && cd client && npm i @vitejs/plugin-vue && vue add vite && exit";');
_context.next = 114;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 114:
_context.next = 126;
break;
case 116:
if (!isMac) {
_context.next = 122;
break;
}
shell.exec('osascript -e "tell app "Terminal" to do script "vue create client; npm i @vitejs/plugin-vue; vue add vite; killall Terminal" in selected tab of the front window"');
_context.next = 120;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 120:
_context.next = 126;
break;
case 122:
if (!isLinux) {
_context.next = 126;
break;
}
shell.exec("gnome-terminal -- /bin/bash -c \"cd .. && vue create client && npm i @vitejs/plugin-vue && vue add vite\"");
_context.next = 126;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 126:
module.exports.template = 'Vue';
_context.next = 201;
break;
case 129:
if (!(template_FRONTEND === 'Mobile')) {
_context.next = 180;
break;
}
_context.next = 132;
return _inquirer["default"].prompt([{
name: 'template_Mobile',
type: 'list',
message: 'Please choose a MOBILE framework โจ',
choices: ['Vue native', 'Ionic']
}]);
case 132:
_yield$inquirer$promp4 = _context.sent;
template_Mobile = _yield$inquirer$promp4.template_Mobile;
if (!(template_Mobile === 'Vue native')) {
_context.next = 157;
break;
}
logger.info('Creating the VueNative project ๐');
_context.next = 138;
return (0, _validate.validateInstallation)('vue-native -v');
case 138:
_context.next = 140;
return (0, _validate.validateInstallation)('expo-cli -V');
case 140:
if (!isWin) {
_context.next = 146;
break;
}
shell.exec('wt -w 0 -d . -p "Command Prompt" cmd /k "cd .. && vue-native init client && cd client && exit";');
_context.next = 144;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 144:
_context.next = 156;
break;
case 146:
if (!isMac) {
_context.next = 152;
break;
}
shell.exec("osascript -e 'tell app \"Terminal\"\n do script \"vue-native init client; cd client; killall Terminal\"\n end tell'");
_context.next = 150;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 150:
_context.next = 156;
break;
case 152:
if (!isLinux) {
_context.next = 156;
break;
}
shell.exec("gnome-terminal -- /bin/bash -c \"cd .. && vue-native init client\"");
_context.next = 156;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 156:
module.exports.template = 'Vue native';
case 157:
if (!(template_Mobile === 'Ionic')) {
_context.next = 178;
break;
}
logger.info('Creating the VueNative project ๐');
_context.next = 161;
return (0, _validate.validateInstallation)('ionic -v');
case 161:
if (!isWin) {
_context.next = 167;
break;
}
shell.exec('wt -w 0 -d . -p "Command Prompt" cmd /k "cd .. && ionic start client tabs --type vue --capacitor && cd client && exit";');
_context.next = 165;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 165:
_context.next = 177;
break;
case 167:
if (!isMac) {
_context.next = 173;
break;
}
shell.exec("osascript -e 'tell app \"Terminal\"\n do script \"sh -c \"ionic start client tabs --type vue --capacitor; cd client; killall Terminal\"\n end tell'");
_context.next = 171;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 171:
_context.next = 177;
break;
case 173:
if (!isLinux) {
_context.next = 177;
break;
}
shell.exec("gnome-terminal -- /bin/bash -c \"cd .. && ionic start client tabs --type vue --capacitor\"");
_context.next = 177;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 177:
module.exports.template = 'Ionic';
case 178:
_context.next = 201;
break;
case 180:
if (!(template_FRONTEND === 'Multi Platform')) {
_context.next = 201;
break;
}
logger.info('Creating the Electron project ๐');
_context.next = 184;
return (0, _validate.validateInstallation)('electron -v');
case 184:
if (!isWin) {
_context.next = 190;
break;
}
shell.exec('wt -w 0 -d . -p "Command Prompt" cmd /k "cd .. && vue create client && cd client && vue add electron-builder && exit";');
_context.next = 188;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 188:
_context.next = 200;
break;
case 190:
if (!isMac) {
_context.next = 196;
break;
}
shell.exec("osascript -e 'tell app \"Terminal\"\n do script \"vue create client; cd client; vue add electron-builder; killall Terminal\"\n end tell'");
_context.next = 194;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 194:
_context.next = 200;
break;
case 196:
if (!isLinux) {
_context.next = 200;
break;
}
shell.exec("gnome-terminal -- /bin/bash -c \"cd .. && vue create client && vue add electron-builder\"");
_context.next = 200;
return (0, _exec["default"])('npm install', 'Installing Frontend Dependencies');
case 200:
module.exports.template = 'Multi Platform';
case 201:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _frontend.apply(this, arguments);
}