<commit_before>'use strict';

var path = require('path');

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    libinfo: {
      cwd: 'lib/ical',
      doc: 'api',
      files: [
        'helpers.js', 'design.js', 'stringify.js', 'parse.js', 'component.js',
        'property.js', 'utc_offset.js', 'binary.js', 'period.js', 'duration.js',
        'timezone.js', 'timezone_service.js', 'time.js', 'vcard_time.js',
        'recur.js', 'recur_iterator.js', 'recur_expansion.js', 'event.js',
        'component_parser.js'
      ],
      test: {
        head: ['test/helper.js'],
        unit: ['test/*_test.js'],
        acceptance: ['test/acceptance/*_test.js'],
        performance: ['test/performance/*_test.js']
      }
    },

    travis: {
      branch: process.env.TRAVIS_BRANCH,
      leader: (process.env.TRAVIS_JOB_NUMBER || "").substr(-2) == ".1",
      commit: process.env.TRAVIS_COMMIT,
      pullrequest: (process.env.TRAVIS_PULL_REQUEST || "false") == "false" ? null : process.env.TRAVIS_PULL_REQUEST,
      secure: process.env.TRAVIS_SECURE_ENV_VARS == "true",
      tag: process.env.TRAVIS_TAG
    },

    concat: {
      options: {
        separator: '',
        process: function(src, filepath) {
          return src.replace('"use strict";', '');
        }
      },

      dist: {
        src: ['<%= libinfo.absfiles %>'],
        dest: 'build/ical.js'
      }
    },

    mocha_istanbul: {
      coverage: {
        src: ['<%= libinfo.test.unit %>', '<%= libinfo.test.acceptance %>'],
        options: {
          root: './lib/ical/',
          require: ['<%= libinfo.test.head %>'],
          reporter: 'dot',
          ui: 'tdd'
        }
      }
    },

    coveralls: {
      options: {
        force: true
      },
      unit: {
        src: './coverage/lcov.info'
      }
    },

    'node-inspector': {
      test: {}
    },

    concurrent: {
      all: ['mochacli', 'node-inspector'],
      unit: ['mochacli:unit', 'node-inspector'],
      acceptance: ['mochacli:acceptance', 'node-inspector'],
      single: ['mochacli:single', 'node-inspector'],
    },

    mochacli: {
      options: {
        ui: 'tdd',
        require: ['<%= libinfo.test.head %>'],
        'debug-brk': grunt.option('debug'),
        reporter: grunt.option('reporter') || 'spec'
      },
      performance: {
        src: ['<%= libinfo.test.performance %>']
      },
      acceptance: {
        src: ['<%= libinfo.test.acceptance %>']
      },
      unit: {
        src: ['<%= libinfo.test.unit %>']
      },
      single: {
        src: [grunt.option('test')]
      }
    },

    jshint: {
      options: {
        "globalstrict": true,
        "eqeqeq": false,
        "-W041": false,
        "strict": false,
        "proto": true,
        "shadow": true
      },
      lib: {
        options: {
          predef: ['ICAL']
        },
        src: ['<%= libinfo.absfiles %>']
      },
      ICALTester: {
        src: ['tools/ICALTester/**/*.js']
      }
    },
    gjslint: {
      options: {
        flags: ['--flagfile .gjslintrc'],
        reporter: {
          name: 'console'
        }
      },
      lib: {
        src: ['<%= libinfo.absfiles %>']
      },
      ICALTester: {
        src: ['tools/ICALTester/**/*.js']
      }
    },
    release: {
      options: {
        tagName: 'v<%=version%>',
        tagMessage: 'v<%=version%>',
        github: {
          repo: 'mozilla-comm/ical.js',
          usernameVar: 'GITHUB_USERNAME',
          passwordVar: 'GITHUB_PASSWORD'
        }
      }
    },
    jsdoc: {
      dist: {
        src: ['<%= libinfo.absfiles %>', 'README.md'],
        options: {
          destination: '<%= libinfo.doc %>',
          template: './node_modules/minami/',
          private: false
        }
      }
    },

    'gh-pages': {
      options: {
        clone: 'jsdoc-stage',
        only: '<%= libinfo.doc %>',
        user: {
          name: 'Travis CI',
          email: 'builds@travis-ci.org',
        },
        repo: 'git@github.com:kewisch/ical.js.git',
        message: 'Update API Documentation for <%= travis.commit %>'
      },
      src: '<%= libinfo.doc %>/**'
    }
  });

  grunt.config.set('libinfo.absfiles', grunt.config.get('libinfo.files').map(function(f) {
    return path.join(grunt.config.get('libinfo.cwd'), f);
  }));

  grunt.loadNpmTasks('grunt-concurrent');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-coveralls');
  grunt.loadNpmTasks('grunt-gjslint');
  grunt.loadNpmTasks('grunt-gh-pages');
  grunt.loadNpmTasks('grunt-jsdoc');
  grunt.loadNpmTasks('grunt-mocha-cli');
  grunt.loadNpmTasks('grunt-mocha-istanbul');
  grunt.loadNpmTasks('grunt-node-inspector');
  grunt.loadNpmTasks('grunt-release');

  grunt.loadTasks('tasks');

  grunt.registerTask('default', ['package']);
  grunt.registerTask('package', ['concat']);
  grunt.registerTask('coverage', 'mocha_istanbul');
  grunt.registerTask('linters', ['jshint', 'gjslint', 'check-browser-build']);
  grunt.registerTask('test-server', ['test-agent-config', 'run-test-server']);
  grunt.registerTask('test', ['test-browser', 'test-node']);
  grunt.registerTask('test-ci', ['check-browser-build', 'linters', 'jsdoc', 'test-node:unit', 'test-node:acceptance', 'coverage', 'coveralls', 'push-api-doc']);

  // Additional tasks:
  //   - tests.js: performance-update, test-node, test-browser,
  //   - timezones.js: timezones

};
<commit_msg>Correct repository for gh-pages push<commit_after>'use strict';

var path = require('path');

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    libinfo: {
      cwd: 'lib/ical',
      doc: 'api',
      files: [
        'helpers.js', 'design.js', 'stringify.js', 'parse.js', 'component.js',
        'property.js', 'utc_offset.js', 'binary.js', 'period.js', 'duration.js',
        'timezone.js', 'timezone_service.js', 'time.js', 'vcard_time.js',
        'recur.js', 'recur_iterator.js', 'recur_expansion.js', 'event.js',
        'component_parser.js'
      ],
      test: {
        head: ['test/helper.js'],
        unit: ['test/*_test.js'],
        acceptance: ['test/acceptance/*_test.js'],
        performance: ['test/performance/*_test.js']
      }
    },

    travis: {
      branch: process.env.TRAVIS_BRANCH,
      leader: (process.env.TRAVIS_JOB_NUMBER || "").substr(-2) == ".1",
      commit: process.env.TRAVIS_COMMIT,
      pullrequest: (process.env.TRAVIS_PULL_REQUEST || "false") == "false" ? null : process.env.TRAVIS_PULL_REQUEST,
      secure: process.env.TRAVIS_SECURE_ENV_VARS == "true",
      tag: process.env.TRAVIS_TAG
    },

    concat: {
      options: {
        separator: '',
        process: function(src, filepath) {
          return src.replace('"use strict";', '');
        }
      },

      dist: {
        src: ['<%= libinfo.absfiles %>'],
        dest: 'build/ical.js'
      }
    },

    mocha_istanbul: {
      coverage: {
        src: ['<%= libinfo.test.unit %>', '<%= libinfo.test.acceptance %>'],
        options: {
          root: './lib/ical/',
          require: ['<%= libinfo.test.head %>'],
          reporter: 'dot',
          ui: 'tdd'
        }
      }
    },

    coveralls: {
      options: {
        force: true
      },
      unit: {
        src: './coverage/lcov.info'
      }
    },

    'node-inspector': {
      test: {}
    },

    concurrent: {
      all: ['mochacli', 'node-inspector'],
      unit: ['mochacli:unit', 'node-inspector'],
      acceptance: ['mochacli:acceptance', 'node-inspector'],
      single: ['mochacli:single', 'node-inspector'],
    },

    mochacli: {
      options: {
        ui: 'tdd',
        require: ['<%= libinfo.test.head %>'],
        'debug-brk': grunt.option('debug'),
        reporter: grunt.option('reporter') || 'spec'
      },
      performance: {
        src: ['<%= libinfo.test.performance %>']
      },
      acceptance: {
        src: ['<%= libinfo.test.acceptance %>']
      },
      unit: {
        src: ['<%= libinfo.test.unit %>']
      },
      single: {
        src: [grunt.option('test')]
      }
    },

    jshint: {
      options: {
        "globalstrict": true,
        "eqeqeq": false,
        "-W041": false,
        "strict": false,
        "proto": true,
        "shadow": true
      },
      lib: {
        options: {
          predef: ['ICAL']
        },
        src: ['<%= libinfo.absfiles %>']
      },
      ICALTester: {
        src: ['tools/ICALTester/**/*.js']
      }
    },
    gjslint: {
      options: {
        flags: ['--flagfile .gjslintrc'],
        reporter: {
          name: 'console'
        }
      },
      lib: {
        src: ['<%= libinfo.absfiles %>']
      },
      ICALTester: {
        src: ['tools/ICALTester/**/*.js']
      }
    },
    release: {
      options: {
        tagName: 'v<%=version%>',
        tagMessage: 'v<%=version%>',
        github: {
          repo: 'mozilla-comm/ical.js',
          usernameVar: 'GITHUB_USERNAME',
          passwordVar: 'GITHUB_PASSWORD'
        }
      }
    },
    jsdoc: {
      dist: {
        src: ['<%= libinfo.absfiles %>', 'README.md'],
        options: {
          destination: '<%= libinfo.doc %>',
          template: './node_modules/minami/',
          private: false
        }
      }
    },

    'gh-pages': {
      options: {
        clone: 'jsdoc-stage',
        only: '<%= libinfo.doc %>',
        user: {
          name: 'Travis CI',
          email: 'builds@travis-ci.org',
        },
        repo: 'git@github.com:mozilla-comm/ical.js.git',
        message: 'Update API Documentation for <%= travis.commit %>'
      },
      src: '<%= libinfo.doc %>/**'
    }
  });

  grunt.config.set('libinfo.absfiles', grunt.config.get('libinfo.files').map(function(f) {
    return path.join(grunt.config.get('libinfo.cwd'), f);
  }));

  grunt.loadNpmTasks('grunt-concurrent');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-coveralls');
  grunt.loadNpmTasks('grunt-gjslint');
  grunt.loadNpmTasks('grunt-gh-pages');
  grunt.loadNpmTasks('grunt-jsdoc');
  grunt.loadNpmTasks('grunt-mocha-cli');
  grunt.loadNpmTasks('grunt-mocha-istanbul');
  grunt.loadNpmTasks('grunt-node-inspector');
  grunt.loadNpmTasks('grunt-release');

  grunt.loadTasks('tasks');

  grunt.registerTask('default', ['package']);
  grunt.registerTask('package', ['concat']);
  grunt.registerTask('coverage', 'mocha_istanbul');
  grunt.registerTask('linters', ['jshint', 'gjslint', 'check-browser-build']);
  grunt.registerTask('test-server', ['test-agent-config', 'run-test-server']);
  grunt.registerTask('test', ['test-browser', 'test-node']);
  grunt.registerTask('test-ci', ['check-browser-build', 'linters', 'jsdoc', 'test-node:unit', 'test-node:acceptance', 'coverage', 'coveralls', 'push-api-doc']);

  // Additional tasks:
  //   - tests.js: performance-update, test-node, test-browser,
  //   - timezones.js: timezones

};
<|endoftext|>


