Gruntfile.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. 'use strict';
  2. module.exports = function (grunt) {
  3. // These plugins provide necessary tasks.
  4. grunt.loadNpmTasks('grunt-contrib-clean');
  5. grunt.loadNpmTasks('grunt-contrib-requirejs');
  6. grunt.loadNpmTasks('grunt-execute');
  7. grunt.loadNpmTasks('amber-dev');
  8. var path = require('path'),
  9. helpers = require('amber-dev').helpers;
  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('{%= amberjson %}'),
  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/{%= name %}.st', // list all sources in dependency order
  33. 'src/{%= name %}-Tests.st' // list all tests in dependency order
  34. ],
  35. amd_namespace: '{%= namespace %}',
  36. libraries: ['amber_core/SUnit', 'amber/web/Web', 'silk/Silk']
  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});'
  51. },
  52. pragmas: {
  53. excludeIdeData: true,
  54. excludeDebugContexts: true
  55. },
  56. include: ['config', 'config-browser', 'node_modules/requirejs/require', 'app', 'amber/lazypack'],
  57. optimize: "uglify2",
  58. out: "the.js"
  59. }
  60. },
  61. devel: {
  62. options: {
  63. mainConfigFile: "config.js",
  64. rawText: {
  65. "amber/compatibility": "/*stub*/",
  66. "amber/Platform": "/*stub*/",
  67. "app": 'define(["devel"],function(x){return x});'
  68. },
  69. include: ['config', 'config-browser', 'node_modules/requirejs/require', 'app'],
  70. exclude: ['devel'],
  71. out: "the.js"
  72. }
  73. },
  74. test_runner: {
  75. options: {
  76. mainConfigFile: "config.js",
  77. rawText: {
  78. "app": "(" + function () {
  79. define(["testing", "amber_devkit/NodeTestRunner"], function (amber) {
  80. amber.initialize().then(function () {
  81. amber.globals.NodeTestRunner._main();
  82. });
  83. });
  84. } + "());"
  85. },
  86. paths: {"amber_devkit": helpers.libPath},
  87. pragmas: {
  88. excludeIdeData: true
  89. },
  90. include: ['config-node', 'app', 'amber/lazypack'],
  91. insertRequire: ['app'],
  92. optimize: "none",
  93. wrap: helpers.nodeWrapperWithShebang,
  94. out: "test_runner.js"
  95. }
  96. }
  97. },
  98. execute: {
  99. test_runner: {
  100. src: ['test_runner.js']
  101. }
  102. },
  103. clean: {
  104. test_runner: ['test_runner.js']
  105. }
  106. });
  107. };