<commit_before>// Generated on <%= (new Date).toISOString().split('T')[0] %> using
// <%= pkg.name %> <%= pkg.version %>
'use strict';

module.exports = function(grunt) {
    require('time-grunt')(grunt);
    require('load-grunt-tasks')(grunt);

    grunt.initConfig({
        watch: {
            js: {
                files: ['./src/app/**/*.js'],
                tasks: ['jshint'],
                options: {
                    livereload: '<%%= connect.options.livereload %>',
                    livereloadOnError: false
                }
            },
            livereload: {
                files: [
                    './src/index.html',
                    './src/app/**/*.html',
                    './src/app/**/*.json'
                ],
                options: {
                    livereload: '<%%= connect.options.livereload %>',
                    livereloadOnError: false
                }
            }
        },

        connect: {
            options: {
                port: <%= portNumber %>,
                open: true,
                livereload: 35729,
                // Change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function(connect) {
                        return [
                            connect.static('./src'),
                            connect().use('/node_modules', connect.static('./node_modules'))
                        ];
                    }
                }
            },
            dist: {
                options: {
                    base: './dist',
                    livereload: false
                }
            }
        },

        useminPrepare: {
            options: {
                dest: 'dist'
            },
            html: './src/index.html'
        },

        usemin: {
            options: {
                assetsDirs: [
                    'dist',
                    'dist/vendor/images',
                    'dist/vendor/css',
                    'dist/vendor/fonts'
                ]
            },
            html: ['./dist/index.html'],
            css: ['./dist/app/css/*.css', './dist/vendor/css/*.css']
        },

        clean: {
            dist: {
                files: [
                    {
                        dot: true,
                        src: [
                            '.tmp',
                            'dist/*',
                            '!dist/.git*'
                        ]
                    }
                ]
            },
            server: '.tmp'
        },

        copy: {
            dist: {
                files: [
                    {
                        expand: true,
                        dot: true,
                        cwd: 'src',
                        dest: 'dist',
                        src: [
                            './index.html',
                            './**/*.html',
                            './**/*.json'
                        ]
                    },
                    {
                        expand: true,
                        dot: true,
                        cwd: 'node_modules/<%= themeName %>',
                        dest: './dist/vendor',
                        src: [
                            './fonts/*.*',
                            './images/*.*',
                            './images/**/*.*'
                        ]
                    },
                    {
                        expand: true,
                        dot: true,
                        cwd: 'node_modules/<%= themeName %>/js/angular/i18n',
                        dest: './dist/vendor/js/angular/i18n',
                        src: [
                            './*.js'
                        ]
                    }
                ]
            }
        },

        replace: {
            dist: {
                src: ['./dist/index.html', './dist/app/js/app.js', './dist/vendor/css/*.css'],
                overwrite: true,
                replacements: [
                    {
                        from: 'node_modules/<%= themeName %>/images/',
                        to: 'vendor/images/'
                    },
                    {
                        from: 'url("../../fonts',
                        to: 'url("../fonts',
                    },
                    {
                        from: 'url(\'../../fonts',
                        to: 'url(\'../fonts',
                    },
                    {
                        from: 'url(../../fonts',
                        to: 'url(../fonts',
                    },
                    {
                        from: 'url("../../images',
                        to: 'url("../images',
                    },
                    {
                        from: 'url(\'../../images',
                        to: 'url(\'../images',
                    },
                    {
                        from: 'url(../../images',
                        to: 'url(../images',
                    },
                    {
                        from: 'node_modules/<%= themeName %>/js/angular/i18n',
                        to: 'vendor/js/angular/i18n',
                    }
                ]
            }
        },

        uglify: {
            dist: {
                files: [
                    {
                        expand: true,
                        flatten: false,
                        cwd: './dist/vendor/js/angular/i18n/',
                        src: ['./*.js'],
                        dest: './dist/vendor/js/angular/i18n/'
                    }
                ]
            }
        },

        htmlmin: {
            dist: {
                options: {
                    collapseWhitespace: true,
                    conservativeCollapse: true,
                    preserveLineBreaks: true,
                    removeAttributeQuotes: true,
                    removeRedundantAttributes: true
                },
                files: [
                    {
                        expand: true,
                        cwd: './dist',
                        src: '**/*.html',
                        dest: './dist'
                    }
                ]
            }
        },

        rev: {
            dist: {
                files: {
                    src: [
                        './dist/app/js/*.js',
                        './dist/app/css/*.css',
                        // TODO: dist/app/ *.html *.json
                        './dist/vendor/css/*.css',
                        './dist/vendor/fonts/*.*',
                        './dist/vendor/images/**/*.*',
                        './dist/vendor/js/*.js'
                    ]
                }
            }
        },

        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: [
                'Gruntfile.js',
                './src/app/*.js',
                './src/app/**/*.js'
            ]
        }
    });

    grunt.registerTask('serve', 'start the server and preview your app, --allow-remote for remote access', function(target) {
        if (grunt.option('allow-remote')) {
            grunt.config.set('connect.options.hostname', '0.0.0.0');
        }

        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'connect:livereload',
            'watch'
        ]);
    });

    grunt.registerTask('build', [
        'clean:dist',
        'useminPrepare',
        'concat:generated',
        'cssmin:generated',
        'uglify:generated',
        'copy:dist',
        'replace:dist',
        'uglify:dist',
        'rev',
        'usemin',
        'htmlmin'
    ]);

    //grunt.registerTask('default', [
    //    'newer:jshint',
    //    'test',
    //    'build'
    //]);
};
<commit_msg>Revving Angular HTML templates for dist #73<commit_after>// Generated on <%= (new Date).toISOString().split('T')[0] %> using
// <%= pkg.name %> <%= pkg.version %>
'use strict';

