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.

119 lines
3.0 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
  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. './lib/moment.js'
  53. ],
  54. header: read('./src/header.js') + '\n' +
  55. '(function () { ', // start of closure
  56. separator: '\n',
  57. // Note: we insert the css as a string in the javascript code here
  58. // the css will be injected on load of the javascript library
  59. footer: 'loadCss(' + cssText + ');\n' +
  60. '})();' // end of closure
  61. });
  62. // minify javascript
  63. minify({
  64. src: VIS,
  65. dest: VIS_MIN,
  66. header: read('./src/header.js')
  67. });
  68. // update version number and stuff in the javascript files
  69. [VIS, VIS_MIN].forEach(function (file) {
  70. replace({
  71. replacements: [
  72. {pattern: '@@name', replacement: 'vis.js'},
  73. {pattern: '@@date', replacement: today()},
  74. {pattern: '@@version', replacement: version()}
  75. ],
  76. src: file
  77. });
  78. });
  79. console.log('created vis.js library');
  80. });
  81. /**
  82. * Recursively remove a directory and its files
  83. * https://gist.github.com/tkihira/2367067
  84. * @param {String} dir
  85. */
  86. var rmdir = function(dir) {
  87. var list = fs.readdirSync(dir);
  88. for(var i = 0; i < list.length; i++) {
  89. var filename = path.join(dir, list[i]);
  90. var stat = fs.statSync(filename);
  91. if(filename == "." || filename == "..") {
  92. // pass these files
  93. } else if(stat.isDirectory()) {
  94. // rmdir recursively
  95. rmdir(filename);
  96. } else {
  97. // rm fiilename
  98. fs.unlinkSync(filename);
  99. }
  100. }
  101. fs.rmdirSync(dir);
  102. };