Gruntfile.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. 'use strict';
  2. module.exports = function (grunt) {
  3. var path = require('path'),
  4. helpers = require('amber-dev/lib/helpers');
  5. // These plugins provide necessary tasks.
  6. grunt.loadNpmTasks('grunt-contrib-clean');
  7. grunt.loadNpmTasks('grunt-contrib-requirejs');
  8. grunt.loadNpmTasks('grunt-execute');
  9. grunt.loadNpmTasks('amber-dev');
  10. // Default task.
  11. grunt.registerTask('default', ['amberc:all']);
  12. grunt.registerTask('test', ['amdconfig:app', 'requirejs:test_runner', 'execute:test_runner', 'clean:test_runner']);
  13. grunt.registerTask('devel', ['amdconfig:app', 'requirejs:devel']);
  14. grunt.registerTask('deploy', ['amdconfig:app', 'requirejs:deploy']);
  15. // Project configuration.
  16. grunt.initConfig({
  17. // Metadata.
  18. // pkg: grunt.file.readJSON(''),
  19. banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
  20. '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
  21. '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
  22. '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
  23. ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
  24. // task configuration
  25. amberc: {
  26. options: {
  27. amber_dir: path.join(__dirname, "bower_components", "amber"),
  28. library_dirs: ['src']
  29. },
  30. all: {
  31. src: [
  32. 'src/Web.st' // list all sources in dependency order
  33. // list all tests in dependency order
  34. ],
  35. amd_namespace: 'trapped',
  36. libraries: []
  37. }
  38. },
  39. amdconfig: {app: {dest: 'config.js'}},
  40. requirejs: {
  41. deploy: {
  42. options: {
  43. mainConfigFile: "config.js",
  44. rawText: {"app": 'define(["deploy"],function(x){return x});'},
  45. pragmas: {
  46. excludeIdeData: true,
  47. excludeDebugContexts: true
  48. },
  49. include: ['config', 'node_modules/requirejs/require', 'app'],
  50. out: "the.js"
  51. }
  52. },
  53. devel: {
  54. options: {
  55. mainConfigFile: "config.js",
  56. rawText: {"app": 'define(["devel"],function(x){return x});'},
  57. include: ['config', 'node_modules/requirejs/require', 'app'],
  58. exclude: ['devel'],
  59. out: "the.js"
  60. }
  61. },
  62. test_runner: {
  63. options: {
  64. mainConfigFile: "config.js",
  65. rawText: {
  66. "app": "(" + function () {
  67. define(["testing", "amber_devkit/NodeTestRunner"], function (amber) {
  68. amber.initialize();
  69. amber.globals.NodeTestRunner._main();
  70. });
  71. } + "());"
  72. },
  73. paths: {"amber_devkit": helpers.libPath},
  74. pragmas: {
  75. excludeIdeData: true
  76. },
  77. include: ['config-node', 'app'],
  78. insertRequire: ['app'],
  79. optimize: "none",
  80. wrap: helpers.nodeWrapperWithShebang,
  81. out: "test_runner.js"
  82. }
  83. }
  84. },
  85. execute: {
  86. test_runner: {
  87. src: ['test_runner.js']
  88. }
  89. },
  90. clean: {
  91. test_runner: ['test_runner.js']
  92. }
  93. });
  94. };