Skip to content

Commit

Permalink
Merge pull request #949 from prose/travis-ci-merge
Browse files Browse the repository at this point in the history
Pushes to master trigger deployment via travis
  • Loading branch information
dereklieu committed Apr 28, 2016
2 parents a4f61d9 + 008a727 commit 7ec3224
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 3,237 deletions.
22 changes: 22 additions & 0 deletions .build_scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -e # halt script on error

# If this is the deploy branch, push it up to gh-pages
echo "${DEPLOY_BRANCH}"
echo "${GH_REF}"
if [ $TRAVIS_PULL_REQUEST = "false" ] && [ $TRAVIS_BRANCH = ${DEPLOY_BRANCH} ]; then
echo "Get ready, we're pushing to gh-pages!"
mkdir site
cp -a dist site
cp -a img fonts index.html style-rtl.css locale.js site
cd site
git init
git config user.name "Travis-CI"
git config user.email "travis@somewhere.com"
cp ../CNAME .
git add .
git commit -m "CI deploy to gh-pages"
git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:gh-pages
else
echo "Not a publishable branch so we're all done here"
fi
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.DS_Store
node_modules/
dist/*
dist
transifex.auth
oauth.json
.vimrc
test/lib/index.js
_site/
test/lib
_site
22 changes: 20 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
language: node_js
node_js:
- '4.2'
notifications:
email: false
env:
global:
- GH_REF=github.com/prose/prose.git
- DEPLOY_BRANCH=master
- secure: R+ZWJe6XOXit4QKOeQqlHw20k6CDuqDXEHo3SSkkdsEax+cWxIaKPv8C9zp+IA8SM32uz6DNkfo5wGUJ/HCUE/S3WZqlr7qijroshjsmcZPRx6+TxVRzE1Xp0iMbeGibSCFZGrWlJmYgHnq5rQAFtjiztNhkSmkhuq3d9nsg8xM=
cache:
directories:
- node_modules
before_install:
- chmod +x ./.build_scripts/deploy.sh
before_script:
- npm test
script:
- npm run build
deploy:
provider: script
skip_cleanup: true
script: .build_scripts/deploy.sh
on:
branch: ${DEPLOY_BRANCH}
150 changes: 60 additions & 90 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// Build file.
// Usage:
//
// $ gulp
//
// See: https://github.com/prose/prose/issues/702

// Require dependencies.
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
Expand All @@ -14,7 +6,10 @@ var browserify = require('browserify');
var rename = require('gulp-rename');
var del = require('del');
var watch = require('gulp-watch');
var gulpif = require('gulp-if');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var merge2 = require('merge2');
var mkdirp = require('mkdirp');
var sass = require('gulp-sass');
var nodeJS = process.execPath;
Expand All @@ -40,13 +35,22 @@ var paths = {
]
};

function isProd () {
return process.env.PROSE_ENV === 'production';
}

gulp.task('setProductionEnv', function () {
return process.env.PROSE_ENV = 'production';
});

var dist = './dist';
var dev = './';

// Removes `dist` folder.
gulp.task('clean', function (cb) {
del(['dist'], cb);
return del([dist], cb);
});


// Translations.
// To run this task we have to have a `transifex.auth`
// file inside `translations` folder.
Expand All @@ -60,7 +64,7 @@ gulp.task('clean', function (cb) {
// An account can be created at https://www.transifex.com/
//
gulp.task('translations', function () {
mkdirp('dist');
mkdirp(dist);
return gulp.src('')
.pipe(
shell([
Expand All @@ -70,20 +74,17 @@ gulp.task('translations', function () {
);
});


// Default tasks.
// ---------------------------

// Parse stylesheet
gulp.task('css', function () {
return gulp.src('./style/style.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./'));
.pipe(rename('prose.css'))
.pipe(gulp.dest(dist));
});

// Build templates.
gulp.task('templates', function () {
mkdirp('dist');
mkdirp(dist);
return gulp.src('')
.pipe(
shell([
Expand All @@ -92,11 +93,10 @@ gulp.task('templates', function () {
);
});


// Creates `dist` directory if not created and
// creates `oauth.json`.
gulp.task('oauth', function () {
mkdirp('dist');
mkdirp(dist);
return gulp.src('')
.pipe(
shell([
Expand All @@ -105,92 +105,62 @@ gulp.task('oauth', function () {
);
});



// Concatenate vendor scripts into dist/vendor.js
gulp.task('vendor', function() {
gulp.src(paths.vendorScripts)
.pipe(concat('vendor.js'))
.pipe(gulp.dest('dist/'));
})


// Build tests.
gulp.task('build-tests', ['templates', 'oauth', 'vendor'], function() {

// Browserify index.js
// Pass `debug` option to enable source maps.
return browserify({
debug: true,
noParse: [require.resolve('handsontable/dist/handsontable.full')]
})
.add('./test/index.js')
.external(['chai', 'mocha'])
.bundle()
.pipe(source('index.js')) // Output file.
.pipe(gulp.dest('./test/lib/')); // Output folder.

// Build tests, then concatenate with vendor scripts
gulp.task('build-tests', ['templates', 'oauth'], function() {
var tests = browserify({
debug: true,
noParse: [require.resolve('handsontable/dist/handsontable.full')]
})
.add('./test/index.js')
.external(['chai', 'mocha'])
.bundle()
.pipe(source('index.js'))
.pipe(buffer());

return merge2(gulp.src(paths.vendorScripts), tests)
.pipe(concat('index.js'))
.pipe(gulp.dest('./test/lib'));
});


// Browserify app scripts, then concatenate with vendor scripts into `prose.js`.
gulp.task('build-app', ['templates', 'oauth', 'vendor'], function() {

// Browserify app scripts.
return browserify({
noParse: [require.resolve('handsontable/dist/handsontable.full')]
})
.add('./app/boot.js')
.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest('./dist/'))

// Concatenate scripts once browserify finishes.
.on('end', function() {

// Concatenate `vendor` and `app` scripts into `prose.js`.
return gulp.src(['dist/vendor.js', 'dist/app.js'])
.pipe(concat('prose.js'))
.pipe(gulp.dest('dist/'));
});

gulp.task('build-app', ['templates', 'oauth'], function() {
var app = browserify({
noParse: [require.resolve('handsontable/dist/handsontable.full')]
})
.add('./app/boot.js')
.bundle()
.pipe(source('app.js'))
.pipe(buffer());

return merge2(gulp.src(paths.vendorScripts), app)
.pipe(concat('prose.js'))
.pipe(gulpif(isProd(), uglify()))
.pipe(gulp.dest(dist));
});


// Compress `prose.js`.
gulp.task('uglify', ['build-app'], function() {

return gulp.src('dist/prose.js')
.pipe(rename('prose.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist'));
});


// Watch for changes in `app` scripts.
// Usage:
//
// $ gulp watch
//
gulp.task('watch', ['build-app', 'build-tests'], function() {
gulp.task('watch', ['build-app', 'build-tests', 'css'], function() {
// Watch any `.js` file under `app` folder.
gulp.watch(paths.app, ['build-app', 'build-tests']);
gulp.watch(paths.test, ['build-tests']);
gulp.watch(paths.templates, ['build-app']);
gulp.watch(paths.css, ['css']);
});


gulp.task('run-tests', ['build-tests'], shell.task([
var testTask = shell.task([
'./node_modules/mocha-phantomjs/bin/mocha-phantomjs test/index.html'
], {ignoreErrors: true}));
], {ignoreErrors: true});

gulp.task('test', ['build-tests'], testTask);

// Like watch, but actually run the tests whenever anything changes.
gulp.task('test', ['run-tests'], function() {
gulp.watch([paths.app, paths.test, paths.templates], ['run-tests'])
// Run tests in command line on app, test, or template change
gulp.task('test-ci', ['test'], function() {
gulp.watch([paths.app, paths.test, paths.templates], ['test'])
});

// Build site, tests
gulp.task('build', ['build-tests', 'build-app', 'css']);
gulp.task('default', ['build']);

// Default task which builds the project when we
// run `gulp` from the command line.
gulp.task('default', ['build-tests', 'build-app', 'css', 'uglify']);
// Minify build
gulp.task('production', ['setProductionEnv', 'build']);
12 changes: 6 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<meta name='apple-mobile-web-app-status-bar-style' content='white' />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>
<link rel='shortcut icon' href='./img/favicon.ico' type='image/x-icon' />
<link rel='apple-touch-icon' href='./img/prose@57.png' />
<link rel='apple-touch-icon' sizes="72x72" href='./img/prose@72.png' />
<link rel='apple-touch-icon' sizes="114x114" href='./img/prose@114.png' />
<link rel='apple-touch-icon' sizes="144x144" href='./img/prose@144.png' />
<link rel='shortcut icon' href='img/favicon.ico' type='image/x-icon' />
<link rel='apple-touch-icon' href='img/prose@57.png' />
<link rel='apple-touch-icon' sizes="72x72" href='img/prose@72.png' />
<link rel='apple-touch-icon' sizes="114x114" href='img/prose@114.png' />
<link rel='apple-touch-icon' sizes="144x144" href='img/prose@144.png' />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/handsontable/0.20.2/handsontable.full.min.css">
<link rel='stylesheet' href='./style.css'>
<link rel='stylesheet' href='dist/prose.css'>
</head>
<body>
<div id='prose'></div>
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
"glob": "~3.1.21",
"gulp": "^3.8.2",
"gulp-concat": "^2.2.0",
"gulp-if": "^2.0.0",
"gulp-rename": "^1.2.0",
"gulp-sass": "^2.2.0",
"gulp-shell": "^0.2.7",
"gulp-uglify": "^0.3.1",
"gulp-watch": "^0.6.8",
"merge2": "^1.0.2",
"mocha": "^2.4.5",
"mocha-phantomjs": "^4.0.2",
"phantomjs": "^2.1.7",
Expand All @@ -47,12 +49,14 @@
"sinon": "^1.17.2",
"sinon-chai": "^2.6.0",
"uglify-js": "~2.2.5",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^0.1.1"
},
"scripts": {
"test": "gulp run-tests",
"test-watch": "gulp test",
"start": "gulp watch & serve"
"test": "gulp test",
"test-ci": "gulp test-ci",
"start": "gulp watch & serve",
"build": "gulp clean; gulp production"
},
"browserify": {
"transform": [
Expand Down
Loading

0 comments on commit 7ec3224

Please sign in to comment.