Gruntfile.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. 'use strict';
  2. module.exports = function (grunt) {
  3. var path = require('path'),
  4. helpers = require('amber-dev').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', ['amdconfig:app', '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. configFile: "config.js"
  29. },
  30. all: {
  31. src: [
  32. 'src/DOMite.st', // list all sources in dependency order
  33. 'src/DOMite-Tests.st' // list all tests in dependency order
  34. ],
  35. amd_namespace: 'domite',
  36. libraries: ['amber_core/SUnit']
  37. }
  38. },
  39. amdconfig: {app: {dest: 'config.js'}},
  40. requirejs: {
  41. options: {
  42. useStrict: true
  43. },
  44. deploy: {
  45. options: {
  46. mainConfigFile: "config.js",
  47. rawText: {
  48. "amber/compatibility": '/*stub*/',
  49. "amber/Platform": '/*stub*/',
  50. "app": 'define(["deploy"],function(x){return x});define("amber/Platform",["amber_core/Platform-Browser"],{});'
  51. },
  52. pragmas: {
  53. excludeIdeData: true,
  54. excludeDebugContexts: true
  55. },
  56. include: ['config', 'config-browser', 'node_modules/requirejs/require', 'app'],
  57. out: "the.js"
  58. }
  59. },
  60. devel: {
  61. options: {
  62. mainConfigFile: "config.js",
  63. rawText: {
  64. "amber/compatibility": '/*stub*/',
  65. "amber/Platform": '/*stub*/',
  66. "app": 'define(["devel"],function(x){return x});define("amber/Platform",["amber_core/Platform-Browser"],{});'
  67. },
  68. include: ['config', 'config-browser', 'node_modules/requirejs/require', 'app'],
  69. exclude: ['devel'],
  70. out: "the.js"
  71. }
  72. },
  73. test_runner: {
  74. options: {
  75. mainConfigFile: "config.js",
  76. rawText: {
  77. "app": "(" + function () {
  78. define(["testing", "amber_devkit/NodeTestRunner"], function (amber) {
  79. amber.initialize();
  80. amber.globals.NodeTestRunner._main();
  81. });
  82. } + "());"
  83. },
  84. paths: {"amber_devkit": helpers.libPath},
  85. pragmas: {
  86. excludeIdeData: true
  87. },
  88. include: ['config-node', 'app'],
  89. insertRequire: ['app'],
  90. optimize: "none",
  91. wrap: helpers.nodeWrapperWithShebang,
  92. out: "test_runner.js"
  93. }
  94. }
  95. },
  96. execute: {
  97. test_runner: {
  98. src: ['test_runner.js']
  99. }
  100. },
  101. clean: {
  102. test_runner: ['test_runner.js']
  103. }
  104. });
  105. };