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.

208 lines
5.6 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 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. wrench = require('wrench'),
  7. CleanCSS = require('clean-css'),
  8. fs = require('fs');
  9. require('jake-utils');
  10. // constants
  11. var DIST = './dist';
  12. var VIS = DIST + '/vis.js';
  13. var VIS_CSS = DIST + '/vis.css';
  14. var VIS_TMP = DIST + '/vis.js.tmp';
  15. var VIS_MIN = DIST + '/vis.min.js';
  16. var VIS_MIN_CSS = DIST + '/vis.min.css';
  17. /**
  18. * default task
  19. */
  20. desc('Default task: build all libraries');
  21. task('default', ['build', 'minify'], function () {
  22. console.log('done');
  23. });
  24. /**
  25. * build the visualization library vis.js
  26. */
  27. desc('Build the visualization library vis.js');
  28. task('build', {async: true}, function () {
  29. jake.mkdirP(DIST);
  30. jake.mkdirP(DIST + '/img');
  31. // concatenate and stringify the css files
  32. concat({
  33. src: [
  34. './src/timeline/component/css/timeline.css',
  35. './src/timeline/component/css/panel.css',
  36. './src/timeline/component/css/labelset.css',
  37. './src/timeline/component/css/itemset.css',
  38. './src/timeline/component/css/item.css',
  39. './src/timeline/component/css/timeaxis.css',
  40. './src/timeline/component/css/currenttime.css',
  41. './src/timeline/component/css/customtime.css',
  42. './src/timeline/component/css/animation.css',
  43. './src/timeline/component/css/dataaxis.css',
  44. './src/timeline/component/css/pathStyles.css',
  45. './src/network/css/network-manipulation.css',
  46. './src/network/css/network-navigation.css'
  47. ],
  48. dest: VIS_CSS,
  49. separator: '\n'
  50. });
  51. console.log('created ' + VIS_CSS);
  52. // concatenate the script files
  53. concat({
  54. dest: VIS_TMP,
  55. src: [
  56. './src/module/imports.js',
  57. './src/shim.js',
  58. './src/util.js',
  59. './src/DOMutil.js',
  60. './src/DataSet.js',
  61. './src/DataView.js',
  62. './src/timeline/component/GraphGroup.js',
  63. './src/timeline/component/Legend.js',
  64. './src/timeline/component/DataAxis.js',
  65. './src/timeline/component/LineGraph.js',
  66. './src/timeline/DataStep.js',
  67. './src/timeline/Stack.js',
  68. './src/timeline/TimeStep.js',
  69. './src/timeline/Range.js',
  70. './src/timeline/component/Component.js',
  71. './src/timeline/component/TimeAxis.js',
  72. './src/timeline/component/CurrentTime.js',
  73. './src/timeline/component/CustomTime.js',
  74. './src/timeline/component/ItemSet.js',
  75. './src/timeline/component/item/*.js',
  76. './src/timeline/component/Group.js',
  77. './src/timeline/Timeline.js',
  78. './src/timeline/Graph2d.js',
  79. './src/network/dotparser.js',
  80. './src/network/shapes.js',
  81. './src/network/Node.js',
  82. './src/network/Edge.js',
  83. './src/network/Popup.js',
  84. './src/network/Groups.js',
  85. './src/network/Images.js',
  86. './src/network/networkMixins/physics/PhysicsMixin.js',
  87. './src/network/networkMixins/physics/HierarchialRepulsion.js',
  88. './src/network/networkMixins/physics/BarnesHut.js',
  89. './src/network/networkMixins/physics/Repulsion.js',
  90. './src/network/networkMixins/HierarchicalLayoutMixin.js',
  91. './src/network/networkMixins/ManipulationMixin.js',
  92. './src/network/networkMixins/SectorsMixin.js',
  93. './src/network/networkMixins/ClusterMixin.js',
  94. './src/network/networkMixins/SelectionMixin.js',
  95. './src/network/networkMixins/NavigationMixin.js',
  96. './src/network/networkMixins/MixinLoader.js',
  97. './src/network/Network.js',
  98. './src/graph3d/Graph3d.js',
  99. './src/module/exports.js'
  100. ],
  101. separator: '\n'
  102. });
  103. // copy images
  104. wrench.copyDirSyncRecursive('./src/network/img', DIST + '/img/network', {
  105. forceDelete: true
  106. });
  107. wrench.copyDirSyncRecursive('./src/timeline/img', DIST + '/img/timeline', {
  108. forceDelete: true
  109. });
  110. var timeStart = Date.now();
  111. // bundle the concatenated script and dependencies into one file
  112. var b = browserify();
  113. b.add(VIS_TMP);
  114. b.bundle({
  115. standalone: 'vis'
  116. }, function (err, code) {
  117. if(err) {
  118. throw err;
  119. }
  120. console.log("browserify",Date.now() - timeStart); timeStart = Date.now();
  121. // add header and footer
  122. var lib = read('./src/module/header.js') + code;
  123. // write bundled file
  124. write(VIS, lib);
  125. console.log('created js' + VIS);
  126. // remove temporary file
  127. fs.unlinkSync(VIS_TMP);
  128. // update version number and stuff in the javascript files
  129. replacePlaceholders(VIS);
  130. complete();
  131. });
  132. });
  133. /**
  134. * minify the visualization library vis.js
  135. */
  136. desc('Minify the visualization library vis.js');
  137. task('minify', {async: true}, function () {
  138. // minify javascript
  139. minify({
  140. src: VIS,
  141. dest: VIS_MIN,
  142. header: read('./src/module/header.js')
  143. });
  144. // update version number and stuff in the javascript files
  145. replacePlaceholders(VIS_MIN);
  146. console.log('created minified ' + VIS_MIN);
  147. var minified = new CleanCSS().minify(read(VIS_CSS));
  148. write(VIS_MIN_CSS, minified);
  149. console.log('created minified ' + VIS_MIN_CSS);
  150. });
  151. /**
  152. * test task
  153. */
  154. desc('Test the library');
  155. task('test', function () {
  156. // TODO: use a testing suite for testing: nodeunit, mocha, tap, ...
  157. var filelist = new jake.FileList();
  158. filelist.include([
  159. './test/**/*.js'
  160. ]);
  161. var files = filelist.toArray();
  162. files.forEach(function (file) {
  163. require('./' + file);
  164. });
  165. console.log('Executed ' + files.length + ' test files successfully');
  166. });
  167. /**
  168. * replace version, date, and name placeholders in the provided file
  169. * @param {String} filename
  170. */
  171. var replacePlaceholders = function (filename) {
  172. replace({
  173. replacements: [
  174. {pattern: '@@date', replacement: today()},
  175. {pattern: '@@version', replacement: version()}
  176. ],
  177. src: filename
  178. });
  179. };