Gruntfile.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. 'use strict';
  2. module.exports = function (grunt) {
  3. var path = require('path');
  4. // These plugins provide necessary tasks.
  5. grunt.loadNpmTasks('grunt-contrib-clean');
  6. grunt.loadNpmTasks('grunt-contrib-requirejs');
  7. grunt.loadNpmTasks('grunt-execute');
  8. grunt.loadNpmTasks('amber-dev');
  9. // Default task.
  10. grunt.registerTask('default', ['amberc:all', 'amberc:counter', 'amberc:todo']);
  11. grunt.registerTask('test', ['amberc:test_runner', 'execute:test_runner', 'clean:test_runner']);
  12. grunt.registerTask('devel', ['amdconfig:app', 'requirejs:devel']);
  13. grunt.registerTask('deploy', ['amdconfig:app', 'requirejs:deploy']);
  14. // Project configuration.
  15. grunt.initConfig({
  16. // Metadata.
  17. // pkg: grunt.file.readJSON(''),
  18. banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
  19. '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
  20. '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
  21. '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
  22. ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
  23. // task configuration
  24. amberc: {
  25. options: {
  26. amber_dir: path.join(__dirname, "bower_components", "amber"),
  27. library_dirs: ['src'],
  28. closure_jar: ''
  29. },
  30. all: {
  31. src: [
  32. 'src/Trapped-Backend.st', 'src/Trapped-Frontend.st', 'src/Trapped-Processors.st', // list all sources in dependency order
  33. 'src/Trapped-Tests.st' // list all tests in dependency order
  34. ],
  35. amd_namespace: 'trapped',
  36. libraries: ['SUnit', 'Web']
  37. },
  38. counter: {
  39. src: [
  40. 'example-counter/src/Trapped-Counter.st'
  41. ],
  42. amd_namespace: 'trapped-counter',
  43. libraries: ['SUnit', 'Web', 'Trapped-Backend']
  44. },
  45. todo: {
  46. src: [
  47. 'example-todo/src/Trapped-Todo.st'
  48. ],
  49. amd_namespace: 'trapped-todo',
  50. libraries: ['SUnit', 'Web', 'Trapped-Frontend', 'Trapped-Backend']
  51. },
  52. test_runner: {
  53. src: ['node_modules/amber-dev/lib/Test.st'],
  54. libraries: [
  55. /* add dependencies packages here */
  56. 'Trapped', /* add other code-to-test packages here */
  57. 'SUnit',
  58. 'Trapped-Tests' /* add other test packages here */
  59. ],
  60. main_class: 'NodeTestRunner',
  61. output_name: 'test_runner'
  62. }
  63. },
  64. amdconfig: {app: {dest: 'config.js'}},
  65. requirejs: {
  66. deploy: {
  67. options: {
  68. mainConfigFile: "config.js",
  69. onBuildWrite: function (moduleName, path, contents) {
  70. return moduleName === "config" ? contents + "\nrequire.config({map:{'*':{app:'deploy'}}});" : contents;
  71. },
  72. pragmas: {
  73. excludeIdeData: true,
  74. excludeDebugContexts: true
  75. },
  76. include: ['config', 'node_modules/requirejs/require', 'deploy'],
  77. out: "the.js"
  78. }
  79. },
  80. devel: {
  81. options: {
  82. mainConfigFile: "config.js",
  83. onBuildWrite: function (moduleName, path, contents) {
  84. return moduleName === "config" ? contents + "\nrequire.config({map:{'*':{app:'devel'}}});" : contents;
  85. },
  86. include: ['config', 'node_modules/requirejs/require'],
  87. out: "the.js"
  88. }
  89. }
  90. },
  91. execute: {
  92. test_runner: {
  93. src: ['test_runner.js']
  94. }
  95. },
  96. clean: {
  97. test_runner: ['test_runner.js']
  98. }
  99. });
  100. };