module.exports = function(grunt) {
    require('time-grunt')(grunt);
    require('load-grunt-tasks')(grunt);

    grunt.initConfig({
        watch: {
            js: {
                files: ['./src/app/**/*.js'],
                tasks: ['jshint'],
                options: {
                    livereload: '<%%= connect.options.livereload %>',
                    livereloadOnError: false
                }
            },
            livereload: {
                files: [
                    './src/index.html',
                    './src/app/**/*.html',
                    './src/app/**/*.json'
                ],
                options: {
                    livereload: '<%%= connect.options.livereload %>',
                    livereloadOnError: false
                }
            }
        },

        connect: {
            options: {
                port: <%= portNumber %>,
                open: true,
                livereload: 35729,
                // Change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function(connect) {
                        return [
                            connect.static('./src'),
                            connect().use('/node_modules', connect.static('./node_modules'))
                        ];
                    }
                }
            },
            dist: {
                options: {
                    base: './dist',
                    livereload: false
                }
            }
        },

        useminPrepare: {
            options: {
                dest: 'dist'
            },
            html: './src/index.html'
        },

        usemin: {
            options: {
                assetsDirs: [
                    'dist',
                    'dist/vendor/images',
                    'dist/vendor/css',
                    'dist/vendor/fonts'
                ],
                patterns: {
                    // FIXME While usemin won't have full support for revved files we have to put all references manually here
                    js: [
                        [/templateUrl:'.+?(\.html)'/gm, 'Update the JS to reference our revved templates']
                    ]
                }
            },
            html: ['./dist/index.html'],
            css: ['./dist/app/css/*.css', './dist/vendor/css/*.css'],
            js: ['./dist/app/js/*.js'],
        },

        clean: {
            dist: {
                files: [
                    {
                        dot: true,
                        src: [
                            '.tmp',
                            'dist/*',
                            '!dist/.git*'
                        ]
                    }
                ]
            },
            server: '.tmp'
        },

        copy: {
            dist: {
                files: [
                    {
                        expand: true,
                        dot: true,
                        cwd: 'src',
                        dest: 'dist',
                        src: [
                            './index.html',
                            './**/*.html',
                            './**/*.json'
                        ]
                    },
                    {
                        expand: true,
                        dot: true,
                        cwd: 'node_modules/<%= themeName %>',
                        dest: './dist/vendor',
                        src: [
                            './fonts/*.*',
                            './images/*.*',
                            './images/**/*.*'
                        ]
                    },
                    {
                        expand: true,
                        dot: true,
                        cwd: 'node_modules/<%= themeName %>/js/angular/i18n',
                        dest: './dist/vendor/js/angular/i18n',
                        src: [
                            './*.js'
                        ]
                    }
                ]
            }
        },

        replace: {
            dist: {
                src: ['./dist/index.html', './dist/app/js/app.js', './dist/vendor/css/*.css'],
                overwrite: true,
                replacements: [
                    {
                        from: 'node_modules/<%= themeName %>/images/',
                        to: 'vendor/images/'
                    },
                    {
                        from: 'url("../../fonts',
                        to: 'url("../fonts',
                    },
                    {
                        from: 'url(\'../../fonts',
                        to: 'url(\'../fonts',
                    },
                    {
                        from: 'url(../../fonts',
                        to: 'url(../fonts',
                    },
                    {
                        from: 'url("../../images',
                        to: 'url("../images',
                    },
                    {
                        from: 'url(\'../../images',
                        to: 'url(\'../images',
                    },
                    {
                        from: 'url(../../images',
                        to: 'url(../images',
                    },
                    {
                        from: 'node_modules/<%= themeName %>/js/angular/i18n',
                        to: 'vendor/js/angular/i18n',
                    }
                ]
            }
        },

        uglify: {
            dist: {
                files: [
                    {
                        expand: true,
                        flatten: false,
                        cwd: './dist/vendor/js/angular/i18n/',
                        src: ['./*.js'],
                        dest: './dist/vendor/js/angular/i18n/'
                    }
                ]
            }
        },

        htmlmin: {
            dist: {
                options: {
                    collapseWhitespace: true,
                    conservativeCollapse: true,
                    preserveLineBreaks: true,
                    removeAttributeQuotes: true,
                    removeRedundantAttributes: true
                },
                files: [
                    {
                        expand: true,
                        cwd: './dist',
                        src: '**/*.html',
                        dest: './dist'
                    }
                ]
            }
        },

        rev: {
            dist: {
                files: {
                    src: [
                        // TODO: dist/app/ *.html *.json
                        './dist/app/**/*.html',
                        './dist/app/js/*.js',
                        './dist/app/css/*.css',
                        './dist/vendor/css/*.css',
                        './dist/vendor/fonts/*.*',
                        './dist/vendor/images/**/*.*',
                        './dist/vendor/js/*.js'
                    ]
                }
            }
        },

        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: [
                'Gruntfile.js',
                './src/app/*.js',
                './src/app/**/*.js'
            ]
        }
    });

    grunt.registerTask('serve', 'start the server and preview your app, --allow-remote for remote access', function(target) {
        if (grunt.option('allow-remote')) {
            grunt.config.set('connect.options.hostname', '0.0.0.0');
        }

        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'connect:livereload',
            'watch'
        ]);
    });

    grunt.registerTask('build', [
        'clean:dist',
        'useminPrepare',
        'concat:generated',
        'cssmin:generated',
        'uglify:generated',
        'copy:dist',
        'replace:dist',
        'uglify:dist',
        'rev:dist',
        'usemin',
        'htmlmin'
    ]);

    //grunt.registerTask('default', [
    //    'newer:jshint',
    //    'test',
    //    'build'
    //]);
};
<|endoftext|>


