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.

114 lines
2.8 KiB

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', ['timeline'], function () {
  13. console.log('done');
  14. });
  15. /**
  16. * timeline
  17. */
  18. desc('Build the timeline visualization');
  19. task('timeline', function () {
  20. var TIMELINE = './bin/timeline/timeline.js';
  21. var TIMELINE_MIN = './bin/timeline/timeline.min.js';
  22. var DIR = './bin/timeline';
  23. jake.rmRf(DIR);
  24. jake.mkdirP(DIR);
  25. // concatenate the script files
  26. concat({
  27. dest: TIMELINE,
  28. src: [
  29. './src/header.js',
  30. './src/util.js',
  31. './src/events.js',
  32. './src/timestep.js',
  33. './src/dataset.js',
  34. './src/stack.js',
  35. './src/range.js',
  36. './src/controller.js',
  37. './src/component/component.js',
  38. './src/component/panel.js',
  39. './src/component/rootpanel.js',
  40. './src/component/timeaxis.js',
  41. './src/component/itemset.js',
  42. './src/component/item/*.js',
  43. './src/visualization/timeline/timeline.js',
  44. './lib/moment.js'
  45. ],
  46. separator: '\n'
  47. });
  48. // concatenate the css files
  49. concat({
  50. dest: './bin/timeline/timeline.css',
  51. src: [
  52. './src/component/css/panel.css',
  53. './src/component/css/item.css',
  54. './src/component/css/timeaxis.css'
  55. ],
  56. separator: '\n'
  57. });
  58. // minify javascript
  59. minify({
  60. src: TIMELINE,
  61. dest: TIMELINE_MIN,
  62. header: read('./src/header.js')
  63. });
  64. // update version number and stuff in the javascript files
  65. [TIMELINE, TIMELINE_MIN].forEach(function (file) {
  66. replace({
  67. replacements: [
  68. {pattern: '@@name', replacement: 'timeline'},
  69. {pattern: '@@date', replacement: today()},
  70. {pattern: '@@version', replacement: version()}
  71. ],
  72. src: file
  73. });
  74. });
  75. // copy examples
  76. jake.cpR('./src/visualization/timeline/examples', './bin/timeline/examples/');
  77. console.log('created timeline library');
  78. });
  79. /**
  80. * Recursively remove a directory and its files
  81. * https://gist.github.com/tkihira/2367067
  82. * @param {String} dir
  83. */
  84. var rmdir = function(dir) {
  85. var list = fs.readdirSync(dir);
  86. for(var i = 0; i < list.length; i++) {
  87. var filename = path.join(dir, list[i]);
  88. var stat = fs.statSync(filename);
  89. if(filename == "." || filename == "..") {
  90. // pass these files
  91. } else if(stat.isDirectory()) {
  92. // rmdir recursively
  93. rmdir(filename);
  94. } else {
  95. // rm fiilename
  96. fs.unlinkSync(filename);
  97. }
  98. }
  99. fs.rmdirSync(dir);
  100. };