Gruntfile.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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/Web.st', 'src/Web-Snippets.js' // list all sources in dependency order
  33. // list all tests in dependency order
  34. ],
  35. amd_namespace: 'amber/web',
  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/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. out: "the.js"
  57. }
  58. },
  59. devel: {
  60. options: {
  61. mainConfigFile: "config.js",
  62. rawText: {
  63. "amber/Platform": '/*stub*/',
  64. "app": 'define(["devel"],function(x){return x});define("amber/Platform",["amber_core/Platform-Browser"],{});'
  65. },
  66. include: ['config', 'node_modules/requirejs/require', 'app'],
  67. exclude: ['devel'],
  68. out: "the.js"
  69. }
  70. },
  71. test_runner: {
  72. options: {
  73. mainConfigFile: "config.js",
  74. rawText: {
  75. "app": "(" + function () {
  76. define(["testing", "amber_devkit/NodeTestRunner"], function (amber) {
  77. amber.initialize();
  78. amber.globals.NodeTestRunner._main();
  79. });
  80. } + "());"
  81. },
  82. paths: {"amber_devkit": helpers.libPath},
  83. pragmas: {
  84. excludeIdeData: true
  85. },
  86. include: ['config-node', 'app'],
  87. insertRequire: ['app'],
  88. optimize: "none",
  89. wrap: helpers.nodeWrapperWithShebang,
  90. out: "test_runner.js"
  91. }
  92. }
  93. },
  94. execute: {
  95. test_runner: {
  96. src: ['test_runner.js']
  97. }
  98. },
  99. clean: {
  100. test_runner: ['test_runner.js']
  101. }
  102. });
  103. };