Skip to content

Commit 260d933

Browse files
author
caian-gums
committed
Initial commit
0 parents  commit 260d933

18 files changed

+282
-0
lines changed

.babelrc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"targets": {
7+
"node": "current"
8+
}
9+
}
10+
]
11+
]
12+
}

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/node_modules
2+
**/webpack.config.js

.eslintrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": ["airbnb-base", "prettier"],
3+
"env": {
4+
"browser": true,
5+
"node": true,
6+
"jest": true
7+
},
8+
"rules": {
9+
"import/prefer-default-export": "off"
10+
}
11+
}

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
*.log
3+
.DS_Store
4+
dist
5+
lib
6+
coverage
7+
yarn.lock
8+
package-lock.json

.huskyrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"hooks": {
3+
"pre-commit": "yarn lint",
4+
"pre-push": "yarn lint && yarn test"
5+
}
6+
}

.npmignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
*.log
3+
src
4+
tests
5+
examples
6+
coverage

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

.prettierrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"tabWidth": 2,
3+
"singleQuote": true,
4+
"semi": true
5+
}

.travis.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- '10'
5+
branches:
6+
only:
7+
- master
8+
cache:
9+
directories:
10+
- node_modules
11+
install:
12+
- yarn --ignore-engines
13+
script:
14+
- yarn test
15+
- yarn coveralls

