|
| 1 | +#!/usr/bin/env node |
| 2 | + |
| 3 | +//Functions |
| 4 | +var fs = require('fs'); |
| 5 | +function existsSync(filePath){ |
| 6 | + try{ |
| 7 | + fs.statSync(filePath); |
| 8 | + }catch(err){ |
| 9 | + if(err.code == 'ENOENT') return false; |
| 10 | + } |
| 11 | + return true; |
| 12 | +} |
| 13 | + |
| 14 | +function copySync(origin,target){ |
| 15 | + try{ |
| 16 | + fs.writeFileSync(target, fs.readFileSync(origin)); |
| 17 | + }catch(err){ |
| 18 | + if(err.code == 'ENOENT') return false; |
| 19 | + } |
| 20 | + return true; |
| 21 | +} |
| 22 | + |
| 23 | +//Add Definition Colors |
| 24 | +const chalk = require('chalk'); |
| 25 | + |
| 26 | +//Vulcan letters |
| 27 | +console.log(chalk.gray(' ___ ___ ')); |
| 28 | +console.log(chalk.gray(' '+String.fromCharCode(92))+chalk.redBright(String.fromCharCode(92))+chalk.dim.yellow(String.fromCharCode(92))+chalk.gray(String.fromCharCode(92)+' /')+chalk.dim.yellow('/')+chalk.yellowBright('/')+chalk.gray('/')); |
| 29 | +console.log(chalk.gray(' '+String.fromCharCode(92))+chalk.redBright(String.fromCharCode(92))+chalk.dim.yellow(String.fromCharCode(92))+chalk.gray(String.fromCharCode(92))+chalk.gray('/')+chalk.dim.yellow('/')+chalk.yellowBright('/')+chalk.gray('/ Vulcan.js')); |
| 30 | +console.log(chalk.gray(' '+String.fromCharCode(92))+chalk.redBright(String.fromCharCode(92))+chalk.dim.yellow(String.fromCharCode(92))+chalk.dim.yellow('/')+chalk.yellowBright('/')+chalk.gray('/ The full-stack React+GraphQL framework')); |
| 31 | +console.log(chalk.gray(' ──── ')); |
| 32 | + |
| 33 | + |
| 34 | +var os = require('os'); |
| 35 | +var exec = require('child_process').execSync; |
| 36 | +var options = { |
| 37 | + encoding: 'utf8' |
| 38 | +}; |
| 39 | +//Check Meteor and install if not installed |
| 40 | +var checker = exec("meteor --version", options); |
| 41 | +if (!checker.includes("Meteor ")) { |
| 42 | +console.log("Vulcan requires Meteor but it's not installed. Trying to Install..."); |
| 43 | + //Check platform |
| 44 | + if (os.platform()=='darwin') { |
| 45 | + //Mac OS platform |
| 46 | + console.log("🌋 "+chalk.bold.yellow("Good news you have a Mac and we will install it now! }")); |
| 47 | + console.log(exec("curl https://install.meteor.com/ | bash", options)); |
| 48 | + } else if (os.platform()=='linux') { |
| 49 | + //GNU/Linux platform |
| 50 | + console.log("🌋 "+chalk.bold.yellow("Good news you are on GNU/Linux platform and we will install Meteor now!")); |
| 51 | + console.log(exec("curl https://install.meteor.com/ | bash", options)); |
| 52 | + } else if (os.platform()=='win32') { |
| 53 | + //Windows NT platform |
| 54 | + console.log("> "+chalk.bold.yellow("Oh no! you are on a Windows platform and you will need to install Meteor Manually!")); |
| 55 | + console.log("> "+chalk.dim.yellow("Meteor for Windows is available at: ")+chalk.redBright("https://install.meteor.com/windows")); |
| 56 | + process.exit(-1) |
| 57 | + } |
| 58 | +} else { |
| 59 | +//Check exist file settings and create if not exist |
| 60 | +if (!existsSync("settings.json")) { |
| 61 | + console.log("> "+chalk.bold.yellow("Creating your own settings.json file...\n")); |
| 62 | + if (!copySync("sample_settings.json","settings.json")) { |
| 63 | + console.log("> "+chalk.bold.red("Error Creating your own settings.json file...check files and permissions\n")); |
| 64 | + process.exit(-1); |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | + console.log("> "+chalk.bold.yellow("Happy hacking with Vulcan!")); |
| 69 | + console.log("> "+chalk.dim.yellow("The docs are available at: ")+chalk.redBright("http://docs.vulcanjs.org")); |
| 70 | +} |
0 commit comments