diff --git a/dist/argsManager.js b/dist/argsManager.js index 4832328..f19a3a3 100644 --- a/dist/argsManager.js +++ b/dist/argsManager.js @@ -37,7 +37,7 @@ var genericProcessor = function genericProcessor(args) { var createProcessor = function createProcessor(args) { return { type: 'create', - args: args.slice(1) + args: args.splice(0, 3) }; }; @@ -60,7 +60,7 @@ function usage() { // console.log(chalk.grey('\nProject run')); // console.log(' vulcan start'); console.log(chalk.grey('\nProject initialisation')); - console.log(' vulcan create '); + console.log(' vulcan create --style=(bootstrap|material)'); // console.log(' vulcan unshallow '); console.log(chalk.grey('\nAssets creation')); console.log(' vulcan (generate|g) package '); diff --git a/dist/generator-vulcanjs/generators/app/index.js b/dist/generator-vulcanjs/generators/app/index.js index 39baf24..212a84b 100644 --- a/dist/generator-vulcanjs/generators/app/index.js +++ b/dist/generator-vulcanjs/generators/app/index.js @@ -14,6 +14,7 @@ var chalk = require('chalk'); var VulcanGenerator = require('../../lib/VulcanGenerator'); var STARTER_REPO_URL = 'https://github.com/VulcanJS/Vulcan-Starter.git'; +var STARTERS = [{ name: "bootstrap", github: 'https://github.com/VulcanJS/Vulcan-Starter.git' }, { name: "material", github: 'https://github.com/Neobii/Vulcan-Starter-Material.git' }]; module.exports = function (_VulcanGenerator) { _inherits(_class, _VulcanGenerator); @@ -27,7 +28,7 @@ module.exports = function (_VulcanGenerator) { _createClass(_class, [{ key: '_registerArguments', value: function _registerArguments() { - this._registerOptions('appName', 'doShallowClone', 'reactExtension', 'packageManager'); + this._registerOptions('appName', 'doShallowClone', 'reactExtension', 'packageManager', 'style'); } }, { key: 'initializing', @@ -60,9 +61,20 @@ module.exports = function (_VulcanGenerator) { if (!this._canInstall()) { return; } + var style = this.props.style && this.props.style.split('=')[1]; + var found = STARTERS.find(function (starter) { + console.log(starter);return starter.name === style; + }); + console.log("no style argument --->", this.props, style); + return; + if (found) { + this.log(chalk.green('\nPulling the most up to date Vulcan-Starter git repository... \n')); + this.spawnCommandSync('git', ['clone', found.github, this.props.appName]); + } else { + this.log(chalk.green('\nPulling the most up to date Vulcan-Starter git repository... \n')); + this.spawnCommandSync('git', ['clone', STARTER_REPO_URL, this.props.appName]); + } - this.log(chalk.green('\nPulling the most up to date Vulcan-Starter git repository... \n')); - this.spawnCommandSync('git', ['clone', STARTER_REPO_URL, this.props.appName]); this.destinationRoot(this.destinationPath(this.props.appName)); this.installDependencies({ npm: this.props.packageManager === 'npm', diff --git a/dist/index.js b/dist/index.js index 9b8f647..d59ac77 100755 --- a/dist/index.js +++ b/dist/index.js @@ -20,6 +20,7 @@ function runWithOptions(generator, extraOptions, callback) { var optionsForGenerators = parseArgs(process.argv.slice(2)); var finalOptions = {}; Object.assign(finalOptions, optionsForGenerators, extraOptions); + console.log("there's a style here -->", finalOptions); return env.run(generator, finalOptions, callback); } @@ -107,7 +108,8 @@ function run() { } else if (action.type === 'create') { registerGenerator('app'); return runWithOptions('app', { - appName: action.args[0] + appName: action.args[0], + style: action.args[2] }); } else if (action.type === 'list') { registerGenerator('list'); diff --git a/src/argsManager.js b/src/argsManager.js index 0b3696e..99eede0 100644 --- a/src/argsManager.js +++ b/src/argsManager.js @@ -32,10 +32,11 @@ const genericProcessor = (args) => { return action; }; -const createProcessor = (args) => ({ +const createProcessor = (args) => { + return { type: 'create', - args: args.slice(1), -}); + args: args.splice(0, 3) +}}; const argsProcessors = { generate: genericProcessor, @@ -56,7 +57,7 @@ function usage () { // console.log(chalk.grey('\nProject run')); // console.log(' vulcan start'); console.log(chalk.grey('\nProject initialisation')); - console.log(' vulcan create '); + console.log(' vulcan create --style=(bootstrap|material)'); // console.log(' vulcan unshallow '); console.log(chalk.grey('\nAssets creation')); console.log(' vulcan (generate|g) package '); diff --git a/src/generator-vulcanjs/generators/app/index.js b/src/generator-vulcanjs/generators/app/index.js index c1cf480..82e8189 100644 --- a/src/generator-vulcanjs/generators/app/index.js +++ b/src/generator-vulcanjs/generators/app/index.js @@ -2,6 +2,10 @@ const chalk = require('chalk'); const VulcanGenerator = require('../../lib/VulcanGenerator'); const STARTER_REPO_URL = 'https://github.com/VulcanJS/Vulcan-Starter.git'; +const STARTERS = [ + {name: "bootstrap", github: 'https://github.com/VulcanJS/Vulcan-Starter.git'}, + {name: "material", github: 'https://github.com/Neobii/Vulcan-Starter-Material.git'} +] module.exports = class extends VulcanGenerator { _registerArguments () { @@ -9,7 +13,8 @@ module.exports = class extends VulcanGenerator { 'appName', 'doShallowClone', 'reactExtension', - 'packageManager' + 'packageManager', + 'style' ); } @@ -40,13 +45,28 @@ module.exports = class extends VulcanGenerator { if (!this._canInstall()) { return; } + const style = this.props.style && this.props.style.split('=')[1]; + const found = STARTERS.find( starter => {console.log(starter);return starter.name === style}); + console.log("no style argument --->", this.props, style) + return; + if(found) { + this.log(chalk.green('\nPulling the most up to date Vulcan-Starter git repository... \n')); + this.spawnCommandSync('git', [ + 'clone', + found.github, + this.props.appName, + ]); + } + + else { + this.log(chalk.green('\nPulling the most up to date Vulcan-Starter git repository... \n')); + this.spawnCommandSync('git', [ + 'clone', + STARTER_REPO_URL, + this.props.appName, + ]); + } - this.log(chalk.green('\nPulling the most up to date Vulcan-Starter git repository... \n')); - this.spawnCommandSync('git', [ - 'clone', - STARTER_REPO_URL, - this.props.appName, - ]); this.destinationRoot( this.destinationPath(this.props.appName) ); diff --git a/src/index.js b/src/index.js index 26f5bed..ebea0e3 100755 --- a/src/index.js +++ b/src/index.js @@ -19,6 +19,7 @@ function runWithOptions (generator, extraOptions, callback) { const optionsForGenerators = parseArgs(process.argv.slice(2)); const finalOptions = {}; Object.assign(finalOptions, optionsForGenerators, extraOptions); + console.log("there's a style here -->", finalOptions) return env.run(generator, finalOptions, callback); } @@ -93,6 +94,7 @@ function run () { registerGenerator('app'); return runWithOptions('app', { appName: action.args[0], + style: action.args[2] }); } else if (action.type === 'list') { registerGenerator('list'); diff --git a/test/create-starter.sh b/test/create-starter.sh new file mode 100755 index 0000000..0672ee4 --- /dev/null +++ b/test/create-starter.sh @@ -0,0 +1,7 @@ +#!/bin/bash +echo "Will create a material ui starter in the ../_vulcan-material-starter folder" +cd ../ +node dist/index.js create test style=material +#cd _vulcan-material-starter +#meteor npm i +#meteor \ No newline at end of file