<commit_before>define( [], function () {
	'use strict';

	// Appearance section
	var appearanceSection = {
		uses: "settings",
		items: {
			general: {
				items:{
					showTitles:{
						defaultValue: false
					}
				}
			}
			includeBeta: includeBeta
		}
	};

	var includeBeta = {
		ref: "props.includeBeta",
		label: "Include Beta Functions",
		type: "boolean",
		component: "switch",
		defaultValue: false
	}

	// *****************************************************************************
	// Main properties panel definition
	// Only what is defined here is returned from properties.js
	// *****************************************************************************
	return {
		type: "items",
		component: "accordion",
		items: {
			appearance: appearanceSection
		}
	};
});
<commit_msg>fix definitions<commit_after>define( [], function () {
	'use strict';

	// Appearance section
	var appearanceSection = {
		uses: "settings",
		items: {
			general: {
				items:{
					showTitles:{
						defaultValue: false
					}
				}
			}
		}
	};

	var includeBeta = {
		ref: "props.includeBeta",
		label: "Include Beta Functions",
		type: "boolean",
		component: "switch",
		defaultValue: false
	};

	var aaiSettings = {
		component: "expandable-items",
		label: "AAI Builder Settings",
		items: {
			includeBeta: includeBeta
		}
	};

	// *****************************************************************************
	// Main properties panel definition
	// Only what is defined here is returned from properties.js
	// *****************************************************************************
	return {
		type: "items",
		component: "accordion",
		items: {
			appearance: appearanceSection,
			aaiSettings: aaiSettings
		}
	};
});
<|endoftext|>


