Skip to content

Commit b0ecb72

Browse files
committed
jest setup, verdaccio docker setup and readme
1 parent 1fa4284 commit b0ecb72

28 files changed

+1666
-602
lines changed

.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./babel.config.js"
3+
}

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/dist

.eslintrc.js

+20
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,28 @@ const path = require('path')
33
module.exports = {
44
extends: 'eslint-config-ns',
55
rules: {
6+
'class-methods-use-this': 0,
7+
'jest/consistent-test-it': [
8+
'error',
9+
{
10+
fn: 'it',
11+
withinDescribe: 'it',
12+
},
13+
],
14+
'import/no-named-as-default': 0,
615
'react/prop-types': 0,
16+
'sort-keys': 0,
717
},
18+
overrides: [
19+
{
20+
files: ['*.test.js', '*.stories.js'],
21+
rules: {
22+
'import/no-extraneous-dependencies': 0,
23+
'no-console': 0,
24+
'react/prop-types': 0,
25+
},
26+
},
27+
],
828
settings: {
929
'import/resolver': {
1030
'eslint-import-resolver-lerna': {

.github/ISSUE_TEMPLATE/bug_report.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
name: Bug Report 🐞
3+
about: Something isn't working as expected? Here is the right place to report.
4+
---
5+
6+
<!--
7+
To make it easier for us to help you — please follow the suggested format below.
8+
9+
Before opening a new issue, please search existing issues: https://github.com/natterstefan/react-component-library-lerna
10+
11+
For general technical questions, contact me on [Twitter](http://twitter.com/natterstefan).
12+
-->
13+
14+
# Bug Report
15+
16+
## Relevant information
17+
18+
<!-- Provide as much useful information as you can -->
19+
20+
### Your Environment
21+
22+
* Browser: **\_**
23+
* Browser version: **\_**
24+
* OS: **\_**
25+
* App Version: **\_**
26+
27+
#### Steps to reproduce
28+
29+
1. Step 1
30+
2. Step 2
31+
3. Step 3
32+
33+
#### Observed Results
34+
35+
* What happened? This could be a description, log output, etc.
36+
37+
#### Expected Results
38+
39+
* What did you expect to happen?
40+
41+
#### Relevant Code (optional)
42+
43+
```js
44+
// TODO(you): code here to reproduce the problem
45+
```
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
name: Feature Request 💡
3+
about: Suggest a new idea.
4+
---
5+
6+
<!--
7+
To make it easier for us to help you — please follow the suggested format below.
8+
9+
Before opening a new issue, please search existing issues: https://github.com/natterstefan/react-component-library-lerna
10+
11+
For general technical questions, contact me on [Twitter](http://twitter.com/natterstefan).
12+
-->
13+
14+
# Feature Request
15+
16+
Brief explanation of the feature you have in mind.
17+
18+
## Basic example
19+
20+
If you want you can include a basic code example. Omit this section if it's
21+
not applicable.
22+
23+
## Motivation
24+
25+
Why are you suggesting this? What is the use case for it and what is the
26+
expected outcome?

.github/ISSUE_TEMPLATE/question.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Question 🤔
3+
about: Usage question or discussion.
4+
---
5+
6+
<!--
7+
To make it easier for us to help you — please follow the suggested format below.
8+
9+
Before opening a new issue, please search existing issues: https://github.com/natterstefan/react-component-library-lerna
10+
11+
For general technical questions, contact me on [Twitter](http://twitter.com/natterstefan).
12+
-->
13+
14+
# Question
15+
16+
## Relevant information
17+
18+
Provide as much useful information as you can.
19+
20+
### Your Environment
21+
22+
* Browser: **\_**
23+
* Browser version: **\_**
24+
* OS: **\_**
25+
* App Version: **\_**

.github/PULL_REQUEST_TEMPLATE.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!--
2+
3+
Please submit all PRs to the `master` branch unless they are specific to current
4+
release.
5+
6+
Maintainers: Please tag your pull request with at least one of the following:
7+
`["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]`
8+
9+
-->
10+
# Issue
11+
12+
## What I did
13+
14+
## How to test
15+
16+
- Is this testable with Jest?
17+
- Does this need an update to the documentation?
18+
19+
If your answer is yes to any of these, please make sure to include it in your PR.

.gitignore

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
.DS_Store
2-
dist
32
node_modules
3+
4+
# logs and temporary files
45
*.log
5-
tmp
6+
tmp
7+
8+
# build
9+
build
10+
dist
11+
*.tgz
12+
13+
# tests
14+
coverage

.npmrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
save-exact=true
2-
@natterstefan:registry=http://localhost:4873/
2+
@natterstefan:registry=http://localhost:4873/
3+
//localhost:4873/:_authToken="kG7FOb1Nem5Q1+mnSw88pg=="

.storybook/config.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@ import { withBackgrounds } from '@storybook/addon-backgrounds'
55
import JSXAddon from 'storybook-addon-jsx'
66
import '@storybook/addon-console'
77

8-
const req = require.context('../storybook', true, /\.stories\.js$/)
9-
108
function loadStories() {
9+
const req = require.context('../packages', true, /\.stories\.js$/)
1110
req.keys().forEach(filename => req(filename))
1211
}
1312

1413
addDecorator(
1514
withOptions({
1615
name: 'Storybook',
17-
url: 'https://natterstefan.me',
1816
goFullScreen: false,
19-
showLeftPanel: true,
20-
showDownPanel: true,
17+
showStoriesPanel: true,
18+
showAddonPanel: true,
2119
showSearchBox: false,
22-
downPanelInRight: true,
20+
addonPanelInRight: true,
2321
sortStoriesByKind: true,
2422
}),
2523
)

CHANGES.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,11 @@ adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## Unreleased
88

9-
- Initial project setup
9+
### Added
10+
11+
- Initial project setup with
12+
- lerna publishing flow
13+
- local verdaccio setup (with docker)
14+
- jest test suite setup
15+
- ESLint and prettier setup
16+
- babel setup

README.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# React Component Library with Lerna
22

33
[![Dependencies](https://img.shields.io/david/natterstefan/react-component-library-lerna.svg)](https://github.com/natterstefan/react-component-library-lerna/blob/master/package.json)
4-
[![DevDependencies](https://img.shields.io/david/dev/natterstefan/react-trello-multiboard.svg)](https://github.com/natterstefan/react-trello-multiboard/blob/master/package.json)
4+
[![DevDependencies](https://img.shields.io/david/dev/natterstefan/react-component-library-lerna.svg)](https://github.com/natterstefan/react-component-library-lerna/blob/master/package.json)
55
[![Known Vulnerabilities](https://snyk.io/test/github/natterstefan/react-component-library-lerna/badge.svg)](https://snyk.io/test/github/natterstefan/react-component-library-lerna)
66
[![GitHub license](https://img.shields.io/github/license/natterstefan/react-component-library-lerna.svg)](https://github.com/natterstefan/react-component-library-lerna/blob/master/LICENCE)
77
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
@@ -33,6 +33,26 @@ Please, be patient. I will soon add "How to" sections. They are going to tell yo
3333

3434
Stay tuned!
3535

36+
### How to test publishing
37+
38+
This repository comes with a pre-configured [verdaccio](https://verdaccio.org/)
39+
(private npm registry) setup. All you need to do is start it with:
40+
41+
```bash
42+
cd localdev
43+
docker-compose -d # will start the verdaccio docker image
44+
```
45+
46+
Now, open [http://localhost:4873/](http://localhost:4873/). You should see
47+
the UI of verdaccio on your screen now. That's great. Because it means you can
48+
now publish the packages to this npm registry. Usually you have to login to
49+
the registry, but the [.npmrc](./.npmrc) already includes the `_authToken`. So
50+
`yarn publish` in one of the packages will publish it, or with `yarn publish` in
51+
the root folder (uses lerna).
52+
53+
In order to publish your packages to npm, simply change the `registry` property
54+
in each `package.json`'s `publishConfig`.
55+
3656
## Licence
3757

3858
[MIT](LICENCE)

jest.config.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// partially inspired by https://github.com/facebook/jest/issues/3112
2+
module.exports = {
3+
collectCoverageFrom: [
4+
'packages/**/*.js',
5+
'!packages/**/coverage/**/*.js',
6+
'!packages/**/dist/**/*.js',
7+
'!packages/**/prop-types.js',
8+
'!packages/**/*.stories.js',
9+
'!packages/**/*.test.js',
10+
'!packages/__tests__/**/*.js',
11+
'!packages/__mocks__/**/*.js',
12+
],
13+
collectCoverage: true,
14+
notify: true,
15+
notifyMode: 'failure-change',
16+
roots: ['<rootDir>/packages/'],
17+
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
18+
snapshotSerializers: ['enzyme-to-json/serializer'],
19+
testPathIgnorePatterns: [
20+
'<rootDir>/(build|dist|node_modules)/',
21+
'<rootDir>/packages/*/(build|dist|node_modules)/',
22+
],
23+
transform: {
24+
'.+\\.js$': 'babel-jest',
25+
},
26+
testEnvironment: 'jest-environment-jsdom-global',
27+
verbose: true,
28+
}

jest.setup.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
import { configure } from 'enzyme'
3+
import Adapter from 'enzyme-adapter-react-16'
4+
5+
configure({ adapter: new Adapter() })

lerna.json

+12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
{
22
"npmClient": "yarn",
33
"packages": ["packages/*"],
4+
"command": {
5+
"publish": {
6+
"ignoreChanges": [
7+
".babelrc",
8+
".eslintrc.js",
9+
"babel.config.js",
10+
"*.stories.js",
11+
"*.test.js",
12+
"*.md"
13+
]
14+
}
15+
},
416
"useWorkspaces": true,
517
"version": "independent"
618
}

localdev/config.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# path to a directory with all packages
2+
storage: /verdaccio/storage
3+
# path to a directory with plugins to include
4+
plugins: /verdaccio/plugins
5+
6+
web:
7+
# WebUI is enabled as default, if you want disable it, just uncomment this line
8+
# enable: false
9+
title: Verdaccio
10+
11+
auth:
12+
htpasswd:
13+
# https://verdaccio.org/docs/en/authentification
14+
# currently defaults to admin:admin
15+
file: ./htpasswd
16+
# Maximum amount of users allowed to register, defaults to "+infinity".
17+
# You can set this to -1 to disable registration.
18+
# max_users: 1000
19+
20+
# To use `npm audit` uncomment the following section
21+
middlewares:
22+
audit:
23+
enabled: true
24+
25+
# a list of other known repositories we can talk to
26+
uplinks:
27+
npmjs:
28+
url: https://registry.npmjs.org/
29+
cache: false
30+
31+
packages:
32+
'@natterstefan/*':
33+
access: $all
34+
publish: $authenticated
35+
proxy: npmjs
36+
37+
'@*/*':
38+
# scoped packages
39+
access: $all
40+
publish: $authenticated
41+
proxy: npmjs
42+
43+
'**':
44+
# allow all users (including non-authenticated users) to read and
45+
# publish all packages
46+
#
47+
# you can specify usernames/groupnames (depending on your auth plugin)
48+
# and three keywords: "$all", "$anonymous", "$authenticated"
49+
access: $all
50+
51+
# allow all known users to publish packages
52+
# (anyone can register by default, remember?)
53+
publish: $all
54+
55+
# if package is not available locally, proxy requests to 'npmjs' registry
56+
proxy: npmjs
57+
58+
# log settings
59+
logs:
60+
- {type: stdout, format: pretty, level: trace}

localdev/docker-compose.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: '3.7'
2+
3+
volumes:
4+
verdaccio:
5+
6+
services:
7+
app:
8+
image: verdaccio/verdaccio:4.x-next
9+
ports:
10+
- 4873:4873
11+
volumes:
12+
- verdaccio:/verdaccio/storage
13+
- ./config.yml:/verdaccio/conf/config.yaml
14+
- ./htpasswd:/verdaccio/conf/htpasswd

localdev/htpasswd

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
admin:$6Q3/x/TBWQac:autocreated 2019-02-09T17:51:16.164Z

0 commit comments

Comments
 (0)