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

Build custom code before packaging #77

Merged
merged 1 commit into from
Apr 25, 2018
Merged
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
6 changes: 3 additions & 3 deletions gulp/tasks/build-scss.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let gutil = require('gulp-util');
gulp.task('cleanup',()=> del(['www']));

gulp.task('extract-scss-files', ()=> {
let proxy_server = require('../config').PROXY_SERVER;
let proxy_server = require('../config').PROXY_SERVER;
console.log(proxy_server+'/primo-explore/lib/scsss.tar.gz');
let url = proxy_server+'/primo-explore/lib/scsss.tar.gz';
var headers = {
Expand Down Expand Up @@ -88,7 +88,7 @@ gulp.task('app-css', (cb) => {
* Please note. The logic of this task will only execute if the run task is
* executed with the "useScss" parameter, e.g.: gulp run --view UNIBZ --useScss
*/
gulp.task("watch-custom-scss", () => {
gulp.task("watch-custom-scss", ['select-view'], () => {
if (!useScss()) {
return;
}
Expand All @@ -105,7 +105,7 @@ gulp.task("watch-custom-scss", () => {
* Please note. The logic of this task will only execute if the run task is
* executed with the "useScss" parameter, e.g.: gulp run --view UNIBZ --useScss
*/
gulp.task("custom-scss", () => {
gulp.task("custom-scss", ['select-view'], () => {
if (!useScss()) {
return;
}
Expand Down
8 changes: 4 additions & 4 deletions gulp/tasks/buildCustomCss.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ var glob = require('glob');

let buildParams = config.buildParams;

gulp.task('watch-css', () => {
gulp.task('watch-css', ['select-view'], () => {

gulp.watch([buildParams.customCssMainPath(),buildParams.customNpmCssPath(),'!'+buildParams.customCssPath()],['custom-css']);
});




gulp.task('custom-css', () => {
gulp.task('custom-css', ['select-view'], () => {

return gulp.src([buildParams.customCssMainPath(),buildParams.customNpmCssPath(),'!'+buildParams.customCssPath()])
.pipe(concat(buildParams.customCssFile))
.pipe(gulp.dest(buildParams.viewCssDir()));


});
2 changes: 1 addition & 1 deletion gulp/tasks/buildCustomHtmlTemplates.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ function prepareTemplates() {
}
}

gulp.task('custom-html-templates', () => {
gulp.task('custom-html-templates', ['select-view'], () => {
prepareTemplates();
})
4 changes: 2 additions & 2 deletions gulp/tasks/buildCustomJs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const browserify = require("browserify");

let buildParams = config.buildParams;

gulp.task('watch-js', () => {
gulp.task('watch-js', ['select-view'], () => {
gulp.watch([`${buildParams.viewJsDir()}/**/*.js`,'!'+buildParams.customPath()],['custom-js']);
});


gulp.task('custom-js', ['custom-html-templates'],() => {
gulp.task('custom-js', ['select-view', 'custom-html-templates'],() => {
if(config.getBrowserify()) {
buildByBrowserify();
}
Expand Down
2 changes: 1 addition & 1 deletion gulp/tasks/buildJsFromPrimoNodeModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let runSequence = require("run-sequence");
*
* e.g. gulp run --view [ViewName] --reinstallNodeModules
*/
gulp.task("reinstall-primo-node-modules", function() {
gulp.task("reinstall-primo-node-modules", ['select-view'], function() {
if (config.getReinstallNodeModules()) {
runSequence(["delete-primo-node-modules", "install-primo-node-modules"]);
}
Expand Down
93 changes: 57 additions & 36 deletions gulp/tasks/createPackage.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,67 @@
'use strict';
var gulp = require('gulp');
let glob = require('glob');
let prompt = require('prompt');
let zip = require('gulp-zip');
let config = require('../config.js');
const gulp = require('gulp');
const glob = require('glob');
const prompt = require('prompt');
const zip = require('gulp-zip');
const config = require('../config.js');

let buildParams = config.buildParams;
gulp.task('select-view', (cb) => {
const basedir = 'primo-explore/custom/';
const customFolderExp = basedir + '*/';
const files = glob.sync(customFolderExp, {});

gulp.task('create-package', function () {
var basedir = 'primo-explore/custom/';
var customFolderExp = basedir+'*/';
console.log('Please Choose a package to create:');
glob(customFolderExp, {}, function (er, files) {
// Note elision, there is no member at 2 so it isn't visited
console.log('\r\n');
files.forEach(function(element, index, array){
console.log(index+1 + ': '+ element.replace(basedir,'').replace('/',''));
console.log('\r\n');
});
prompt.start();
var property = {
name: 'package',
message: 'Please Choose the level you want to create the package for'
};
prompt.get(property, function (err, result) {
return new Promise(resolve => {
if (!config.view()) {
console.log('Please Choose a view to use:\r\n');
files.forEach(function(element, index, array){
console.log(index+1 + ': '+ element.replace(basedir,'').replace('/',''));
console.log('\r\n');
});

console.log('\r\n');
var code = result.package;
prompt.start();
const property = {
name: 'view',
message: 'Please Choose view to use'
};
prompt.get(property, function (err, result) {
console.log('\r\n');
let code = result.view;

if(files[result.package - 1]){
code = files[result.package - 1].replace(basedir,'').replace('/','');
if(files[result.view - 1]){
code = files[result.view - 1].replace(basedir,'').replace('/','');
}
config.setView(code);
resolve();
});
} else {
let valid = false
for (let index in files) {
let dir = files[index].replace(basedir,'').replace('/','')

if(dir === config.view()) {
valid = true
break;
}
}
console.log('Creating package for : ('+code+'.zip)');
console.log(code);
console.log(' in : /packages');
console.log('\r\n');
console.log('............................................................................................................................................');
return gulp.src(['./primo-explore/custom/'+code,'./primo-explore/custom/'+code+'/html/**','./primo-explore/custom/'+code+'/img/**','./primo-explore/custom/'+code+'/css/custom1.css','./primo-explore/custom/'+code+'/js/custom.js'], {base: './primo-explore/custom'})
.pipe(zip(code+'.zip'))
.pipe(gulp.dest('./packages/'));
});

if (!valid) {
resolve()
cb("--view must be a valid view")
} else {
resolve()
}
}
})
})

gulp.task('create-package', ['select-view', 'custom-js','custom-scss','custom-css'], function () {
const code = config.view();
console.log('Creating package for : ('+code+'.zip)');
console.log(code);
console.log(' in : /packages');
console.log('\r\n');
console.log('............................................................................................................................................');
return gulp.src(['./primo-explore/custom/'+code,'./primo-explore/custom/'+code+'/html/**','./primo-explore/custom/'+code+'/img/**','./primo-explore/custom/'+code+'/css/custom1.css','./primo-explore/custom/'+code+'/js/custom.js'], {base: './primo-explore/custom'})
.pipe(zip(code+'.zip'))
.pipe(gulp.dest('./packages/'));
});
6 changes: 3 additions & 3 deletions gulp/tasks/servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let runSequence = require('run-sequence');



gulp.task('setup_watchers', ['watch-js', 'watch-custom-scss', 'watch-css'], () => {
gulp.task('setup_watchers', ['select-view', 'watch-js', 'watch-custom-scss', 'watch-css'], () => {
gulp.watch(config.buildParams.customPath(),() => {
return browserSyncManager.reloadServer();
});
Expand All @@ -26,7 +26,7 @@ gulp.task('setup_watchers', ['watch-js', 'watch-custom-scss', 'watch-css'], () =



gulp.task('connect:primo_explore', function() {
gulp.task('connect:primo_explore', ['select-view'], function() {
let appName = 'primo-explore';
browserSyncManager.startServer({
label: 'production',
Expand Down Expand Up @@ -119,4 +119,4 @@ gulp.task('connect:primo_explore', function() {
});


gulp.task('run', ['connect:primo_explore','reinstall-primo-node-modules','setup_watchers','custom-js','custom-scss','custom-css']); //watch
gulp.task('run', ['select-view', 'connect:primo_explore','reinstall-primo-node-modules','setup_watchers','custom-js','custom-scss','custom-css']); //watch