Skip to content

Commit

Permalink
New alias system (visgl#1504)
Browse files Browse the repository at this point in the history
* Consolidate node test scripts

* deck.gl-test-utils v0.2.0

* deck.gl-test-utils v0.2.1

* deck.gl-test-utils v0.2.2

* deck.gl-test-utils v0.2.3

* deck.gl-test-utils v0.2.5
  • Loading branch information
ibgreen authored Mar 5, 2018
1 parent ef4095f commit 41dcd98
Show file tree
Hide file tree
Showing 23 changed files with 264 additions and 334 deletions.
25 changes: 17 additions & 8 deletions test/node-aliases.js → aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,24 @@
// THE SOFTWARE.

// Enables ES2015 import/export in Node.js
require('reify');

// Registers an alias for this module
const path = require('path');
const moduleAlias = require('module-alias');
moduleAlias.addAlias('deck.gl/test', path.resolve('./test'));
moduleAlias.addAlias('deck.gl', path.resolve('./src'));
moduleAlias.addAlias('deck.gl/dist', path.resolve('./src'));
moduleAlias.addAlias('deck.gl-layers', path.resolve('./src/experimental-layers/src'));
moduleAlias.addAlias('deck.gl-test-utils', path.resolve('./src/test-utils/src'));

require('babel-polyfill');
const ALIASES = {
'deck.gl/test': path.resolve('./test'),
'deck.gl': path.resolve('./src'),
'deck.gl-layers': path.resolve('./src/experimental-layers/src')
// 'deck.gl-test-utils': path.resolve('./src/test-utils/src')
};

if (module.require) {
module.require('reify');

const moduleAlias = module.require('module-alias');
moduleAlias.addAliases(ALIASES);

module.require('babel-polyfill');
}

module.exports = ALIASES;
20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
"clean": "npm run build-clean",
"clean-modules": "for D in src/*; do ([ -d $D ] && cd $D && rm -rf node_modules && rm -f yarn.lock && rm -fr dist dist-es6 && mkdir -p dist dist-es6 ); done",
"build-clean": "rm -fr dist dist-es6 && mkdir -p dist dist-es6",
"build-es6": "rm -fr dist-es6 && babel src --ignore 'node_modules/' --out-dir dist-es6 --source-maps inline",
"build-es5": "rm -fr dist && babel src --ignore 'node_modules/' --out-dir dist --plugins=transform-es2015-modules-commonjs --source-maps inline",
"build": "npm run build-clean && npm run build-es6 && npm run build-es5",
"build-es6": "rm -fr dist-es6 && babel src --ignore 'node_modules/' --out-dir dist-es6 --source-maps",
"build-es5": "rm -fr dist && babel src --ignore 'node_modules/' --out-dir dist --plugins=transform-es2015-modules-commonjs --source-maps",
"build-size": "(echo \"dist size\" ; find dist -name '*.js' | xargs cat | wc -c) && (echo \"dist-es6 size\" ; find dist-es6 -name '*.js' | xargs cat | wc -c)",
"build": "npm run build-clean && npm run build-es6 && npm run build-es5 && npm run build-size",
"cover": "NODE_ENV=test nyc --reporter html --reporter cobertura --reporter=lcov npm run test-cover",
"pretty": "prettier --write \"{src,examples,test}/**/*.js\" --loglevel warn",
"lint": "prettier-check \"{src,examples,test}/**/*.js\" && eslint src test examples && npm run lint-yarn",
Expand All @@ -36,15 +37,15 @@
"publish-beta": "npm run build && npm run test && npm run test-dist && npm publish --tag beta",
"test": "npm run lint && npm run test-node && npm run build && npm run test-render-react",
"test-fast": "npm run test-node",
"test-ci": "npm run lint && node test/node-ci.js",
"test-ci": "npm run lint && node test/start.js test-ci",
"test-cover": "NODE_ENV=test tape -r babel-register test/node.js && nyc report",
"test-node": "node test/node.js",
"test-dist": "node test/node-dist.js",
"test-node": "node test/start.js test",
"test-dist": "node test/start.js test-dist",
"test-render": "node test/start.js render",
"test-render-react": "node test/start.js render-react",
"test-browser": "webpack-dev-server --env.test --progress --hot --open",
"test-render": "node test/render/node-start.js",
"test-render-react": "node test/render/node-start.js render-react",
"test-render-browser": "webpack-dev-server --env.render --progress --hot --open",
"bench": "node test/bench/node.js",
"bench": "node test/start.js bench",
"bench-browser": "webpack-dev-server --env.bench --progress --hot --open"
},
"dependencies": {
Expand All @@ -71,6 +72,7 @@
"benchmark": "^2.1.3",
"brfs-babel": "^1.0.0",
"coveralls": "^2.13.0",
"deck.gl-test-utils": "^0.2.7",
"eslint": "^4.13.1",
"eslint-config-prettier": "^2.9.0",
"eslint-config-uber-es2015": "^3.1.2",
Expand Down
23 changes: 23 additions & 0 deletions src/test-utils/aliases.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Registers an alias for this module

const path = require('path');
const ALIASES = {
'deck.gl-test-utils': path.resolve(__dirname, './src'),
'deck.gl/test/data': path.resolve(__dirname, '../../test/data'),
'deck.gl': path.resolve(__dirname, '../../src')
};

if (module.require) {
// Enables ES2015 import/export in Node.js
require('reify');

const moduleAlias = require('module-alias');
moduleAlias.addAliases(ALIASES);

require('babel-polyfill');

// Import headless luma support
require('luma.gl/headless');
}

module.exports = ALIASES;
12 changes: 5 additions & 7 deletions src/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "deck.gl-test-utils",
"description": "Test utilities for deck.gl layers",
"license": "MIT",
"version": "0.1.0",
"version": "0.2.7",
"keywords": [
"webgl",
"visualization",
Expand All @@ -14,17 +14,15 @@
"url": "https://github.com/uber/deck.gl.git"
},
"main": "dist/index.js",
"module": "dist-es6/index.js",
"files": [
"dist",
"dist-es6",
"src"
],
"scripts": {
"build-clean": "rm -fr dist dist-es6 && mkdir -p dist dist-es6",
"build-es6": "rm -fr dist-es6 && babel src --out-dir dist-es6 --source-maps inline",
"build-es5": "rm -fr dist && babel src --out-dir dist --plugins=transform-es2015-modules-commonjs --source-maps inline",
"build": "npm run build-clean && npm run build-es6 && npm run build-es5",
"build": "npm run build-clean && npm run build-es5",
"cover": "NODE_ENV=test nyc --reporter html --reporter cobertura --reporter=lcov npm run test-cover",
"lint": "eslint src test examples && npm run lint-yarn",
"lint-yarn": "!(grep -q unpm.u yarn.lock) || (echo 'Please rebuild yarn file using public npmrc' && false)",
Expand All @@ -41,14 +39,14 @@
"test-rendering": "(cd test/render && webpack-dev-server --config webpack.config.test-rendering.js --progress --hot --open)"
},
"dependencies": {
"deck.gl": "^5.1.0",
"deck.gl": "^5.1.1",
"luma.gl": "^5.1.0",
"probe.gl": "^0.2.2",
"ndarray": "^1.0.18",
"save-pixels": "^2.3.2",
"canvas-to-blob": "0.0.0",
"filesaver.js": "^0.2.0",
"through": "^2.3.8",
"probe.gl": "^0.2.2"
"through": "^2.3.8"
},
"devDependencies": {
"babel-cli": "^6.22.2",
Expand Down
13 changes: 0 additions & 13 deletions src/test-utils/test/node-aliases.js

This file was deleted.

14 changes: 1 addition & 13 deletions src/test-utils/test/node-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// Enables ES2015 import/export in Node.js
require('reify');

// Registers an alias for this module
const path = require('path');
const moduleAlias = require('module-alias');
moduleAlias.addAlias('deck.gl-layers/test', path.resolve('./test'));
moduleAlias.addAlias('deck.gl-layers', path.resolve('./src'));

require('babel-polyfill');

// Import headless luma support
require('luma.gl/headless');
import '../aliases';

// Run the tests
const {RenderTestDriver} = require('deck.gl-test-utils');
Expand Down
2 changes: 1 addition & 1 deletion src/test-utils/test/node-test-dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

require('./node-aliases');
require('../aliases');

// Run the tests
require('./index');
2 changes: 1 addition & 1 deletion src/test-utils/test/node-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

require('./node-aliases');
require('../aliases');

// Run the tests
require('./index');
2 changes: 1 addition & 1 deletion src/test-utils/test/src/lifecycle-test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// THE SOFTWARE.

import test from 'tape-catch';
import * as FIXTURES from 'deck.gl/test/data/geojson-data';
import * as FIXTURES from 'deck.gl/test/data';
import {testLayer} from 'deck.gl-test-utils';

import {GeoJsonLayer} from 'deck.gl';
Expand Down
21 changes: 13 additions & 8 deletions src/test-utils/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const {resolve} = require('path');
const webpack = require('webpack');

const ALIASES = require('./aliases');

const LIBRARY_BUNDLE_CONFIG = {
// Bundle the source code
entry: {
Expand All @@ -23,6 +25,10 @@ const LIBRARY_BUNDLE_CONFIG = {
// Exclude any non-relative imports from resulting bundle
externals: [/^[a-z\.\-0-9]+$/],

resolve: {
alias: ALIASES
},

module: {
rules: [
{
Expand Down Expand Up @@ -66,9 +72,7 @@ const BROWSER_CONFIG = {
},

resolve: {
alias: {
'deck.gl-test-utils': resolve('./src')
}
alias: ALIASES
},

devtool: '#inline-source-maps',
Expand Down Expand Up @@ -121,17 +125,18 @@ const BENCH_BROWSER_CONFIG = Object.assign({}, BROWSER_CONFIG, {

module.exports = env => {
env = env || {};
let config = LIBRARY_BUNDLE_CONFIG;
if (env.test) {
return TEST_BROWSER_CONFIG;
config = TEST_BROWSER_CONFIG;
}
if (env.render) {
return RENDER_BROWSER_CONFIG;
config = RENDER_BROWSER_CONFIG;
}
if (env['render-react']) {
return RENDER_REACT_BROWSER_CONFIG;
config = RENDER_REACT_BROWSER_CONFIG;
}
if (env.bench) {
return BENCH_BROWSER_CONFIG;
config = BENCH_BROWSER_CONFIG;
}
return LIBRARY_BUNDLE_CONFIG;
return config;
};
2 changes: 1 addition & 1 deletion test/bench/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// THE SOFTWARE.

/* eslint-disable no-console, no-invalid-this */
import {Bench} from 'probe.gl';
import {Bench} from 'probe.gl/bench';

import layerBench from './layer.bench';
import coreLayersBench from './core-layers.bench';
Expand Down
42 changes: 0 additions & 42 deletions test/bench/node.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
require('tap-browser-color')();
require('babel-polyfill');

require('./index');
require('./src/index');
require('./src/react');
24 changes: 0 additions & 24 deletions test/electron.js

This file was deleted.

39 changes: 0 additions & 39 deletions test/node-ci.js

This file was deleted.

Loading

0 comments on commit 41dcd98

Please sign in to comment.