Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
caian-gums committed Dec 9, 2019
0 parents commit e5eb088
Show file tree
Hide file tree
Showing 18 changed files with 282 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/node_modules
**/webpack.config.js
11 changes: 11 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": ["airbnb-base", "prettier"],
"env": {
"browser": true,
"node": true,
"jest": true
},
"rules": {
"import/prefer-default-export": "off"
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
*.log
.DS_Store
dist
lib
coverage
yarn.lock
package-lock.json
6 changes: 6 additions & 0 deletions .huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"hooks": {
"pre-commit": "yarn lint",
"pre-push": "yarn lint && yarn test"
}
}
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store
*.log
src
tests
examples
coverage
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tabWidth": 2,
"singleQuote": true,
"semi": true
}
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sudo: false
language: node_js
node_js:
- '10'
branches:
only:
- master
cache:
directories:
- node_modules
install:
- yarn --ignore-engines
script:
- yarn test
- yarn coveralls
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Contributing

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -m 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`

_Remember that we have a pre-push hook with steps that analyzes and prevents mistakes._

**After your pull request is merged**, you can safely delete your branch.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Codevor - js-library-boilerplate

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# js-library-boilerplate

[![License][license-badge]][license-url] [![Travis CI][travis-badge]][travis-url] [![Coverage Status][coverage-badge]][coverage-url] [![Commitizen][commitizen-badge]][commitizen-url]

> js-library-boilerplate-description.
## Installation

js-library-boilerplate is available on npm/yarn:

```bash
$ npm install js-library-boilerplate --save
$ yarn add js-library-boilerplate
```

## Usage

### With ES6/import

```js
import { sum } from 'js-library-boilerplate';

sum(2, 2); // => 4
```

### With require

```js
const sum = require('js-library-boilerplate').sum;

sum(2, 2); // => 4
```

## Contributing

Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.

## Changelog

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.

## Bugs and Sugestions

Report bugs or do suggestions using the [issues](https://github.com/codevor/js-library-boilerplate/issues).

## License

[MIT License](LICENSE) © [Codevor](https://github.com/codevor)

[license-badge]: https://img.shields.io/github/license/codevor/js-library-boilerplate.svg
[license-url]: https://opensource.org/licenses/MIT
[coverage-badge]: https://coveralls.io/repos/github/codevor/js-library-boilerplate/badge.svg?branch=master
[coverage-url]: https://coveralls.io/github/codevor/js-library-boilerplate?branch=master
[travis-badge]: https://travis-ci.org/codevor/js-library-boilerplate.svg?branch=master
[travis-url]: https://travis-ci.org/codevor/js-library-boilerplate
[commitizen-badge]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg
[commitizen-url]: http://commitizen.github.io/cz-cli/
54 changes: 54 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "js-library-boilerplate",
"version": "0.1.0",
"description": "js-library-boilerplate-description",
"main": "dist/js-library-boilerplate.js",
"unpkg": "dist/js-library-boilerplate.min.js",
"scripts": {
"clean": "rimraf dist",
"dev": "NODE_ENV=dev webpack --progress --colors --watch",
"build:umd": "NODE_ENV=production webpack",
"lint": "eslint src tests",
"test": "jest --coverage --expand",
"test:watch": "jest --watch",
"coveralls": "cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
"prepublish": "yarn lint && yarn test && yarn clean && yarn build:umd",
"commit": "git-cz"
},
"keywords": [],
"author": "Helder Burato Berto <helder.burato@gmail.com> (https://helder.dev/)",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/codevor/js-library-boilerplate.git"
},
"bugs": {
"url": "https://github.com/codevor/js-library-boilerplate/issues"
},
"homepage": "https://github.com/codevor/js-library-boilerplate#readme",
"devDependencies": {
"@babel/cli": "^7.6.4",
"@babel/core": "^7.6.4",
"@babel/preset-env": "^7.6.3",
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",
"commitizen": "^4.0.3",
"coveralls": "^3.0.7",
"cz-conventional-changelog": "3.0.2",
"eslint": "^6.5.1",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.4.0",
"eslint-plugin-import": "^2.18.2",
"husky": "^3.0.9",
"jest": "^24.9.0",
"rimraf": "^3.0.0",
"uglifyjs-webpack-plugin": "^2.2.0",
"webpack": "^4.41.1",
"webpack-cli": "^3.3.9"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function sum(x, y) {
return x + y;
}
7 changes: 7 additions & 0 deletions tests/sum.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { sum } from '../src';

describe('sum', () => {
test('it should sum 2 + 2', () => {
expect(sum(2, 2)).toBe(4);
});
});
51 changes: 51 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const path = require('path');
const webpack = require('webpack');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

const isProduction = process.env.NODE_ENV === 'production';
const mode = isProduction ? 'production' : 'development';

const libraryName = 'js-library-boilerplate';

module.exports = {
mode,
entry: {
[libraryName]: path.resolve(__dirname, 'src/index.js'),
[`${libraryName}.min`]: path.resolve(__dirname, 'src/index.js')
},
devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true,
globalObject: "typeof self !== 'undefined' ? self : this"
},
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
},
exclude: /node_modules/
}
]
},
optimization: {
minimize: true,
minimizer: [new UglifyJsPlugin({ include: /\.min\.js$/ })]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
],
resolve: {
extensions: ['.json', '.js']
}
};

0 comments on commit e5eb088

Please sign in to comment.