Skip to content

Commit

Permalink
Reorg for new docs and browserify, not tested
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahghp committed Aug 11, 2015
1 parent dd8dc5a commit f0a3934
Show file tree
Hide file tree
Showing 448 changed files with 828 additions and 85,706 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
@@ -0,0 +1,17 @@
# EditorConfig: http://EditorConfig.org

# Top-most EditorConfig file
root = true

# Rules for JavaScript files:

[*.js]
# 2 space indentation
indent_style = space
indent_size = 2
# No trailing spaces
trim_trailing_whitespace = true
# Unix-style newlines
end_of_line = lf
# Newline ending every file
insert_final_newline = true
4 changes: 4 additions & 0 deletions .jscsrc
@@ -0,0 +1,4 @@
{
"disallowTrailingWhitespace": true,
"validateIndentation": 2
}
182 changes: 63 additions & 119 deletions Gruntfile.js
Expand Up @@ -4,32 +4,24 @@
* runner/builder, used to build the source code into the library
* and handle other housekeeping tasks.
*
* There are three main tasks:
* There are four main tasks:
*
* grunt - This is the default task, which builds the code, tests it
* using both jslint and mocha, and then minifies it.
* grunt - This is the default task, which both tests and builds.
*
* grunt yui - This will build the inline documentation for p5.js.
* grunt build - This task builds and minifies the client source code.
*
* grunt test - This only runs the automated tests, which is faster than
* rebuilding entirely from source because it skips minification
* and concatination.
*
* And there are several secondary tasks:
*
*
* grunt watch - This watches the source for changes and rebuilds on
* every file change, running the linter and tests.
* and concatination. If you need to debug
* a test suite in a browser, `grunt test --keepalive` will
* start the connect server and leave it running; the tests
* can then be opened at localhost:9001/test/test.htmln
*
* grunt watch:main - This watches the source for changes and rebuilds on
* every file change, but does not rebuild the docs.
* It's faster than the default watch.
*
* grunt update_json - This automates updating the bower file
* to match the package.json
* every file change.
*/

/* global module:false */

