git ssb

1+

dinoworm ๐Ÿ› / catstack



Commit b817a22329dc2038d6896282542635e15961b37b

Merge branch 'master' of https://github.com/ahdinosaur/craftworks-todomvc

Don Smith committed on 12/28/2015, 8:28:50 PM
Parent: 7d964f2bef52e9913aa6872a034f7e967653274b
Parent: d616b061d62dd2c5b590c4c986655fec7d2d4df7

Files changed

README.mdchanged
app/client.jschanged
app/package.jsonchanged
app/routes.jschanged
app/services/index.jschanged
app/store.jschanged
app/actions/index.jsdeleted
app/components/dev-tools.jsdeleted
app/components/landing/index.cssdeleted
app/components/landing/index.jsdeleted
app/dev/root.jsadded
app/dev/tools.jsadded
app/containers/app.jsdeleted
app/containers/dev-root.jsdeleted
app/containers/landing.jsdeleted
app/containers/no-match.jsdeleted
app/containers/todos.jsdeleted
app/features.jsadded
app/four-oh-four/container.jsadded
app/four-oh-four/routes.jsadded
app/reducers/index.jsdeleted
app/reducers/todos.jsdeleted
app/landing/component.jsadded
app/landing/container.jsadded
app/landing/routes.jsadded
app/landing/style.cssadded
app/layout/container.jsadded
app/reducer.jsadded
app/spec.jsadded
app/todos/container.jsadded
app/todos/features/new.featureadded
app/todos/reducer.jsadded
app/todos/routes.jsadded
package.jsonchanged
feature/index.jsdeleted
feature/steps.jsdeleted
spec/index.jsdeleted
README.mdView
@@ -18,33 +18,28 @@
1818 - `/config/defaults.js`
1919 - `/config/{ NODE_ENV }.js`
2020 - `/app/`
2121 - symlink `/app` to `/node_modules/app`
22- - e.g.
2322 - `/app/package.json`
2423 - `/app/client.js`
2524 - `/app/server.js`
25+ - `/app/reducer.js`
2626 - `/app/routes.js`
27- - `/app/store.js`
28- - `/app/models/todo.js`
29- - `/app/services/todos.js`
30- - `/app/clients/todos.js`
31- - `/app/actions/todos.js`
32- - `/app/action-types/todos.js`
33- - `/app/reducers/todos.js`
34- - `/app/getters/todos.js`
35- - `/app/containers/todos.js`
36- - `/app/components/todos/index.js`
37- - `/app/components/todos/index.css`
38- - always require top-down (`require('app/models/todo')`) instead of relative.
39- - `/spec/`
40- - e.g.
41- - `/spec/services/todos.js`
42- - `/spec/components/todos.js`
43- - `/features/`
44- - e.g.
45- - `/features/steps.js`
46- - `/features/todos.feature`
27+ - `/app/thing/model.js`
28+ - `/app/thing/service.js`
29+ - `/app/thing/client.js`
30+ - `/app/thing/routes.js`
31+ - `/app/thing/actions.js`
32+ - `/app/thing/reducer.js`
33+ - `/app/thing/getters.js`
34+ - `/app/thing/components/thing-list.js`
35+ - `/app/thing/components/thing-list.css`
36+ - `/app/thing/spec/components/thing-list.js`
37+ - `/app/thing/index.feature`
38+ - `/app/thing/steps.js`
39+ - `/app/list-view/index.js`
40+ - only do relative requires if within module
41+ - otherwise, always require top-down (`require('app/things/model')`).
4742 - data model: [tcomb](https://github.com/gcanti/tcomb)
4843 - database: [knex](https://www.npmjs.com/package/knex)
4944 - data validator: [tcomb-validator](https://github.com/gcanti/tcomb-validation)
5045 - api service: [feathers-knex](https://www.npmjs.com/package/feathers-knex)
@@ -59,9 +54,9 @@
5954 - client store: [redux](https://www.npmjs.com/package/redux)
6055 - client router: [redux-router](https://www.npmjs.com/package/redux-router)
6156 - client views: [react](https://www.npmjs.com/package/react)
6257 - client forms: [tcomb-form](https://github.com/gcanti/tcomb-form)
63-- test specs: [tape](https://www.npmjs.com/package/tape)
58+- test specs: [ava](https://www.npmjs.com/package/ava)
6459 - test features: [cuke-tap](https://www.npmjs.com/package/cuke-tap)
6560 - generators: [plop](https://github.com/amwmedia/plop)
6661
6762 refs: [0](http://teropa.info/blog/2015/09/10/full-stack-redux-tutorial.html), [1](http://blog.workshape.io/the-3ree-stack-react-redux-rethinkdb-express-js/)
app/client.jsView
@@ -30,9 +30,9 @@
3030 document.querySelector('main')
3131 )
3232
3333 if (process.env.NODE_ENV === 'development') {
34- const DevTools = require('app/components/dev-tools')
34+ const DevTools = require('app/dev/tools')
3535
3636 render(
3737 <Provider store={store} key="provider">
3838 <div>
app/package.jsonView
@@ -4,9 +4,9 @@
44 "./config.js": "./config-browser.js"
55 },
66 "browserify": {
77 "transform": [
8- ["cssify", { "modules": true }],
8+ ["cssify", { "modules": true } ],
99 "babelify",
1010 "envify",
1111 ["evalify", { "files": [ "config-browser.js" ] } ],
1212 "bulkify"
app/routes.jsView
@@ -1,17 +1,24 @@
11 const React = require('react')
22 const { Route, IndexRoute } = require('react-router')
3+const bulk = require('bulk-require')
4+const { mapObjIndexed, values } = require('ramda')
35
4-const AppContainer = require('app/containers/app')
5-const LandingContainer = require('app/containers/landing')
6-const TodosContainer = require('app/containers/todos')
7-const NoMatchContainer = require('app/containers/no-match')
6+const LayoutContainer = require('app/layout/container')
7+const FourOhFourRoutes = require('app/four-oh-four/routes')
88
99 const routes = (
10- <Route path='/' component={AppContainer}>
11- <IndexRoute component={LandingContainer} />
12- <Route path='todos' component={TodosContainer} />
13- <Route path="*" component={NoMatchContainer} />
10+ <Route path='/' component={LayoutContainer}>
11+ {
12+ values(mapObjIndexed(
13+ (module, moduleName) => ({
14+ ...module.routes,
15+ key: moduleName
16+ }),
17+ bulk(__dirname, '!(four-oh-four)/routes.js')
18+ ))
19+ }
20+ { FourOhFourRoutes }
1421 </Route>
1522 )
1623
1724 module.exports = routes
app/services/index.jsView
@@ -1,3 +1,10 @@
11 const bulk = require('bulk-require')
2+const { map } = require('ramda')
23
3-module.exports = bulk(__dirname, '!(index.js)')
4+module.exports = {
5+ ...bulk(__dirname, '*/service.js'),
6+ ...map(
7+ (module) => module.services,
8+ bulk(__dirname, '*/services/*.js')
9+ )
10+}
app/store.jsView
@@ -1,9 +1,9 @@
11 const { createStore, compose, applyMiddleware } = require('redux')
22 const thunk = require('redux-thunk')
33 const { createHistory } = require('history')
44
5-const reducer = require('app/reducers')
5+const reducer = require('app/reducer')
66
77 let storeEnhancers = []
88 let middleware = []
99
@@ -12,9 +12,9 @@
1212 if (process.env.NODE_ENV === 'development') {
1313 var logger = require('redux-logger')
1414 var { persistState } = require('redux-devtools')
1515
16- var DevTools = require('app/components/dev-tools')
16+ var DevTools = require('app/dev/tools')
1717 }
1818
1919 storeEnhancers.push(
2020 applyMiddleware(...middleware)
@@ -41,10 +41,10 @@
4141
4242 function finalCreateStore(initialState) {
4343
4444 if (module.hot) {
45- module.hot.accept('app/reducers', () => {
46- store.replaceReducer(require('app/reducers'))
45+ module.hot.accept('app/reducer', () => {
46+ store.replaceReducer(require('app/reducer'))
4747 })
4848 }
4949
5050 return createEnhancedStore(reducer, initialState)
app/actions/index.jsView
@@ -1,3 +1,0 @@
1-const bulk = require('bulk-require')
2-
3-module.exports = bulk(__dirname, '*.js')
app/components/dev-tools.jsView
@@ -1,13 +1,0 @@
1-const React = require('react')
2-const { createDevTools } = require('redux-devtools')
3-const LogMonitor = require('redux-devtools-log-monitor').default
4-const DockMonitor = require('redux-devtools-dock-monitor').default
5-
6-const DevTools = createDevTools(
7- <DockMonitor toggleVisibilityKey='H'
8- changePositionKey='Q'>
9- <LogMonitor />
10- </DockMonitor>
11-)
12-
13-module.exports = DevTools
app/components/landing/index.cssView
@@ -1,3 +1,0 @@
1-.container {
2- font-weight: bold;
3-}
app/components/landing/index.jsView
@@ -1,13 +1,0 @@
1-const React = require('react')
2-
3-const style = require('./index.css')
4-
5-class Landing extends React.Component {
6- render () {
7- return <div className={style.container}>
8- landing!
9- </div>
10- }
11-}
12-
13-module.exports = Landing
app/dev/root.jsView
@@ -1,0 +1,31 @@
1+const React = require('react')
2+const { Provider } = require('react-redux')
3+const { ReduxRouter } = require('redux-router')
4+
5+const routes = require('app/routes')
6+
7+if (process.env.NODE_ENV === 'development') {
8+ var DevTools = require('app/components/dev-tools')
9+}
10+
11+class Root extends React.Component {
12+ render() {
13+ const { store } = this.props;
14+
15+ return (
16+ <Provider store={store}>
17+ <div>
18+ <ReduxRouter>
19+ { routes }
20+ </ReduxRouter>
21+ {
22+ (process.env.NODE_ENV === 'development') ?
23+ <DevTools /> : null
24+ }
25+ </div>
26+ </Provider>
27+ )
28+ }
29+}
30+
31+module.exports = Root
app/dev/tools.jsView
@@ -1,0 +1,13 @@
1+const React = require('react')
2+const { createDevTools } = require('redux-devtools')
3+const LogMonitor = require('redux-devtools-log-monitor').default
4+const DockMonitor = require('redux-devtools-dock-monitor').default
5+
6+const DevTools = createDevTools(
7+ <DockMonitor toggleVisibilityKey='H'
8+ changePositionKey='Q'>
9+ <LogMonitor />
10+ </DockMonitor>
11+)
12+
13+module.exports = DevTools
app/containers/app.jsView
@@ -1,17 +1,0 @@
1-const React = require('react')
2-const { connect } = require('react-redux')
3-
4-class AppContainer extends React.Component {
5- render () {
6- const { children } = this.props
7-
8- return <div>
9- <span>hello world!</span>
10- { children }
11- </div>
12- }
13-}
14-
15-module.exports = connect(
16- (state) => ({})
17-)(AppContainer)
app/containers/dev-root.jsView
@@ -1,31 +1,0 @@
1-const React = require('react')
2-const { Provider } = require('react-redux')
3-const { ReduxRouter } = require('redux-router')
4-
5-const routes = require('app/routes')
6-
7-if (process.env.NODE_ENV === 'development') {
8- var DevTools = require('app/components/dev-tools')
9-}
10-
11-class Root extends React.Component {
12- render() {
13- const { store } = this.props;
14-
15- return (
16- <Provider store={store}>
17- <div>
18- <ReduxRouter>
19- { routes }
20- </ReduxRouter>
21- {
22- (process.env.NODE_ENV === 'development') ?
23- <DevTools /> : null
24- }
25- </div>
26- </Provider>
27- )
28- }
29-}
30-
31-module.exports = Root
app/containers/landing.jsView
@@ -1,14 +1,0 @@
1-const React = require('react')
2-const { connect } = require('react-redux')
3-
4-const Landing = require('app/components/landing')
5-
6-class LandingContainer extends React.Component {
7- render () {
8- return <Landing />
9- }
10-}
11-
12-module.exports = connect(
13- (state) => ({})
14-)(LandingContainer)
app/containers/no-match.jsView
@@ -1,14 +1,0 @@
1-const React = require('react')
2-const { connect } = require('react-redux')
3-
4-class NoMatchContainer extends React.Component {
5- render () {
6- return <div>
7- no match!
8- </div>
9- }
10-}
11-
12-module.exports = connect(
13- (state) => ({})
14-)(NoMatchContainer)
app/containers/todos.jsView
@@ -1,14 +1,0 @@
1-const React = require('react')
2-const { connect } = require('react-redux')
3-
4-class TodosContainer extends React.Component {
5- render () {
6- return <div>
7- todo list!
8- </div>
9- }
10-}
11-
12-module.exports = connect(
13- (state) => ({})
14-)(TodosContainer)
app/features.jsView
@@ -1,0 +1,30 @@
1+const cuke = require('cuke-tap')
2+const path = require('path')
3+const glob = require('glob')
4+const join = require('path').join
5+const parallel = require('run-parallel')
6+
7+parallel([
8+ function (cb) {
9+ glob('{features/*.feature,*/index.feature,*/features/*.feature}', { cwd: __dirname }, cb)
10+ },
11+ function (cb) {
12+ glob('{steps/*.js,*/steps.js,*/steps/*.js}', { cwd: __dirname }, cb)
13+ }
14+], function (err, results) {
15+ if (err) { throw err }
16+
17+ const features = results[0].map(function (file) {
18+ return join(__dirname, file)
19+ })
20+ const steps = results[1].map(function (file) {
21+ return require(join(__dirname, file))
22+ })
23+
24+ console.log("features", features)
25+ console.log("steps", steps)
26+
27+ if (features.length > 0) {
28+ cuke(features, steps)
29+ }
30+})
app/four-oh-four/container.jsView
@@ -1,0 +1,14 @@
1+const React = require('react')
2+const { connect } = require('react-redux')
3+
4+class FourOhFourContainer extends React.Component {
5+ render () {
6+ return <div>
7+ no match!
8+ </div>
9+ }
10+}
11+
12+module.exports = connect(
13+ (state) => ({})
14+)(FourOhFourContainer)
app/four-oh-four/routes.jsView
@@ -1,0 +1,6 @@
1+const React = require('react')
2+const { Route } = require('react-router')
3+
4+const FourOhFourContainer = require('./container')
5+
6+module.exports = <Route path="*" component={FourOhFourContainer} />
app/reducers/index.jsView
@@ -1,8 +1,0 @@
1-const bulk = require('bulk-require')
2-const { combineReducers } = require('redux')
3-const { routeReducer } = require('redux-simple-router')
4-
5-module.exports = combineReducers({
6- ...bulk(__dirname, '!(index.js)'),
7- routing: routeReducer
8-})
app/reducers/todos.jsView
@@ -1,13 +1,0 @@
1-module.exports = todos
2-
3-function todos (state = {}, action) {
4- switch (action.type) {
5- case 'CREATE_TODO':
6- return {
7- ...state,
8- [action.payload.id]: action.payload
9- }
10- default:
11- return state
12- }
13-}
app/landing/component.jsView
@@ -1,0 +1,13 @@
1+const React = require('react')
2+
3+const style = require('./style.css')
4+
5+class Landing extends React.Component {
6+ render () {
7+ return <div className={style.container}>
8+ landing!
9+ </div>
10+ }
11+}
12+
13+module.exports = Landing
app/landing/container.jsView
@@ -1,0 +1,14 @@
1+const React = require('react')
2+const { connect } = require('react-redux')
3+
4+const Landing = require('./component')
5+
6+class LandingContainer extends React.Component {
7+ render () {
8+ return <Landing />
9+ }
10+}
11+
12+module.exports = connect(
13+ (state) => ({})
14+)(LandingContainer)
app/landing/routes.jsView
@@ -1,0 +1,6 @@
1+const React = require('react')
2+const { IndexRoute } = require('react-router')
3+
4+const LandingContainer = require('./container')
5+
6+module.exports = <IndexRoute component={LandingContainer} />
app/landing/style.cssView
@@ -1,0 +1,3 @@
1+.container {
2+ font-weight: bold;
3+}
app/layout/container.jsView
@@ -1,0 +1,17 @@
1+const React = require('react')
2+const { connect } = require('react-redux')
3+
4+class LayoutContainer extends React.Component {
5+ render () {
6+ const { children } = this.props
7+
8+ return <div>
9+ <span>hello world!</span>
10+ { children }
11+ </div>
12+ }
13+}
14+
15+module.exports = connect(
16+ (state) => ({})
17+)(LayoutContainer)
app/reducer.jsView
@@ -1,0 +1,16 @@
1+const bulk = require('bulk-require')
2+const { combineReducers } = require('redux')
3+const { routeReducer } = require('redux-simple-router')
4+const { map } = require('ramda')
5+
6+module.exports = combineReducers({
7+ ...map(
8+ (module) => module.reducer,
9+ bulk(__dirname, '*/reducer.js')
10+ ),
11+ ...map(
12+ (module) => combineReducers(module.reducers),
13+ bulk(__dirname, '*/reducers/*.js')
14+ ),
15+ routing: routeReducer
16+})
app/spec.jsView
@@ -1,0 +1,10 @@
1+const ava = require('ava/api')
2+const glob = require('glob')
3+
4+glob('{spec/*.js,*/spec.js,*/spec/*.js}', { cwd: __dirname }, function (err, files) {
5+ if (err) { throw err }
6+
7+ if (files.length > 0) {
8+ ava(files).run()
9+ }
10+})
app/todos/container.jsView
@@ -1,0 +1,14 @@
1+const React = require('react')
2+const { connect } = require('react-redux')
3+
4+class TodosContainer extends React.Component {
5+ render () {
6+ return <div>
7+ todo list!
8+ </div>
9+ }
10+}
11+
12+module.exports = connect(
13+ (state) => ({})
14+)(TodosContainer)
app/todos/features/new.featureView
@@ -1,0 +1,22 @@
1+Feature: New Todo
2+
3+ Background:
4+ Given I visit TODOMVC
5+ And I make sure that there are no todos
6+
7+ Scenario: Pressing enter creates the todo
8+ When I enter a new todo
9+ Then it should be appended to the todo list
10+
11+ Scenario: Pressing enter clears the input
12+ When I enter a new todo
13+ Then the input should be cleared
14+
15+ Scenario: The input should be trimmed
16+ When I enter a new todo with extra spaces
17+ Then the input should be trimmed
18+
19+ Scenario: An empty todo should not be added
20+ When I enter a new todo
21+ And I enter a new todo that is empty
22+ Then it should not add it to the list
app/todos/reducer.jsView
@@ -1,0 +1,13 @@
1+module.exports = todos
2+
3+function todos (state = {}, action) {
4+ switch (action.type) {
5+ case 'CREATE_TODO':
6+ return {
7+ ...state,
8+ [action.payload.id]: action.payload
9+ }
10+ default:
11+ return state
12+ }
13+}
app/todos/routes.jsView
@@ -1,0 +1,6 @@
1+const React = require('react')
2+const { Route } = require('react-router')
3+
4+const TodosContainer = require('./container')
5+
6+module.exports = <Route path="todos" component={TodosContainer} />
package.jsonView
@@ -7,10 +7,10 @@
77 "postinstall": "lnfs app node_modules/app",
88 "lint": "snazzy",
99 "format": "snazzy --format",
1010 "test": "npm-run-all -p test:*",
11- "test:spec": "node spec",
12- "test:feature": "node feature",
11+ "test:spec": "node app/spec",
12+ "test:feature": "node app/features",
1313 "dev:client": "BABEL_ENV=hot watchify client -o assets/bundle.js -dv -p browserify-hmr",
1414 "dev:assets": "cpx \"app/assets/**/*\" assets -w",
1515 "dev:server": "node-dev server",
1616 "prod:client": "browserify client -o assets/bundle.js -g envify -g uglifyify",
@@ -46,11 +46,13 @@
4646 "node": "^4.0.0",
4747 "npm": "^3.0.0"
4848 },
4949 "devDependencies": {
50+ "ava": "^0.8.0",
5051 "babel-plugin-react-transform": "^2.0.0",
5152 "browserify-hmr": "^0.3.1",
5253 "cuke-tap": "^1.0.2",
54+ "glob": "^6.0.2",
5355 "jsdom": "^7.1.0",
5456 "node-dev": "^2.7.1",
5557 "react-transform-catch-errors": "^1.0.0",
5658 "react-transform-hmr": "^1.0.1",
@@ -58,9 +60,10 @@
5860 "redux-devtools": "^3.0.0",
5961 "redux-devtools-dock-monitor": "^1.0.1",
6062 "redux-devtools-log-monitor": "^1.0.1",
6163 "redux-logger": "^2.0.4",
62- "tape": "^4.2.2",
64+ "run-parallel": "^1.1.4",
65+ "tape": "^4.4.0",
6366 "watchify": "^3.6.1"
6467 },
6568 "dependencies": {
6669 "babel-core": "^6.2.1",
@@ -69,14 +72,14 @@
6972 "babel-preset-es2015": "^6.1.18",
7073 "babel-preset-react": "^6.1.18",
7174 "babel-runtime": "^6.2.0",
7275 "babelify": "^7.2.0",
73- "browserify": "^12.0.1",
76+ "browserify": "github:ahdinosaur/node-browserify",
7477 "bulk-require": "^0.2.1",
7578 "bulkify": "^1.1.1",
7679 "cpx": "^1.2.1",
7780 "css-modules-require-hook": "^2.1.0",
78- "cssify": "^1.0.2",
81+ "cssify": "github:ahdinosaur/cssify",
7982 "envify": "^3.4.0",
8083 "evalify": "^1.0.1",
8184 "feathers": "^1.2.0",
8285 "history": "^1.13.1",
feature/index.jsView
@@ -1,7 +1,0 @@
1-const cuke = require('cuke-tap')
2-const path = require('path')
3-
4-const features = [ path.join(__dirname, '/feature.feature') ]
5-const steps = [ require('./steps') ]
6-
7-cuke(features, steps)
feature/steps.jsView
@@ -1,11 +1,0 @@
1-const test = require('cuke-tap')
2-const jsdom = require('jsdom')
3-
4-test.given(/^I am on the landing page$/, (t, world, params) => {
5- t.plan(1)
6- jsdom.env('http://localhost:9966', (err, window) => {
7- t.error(err)
8- world.window = window
9- t.pass('done')
10- })
11-})
spec/index.jsView

Built with git-ssb-web