Skip to content

Commit

Permalink
updating tests, linting, and added docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
devpaul committed Dec 21, 2017
1 parent 383077b commit 08a8b5e
Show file tree
Hide file tree
Showing 28 changed files with 227 additions and 92 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
_build
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# http://editorconfig.org
root = true

[*]
indent_style = tab
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[{package.json,.travis.yml}]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,4 @@ fabric.properties

/dist/
/package-lock.json
/_build/
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sudo: false
language: node_js
node_js:
- 6
cache:
directories:
- node_modules
before_install:
- export TZ=America/Los_Angeles
script:
- npm run ci
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Container for support server
# Usage
# Build: docker build -t derpymon .
# Run: docker run --name derp -p 8888:8888 derpymon
# Share volumes:
# docker run --name derp \
# -v `pwd`/src:/derpymon/src -v `pwd`/tests:/derpymon/tests \
# -p 8888:8888 -p 8001:8001 -p 8010:8010 derpymon
# Shell: docker exec -it derp /bin/bash
# Stop: docker stop derp
FROM node:8

COPY . /derpymon
WORKDIR /derpymon
RUN npm install
RUN npm run build
EXPOSE 8888
EXPOSE 8001
ENTRYPOINT [ "npm", "run", "serve" ]
40 changes: 40 additions & 0 deletions intern.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"capabilities+": {
"project": "Derpymon",
"name": "devpaul/derpymon"
},
"browser": {
"plugins": [
"./_build/src/src.js"
],
"suites": [
"./_build/tests/unit/all.js"
]
},
"coverage": false,
"node": {
"reporters": [{ "name": "simple" }]
},
"configs": {
"local": {
"tunnel": "selenium",
"environments": [
{ "browserName": "chrome" }
]
},
"saucelabs": {
"tunnel": "saucelabs",
"capabilities+": {
"fixSessionCapabilities": false
},

"defaultTimeout": 10000,
"environments": [
{ "browserName": "internet explorer", "version": [ "11.0" ], "platform": "Windows 7" },
{ "browserName": "firefox", "version": "43", "platform": "Windows 10" },
{ "browserName": "chrome", "platform": "Windows 10" }
],
"maxConcurrency": 4
}
}
}
30 changes: 19 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@
"license": "MPL-2.0",
"scripts": {
"build": "dojo build",
"build-tests": "dojo build -t --disableLazyWidgetDetection",
"ci": "npm run build-tests && npm run saucelabs",
"element": "dojo build --element=src/createDerpymonElement.ts",
"saucelabs": "intern config=@saucelabs",
"selenium": "intern config=@local",
"serve": "ts-node ./support/webserv",
"test": "dojo test",
"watch": "dojo build -w"
},
"repository": {
"git": "https://github.com/devpaul/derpymon"
},
"dependencies": {
"@dojo/core": "^0.1.0",
"@dojo/has": "^0.1.0",
"@dojo/i18n": "^0.1.0",
"@dojo/interfaces": "^0.1.0",
"@dojo/routing": "^0.1.0",
"@dojo/shim": "^0.1.0",
"@dojo/shim": "^0.2.3",
"@dojo/widget-core": "^0.1.0",
"@types/aframe": "^0.5.0",
"@webcomponents/custom-elements": "^1.0.2",
Expand All @@ -25,25 +34,24 @@
"maquette": "devpaul/maquette#custom-elements-dist"
},
"devDependencies": {
"@dojo/cli": "next",
"@dojo/cli-build-webpack": "next",
"@dojo/cli-test-intern": "next",
"@dojo/interfaces": "next",
"@dojo/loader": "next",
"@types/chai": "~3.4.0",
"@dojo/cli": "^0.2.0",
"@dojo/cli-build-webpack": "^0.2.2",
"@dojo/cli-test-intern": "^0.2.1",
"@dojo/test-extras": "^0.2.1",
"@types/glob": "~5.0.0",
"@types/grunt": "~0.4.0",
"@types/ip": "0.0.30",
"@types/node": "^6.0.46",
"@types/opn": "^3.0.28",
"@types/sinon": "^1.16.35",
"chai": "^3.5.0",
"intern": "~3.4.1",
"chai": "^4.1.2",
"intern": "^4.1.4",
"ip": "^1.1.5",
"opn": "^5.1.0",
"sinon": "^2.0.0",
"ts-node": "^3.3.0",
"typescript": "^2.4.2",
"ts-node": "^4.0.2",
"tslint-sitepen": "^0.1.0",
"typescript": "^2.6.2",
"webserv": "^0.11.1"
}
}
2 changes: 1 addition & 1 deletion src/commands/throwDerpyball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import OutsideContext, { Throw } from '../context/OutsideContext';

