Skip to content

Commit df33695

Browse files
committed
refactor(npm package): cli restructure (#15)
BREAKING CHANGE: npm packaging, cli * build, update tooling for editor, ci, testing * build, readme cli additions, contributing * build, github request templates * cli, added bin script * docker, cmd script updated towards cli * tests, breakout ecma class for testing
1 parent 93f1a27 commit df33695

31 files changed

+3738
-748
lines changed

.codecov.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
coverage:
2+
precision: 2
3+
round: down
4+
range: "50...95"
5+
6+
status:
7+
project:
8+
default:
9+
target: "65%"
10+
patch:
11+
default: off
12+
changes:
13+
default: off
14+
15+
comment:
16+
layout: "header, reach, diff, flags, files, footer"
17+
behavior: default
18+
require_changes: no
19+
require_base: no
20+
require_head: yes

.editorconfig

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
# Editor configuration, see http://editorconfig.org
12
root = true
23

34
[*]
5+
charset = utf-8
46
indent_style = space
57
indent_size = 2
6-
end_of_line = lf
7-
charset = utf-8
8-
trim_trailing_whitespace = true
98
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
end_of_line = lf
11+
12+
[*.snap]
13+
max_line_length = off
14+
trim_trailing_whitespace = false
1015

1116
[*.md]
17+
max_line_length = off
1218
trim_trailing_whitespace = false

.eslintrc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
{
22
"parser": "babel-eslint",
33
"env": {
4-
"node": true,
5-
"es6": true
4+
"es6": true,
5+
"jest": true,
6+
"node": true
67
},
78
"plugins": [
9+
"jest",
810
"node",
911
"prettier"
1012
],
1113
"extends": [
1214
"eslint:recommended",
15+
"plugin:jest/recommended",
1316
"plugin:node/recommended",
1417
"plugin:prettier/recommended"
1518
],
@@ -25,22 +28,25 @@
2528
"max-len": [
2629
"error",
2730
{
28-
"code": 200,
31+
"code": 240,
2932
"ignoreUrls": true
3033
}
3134
],
32-
"no-plusplus": 0,
33-
"padded-blocks": 0,
34-
"space-before-function-paren": 0,
3535
"no-console": 0,
3636
"no-debugger": 1,
37+
"no-plusplus": 0,
38+
"node/no-unsupported-features/es-syntax": 1,
39+
"node/shebang": 0,
40+
"node/no-unpublished-bin": 0,
41+
"padded-blocks": 0,
3742
"prettier/prettier": [
3843
"error",
3944
{
4045
"singleQuote": true,
4146
"printWidth": 100
4247
}
4348
],
49+
"space-before-function-paren": 0,
4450
"valid-jsdoc": [
4551
1,
4652
{

.github/ISSUE_TEMPLATE/Bug Report.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Bug report
3+
about: A clear and concise description of what the bug is.
4+
5+
---
6+
7+
## Summary:
8+
<!-- Provide a description of the issue being raised. -->
9+
10+
### Steps to reproduce
11+
<!-- List clear steps to reproduce the bug. -->
12+
1.
13+
1.
14+
15+
### Expected Result
16+
<!-- Describe the expected behavior for the program. -->
17+
...
18+
19+
## Additional Context
20+
<!-- Append a demo/screenshot/animated gif of the problem. Package.json version, tag, or git commit information. -->
21+
...
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Feature request
3+
about: Suggest a feature, or enhancement, for this project.
4+
5+
---
6+
7+
## Feature description
8+
As user X, I want Y to happen so that Z.
9+
10+
### Is your feature request related to a problem?
11+
<!-- Provide a clear, concise description of what the problem is. -->
12+
...
13+
14+
### Describe the solution you'd like
15+
<!-- A clear and concise description of what you want to happen. -->
16+
...
17+
18+
## Acceptance Criteria
19+
20+
- [ ] X should happen
21+
- [ ] Y should also happen for Z
22+
23+
<!-- ## Assumptions and Questions -->

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## What's included
2+
<!-- List your changes/additions, or commits -->
3+
...
4+
5+
<!-- ### Notes -->
6+
<!-- Anything funky about your updates. Or issues that aren't resolved by this merge request, things of note? -->
7+
8+
## How to test
9+
<!-- Are there directions to test/review? -->
10+
<!--
11+
### Coverage and basic unit test check
12+
1. update the NPM packages with `$ yarn`
13+
1. `$ yarn test`
14+
### Interactive unit test check
15+
1. update the NPM packages with `$ yarn`
16+
1. `$ yarn test:dev`
17+
-->
18+
...
19+
20+
## Example
21+
<!-- Append a demo/screenshot/animated gif, or a link to the aforementioned, of the cli output -->
22+
...
23+
24+
## Updates issue/story
25+
<!-- What issue/story does this update, i.e Updates #33 -->

.gitignore

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1-
.env.local
2-
*.log
3-
dist
1+
# dependencies
42
node_modules
53
package-lock.json
4+
.yarn-integrity
5+
6+
# coverage
7+
lib-cov
68
coverage
79
.nyc*
8-
docs
10+
*.lcov
11+
12+
# logs
13+
logs
14+
*.log
15+
npm-debug.log*
16+
yarn-debug.log*
17+
yarn-error.log*
18+
api-debug*
19+
20+
# misc
21+
.env
22+
.docs

.npmignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*
2+
!package.json
3+
!bin/**/*.js
4+
!data/**/*.js
5+
!src/**/*.js
6+
src/**/*test.js
7+
src/**/*.archive
8+
!LICENSE
9+
!README.md
10+
!CHANGELOG.md

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: node_js
2+
3+
cache: yarn
4+
5+
jobs:
6+
include:
7+
- stage: test
8+
env:
9+
- NAME=yarn
10+
node_js: "10"
11+
before_script: yarn global add codecov
12+
script: yarn test
13+
after_success: codecov

CONTRIBUTING.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Contributing
2+
3+
## Commits
4+
For consistency we make use of [Conventional Commits](https://www.conventionalcommits.org). It's encouraged that
5+
commit messaging follow the format
6+
```
7+
<type>[optional scope]: <description>
8+
```
9+
10+
### Build Requirements
11+
To setup your work environment you'll need to use
12+
* [NodeJS version 10+](https://nodejs.org/)
13+
* [Yarn 1.13+](https://yarnpkg.com)
14+
* And if you plan on making Docker contributions you may want to setup
15+
- [Docker](https://docs.docker.com/engine/installation/)
16+
17+
### Developing
18+
To start work
19+
```shell
20+
$ yarn
21+
$ yarn start:dev
22+
```
23+
24+
#### Testing during development
25+
Jest is used for the unit test framework. To run unit tests during development open a terminal instance and run
26+
```shell
27+
$ yarn test:dev
28+
```
29+
30+
This should also let you update the code snapshots.
31+
32+
### Code Coverage
33+
The requirements for code coverage are currently maintained around the `60%` to `70%` mark.
34+
35+
Updates that drop coverage below the current threshold should have their coverage expanded before being merged.
36+
37+
Settings for coverage can be found in [package.json](./package.json)
38+
39+
#### To check test coverage
40+
```shell
41+
$ yarn test
42+
```
43+
44+
#### Code coverage failing to update?
45+
If you're having trouble getting an accurate code coverage report, or it's failing to provide updated results (i.e. you renamed files) you can try running
46+
```
47+
$ yarn test:clearCache
48+
```

Dockerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ FROM node:10-alpine
22

33
WORKDIR /app
44

5-
COPY package.json /app/
65
ADD ./data/example.js /data/example.js
76
COPY . /app
87

@@ -12,7 +11,4 @@ VOLUME /docs
1211
RUN yarn --production --non-interactive \
1312
&& yarn cache clean
1413

15-
ENV PORT=8000
16-
17-
EXPOSE ${PORT}
18-
CMD ["yarn", "start:container"]
14+
CMD ["yarn", "start"]

0 commit comments

Comments
 (0)