1
0

Gruntfile.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. 'use strict';
  2. var fs = require('fs'),
  3. path = require('path');
  4. function findAmberPath(options) {
  5. var result;
  6. options.some(function (x) {
  7. var candidate = path.join(__dirname, x);
  8. return fs.existsSync(path.join(candidate, 'support/boot.js')) && (result = candidate);
  9. });
  10. return result;
  11. }
  12. module.exports = function (grunt) {
  13. var helpers = require('amber-dev').helpers;
  14. // These plugins provide necessary tasks.
  15. grunt.loadNpmTasks('grunt-contrib-clean');
  16. grunt.loadNpmTasks('grunt-contrib-requirejs');
  17. grunt.loadNpmTasks('grunt-execute');
  18. grunt.loadNpmTasks('amber-dev');
  19. // Default task.
  20. grunt.registerTask('default', ['amdconfig:app', 'amberc:all']);
  21. grunt.registerTask('test', ['amdconfig:app', 'requirejs:test_runner', 'execute:test_runner', 'clean:test_runner']);
  22. grunt.registerTask('devel', ['amdconfig:app', 'requirejs:devel']);
  23. grunt.registerTask('deploy', ['amdconfig:app', 'requirejs:deploy']);
  24. // Project configuration.
  25. grunt.initConfig({
  26. // Metadata.
  27. // pkg: grunt.file.readJSON(''),
  28. banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
  29. '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
  30. '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
  31. '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
  32. ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
  33. // task configuration
  34. amberc: {
  35. options: {
  36. amber_dir: findAmberPath(['../..', 'bower_components/amber']),
  37. configFile: "config.js"
  38. },
  39. all: {
  40. src: [
  41. 'src/Benchfib.st', 'src/Examples.st', 'src/IDE.st' // list all sources in dependency order
  42. // list all tests in dependency order
  43. ],
  44. amd_namespace: 'amber/legacy',
  45. libraries: ['amber/web/Web']
  46. }
  47. },
  48. amdconfig: {app: {dest: 'config.js'}},
  49. requirejs: {
  50. options: {
  51. useStrict: true
  52. },
  53. deploy: {
  54. options: {
  55. mainConfigFile: "config.js",
  56. rawText: {
  57. "amber/Platform": '/*stub*/',
  58. "app": 'define(["deploy"],function(x){return x});define("amber/Platform",["amber_core/Platform-Browser"],{});'
  59. },
  60. pragmas: {
  61. excludeIdeData: true,
  62. excludeDebugContexts: true
  63. },
  64. include: ['config', 'node_modules/requirejs/require', 'app'],
  65. out: "the.js"
  66. }
  67. },
  68. devel: {
  69. options: {
  70. mainConfigFile: "config.js",
  71. rawText: {
  72. "amber/Platform": '/*stub*/',
  73. "app": 'define(["devel"],function(x){return x});define("amber/Platform",["amber_core/Platform-Browser"],{});'
  74. },
  75. include: ['config', 'node_modules/requirejs/require', 'app'],
  76. exclude: ['devel'],
  77. out: "the.js"
  78. }
  79. },
  80. test_runner: {
  81. options: {
  82. mainConfigFile: "config.js",
  83. rawText: {
  84. "app": "(" + function () {
  85. define(["testing", "amber_devkit/NodeTestRunner"], function (amber) {
  86. amber.initialize();
  87. amber.globals.NodeTestRunner._main();
  88. });
  89. } + "());"
  90. },
  91. paths: {"amber_devkit": helpers.libPath},
  92. pragmas: {
  93. excludeIdeData: true
  94. },
  95. include: ['config-node', 'app'],
  96. insertRequire: ['app'],
  97. optimize: "none",
  98. wrap: helpers.nodeWrapperWithShebang,
  99. out: "test_runner.js"
  100. }
  101. }
  102. },
  103. execute: {
  104. test_runner: {
  105. src: ['test_runner.js']
  106. }
  107. },
  108. clean: {
  109. test_runner: ['test_runner.js']
  110. }
  111. });
  112. };