Skip to content

Commit

Permalink
project structure updated (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Jackowski committed Jul 25, 2016
1 parent abf850f commit 9599ab0
Show file tree
Hide file tree
Showing 76 changed files with 1,271 additions and 74 deletions.
3 changes: 3 additions & 0 deletions .babelrc
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
11 changes: 11 additions & 0 deletions .eslintrc
@@ -0,0 +1,11 @@
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"rules": {},
"env": {
"browser": true,
"node": true
}
}
34 changes: 24 additions & 10 deletions .gitignore
@@ -1,17 +1,31 @@
#project specific
inputs.txt
nbproject/
node_modules/
webpack
mocha
repl
dist/

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# Commenting this out is preferred by some people, see
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules
bower_components
coverage
tmp

# Users Environment Variables
.lock-wscript
18 changes: 7 additions & 11 deletions .travis.yml
@@ -1,14 +1,10 @@
language: node_js
node_js:
- "6"
before_install:
- rvm install ruby --latest
- gem install zendesk_apps_tools

script:
- npm test
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then npm run-script build-webpack; fi
- if [[ "$TRAVIS_TAG" == "$RELEASE_TAG" ]]; then zat; fi

- "4"
- "5"
- "stable"
sudo: false
script: "gulp coverage"
after_success:
- echo "Success - Branch($TRAVIS_BRANCH) Pull Request($TRAVIS_PULL_REQUEST) Tag($TRAVIS_TAG)"
- npm install -g codeclimate-test-reporter
- codeclimate-test-reporter < coverage/lcov.info
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,3 @@
### [0.0.1](https://github.com/matthewjackowski/custard-moon/releases/tag/v0.0.1)

- The first release
1 change: 1 addition & 0 deletions gulp
202 changes: 202 additions & 0 deletions gulpfile.js
@@ -0,0 +1,202 @@
const gulp = require('gulp');
const loadPlugins = require('gulp-load-plugins');
const del = require('del');
const glob = require('glob');
const path = require('path');
const isparta = require('isparta');
const webpack = require('webpack');
const webpackStream = require('webpack-stream');

const Instrumenter = isparta.Instrumenter;
const mochaGlobals = require('./test/setup/.globals');
const manifest = require('./package.json');

// Load all of our Gulp plugins
const $ = loadPlugins();

// Gather the library data from `package.json`
const config = manifest.babelBoilerplateOptions;
const mainFile = manifest.main;
const destinationFolder = path.dirname(mainFile);
const exportFileName = path.basename(mainFile, path.extname(mainFile));

function cleanDist(done) {
del([destinationFolder]).then(() => done());
}

function cleanTmp(done) {
del(['tmp']).then(() => done());
}

// Lint a set of files
function lint(files) {
return gulp.src(files)
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failAfterError());
}

function lintSrc() {
return lint('src/**/*.js');
}

function lintTest() {
return lint('test/**/*.js');
}

function lintGulpfile() {
return lint('gulpfile.js');
}

function build() {
return gulp.src(path.join('src', config.entryFileName))
.pipe(webpackStream({
output: {
filename: exportFileName + '.js',
libraryTarget: 'umd',
library: config.mainVarName
},
// Add your own externals here. For instance,
// {
// jquery: true
// }
// would externalize the `jquery` module.
externals: {},
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }
]
},
devtool: 'source-map'
}))
.pipe(gulp.dest(destinationFolder))
.pipe($.filter(['**', '!**/*.js.map']))
.pipe($.rename(exportFileName + '.min.js'))
.pipe($.sourcemaps.init({ loadMaps: true }))
.pipe($.uglify())
.pipe($.sourcemaps.write('./'))
.pipe(gulp.dest(destinationFolder));
}

function _mocha() {
return gulp.src(['test/setup/node.js', 'test/unit/**/*.js'], {read: false})
.pipe($.mocha({
reporter: 'dot',
globals: Object.keys(mochaGlobals.globals),
ignoreLeaks: false
}));
}

