Skip to content

Commit e085aab

Browse files
authored
Merge pull request #7 from KevinAst/initial
publish: v0.1.0 Initial Release
2 parents c5d42f8 + 9fa136c commit e085aab

File tree

5 files changed

+25
-60
lines changed

5 files changed

+25
-60
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ language: node_js
22
node_js:
33
- "6"
44
- "7"
5+
- "8"
56
- node # current node version (may be duplicate, but that's OK)
67
script:
78
- npm run prepublish # lint, clean, build (bundles), test (bundles)

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,11 @@ run-time stack.
1919

2020

2121
<!--- Badges for CI Builds --->
22+
[![Build Status](https://travis-ci.org/KevinAst/feature-redux-logic.svg?branch=master)](https://travis-ci.org/KevinAst/feature-redux-logic)
2223
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/81530601c0f2449481882ac285add698)](https://www.codacy.com/app/KevinAst/feature-redux-logic?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=KevinAst/feature-redux-logic&amp;utm_campaign=Badge_Grade)
24+
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/81530601c0f2449481882ac285add698)](https://www.codacy.com/app/KevinAst/feature-redux-logic?utm_source=github.com&utm_medium=referral&utm_content=KevinAst/feature-redux-logic&utm_campaign=Badge_Coverage)
2325
[![Known Vulnerabilities](https://snyk.io/test/github/kevinast/feature-redux-logic/badge.svg?targetFile=package.json)](https://snyk.io/test/github/kevinast/feature-redux-logic?targetFile=package.json)
2426
[![NPM Version Badge](https://img.shields.io/npm/v/feature-redux-logic.svg)](https://www.npmjs.com/package/feature-redux-logic)
25-
<!--- TODO Badges
26-
- CI Build: ?? WHEN CI Build In place
27-
- GRADE: DONE (see above)
28-
- CODE COV: ?? WHEN Code coverage in place
29-
- Vulnerab: DONE (see above)
30-
- NPM: DONE (see above)
31-
--->
3227

3328

3429
**Overview:**
@@ -295,7 +290,7 @@ your using redux-logic?_
295290
You can change this behavior through the following configuration:
296291

297292
```js
298-
logicAspect.allowNoLogic$ = true;
293+
logicAspect.config.allowNoLogic$ = true;
299294
```
300295

301296
With this option enabled, when no logic modules are found,

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"eslint": "^3.19.0",
9494
"eslint-loader": "^1.7.1",
9595
"eslint-plugin-react": "^7.6.1",
96+
"feature-u": ">=0.1.0",
9697
"jest": "^22.1.4",
9798
"npm-run-all": "^4.0.2",
9899
"redux-logic": ">=0.7.0",
@@ -101,6 +102,7 @@
101102
},
102103
"dependencies": {},
103104
"peerDependencies": {
105+
"feature-u": ">=0.1.0",
104106
"redux-logic": ">=0.7.0"
105107
}
106108
}

src/logicAspect.js

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {createLogicMiddleware} from 'redux-logic'; // peerDependency
22
import {createAspect,
3-
extendAspectProperty,
43
launchApp} from 'feature-u'; // peerDependency:
54

65
// our logger (integrated/activated via feature-u)
@@ -9,35 +8,16 @@ const logf = launchApp.diag.logf.newLogger('- ***feature-redux-logic*** logicAsp
98
// NOTE: See README for complete description
109
export default createAspect({
1110
name: 'logic',
12-
genesis,
1311
validateFeatureContent,
1412
assembleFeatureContent,
15-
createLogicMiddleware$,
1613
getReduxMiddleware,
14+
config: {
15+
allowNoLogic$: false, // PUBLIC: client override to: true || [{logicModules}]
16+
createLogicMiddleware$, // HIDDEN: createLogicMiddleware$(app, appLogic): reduxMiddleware
17+
},
1718
});
1819

1920

20-
/**
21-
* Register feature-redux-logic proprietary Aspect APIs (required to
22-
* pass feature-u validation).
23-
* This must occur early in the life-cycle (i.e. this method) to
24-
* guarantee the new API is available during feature-u validation.
25-
*
26-
* @return {string} NONE FOR US ... an error message when self is in an invalid state
27-
* (falsy when valid).
28-
*
29-
* @private
30-
*/
31-
function genesis() {
32-
logf('genesis() registering internal Aspect properties');
33-
34-
extendAspectProperty('allowNoLogic$'); // Aspect.allowNoLogic$: true || [{logicModules}]
35-
// ... AI: technically this is for reducerAspect only (if the API ever supports this)
36-
extendAspectProperty('createLogicMiddleware$'); // Aspect.createLogicMiddleware$(app, appLogic): reduxMiddleware
37-
// ... AI: technically this is for reducerAspect only (if the API ever supports this)
38-
}
39-
40-
4121
/**
4222
* Validate self's aspect content on supplied feature.
4323
*
@@ -97,23 +77,23 @@ function assembleFeatureContent(app, activeFeatures) {
9777
else {
9878

9979
// by default, this is an error condition (when NOT overridden by client)
100-
if (!this.allowNoLogic$) {
80+
if (!this.config.allowNoLogic$) {
10181
throw new Error('***ERROR*** feature-redux-logic found NO logic modules within your features ' +
10282
`... did you forget to register Feature.${this.name} aspects in your features? ` +
10383
'(please refer to the feature-redux-logic docs to see how to override this behavior).');
10484
}
10585

10686
// when client override is an array, interpret it as logic modules
107-
if (Array.isArray(this.allowNoLogic$)) {
108-
logf.force('WARNING: NO logic modules were found in your Features (i.e. Feature.${this.name}), ' +
109-
'but client override (logicAspect.allowNoLogic$=[{logicModules}];) ' +
87+
if (Array.isArray(this.config.allowNoLogic$)) {
88+
logf.force(`WARNING: NO logic modules were found in your Features (i.e. Feature.${this.name}), ` +
89+
'but client override (logicAspect.config.allowNoLogic$=[{logicModules}];) ' +
11090
'directed a continuation WITH specified logic modules.');
111-
appLogic = this.allowNoLogic$;
91+
appLogic = this.config.allowNoLogic$;
11292
}
11393
// otherwise, we simply disable redux-logic and continue on
11494
else {
115-
logf.force('WARNING: NO logic modules were found in your Features, ' +
116-
'but client override (logicAspect.allowNoLogic$=true;) ' +
95+
logf.force(`WARNING: NO logic modules were found in your Features (i.e. Feature.${this.name}), ` +
96+
'but client override (logicAspect.config.allowNoLogic$=truthy;) ' +
11797
'directed a continuation WITHOUT redux-logic.');
11898
}
11999
}
@@ -122,8 +102,8 @@ function assembleFeatureContent(app, activeFeatures) {
122102
// ... conditionally when we have logic modules
123103
// ... retained in self for promotion to feature-redux plugin
124104
if (appLogic.length > 0) {
125-
// ... accomplished in internal micro method (a defensive measure to allow easier overriding by client)
126-
this.logicMiddleware = this.createLogicMiddleware$(app, appLogic);
105+
// ... accomplished in internal config micro function (a defensive measure to allow easier overriding by client)
106+
this.logicMiddleware = this.config.createLogicMiddleware$(app, appLogic);
127107
}
128108
// if we have no logic ... we have no middleware
129109
else {
@@ -133,8 +113,8 @@ function assembleFeatureContent(app, activeFeatures) {
133113

134114

135115
/**
136-
* An internal micro method that creates/returns the redux middleware
137-
* for redux-logic.
116+
* An internal config micro function that creates/returns the
117+
* redux middleware for redux-logic.
138118
*
139119
* This logic is broken out in this internal method as a defensive
140120
* measure to make it easier for a client to override (if needed for

src/spec/logicAspect.spec.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,6 @@ describe('logicAspect() tests', () => {
1717
});
1818

1919

20-
describe('genesis()', () => {
21-
22-
logicAspect.genesis();
23-
24-
const noOpTest = "can't access isAspectProperty() ... just running code :-(";
25-
test('verify extendAspectProperty()', () => {
26-
expect(noOpTest)
27-
.toBe(noOpTest);
28-
});
29-
30-
});
31-
32-
3320
describe('validateFeatureContent()', () => {
3421

3522
test('must be an array', () => {
@@ -66,10 +53,10 @@ describe('logicAspect() tests', () => {
6653

6754
describe('no logic modules (OVERRIDE true)', () => {
6855
beforeEach(() => {
69-
logicAspect.allowNoLogic$ = true;
56+
logicAspect.config.allowNoLogic$ = true;
7057
});
7158
afterEach(() => {
72-
logicAspect.allowNoLogic$ = false;
59+
logicAspect.config.allowNoLogic$ = false;
7360
});
7461
test('expecting getReduxMiddleware() to be null', () => {
7562
logicAspect.assembleFeatureContent('simulated app', []);
@@ -80,10 +67,10 @@ describe('logicAspect() tests', () => {
8067

8168
describe('no logic modules (OVERRIDE array)', () => {
8269
beforeEach(() => {
83-
logicAspect.allowNoLogic$ = ['simulated', 'logic'];
70+
logicAspect.config.allowNoLogic$ = ['simulated', 'logic'];
8471
});
8572
afterEach(() => {
86-
logicAspect.allowNoLogic$ = false;
73+
logicAspect.config.allowNoLogic$ = false;
8774
});
8875
test('expecting getReduxMiddleware() to be non-null', () => {
8976
logicAspect.assembleFeatureContent('simulated app', []);

0 commit comments

Comments
 (0)