export default function throwDerpyball(payload: Throw, outside: OutsideContext) {
if (payload) {
outside.throwBall(payload)
outside.throwBall(payload);
}
}
3 changes: 2 additions & 1 deletion src/components/heightComponent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box3 } from 'three';
// tslint:disable:variable-name
const AFrame = require('aframe');

export const objHeight = 'objheight';
Expand Down Expand Up @@ -36,7 +37,7 @@ export default function register() {
if (scale === 0) {
scale = zeroScale;
}
console.log(bounds, );
console.log(bounds);
// Scale to desired height
object3D.scale.set(scale, scale, scale);
// Place on the ground
Expand Down
8 changes: 3 additions & 5 deletions src/containers/AppContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import initialize from '../commands/initialize';
import AssetContext from '../context/AssetContext';
import OutsideContext from '../context/OutsideContext';

const AppContainer = Container(App, [ State.App, State.Asset, State.Outside ], {
export default class AppContainer extends Container(App, [ State.App, State.Asset, State.Outside ], {
getProperties([ app, assets, outside ]: [ AppContext, AssetContext, OutsideContext ]): AppProperties {
return {
isLoadingState: app.isLoadingState,
Expand All @@ -15,8 +15,6 @@ const AppContainer = Container(App, [ State.App, State.Asset, State.Outside ], {
initialize() {
initialize(app, assets, outside);
}
}
};
}
});

export default AppContainer;
}) {}
8 changes: 3 additions & 5 deletions src/containers/AssetContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import Assets from '../widgets/Assets';
import AssetContext from '../context/AssetContext';
import { State } from '../initialize';

const AssetContainer = Container(Assets, State.Asset, {
export default class AssetContainer extends Container(Assets, State.Asset, {
getProperties(context: AssetContext) {
return {
assets: context.assets
}
};
}
});

export default AssetContainer;
}) {}
8 changes: 3 additions & 5 deletions src/containers/ControlsContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Controls, { ControlsProperties } from '../widgets/Controls';
import { Throw } from '../context/OutsideContext';
import throwDerpyball from '../commands/throwDerpyball';

const ControlsContainer = Container(Controls, [ State.App, State.Outside ], {
export default class ControlsContainer extends Container(Controls, [ State.App, State.Outside ], {
getProperties([ app, outside ]): ControlsProperties {
return {
onActionButtonPressed() {
Expand All @@ -20,8 +20,6 @@ const ControlsContainer = Container(Controls, [ State.App, State.Outside ], {
onActionButtonReleased() {
console.log('released', app.state);
}
}
};
}
});

export default ControlsContainer;
}) {}
12 changes: 5 additions & 7 deletions src/containers/OutsideContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { State } from '../initialize';
import AssetContext from '../context/AssetContext';
import removeDerpyball from '../commands/removeDerpyball';

const OutsideContainer = Container(Outside, [ State.Outside, State.Asset ], {
export default class OutsideContainer extends Container(Outside, [ State.Outside, State.Asset ], {
getProperties(payload: [ OutsideContext, AssetContext ]): OutsideProperties {
const [
outside = throws(),
appContext = throws(),
appContext = throws()
] = payload;
let monster: OutsideProperties['monster'];
const monsterInfo = outside.monster;
Expand All @@ -23,7 +23,7 @@ const OutsideContainer = Container(Outside, [ State.Outside, State.Asset ], {
mtl: `#${ assets.mtl.id }`,
name: monsterInfo.name,
obj: `#${ assets.obj.id }`
}
};
}
}
return {
Expand All @@ -34,8 +34,6 @@ const OutsideContainer = Container(Outside, [ State.Outside, State.Asset ], {
removeDerpyball() {
removeDerpyball(outside);
}
}
};
}
});

export default OutsideContainer;
}) {}
8 changes: 3 additions & 5 deletions src/containers/SceneContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import AppContext from '../context/AppContext';
import Scene, { SceneProperties } from '../widgets/Scene';
import { State } from '../initialize';

const SceneContainer = Container(Scene, State.App, {
export default class SceneContainer extends Container(Scene, State.App, {
getProperties(state: AppContext): SceneProperties {
return {
debug: state.debug,
state: state.state
}
};
}
});

export default SceneContainer;
}) {}
2 changes: 1 addition & 1 deletion src/context/AssetContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ export default class AssetContext extends InjectorBase {
return {
mtl: this._assets.get(`${ name }-mtl`),
obj: this._assets.get(`${ name }-obj`)
}
};
}
}
2 changes: 1 addition & 1 deletion src/context/OutsideContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class OutsideContext extends InjectorBase {
initialTime: value.initialTime || performance.now(),
position: <Dimension3> Array.from(value.position),
speed: value.speed
}
};
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ProjectorMixin } from '@dojo/widget-core/mixins/Projector';
import initialize from './initialize';
import AppContainer from './containers/AppContainer';
import Executor from './framework/Executor';