<commit_before>
require('quiet-grunt')

var channel = process.env.CI_CHANNEL || 'stable'
var appName = (channel === 'stable' ? 'itch' : 'kitch')

var fs = require('fs')
var path = require('path')
var packagePath = path.join(__dirname, 'package.json')
var version = process.env.CI_VERSION || JSON.parse(fs.readFileSync(packagePath, { encoding: 'utf8' })).version

var iconsPath = path.join('release', 'images', appName + '-icons')
var icoPath = path.join(iconsPath, 'itch.ico')
var icnsPath = path.join(iconsPath, 'itch.icns')
var installerGifPath = 'release/images/installer.gif'

var electronVersion = '1.2.2'
var outDir = path.join('build', 'v' + version)
var companyName = 'Itch Corp'

var gruntElectronCommon = {
  dir: 'stage',
  name: appName,
  version: electronVersion,
  'app-version': version,
  prune: true,
  asar: true,
  overwrite: true,
  out: outDir
}

var windowsElectronOptions = Object.assign({}, gruntElectronCommon, {
  platform: 'win32',
  icon: icoPath,
  'version-string': {
    CompanyName: companyName,
    LegalCopyright: 'MIT license, (c) Itch Corp',
    FileDescription: appName,
    OriginalFileName: appName + '.exe',
    FileVersion: version,
    AppVersion: version,
    ProductName: appName,
    InternalName: appName + '.exe'
  }
})

var electronInstallerCommon = {
  authors: companyName,
  exe: appName + '.exe',
  description: 'The best way to play itch.io games',
  version: version,
  title: appName,
  // sic. it's really itch.ico
  iconUrl: 'http://raw.githubusercontent.com/itchio/itch/master/release/images/' + appName + '-icons/itch.ico',
  loadingGif: installerGifPath,
  setupIcon: icoPath,
  remoteReleases: 'https://github.com/itchio/' + appName,
  signWithParams: '/v /s MY /n "Open Source Developer, Amos Wenger" /fd sha256 /tr http://timestamp.comodoca.com/?td=sha256 /td sha256',
  noMsi: true
}

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

  grunt.initConfig({
    // Create a .exe, .app, folder for windows, mac, linux
    electron: {
      'windows-ia32': {
        options: Object.assign({
          arch: 'ia32'
        }, windowsElectronOptions)
      },
      'darwin-x64': {
        options: Object.assign({}, gruntElectronCommon, {
          platform: 'darwin',
          arch: 'x64',
          icon: icnsPath,
          'app-bundle-id': 'io.' + appName + '.mac',
          'app-category-type': 'public.app-category.games',
          protocols: [{
            name: 'itch.io',
            schemes: [appName + 'io']
          }]
        })
      },
      'linux-ia32': {
        options: Object.assign({}, gruntElectronCommon, {
          platform: 'linux',
          arch: 'ia32'
        })
      },
      'linux-x64': {
        options: Object.assign({}, gruntElectronCommon, {
          platform: 'linux',
          arch: 'x64'
        })
      }
    },
    'create-windows-installer': {
      'ia32': Object.assign({}, electronInstallerCommon, {
        appDirectory: path.join(outDir, appName + '-win32-ia32'),
        outputDirectory: process.env.CI_WINDOWS_INSTALLER_PATH || path.join('build', 'squirrel-ia32')
      })
    },
    'babel': {
      options: {
        sourceMap: true
      },
      dist: {
        files: [
          { expand: true, cwd: 'appsrc', src: ['**/*.js'], dest: 'app' },
          { expand: true, cwd: 'testsrc', src: ['**/*.js'], dest: 'test' }
        ]
      }
    },
    'sass': {
      options: {
        sourceMap: true
      },
      dist: {
        files: {
          'app/style/bundle.css': ['appsrc/style/bundle.scss', 'appsrc/style/**/*.scss']
        }
      }
    },
    'copy': {
      options: {
        mode: true
      },
      dist: {
        files: [
          { expand: true, cwd: 'appsrc', src: ['**/*.html', 'static/**'], dest: 'app' },
          { expand: true, cwd: 'testsrc', src: ['runner'], dest: 'test' }
        ]
      }
    }
  })

  grunt.registerTask('default', ['newer:babel', 'newer:sass', 'newer:copy'])
}
<commit_msg>:arrow_up: electron 1.2.3<commit_after>
require('quiet-grunt')

var channel = process.env.CI_CHANNEL || 'stable'
var appName = (channel === 'stable' ? 'itch' : 'kitch')

var fs = require('fs')
var path = require('path')
var packagePath = path.join(__dirname, 'package.json')
var version = process.env.CI_VERSION || JSON.parse(fs.readFileSync(packagePath, { encoding: 'utf8' })).version

var iconsPath = path.join('release', 'images', appName + '-icons')
var icoPath = path.join(iconsPath, 'itch.ico')
var icnsPath = path.join(iconsPath, 'itch.icns')
var installerGifPath = 'release/images/installer.gif'

var electronVersion = '1.2.3'
var outDir = path.join('build', 'v' + version)
var companyName = 'Itch Corp'

var gruntElectronCommon = {
  dir: 'stage',
  name: appName,
  version: electronVersion,
  'app-version': version,
  prune: true,
  asar: true,
  overwrite: true,
  out: outDir
}

var windowsElectronOptions = Object.assign({}, gruntElectronCommon, {
  platform: 'win32',
  icon: icoPath,
  'version-string': {
    CompanyName: companyName,
    LegalCopyright: 'MIT license, (c) Itch Corp',
    FileDescription: appName,
    OriginalFileName: appName + '.exe',
    FileVersion: version,
    AppVersion: version,
    ProductName: appName,
    InternalName: appName + '.exe'
  }
})

var electronInstallerCommon = {
  authors: companyName,
  exe: appName + '.exe',
  description: 'The best way to play itch.io games',
  version: version,
  title: appName,
  // sic. it's really itch.ico
  iconUrl: 'http://raw.githubusercontent.com/itchio/itch/master/release/images/' + appName + '-icons/itch.ico',
  loadingGif: installerGifPath,
  setupIcon: icoPath,
  remoteReleases: 'https://github.com/itchio/' + appName,
  signWithParams: '/v /s MY /n "Open Source Developer, Amos Wenger" /fd sha256 /tr http://timestamp.comodoca.com/?td=sha256 /td sha256',
  noMsi: true
}

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

  grunt.initConfig({
    // Create a .exe, .app, folder for windows, mac, linux
    electron: {
      'windows-ia32': {
        options: Object.assign({
          arch: 'ia32'
        }, windowsElectronOptions)
      },
      'darwin-x64': {
        options: Object.assign({}, gruntElectronCommon, {
          platform: 'darwin',
          arch: 'x64',
          icon: icnsPath,
          'app-bundle-id': 'io.' + appName + '.mac',
          'app-category-type': 'public.app-category.games',
          protocols: [{
            name: 'itch.io',
            schemes: [appName + 'io']
          }]
        })
      },
      'linux-ia32': {
        options: Object.assign({}, gruntElectronCommon, {
          platform: 'linux',
          arch: 'ia32'
        })
      },
      'linux-x64': {
        options: Object.assign({}, gruntElectronCommon, {
          platform: 'linux',
          arch: 'x64'
        })
      }
    },
    'create-windows-installer': {
      'ia32': Object.assign({}, electronInstallerCommon, {
        appDirectory: path.join(outDir, appName + '-win32-ia32'),
        outputDirectory: process.env.CI_WINDOWS_INSTALLER_PATH || path.join('build', 'squirrel-ia32')
      })
    },
    'babel': {
      options: {
        sourceMap: true
      },
      dist: {
        files: [
          { expand: true, cwd: 'appsrc', src: ['**/*.js'], dest: 'app' },
          { expand: true, cwd: 'testsrc', src: ['**/*.js'], dest: 'test' }
        ]
      }
    },
    'sass': {
      options: {
        sourceMap: true
      },
      dist: {
        files: {
          'app/style/bundle.css': ['appsrc/style/bundle.scss', 'appsrc/style/**/*.scss']
        }
      }
    },
    'copy': {
      options: {
        mode: true
      },
      dist: {
        files: [
          { expand: true, cwd: 'appsrc', src: ['**/*.html', 'static/**'], dest: 'app' },
          { expand: true, cwd: 'testsrc', src: ['runner'], dest: 'test' }
        ]
      }
    }
  })

  grunt.registerTask('default', ['newer:babel', 'newer:sass', 'newer:copy'])
}
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    sass: {
      options: {
        includePaths: ['bower_components/foundation/scss']
      },
      dist: {
        options: {
          outputStyle: 'compressed'
        },
        files: {
          'css/app.css': 'scss/app.scss'
        }
      }
    },

    watch: {
      grunt: { files: ['Gruntfile.js'] },

      sass: {
        files: 'scss/**/*.scss',
        tasks: ['sass']
      }
    }
  });

  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('build', ['sass']);
  grunt.registerTask('default', ['build','watch']);
}<commit_msg>Update SASS include paths<commit_after>module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    sass: {
      options: {
        includePaths: ['public/assets/vendor/foundation/scss']
      },
      dist: {
        options: {
          outputStyle: 'compressed'
        },
        files: {
          'public/assets/css/app.css': 'public/assets/scss/app.scss'
        }
      }
    },

    watch: {
      grunt: { files: ['Gruntfile.js'] },

      sass: {
        files: 'public/assets/scss/**/*.scss',
        tasks: ['sass']
      }
    }
  });

  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('build', ['sass']);
  grunt.registerTask('default', ['build','watch']);
}<|endoftext|>


<commit_before>/** @module other */

const EventEmitter = require('events')

/** @inheritdoc */
class Channel extends EventEmitter {
 // TODO: Implement me.
}

