Skip to content

Commit

Permalink
Create viewer dir for deploy to gh pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ebidel committed Dec 10, 2016
1 parent 11e41a3 commit 1dd327a
Show file tree
Hide file tree
Showing 3 changed files with 3,177 additions and 12 deletions.
40 changes: 29 additions & 11 deletions lighthouse-viewer/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ const gulpLoadPlugins = require('gulp-load-plugins');
const runSequence = require('run-sequence');
const browserify = require('browserify');
const closure = require('google-closure-compiler-js').gulp();
const ghPages = require('gulp-gh-pages');
const ghpages = require('gh-pages');

const $ = gulpLoadPlugins();

const DIST_FOLDER = 'dist';

function license() {
return $.license('Apache', {
organization: 'Copyright 2016 Google Inc. All rights reserved.',
Expand All @@ -52,27 +54,27 @@ gulp.task('lint', () => {

gulp.task('images', () => {
return gulp.src('app/images/**/*')
.pipe(gulp.dest('dist/images'));
.pipe(gulp.dest(`${DIST_FOLDER}/images`));
});

gulp.task('css', () => {
return gulp.src([
'app/styles/**/*.css',
'../lighthouse-core/report/styles/report.css'
])
.pipe(gulp.dest('dist/styles'));
.pipe(gulp.dest(`${DIST_FOLDER}/styles`));
});

gulp.task('html', () => {
return gulp.src('app/*.html').pipe(gulp.dest('dist'));
return gulp.src('app/*.html').pipe(gulp.dest(DIST_FOLDER));
});

gulp.task('polyfills', () => {
return gulp.src([
'node_modules/url-search-params/build/url-search-params.js',
'node_modules/whatwg-fetch/fetch.js'
])
.pipe(gulp.dest('dist/src/polyfills'));
.pipe(gulp.dest(`${DIST_FOLDER}/src/polyfills`));
});

gulp.task('browserify', () => {
Expand All @@ -86,12 +88,12 @@ gulp.task('browserify', () => {
// Inject transformed browserified content back into our gulp pipeline.
file.contents = bundle.bundle();
}))
.pipe(gulp.dest('dist/src'));
.pipe(gulp.dest(`${DIST_FOLDER}/src`));
});

gulp.task('compile', ['browserify'], () => {
return gulp.src([
'dist/src/main.js'
`${DIST_FOLDER}/src/main.js`
])
// .pipe($.sourcemaps.init())
.pipe(closure({
Expand All @@ -106,11 +108,11 @@ gulp.task('compile', ['browserify'], () => {
.pipe($.uglify()) // Use uglify to strip out duplicated license headers.
.pipe(license()) // Add license to top.
// .pipe($.sourcemaps.write('/'))
.pipe(gulp.dest('dist/src'));
.pipe(gulp.dest(`${DIST_FOLDER}/src`));
});

gulp.task('clean', () => {
return del(['dist']).then(paths =>
return del([DIST_FOLDER]).then(paths =>
paths.forEach(path => $.util.log('deleted:', $.util.colors.blue(path)))
);
});
Expand All @@ -135,8 +137,24 @@ gulp.task('watch', ['lint', 'browserify', 'polyfills', 'html', 'images', 'css'],
], ['browserify']);
});

gulp.task('deploy', ['build'], () => {
return gulp.src('dist/**/*').pipe(ghPages());
gulp.task('create-dir-for-gh-pages', () => {
del.sync([`${DIST_FOLDER}/viewer`]);

return gulp.src([`${DIST_FOLDER}/**/*`])
.pipe(gulp.dest(`${DIST_FOLDER}/viewer/viewer`));
});

gulp.task('deploy', cb => {
runSequence('build', 'create-dir-for-gh-pages', function() {
ghpages.publish(`${DIST_FOLDER}/viewer`, {
logger: $.util.log
}, err => {
if (err) {
$.util.log(err);
}
cb();
});
});
});

gulp.task('build', cb => {
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"browserify": "^13.0.0",
"del": "^2.2.0",
"eslint-config-xo": "^0.10.1",
"gh-pages": "^0.12.0",
"google-closure-compiler-js": "^20161024.0.0",
"gulp": "^3.9.1",
"gulp-eslint": "^2.0.0",
"gulp-gh-pages": "^0.5.4",
"gulp-license": "^1.1.0",
"gulp-load-plugins": "^1.4.0",
"gulp-sourcemaps": "^1.9.1",
Expand Down
Loading

0 comments on commit 1dd327a

Please sign in to comment.