Skip to content

Commit a7b640f

Browse files
committed
gulp file update
1 parent 12fa93a commit a7b640f

File tree

2 files changed

+120
-5
lines changed

2 files changed

+120
-5
lines changed

gulpfile.js

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
var gulp = require('gulp');
2+
var Server = require('karma').Server;
3+
4+
//plugins
5+
var debug = require('gulp-filelog');
6+
var connect = require('gulp-connect');
7+
var jshint = require('gulp-jshint');
8+
var uglify = require('gulp-uglify');
9+
var minifyCSS = require('gulp-minify-css');
10+
var gnf = require('gulp-npm-files');
11+
var clean = require('gulp-clean');
12+
var runSequence = require('run-sequence');
13+
var gulpDocs = require('gulp-ngdocs');
14+
15+
//generate code comment based documentation for the app
16+
gulp.task('ngdocs', [], function () {
17+
var options = {
18+
html5Mode: true,
19+
startPage: '/api',
20+
title: "Darksky Forecast Docs"
21+
}
22+
gulp.src('./docs/*')
23+
.pipe(clean({
24+
force: true
25+
}));
26+
gulp.src('app/**/*.js')
27+
.pipe(debug())
28+
.pipe(gulpDocs.process(options))
29+
.pipe(gulp.dest('./docs'));
30+
});
31+
32+
33+
// tasks
34+
gulp.task('lint', function () {
35+
gulp.src('./app/**/*.js')
36+
.pipe(jshint())
37+
.pipe(jshint.reporter('default'))
38+
.pipe(jshint.reporter('fail'));
39+
});
40+
gulp.task('clean', function () {
41+
gulp.src('./dist/*')
42+
.pipe(clean({
43+
force: true
44+
}));
45+
});
46+
gulp.task('minify-css', function () {
47+
var opts = {
48+
comments: true,
49+
spare: true
50+
};
51+
gulp.src(['./app/**/*.css', './app.css'])
52+
.pipe(minifyCSS(opts))
53+
.pipe(gulp.dest('./dist/'))
54+
});
55+
gulp.task('minify-js', function () {
56+
gulp.src('./app/**/*.js')
57+
.pipe(uglify())
58+
.pipe(gulp.dest('./dist/'))
59+
});
60+
gulp.task('copy-npm-dependencies', function () {
61+
gulp.src(gnf(), {
62+
base: './'
63+
})
64+
.pipe(gulp.dest('./dist/'));
65+
});
66+
gulp.task('copy-html-files', function () {
67+
gulp.src(['./app/**/*.html', './index.html'])
68+
.pipe(gulp.dest('dist/'));
69+
});
70+
// Run tests once and exit
71+
gulp.task('test', function (done) {
72+
new Server({
73+
configFile: './karma.conf.js',
74+
singleRun: true
75+
}, done).start();
76+
});
77+
78+
// detect changes on files and rerun tests
79+
gulp.task('tdd', function (done) {
80+
new Server({
81+
configFile: './karma.conf.js'
82+
}, done).start();
83+
});
84+
85+
//run this task for development
86+
gulp.task('connect', function () {
87+
connect.server({
88+
root: '.',
89+
port: 8000
90+
});
91+
});
92+
//run this task to see how the distribution files look before deployment
93+
gulp.task('connectDist', function () {
94+
connect.server({
95+
root: '.',
96+
port: 9000
97+
});
98+
});
99+
100+
101+
// default task
102+
gulp.task('default', ['lint', 'tdd', 'connect']);
103+
gulp.task('build', function () {
104+
runSequence(
105+
['clean'], ['test', 'lint', 'minify-css', 'minify-js', 'copy-html-files', 'copy-npm-dependencies', 'connectDist']
106+
);
107+
});

package.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
"version": "0.0.0",
44
"description": "a forecast from darksky",
55
"main": "app.js",
6-
"scripts": {
7-
"start": "http-server -a localhost -p 8000 -c-1 ."
8-
},
96
"author": "Ami",
107
"license": "MIT",
118
"dependencies": {
@@ -17,10 +14,21 @@
1714
"devDependencies": {
1815
"angular": "^1.6.3",
1916
"angular-mocks": "^1.6.3",
20-
"angular-ui-router": "^0.4.2",
17+
"angular-route": "^1.6.3",
18+
"gulp": "^3.9.1",
19+
"gulp-clean": "^0.3.2",
20+
"gulp-connect": "^5.0.0",
21+
"gulp-filelog": "^0.4.1",
22+
"gulp-jshint": "^2.0.4",
23+
"gulp-minify-css": "^1.2.4",
24+
"gulp-ngdocs": "^0.3.0",
25+
"gulp-npm-files": "^0.1.3",
26+
"gulp-uglify": "^2.1.0",
2127
"jasmine-core": "^2.5.2",
28+
"jshint": "^2.9.4",
2229
"karma": "^1.5.0",
2330
"karma-chrome-launcher": "^2.0.0",
24-
"karma-jasmine": "^1.1.0"
31+
"karma-jasmine": "^1.1.0",
32+
"run-sequence": "^1.2.2"
2533
}
2634
}

0 commit comments

Comments
 (0)