/** @inheritdoc */
class Account extends EventEmitter {
 // TODO: Implement me.
}

/** @inheritdoc */
class Identity extends EventEmitter {
  // TODO: Implement me.
}

/**
 * An interface for Features to interact with the chatternet.
 *
 * @inheritdoc
 */
class Chatternet extends EventEmitter {
  /**
   * @param {Object} args - destructured args.
   * @param {string} args.identity - Scope for chatternet interactions.
   */
  constructor({identity}) {
    super()
  }

  /** @return {Channel} The channel associated witht he given id or else null if it doesn't exist. */
  channel({id}) {
    return new Channel() // TODO: Implement me.
  }

  /** @return {Account} The account associated witht he given id or else null if it doesn't exist. */
  account({id}) {
    return new Account() // TODO: Implement me.
  }

  /** @return {Identity} The identity associated witht he given id or else null if it doesn't exist. */
  identity({id}) {
    return new Identity() // TODO: Implement me.
  }
}

/**
 * An interface for Features to interact with an Other Chat user agent.
 *
 * Supported events and their arguments:
 *   SET_STAGED_MESSAGE: {text}
 *
 * @inheritdoc
 */
class UserAgent extends EventEmitter {
  /** @return {Channel} The currently active channel. */
  channel() {
    return new Channel() // TODO: Implement me.
  }

  /** @return {Account} The currently active account. */
  account() {
    return new Account() // TODO: Implement me.
  }

  /** @return {Identity} The currently active identity. */
  identity() {
    return new Identity() // TODO: Implement me.
  }

  /**
   * Navigates to the given channel id.
   *
   * @param {Object} target - The navigation target.
   * @param {string} target.channelId - The channel identifier to navigate to. May be (1) identityId for identity channels (2) channelId for standard channels or (3) lowerIdentityId:upperIdentityId for whisper channels.
   */
  navigate({channelId}) {
    // TODO: Implement me.
  }
}

const userAgent = new UserAgent()

/**
 * An item which may be displayed as a chat complete result.
 */
class ChatCompleteResult {
  constructor({text}) {
    this.text = text
  }
}

/**
 * A command which users may run from the input area.
 */
class Command {
  /**
   * @param {Object} args - destructured args.
   * @param {string[]} args.tokens - Keyword tokens which the user may type at the beginning of the input area to invoke this command.
   * @param {onQueryCallback} args.onQuery - Called when one of the tokens is invoked by the user.
   */
  constructor({tokens, onQuery}) {
    this._tokens = tokens.sort((a, b) => b.length - a.length)  // Sort by length descending so that longest token is matched
    this._onQuery = onQuery
    userAgent.on('SET_STAGED_MESSAGE', event => {
      for (const token of this._tokens) {
        if (event.text.startsWith(token)) {
          this._onQuery(token, event.text.substring(token.length)).then(results => {
            console.log(results)
          })
          break
        }
      }
    })
  }

  /** @param {onQueryCallback} callback - Called when one of the tokens is invoked by the user. */
  onQuery(callback) {
    this._onQuery = callback
  }

  /**
   * @callback onQueryCallback
   * @param {string} token - The token that was invoked.
   * @param {string} query - The user's query (i.e. all text entered after the token).
   * @return {Promise} - A Promise to an array of ChatCompleteResults.
   */
}

/**
 * A package that extends Chatternet and/or Other Chat user agent functionality.
 * This is the base unit of other.js.
 */
class Feature {
  /**
   * @param {Object} metadata - metadata describing the package.
   * @param {string} metadata.name - User facing name.
   * @param {string} metadata.description - User facing, one-line description .
   * @param {string} metadata.version - {@link http://semver.org/|Semantic Version} used for determining compatibility with clients and other features.
   * @param {string} metadata.identity - Feature developer's Chatternet Identity under which all Chatternet operations are performed.
   * @param {Command[]} metadata.commands - Commands to register.
   */
  constructor({name, description, version, identity, commands = []}) {
    // TODO: Validation
    this.name = name
    this.description = description
    this.version = version
    this.identity = identity
    this.commands = commands
    this._chatternet = identity ? new Chatternet({identity}) : null
  }

  /** @return {Chatternet} The global chatternet as seen by this feature's identity or null if the feature doesn't have access. */
  get chatternet() {
    return this._chatternet
  }

  /** @return {UserAgent} The user agent's current browsing context. */
  get userAgent() {
    return userAgent
  }
}

module.exports = {ChatCompleteResult, Command, Feature}
<commit_msg>Create event constants<commit_after>/** @module other */

const EventEmitter = require('events')

/** @inheritdoc */
class Channel extends EventEmitter {
 // TODO: Implement me.
}

/** @inheritdoc */
class Account extends EventEmitter {
 // TODO: Implement me.
}

/** @inheritdoc */
class Identity extends EventEmitter {
  // TODO: Implement me.
}

/**
 * An interface for Features to interact with the chatternet.
 *
 * @inheritdoc
 */
class Chatternet extends EventEmitter {
  /**
   * @param {Object} args - destructured args.
   * @param {string} args.identity - Scope for chatternet interactions.
   */
  constructor({identity}) {
    super()
  }

  /** @return {Channel} The channel associated witht he given id or else null if it doesn't exist. */
  channel({id}) {
    return new Channel() // TODO: Implement me.
  }

  /** @return {Account} The account associated witht he given id or else null if it doesn't exist. */
  account({id}) {
    return new Account() // TODO: Implement me.
  }

  /** @return {Identity} The identity associated witht he given id or else null if it doesn't exist. */
  identity({id}) {
    return new Identity() // TODO: Implement me.
  }
}

/** @constant Event carrying a payload of {text} indicating unsent message text input by the user. */
const SET_STAGED_MESSAGE = 'SET_STAGED_MESSAGE'

/**
 * An interface for Features to interact with an Other Chat user agent.
 *
 * @inheritdoc
 */
class UserAgent extends EventEmitter {

  /** @return {Channel} The currently active channel. */
  channel() {
    return new Channel() // TODO: Implement me.
  }

  /** @return {Account} The currently active account. */
  account() {
    return new Account() // TODO: Implement me.
  }

  /** @return {Identity} The currently active identity. */
  identity() {
    return new Identity() // TODO: Implement me.
  }

  /**
   * Navigates to the given channel id.
   *
   * @param {Object} target - The navigation target.
   * @param {string} target.channelId - The channel identifier to navigate to. May be (1) identityId for identity channels (2) channelId for standard channels or (3) lowerIdentityId:upperIdentityId for whisper channels.
   */
  navigate({channelId}) {
    // TODO: Implement me.
  }
}

const userAgent = new UserAgent()

/**
 * An item which may be displayed as a chat complete result.
 */
class ChatCompleteResult {
  constructor({text}) {
    this.text = text
  }
}

/**
 * A command which users may run from the input area.
 */
class Command {
  /**
   * @param {Object} args - destructured args.
   * @param {string[]} args.tokens - Keyword tokens which the user may type at the beginning of the input area to invoke this command.
   * @param {onQueryCallback} args.onQuery - Called when one of the tokens is invoked by the user.
   */
  constructor({tokens, onQuery}) {
    this._tokens = tokens.sort((a, b) => b.length - a.length)  // Sort by length descending so that longest token is matched
    this._onQuery = onQuery
    userAgent.on(SET_STAGED_MESSAGE, event => {
      for (const token of this._tokens) {
        if (event.text.startsWith(token)) {
          this._onQuery(token, event.text.substring(token.length)).then(results => {
            console.log(results)
          })
          break
        }
      }
    })
  }

  /** @param {onQueryCallback} callback - Called when one of the tokens is invoked by the user. */
  onQuery(callback) {
    this._onQuery = callback
  }

  /**
   * @callback onQueryCallback
   * @param {string} token - The token that was invoked.
   * @param {string} query - The user's query (i.e. all text entered after the token).
   * @return {Promise} - A Promise to an array of ChatCompleteResults.
   */
}

/**
 * A package that extends Chatternet and/or Other Chat user agent functionality.
 * This is the base unit of other.js.
 */
class Feature {
  /**
   * @param {Object} metadata - metadata describing the package.
   * @param {string} metadata.name - User facing name.
   * @param {string} metadata.description - User facing, one-line description .
   * @param {string} metadata.version - {@link http://semver.org/|Semantic Version} used for determining compatibility with clients and other features.
   * @param {string} metadata.identity - Feature developer's Chatternet Identity under which all Chatternet operations are performed.
   * @param {Command[]} metadata.commands - Commands to register.
   */
  constructor({name, description, version, identity, commands = []}) {
    // TODO: Validation
    this.name = name
    this.description = description
    this.version = version
    this.identity = identity
    this.commands = commands
    this._chatternet = identity ? new Chatternet({identity}) : null
  }

  /** @return {Chatternet} The global chatternet as seen by this feature's identity or null if the feature doesn't have access. */
  get chatternet() {
    return this._chatternet
  }

  /** @return {UserAgent} The user agent's current browsing context. */
  get userAgent() {
    return userAgent
  }
}

module.exports = {ChatCompleteResult, Command, Feature}
<|endoftext|>


