Skip to content
This repository was archived by the owner on Oct 29, 2023. It is now read-only.

Commit ed246c6

Browse files
authored
Merge pull request #162 from data-provider/release
Release v2.8.2
2 parents f775cad + b1ec7cf commit ed246c6

17 files changed

+218
-98
lines changed

.github/workflows/build.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: build
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- release
7+
pull_request:
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
node: ["10.23.0", "12.19.0", "14.15.0", "15.2.0"]
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- name: Extract branch name
18+
shell: bash
19+
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})"
20+
id: extract-branch
21+
- name: Use Node.js
22+
uses: actions/setup-node@v1
23+
with:
24+
node-version: ${{ matrix.node }}
25+
- name: Cache node modules
26+
uses: actions/cache@v2
27+
env:
28+
cache-name: cache-node-modules
29+
with:
30+
# npm cache files are stored in `~/.npm` on Linux/macOS
31+
path: ~/.npm
32+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
33+
restore-keys: |
34+
${{ runner.os }}-build-${{ env.cache-name }}-
35+
${{ runner.os }}-build-
36+
${{ runner.os }}-
37+
- name: Install dependencies
38+
run: npm ci
39+
- name: Lint
40+
run: npm run lint
41+
- name: Test unit
42+
run: npm run test:unit
43+
- name: Test E2E
44+
run: npm run test:e2e:ci
45+
id: test-e2e
46+
- name: Upload E2E tests screenshots
47+
if: ${{ always() && steps.test-e2e.outcome == 'failure' }}
48+
uses: actions/upload-artifact@v2
49+
with:
50+
name: e2e-screenshots-${{ matrix.node }}
51+
path: test-e2e/browser/cypress/screenshots
52+
retention-days: 7
53+
- name: Upload test results
54+
uses: actions/upload-artifact@v2
55+
with:
56+
name: coverage-${{ matrix.node }}
57+
path: coverage
58+
retention-days: 1
59+
quality:
60+
runs-on: ubuntu-latest
61+
needs: test
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v2
65+
- name: Download test results
66+
uses: actions/download-artifact@v2
67+
with:
68+
name: coverage-15.2.0
69+
path: coverage
70+
- name: Coveralls
71+
uses: coverallsapp/github-action@master
72+
with:
73+
github-token: ${{ secrets.GITHUB_TOKEN }}
74+
- name: SonarCloud Scan
75+
if: env.SONAR_TOKEN != ''
76+
uses: sonarsource/sonarcloud-github-action@master
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/publish-to-github-registry.yml renamed to .github/workflows/publish-to-github.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: publish-to-github-registry
1+
name: publish-to-github
22
on:
33
release:
44
types: [created]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: publish-to-npm
2+
on:
3+
release:
4+
types: [created]
5+
jobs:
6+
publish:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- uses: actions/setup-node@v1
11+
with:
12+
node-version: '12.x'
13+
registry-url: 'https://registry.npmjs.org/'
14+
- run: npm ci
15+
- run: npm run build
16+
- run: npm publish
17+
env:
18+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.travis.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
### Fixed
1111
### Removed
1212

13+
## [2.8.2] - 2020-12-12
14+
### Added
15+
- chore(ci): Migrate from Travis CI to github actions
16+
- chore(deps): Support all Node.js releases that have not passed their end date
17+
18+
### Changed
19+
- test(mutation): Set branch name in stryker dashboard based on environment variable
20+
- docs(readme): Update docs
21+
22+
### Fixed
23+
- fix(events): Pass force option also to children when cleaning caches
24+
- fix(selector): Force cleaning of cache when a selector dependency is cleaned (#156)
25+
- fix(providers): Allow options in providers.cleanCache method
26+
- test: Fix Sonar smell in tests
27+
1328
## [2.8.1] - 2020-11-27
1429

1530
### Fixed

README.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build status][travisci-image]][travisci-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Quality Gate][quality-gate-image]][quality-gate-url] [![Mutation testing badge][stryker-image]][stryker-url]
1+
[![Build status][build-image]][build-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Quality Gate][quality-gate-image]][quality-gate-url] [![Mutation testing badge][stryker-image]][stryker-url]
22

