Initial commit after running babel-generator

master
Robin Hawkes 2016-02-10 19:01:56 +00:00
commit 6ce2092ab5
19 zmienionych plików z 596 dodań i 0 usunięć

3
.babelrc 100644
Wyświetl plik

@ -0,0 +1,3 @@
{
"blacklist": ["useStrict"]
}

16
.editorconfig 100644
Wyświetl plik

@ -0,0 +1,16 @@
# EditorConfig is awesome: http://EditorConfig.org
root = true;
[*]
# Ensure there's no lingering whitespace
trim_trailing_whitespace = true
# Ensure a newline at the end of each file
insert_final_newline = true
[*.js]
# Unix-style newlines
end_of_line = lf
charset = utf-8
indent_style = space
indent_size = 2

11
.eslintrc 100644
Wyświetl plik

@ -0,0 +1,11 @@
{
"parser": "babel-eslint",
"rules": {
"strict": 0,
"quotes": [2, "single"]
},
"env": {
"browser": true,
"node": true
}
}

86
.gitignore vendored 100644
Wyświetl plik

@ -0,0 +1,86 @@
# Created by https://www.gitignore.io/api/node,osx,windows
### Node ###
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.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
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
node_modules
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
### OSX ###
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Windows ###
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk

6
.jscsrc 100644
Wyświetl plik

@ -0,0 +1,6 @@
{
"preset": "google",
"maximumLineLength": null,
"esnext": true,
"disallowSpacesInsideObjectBrackets": null
}

31
.npmignore 100644
Wyświetl plik

@ -0,0 +1,31 @@
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.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

10
.travis.yml 100644
Wyświetl plik

@ -0,0 +1,10 @@
language: node_js
node_js:
- "0.10"
- "0.12"
- "io.js"
sudo: false
script: "gulp coverage"
after_success:
- npm install -g codeclimate-test-reporter
- codeclimate-test-reporter < coverage/lcov.info

3
CHANGELOG.md 100644
Wyświetl plik

@ -0,0 +1,3 @@
### [0.3.0](https://github.com/vizicities/vizicities/releases/tag/v0.3.0)
- The first release

21
LICENSE 100644
Wyświetl plik

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 ViziCities <hello@vizicities.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

9
README.md 100644
Wyświetl plik