<commit_before>module.exports = function(grunt) {

	require('load-grunt-tasks')(grunt);
	require('time-grunt')(grunt);

	grunt.initConfig({
		sass: {
			compile: {
				options: {
					style: 'compressed'
				},
				files: {
					'styles/screen.css': 'styles/screen.scss'
				}
			}
		},
		cssshrink: {
			shrink: {
				files: {
					'styles/screen.css': 'styles/screen.css'
				}
			}
		},
		autoprefixer: {
			prefix: {
				src: 'styles/screen.css'
			}
		},
		jekyll: {
			full: {},
			limit: {
				options: {
					limit_posts: 150
				}
			}
		},
		htmlmin: {
			html: {
				options: {
					removeComments: true,
					collapseWhitespace: true
				},
				expand: true,
				cwd: '_site/',
				src: [
					'**/index.html',
					'errors/*.html'
				],
				dest: '_site/'
			},
			xml: {
				options: {
					collapseWhitespace: true,
					keepClosingSlash: true
				},
				files: {
					'_site/feed/index.xml': '_site/feed/index.xml'
				}
			}
		},
		connect: {
			task: {
				options: {
					base: '_site',
					port: 0,
					livereload: true,
					open: true
				}
			}
		},
		watch: {
			styles: {
				files: 'styles/*.scss',
				tasks: [
					'sass',
					'autoprefixer',
					'cssshrink',
					'copy'
				]
			},
			limit: {
				files: [
					'**',

					'!.git/**',
					'!.sass-cache/**',

					'!_scripts/**',
					'!_site/**',

					'!CONTRIBUTING.md',
					'!LICENSE.md',
					'!README.md',

					'!Gruntfile.js',
					'!node_modules/**',
					'!package.json',
					'!install.sh',
					'!styles/*',

					'!{articles,blog,tv}/**',
						'{articles,blog,tv}/index.html',
						'{articles,blog,tv}/**/_posts/*.md'
				],
				tasks: [
					'jekyll:limit',
					'htmlmin'
				]
			},
			livereload: {
				options: {
					livereload: true
				},
				files: [
					'_site/**/*.html',
					'_site/styles/screen.css'
				]
			}
		},
		copy: {
			css: {
				files: {
					'_site/styles/screen.css' : 'styles/screen.css'
				}
			}
		},
		replace: {
			remote: {
				src: '.htaccess',
				dest: '_site/',
				replacements: [{
					// Redirect all traffic to http://dev.opera.com/*
					from: 'RewriteEngine On\n\n',
					to: 'RewriteEngine On\n\nRewriteCond %{HTTP_HOST} !^dev\\.opera\\.com [NC]\nRewriteRule ^(.*)$ http://dev.opera.com%{REQUEST_URI} [R=301,L]\n\n'
				}]
			}
		},
		rsync: {
			options: {
				args: [
					// Note: the next line is commented out to avoid deleting the
					// `extension-docs` directory, which is generated from a separate
					// repository at the moment. As soon as the extension docs are merged
					// with the main `devopera` repository, we should re-enable it.
					//'--delete', // delete extraneous files on the receiving side
					'--times', // preserve modification times…
					'--omit-dir-times', // …except for directories
					'--compress', // compress data during the transfer
					'--verbose', // increase verbosity
					'--chmod=ug=rwX,o=rX', // `chmod` new files
					'--human-readable' // output numbers in a human-readable format
				],
				exclude: ['.DS_Store'],
				recursive: true
			},
			deploy: {
				options: {
					src: '_site/',
					dest: '/var/www/html/',
					host: '54.213.240.91'
				}
			}
		}
	});

	grunt.registerTask('default', [
		'sass',
		'autoprefixer',
		'cssshrink',
		'jekyll:limit',
		'htmlmin',
		'connect',
		'watch'
	]);

	grunt.registerTask('build', [
		'sass',
		'autoprefixer',
		'cssshrink',
		'jekyll:full',
		'htmlmin',
		'connect',
		'watch'
	]);

	grunt.registerTask('deploy', ['replace', 'rsync']);

};
<commit_msg>Random port doesn’t work for Node 0.11<commit_after>module.exports = function(grunt) {

	require('load-grunt-tasks')(grunt);
	require('time-grunt')(grunt);

	grunt.initConfig({
		sass: {
			compile: {
				options: {
					style: 'compressed'
				},
				files: {
					'styles/screen.css': 'styles/screen.scss'
				}
			}
		},
		cssshrink: {
			shrink: {
				files: {
					'styles/screen.css': 'styles/screen.css'
				}
			}
		},
		autoprefixer: {
			prefix: {
				src: 'styles/screen.css'
			}
		},
		jekyll: {
			full: {},
			limit: {
				options: {
					limit_posts: 150
				}
			}
		},
		htmlmin: {
			html: {
				options: {
					removeComments: true,
					collapseWhitespace: true
				},
				expand: true,
				cwd: '_site/',
				src: [
					'**/index.html',
					'errors/*.html'
				],
				dest: '_site/'
			},
			xml: {
				options: {
					collapseWhitespace: true,
					keepClosingSlash: true
				},
				files: {
					'_site/feed/index.xml': '_site/feed/index.xml'
				}
			}
		},
		connect: {
			task: {
				options: {
					base: '_site',
					port: 33310,
					livereload: true,
					open: true
				}
			}
		},
		watch: {
			styles: {
				files: 'styles/*.scss',
				tasks: [
					'sass',
					'autoprefixer',
					'cssshrink',
					'copy'
				]
			},
			limit: {
				files: [
					'**',

					'!.git/**',
					'!.sass-cache/**',

					'!_scripts/**',
					'!_site/**',

					'!CONTRIBUTING.md',
					'!LICENSE.md',
					'!README.md',

					'!Gruntfile.js',
					'!node_modules/**',
					'!package.json',
					'!install.sh',
					'!styles/*',

					'!{articles,blog,tv}/**',
						'{articles,blog,tv}/index.html',
						'{articles,blog,tv}/**/_posts/*.md'
				],
				tasks: [
					'jekyll:limit',
					'htmlmin'
				]
			},
			livereload: {
				options: {
					livereload: true
				},
				files: [
					'_site/**/*.html',
					'_site/styles/screen.css'
				]
			}
		},
		copy: {
			css: {
				files: {
					'_site/styles/screen.css' : 'styles/screen.css'
				}
			}
		},
		replace: {
			remote: {
				src: '.htaccess',
				dest: '_site/',
				replacements: [{
					// Redirect all traffic to http://dev.opera.com/*
					from: 'RewriteEngine On\n\n',
					to: 'RewriteEngine On\n\nRewriteCond %{HTTP_HOST} !^dev\\.opera\\.com [NC]\nRewriteRule ^(.*)$ http://dev.opera.com%{REQUEST_URI} [R=301,L]\n\n'
				}]
			}
		},
		rsync: {
			options: {
				args: [
					// Note: the next line is commented out to avoid deleting the
					// `extension-docs` directory, which is generated from a separate
					// repository at the moment. As soon as the extension docs are merged
					// with the main `devopera` repository, we should re-enable it.
					//'--delete', // delete extraneous files on the receiving side
					'--times', // preserve modification times…
					'--omit-dir-times', // …except for directories
					'--compress', // compress data during the transfer
					'--verbose', // increase verbosity
					'--chmod=ug=rwX,o=rX', // `chmod` new files
					'--human-readable' // output numbers in a human-readable format
				],
				exclude: ['.DS_Store'],
				recursive: true
			},
			deploy: {
				options: {
					src: '_site/',
					dest: '/var/www/html/',
					host: '54.213.240.91'
				}
			}
		}
	});

	grunt.registerTask('default', [
		'sass',
		'autoprefixer',
		'cssshrink',
		'jekyll:limit',
		'htmlmin',
		'connect',
		'watch'
	]);

	grunt.registerTask('build', [
		'sass',
		'autoprefixer',
		'cssshrink',
		'jekyll:full',
		'htmlmin',
		'connect',
		'watch'
	]);

	grunt.registerTask('deploy', ['replace', 'rsync']);

};
<|endoftext|>


<commit_before>/*
 * grunt-angular-templates
 * https://github.com/ericclemmons/grunt-angular-templates
 *
 * Copyright (c) 2013 Eric Clemmons
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  grunt.initConfig({
    clean: {
      tests: 'tmp'
    },
    nodeunit: {
      tests: ['test/*.js']
    },
    watch: {
      tests: '<%= nodeunit.tests %>',
      tasks: 'default'
    },
    jshint: {
      all: ['Gruntfile.js', 'tasks/**/*.js', '<%= nodeunit.tests %>'],
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        boss: true,
        eqnull: true,
        node: true,
        es5: true
      },
      globals: {}
    },
    concat: {
      custom_concat: {
        src: 'test/fixtures/one.html',
        dest: 'tmp/custom_concat_combined.js',
        options: {
          separator: '\n\n'
        }
      }
    },

    // All supported examples should be here
    ngtemplates: {
      // Change `angular` namespace to something else
      custom_angular: {
        src: 'test/fixtures/**/*.html',
        dest: 'tmp/custom_angular.js',
        options: {
          angular: 'myAngular'
        }
      },

      // Custom CommonJS bootstrapper
      custom_bootstrap: {
        src: 'test/fixtures/**/*.html',
        dest: 'tmp/custom_bootstrap.js',
        options: {
          bootstrap: function(module, script) {
            return 'module.exports = function($templateCache) {\n' + script + '\n};\n';
          }
        }
      },

      // Append dest to existing concat target
      custom_concat: {
        src: 'test/fixtures/**/*.html',
        dest: 'tmp/custom_concat.js',
        options: {
          concat: 'custom_concat'
        }
      },

      // Minify the HTML
      custom_htmlmin: {
        src: 'test/fixtures/**/*.html',
        dest: 'tmp/custom_htmlmin.js',
        options: {
          htmlmin: {
            collapseBooleanAttributes:      true,
            collapseWhitespace:             true,
            removeAttributeQuotes:          true,
            removeComments:                 true,
            removeEmptyAttributes:          true,
            removeRedundantAttributes:      true,
            removeScriptTypeAttributes:     true,
            removeStyleLinkTypeAttributes:  true
          }
        }
      },

      // Minify the HTML, but using another tasks' settings
      task_htmlmin: {
        src: 'test/fixtures/**/*.html',
        dest: 'tmp/task_htmlmin.js',
        options: {
          htmlmin: '<%= ngtemplates.custom_htmlmin.options.htmlmin %>'
        }
      },

      // Default `module` option to the sub-task name (`default_module`)
      default_module: {
        src: 'test/fixtures/**/*.html',
        dest: 'tmp/default_module.js'
      },

      // Customize angular module
      custom_module: {
        src: 'test/fixtures/**/*.html',
        dest: 'tmp/custom_module.js',
        options: {
          module: 'customModule'
        }
      },

      // Customize angular module
      callback_module: {
        src: 'test/fixtures/**/*.html',
        dest: 'tmp/callback_module.js',
        options: {
          module: function(url, options) {
            return url.split('/').join('.');
          },
          url: function(file) {
            return file.replace('.html', '');
          }
        }
      },

      // Customize template source
      custom_source: {
        src: 'test/fixtures/**/*.html',
        dest: 'tmp/custom_source.js',
        options: {
          source: function(source, url) {
            return "<!-- Template: " + url + " -->\n" + source;
          }
        }
      },

      // Module should be new & have [] defined
      standalone: {
        src: 'test/fixtures/**/*.html',
        dest: 'tmp/standalone.js',
        options: {
          standalone: true
        }
      },

      // URLs should match path exactly
      full_url: {
        src: 'test/fixtures/**/*.html',
        dest: 'tmp/full_url.js'
      },

      // URLs should match path, sans the `cwd`
      relative_url: {
        cwd: 'test/fixtures',
        src: '**/*.html',
        dest: 'tmp/relative_url.js'
      },

      // Customize URLs to not have an extension
      custom_url:  {
        src: 'test/fixtures/**/*.html',
        dest: 'tmp/custom_url.js',
        options: {
          url: function(url) {
            return url.replace('.html', '');
          }
        }
      }
    }
  });

  // Load local tasks.
  grunt.loadTasks('tasks');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-nodeunit');

  grunt.registerTask('default', ['jshint', 'clean', 'ngtemplates', 'concat', 'nodeunit']);
};
<commit_msg>Whitelist most test fixtures<commit_after>/*
 * grunt-angular-templates
 * https://github.com/ericclemmons/grunt-angular-templates
 *
 * Copyright (c) 2013 Eric Clemmons
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  grunt.initConfig({
    clean: {
      tests: 'tmp'
    },
    nodeunit: {
      tests: ['test/*.js']
    },
    watch: {
      tests: '<%= nodeunit.tests %>',
      tasks: 'default'
    },
    jshint: {
      all: ['Gruntfile.js', 'tasks/**/*.js', '<%= nodeunit.tests %>'],
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        boss: true,
        eqnull: true,
        node: true,
        es5: true
      },
      globals: {}
    },
    concat: {
      custom_concat: {
        src: 'test/fixtures/one.html',
        dest: 'tmp/custom_concat_combined.js',
        options: {
          separator: '\n\n'
        }
      }
    },

    // All supported examples should be here
    ngtemplates: {
      // Change `angular` namespace to something else
      custom_angular: {
        src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
        dest: 'tmp/custom_angular.js',
        options: {
          angular: 'myAngular'
        }
      },

      // Custom CommonJS bootstrapper
      custom_bootstrap: {
        src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
        dest: 'tmp/custom_bootstrap.js',
        options: {
          bootstrap: function(module, script) {
            return 'module.exports = function($templateCache) {\n' + script + '\n};\n';
          }
        }
      },

      // Append dest to existing concat target
      custom_concat: {
        src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
        dest: 'tmp/custom_concat.js',
        options: {
          concat: 'custom_concat'
        }
      },

      // Minify the HTML
      custom_htmlmin: {
        src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
        dest: 'tmp/custom_htmlmin.js',
        options: {
          htmlmin: {
            collapseBooleanAttributes:      true,
            collapseWhitespace:             true,
            removeAttributeQuotes:          true,
            removeComments:                 true,
            removeEmptyAttributes:          true,
            removeRedundantAttributes:      true,
            removeScriptTypeAttributes:     true,
            removeStyleLinkTypeAttributes:  true
          }
        }
      },

      // Minify the HTML, but using another tasks' settings
      task_htmlmin: {
        src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
        dest: 'tmp/task_htmlmin.js',
        options: {
          htmlmin: '<%= ngtemplates.custom_htmlmin.options.htmlmin %>'
        }
      },

      // Default `module` option to the sub-task name (`default_module`)
      default_module: {
        src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
        dest: 'tmp/default_module.js'
      },

      // Customize angular module
      custom_module: {
        src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
        dest: 'tmp/custom_module.js',
        options: {
          module: 'customModule'
        }
      },

      // Customize angular module
      callback_module: {
        src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
        dest: 'tmp/callback_module.js',
        options: {
          module: function(url, options) {
            return url.split('/').join('.');
          },
          url: function(file) {
            return file.replace('.html', '');
          }
        }
      },

      // Customize template source
      custom_source: {
        src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
        dest: 'tmp/custom_source.js',
        options: {
          source: function(source, url) {
            return "<!-- Template: " + url + " -->\n" + source;
          }
        }
      },

      // Module should be new & have [] defined
      standalone: {
        src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
        dest: 'tmp/standalone.js',
        options: {
          standalone: true
        }
      },

      // URLs should match path exactly
      full_url: {
        src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
        dest: 'tmp/full_url.js'
      },

      // URLs should match path, sans the `cwd`
      relative_url: {
        cwd: 'test/fixtures',
        src: ['one.html', 'two/**/*.html'],
        dest: 'tmp/relative_url.js'
      },

      // Customize URLs to not have an extension
      custom_url:  {
        src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
        dest: 'tmp/custom_url.js',
        options: {
          url: function(url) {
            return url.replace('.html', '');
          }
        }
      }
    }
  });

  // Load local tasks.
  grunt.loadTasks('tasks');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-nodeunit');

  grunt.registerTask('default', ['jshint', 'clean', 'ngtemplates', 'concat', 'nodeunit']);
};
<|endoftext|>


