module.exports = ->
  # Project configuration
  @initConfig
    pkg: @file.readJSON 'package.json'

    # Environment for local testing
    env:
      dev:
        EMBEDLY_API_TOKEN: 'a715cf41cc93453ca338d350cd26f87b'
        GITHUB_API_TOKEN: 'ed71b06abb5c5ed782628cd9bcbec9f297c2de0e'

    # Updating the package manifest files
    noflo_manifest:
      update:
        files:
          'package.json': ['graphs/*', 'components/*']

    # BDD tests on Node.js
    mochaTest:
      nodejs:
        src: ['spec/*.coffee']
        options:
          reporter: 'spec'
          require: 'coffee-script/register'
          grep: process.env.TESTS

    # Coding standards
    coffeelint:
      components: ['Gruntfile.coffee', 'spec/*.coffee', 'components/*.coffee']
      options:
        'max_line_length':
          'level': 'ignore'
    noflo_lint:
      graphs:
        options:
          description: 'ignore'
          icon: 'ignore'
          port_descriptions: 'ignore'
          asynccomponent: 'error'
          wirepattern: 'warn'
          process_api: 'ignore'
          legacy_api: 'ignore'
        files:
          src: [
            'graphs/Publish.json'
            'graphs/FetchAndFlatten.json'
          ]

  # Grunt plugins used for building
  @loadNpmTasks 'grunt-noflo-manifest'

  # Grunt plugins used for testing
  @loadNpmTasks 'grunt-env'
  @loadNpmTasks 'grunt-mocha-test'
  @loadNpmTasks 'grunt-coffeelint'
  @loadNpmTasks 'grunt-noflo-lint'

  # Our local tasks
  @registerTask 'build', 'Build NoFlo for the chosen target platform', (target = 'all') =>
    @task.run 'noflo_manifest'

  @registerTask 'test', 'Build NoFlo and run automated tests', (target = 'all') =>
    @task.run 'coffeelint'
    @task.run 'noflo_lint'
    @task.run 'noflo_manifest'
    @task.run 'mochaTest'

  @registerTask 'default', ['test']
  @registerTask 'dev', ['env:dev', 'test']