const root = document.querySelector('go-derpy') || undefined;

Expand All @@ -10,6 +9,7 @@ if (!root) {
}

const registry = initialize();
// tslint:disable:variable-name
const Projector = ProjectorMixin(AppContainer);
const projector = new Projector();
projector.setProperties({ registry });
Expand Down
2 changes: 1 addition & 1 deletion src/util/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function filteredProps<T = any>(whitelist: string[]): GetProperties<T> {
props[item] = properties[item];
}
return props;
}
};
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/Controls.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { v } from '@dojo/widget-core/d';
import { DNode, EventHandler, WidgetProperties } from '@dojo/widget-core/interfaces';
import { DNode, EventHandler } from '@dojo/widget-core/interfaces';
import { WidgetBase } from '@dojo/widget-core/WidgetBase';

export interface ControlsProperties {
onActionButtonPressed?: EventHandler,
onActionButtonReleased?: EventHandler
onActionButtonPressed?: EventHandler;
onActionButtonReleased?: EventHandler;
}

export default class Controls extends WidgetBase<ControlsProperties> {
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/Outside.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export default class Outside extends WidgetBase<OutsideProperties> {
'static-body': 'shape: auto',
visible: 'false',
width: '30'
}),
]
})
];
}

private renderMonster() {
Expand All @@ -84,6 +84,6 @@ export default class Outside extends WidgetBase<OutsideProperties> {
position: `0 0 -${ monster.distance }`,
'static-body': 'shape: box',
[objHeight]: `${ monster.height }`
}) : null
}) : null;
}
}
4 changes: 2 additions & 2 deletions src/widgets/Scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ export default class Scene extends WidgetBase<SceneProperties> {

protected renderOutside() {
const {
debug = false,
debug = false
} = this.properties;

return v('a-scene', {
physics: `debug: ${ debug }`
}, [
w(AssetContainer, {}),
w(Controls, {}),
w(OutsideContainer, {}),
w(OutsideContainer, {})
]);
}

Expand Down
Loading

0 comments on commit 08a8b5e

Please sign in to comment.