Skip to content

Commit

Permalink
chore: improve repo structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Guria committed Jan 11, 2017
1 parent e529129 commit 3fea2d2
Show file tree
Hide file tree
Showing 662 changed files with 233 additions and 106 deletions.
19 changes: 3 additions & 16 deletions .travis.yml
@@ -1,32 +1,19 @@
sudo: false
language: node_js
node_js: '6'
cache:
directories:
- node_modules
- packages/cerebral/node_modules
- packages/cerebral-forms/node_modules
- packages/cerebral-provider-http/node_modules
- packages/cerebral-router/node_modules
- packages/function-tree/node_modules
notifications:
email: false
node_js:
- '6'
- '4'
before_install:
- npm i -g npm@^3.0.0
- lerna bootstrap --scope function-tree
- lerna bootstrap --scope cerebral
- lerna bootstrap --scope cerebral-forms
- lerna bootstrap --scope cerebral-provider-http
- lerna bootstrap --scope cerebral-router
before_script:
- npm prune
- lerna bootstrap --scope '@(function-tree|cerebral|cerebral-forms|cerebral-provider-http|cerebral-router)'
after_success:
- npm run coverage
- npm run coverage:upload
- |
echo $TRAVIS_BRANCH; echo $TRAVIS_PULL_REQUEST; echo $TRAVIS_NODE_VERSION; if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' && $TRAVIS_NODE_VERSION == '6' ]]; then
echo $TRAVIS_BRANCH; echo $TRAVIS_PULL_REQUEST; if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then
echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > ~/.npmrc ;
lerna bootstrap
lerna publish -c --npm-tag next --yes ;
Expand Down
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -34,7 +34,8 @@ The entire Cerebral codebase has been rewritten to encourage contributions. The

1. Clone the monorepo: `git clone https://github.com/cerebral/cerebral.git`
2. In root: `npm install`
3. Run `npm run setup` which will build code and bootstrap it together
3. Run `npm run setup:packages` which will build packages source code and link it together
4. Run `npm run setup` if you need to set up whole repo (docs, demos, tutorials, debuggers)

The packages are located under `packages` folder and there is **no need** to run `npm install` for each package.

