Skip to content

Commit

Permalink
feat(core): create @skele/core package (#112)
Browse files Browse the repository at this point in the history
The @skele/core package contains the following features (usable from all supported environments):
* data, registry, zip
* logging internals

It's mostly extracting it from @skele/classic with using it as a dependency in there, while preserving the same API.

More details about the new package restructuring: #99
  • Loading branch information
andon committed Aug 30, 2018
1 parent b010641 commit 9979ddf
Show file tree
Hide file tree
Showing 65 changed files with 277 additions and 122 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
dist/
coverage/
packages/classic/src/vendor
packages/core/src/vendor
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The repository is a monorepo that is composed of several NPM packages.
| [Classic](/packages/classic) | The library as a (still) monolithic package. |
| [Config](/packages/config) | Library for setting up layered app configuration. |
| [Components](/packages/components) | Collection of helpful custom components. |
| [Core](/packages/core) | Essential building blocks of the framework. |

## Documentation

Expand Down
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@
"coverage-report": "cat ./coverage/lcov.info | coveralls",
"lint": "eslint .",
"es5":
"yarn run es5:classic && yarn run es5:config && yarn run es5:components",
"yarn run es5:classic && yarn run es5:config && yarn run es5:components && yarn run es5:core",
"es5:classic":
"babel -q packages/classic/src --out-dir packages/classic/dist/es5",
"es5:config":
"babel -q packages/config/src --out-dir packages/config/dist/es5",
"es5:components":
"babel -q packages/components/src --out-dir packages/components/dist/es5",
"es5:core": "babel -q packages/core/src --out-dir packages/core/dist/es5",
"clean":
"yarn run clean:classic && yarn run clean:config && yarn run clean:components",
"yarn run clean:classic && yarn run clean:config && yarn run clean:components && yarn run clean:core",
"clean:classic": "del-cli packages/classic/dist",
"clean:config": "del-cli packages/config/dist",
"clean:components": "del-cli packages/components/dist",
"clean:core": "del-cli packages/core/dist",
"build": "yarn run clean && yarn run test && yarn run lint && yarn run es5",
"release:test-token":
"test -n \"$CONVENTIONAL_GITHUB_RELEASER_TOKEN\" || (echo 'Setup your github autho token first: https://github.com/conventional-changelog/conventional-github-releaser#cli' && exit 1)",
Expand Down Expand Up @@ -90,15 +92,17 @@
"roots": [
"<rootDir>/packages/classic",
"<rootDir>/packages/config",
"<rootDir>/packages/components"
"<rootDir>/packages/components",
"<rootDir>/packages/core"
],
"testMatch": ["**/__tests__/**/*.js"],
"collectCoverageFrom": [
"**/*.js",
"!**/__tests__/**",
"!**/node_modules/**",
"!**/vendor/**",
"!**/dist/es5/**"
"!**/dist/es5/**",
"!packages/core/src/log/**"
]
},
"workspaces": ["packages/*"]
Expand Down
12 changes: 4 additions & 8 deletions packages/classic/package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
{
"name": "@skele/classic",
"version": "1.0.0-alpha.31",
"description": "Skele is an architectural framework that assists with building data-driven apps with React or React Native.",
"description":
"Skele is an architectural framework that assists with building data-driven apps with React or React Native.",
"react-native": "src/index.js",
"main": "dist/es5/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/netceteragroup/skele.git"
},
"keywords": [
"react",
"react-native",
"redux",
"redux-saga",
"netcetera"
],
"keywords": ["react", "react-native", "redux", "netcetera"],
"author": "netcetera",
"license": "MIT",
"bugs": {
"url": "https://github.com/netceteragroup/skele/issues"
},
"homepage": "https://netcetera.gitbooks.io/skele/",
"dependencies": {
"@skele/core": "^1.0.0-alpha.31",
"immutable": "^3.8.1",
"invariant": "^2.2.2",
"ramda": "^0.25.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/classic/src/__tests__/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { mount } from 'enzyme'

import React from 'react'
import { fromJS } from 'immutable'
import { ui, enrich, enhance, transform, read, data, Engine, http } from '..'
import { ui, enrich, enhance, transform, read, Engine, http } from '..'
import * as propNames from '../propNames'
const { isOfKind } = data.element
import { data } from '@skele/core'
const { isOfKind } = data

describe("Reads using core subsystem's Read element", () => {
const appState = {
Expand Down
4 changes: 2 additions & 2 deletions packages/classic/src/action.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

import * as R from 'ramda'
import { kindOf } from './data'
import { data } from '@skele/core'

export const actionMetaProperty = '@@skele/actionMeta'

Expand All @@ -16,7 +16,7 @@ export const actionMeta = R.prop(actionMetaProperty)
*/
export const atCursor = R.curry((cursor, action) => {
const keyPath = cursor._keyPath
const kind = kindOf(cursor)
const kind = data.kindOf(cursor)

return { ...action, [actionMetaProperty]: { keyPath, kind } }
})
7 changes: 4 additions & 3 deletions packages/classic/src/effect/impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import * as R from 'ramda'

import * as actions from '../action'
import { types as actionTypes } from './actions'
import * as data from '../data'
import { ActionRegistry } from '../registry'
import { data, log } from '@skele/core'

import { findParentEntry } from '../impl/cursor'
import { error } from '../impl/log'

import { ActionRegistry } from '../registry'

const updateStateAction = '@@skele/_effects.updateState'
const { error } = log

export const middleware = R.curry((config, store, next, action) => {
const { kernel, effectsRegistry } = config
Expand Down
7 changes: 5 additions & 2 deletions packages/classic/src/effect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import * as R from 'ramda'
import invariant from 'invariant'

import { chainRegistries, ActionRegistry } from '../registry'
import * as data from '../data'
import { data, registry } from '@skele/core'
import { ActionRegistry } from '../registry'

import * as Subsystem from '../subsystem'

import * as impl from './impl'

const { chainRegistries } = registry

const effectsRegistryAttribute = '@@skele/_effectsRegistry'
const sideEffectsRegistryAttribute = '@@skele/_sideEffectsRegistry'

Expand Down
2 changes: 1 addition & 1 deletion packages/classic/src/enhance/__tests__/enhance.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fromJS } from 'immutable'
import * as SubSystem from '../../subsystem'
import * as Kernel from '../../kernel'
import * as propNames from '../../propNames'
import * as data from '../../data'
import { data } from '@skele/core'

import enhanceSubsystem from '..'

Expand Down
2 changes: 1 addition & 1 deletion packages/classic/src/enhance/impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import * as R from 'ramda'
import I from 'immutable'
import * as zip from '../zip'
import { zip } from '@skele/core'

export async function runEnhancers(el, context, enhancers) {
return Promise.all(
Expand Down
6 changes: 4 additions & 2 deletions packages/classic/src/enhance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import * as R from 'ramda'
import { List } from 'immutable'
import invariant from 'invariant'

import { isElementRef } from '../data'
import { data, registry } from '@skele/core'

import * as SubSystem from '../subsystem'
import { MultivalueRegistry, chainMultivalueRegistries } from '../registry'

import * as impl from './impl'

const readDependentRegistryAttribute = '@@skele/_readDependentEnhanceRegistry'
const readIndependentListAttribute = '@@skele/_readIndependentEnhanceList'

const { MultivalueRegistry, chainMultivalueRegistries } = registry
const { isElementRef } = data

SubSystem.extend(() => {
const readDependentRegistry = new MultivalueRegistry()
const readIndependentList = List().asMutable()
Expand Down
2 changes: 1 addition & 1 deletion packages/classic/src/enrich/__tests__/enrich.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fromJS, List } from 'immutable'
import * as Subsystem from '../../subsystem'
import * as Kernel from '../../kernel'
import * as propNames from '../../propNames'
import * as data from '../../data'
import { data } from '@skele/core'

import enrichSubsystem from '..'

Expand Down
3 changes: 1 addition & 2 deletions packages/classic/src/enrich/impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import * as R from 'ramda'
import { memoize } from '../impl/util'
import * as data from '../data'
import * as zip from '../zip'
import { data, zip } from '@skele/core'

export function enricher(config) {
const { registry, elementZipper } = config
Expand Down
7 changes: 4 additions & 3 deletions packages/classic/src/enrich/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
import * as R from 'ramda'
import invariant from 'invariant'

import { isElementRef } from '../data'
import { data, registry } from '@skele/core'

import * as SubSystem from '../subsystem'
import { MultivalueRegistry, chainMultivalueRegistries } from '../registry'

import * as impl from './impl'

const registryAttribute = '@@skele/_enrichRegistry'

const { MultivalueRegistry, chainMultivalueRegistries } = registry
const { isElementRef } = data

SubSystem.extend(() => {
const registry = new MultivalueRegistry()

Expand Down
2 changes: 1 addition & 1 deletion packages/classic/src/impl/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as R from 'ramda'
import { List, Seq } from 'immutable'
import Cursor from 'immutable/contrib/cursor'

import * as data from '../data'
import { data } from '@skele/core'

export const findParentEntry = R.curry((registry, keyfn, cursor) =>
data.flow(
Expand Down
3 changes: 1 addition & 2 deletions packages/classic/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import * as Subsystem from './subsystem'
import * as Kernel from './kernel'

import core, { defaultSubsystems } from './core'
import * as data from './data'
import * as zip from './zip'
import { data, zip } from '@skele/core'
import * as action from './action'
import * as registry from './registry'
import * as propNames from './propNames'
Expand Down
3 changes: 1 addition & 2 deletions packages/classic/src/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import I from 'immutable'
import Cursor from 'immutable/contrib/cursor'
import * as R from 'ramda'

import * as zip from './zip'
import { data, zip } from '@skele/core'
import * as actions from './action'
import * as data from './data'

import { createStore, applyMiddleware } from 'redux'

Expand Down
7 changes: 5 additions & 2 deletions packages/classic/src/propNames.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
'use strict'

import { propNames } from '@skele/core'

export { actionMetaProperty as actionMeta } from './action'
export { fallback as readFallback } from './read'

export { childrenProperty as children } from './data'
export const metadata = '@@skele/metadata'
const { children, metadata } = propNames
export { children }
export { metadata }
2 changes: 1 addition & 1 deletion packages/classic/src/read/__tests__/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import read from '..'
import * as http from '../http'

import * as action from '../../action'
import * as data from '../../data'
import { data } from '@skele/core'

import * as readActions from '../actions'
import * as propNames from '../../propNames'
Expand Down
7 changes: 5 additions & 2 deletions packages/classic/src/read/impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ import { fromJS } from 'immutable'

import uuid from 'uuid'

import { info, error } from '../impl/log'
import { data, log } from '@skele/core'

import { time, timeSync } from '../impl/util'

import { canonical, flow, kindOf } from '../data'
import * as readActions from './actions'
import * as propNames from '../propNames'
import { isOK, isResponse } from './http'

const { canonical, flow, kindOf } = data
const { info, error } = log

export const fallback = '@@skele/defaultRead'

const updateKind = R.curry((update, element) =>
Expand Down
4 changes: 3 additions & 1 deletion packages/classic/src/read/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import '../enrich'
import '../enhance'
import '../transform'

import { PatternRegistry, chainRegistries } from '../registry'
import { registry } from '@skele/core'

import * as impl from './impl'
import * as http from './http'
Expand All @@ -20,6 +20,8 @@ import * as readActions from './actions'
const registryAttribute = '@@skele/_readRegistry'
const fallback = impl.fallback

const { PatternRegistry, chainRegistries } = registry

/**
* Extension point for defining reads
*/
Expand Down
5 changes: 3 additions & 2 deletions packages/classic/src/registry/ActionRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import { List } from 'immutable'

import { Registry, MultivalueRegistry } from '../registry'
import { data, registry } from '@skele/core'
import * as actions from '../action'
import * as data from '../data'

const { Registry, MultivalueRegistry } = registry

export const keyFor = (kind, action) => List.of(data.canonical(kind), action)

Expand Down
10 changes: 0 additions & 10 deletions packages/classic/src/registry/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
'use strict'

export { default as AbstractRegistry } from './AbstractRegistry'
export { default as Registry } from './Registry'
export { default as MultivalueRegistry } from './MultivalueRegistry'
export { default as PatternRegistry } from './PatternRegistry'
export { ActionRegistry, ActionMultivalueRegistry } from './ActionRegistry'
export {
RegistryChain,
MultivalueRegistryChain,
chainRegistries,
chainMultivalueRegistries,
} from './RegistryChain'
8 changes: 5 additions & 3 deletions packages/classic/src/transform/impl.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
'use strict'

import * as R from 'ramda'
import { kindOf } from '../data/element'

import { data, zip } from '@skele/core'

import { memoize } from '../impl/util'

import { postWalk, root, value } from '../zip'
import { flow } from '../data'
const { postWalk, root, value } = zip
const { flow, kindOf } = data

export function transformer(registry, elementZipper) {
const elementTransformer = memoize(kind =>
Expand Down
6 changes: 4 additions & 2 deletions packages/classic/src/transform/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import * as R from 'ramda'
import invariant from 'invariant'

import { isElementRef } from '../data'
import { data, registry } from '@skele/core'

import * as SubSystem from '../subsystem'
import { MultivalueRegistry, chainMultivalueRegistries } from '../registry'

import * as impl from './impl'

const { isElementRef } = data
const { MultivalueRegistry, chainMultivalueRegistries } = registry

const registryAttribute = '@@skele/_transformRegistry'

SubSystem.extend(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/classic/src/ui/ElementView.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import I from 'immutable'
import React from 'react'
import PropTypes from 'prop-types'

import * as data from '../data'
import { data } from '@skele/core'

export default R.curry((kind, Component, runtime) => {
const { uiFor: globalUIFor, system } = runtime
Expand Down
Loading

0 comments on commit 9979ddf

Please sign in to comment.