<commit_before>var xhr       = require('xhr')
var shoe      = require('shoe')('/smokestack')
var slice     = require('sliced')
var isDom     = require('is-dom')
var format    = require('util').format
var convert   = require('convert-source-map')
var console   = window.console
var SourceMap = require('source-map').SourceMapConsumer

// magical auto-correction of error stack traces in v8
require('source-map-support').install()

// keep around so can call
// console methods without sending data to server
var nativeConsole = {}

;['error'
, 'info'
, 'log'
, 'debug'
, 'warn'
].forEach(function(k) {
  var nativeMethod = console[k]
  nativeConsole[k] = nativeMethod.bind(console)
  var prefix = k

  console[k] = function() {
    // keep original args so browser can log as usual
    var args = slice(arguments)
    write(prefix, args)
    return nativeMethod.apply(this, args)
  }
})

function write(prefix, args) {
  // prepare args for transport
  var cleanArgs = args.map(function(item) {
    // no sensible default for stringifying
    // DOM Elements nicely so just toString and let
    // whoever is logging handle stringification.
    if (item && isDom(item)) return item.toString()
    return item
  })

  var output = format.apply(null, cleanArgs)
  var data = JSON.stringify([prefix].concat(output))

  shoe.write(data)
  shoe.write('\n')
}

var close = window.close

window.close = function() {
  setTimeout(function() {
    shoe.write(JSON.stringify({ end: true }))
    shoe.write('\n')
    shoe.once('data', function() {
      shoe.end()
    })
  })
}

shoe.on('end', function() {
  close()
})

xhr('script.js', function(err, resp) {
  if (err) return console.error(err)
  var src = resp.body
  var sourceMap = convert.fromSource(src)
  // Not all browsers support the full function signature
  // of window.onerror, so the Error instance is not always
  // guaranteed:
  // http://danlimerick.wordpress.com/2014/01/18/how-to-catch-javascript-errors-with-window-onerror-even-on-chrome-and-firefox/
  window.onerror = function(message, filename, line, col, error) {
    var supportsError = !!error
    if (!supportsError) {
      var error = new Error(message)
      error.stack = 'Error: '+message+'\n    at '+filename+':'+line+':'+col
    }
    error.fileName = error.fileName || filename
    error.lineNumber = error.lineNumber || line
    error.columnNumber = error.columnNumber || col
    if (supportsError && sourceMap) {
      var sm = sourceMap.toObject()
      var smc = new SourceMap(sm)
      var original = smc.originalPositionFor({line: error.lineNumber, column: error.columnNumber})
      var source = smc.sourceContentFor(original.source)
      logError(source, error, original)
    } else {
      logError(src, error)
    }
    window.close()
  }

  var script = document.createElement("script")
  script.type = "text\/javascript"
  document.body.appendChild(script)
  script.src = 'script.js'
})