Expand All @@ -59,7 +60,7 @@ $ unlink node_modules/cerebral
```

### Running demos
Go to the respective `packages/some-demo-folder` and run `npm start`
Go to the respective `demos/some-demo-folder` and run `npm start`

### Testing
You can run all tests in all packages from root:
Expand Down
File renamed without changes.
File renamed without changes.
@@ -1,5 +1,5 @@
{
"name": "cerebral-debugger",
"name": "@cerebral/debugger",
"version": "1.0.0",
"private": true,
"main": "electron/main.js",
Expand All @@ -24,21 +24,16 @@
"electron-default-menu": "^1.0.0",
"electron-json-storage": "^2.1.0",
"prismjs": "^1.5.1",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"ws": "^1.1.1"
},
"devDependencies": {
"babel-loader": "^6.2.10",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"concurrently": "^3.1.0",
"css-loader": "^0.26.0",
"electron": "^1.4.1",
"electron-packager": "^8.3.0",
"express": "^4.14.0",
"react-scripts": "0.7.0",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.13.3",
Expand Down
File renamed without changes.
File renamed without changes.
@@ -1,5 +1,5 @@
{
"name": "cerebral-debugger",
"name": "@cerebral/function-tree-debugger",
"version": "1.0.0",
"private": true,
"main": "electron/main.js",
Expand All @@ -24,21 +24,16 @@
"electron-default-menu": "^1.0.0",
"electron-json-storage": "^2.1.0",
"prismjs": "^1.5.1",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"ws": "^1.1.1"
},
"devDependencies": {
"babel-loader": "^6.2.8",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"concurrently": "^3.1.0",
"css-loader": "^0.26.0",
"electron": "^1.4.1",
"electron-packager": "^8.3.0",
"express": "^4.14.0",
"react-scripts": "0.7.0",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.13.3",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions packages/demo/package.json → demos/demo/package.json
@@ -1,5 +1,5 @@
{
"name": "cerebral-demo",
"name": "@cerebral/demo",
"version": "0.0.0",
"private": true,
"homepage": "http://cerebral.github.io/demo",
Expand All @@ -11,8 +11,8 @@
"Julio Saito <saitodisse@gmail.com>"
],
"devDependencies": {
"node-sass": "^3.11.2",
"react-scripts": "0.7.0"
"@cerebral/monorepo": "0.0.1",
"node-sass": "^3.11.2"
},
"dependencies": {
"bulma": "^0.2.3",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions demos/demo/src/common/Collection/operators/makeRef.js
@@ -0,0 +1,5 @@
import {v4} from 'uuid'

export default function (context) {
return {value: v4()}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions demos/demo/src/factories/firebaseGetValue.js
@@ -0,0 +1,13 @@
export default function firebaseGetValue ({firebasePath, uidPath}) {
return function ({firebase, state, path}) {
let uid = ''
if (uidPath) {
uid = `.${state.get(uidPath)}`
}
return firebase.value(`${firebasePath}${uid}`)
.then((result) => {
return result.value ? path.success(result) : path.success({value: {}})
})
.catch(path.error)
}
}
7 changes: 7 additions & 0 deletions demos/demo/src/factories/firebaseItemChanged.js
@@ -0,0 +1,7 @@
export default function firebaseItemChanged (statePath) {
return function mergeItem ({ state, input }) {
const { key, value } = input
state.set(`${statePath}.${key}`, value)
return { key }
}
}
6 changes: 6 additions & 0 deletions demos/demo/src/factories/firebaseItemRemoved.js
@@ -0,0 +1,6 @@
export default function firebaseItemRemoved (statePath) {
return function removeItem ({ input, state }) {
state.unset(`${statePath}.${input.key || input.id}`)
}
}

16 changes: 16 additions & 0 deletions demos/demo/src/factories/firebaseListen.js
@@ -0,0 +1,16 @@
export default function firebaseListen ({moduleName, firebasePath, uidPath, childAddedOptions}) {
return function ({firebase, state}) {
const signalName = firebasePath.replace('.', '_')
let uid = ''
if (uidPath) {
// firebase collection is under an user_id
uid = `.${state.get(uidPath)}`
}

firebase.onChildAdded(`${firebasePath}${uid}`, `${moduleName}.${signalName}_ChildAdded`,
childAddedOptions
)
firebase.onChildRemoved(`${firebasePath}${uid}`, `${moduleName}.${signalName}_ChildRemoved`, {})
firebase.onChildChanged(`${firebasePath}${uid}`, `${moduleName}.${signalName}_ChildChanged`, {})
}
}
7 changes: 7 additions & 0 deletions demos/demo/src/factories/firebaseUpdateItem.js
@@ -0,0 +1,7 @@
export default function firebaseUpdateItem ({firebase, moduleName, uid, id, payload}) {
const payloadWithDates = Object.assign({}, {
updated_at: {'.sv': 'timestamp'},
created_at: payload.created_at || {'.sv': 'timestamp'}
}, payload)
return firebase.update(`${moduleName}.${uid}.${id}`, payloadWithDates)
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions demos/demo/src/modules/clients/actions/draftChanged.js
@@ -0,0 +1,18 @@
function draftChanged ({state, path}) {
const draft = state.get('clients.$draft')
if (!draft) {
return path.false()
}

const client = state.get(`clients.all.${draft.ref}`)

Object.keys(Object.assign({}, draft, client)).forEach(key => {
if (draft[key] !== client[key]) {
return path.false()
}
})

return path.true()
}

export default draftChanged
8 changes: 8 additions & 0 deletions demos/demo/src/modules/clients/actions/removeClient.js
@@ -0,0 +1,8 @@
function removeClient ({input, firebase, state, path}) {
const uid = state.get('user.$currentUser.uid')
return firebase.remove(`clients.${uid}.${input.ref}`)
.then(path.success)
.catch(path.error)
}

export default removeClient
17 changes: 17 additions & 0 deletions demos/demo/src/modules/clients/actions/saveDraft.js
@@ -0,0 +1,17 @@
import firebaseUpdateItem from '../../../factories/firebaseUpdateItem'

function saveDraft ({state, path, firebase}) {
const draft = state.get('clients.$draft')
const uid = state.get('user.$currentUser.uid')
return firebaseUpdateItem({
firebase,
moduleName: 'clients',
uid,
id: draft.ref,
payload: draft
})
.then(path.success)
.catch(path.error)
}

export default saveDraft
File renamed without changes.
17 changes: 17 additions & 0 deletions demos/demo/src/modules/projects/actions/saveDraft.js
@@ -0,0 +1,17 @@
import firebaseUpdateItem from '../../../factories/firebaseUpdateItem'

function saveDraft ({firebase, state, path}) {
const draft = state.get('projects.$draft')
const uid = state.get('user.$currentUser.uid')
return firebaseUpdateItem({
firebase,
moduleName: 'projects',
uid,
id: draft.ref,
payload: draft
})
.then(path.success)
.catch(path.error)
}

export default saveDraft
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions demos/demo/src/modules/tasks/operators/elapsedSeconds.js
@@ -0,0 +1,16 @@
import {elapsedSeconds as computeElapsedSeconds} from '../../../helpers/dateTime'

export default function (startedAtTag, endedAtTag) {
function elapsedSeconds (context) {
const startedAt = typeof startedAtTag === 'function'
? startedAtTag(context).value : startedAtTag
const endedAt = typeof endedAtTag === 'function'
? endedAtTag(context).value : endedAtTag

return {value: computeElapsedSeconds(startedAt, endedAt)}
}

elapsedSeconds.displayName = 'elapsedSeconds'

return elapsedSeconds
}
5 changes: 5 additions & 0 deletions demos/demo/src/modules/tasks/operators/now.js
@@ -0,0 +1,5 @@
import {now} from '../../../helpers/dateTime'

export default function (context) {
return {value: now()}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,9 +1,9 @@
{
"name": "forms-demo",
"name": "@cerebral/forms-demo",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-scripts": "0.7.0"
"@cerebral/monorepo": "0.0.1"
},
"dependencies": {
"aphrodite": "^1.1.0",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3fea2d2

Please sign in to comment.