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.

167 lines
4.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
  1. /**
  2. * Jake build script
  3. */
  4. var jake = require('jake'),
  5. browserify = require('browserify'),
  6. path = require('path'),
  7. fs = require('fs');
  8. require('jake-utils');
  9. // constants
  10. var VIS = './dist/vis.js';
  11. var VIS_CSS = './dist/vis.css';
  12. var VIS_TMP = './vis.js.tmp';
  13. var VIS_MIN = './dist/vis.min.js';
  14. /**
  15. * default task
  16. */
  17. desc('Execute all tasks: build all libraries');
  18. task('default', ['build', 'minify', 'test'], function () {
  19. console.log('done');
  20. });
  21. /**
  22. * build the visualization library vis.js
  23. */
  24. desc('Build the visualization library vis.js');
  25. task('build', {async: true}, function () {
  26. // concatenate and stringify the css files
  27. concat({
  28. src: [
  29. './src/timeline/component/css/timeline.css',
  30. './src/timeline/component/css/panel.css',
  31. './src/timeline/component/css/groupset.css',
  32. './src/timeline/component/css/itemset.css',
  33. './src/timeline/component/css/item.css',
  34. './src/timeline/component/css/timeaxis.css',
  35. './src/timeline/component/css/currenttime.css',
  36. './src/timeline/component/css/customtime.css'
  37. ],
  38. dest: VIS_CSS,
  39. separator: '\n'
  40. });
  41. console.log('created ' + VIS_CSS);
  42. // concatenate the script files
  43. concat({
  44. dest: VIS_TMP,
  45. src: [
  46. './src/module/imports.js',
  47. './src/shim.js',
  48. './src/util.js',
  49. './src/events.js',
  50. './src/EventBus.js',
  51. './src/DataSet.js',
  52. './src/DataView.js',
  53. './src/timeline/TimeStep.js',
  54. './src/timeline/Stack.js',
  55. './src/timeline/Range.js',
  56. './src/timeline/Controller.js',
  57. './src/timeline/component/Component.js',
  58. './src/timeline/component/Panel.js',
  59. './src/timeline/component/RootPanel.js',
  60. './src/timeline/component/TimeAxis.js',
  61. './src/timeline/component/CurrentTime.js',
  62. './src/timeline/component/CustomTime.js',
  63. './src/timeline/component/ItemSet.js',
  64. './src/timeline/component/item/*.js',
  65. './src/timeline/component/Group.js',
  66. './src/timeline/component/GroupSet.js',
  67. './src/timeline/Timeline.js',
  68. './src/graph/dotparser.js',
  69. './src/graph/shapes.js',
  70. './src/graph/Node.js',
  71. './src/graph/Edge.js',
  72. './src/graph/Popup.js',
  73. './src/graph/Groups.js',
  74. './src/graph/Images.js',
  75. './src/graph/Graph.js',
  76. './src/module/exports.js'
  77. ],
  78. separator: '\n'
  79. });
  80. // bundle the concatenated script and dependencies into one file
  81. var b = browserify();
  82. b.add(VIS_TMP);
  83. b.bundle({
  84. standalone: 'vis'
  85. }, function (err, code) {
  86. if(err) {
  87. throw err;
  88. }
  89. // add header and footer
  90. var lib = read('./src/module/header.js') + code;
  91. // write bundled file
  92. write(VIS, lib);
  93. console.log('created ' + VIS);
  94. // remove temporary file
  95. fs.unlinkSync(VIS_TMP);
  96. // update version number and stuff in the javascript files
  97. replacePlaceholders(VIS);
  98. complete();
  99. });
  100. });
  101. /**
  102. * minify the visualization library vis.js
  103. */
  104. desc('Minify the visualization library vis.js');
  105. task('minify', function () {
  106. // minify javascript
  107. minify({
  108. src: VIS,
  109. dest: VIS_MIN,
  110. header: read('./src/module/header.js')
  111. });
  112. // update version number and stuff in the javascript files
  113. replacePlaceholders(VIS_MIN);
  114. console.log('created ' + VIS_MIN);
  115. });
  116. /**
  117. * test task
  118. */
  119. desc('Test the library');
  120. task('test', ['build'], function () {
  121. // TODO: use a testing suite for testing: nodeunit, mocha, tap, ...
  122. var filelist = new jake.FileList();
  123. filelist.include([
  124. './test/**/*.js'
  125. ]);
  126. var files = filelist.toArray();
  127. files.forEach(function (file) {
  128. require('./' + file);
  129. });
  130. console.log('Executed ' + files.length + ' test files successfully');
  131. });
  132. /**
  133. * replace version, date, and name placeholders in the provided file
  134. * @param {String} filename
  135. */
  136. var replacePlaceholders = function (filename) {
  137. replace({
  138. replacements: [
  139. {pattern: '@@date', replacement: today()},
  140. {pattern: '@@version', replacement: version()}
  141. ],
  142. src: filename
  143. });
  144. };