Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding option to create material starter WIP #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dist/argsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
};

Expand All @@ -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 <appName>');
console.log(' vulcan create <projectName> --style=(bootstrap|material)');
// console.log(' vulcan unshallow ');
console.log(chalk.grey('\nAssets creation'));
console.log(' vulcan (generate|g) package <packageName>');
Expand Down
18 changes: 15 additions & 3 deletions dist/generator-vulcanjs/generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 3 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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');
Expand Down
9 changes: 5 additions & 4 deletions src/argsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 <appName>');
console.log(' vulcan create <projectName> --style=(bootstrap|material)');
// console.log(' vulcan unshallow ');
console.log(chalk.grey('\nAssets creation'));
console.log(' vulcan (generate|g) package <packageName>');
Expand Down
34 changes: 27 additions & 7 deletions src/generator-vulcanjs/generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ 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 () {
this._registerOptions(
'appName',
'doShallowClone',
'reactExtension',
'packageManager'
'packageManager',
'style'
);
}

Expand Down Expand Up @@ -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)
);
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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');
Expand Down
7 changes: 7 additions & 0 deletions test/create-starter.sh
Original file line number Diff line number Diff line change
@@ -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