33
[![NPM dependencies][npm-dependencies-image]][npm-dependencies-url] [![Renovate](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com) [![Last commit][last-commit-image]][last-commit-url] [![Last release][release-image]][release-url]
44

@@ -15,11 +15,11 @@ The main target of the library are front-end applications, but it could be used
1515
It helps you __providing async data__ to your components informing them about __loading and error states__.
1616
It also provides a __cache layer__, so you don´t have to worry about when to read the data, and allows you to __combine the results of different data providers__ using a syntax very similar to the known [Reselect][reselect], recalculating them only when one of the dependencies cache is cleaned.
1717

18-
As its states are managed with [Redux][redux], you can take advantage of his large ecosystem of addons, which will improve the developer experience. _(You don't need to use Redux directly in your application if you don't want, the library includes its own internal store for that purpose, which [can be migrated to your own store][api-store-manager])._
18+
As its states are managed with [Redux][redux], you can take advantage of his large ecosystem of addons, which will improve the developer experience. _(You don't need to use Redux directly in your application if you don't want, the library includes its own internal store for that purpose, which [can be migrated to your own store easily][api-store-manager] for debugging purposes, for example)._
1919

20-
You can use Data Provider with [React][react], or with any other view library. Separated addons are available for that purpose, as [@data-provider/react][data-provider-react].
20+
You can use Data Provider with [React][react], or with any other view library. [Separated addons][addons] are available for that purpose, as [@data-provider/react][data-provider-react].
2121

22-
Data Provider is __agnostic about data origins__, so it can be used to read data from a REST API, from localStorage, or from any other origin. Choose one of the available plugins depending of the type of the origin you want to read from, as [@data-provider/axios][data-provider-axios], or [@data-provider/browser-storage][data-provider-browser-storage].
22+
Data Provider is __agnostic about data origins__, so it can be used to read data from a REST API, from localStorage, or from any other origin. Choose one of the [available addons][addons] depending of the type of the origin you want to read from, as [@data-provider/axios][data-provider-axios], or [@data-provider/browser-storage][data-provider-browser-storage].
2323

2424
It has a __light weight__, 4.2KB gzipped in UMD format _(you have to add the Redux weight to this)_, and addons usually are even lighter.
2525

@@ -32,16 +32,17 @@ We have a website available to help you to learn to use Data Provider. There are
3232
* [Motivation][motivation]
3333
* [Installation][installation]
3434
* [Basic tutorial][basic-tutorial]
35+
* [Addons][addons]
3536
* [Recipes][recipes]
3637
* [API reference][api-reference]
3738

3839
## Main features
3940

4041
### Agnostic about data origins
4142

42-
The Provider class provides the cache, state handler, etc., but not the "read" method. The "read" behavior is implemented by __different Data Provider Origins addons__.
43+
The Provider class provides the cache, state handler, etc., but not the "read" method. The "read" behavior is implemented by __different [Data Provider Origins addons][addons]__.
4344

44-
There are different origins available, such as __[Axios][data-provider-axios], [LocalStorage][data-provider-browser-storage], [Memory][data-provider-memory], etc.__ and building your own is so easy as extending the Provider class with a custom "readMethod".
45+
There are different origins addons available, such as __[Axios][data-provider-axios], [LocalStorage][data-provider-browser-storage], [Memory][data-provider-memory], etc.__ and building your own is so easy as extending the Provider class with a custom "readMethod".
4546

4647
Sharing the same interface for all origins, and being able to build Selectors combining all of them implies that your logic will be __completely isolated about WHERE the data is being retrieved.__
4748

@@ -119,7 +120,7 @@ Providers and selectors instances can be queried, which returns a new child inst
119120

120121
Each different child has a different cache, different state, etc.
121122

122-
Different origins can use the "query" value for different purposes (API origins will normally use it for adding different params or query strings to the provider url)
123+
Different origins can use the "query" value for different purposes (API origins will normally use it for adding different params or query strings to the provider url, for example)
123124

124125
When the parent provider cache is clean, also the children is. _(For example, cleaning the cache of an API origin requesting to "/api/books", will also clean the cache for "/api/books?author=2")_
125126

@@ -147,26 +148,30 @@ export default Book;
147148

148149
Data Provider is not concerned about the views, but UI binding addons are available.
149150

150-
For example, the [@data-provider/react][data-provider-react] package __gives you HOCs to connect providers to your components__, creating a wrapper component handling all the logic for you.
151+
For example, the [@data-provider/react][data-provider-react] package __gives you hooks to easily retrieve and provide data and other data-provider states to your components__,
151152

152-
It also provides __hooks like "useData", "useLoading", etc.__
153+
It also provides __HOCs like "withData", "withLoading", etc., creating a wrapper component handling all the logic for you.__
153154

154-
__Optimized__, it takes care of reading the data and re-renders the component only when your desired props have changed.
155+
__Optimized__, it takes care of reading the data and re-renders the component only when the provider desired props have changed. It also takes care of reading the data again every time the cache of the provider is invalidated.
155156

156157
```jsx
157-
import { withDataProvider } from "@data-provider/react";
158+
import { useData, useLoading, useError } from "@data-provider/react";
158159

159160
import { booksProvider } from "data/books";
160161
import ErrorComponent from "components/error";
161162

162-
const Books = ({ data, loading, error }) => {
163+
const Books = () => {
164+
const error = useError(booksProvider);
165+
const data = useData(booksProvider);
166+
const loading = useLoading(booksProvider);
167+
163168
if (error) {
164169
return <ErrorComponent error={error}/>
165170
}
166171
return <BooksList data={data} loading={loading} />;
167172
};
168173

169-
export default withDataProvider(booksProvider)(Books);
174+
export default Books;
170175
```
171176

172177
## Contributing
@@ -190,15 +195,16 @@ Please read the [contributing guidelines](.github/CONTRIBUTING.md) and [code of
190195
[motivation]: https://www.data-provider.org/docs/motivation
191196
[installation]: https://www.data-provider.org/docs/installation
192197
[basic-tutorial]: https://www.data-provider.org/docs/basics-intro
198+
[addons]: https://www.data-provider.org/docs/addons-intro
193199
[recipes]: https://www.data-provider.org/docs/recipes-index
194200
[api-reference]: https://www.data-provider.org/docs/api-reference
195201
[api-selector]: https://www.data-provider.org/docs/api-selector
196202
[api-store-manager]: https://www.data-provider.org/docs/api-store-manager
197203

198204
[coveralls-image]: https://coveralls.io/repos/github/data-provider/core/badge.svg
199205
[coveralls-url]: https://coveralls.io/github/data-provider/core
200-
[travisci-image]: https://travis-ci.com/data-provider/core.svg?branch=master
201-
[travisci-url]: https://travis-ci.com/data-provider/core
206+
[build-image]: https://github.com/data-provider/core/workflows/build/badge.svg?branch=master
207+
[build-url]: https://github.com/data-provider/core/actions?query=workflow%3Abuild+branch%3Amaster
202208
[last-commit-image]: https://img.shields.io/github/last-commit/data-provider/core.svg
203209
[last-commit-url]: https://github.com/data-provider/core/commits
204210
[license-image]: https://img.shields.io/npm/l/@data-provider/core.svg

package-lock.json

Lines changed: 1 addition & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@data-provider/core",
3-
"version": "2.8.1",
3+
"version": "2.8.2",
44
"description": "Async Data Provider agnostic about data origins",
55
"keywords": [
66
"data",
@@ -10,7 +10,9 @@
1010
"cache",
1111
"reactive",
1212
"state",
13-
"agnostic"
13+
"modular",
14+
"front-end",
15+
"nodejs"
1416
],
1517
"author": "Javier Brea",
1618
"license": "Apache-2.0",
@@ -31,19 +33,17 @@
3133
"scripts": {
3234
"build": "rollup --config",
3335
"test": "jest",
34-
"test:coverage": "npm run test",
36+
"test:unit": "npm run test",
3537
"test:e2e:browser:install": "cd test-e2e/browser && npm i && cd vanilla-app && npm i && cd ../react-app && npm i",
3638
"test:e2e:browser": "cd test-e2e/browser && npm run test:vanilla-app && npm run test:react-app",
3739
"test:e2e:node:install": "cd test-e2e/nodejs/esm && npm i",
3840
"test:e2e:node": "cd test-e2e/nodejs/cjs && npm run test && cd ../esm && npm run test",
3941
"test:e2e": "npm run test:e2e:browser && npm run test:e2e:node",
40-
"test:e2e:ci": "npm run test:e2e:browser:install && npm run test:e2e:node:install && npm run test:e2e",
41-
"test:ci": "npm run build && npm run test:coverage && npm run test:e2e:ci",
42+
"test:e2e:ci": "npm run build && npm run test:e2e:browser:install && npm run test:e2e:node:install && npm run test:e2e",
43+
"test:ci": "npm run test:unit && npm run test:e2e:ci",
4244
"test:mutation": "stryker run",
43-
"test:mutation:dev": "stryker run stryker.conf.local.js",
4445
"lint": "eslint src test test-e2e/browser/vanilla-app/public/main.js test-e2e/browser/react-app/src test-e2e/browser/cypress test-e2e/nodejs/cjs test-e2e/nodejs/esm/src *.js",
45-
"lint-staged": "lint-staged",
46-
"coveralls": "cat ./coverage/lcov.info | coveralls"
46+
"lint-staged": "lint-staged"
4747
},
4848
"peerDependencies": {
4949
"redux": "4.x"
@@ -64,7 +64,6 @@
6464
"babel-core": "7.0.0-bridge.0",
6565
"babel-eslint": "10.1.0",
6666
"babel-polyfill": "6.26.0",
67-
"coveralls": "3.0.9",
6867
"eslint": "7.12.1",
6968
"eslint-config-prettier": "6.15.0",
7069
"eslint-plugin-prettier": "3.1.4",
@@ -95,6 +94,6 @@
9594
}
9695
},
9796
"engines": {
98-
"node": "12.x || 14.x || 15.x"
97+
"node": "10.x || 12.x || 14.x || 15.x"
9998
}
10099
}

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
sonar.organization=data-provider
22
sonar.projectKey=data-provider-core
3-
sonar.projectVersion=2.8.1
3+
sonar.projectVersion=2.8.2
44

55
sonar.sources=src,test
66
sonar.exclusions=node_modules/**

0 commit comments

Comments
 (0)