module.exports = function(grunt) {

// Specify what reporter we'd like to use for Mocha
Expand All @@ -48,6 +40,26 @@ module.exports = function(grunt) {
// read in the package, used for knowing the current version, et al.
pkg: grunt.file.readJSON('package.json'),

// Configure style consistency checking for this file, the source, and the tests.
jscs: {
options: {
config: '.jscsrc',
reporter: require('jscs-stylish').path
},
build: {
src: ['Gruntfile.js']
},
source: {
src: [
'src/**/*.js',
'!src/external/**/*.js'
]
},
test: {
src: ['test/unit/**/*.js']
}
},

// Configure hinting for this file, the source, and the tests.
jshint: {
build: {
Expand All @@ -72,36 +84,14 @@ module.exports = function(grunt) {
},

// Set up the watch task, used for live-reloading during development.
// This watches both the codebase and the yuidoc theme. Changing the
// code touches files within the theme, so it will also recompile the
// documentation.
watch: {
// Watch the codebase for changes
main: {
files: ['src/**/*.js'],
tasks: ['newer:jshint:source','requirejs:sensors_unminified','mocha'],
tasks: ['newer:jshint:source','test'],
options: {
livereload: true
}
},
// watch the theme for changes
reference_build: {
files: ['docs/yuidoc-p5-theme/**/*'],
tasks: ['yuidoc'],
options: {
livereload: true,
interrupt: true
}
},
// watch the yuidoc/reference theme scripts for changes
yuidoc_theme_build: {
files: ['docs/yuidoc-p5-theme-src/scripts/**/*'],
tasks: ['requirejs:yuidoc_theme']
},
// Watch the codebase for doc updates
yui:{
files:['src/**/*.js'],
task:['yuidoc']
}
},

Expand All @@ -110,6 +100,10 @@ module.exports = function(grunt) {
test: {
src: ['test/**/*.html'],
options: {
urls: [
'http://localhost:9001/test/test.html',
'http://localhost:9001/test/test-minified.html'
],
reporter: reporter,
run: true,
log: true,
Expand All @@ -118,6 +112,7 @@ module.exports = function(grunt) {
},
},

// Set up the mocha-chai-sinon task, used for the automated server-side tests.
'mocha-chai-sinon': {
build: {
src: ['test/unit/server/app.js'],
Expand All @@ -128,89 +123,37 @@ module.exports = function(grunt) {
}
},

// The actual compile step: This should collect all the dependencies
// and compile them into a single file.
requirejs: {
sensors_unminified: {
// Build p5bots client source into a single, UMD-wrapped file
browserify: {
p5: {
options: {
baseUrl: '.', // whence do the files come?
findNestedDependencies: true,
optimize: 'none', // skip running uglify on the concatenated code
out: 'lib/p5bots.js', // name of the output file
useStrict: true, // Allow "use strict"; be included in the RequireJS files.
//findNestedDependencies: true, // automatically find nested deps. Doesn't appear to effect the code?
include: ['src/client/app.js'], // this is the file which we are actually building
wrap: {
start: '/*! p5bots.js v<%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' + grunt.file.read('./fragments/before.frag'),
end: grunt.file.read('./fragments/after.frag')
},


// This will transform the compiled file, reversing out the AMD loader and creating a
// static JS file. This code is potentially problematic.
onBuildWrite: function(name, path, contents) {
return require('amdclean').clean({
code: contents,
'globalObject': true,
escodegen: {
'comment': true,
'format': {
'indent': {
'style': ' ',
'adjustMultilineComment': true
}
}
}
});
transform: ['brfs'],
browserifyOptions: {
standalone: 'p5bots'
},

done: function(done, output) {
require('concat-files')([
'lib/p5bots.js',
], 'lib/p5bots.js', function() {
done();
});
}
}
},

// This generates the theme for the documentation from the theme source
// files.
yuidoc_theme: {
options: {
baseUrl: './docs/yuidoc-p5-theme-src/scripts/',
mainConfigFile: './docs/yuidoc-p5-theme-src/scripts/config.js',
name: 'main',
out: './docs/yuidoc-p5-theme/assets/js/reference.js',
optimize: 'none',
generateSourceMaps: true,
findNestedDependencies: true,
wrap: true,
paths: {
'jquery': 'empty:'
}
}
banner: '/*! p5bots.js v<%= pkg.version %> <%= grunt.template.today("mmmm dd, yyyy") %> */'
},
src: 'src/client/app.js',
dest: 'lib/p5bots.js'
}
},

// this builds the documentation for the codebase.
yuidoc: {
compile: {
name: '<%= pkg.name %>',
description: '<%= pkg.description %>',
version: '<%= pkg.version %>',
url: '<%= pkg.homepage %>',
options: {
paths: ['src/', 'lib/addons/'],
themedir: 'docs/yuidoc-p5-theme/',
outdir: 'docs/reference/'
}
// This minifies the javascript into a single file and adds a banner to the
// front of the file.
uglify: {
options: {
banner: '/*! p5bots.js v<%= pkg.version %> <%= grunt.template.today("mmmm dd, yyyy") %> */ '
},
build: {
src: 'lib/p5bots.js',
dest: 'lib/p5bots.min.js'
}
},

release: {
options: {
github: {
repo: 'processing/p5.js', //put your user/repo here
repo: 'sarahgp/p5bots', //put your user/repo here
usernameVar: process.env.GITHUB_USERNAME, //ENVIRONMENT VARIABLE that contains Github username
passwordVar: process.env.GITHUB_PASSWORD //ENVIRONMENT VARIABLE that contains Github password
}
Expand All @@ -222,7 +165,7 @@ module.exports = function(grunt) {
connect: {
server: {
options: {
base: './test',
base: './',
port: 9001,
keepalive: keepalive,
middleware: function(connect, options, middlewares) {
Expand All @@ -239,18 +182,19 @@ module.exports = function(grunt) {
});

// Load the external libraries used.
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-jscs');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-mocha-chai-sinon');
grunt.loadNpmTasks('grunt-contrib-yuidoc');
grunt.loadNpmTasks('grunt-update-json');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-newer');

// Create the multitasks.
grunt.registerTask('test', ['connect', 'newer:jshint', 'requirejs', 'mocha', 'mocha-chai-sinon']);
grunt.registerTask('yui', ['yuidoc']);
grunt.registerTask('default', ['connect', 'jshint', 'requirejs', 'mocha', 'mocha-chai-sinon']);
grunt.registerTask('build', ['browserify', 'uglify', 'requirejs']);
grunt.registerTask('test', ['jshint', 'jscs', 'build', 'connect', 'mocha', 'mocha-chai-sinon']);
grunt.registerTask('default', ['test', 'build']);
};
Binary file removed docs/css/f/AvenirNextLTW01-Medium.eot
Binary file not shown.

0 comments on commit f0a3934

Please sign in to comment.