vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
3.1 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. /**
  2. * Jake build script
  3. */
  4. var jake = require('jake'),
  5. fs = require('fs'),
  6. path = require('path');
  7. require('jake-utils');
  8. /**
  9. * default task
  10. */
  11. desc('Execute all tasks: build all libraries');
  12. task('default', ['vis'], function () {
  13. console.log('done');
  14. });
  15. /**
  16. * build the visualization library vis.js
  17. */
  18. desc('Build the visualization library vis.js');
  19. task('vis', function () {
  20. var VIS = './vis.js';
  21. var VIS_MIN = './vis.min.js';
  22. // concatenate and stringify css files
  23. var result = concat({
  24. src: [
  25. './src/component/css/panel.css',
  26. './src/component/css/item.css',
  27. './src/component/css/timeaxis.css'
  28. ],
  29. header: '/* vis.js stylesheet */',
  30. separator: '\n'
  31. });
  32. var cssText = JSON.stringify(result.code);
  33. // concatenate the script files
  34. concat({
  35. dest: VIS,
  36. src: [
  37. './src/module.js',
  38. './src/util.js',
  39. './src/events.js',
  40. './src/timestep.js',
  41. './src/dataset.js',
  42. './src/stack.js',
  43. './src/range.js',
  44. './src/controller.js',
  45. './src/component/component.js',
  46. './src/component/panel.js',
  47. './src/component/rootpanel.js',
  48. './src/component/timeaxis.js',
  49. './src/component/itemset.js',
  50. './src/component/item/*.js',
  51. './src/visualization/timeline.js',
  52. // TODO: do not package moment.js with vis.js.
  53. './lib/moment.js'
  54. ],
  55. header: read('./src/header.js') + '\n' +
  56. '(function () { ', // start of closure
  57. separator: '\n',
  58. // Note: we insert the css as a string in the javascript code here
  59. // the css will be injected on load of the javascript library
  60. footer: 'loadCss(' + cssText + ');\n' +
  61. '})();' // end of closure
  62. });
  63. // minify javascript
  64. minify({
  65. src: VIS,
  66. dest: VIS_MIN,
  67. header: read('./src/header.js')
  68. });
  69. // update version number and stuff in the javascript files
  70. [VIS, VIS_MIN].forEach(function (file) {
  71. replace({
  72. replacements: [
  73. {pattern: '@@name', replacement: 'vis.js'},
  74. {pattern: '@@date', replacement: today()},
  75. {pattern: '@@version', replacement: version()}
  76. ],
  77. src: file
  78. });
  79. });
  80. console.log('created vis.js library');
  81. });
  82. /**
  83. * Recursively remove a directory and its files
  84. * https://gist.github.com/tkihira/2367067
  85. * @param {String} dir
  86. */
  87. var rmdir = function(dir) {
  88. var list = fs.readdirSync(dir);
  89. for(var i = 0; i < list.length; i++) {
  90. var filename = path.join(dir, list[i]);
  91. var stat = fs.statSync(filename);
  92. if(filename == "." || filename == "..") {
  93. // pass these files
  94. } else if(stat.isDirectory()) {
  95. // rmdir recursively
  96. rmdir(filename);
  97. } else {
  98. // rm fiilename
  99. fs.unlinkSync(filename);
  100. }
  101. }
  102. fs.rmdirSync(dir);
  103. };