<commit_before>'use strict';

module.exports = function (grunt) {

  grunt.initConfig({
    // lint
    tslint: {
      options: {
        configuration: grunt.file.readJSON('tslint.json')
      },
      src: {
        src: ['src/ts/**/*.ts']
      }
    },

    // build
    ts: {
      options: {
        fast: 'never',
        target: 'es5'
      },
      dev: {
        src: 'src/ts/**/*.ts',
        out: 'bin/js/lsystems.js',
        options: {
          sourcemap: true,
          removeComments: false
        }
      },
      prod: {
        src: 'src/ts/**/*.ts',
        out: 'bin/js/lsystems.js',
        options: {
          sourcemap: false,
          removeComments: true
        }
      }
    },
    jade: {
      dev: {
        src: 'src/jade/index.jade',
        dest: 'bin/index.html'
      },
      prod: {
        src: 'src/jade/index.jade',
        dest: 'bin/index.html'
      }
    },
    less: {
      options: {
        paths: [
          'node_modules/bootstrap-less',
          'node_modules/bootswatch'
        ]
      },
      dev: {
        src: 'src/less/index.less',
        dest: 'bin/css/index.css',
        options: {
          sourceMap: true,
          sourceMapRootpath: '../..',
          sourceMapBasepath: '.',
          compress: false
        }
      },
      prod: {
        src: 'src/less/index.less',
        dest: 'bin/css/index.css',
        options: {
          sourceMap: false,
          compress: true
        }
      }
    },
    copy: {
      res: {
        files: [
          {
            expand: true,
            cwd: 'src/res',
            src: ['**/*'],
            dest: 'bin/res'
          }
        ]
      }
    },
    uglify: {
      prod: {
        files: {
          '<%= ts.prod.out %>': '<%= ts.prod.out %>'
        }
      }
    },

    // clean
    clean: {
      js: {
        src: ['bin/js']
      },
      html: {
        src: ['bin/index.html']
      },
      css: {
        src: ['bin/css']
      },
      res: {
        src: ['bin/res']
      },
      bin: {
        src: ['bin']
      },
      remove_src_baseDir: {
        src: ['src/ts/**/.baseDir.ts'],
        dot: true
      }
    },

    // other
    watch: {
      ts: {
        files: ['src/ts/**/*'],
        tasks: ['clean:js', 'build_dev:ts']
      },
      jade: {
        files: ['src/jade/**/*'],
        tasks: ['clean:html', 'build_dev:jade']
      },
      less: {
        files: ['src/less/**/*'],
        tasks: ['clean:css', 'build_dev:less']
      },
      res: {
        files: ['src/res/**/*'],
        tasks: ['clean:res', 'copy:res']
      }
    },
    todo: {
      options: {},
      src: ['src/**/*']
    }
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-jade');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-todo');
  grunt.loadNpmTasks('grunt-ts');
  grunt.loadNpmTasks('grunt-tslint');

  grunt.registerTask('build_dev:ts', ['tslint:src', 'ts:dev', 'clean:remove_src_baseDir']);
  grunt.registerTask('build_dev:jade', ['jade:dev']);
  grunt.registerTask('build_dev:less', ['less:dev']);
  grunt.registerTask('build_dev', ['clean:bin', 'build_dev:ts', 'build_dev:jade', 'build_dev:less', 'copy:res']);

  grunt.registerTask('build:ts', ['tslint:src', 'ts:prod', 'clean:remove_src_baseDir', 'uglify:prod']);
  grunt.registerTask('build:jade', ['jade:prod']);
  grunt.registerTask('build:less', ['less:prod']);
  grunt.registerTask('build', ['clean:bin', 'build:ts', 'build:jade', 'build:less', 'copy:res']);

  grunt.registerTask('default', ['build_dev', 'todo']);

};
<commit_msg>Added temp fix for issue with LESS source maps https://github.com/gruntjs/grunt-contrib-less/issues/236<commit_after>'use strict';

module.exports = function (grunt) {

  grunt.initConfig({
    // lint
    tslint: {
      options: {
        configuration: grunt.file.readJSON('tslint.json')
      },
      src: {
        src: ['src/ts/**/*.ts']
      }
    },

    // build
    ts: {
      options: {
        fast: 'never',
        target: 'es5'
      },
      dev: {
        src: 'src/ts/**/*.ts',
        out: 'bin/js/lsystems.js',
        options: {
          sourcemap: true,
          removeComments: false
        }
      },
      prod: {
        src: 'src/ts/**/*.ts',
        out: 'bin/js/lsystems.js',
        options: {
          sourcemap: false,
          removeComments: true
        }
      }
    },
    jade: {
      dev: {
        src: 'src/jade/index.jade',
        dest: 'bin/index.html'
      },
      prod: {
        src: 'src/jade/index.jade',
        dest: 'bin/index.html'
      }
    },
    less: {
      options: {
        paths: [
          'node_modules/bootstrap-less',
          'node_modules/bootswatch'
        ]
      },
      dev: {
        src: 'src/less/index.less',
        dest: 'bin/css/index.css',
        options: {
          sourceMap: true,
          sourceMapRootpath: '../..',
          sourceMapBasepath: '.',
          sourceMapURL: 'index.css.map', // TODO: temporary fix for https://github.com/gruntjs/grunt-contrib-less/issues/236
          compress: false
        }
      },
      prod: {
        src: 'src/less/index.less',
        dest: 'bin/css/index.css',
        options: {
          sourceMap: false,
          compress: true
        }
      }
    },
    copy: {
      res: {
        files: [
          {
            expand: true,
            cwd: 'src/res',
            src: ['**/*'],
            dest: 'bin/res'
          }
        ]
      }
    },
    uglify: {
      prod: {
        files: {
          '<%= ts.prod.out %>': '<%= ts.prod.out %>'
        }
      }
    },

    // clean
    clean: {
      js: {
        src: ['bin/js']
      },
      html: {
        src: ['bin/index.html']
      },
      css: {
        src: ['bin/css']
      },
      res: {
        src: ['bin/res']
      },
      bin: {
        src: ['bin']
      },
      remove_src_baseDir: {
        src: ['src/ts/**/.baseDir.ts'],
        dot: true
      }
    },

    // other
    watch: {
      ts: {
        files: ['src/ts/**/*'],
        tasks: ['clean:js', 'build_dev:ts']
      },
      jade: {
        files: ['src/jade/**/*'],
        tasks: ['clean:html', 'build_dev:jade']
      },
      less: {
        files: ['src/less/**/*'],
        tasks: ['clean:css', 'build_dev:less']
      },
      res: {
        files: ['src/res/**/*'],
        tasks: ['clean:res', 'copy:res']
      }
    },
    todo: {
      options: {},
      src: ['src/**/*']
    }
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-jade');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-todo');
  grunt.loadNpmTasks('grunt-ts');
  grunt.loadNpmTasks('grunt-tslint');

  grunt.registerTask('build_dev:ts', ['tslint:src', 'ts:dev', 'clean:remove_src_baseDir']);
  grunt.registerTask('build_dev:jade', ['jade:dev']);
  grunt.registerTask('build_dev:less', ['less:dev']);
  grunt.registerTask('build_dev', ['clean:bin', 'build_dev:ts', 'build_dev:jade', 'build_dev:less', 'copy:res']);

  grunt.registerTask('build:ts', ['tslint:src', 'ts:prod', 'clean:remove_src_baseDir', 'uglify:prod']);
  grunt.registerTask('build:jade', ['jade:prod']);
  grunt.registerTask('build:less', ['less:prod']);
  grunt.registerTask('build', ['clean:bin', 'build:ts', 'build:jade', 'build:less', 'copy:res']);

  grunt.registerTask('default', ['build_dev', 'todo']);

};
<|endoftext|>


<commit_before>/*
 * grunt-contrib-jade
 * http://gruntjs.com/
 *
 * Copyright (c) 2012 Eric Woroshow, contributors
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/*.js',
        '<%= nodeunit.tests %>'
      ],
      options: {
        jshintrc: '.jshintrc'
      }
    },

    // Before generating any new files, remove any previously-created files.
    clean: {
      test: ['tmp']
    },

    // Configuration to be run (and then tested).
    jade: {
      compile: {
        files: {
          'tmp/jade.html': ['test/fixtures/jade.jade'],
          'tmp/jade2.html': ['test/fixtures/jade2.jade'],
          'tmp/jadeInclude.html': ['test/fixtures/jadeInclude.jade'],
          'tmp/jadeTemplate.html': ['test/fixtures/jadeTemplate.jade']
        },
        options: {
          data: {
            test: true,
            year: '<%= grunt.template.today("yyyy") %>'
          }
        }
      }
    },

    // Unit tests.
    nodeunit: {
      tests: ['test/*_test.js']
    }
  });

  // Actually load this plugin's task(s).
  grunt.loadTasks('tasks');

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-nodeunit');
  grunt.loadNpmTasks('grunt-contrib-internal');

  // Whenever the "test" task is run, first clean the "tmp" dir, then run this
  // plugin's task(s), then test the result.
  grunt.registerTask('test', ['jade', 'nodeunit']);

  // By default, lint and run all tests.
  grunt.registerTask('default', ['jshint', 'test', 'build-contrib']);

};
<commit_msg>clean before running tests<commit_after>/*
 * grunt-contrib-jade
 * http://gruntjs.com/
 *
 * Copyright (c) 2012 Eric Woroshow, contributors
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/*.js',
        '<%= nodeunit.tests %>'
      ],
      options: {
        jshintrc: '.jshintrc'
      }
    },

    // Before generating any new files, remove any previously-created files.
    clean: {
      test: ['tmp']
    },

    // Configuration to be run (and then tested).
    jade: {
      compile: {
        files: {
          'tmp/jade.html': ['test/fixtures/jade.jade'],
          'tmp/jade2.html': ['test/fixtures/jade2.jade'],
          'tmp/jadeInclude.html': ['test/fixtures/jadeInclude.jade'],
          'tmp/jadeTemplate.html': ['test/fixtures/jadeTemplate.jade']
        },
        options: {
          data: {
            test: true,
            year: '<%= grunt.template.today("yyyy") %>'
          }
        }
      }
    },

    // Unit tests.
    nodeunit: {
      tests: ['test/*_test.js']
    }
  });

  // Actually load this plugin's task(s).
  grunt.loadTasks('tasks');

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-nodeunit');
  grunt.loadNpmTasks('grunt-contrib-internal');

  // Whenever the "test" task is run, first clean the "tmp" dir, then run this
  // plugin's task(s), then test the result.
  grunt.registerTask('test', ['clean', 'jade', 'nodeunit']);

  // By default, lint and run all tests.
  grunt.registerTask('default', ['jshint', 'test', 'build-contrib']);

};
<|endoftext|>


<commit_before>/*global module:false*/
module.exports = function(grunt) {

  var shellOpts = {
    stdout: true,
    failOnError: true
  };

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    meta: {
      banner: '/*! KMC - v<%= pkg.version %> - ' +
        '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
        '* https://github.com/kaltura/LiveAnalytics\n' +
        '* Copyright (c) <%= grunt.template.today("yyyy") %> ' +
        'Atar Shadmi; Licensed GNU */\n'
    },
    concat: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        src: [
          'app/js/app.js',
          'app/js/controllers.js',
          'app/js/directiveControllers.js',
          'app/js/directives.js',
          'app/js/filters.js',
          'app/js/services.js',
          'app/js/dummyServices.js'
        ],
        dest: 'app/js/livea.js'
      },
      libs: {
          src: [
              'app/lib/jquery/jquery-1.10.2.min.js',
              'app/lib/jquery-ui/jquery-ui-1.10.4/ui/minified/jquery-ui.min.js',
              'app/lib/bootstrap/bootstrap-3.1.1-dist/js/bootstrap.min.js',
              'app/lib/bootstrap/bootstrap-paginator.js',
              'app/lib/angular/angular.min.js',
              'app/lib/angular/angular-resource.min.js',
              'app/lib/angular/angular-route.min.js',
              'app/lib/rickshaw/rickshaw.js',
              'app/lib/rickshaw/d3.v3.js',
              'app/lib/rickshaw/d3.layout.min.js',
              'app/lib/kaltura/KHoverDetail.js',
              'app/lib/OpenLayers-2.13.1/OpenLayers.js'
          ],
          dest: '_dist/js/libs.js'
      }
    },
    uglify: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        files: {
          '_dist/js/livea.min.js': ['<%= concat.dist.dest %>']
        }
      }
    },
    cssmin: {
        combine: {
            files: {
                '_dist/css/vendor.css': [
                                         'app/lib/bootstrap/bootstrap-3.1.1-dist/css/bootstrap.css',
                                         'app/lib/jquery-ui/jquery-ui-1.10.4/themes/base/jquery-ui.css',
                                         'app/lib/rickshaw/css/rickshaw.css',
                                         'app/lib/OpenLayers-2.13.1/theme/default/style.css'
                                         ]
            }

        }
    },
    clean: {
        build: ["_dist", "_dist/js", "_dist/css"]
    },
    copy: {
        main: {
            files: [
                    { // dummy data
                    	expand: true,
                    	cwd: 'app/data/',
                    	src: '**',
                    	dest: '_dist/data/'
                    },
                { // main files
                    expand: true,
                    cwd: 'app/dist_src',
                    src: '**',
                    dest: '_dist/'
                },
                { // partials
                    expand: true,
                    cwd: 'app/partials/',
                    src: '**',
                    dest: '_dist/partials/'
                },
                // js app + vendor are created directly in place
                { // css - app (vendor is created directly in place)
                    src: 'app/css/app.css',
                    dest: '_dist/css/app.css'
                },
                { // fonts
                	 expand: true,
                     cwd: 'app/lib/bootstrap/bootstrap-3.1.1-dist/fonts',
                     src: '*',
                     dest: '_dist/fonts'
                },
                { // open layers images
                	expand: true,
                	cwd: 'app/lib/OpenLayers-2.13.1/theme/default/img',
                	src: '*',
                	dest: '_dist/css/images/ol'
                },
                { // jquery ui images
                	expand: true,
                	cwd: 'app/lib/jquery-ui/jquery-ui-1.10.4/themes/base/minified/images',
                	src: '*',
                	dest: '_dist/css/images'
                },

            ]
        }
    },
    clean: {
    	build: ['app/js/livea.js']
    }

  });

  // Add grunt plugins
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-clean');

  // Default task.
  grunt.registerTask('default', ['clean:build', 'copy:main', 'concat:dist', 'uglify:dist', 'concat:libs', 'cssmin:combine', 'clean:build']);
};
<commit_msg>add deployment files to _dist<commit_after>/*global module:false*/
module.exports = function(grunt) {

  var shellOpts = {
    stdout: true,
    failOnError: true
  };

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    meta: {
      banner: '/*! KMC - v<%= pkg.version %> - ' +
        '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
        '* https://github.com/kaltura/LiveAnalytics\n' +
        '* Copyright (c) <%= grunt.template.today("yyyy") %> ' +
        'Atar Shadmi; Licensed GNU */\n'
    },
    concat: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        src: [
          'app/js/app.js',
          'app/js/controllers.js',
          'app/js/directiveControllers.js',
          'app/js/directives.js',
          'app/js/filters.js',
          'app/js/services.js',
          'app/js/dummyServices.js'
        ],
        dest: 'app/js/livea.js'
      },
      libs: {
          src: [
              'app/lib/jquery/jquery-1.10.2.min.js',
              'app/lib/jquery-ui/jquery-ui-1.10.4/ui/minified/jquery-ui.min.js',
              'app/lib/bootstrap/bootstrap-3.1.1-dist/js/bootstrap.min.js',
              'app/lib/bootstrap/bootstrap-paginator.js',
              'app/lib/angular/angular.min.js',
              'app/lib/angular/angular-resource.min.js',
              'app/lib/angular/angular-route.min.js',
              'app/lib/rickshaw/rickshaw.js',
              'app/lib/rickshaw/d3.v3.js',
              'app/lib/rickshaw/d3.layout.min.js',
              'app/lib/kaltura/KHoverDetail.js',
              'app/lib/OpenLayers-2.13.1/OpenLayers.js'
          ],
          dest: '_dist/js/libs.js'
      }
    },
    uglify: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        files: {
          '_dist/js/livea.min.js': ['<%= concat.dist.dest %>']
        }
      }
    },
    cssmin: {
        combine: {
            files: {
                '_dist/css/vendor.css': [
                                         'app/lib/bootstrap/bootstrap-3.1.1-dist/css/bootstrap.css',
                                         'app/lib/jquery-ui/jquery-ui-1.10.4/themes/base/jquery-ui.css',
                                         'app/lib/rickshaw/css/rickshaw.css',
                                         'app/lib/OpenLayers-2.13.1/theme/default/style.css'
                                         ]
            }

        }
    },
    clean: {
        build: ["_dist", "_dist/js", "_dist/css"]
    },
    copy: {
        main: {
            files: [
                    { // dummy data
                    	expand: true,
                    	cwd: 'app/data/',
                    	src: '**',
                    	dest: '_dist/data/'
                    },
                { // main files
                    expand: true,
                    cwd: 'app/dist_src',
                    src: '**',
                    dest: '_dist/'
                },
                { // partials
                    expand: true,
                    cwd: 'app/partials/',
                    src: '**',
                    dest: '_dist/partials/'
                },
                // js app + vendor are created directly in place
                { // css - app (vendor is created directly in place)
                    src: 'app/css/app.css',
                    dest: '_dist/css/app.css'
                },
                { // fonts
                	 expand: true,
                     cwd: 'app/lib/bootstrap/bootstrap-3.1.1-dist/fonts',
                     src: '*',
                     dest: '_dist/fonts'
                },
                { // open layers images
                	expand: true,
                	cwd: 'app/lib/OpenLayers-2.13.1/theme/default/img',
                	src: '*',
                	dest: '_dist/css/images/ol'
                },
                { // jquery ui images
                	expand: true,
                	cwd: 'app/lib/jquery-ui/jquery-ui-1.10.4/themes/base/minified/images',
                	src: '*',
                	dest: '_dist/css/images'
                },
                { // deployment
                	expand: true,
                	cwd: 'deploy',
                	src: '**',
                	dest: '_dist/deploy'
                },

            ]
        }
    },
    clean: {
    	build: ['app/js/livea.js']
    }

  });

  // Add grunt plugins
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-clean');

  // Default task.
  grunt.registerTask('default', ['clean:build', 'copy:main', 'concat:dist', 'uglify:dist', 'concat:libs', 'cssmin:combine', 'clean:build']);
};
<|endoftext|>