function logError(src, error, position) {
  var lines = src.trim().split('\n')
  position = position || {
    line: error.lineNumber,
    column: error.columnNumber,
    source: error.filename
  }
  var errorLine = '' + lines[position.line - 1]
  var spaces = ''
  write('error', [position.source + ':' +position.line])
  for (var i = 0; i < position.column; i++) {
    spaces += ' '
  }
  var columnLine = spaces + '^'
  var errorLines = [errorLine, columnLine]
  // write different data to remote console
  // and window console.
  write('error', [errorLines.join('\n') + '\n'])

  // it's possible that we can fail to get a stack
  try {
    write('error', [error.stack])
  } catch (e) {
    write('error', ['Could not get stack trace because:', e.message])
  }

  nativeConsole.error(error)
}
<commit_msg>Fail the tests on uncaught exception<commit_after>var xhr       = require('xhr')
var shoe      = require('shoe')('/smokestack')
var slice     = require('sliced')
var isDom     = require('is-dom')
var format    = require('util').format
var convert   = require('convert-source-map')
var console   = window.console
var SourceMap = require('source-map').SourceMapConsumer

// magical auto-correction of error stack traces in v8
require('source-map-support').install()

// keep around so can call
// console methods without sending data to server
var nativeConsole = {}

;['error'
, 'info'
, 'log'
, 'debug'
, 'warn'
].forEach(function(k) {
  var nativeMethod = console[k]
  nativeConsole[k] = nativeMethod.bind(console)
  var prefix = k

  console[k] = function() {
    // keep original args so browser can log as usual
    var args = slice(arguments)
    write(prefix, args)
    return nativeMethod.apply(this, args)
  }
})

function write(prefix, args) {
  // prepare args for transport
  var cleanArgs = args.map(function(item) {
    // no sensible default for stringifying
    // DOM Elements nicely so just toString and let
    // whoever is logging handle stringification.
    if (item && isDom(item)) return item.toString()
    return item
  })

  var output = format.apply(null, cleanArgs)
  var data = JSON.stringify([prefix].concat(output))

  shoe.write(data)
  shoe.write('\n')
}

var close = window.close

window.close = function() {
  setTimeout(function() {
    shoe.write(JSON.stringify({ end: true }))
    shoe.write('\n')
    shoe.once('data', function() {
      shoe.end()
    })
  })
}

shoe.on('end', function() {
  close()
})

xhr('script.js', function(err, resp) {
  if (err) return console.error(err)
  var src = resp.body
  var sourceMap = convert.fromSource(src)
  // Not all browsers support the full function signature
  // of window.onerror, so the Error instance is not always
  // guaranteed:
  // http://danlimerick.wordpress.com/2014/01/18/how-to-catch-javascript-errors-with-window-onerror-even-on-chrome-and-firefox/
  window.onerror = function(message, filename, line, col, error) {
    var supportsError = !!error
    if (!supportsError) {
      var error = new Error(message)
      error.stack = 'Error: '+message+'\n    at '+filename+':'+line+':'+col
    }
    error.fileName = error.fileName || filename
    error.lineNumber = error.lineNumber || line
    error.columnNumber = error.columnNumber || col
    if (supportsError && sourceMap) {
      var sm = sourceMap.toObject()
      var smc = new SourceMap(sm)
      var original = smc.originalPositionFor({line: error.lineNumber, column: error.columnNumber})
      var source = smc.sourceContentFor(original.source)
      logError(source, error, original)
    } else {
      logError(src, error)
    }
    window.close()
  }

  var script = document.createElement("script")
  script.type = "text\/javascript"
  document.body.appendChild(script)
  script.src = 'script.js'
})

function logError(src, error, position) {
  var lines = src.trim().split('\n')
  position = position || {
    line: error.lineNumber,
    column: error.columnNumber,
    source: error.filename
  }
  var errorLine = '' + lines[position.line - 1]
  var spaces = ''

  // write in tap format so that test fail when there's an uncaught exception
  write('error', ['not ok - ' + error.message])

  write('error', [position.source + ':' +position.line])
  for (var i = 0; i < position.column; i++) {
    spaces += ' '
  }
  var columnLine = spaces + '^'
  var errorLines = [errorLine, columnLine]
  // write different data to remote console
  // and window console.
  write('error', [errorLines.join('\n') + '\n'])

  // it's possible that we can fail to get a stack
  try {
    write('error', [error.stack])
  } catch (e) {
    write('error', ['Could not get stack trace because:', e.message])
  }

  nativeConsole.error(error)
}
<|endoftext|>