Gruntfile.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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-execute');
  16. grunt.loadNpmTasks('grunt-contrib-clean');
  17. grunt.loadNpmTasks('grunt-contrib-less');
  18. grunt.loadNpmTasks('grunt-contrib-requirejs');
  19. grunt.loadNpmTasks('grunt-contrib-watch');
  20. grunt.loadNpmTasks('amber-dev');
  21. // Default task.
  22. grunt.registerTask('default', ['amdconfig:helios', 'less', 'amberc:all']);
  23. grunt.registerTask('test', ['amdconfig:helios', 'requirejs:test_runner', 'execute:test_runner', 'clean:test_runner']);
  24. grunt.registerTask('devel', ['amdconfig:helios']);
  25. // Project configuration.
  26. grunt.initConfig({
  27. // Metadata.
  28. // pkg: grunt.file.readJSON(''),
  29. banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
  30. '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
  31. '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
  32. '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
  33. ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
  34. // task configuration
  35. less: {
  36. development: {
  37. files: {
  38. 'resources/helios.css': 'resources/helios.less'
  39. }
  40. }
  41. },
  42. amberc: {
  43. options: {
  44. amber_dir: findAmberPath(['../..', 'bower_components/amber']),
  45. configFile: "config.js"
  46. },
  47. all: {
  48. output_dir: 'src',
  49. src: [
  50. // list all sources in dependency order
  51. 'src/Helios-Core.st', 'src/Helios-Exceptions.st', 'src/Helios-Announcements.st',
  52. 'src/Helios-KeyBindings.st', 'src/Helios-Layout.st', 'src/Helios-Helpers.st',
  53. 'src/Helios-Commands-Core.st',
  54. 'src/Helios-Commands-Tools.st', 'src/Helios-Commands-Browser.st', 'src/Helios-Commands-SUnit.st',
  55. 'src/Helios-References.st', 'src/Helios-Inspector.st', 'src/Helios-Browser.st',
  56. 'src/Helios-Transcript.st', 'src/Helios-Workspace.st', 'src/Helios-Debugger.st',
  57. 'src/Helios-SUnit.st',
  58. // list all tests in dependency order
  59. 'src/Helios-Browser-Tests.st', 'src/Helios-Workspace-Tests.st', 'src/Helios-SUnit-Tests.st'
  60. ],
  61. libraries: ['amber_core/SUnit', 'amber/web/Web'],
  62. amd_namespace: 'helios',
  63. jsGlobals: ['navigator']
  64. }
  65. },
  66. requirejs: {
  67. options: {
  68. useStrict: true
  69. },
  70. test_runner: {
  71. options: {
  72. mainConfigFile: "config.js",
  73. rawText: {
  74. "app": "(" + function () {
  75. define(["amber/deploy", "helios/all", "amber_devkit/NodeTestRunner"], function (amber) {
  76. amber.initialize();
  77. amber.globals.NodeTestRunner._main();
  78. });
  79. } + "());"
  80. },
  81. paths: {"amber_devkit": helpers.libPath},
  82. pragmas: {
  83. excludeIdeData: true
  84. },
  85. include: ['config-node', 'app'],
  86. insertRequire: ['app'],
  87. optimize: "none",
  88. wrap: helpers.nodeWrapperWithShebang,
  89. out: "test_runner.js"
  90. }
  91. }
  92. },
  93. amdconfig: {helios: {dest: 'config.js'}},
  94. execute: {
  95. test_runner: {
  96. src: ['test_runner.js']
  97. }
  98. },
  99. clean: {
  100. test_runner: ['test_runner.js']
  101. },
  102. watch: {
  103. less: {
  104. files: ['resources/*.less'],
  105. tasks: ['less'],
  106. options: {
  107. spawn: false
  108. }
  109. }
  110. }
  111. });
  112. };