Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use d3 dependencies directly #21

Merged
merged 12 commits into from
Jul 19, 2016
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://travis-ci.org/ivanvanderbyl/ember-cli-d3-shape.svg?branch=master)](https://travis-ci.org/ivanvanderbyl/ember-cli-d3-shape) [![Ember Observer Score](https://emberobserver.com/badges/ember-cli-d3-shape.svg)](https://emberobserver.com/addons/ember-cli-d3-shape) [![npm version](https://badge.fury.io/js/ember-cli-d3-shape.svg)](https://badge.fury.io/js/ember-cli-d3-shape) [![Dependency Status](https://david-dm.org/ivanvanderbyl/ember-cli-d3-shape.svg)](https://david-dm.org/ivanvanderbyl/ember-cli-d3-shape) [![devDependency Status](https://david-dm.org/ivanvanderbyl/ember-cli-d3-shape/dev-status.svg)](https://david-dm.org/ivanvanderbyl/ember-cli-d3-shape#info=devDependencies)

`ember-cli-d3-shape` is a shim for D3 `4.0.0-rc.1`, loaded from NPM as ES6 modules. It includes `d3-shape` and all version 4 modules in D3 `4.0.0-rc.1`.
`ember-cli-d3-shape` is a shim for D3 `4.x`, loaded from NPM as ES6 modules. It includes `d3-shape` and all version 4 modules in D3 `4.x`.

---

Expand Down
33 changes: 19 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ module.exports = {
app = app.app;
}

var pkg = require(path.join(lookupPackage('d3'), 'package.json'));

// Find all dependencies of `d3`

this.d3Modules = Object.keys(pkg.dependencies).filter(function(name) {
return /^d3\-/.test(name);
});

// This essentially means we'll skip importing this package twice, if it's
// a dependency of another package.
if (!app.import) {
Expand All @@ -53,17 +61,6 @@ module.exports = {
return;
}

var packageDependencies = this.dependencies();

this.d3Modules = [];

for (var packageName in packageDependencies) {
if (packageDependencies.hasOwnProperty(packageName)) {
if (/^d3\-/.test(packageName)) {
this.d3Modules.push(packageName);
}
}
}
var _this = this;
this.d3Modules.forEach(function(packageName) {
_this.import(path.join('vendor', packageName, packageName + '.js'));
Expand All @@ -77,17 +74,25 @@ module.exports = {
trees.push(tree);
}

// var nodeModulesPath = this.nodeModulesPath;
var d3PackagePath = lookupPackage('d3');

this.d3Modules.forEach(function(packageName) {
var d3PathToSrc, srcTree;

// Import existing builds from node d3 packages, which are UMD packaged.
var packageBuildPath = path.join('build', packageName + '.js');

d3PathToSrc = lookupPackage(packageName);
d3PathToSrc = path.join(d3PackagePath, 'node_modules', packageName);

try {
fs.statSync(path.join(d3PathToSrc)).isDirectory();
} catch(err) {
d3PathToSrc = lookupPackage(packageName);
}

if (!fs.statSync(path.join(d3PathToSrc, packageBuildPath)).isFile()) {
try {
fs.statSync(path.join(d3PathToSrc, packageBuildPath)).isFile()
} catch(err) {
console.error('[ERROR] D3 Package (' + packageName + ') is not built as expected, cannot continue. Please report this as a bug.');
return;
}
Expand Down
37 changes: 5 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-cli-d3-shape",
"version": "0.9.3",
"version": "0.9.4-4.1.1.0",
"description": "Data-Driven Documents for Ember",
"directories": {
"doc": "doc",
Expand Down Expand Up @@ -35,9 +35,9 @@
"ember-export-application-global": "^1.0.5",
"ember-load-initializers": "^0.5.1",
"ember-resolver": "^2.0.3",
"loader.js": "^4.0.1",
"ember-suave": "2.0.1",
"ember-try": "^0.2.2",
"loader.js": "^4.0.1",
"npm-registry-client": "^7.1.1",
"semver": "^5.1.0"
},
Expand All @@ -55,36 +55,9 @@
"broccoli-merge-trees": "^1.1.1",
"broccoli-persistent-filter": "^1.1.6",
"broccoli-stew": "^1.2.0",
"d3-array": "1.0.0",
"d3-axis": "1.0.0",
"d3-brush": "1.0.1",
"d3-collection": "1.0.0",
"d3-color": "1.0.0",
"d3-dispatch": "1.0.0",
"d3-drag": "1.0.0",
"d3-dsv": "1.0.0",
"d3-ease": "1.0.0",
"d3-force": "1.0.0",
"d3-format": "1.0.0",
"d3-hierarchy": "1.0.0",
"d3-interpolate": "1.0.0",
"d3-path": "1.0.0",
"d3-polygon": "1.0.0",
"d3-quadtree": "1.0.0",
"d3-queue": "3.0.1",
"d3-random": "1.0.0",
"d3-request": "1.0.0",
"d3-scale": "1.0.0",
"d3-selection": "1.0.0",
"d3-shape": "1.0.0",
"d3-time": "1.0.0",
"d3-time-format": "2.0.0",
"d3-timer": "1.0.0",
"d3-transition": "1.0.0",
"d3-voronoi": "1.0.0",
"d3-zoom": "1.0.1",
"ember-cli-babel": "^5.1.6",
"recast": "^0.11.0"
"d3": "4.1.1",
"recast": "^0.11.0",
"ember-cli-babel": "^5.1.6"
},
"ember-addon": {
"configPath": "tests/dummy/config"
Expand Down