<commit_before>/*jshint node:true */
module.exports = function( grunt ) {

require( "load-grunt-tasks" )( grunt );

function process( code ) {
	return code

		// Embed version
		.replace( /@VERSION/g, grunt.config( "pkg" ).version )

		// Embed date (yyyy-mm-ddThh:mmZ)
		.replace( /@DATE/g, ( new Date() ).toISOString().replace( /:\d+\.\d+Z$/, "Z" ) );
}

grunt.initConfig({
	pkg: grunt.file.readJSON( "package.json" ),
	concat: {
		"src-js": {
			options: { process: process },
			src: [
				"src/intro.js",
				"src/core.js",
				"src/test.js",
				"src/assert.js",
				"src/equiv.js",
				"src/dump.js",
				"src/diff.js",
				"src/export.js",
				"src/outro.js"
			],
			dest: "dist/qunit.js"
		},
		"src-css": {
			options: { process: process },
			src: [
				"src/qunit.css"
			],
			dest: "dist/qunit.css"
		}
	},
	jshint: {
		options: {
			jshintrc: ".jshintrc"
		},
		gruntfile: [ "Gruntfile.js" ],
		dist: [ "dist/*.js" ],
		tests: [ "test/**/*.js" ]
	},
	qunit: {
		options: {
			timeout: 30000,
			"--web-security": "no",
			coverage: {
				src: [ "dist/qunit.js" ],
				instrumentedFiles: "temp/",
				htmlReport: "build/report/coverage",
				lcovReport: "build/report/lcov",
				linesThresholdPct: 70
			}
		},
		qunit: [
			"test/index.html",
			"test/async.html",
			"test/logs.html",
			"test/setTimeout.html"
		]
	},
	coveralls: {
		options: {
			force: true
		},
		all: {

			// LCOV coverage file relevant to every target
			src: "build/report/lcov/lcov.info"
		}
	},
	watch: {
		files: [ "*", ".jshintrc", "{src,test}/**/{*,.*}" ],
		tasks: "default"
	}
});

grunt.registerTask( "testswarm", function( commit, configFile, projectName, browserSets, timeout ) {
	var config,
		testswarm = require( "testswarm" ),
		runs = {},
		done = this.async();

	projectName = projectName || "qunit";
	config = grunt.file.readJSON( configFile )[ projectName ];
	browserSets = browserSets || config.browserSets;
	if ( browserSets[ 0 ] === "[" ) {
		// We got an array, parse it
		browserSets = JSON.parse( browserSets );
	}
	timeout = timeout || 1000 * 60 * 15;

	[ "index", "async", "setTimeout" ].forEach(function ( suite ) {
		runs[ suite ] = config.testUrl + commit + "/test/" + suite + ".html";
	});

	testswarm
		.createClient({
			url: config.swarmUrl
		})
		.addReporter( testswarm.reporters.cli )
		.auth({
			id: config.authUsername,
			token: config.authToken
		})
		.addjob({
			name: "Commit " +
				commit.substr( 0, 10 ) + "",
			runs: runs,
			browserSets: browserSets,
			timeout: timeout
		}, function( err, passed ) {
			if ( err ) {
				grunt.log.error( err );
			}
			done( passed );
		});
});

// TODO: Extract this task later, if feasible
// Also spawn a separate process to keep tests atomic
grunt.registerTask( "test-on-node", function() {
	var testActive = false,
		runDone = false,
		done = this.async(),
		QUnit = require( "./dist/qunit" );

	// Make the current tests work in the Node.js environment by appending
	// a bunch of properties into the `global` object
	[ "test", "asyncTest", "start", "stop", "expect" ].forEach(function( method ) {
		global[ method ] = QUnit[ method ];
	});
	global.QUnit = QUnit;

	QUnit.testStart(function() {
		testActive = true;
	});
	QUnit.log(function( details ) {
		if ( !testActive || details.result ) {
			return;
		}
		var message = "name: " + details.name + " module: " + details.module +
			" message: " + details.message;
		grunt.log.error( message );
	});
	QUnit.testDone(function() {
		testActive = false;
	});
	QUnit.done(function( details ) {
		if ( runDone ) {
			return;
		}
		var succeeded = ( details.failed === 0 ),
			message = details.total + " assertions in (" + details.runtime + "ms), passed: " +
				details.passed + ", failed: " + details.failed;
		if ( succeeded ) {
			grunt.log.ok( message );
		} else {
			grunt.log.error( message );
		}
		done( succeeded );
		runDone = true;
	});
	QUnit.config.autorun = false;

	require( "./test/logs" );
	require( "./test/test" );
	require( "./test/deepEqual" );
	require( "./test/globals" );

	QUnit.load();
});

grunt.registerTask( "build", [ "concat" ] );
grunt.registerTask( "default", [ "build", "jshint", "qunit", "test-on-node" ] );

};
<commit_msg>Grunt: Watch task run the default task at start<commit_after>/*jshint node:true */
module.exports = function( grunt ) {

require( "load-grunt-tasks" )( grunt );

function process( code ) {
	return code

		// Embed version
		.replace( /@VERSION/g, grunt.config( "pkg" ).version )

		// Embed date (yyyy-mm-ddThh:mmZ)
		.replace( /@DATE/g, ( new Date() ).toISOString().replace( /:\d+\.\d+Z$/, "Z" ) );
}

grunt.initConfig({
	pkg: grunt.file.readJSON( "package.json" ),
	concat: {
		"src-js": {
			options: { process: process },
			src: [
				"src/intro.js",
				"src/core.js",
				"src/test.js",
				"src/assert.js",
				"src/equiv.js",
				"src/dump.js",
				"src/diff.js",
				"src/export.js",
				"src/outro.js"
			],
			dest: "dist/qunit.js"
		},
		"src-css": {
			options: { process: process },
			src: [
				"src/qunit.css"
			],
			dest: "dist/qunit.css"
		}
	},
	jshint: {
		options: {
			jshintrc: ".jshintrc"
		},
		gruntfile: [ "Gruntfile.js" ],
		dist: [ "dist/*.js" ],
		tests: [ "test/**/*.js" ]
	},
	qunit: {
		options: {
			timeout: 30000,
			"--web-security": "no",
			coverage: {
				src: [ "dist/qunit.js" ],
				instrumentedFiles: "temp/",
				htmlReport: "build/report/coverage",
				lcovReport: "build/report/lcov",
				linesThresholdPct: 70
			}
		},
		qunit: [
			"test/index.html",
			"test/async.html",
			"test/logs.html",
			"test/setTimeout.html"
		]
	},
	coveralls: {
		options: {
			force: true
		},
		all: {

			// LCOV coverage file relevant to every target
			src: "build/report/lcov/lcov.info"
		}
	},
	watch: {
		options: {
			atBegin: true
		},
		files: [ "*", ".jshintrc", "{src,test}/**/{*,.*}" ],
		tasks: "default"
	}
});

grunt.registerTask( "testswarm", function( commit, configFile, projectName, browserSets, timeout ) {
	var config,
		testswarm = require( "testswarm" ),
		runs = {},
		done = this.async();

	projectName = projectName || "qunit";
	config = grunt.file.readJSON( configFile )[ projectName ];
	browserSets = browserSets || config.browserSets;
	if ( browserSets[ 0 ] === "[" ) {
		// We got an array, parse it
		browserSets = JSON.parse( browserSets );
	}
	timeout = timeout || 1000 * 60 * 15;

	[ "index", "async", "setTimeout" ].forEach(function ( suite ) {
		runs[ suite ] = config.testUrl + commit + "/test/" + suite + ".html";
	});

	testswarm
		.createClient({
			url: config.swarmUrl
		})
		.addReporter( testswarm.reporters.cli )
		.auth({
			id: config.authUsername,
			token: config.authToken
		})
		.addjob({
			name: "Commit " +
				commit.substr( 0, 10 ) + "",
			runs: runs,
			browserSets: browserSets,
			timeout: timeout
		}, function( err, passed ) {
			if ( err ) {
				grunt.log.error( err );
			}
			done( passed );
		});
});

// TODO: Extract this task later, if feasible
// Also spawn a separate process to keep tests atomic
grunt.registerTask( "test-on-node", function() {
	var testActive = false,
		runDone = false,
		done = this.async(),
		QUnit = require( "./dist/qunit" );

	// Make the current tests work in the Node.js environment by appending
	// a bunch of properties into the `global` object
	[ "test", "asyncTest", "start", "stop", "expect" ].forEach(function( method ) {
		global[ method ] = QUnit[ method ];
	});
	global.QUnit = QUnit;

	QUnit.testStart(function() {
		testActive = true;
	});
	QUnit.log(function( details ) {
		if ( !testActive || details.result ) {
			return;
		}
		var message = "name: " + details.name + " module: " + details.module +
			" message: " + details.message;
		grunt.log.error( message );
	});
	QUnit.testDone(function() {
		testActive = false;
	});
	QUnit.done(function( details ) {
		if ( runDone ) {
			return;
		}
		var succeeded = ( details.failed === 0 ),
			message = details.total + " assertions in (" + details.runtime + "ms), passed: " +
				details.passed + ", failed: " + details.failed;
		if ( succeeded ) {
			grunt.log.ok( message );
		} else {
			grunt.log.error( message );
		}
		done( succeeded );
		runDone = true;
	});
	QUnit.config.autorun = false;

	require( "./test/logs" );
	require( "./test/test" );
	require( "./test/deepEqual" );
	require( "./test/globals" );

	QUnit.load();
});

grunt.registerTask( "build", [ "concat" ] );
grunt.registerTask( "default", [ "build", "jshint", "qunit", "test-on-node" ] );

};
<|endoftext|>


