-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
84 lines (70 loc) · 2.02 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
var path = require('path');
var plugins = expand({
'larskotthoff': [ 'chernoff' ],
'skokenes': [ 'lasso' ],
'tmcw': [ 'jsonp', 'keybinding' ],
'zjonsson': [ 'force-labels' ],
'prcweb': [ 'circular-heat-chart' ],
'deprecated': [ 'interpolate-zoom' ],
'jasondavies': [ 'cloud', 'longscroll', 'parsets' ],
'emeeks': [ 'adjacency-matrix', 'graph', 'orbit', 'timeline', 'legend', 'circular-brush', 'ribbon', 'sketchy' ],
'klortho': [ 'flex-tree' ],
'susielu': [ 'legend' ],
'square': [ 'crossfilter' ],
'riccardoscalco': [ 'textures' ],
'adnan-wahab': [ 'pathgl' ],
'mbostock': [
'box',
'bullet',
'fisheye',
'hive',
'hexbin',
'horizon',
'sankey',
'rollup',
'qq',
'geodesic',
'contour',
'urlencode',
'superformula',
'cubehelix',
'tile',
'topojson'
],
});
function Plugin(author, plugin) {
this.name = plugin;
this.author = author;
}
Plugin.prototype.pathFor = function (format) {
return path.join(this.author, this.name, format, fileNameFor(format));
};
Plugin.prototype.absolutePathFor = function (format) {
return path.join(__dirname, 'dist', this.author, this.name, format, fileNameFor(format));
};
function fileNameFor(format) {
switch (format) {
case 'amd': case 'cjs': case 'es6': return 'index.js';
case 'globals': case 'named-amd': return 'main.js';
default: throw new TypeError('Expected amd, cjs, es6, globals, or named-amd as format');
}
}
function expand(index) {
var trees = [];
var lookup = {};
for (var author in index) {
var plugins = index[author];
lookup[author] = lookup[author] || {};
plugins.forEach(function (plugin) {
trees.push(lookup[author][plugin] = new Plugin(author, plugin));
});
}
trees.lookup = function (author, plugin) {
return lookup[author][plugin];
};
trees.toTree = function () {
return path.join(__dirname, 'dist');
};
return trees;
};
module.exports = plugins;