CONTRIBUTING.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Contributing
2+
3+
1. Fork it!
4+
2. Create your feature branch: `git checkout -b my-new-feature`
5+
3. Commit your changes: `git commit -m 'Add some feature'`
6+
4. Push to the branch: `git push origin my-new-feature`
7+
8+
_Remember that we have a pre-push hook with steps that analyzes and prevents mistakes._
9+
10+
**After your pull request is merged**, you can safely delete your branch.

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Codevor - js-library-boilerplate
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# js-library-boilerplate
2+
3+
[![License][license-badge]][license-url] [![Travis CI][travis-badge]][travis-url] [![Coverage Status][coverage-badge]][coverage-url] [![Commitizen][commitizen-badge]][commitizen-url]
4+
5+
> js-library-boilerplate-description.
6+
7+
## Installation
8+
9+
js-library-boilerplate is available on npm/yarn:
10+
11+
```bash
12+
$ npm install js-library-boilerplate --save
13+
$ yarn add js-library-boilerplate
14+
```
15+
16+
## Usage
17+
18+
### With ES6/import
19+
20+
```js
21+
import { sum } from 'js-library-boilerplate';
22+
23+
sum(2, 2); // => 4
24+
```
25+
26+
### With require
27+
28+
```js
29+
const sum = require('js-library-boilerplate').sum;
30+
31+
sum(2, 2); // => 4
32+
```
33+
34+
## Contributing
35+
36+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
37+
38+
## Changelog
39+
40+
This project adheres to [Semantic Versioning](https://semver.org/). Every release, along with the migration instructions, is documented on the Github [Releases](https://github.com/codevor/js-library-boilerplate/releases) page.
41+
42+
## Bugs and Sugestions
43+
44+
Report bugs or do suggestions using the [issues](https://github.com/codevor/js-library-boilerplate/issues).
45+
46+
## License
47+
48+
[MIT License](LICENSE) © [Codevor](https://github.com/codevor)
49+
50+
[license-badge]: https://img.shields.io/github/license/codevor/js-library-boilerplate.svg
51+
[license-url]: https://opensource.org/licenses/MIT
52+
[coverage-badge]: https://coveralls.io/repos/github/codevor/js-library-boilerplate/badge.svg?branch=master
53+
[coverage-url]: https://coveralls.io/github/codevor/js-library-boilerplate?branch=master
54+
[travis-badge]: https://travis-ci.org/codevor/js-library-boilerplate.svg?branch=master
55+
[travis-url]: https://travis-ci.org/codevor/js-library-boilerplate
56+
[commitizen-badge]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg
57+
[commitizen-url]: http://commitizen.github.io/cz-cli/

package.json

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "js-library-boilerplate",
3+
"version": "0.1.0",
4+
"description": "js-library-boilerplate-description",
5+
"main": "dist/js-library-boilerplate.js",
6+
"unpkg": "dist/js-library-boilerplate.min.js",
7+
"scripts": {
8+
"clean": "rimraf dist",
9+
"dev": "NODE_ENV=dev webpack --progress --colors --watch",
10+
"build:umd": "NODE_ENV=production webpack",
11+
"lint": "eslint src tests",
12+
"test": "jest --coverage --expand",
13+
"test:watch": "jest --watch",
14+
"coveralls": "cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
15+
"prepublish": "yarn lint && yarn test && yarn clean && yarn build:umd",
16+
"commit": "git-cz"
17+
},
18+
"keywords": [],
19+
"author": "Helder Burato Berto <[email protected]> (https://helder.dev/)",
20+
"license": "MIT",
21+
"repository": {
22+
"type": "git",
23+
"url": "git+https://github.com/codevor/js-library-boilerplate.git"
24+
},
25+
"bugs": {
26+
"url": "https://github.com/codevor/js-library-boilerplate/issues"
27+
},
28+
"homepage": "https://github.com/codevor/js-library-boilerplate#readme",
29+
"devDependencies": {
30+
"@babel/cli": "^7.6.4",
31+
"@babel/core": "^7.6.4",
32+
"@babel/preset-env": "^7.6.3",
33+
"babel-jest": "^24.9.0",
34+
"babel-loader": "^8.0.6",
35+
"commitizen": "^4.0.3",
36+
"coveralls": "^3.0.7",
37+
"cz-conventional-changelog": "3.0.2",
38+
"eslint": "^6.5.1",
39+
"eslint-config-airbnb-base": "^14.0.0",
40+
"eslint-config-prettier": "^6.4.0",
41+
"eslint-plugin-import": "^2.18.2",
42+
"husky": "^3.0.9",
43+
"jest": "^24.9.0",
44+
"rimraf": "^3.0.0",
45+
"uglifyjs-webpack-plugin": "^2.2.0",
46+
"webpack": "^4.41.1",
47+
"webpack-cli": "^3.3.9"
48+
},
49+
"config": {
50+
"commitizen": {
51+
"path": "./node_modules/cz-conventional-changelog"
52+
}
53+
}
54+
}

src/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function sum(x, y) {
2+
return x + y;
3+
}

tests/sum.test.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { sum } from '../src';
2+
3+
describe('sum', () => {
4+
test('it should sum 2 + 2', () => {
5+
expect(sum(2, 2)).toBe(4);
6+
});
7+
});

webpack.config.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const path = require('path');
2+
const webpack = require('webpack');
3+
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
4+
5+
const isProduction = process.env.NODE_ENV === 'production';
6+
const mode = isProduction ? 'production' : 'development';
7+
8+
const libraryName = 'js-library-boilerplate';
9+
10+
module.exports = {
11+
mode,
12+
entry: {
13+
[libraryName]: path.resolve(__dirname, 'src/index.js'),
14+
[`${libraryName}.min`]: path.resolve(__dirname, 'src/index.js')
15+
},
16+
devtool: 'source-map',
17+
output: {
18+
path: path.resolve(__dirname, 'dist'),
19+
filename: '[name].js',
20+
library: libraryName,
21+
libraryTarget: 'umd',
22+
umdNamedDefine: true,
23+
globalObject: "typeof self !== 'undefined' ? self : this"
24+
},
25+
module: {
26+
rules: [
27+
{
28+
test: /\.js$/,
29+
use: {
30+
loader: 'babel-loader',
31+
options: {
32+
presets: ['@babel/preset-env']
33+
}
34+
},
35+
exclude: /node_modules/
36+
}
37+
]
38+
},
39+
optimization: {
40+
minimize: true,
41+
minimizer: [new UglifyJsPlugin({ include: /\.min\.js$/ })]
42+
},
43+
plugins: [
44+
new webpack.DefinePlugin({
45+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
46+
})
47+
],
48+
resolve: {
49+
extensions: ['.json', '.js']
50+
}
51+
};

0 commit comments

Comments
 (0)