Skip to content

Commit

Permalink
Merge 6b599ba into e87c3b9
Browse files Browse the repository at this point in the history
  • Loading branch information
morleyzhi committed Jan 24, 2019
2 parents e87c3b9 + 6b599ba commit e546db6
Show file tree
Hide file tree
Showing 36 changed files with 5,299 additions and 2,925 deletions.
29 changes: 29 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
extends: ['airbnb-base', 'prettier'],
plugins: ['prettier'],
rules: {
// OFF
'import/prefer-default-export': 0,
camelcase: 0,
'class-methods-use-this': 0,
'linebreak-style': 0,
'no-underscore-dangle': 0,
'no-use-before-define': 0,
'prefer-destructuring': 0,
'lines-between-class-members': 0,

// WARN
'no-console': ['warn', { allow: ['assert'] }],
'no-debugger': 1,
'no-unused-vars': 1,
'arrow-body-style': 1,
'valid-jsdoc': [1],
'prefer-const': 1,
'object-shorthand': 1,
'require-await': 1,

// ERROR
'no-unused-expressions': [2, { allowTaggedTemplates: true }],
},
parser: 'babel-eslint',
};
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package.json
node_modules
lib
dist
gulpfile.js
60 changes: 30 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
language: node_js
matrix:
include:
- node_js: 6.9.4
- node_js: 6.9.4
env: SAUCE=true
- node_js: 6.9.4
env: INTEGRATION=true
- node_js: 6.14.0
- node_js: 6.14.0
env: SAUCE=true
- node_js: 6.14.0
env: INTEGRATION=true
script:
- |
echo "machine github.com login stellar-jenkins password $GITHUB_TOKEN" >~/.netrc
git config --global user.name "Travis CI"
git config --global user.email "travis@stellar.org"
if [ "${SAUCE}" = "true" ]; then
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
gulp test:sauce
- |
echo "machine github.com login stellar-jenkins password $GITHUB_TOKEN" >~/.netrc
git config --global user.name "Travis CI"
git config --global user.email "travis@stellar.org"
if [ "${SAUCE}" = "true" ]; then
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
babel-node ./node_modules/gulp/bin/gulp.js test:sauce
else
echo "Pull request - skip Sauce Labs testing..."
fi
elif [ "${INTEGRATION}" = "true" ]; then
# Ugly but it's the only way to make istanbul generate coverage report
babel-node ./node_modules/gulp/bin/gulp.js test:integration
else
echo "Pull request - skip Sauce Labs testing..."
babel-node ./node_modules/gulp/bin/gulp.js test:unit
fi
elif [ "${INTEGRATION}" = "true" ]; then
# Ugly but it's the only way to make istanbul generate coverage report
babel-node ./node_modules/gulp/bin/gulp.js test:integration
else
gulp test:unit
fi
after_success:
- |
# Send report to coveralls but only once
if [ "${INTEGRATION}" = "true" ] && [ "${TRAVIS_BRANCH}" = "master" ] ; then
gulp submit-coverage
fi
- |
# Send report to coveralls but only once
if [ "${INTEGRATION}" = "true" ] && [ "${TRAVIS_BRANCH}" = "master" ] ; then
babel-node ./node_modules/gulp/bin/gulp.js submit-coverage
fi
env:
global:
- secure: Pc3DwkXywnOGAhUdBZiUCKjyljzrQzPoqm9EEr+UL2BaeaDniFLCLEkuU+ViiuJBo8oPyOIl7I+d86Mi5q06fQx55+xH7DmiW/aj4qKVB2U6Ghn6A3QWkQuvRB1o8SP7iTYRCX480ULZs6AGrMd9y1PFRx/L93fBrO+J/bOtEmg=
- secure: Pc3DwkXywnOGAhUdBZiUCKjyljzrQzPoqm9EEr+UL2BaeaDniFLCLEkuU+ViiuJBo8oPyOIl7I+d86Mi5q06fQx55+xH7DmiW/aj4qKVB2U6Ghn6A3QWkQuvRB1o8SP7iTYRCX480ULZs6AGrMd9y1PFRx/L93fBrO+J/bOtEmg=
notifications:
slack:
secure: CgXxNEQrQ82EatyF/wSdF0P5rXcWPL+fFZ1lb1aBb8RbVt5gwddJ6xWVD/nYSr6tIJvIYHYhoYsIDPENwezIPsesG7kWXerQhydsEcA34JKxzsStd/TmU6Moxuwy6KTN7yzmL6586nSvoAw9TNPgvRkJFkH07asjGIc9Rlaq7/Y=
before_deploy: gulp build
after_deploy: "./after_deploy.sh"
before_deploy: babel-node ./node_modules/gulp/bin/gulp.js build
after_deploy: './after_deploy.sh'
deploy:
- provider: npm
email: npm@stellar.org
Expand All @@ -47,12 +47,12 @@ deploy:
tags: true
repo: stellar/js-stellar-sdk
node: 6.9.4
condition: "$INTEGRATION = true"
condition: '$INTEGRATION = true'
- provider: script
script: "./bower_publish.sh"
script: './bower_publish.sh'
skip_cleanup: true
on:
tags: true
repo: stellar/js-stellar-sdk
node: 6.9.4
condition: "$INTEGRATION = true"
condition: '$INTEGRATION = true'
187 changes: 112 additions & 75 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,139 +1,176 @@
'use strict';