function _registerBabel() {
require('babel-register');
}

function test() {
_registerBabel();
return _mocha();
}

function coverage(done) {
_registerBabel();
gulp.src(['src/**/*.js'])
.pipe($.istanbul({
instrumenter: Instrumenter,
includeUntested: true
}))
.pipe($.istanbul.hookRequire())
.on('finish', () => {
return test()
.pipe($.istanbul.writeReports())
.on('end', done);
});
}

const watchFiles = ['src/**/*', 'test/**/*', 'package.json', '**/.eslintrc'];

// Run the headless unit tests as you make changes.
function watch() {
gulp.watch(watchFiles, ['test']);
}

function testBrowser() {
// Our testing bundle is made up of our unit tests, which
// should individually load up pieces of our application.
// We also include the browser setup file.
const testFiles = glob.sync('./test/unit/**/*.js');
const allFiles = ['./test/setup/browser.js'].concat(testFiles);

// Lets us differentiate between the first build and subsequent builds
var firstBuild = true;

// This empty stream might seem like a hack, but we need to specify all of our files through
// the `entry` option of webpack. Otherwise, it ignores whatever file(s) are placed in here.
return gulp.src('')
.pipe($.plumber())
.pipe(webpackStream({
watch: true,
entry: allFiles,
output: {
filename: '__spec-build.js'
},
// Externals isn't necessary here since these are for tests.
module: {
loaders: [
// This is what allows us to author in future JavaScript
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
// This allows the test setup scripts to load `package.json`
{ test: /\.json$/, exclude: /node_modules/, loader: 'json-loader' }
]
},
plugins: [
// By default, webpack does `n=>n` compilation with entry files. This concatenates
// them into a single chunk.
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 })
],
devtool: 'inline-source-map'
}, null, function() {
if (firstBuild) {
$.livereload.listen({port: 35729, host: 'localhost', start: true});
var watcher = gulp.watch(watchFiles, ['lint']);
} else {
$.livereload.reload('./tmp/__spec-build.js');
}
firstBuild = false;
}))
.pipe(gulp.dest('./tmp'));
}

// Remove the built files
gulp.task('clean', cleanDist);

// Remove our temporary files
gulp.task('clean-tmp', cleanTmp);

// Lint our source code
gulp.task('lint-src', lintSrc);

// Lint our test code
gulp.task('lint-test', lintTest);

// Lint this file
gulp.task('lint-gulpfile', lintGulpfile);

// Lint everything
gulp.task('lint', ['lint-src', 'lint-test', 'lint-gulpfile']);

// Build two versions of the library
gulp.task('build', ['lint', 'clean'], build);

// Lint and run our tests
gulp.task('test', ['lint'], test);

// Set up coverage and run tests
gulp.task('coverage', ['lint'], coverage);

// Set up a livereload environment for our spec runner `test/runner.html`
gulp.task('test-browser', ['lint', 'clean-tmp'], testBrowser);

// Run the headless unit tests as you make changes.
gulp.task('watch', watch);

// An alias of test
gulp.task('default', ['test']);
13 changes: 0 additions & 13 deletions makefile
Expand Up @@ -4,23 +4,10 @@ init:
npm install;
ln -s ./node_modules/webpack/bin/webpack.js ./webpack

test:
@NODE_ENV=test ./node_modules/.bin/csslint ./src/app.css
@NODE_ENV=test ./node_modules/.bin/jshint ./src/*.js ./lib/*.js ./bin/*.js || echo
@NODE_ENV=test ./node_modules/mocha/bin/mocha \
--reporter $(REPORTER)

test-w:
@NODE_ENV=test ./node_modules/.bin/mocha \
--reporter $(REPORTER) \
--watch
run:
cd ./dist;cat ../inputs.txt | zat server;

package:
cd ./dist;zat package

build-webpack:
@NODE_ENV=test ./node_modules/webpack/bin/webpack.js

.PHONY: test test-w

0 comments on commit 9599ab0

Please sign in to comment.