@ -0,0 +1,9 @@
# ViziCities
3D city and data visualisation platform
[![Travis build status](http://img.shields.io/travis/vizicities/vizicities.svg?style=flat)](https://travis-ci.org/vizicities/vizicities)
[![Code Climate](https://codeclimate.com/github/vizicities/vizicities/badges/gpa.svg)](https://codeclimate.com/github/vizicities/vizicities)
[![Test Coverage](https://codeclimate.com/github/vizicities/vizicities/badges/coverage.svg)](https://codeclimate.com/github/vizicities/vizicities)
[![Dependency Status](https://david-dm.org/vizicities/vizicities.svg)](https://david-dm.org/vizicities/vizicities)
[![devDependency Status](https://david-dm.org/vizicities/vizicities/dev-status.svg)](https://david-dm.org/vizicities/vizicities#info=devDependencies)

205
gulpfile.babel.js 100644
Wyświetl plik

@ -0,0 +1,205 @@
import gulp from 'gulp';
import loadPlugins from 'gulp-load-plugins';
import del from 'del';
import glob from 'glob';
import path from 'path';
import webpack from 'webpack';
import webpackStream from 'webpack-stream';
import source from 'vinyl-source-stream';
import { Instrumenter } from 'isparta';
import manifest from './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));
// Remove a directory
function _clean(dir, done) {
del([dir], done);
}
function cleanDist(done) {
_clean(destinationFolder, done);
}
function cleanTmp(done) {
_clean('tmp', done);
}
function onError() {
$.util.beep();
}
// Lint a set of files
function lint(files) {
return gulp.src(files)
.pipe($.plumber())
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failOnError())
.pipe($.jscs())
.pipe($.jscs.reporter('fail'))
.on('error', onError);
}
function lintSrc() {
return lint('src/**/*.js');
}
function lintTest() {
return lint('test/**/*.js');
}
function lintGulpfile() {
return lint('gulpfile.babel.js');
}
function build() {
return gulp.src(path.join('src', config.entryFileName + '.js'))
.pipe($.plumber())
.pipe(webpackStream({
output: {
filename: exportFileName + '.js',
libraryTarget: 'umd',
library: config.mainVarName
},
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: config.mochaGlobals,
ignoreLeaks: false
}));
}
function _registerBabel() {
require('babel-core/register');
}
function test() {
_registerBabel();
return _mocha();
}
function coverage(done) {
_registerBabel();
gulp.src(['src/**/*.js'])
.pipe($.istanbul({ instrumenter: Instrumenter }))
.pipe($.istanbul.hookRequire())
.on('finish', () => {
return test()
.pipe($.istanbul.writeReports())
.on('end', done);
});
}
const watchFiles = ['src/**/*', 'test/**/*', 'package.json', '**/.eslintrc', '.jscsrc'];
// 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'
},
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']);

75
package.json 100644
Wyświetl plik

@ -0,0 +1,75 @@
{
"name": "vizicities",
"version": "0.3.0",
"description": "3D city and data visualisation platform",
"main": "dist/vizicities.js",
"scripts": {
"test": "gulp",
"lint": "gulp lint",
"test-browser": "gulp test-browser",
"watch": "gulp watch",
"build": "gulp build",
"coverage": "gulp coverage"
},
"repository": {
"type": "git",
"url": "https://github.com/vizicities/vizicities.git"
},
"keywords": [
"mapping",
"geography",
"cities",
"3d",
"webgl",
"three.js",
"maps",
"data",
"visualisation",
"geojson",
"gis"
],
"author": "ViziCities <hello@vizicities.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/vizicities/vizicities/issues"
},
"homepage": "https://github.com/vizicities/vizicities",
"devDependencies": {
"babel-core": "^5.2.17",
"babel-eslint": "^4.0.5",
"babel-loader": "^5.3.2",
"chai": "^3.2.0",
"del": "^1.1.1",
"glob": "^5.0.14",
"gulp": "^3.8.10",
"gulp-babel": "^5.0.0",
"gulp-eslint": "^1.0.0",
"gulp-filter": "^3.0.0",
"gulp-istanbul": "^0.10.0",
"gulp-jscs": "^3.0.0",
"gulp-livereload": "^3.4.0",
"gulp-load-plugins": "^0.10.0",
"gulp-mocha": "^2.0.0",
"gulp-plumber": "^1.0.1",
"gulp-rename": "^1.2.0",
"gulp-sourcemaps": "^1.3.0",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.6",
"isparta": "^3.0.3",
"json-loader": "^0.5.3",
"mocha": "^2.1.0",
"sinon": "^1.12.2",
"sinon-chai": "^2.7.0",
"vinyl-source-stream": "^1.0.0",
"webpack": "^1.12.2",
"webpack-stream": "^2.1.1"
},
"babelBoilerplateOptions": {
"entryFileName": "vizicities",
"mainVarName": "VIZI",
"mochaGlobals": [
"stub", "spy", "expect", "sandbox", "mock",
"useFakeTimers", "useFakeXMLHttpRequest", "useFakeServer"
]
}
}

Wyświetl plik

@ -0,0 +1,7 @@
const VIZI = {
greet() {
return 'hello';
}
};
export default VIZI;

22
test/.eslintrc 100644
Wyświetl plik

@ -0,0 +1,22 @@
{
"parser": "babel-eslint",
"rules": {
"strict": 0,
"quotes": [2, "single"],
"no-unused-expressions": 0
},
"env": {
"browser": true,
"node": true,
"mocha": true
},
"globals": {
"spy": true,
"stub": true,
"mock": true,
"useFakeTimers": true,
"useFakeXMLHttpRequest": true,
"useFakeServer": true,
"expect": true
}
}

28
test/runner.html 100644
Wyświetl plik

@ -0,0 +1,28 @@
<!doctype html>
<!-- You need to run `gulp test-browser` before opening this in your browser -->
<html lang='en'>
<head>
<meta charset='utf-8'>
<title>Tests</title>
<link rel='stylesheet' href='../node_modules/mocha/mocha.css' />
<!-- Polyfill (required by Babel) -->
<script src='../node_modules/babel-core/browser-polyfill.js'></script>
<!-- Testing libraries -->
<script src='../node_modules/mocha/mocha.js'></script>
<script src='../node_modules/chai/chai.js'></script>
<script src='../node_modules/sinon/pkg/sinon.js'></script>
<script src='../node_modules/sinon-chai/lib/sinon-chai.js'></script>
<!-- Livereload -->
<script src='http://localhost:35729/livereload.js'></script>
<!-- Load the built library -->
<script src='../tmp/__spec-build.js'></script>
</head>
<body>
<!-- Required for browser reporter -->
<div id='mocha'></div>
</body>
</html>

Wyświetl plik

@ -0,0 +1,9 @@
var config = require('../../package.json').babelBoilerplateOptions;
window.mocha.setup('bdd');
window.onload = function() {
window.mocha.checkLeaks();
window.mocha.globals(config.mochaGlobals);
window.mocha.run();
require('./setup')(window);
};

14
test/setup/node.js 100644
Wyświetl plik

@ -0,0 +1,14 @@
global.chai = require('chai');
global.sinon = require('sinon');
global.chai.use(require('sinon-chai'));
require('babel-core/register');
require('./setup')();
/*
Uncomment the following if your library uses features of the DOM,
for example if writing a jQuery extension, and
add 'simple-jsdom' to the `devDependencies` of your package.json
*/
// import simpleJSDom from 'simple-jsdom';
// simpleJSDom.install();

Wyświetl plik

@ -0,0 +1,22 @@
module.exports = function(root) {
root = root ? root : this;
root.expect = root.chai.expect;
beforeEach(function() {
// Using these globally-available Sinon features is preferrable, as they're
// automatically restored for you in the subsequent `afterEach`
root.sandbox = root.sinon.sandbox.create();
root.stub = root.sandbox.stub.bind(root.sandbox);
root.spy = root.sandbox.spy.bind(root.sandbox);
root.mock = root.sandbox.mock.bind(root.sandbox);
root.useFakeTimers = root.sandbox.useFakeTimers.bind(root.sandbox);
root.useFakeXMLHttpRequest = root.sandbox.useFakeXMLHttpRequest.bind(root.sandbox);
root.useFakeServer = root.sandbox.useFakeServer.bind(root.sandbox);
});
afterEach(function() {
delete root.stub;
delete root.spy;
root.sandbox.restore();
});
};

Wyświetl plik

@ -0,0 +1,18 @@
import VIZI from '../../src/vizicities';
describe('VIZI', () => {
describe('Greet function', () => {
beforeEach(() => {
spy(VIZI, 'greet');
VIZI.greet();
});
it('should have been run once', () => {
expect(VIZI.greet).to.have.been.calledOnce;
});
it('should have always returned hello', () => {
expect(VIZI.greet).to.have.always.returned('hello');
});
});
});