var gulp = require('gulp');
var isparta = require('isparta');
var plugins = require('gulp-load-plugins')();
var gulp = require('gulp');
var isparta = require('isparta');
var plugins = require('gulp-load-plugins')();
var runSequence = require('run-sequence');
var server = require('gulp-develop-server' );
var webpack = require("webpack");
var exec = require('child_process').exec;
var fs = require("fs");
var server = require('gulp-develop-server');
var webpack = require('webpack');
var fs = require('fs');
var clear = require('clear');

gulp.task('default', ['build']);

gulp.task('lint:src', function() {
return gulp.src(['src/**/*.js'])
.pipe(plugins.plumber())
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('jshint-stylish'))
.pipe(plugins.jshint.reporter('fail'));
clear();
return gulp
.src(['src/**/*.js'])
.pipe(plugins.eslint())
.pipe(plugins.eslint.format())
.pipe(plugins.eslint.failAfterError());
});

// Lint our test code
gulp.task('lint:test', function() {
return gulp.src(['test/unit/**/*.js'])
.pipe(plugins.plumber())
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('jshint-stylish'))
.pipe(plugins.jshint.reporter('fail'));
return gulp
.src(['test/unit/**/*.js'])
.pipe(plugins.eslint())
.pipe(plugins.eslint.format())
.pipe(plugins.eslint.failAfterError());
});

// this task doesn't fail on error so it doesn't break a watch loop
gulp.task('lint-for-watcher:src', function() {
clear();
return gulp
.src(['src/**/*.js'])
.pipe(plugins.eslint())
.pipe(plugins.eslint.format())
.pipe(plugins.eslint.failAfterError());
});

gulp.task('lint:watch', ['lint-for-watcher:src'], function() {
gulp.watch('src/**/*', ['lint-for-watcher:src']);
});

gulp.task('build', function(done) {
runSequence('clean', 'build:node', 'build:browser', done);
});

gulp.task('test', function(done) {
runSequence('clean', 'test:unit', 'test:browser', function (err) {
runSequence('clean', 'test:unit', 'test:browser', function(err) {
server.kill();
done();
});
});


gulp.task('hooks:precommit', ['build'], function() {
return gulp.src(['dist/*', 'lib/*'])
.pipe(plugins.git.add());
return gulp.src(['dist/*', 'lib/*']).pipe(plugins.git.add());
});

gulp.task('build:node', ['lint:src'], function() {
return gulp.src('src/**/*.js')
.pipe(plugins.babel())
.pipe(gulp.dest('lib'));
return gulp
.src('src/**/*.js')
.pipe(plugins.babel())
.pipe(gulp.dest('lib'));
});

gulp.task('build:browser', ['lint:src'], function() {
return gulp.src('src/browser.js')
.pipe(plugins.webpack({
output: { library: 'StellarSdk' },
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'}
],
},
plugins: [
// Ignore native modules (ed25519)
new webpack.IgnorePlugin(/ed25519/)
]
}))
// Add EventSource polyfill for IE11
.pipe(plugins.insert.prepend(fs.readFileSync('./node_modules/event-source-polyfill/src/eventsource.min.js')))
.pipe(plugins.rename('stellar-sdk.js'))
.pipe(gulp.dest('dist'))
.pipe(plugins.uglify({
output: {
ascii_only: true
}
}))
.pipe(plugins.rename('stellar-sdk.min.js'))
.pipe(gulp.dest('dist'));
});

