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('{%= 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/Platform": '/*stub*/',
  49. "app": 'define(["deploy"],function(x){return x});define("amber/Platform",["amber_core/Platform-Browser"],{});'
  50. },
  51. pragmas: {
  52. excludeIdeData: true,
  53. excludeDebugContexts: true
  54. },
  55. include: ['config', 'node_modules/requirejs/require', 'app'],
  56. optimize: "uglify2",
  57. out: "the.js"
  58. }
  59. },
  60. devel: {
  61. options: {
  62. mainConfigFile: "config.js",
  63. rawText: {
  64. "amber/Platform": '/*stub*/',
  65. "app": 'define(["devel"],function(x){return x});define("amber/Platform",["amber_core/Platform-Browser"],{});'
  66. },
  67. include: ['config', 'node_modules/requirejs/require', 'app'],
  68. exclude: ['devel'],
  69. out: "the.js"
  70. }
  71. },
  72. test_runner: {
  73. options: {
  74. mainConfigFile: "config.js",
  75. rawText: {
  76. "app": "(" + function () {
  77. define(["testing", "amber_devkit/NodeTestRunner"], function (amber) {
  78. amber.initialize().then(function () {
  79. amber.globals.NodeTestRunner._main();
  80. });
  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. };