Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #30 from vladimirpikul/master
Browse files Browse the repository at this point in the history
updated
  • Loading branch information
sgurin authored Aug 6, 2019
2 parents b502428 + 915a428 commit 3749272
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 670 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Web Starter Kit](https://cloud.githubusercontent.com/assets/25930200/24800100/4fb5c49e-1ba7-11e7-982f-578699121d9b.png)](https://github.com/justcoded/npm-jcn/releases)
[![Web Starter Kit](https://user-images.githubusercontent.com/32138684/62466371-d3096b80-b799-11e9-8c96-2ae7d3173116.png)](https://github.com/justcoded/npm-jcn/releases)



Expand Down Expand Up @@ -55,4 +55,4 @@ Contributions, questions and comments are all welcome and encouraged. For code c

The MIT License (MIT)

Copyright (c) 2018 JustCoded the IP provided on other devices on your network
Copyright (c) 2019 JustCoded the IP provided on other devices on your network
69 changes: 10 additions & 59 deletions modules/behavior.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
'use strict';

const colors = require('colors'),
shell = require('shelljs/global'),
fs = require('fs'),
emoji = require('node-emoji'),
del = require('del'),
copydir = require('copy-dir'),
noEmoji = /^win/.test(process.platform);
shell = require('shelljs/global'),
fs = require('fs'),
emoji = require('node-emoji'),
del = require('del'),
copydir = require('copy-dir'),
noEmoji = /^win/.test(process.platform);

if (noEmoji) {
emoji.get = () => '';
}

let config = {},
configClass = require('./config')({
fs: fs,
del: del
}),
git = require('./git')({
folderExists: folderExists,
logComplete: logComplete,
Expand All @@ -27,10 +23,6 @@ let config = {},
errorMessage: errorMessage,
logComplete: logComplete,
fs: fs
}),
vendor = require('./vendor')({
errorMessage: errorMessage,
fs: fs
});

/**
Expand Down Expand Up @@ -114,11 +106,10 @@ function finish() {
* @function
* @param {Object} conf - Information about git repositary and paths to files to delete
*/
function build(conf, isWPforPug) {
function build(conf) {
return new Promise((resolve, reject) => {

// define source path for WordPress projects or clean frontend projects (isWP_Path)
let isWP_Path = isWPforPug == 'WordPress-With-Pug' ? 'assets' : 'src';

let chain = Promise.resolve();

Expand All @@ -143,20 +134,6 @@ function build(conf, isWPforPug) {
// If not the first call read config file and configure package.json
if (i !== 0) {
chain = chain
.then(() => {
return new Promise((resolve, reject) => {
configClass.readConfigFile()
.then(res => {
config = res;
resolve();
}).catch(e => {
errorMessage(e);
reject();
});
});
}).catch(e => {
errorMessage(e);
})
.then(() => {
return new Promise((resolve, reject) => {
dependencies.configurePackageJson(config)
Expand All @@ -167,32 +144,6 @@ function build(conf, isWPforPug) {
}).catch(e => {
errorMessage(e);
})
.then(() => {
return new Promise((resolve, reject) => {
vendor.changeVendor({
config: config,
path: './'+isWP_Path+'/vendor_entries/vendor.scss',
addVendor: vendor.addVendorScss,
deleteVendor: vendor.deleteVendorScss
})
.then(resolve);
});
}).catch(e => {
errorMessage(e);
})
.then(() => {
return new Promise((resolve, reject) => {
vendor.changeVendor({
config: config,
path: './'+isWP_Path+'/vendor_entries/vendor.js',
addVendor: vendor.addVendorJs,
deleteVendor: vendor.deleteVendorJs
})
.then(resolve);
});
}).catch(e => {
errorMessage(e);
});
}

// If the last call install node modules and run gulp
Expand All @@ -218,9 +169,9 @@ function build(conf, isWPforPug) {
* @param {Object} module.emoji - Emoji module
*/
module.exports = {
init: function (conf, isWPforPug) {
init: function (conf) {
console.log('\nGetting starter files... ' + emoji.get('runner'));
build(conf, isWPforPug);
build(conf);
},
emoji: emoji
}
};
22 changes: 0 additions & 22 deletions modules/config.js

This file was deleted.

106 changes: 5 additions & 101 deletions modules/questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ const behavior = require('./behavior'),
defaultGit = 'https://github.com/justcoded/web-starter-kit.git';

let config = [];
let isWPforPug = '';
let isWpGulp = '';

module.exports = () => {
// Check the jcn version (currently doesn't work on Windows)
Expand Down Expand Up @@ -43,7 +41,7 @@ module.exports = () => {
}]
}];



inquirer.prompt(questions).then(answers => {

Expand All @@ -54,8 +52,6 @@ module.exports = () => {
url: defaultGit,
branch: 'master' // Gulp branch
});

isWPforPug = 'With-Pug';

break;
case 'WordPress':
Expand All @@ -64,9 +60,6 @@ module.exports = () => {
branch: 'WordPress-Gulp' // Gulp+WP branch
});

isWpGulp = 'WordPress-Gulp-';
isWPforPug = 'WordPress-With-Pug';

break;
default:
console.log('Something went wrong!'.red);
Expand All @@ -79,99 +72,10 @@ module.exports = () => {

projectType()
.then(() => {
let questions = [{
message: 'Would you like to use Pug?',
type: 'list',
name: 'value',
choices: [{
name: 'Yes',
// With-Pug git branch
value: 'With-Pug'
}, {
name: 'No',
value: 'Markup-Gulp'
}],
},
{
when: function (answers) {
if (answers.value === 'With-Pug') {
// Push the additional information to config
config.push({
url: defaultGit,
branch: isWPforPug
});
}

return true;
},
message: 'Would you like to use CSS Framework?',
type: 'list',
name: 'value',
choices: [{
name: 'Yes',
value: 'CssFramework-Yes'
}, {
name: 'No',
value: 'CssFramework-No'
}],
},
{
when: function (answers) {
return answers.value === 'CssFramework-No' ? true : false;
},
// This question will appear only if user doesn't want to use CSS Frameworks
message: 'Would you like to use SCSS maps?',
type: 'list',
name: 'value',
choices: [{
name: 'Yes',
value: 'default'
}, {
name: 'No',
value: 'Without-SCSS-Map'
}]
},
{
when: function (answers) {
return answers.value === 'CssFramework-Yes' ? true : false;
},
// This question will appear onlu if user wantsto use CSS Frameworks
message: 'Which Framework do you want to use?',
type: 'list',
name: 'value',
choices: [{
name: 'Bootstrap',
// With-Bootstrap git branch
value: 'With-Bootstrap'
}, {
name: 'Materialize',
// With-Materialize git branch
value: 'With-Materialize'
}]
}
];

inquirer.prompt(questions)
.then(answers => {
switch (answers.value) {
case 'Without-SCSS-Map':
case 'With-Bootstrap':
case 'With-Materialize':
// Push the additional information to config
config.push({
url: defaultGit,
branch: isWpGulp + answers.value
});
break;
}

behavior.init(config, isWPforPug);
})
.catch(e => {
console.log(e);
});
behavior.init(config);
})
.catch(e => {
console.log(e);
});;
};
});

};
Loading

0 comments on commit 3749272

Please sign in to comment.