gulp.task('test:init-istanbul', ['clean-coverage'], function () {
return gulp.src(['src/**/*.js'])
.pipe(plugins.istanbul({
instrumenter: isparta.Instrumenter
}))
return (
gulp
.src('src/browser.js')
.pipe(
plugins.webpack({
output: { library: 'StellarSdk' },
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
],
},
plugins: [
// Ignore native modules (ed25519)
new webpack.IgnorePlugin(/ed25519/),
],
}),
)
// Add EventSource polyfill for IE11
.pipe(
plugins.insert.prepend(
fs.readFileSync(
'./node_modules/event-source-polyfill/src/eventsource.min.js',
),
),
)
.pipe(plugins.rename('stellar-sdk.js'))
.pipe(gulp.dest('dist'))
.pipe(
plugins.uglify({
output: {
ascii_only: true,
},
}),
)
.pipe(plugins.rename('stellar-sdk.min.js'))
.pipe(gulp.dest('dist'))
);
});

gulp.task('test:init-istanbul', ['clean-coverage'], function() {
return gulp
.src(['src/**/*.js'])
.pipe(
plugins.istanbul({
instrumenter: isparta.Instrumenter,
}),
)
.pipe(plugins.istanbul.hookRequire());
});

gulp.task('test:integration', ['build:node', 'test:init-istanbul'], function() {
return gulp.src(["test/test-helper.js", "test/unit/**/*.js", "test/integration/**/*.js"])
.pipe(plugins.mocha({
reporter: ['spec']
}))
return gulp
.src([
'test/test-helper.js',
'test/unit/**/*.js',
'test/integration/**/*.js',
])
.pipe(
plugins.mocha({
reporter: ['spec'],
}),
)
.pipe(plugins.istanbul.writeReports());
});

gulp.task('test:unit', ['build:node'], function() {
return gulp.src(["test/test-helper.js", "test/unit/**/*.js"])
.pipe(plugins.mocha({
reporter: ['spec']
}));
return gulp.src(['test/test-helper.js', 'test/unit/**/*.js']).pipe(
plugins.mocha({
reporter: ['spec'],
}),
);
});


gulp.task('test:browser', ["build:browser"], function (done) {
gulp.task('test:browser', ['build:browser'], function(done) {
var Server = require('karma').Server;
var server = new Server({ configFile: __dirname + '/karma.conf.js' });
server.start(function() {
done();
});
});

gulp.task('test:sauce', ["build:browser"], function (done) {
gulp.task('test:sauce', ['build:browser'], function(done) {
var Server = require('karma').Server;
var server = new Server({ configFile: __dirname + '/karma-sauce.conf.js' });
server.start(function() {
done();
});
});

gulp.task('clean', function () {
return gulp.src('dist', { read: false })
.pipe(plugins.rimraf());
gulp.task('clean', function() {
return gulp.src('dist', { read: false }).pipe(plugins.rimraf());
});

gulp.task('watch', ['build'], function() {
gulp.watch('lib/**/*', ['build']);
});

gulp.task('clean-coverage', function() {
return gulp.src(['coverage'], { read: false })
.pipe(plugins.rimraf());
return gulp.src(['coverage'], { read: false }).pipe(plugins.rimraf());
});

gulp.task('submit-coverage', function() {
return gulp
.src("./coverage/**/lcov.info")
.pipe(plugins.coveralls());
return gulp.src('./coverage/**/lcov.info').pipe(plugins.coveralls());
});

0 comments on commit e546db6

Please sign in to comment.