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

Commit

Permalink
Update for build process.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wobbabits committed Feb 24, 2016
1 parent 1180aa4 commit d6325e5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 185 deletions.
232 changes: 50 additions & 182 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ var gutils = require('gulp-util');
var ts = require('gulp-typescript');
var beautify = require('gulp-jsbeautifier');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var cssnano = require('gulp-cssnano');
var jsmin = require('gulp-jsmin');
var minifyCSS = require('gulp-minify-css');
var rename = require('gulp-rename');
var colors = require('colors');
var combiner = require('stream-combiner2');
Expand Down Expand Up @@ -37,20 +37,18 @@ var Truck_Files = [
'truck-engine/event-aliases.js',
'truck-engine/gestures.js',
'truck-engine/plugins.js',
'truck-engine/dispatcher.js',
'truck-engine/stack.js',
'truck-engine/mediator.js',
'truck-engine/model.js',
'truck-engine/mediator.js',
'truck-engine/view.js',
'truck-engine/component.js',
'truck-engine/screens.js',
'truck-engine/router.js',
'truck-engine/promises.js',
'truck-engine/fetch.js',
'truck-engine/formatters.js',
'truck-engine/validators.js',
'truck-engine/box.js',
'truck-engine/anim.js',
'truck-engine/oop.js',

/* Truck Body Components */
'truck-body/body-comments.js',
Expand All @@ -70,6 +68,7 @@ var Truck_Files = [
'truck-body/segmented.js',
'truck-body/range.js',
'truck-body/sheets.js',
'truck-body/slide-out.js',
'truck-body/paging.js',
'truck-body/stepper.js',
'truck-body/popover.js',
Expand All @@ -79,42 +78,6 @@ var Truck_Files = [
return path.join(filePathStart, file);
});

var Min_Build = [
/* Truck Wheel Components */
'truck-wheels/domstack.js',
'truck-wheels/selectors.js',
'truck-wheels/utils.js',
'truck-wheels/types.js',
'truck-wheels/strings.js',
'truck-wheels/domstack.js',
'truck-wheels/dom.js',
'truck-wheels/data.js',
'truck-wheels/serialize.js',
'truck-wheels/events.js',

/* Truck Engine Components */
'truck-engine/environment.js',
'truck-engine/event-aliases.js',
'truck-engine/gestures.js',
'truck-engine/plugins.js',
'truck-engine/stack.js',
'truck-engine/mediator.js',
'truck-engine/model.js',
'truck-engine/view.js',
'truck-engine/component.js',
'truck-engine/screens.js',
'truck-engine/router.js',

/* Truck Body Components */
'truck-body/navbar.js',
'truck-body/setup.js',
'truck-body/buttons.js',
'truck-body/navigation.js',
'truck-body/center.js',
].map(function(file) {
return path.join(filePathStart, file);
});

var Truck_Wheel_Files = [
/* Truck Wheel Components */
'truck-wheels/wheels-comments.js',
Expand All @@ -132,7 +95,7 @@ var Truck_Wheel_Files = [
'truck-engine/event-aliases.js',
'truck-engine/gestures.js',
'truck-engine/plugins.js',
'truck-engine/mediator.js',
'truck-engine/dispatcher.js',
'truck-engine/promises.js',
'truck-engine/fetch.js',
'truck-engine/formatters.js',
Expand All @@ -148,9 +111,10 @@ var Truck_Engine_Files = [
'truck-engine/event-aliases.js',
'truck-engine/gestures.js',
'truck-engine/plugins.js',
'truck-engine/dispatcher.js',
'truck-engine/stack.js',
'truck-engine/mediator.js',
'truck-engine/model.js',
'truck-engine/mediator.js',
'truck-engine/view.js',
'truck-engine/screens.js',
'truck-engine/router.js',
Expand All @@ -166,15 +130,32 @@ var Truck_Engine_Files = [
var Truck_MVC_Files = [
/* Truck MVP Components */
'truck-engine/plugins.js',
'truck-engine/dispatcher.js',
'truck-engine/stack.js',
'truck-engine/mediator.js',
'truck-engine/model.js',
'truck-engine/mediator.js',
'truck-engine/view.js',
'truck-engine/box.js'
].map(function(file) {
return path.join(filePathStart, file);
});

var Truck_Body_Files = [
{os: 'android', src: 'src/js/truck-body/truck-android.css'},
{os: 'ios', src: 'src/js/truck-body/truck-ios.css'},
{os: 'windows', src: 'src/js/truck-body/truck-windows.css'}
];


// Define CSS paths:
cssDirectory = 'src/truck-chassis/';
var cssFiles = [
'truck-android.css',
'truck-ios.css',
'truck-windows.css'
].map(function (f) {
return path.join(cssDirectory, f);
});

// Concat, minify and output JavaScript:
gulp.task('js', function () {
Expand All @@ -185,7 +166,7 @@ gulp.task('js', function () {
.pipe(concat('truck-wheels.js'))
.pipe(beautify({indentSize: 2, braceStyle: "collapse", spaceBeforeConditional: true}))
.pipe(gulp.dest('dist/'))
.pipe(uglify({ mangle: false }))
.pipe(jsmin())
.pipe(rename("truck-wheels.min.js"))
.pipe(gulp.dest('dist/'));

Expand All @@ -196,7 +177,7 @@ gulp.task('js', function () {
.pipe(concat('truck-engine.js'))
.pipe(beautify({indentSize: 2, braceStyle: "collapse", spaceBeforeConditional: true}))
.pipe(gulp.dest('dist/'))
.pipe(uglify({ mangle: false }))
.pipe(jsmin())
.pipe(rename("truck-engine.min.js"))
.pipe(gulp.dest('dist/'));

Expand All @@ -206,120 +187,9 @@ gulp.task('js', function () {
.pipe(concat('truck-tank.js'))
.pipe(beautify({indentSize: 2, braceStyle: "collapse", spaceBeforeConditional: true}))
.pipe(gulp.dest('dist/'))
.pipe(uglify({ mangle: false }))
.pipe(jsmin())
.pipe(rename("truck-tank.min.js"))
.pipe(gulp.dest('dist/'));

} else if ( gutils.env.minimum) {
console.log('We are building a minimum version of Truck for you.');
if (gutils.env.extras) {
var extra = gutils.env.extras
var extras = extra.split(' ');
if (extras.indexOf('promises') < 0 && (extras.indexOf('fetch') || extras.indexOf('box'))) {
console.log('Adding promises');
extras.push('promises');
}
if (extras.indexOf('validators') < 0 && extras.indexOf('form')) {
extras.push('validators');
}
if (extras.indexOf('block') < 0 && (extras.indexOf('activityindicator') || extras.indexOf('popup') || extras.indexOf('popover'))) {
extras.push('block');
}
extras.forEach(function(feature) {
console.log('Add feature: ' + feature);
switch(feature) {
case 'promises':
Min_Build.push(path.join(filePathStart, 'truck-engine', 'promises' + '.js'));
return;
case 'fetch':
Min_Build.push(path.join(filePathStart, 'truck-engine', 'fetch' + '.js'));
return;
case 'validators':
Min_Build.push(path.join(filePathStart, 'truck-engine', 'validators' + '.js'));
return;
case 'box':
Min_Build.push(path.join(filePathStart, 'truck-engine', 'box' + '.js'));
return;
case 'anim':
Min_Build.push(path.join(filePathStart, 'truck-engine', 'anim' + '.js'));
return;
case 'oop':
Min_Build.push(path.join(filePathStart, 'truck-engine', 'oop' + '.js'));
return;
case 'tabbar':
Min_Build.push(path.join(filePathStart, 'truck-body', 'tabbar' + '.js'));
return;
case 'slideout':
Min_Build.push(path.join(filePathStart, 'truck-body', 'slide-out' + '.js'));
return;
case 'editable':
Min_Build.push(path.join(filePathStart, 'truck-body', 'editable' + '.js'));
return;
case 'form':
Min_Build.push(path.join(filePathStart, 'truck-body', 'form' + '.js'));
return;
case 'select':
Min_Build.push(path.join(filePathStart, 'truck-body', 'selectList' + '.js'));
return;
case 'multiSelect':
case 'multiselect':
Min_Build.push(path.join(filePathStart, 'truck-body', 'multiSelectList' + '.js'));
return;
case 'switch':
case 'switches':
Min_Build.push(path.join(filePathStart, 'truck-body', 'switches' + '.js'));
return;
case 'popup':
Min_Build.push(path.join(filePathStart, 'truck-body', 'popup' + '.js'));
return;
case 'popover':
Min_Build.push(path.join(filePathStart, 'truck-body', 'popover' + '.js'));
return;
case 'segmented':
Min_Build.push(path.join(filePathStart, 'truck-body', 'segmented' + '.js'));
return;
case 'range':
Min_Build.push(path.join(filePathStart, 'truck-body', 'range' + '.js'));
return;
case 'sheets':
Min_Build.push(path.join(filePathStart, 'truck-body', 'sheets' + '.js'));
return;
case 'paging':
Min_Build.push(path.join(filePathStart, 'truck-body', 'paging' + '.js'));
return;
case 'stepper':
Min_Build.push(path.join(filePathStart, 'truck-body', 'stepper' + '.js'));
return;
case 'busy':
case 'activityIndicator':
Min_Build.push(path.join(filePathStart, 'truck-body', 'activityIndicator' + '.js'));
return;
}
});

}
gulp.src(Min_Build)
.pipe(concat('truck.js'))
.pipe(beautify({indentSize: 2, braceStyle: "collapse", spaceBeforeConditional: true}))
.pipe(gulp.dest('dist/'))
.pipe(uglify({ mangle: false }))
.pipe(rename("truck.min.js"))
.pipe(gulp.dest('dist/'));

gulp.src(Min_Build)
.pipe(concat('truck.js'))
.pipe(gulp.dest('dist/'));

// Define CSS paths:
typescriptDirectory = 'src/truck-chassis/';
var cssFiles = [
'truck-android.css',
'truck-ios.css',
'truck-windows.css'
].map(function (f) {
return path.join(typescriptDirectory, f);
});

} else {
// Print out Truck image:
console.log('');
Expand All @@ -336,42 +206,40 @@ gulp.task('js', function () {
console.log(' ');
console.log('Hold on tight. We\'re building your TruckJS now.');

// Define CSS paths:
var cssDirectory = 'src/truck-chassis/';
var cssFiles = [
'truck-android.css',
'truck-ios.css',
'truck-windows.css'
].map(function (f) {
return path.join(cssDirectory, f);
});

gulp.src(Truck_Files)
gulp.src(Truck_Files)
.pipe(concat('truck.js'))
.pipe(beautify({indentSize: 2, braceStyle: "collapse", spaceBeforeConditional: true}))
.pipe(gulp.dest('dist/'))
.pipe(uglify({ mangle: false }))
.pipe(jsmin())
.pipe(rename("truck.min.js"))
.pipe(gulp.dest('dist/'));

gulp.src(Truck_Files)
.pipe(concat('truck.js'))
.pipe(gulp.dest('dist/'));

cssFiles.forEach(function(file, idx) {
gulp.src(file)
.pipe(gulp.dest('dist/styles'))
.pipe(cssnano({safe: true}))
.pipe(rename(osTypes[idx] + '.min.css'))
.pipe(gulp.dest('dist/styles'));
});
gulp.src('src/truck-chassis/*.css')
.pipe(gulp.dest('dist/styles'))
.pipe(minifyCSS({}))
.pipe(rename('*.min.css'))
.pipe(gulp.dest('dist/styles'));
}

gulp.src('src/truck-chassis/*.css')
.pipe(gulp.dest('dist/styles'));


cssFiles.forEach(function(file, idx) {
console.log(file)
gulp.src(file)
.pipe(gulp.dest('dist/styles'))
.pipe(minifyCSS({}))
.pipe(rename(osTypes[idx] + '.min.css'))
.pipe(gulp.dest('dist/styles'));
});
});

/*
Four ways to build. Default will build Truck with everything.
Using gulp --mvc will build only the mvc parts.
Using gulp --wheels
Using gulp --wheel
Using gulp --tank
Using gulp --engine
*/
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@
"colors": "^1.1.2",
"gulp": "~3.9.0",
"gulp-concat": "~2.1.7",
"gulp-cssnano": "^2.1.1",
"gulp-footer": "~1.0.2",
"gulp-gzip": "^1.2.0",
"gulp-header": "~1.2.2",
"gulp-jsbeautifier": "^1.0.1",
"gulp-jshint": "~1.3.4",
"gulp-jsmin": "^0.1.5",
"gulp-minify-css": "^1.2.1",
"gulp-rename": "~0.2.1",
"gulp-typescript": "^2.7.8",
"gulp-uglify": "^1.5.1",
"gulp-util": "~2.2.10",
"stream-combiner2": "^1.1.1"
}
Expand Down

0 comments on commit d6325e5

Please sign in to comment.