Browse Source

Iteration on install script

pull/1785/head
jlukic 10 years ago
parent
commit
65d037dd66
2 changed files with 86 additions and 37 deletions
  1. 55
      tasks/config/project/install.js
  2. 68
      tasks/install.js

55
tasks/config/project/install.js

@ -20,7 +20,7 @@ var when = {
// path
changeRoot: function(questions) {
return (questions.useRoot == 'no');
return (questions.useRoot === undefined || questions.useRoot == 'no');
},
// install
@ -86,25 +86,25 @@ module.exports = {
;
if( folder == 'bower_components') {
return {
name: 'bower',
name: 'Bower',
root: nextDirectory
};
}
else if(folder == 'node_modules') {
return {
name: 'npm',
name: 'NPM',
root: nextDirectory
};
}
else if(folder == 'composer') {
return {
name: 'composer',
name: 'Composer',
root: nextDirectory
};
}
else if(folder == 'components' || folder == 'modules') {
return {
name: 'custom',
name: 'a custom module system',
root: nextDirectory
};
}
@ -132,8 +132,9 @@ module.exports = {
],
files: {
config: 'semantic.json',
theme : 'theme.config',
config : 'semantic.json',
site : 'src/site',
theme : 'src/theme.config'
},
// modified to create configs
@ -154,29 +155,39 @@ module.exports = {
root: [
{
type: 'list',
name: 'useRoot',
message: '{packageMessage}We determined your project\'s root as {root}. Is this correct?',
type : 'list',
name : 'useRoot',
message :
' \n' +
' {packageMessage} \n' +
' \n' +
' Is this your project\'s root (where gulp will be run)?\n' +
' \033[92m{root}\033[0m \n' +
' \n ' +
'\n',
choices: [
{
name: 'Yes',
value: 'yes'
},
{
name: 'Close! One level below that.',
value: 'modify'
name : 'Yes',
value : 'yes'
},
{
name: 'No, let me specify',
value: 'no'
name : 'No, let me specify',
value : 'no'
}
]
},
{
type: 'input',
name: 'customRoot',
message: 'Please enter the path to your root folder',
when: when.changeRoot
type : 'input',
name : 'customRoot',
message : 'Please enter the path to your project root folder (where build tools will be run)',
default : './',
when : when.changeRoot
},
{
type : 'input',
name : 'sourceFolder',
message : 'Where should we put Semantic UI inside your project folder?',
default : 'semantic/'
}
],

68
tasks/install.js

@ -36,24 +36,55 @@ var
// Export install task
module.exports = function () {
/*--------------
PM Detection
---------------*/
var
currentConfig = requireDotFile('semantic.json'),
manager = install.getPackageManager()
manager = install.getPackageManager(),
rootQuestions = questions.root
;
console.clear();
// if semantic.json exists skip root questions
// test conditions REMOVE
currentConfig = false;
// determine if is in node_modules, bower_modules and determine project root
console.clear();
gulp
manager = {
name: 'NPM',
root: __dirname
};
if(manager && !currentConfig) {
// PM Detected & First Run
rootQuestions[0].message = rootQuestions[0].message
.replace('{packageMessage}', 'We detected you are using \033[92m' + manager.name + '\033[0m. Nice! ')
.replace('{root}', manager.root)
;
rootQuestions[0].default = manager.root;
}
else if(currentConfig) {
// Not First Run
rootQuestions = [];
}
else {
// No PM / First Run (Remove PM Question)
rootQuestions.shift();
}
// insert root questions after "Install Type" question
if(rootQuestions.length > 0) {
Array.prototype.splice.apply(questions.setup, [2, 0].concat(rootQuestions));
}
/*--------------
Inquire
---------------*/
return gulp
.src('gulpfile.js')
.pipe(prompt.prompt(questions.root, function(answers) {
}))
.pipe(prompt.prompt(questions.setup, function(answers) {
var
siteVariable = /@siteFolder .*\'(.*)/mg,
@ -88,6 +119,15 @@ module.exports = function () {
console.log('Installing');
console.log('------------------------------');
/*--------------
PM Mods
---------------*/
// (All cases) Copy node_modules folder, if it isnt current folder
// (PM Case) Copy src/ to project root
/*--------------
Site Themes
---------------*/
@ -101,7 +141,7 @@ module.exports = function () {
}
// Copy _site template without overwrite
wrench.copyDirSyncRecursive(config.templates.site, siteDestination, settings.wrench.recursive);
wrench.copyDirSyncRecursive(install.templates.site, siteDestination, settings.wrench.recursive);
/*--------------
Theme.config
@ -113,17 +153,15 @@ module.exports = function () {
gulp.src(config.files.site)
.pipe(plumber())
.pipe(replace(siteVariable, sitePathReplace))
.pipe(chmod(config.permission))
.pipe(gulp.dest(install.folders.theme))
;
}
else {
console.info('Creating src/theme.config (LESS config)');
gulp.src(config.templates.theme)
gulp.src(install.templates.theme)
.pipe(plumber())
.pipe(rename({ extname : '' }))
.pipe(replace(siteVariable, sitePathReplace))
.pipe(chmod(config.permission))
.pipe(gulp.dest(install.folders.theme))
;
}

Loading…
Cancel
Save