<commit_before>/*
 * grunt-nose
 * https://github.com/tarjei/grunt-nose
 *
 * Copyright (c) 2013 Tarjei Husøy
 * Licensed under the Apache, 2.0 licenses.
 */

'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({

    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/*.js',
        '<%= nodeunit.tests %>',
      ],
      options: {
        jshintrc: '.jshintrc',
      },
    },

    // Before generating any new files, remove any previously-created files.
    clean: {
      report: ['nosetests.xml'],
      python: ['test/**/*.pyc'],
      install_artifacts: ['tasks/lib/*.egg-info'],
    },

    // Configuration to be run (and then tested).
    nose: {

      default: {
      },

      custom_options: {
        options: {
          with_xunit: true,
          xunit_file: 'nosetests.xml',
        },
        src: 'test/fixtures',
      },

      test_options: {
        options: {
          verbose: true,
          tests: [
            'more_tests',
            'tests',
          ],
          // match: "passing",
          debug: [
            'nose.plugins',
            'nose.importer',
          ],
          include: "passing",
          //pdb_failures: true,
          //eval_attr: "do_run",
        },
        //src: 'test/fixtures',
      },

      full_example: {
        options: {
          exclude: "test_fails",
          verbose: true,
          with_coverage: true,
          cover_package: "fixtures",
          cover_branches: true,
          cover_xml: true,
          cover_html: true,
          cover_html_dir: 'code_coverage',
          virtualenv: 'test/fixtures/test_virtualenv',
          with_doctest: true,
          with_xunit: true,
        },
        src: "test/fixtures",
      }
    },

  });

  // Load grunt plugins found in package.json
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  // Actually load this plugin's task(s).
  grunt.loadTasks('tasks');

  // Task aliases
  grunt.registerTask('default', ['jshint', 'clean', 'nose']);

};
<commit_msg>Remove stale reference to nodeunit.<commit_after>/*
 * grunt-nose
 * https://github.com/tarjei/grunt-nose
 *
 * Copyright (c) 2013 Tarjei Husøy
 * Licensed under the Apache, 2.0 licenses.
 */

