Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Revert "Revert "update gulp tasks to build code before package, as we…
Browse files Browse the repository at this point in the history
…ll as slightly alter view selection options (ExLibrisGroup#77)""

This reverts commit c7d47fe.
  • Loading branch information
Elliott Grieco committed Nov 30, 2018
1 parent 85c1483 commit 588e179
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 50 deletions.
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 @@ -19,12 +19,12 @@ const sourcemaps = require('gulp-sourcemaps');

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

0 comments on commit 588e179

Please sign in to comment.