Skip to content

Commit 50aa1ca

Browse files
committed
include schema in dist
1 parent 42662ba commit 50aa1ca

File tree

6 files changed

+35
-3
lines changed

6 files changed

+35
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
"gzip-size": "^3.0.0",
120120
"image-size": "^0.5.1",
121121
"jasmine-core": "^2.4.1",
122+
"jsdom": "^9.5.0",
122123
"karma": "^1.5.0",
123124
"karma-browserify": "^5.1.1",
124125
"karma-chrome-launcher": "^2.0.0",

src/plot_api/plot_schema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ exports.get = function() {
6464
return {
6565
defs: {
6666
valObjects: Lib.valObjectMeta,
67-
metaKeys: UNDERSCORE_ATTRS.concat(['description', 'role']),
67+
metaKeys: UNDERSCORE_ATTRS.concat(['description', 'role', 'editType', 'impliedEdits']),
6868
editType: {
6969
traces: editTypes.traces,
7070
layout: editTypes.layout

tasks/bundle.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var constants = require('./util/constants');
22
var common = require('./util/common');
33
var _bundle = require('./util/browserify_wrapper');
4-
4+
var makeSchema = require('./util/make_schema');
55
/*
66
* This script takes one argument
77
*
@@ -41,7 +41,8 @@ _bundle(constants.pathToPlotlyGeoAssetsSrc, constants.pathToPlotlyGeoAssetsDist,
4141
// Browserify the plotly.js with meta
4242
_bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyDistWithMeta, {
4343
standalone: 'Plotly',
44-
debug: DEV
44+
debug: DEV,
45+
then: makeSchema(constants.pathToPlotlyDistWithMeta, constants.pathToSchema)
4546
});
4647

4748
// Browserify the plotly.js partial bundles

tasks/util/browserify_wrapper.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ module.exports = function _bundle(pathToIndex, pathToBundle, opts) {
5050

5151
bundleWriteStream.on('finish', function() {
5252
logger(pathToBundle);
53+
if(opts.then) {
54+
opts.then();
55+
}
5356
});
5457

5558
b.bundle(function(err, buf) {

tasks/util/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ module.exports = {
4141
pathToPlotlyDistMin: path.join(pathToDist, 'plotly.min.js'),
4242
pathToPlotlyDistWithMeta: path.join(pathToDist, 'plotly-with-meta.js'),
4343

44+
pathToSchema: path.join(pathToDist, 'plot-schema.json'),
45+
4446
partialBundleNames: partialBundleNames,
4547
partialBundlePaths: partialBundlePaths,
4648

tasks/util/make_schema.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var fs = require('fs');
2+
var path = require('path');
3+
var jsdom = require('jsdom');
4+
5+
module.exports = function makeSchema(plotlyPath, schemaPath) {
6+
return function() {
7+
var plotlyjsCode = fs.readFileSync(plotlyPath, 'utf-8');
8+
jsdom.env({
9+
html: '<div></div>',
10+
src: [plotlyjsCode],
11+
done: function(err, window) {
12+
if(err) {
13+
console.log(err);
14+
return;
15+
}
16+
17+
var plotSchema = window.Plotly.PlotSchema.get();
18+
var plotSchemaStr = JSON.stringify(plotSchema, null, 4);
19+
fs.writeFileSync(schemaPath, plotSchemaStr);
20+
21+
console.log('ok ' + path.basename(schemaPath));
22+
}
23+
});
24+
};
25+
};

0 commit comments

Comments
 (0)