'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({

    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/*.js',
      ],
      options: {
        jshintrc: '.jshintrc',
      },
    },

    // Before generating any new files, remove any previously-created files.
    clean: {
      report: ['nosetests.xml'],
      python: ['test/**/*.pyc'],
      install_artifacts: ['tasks/lib/*.egg-info'],
    },

    // Configuration to be run (and then tested).
    nose: {

      default: {
      },

      custom_options: {
        options: {
          with_xunit: true,
          xunit_file: 'nosetests.xml',
        },
        src: 'test/fixtures',
      },

      test_options: {
        options: {
          verbose: true,
          tests: [
            'more_tests',
            'tests',
          ],
          // match: "passing",
          debug: [
            'nose.plugins',
            'nose.importer',
          ],
          include: "passing",
          //pdb_failures: true,
          //eval_attr: "do_run",
        },
        //src: 'test/fixtures',
      },

      full_example: {
        options: {
          exclude: "test_fails",
          verbose: true,
          with_coverage: true,
          cover_package: "fixtures",
          cover_branches: true,
          cover_xml: true,
          cover_html: true,
          cover_html_dir: 'code_coverage',
          virtualenv: 'test/fixtures/test_virtualenv',
          with_doctest: true,
          with_xunit: true,
        },
        src: "test/fixtures",
      }
    },

  });

  // Load grunt plugins found in package.json
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  // Actually load this plugin's task(s).
  grunt.loadTasks('tasks');

  // Task aliases
  grunt.registerTask('default', ['jshint', 'clean', 'nose']);

};
<|endoftext|>


<commit_before>var grunt = require('grunt');
require('load-grunt-tasks')(grunt);

var files = ['test/*.js'];

grunt.initConfig({
  mochacli: {
      options: {
          reporter: 'spec',
          bail: false
      },
      all: files
  },
  jshint: {
      files: files,
      options: {
          jshintrc: '.jshintrc'
      }
  },
  jscs: {
      files: {
          src: files
      },
      options: {
          config: '.jscsrc',
          esnext: true
      }
  },
  jsbeautifier: {
      test: {
          files: {
              src: files
          },
          options: {
              mode: 'VERIFY_ONLY',
              config: '.beautifyrc'
          }
      },
      write: {
          files: {
              src: files
          },
          options: {
              config: '.beautifyrc'
          }
      }
  }
});
grunt.registerTask('test', ['jshint', 'jscs', 'jsbeautifier', 'mochacli']);
<commit_msg>Add lint and reformat target.<commit_after>var grunt = require('grunt');
require('load-grunt-tasks')(grunt);

var files = ['test/*.js'];
var templates = ['**/*.json'];

grunt.initConfig({
  mochacli: {
      options: {
          reporter: 'spec',
          bail: false
      },
      all: files
  },
  jshint: {
      files: files,
      options: {
          jshintrc: '.jshintrc'
      }
  },
  jscs: {
      files: {
          src: files
      },
      options: {
          config: '.jscsrc',
          esnext: true
      }
  },
  jsbeautifier: {
      test: {
          files: {
              src: files
          },
          options: {
              mode: 'VERIFY_ONLY',
              config: '.beautifyrc'
          }
      },
      lint: {
          files: {
              src: templates
          },
          options: {
              mode: 'VERIFY_ONLY',
              config: '.beautifyrc'
          }
      },
      reformat: {
          files: {
              src: templates
          },
          options: {
              mode: 'VERIFY_AND_WRITE',
              config: '.beautifyrc'
          }
      },
      write: {
          files: {
              src: files
          },
          options: {
              config: '.beautifyrc'
          }
      }
  }
});
grunt.registerTask('test', ['jshint', 'jscs', 'jsbeautifier:test', 'jsbeautifier:write', 'mochacli']);
<|endoftext|>


<commit_before>var fs = require('fs');

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

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        concat: {
            singleGlobalUseStrict: {
                options: {
                    // Replace all 'use strict' statements in the code with a single one at the top
                    banner: fs.readFileSync('src/module.prefix', 'utf8'),
                    process: function(src) {
                        return src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
                    },
                    footer: fs.readFileSync('src/module.suffix', 'utf8')
                },
                files: {
                    'dist/<%= pkg.name %>-nonAnnotated.js': ['src/module.js', 'src/config.js', 'src/mockCreator.js',
                            'src/moduleBuilder.js', 'src/$q.js', 'src/exports.js']
                }
            }
        },
        ngAnnotate: {
            options: {
                ngAnnotateOptions: {}
            },
            default: {
                files: {
                    'dist/<%= pkg.name %>.js': ['dist/<%= pkg.name %>-nonAnnotated.js']
                }
            }
        },
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
            },
            dist: {
                files: {
                    'dist/<%= pkg.name %>.min.js': ['dist/<%= pkg.name %>.js']
                }
            }
        },
        karma: {
            options: {
                singleRun: true,
                reporters: ['dots', 'coverage'],
                preprocessors: {
                    'src/**/*.js': ['coverage']
                }
            },
            angular_TMP: {
                configFile: 'karma-angular-TMP.conf.js',
                coverageReporter: {
                    type: 'lcov',
                    dir: 'coverage/angular-TMP'
                }
            },
            //angular_1_2: {
            //    configFile: 'karma-angular-1.2.conf.js',
            //    coverageReporter: {
            //        type: 'lcov',
            //        dir: 'coverage/angular-1.2'
            //    }
            //},
            //angular_1_3: {
            //    configFile: 'karma-angular-1.3.conf.js',
            //    coverageReporter: {
            //        type: 'lcov',
            //        dir: 'coverage/angular-1.3'
            //    }
            //}
        },
        jshint: {
            files: ['*.js', 'src/**/*.js', 'test/**/*.js'],
            options: {
                jshintrc: true
            }
        },
        watch: {
            files: ['<%= jshint.files %>'],
            tasks: ['jshint', 'karma']
        },
        coveralls: {
            'combined-lcov-info': {
                src: 'coverage/combined-lcov.info'
            }
        }
    });

    grunt.registerTask('upload-combined-coverage', ['coveralls:combined-lcov-info']);

    grunt.registerTask('test', ['jshint', 'karma']);

    grunt.registerTask('default', ['jshint', 'karma', 'concat:singleGlobalUseStrict', 'ngAnnotate', 'uglify']);
};<commit_msg>Correcting "Gruntfile.js"<commit_after>var fs = require('fs');

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

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        concat: {
            singleGlobalUseStrict: {
                options: {
                    // Replace all 'use strict' statements in the code with a single one at the top
                    banner: fs.readFileSync('src/module.prefix', 'utf8'),
                    process: function(src) {
                        return src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
                    },
                    footer: fs.readFileSync('src/module.suffix', 'utf8')
                },
                files: {
                    'dist/<%= pkg.name %>-nonAnnotated.js': ['src/module.js', 'src/config.js', 'src/mockCreator.js',
                            'src/moduleBuilder.js', 'src/$q.js', 'src/exports.js']
                }
            }
        },
        ngAnnotate: {
            options: {
                ngAnnotateOptions: {}
            },
            default: {
                files: {
                    'dist/<%= pkg.name %>.js': ['dist/<%= pkg.name %>-nonAnnotated.js']
                }
            }
        },
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
            },
            dist: {
                files: {
                    'dist/<%= pkg.name %>.min.js': ['dist/<%= pkg.name %>.js']
                }
            }
        },
        karma: {
            options: {
                singleRun: true,
                reporters: ['dots', 'coverage'],
                preprocessors: {
                    'src/**/*.js': ['coverage']
                }
            },
            angular_1_2: {
                configFile: 'karma-angular-1.2.conf.js',
                coverageReporter: {
                    type: 'lcov',
                    dir: 'coverage/angular-1.2'
                }
            },
            angular_1_3: {
                configFile: 'karma-angular-1.3.conf.js',
                coverageReporter: {
                    type: 'lcov',
                    dir: 'coverage/angular-1.3'
                }
            }
        },
        jshint: {
            files: ['*.js', 'src/**/*.js', 'test/**/*.js'],
            options: {
                jshintrc: true
            }
        },
        watch: {
            files: ['<%= jshint.files %>'],
            tasks: ['jshint', 'karma']
        },
        coveralls: {
            'combined-lcov-info': {
                src: 'coverage/combined-lcov.info'
            }
        }
    });

    grunt.registerTask('upload-combined-coverage', ['coveralls:combined-lcov-info']);

    grunt.registerTask('test', ['jshint', 'karma']);

    grunt.registerTask('default', ['jshint', 'karma', 'concat:singleGlobalUseStrict', 'ngAnnotate', 'uglify']);
};<|endoftext|>