Skip to content

Commit

Permalink
refactor: migrate to es6
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed Sep 23, 2021
1 parent ff6461e commit 0d47af8
Show file tree
Hide file tree
Showing 32 changed files with 23,521 additions and 3,831 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"
}
}
]
]
}
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js}]
charset = utf-8
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/predefine.apidoc.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",
"plugin:prettier/recommended",
"plugin:jsdoc/recommended"
],
"plugins": ["prettier", "jsdoc"],
"rules": {
"prettier/prettier": "error"
}
}
30 changes: 11 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,21 @@
logs
*.log

#Temporary data
.tmp

# Runtime data
# Runtime
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
# Temporary
.tmp
.grunt

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
# Dependencies
node_modules
doc
startup.sh

# Coverage
libcov
coverage
.nyc_output

# Docs
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
7 changes: 0 additions & 7 deletions .jsbeautifyrc

This file was deleted.

21 changes: 0 additions & 21 deletions .jshintrc

This file was deleted.

29 changes: 12 additions & 17 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
logs
*.log
pids
*.pid
*.seed
.tmp
.grunt
node_modules
ssl
.DS_STORE
*~
.idea
nbproject
libcov
coverage
.nyc_output
test
.git
.gitignore
.tmp
*.swo
*.swp
*.swn
*.swm
*.log
.jshintrc
.editorconfig
examples
docs
doc.html
.travis.yml
Gruntfile.js
Gruntfile.js
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
registry = https://registry.npmjs.com/
registry = "https://registry.npmjs.com/"
git-tag-version = false
Empty file added .prettierignore
Empty file.
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 80,
"singleQuote": true,
"semi": true,
"trailingComma": "es5"
}
12 changes: 8 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
language: node_js
services: mongodb
services:
- mongodb
node_js:
- "11.12.0"
before_script:
- npm install -g grunt-cli
- node
script:
- commitlint-travis
- npm test
after_success: npm run coverage

50 changes: 0 additions & 50 deletions Gruntfile.js

This file was deleted.

4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
The MIT License (MIT)

Copyright (c) 2018 lykmapipo & Contributors
Copyright (c) lykmapipo & Contributors

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.
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.
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
# mongoose-faker

[![Build Status](https://travis-ci.org/lykmapipo/mongoose-faker.svg?branch=master)](https://travis-ci.org/lykmapipo/mongoose-faker)
[![Dependencies Status](https://david-dm.org/lykmapipo/mongoose-faker/status.svg)](https://david-dm.org/lykmapipo/mongoose-faker)
[![npm version](https://badge.fury.io/js/%40lykmapipo%2Fmongoose-faker.svg)](https://badge.fury.io/js/%40lykmapipo%2Fmongoose-faker)
[![Build Status](https://app.travis-ci.com/lykmapipo/mongoose-faker.svg?branch=master)](https://app.travis-ci.com/lykmapipo/mongoose-faker)
[![Dependencies Status](https://david-dm.org/lykmapipo/mongoose-faker.svg)](https://david-dm.org/lykmapipo/mongoose-faker)
[![Coverage Status](https://coveralls.io/repos/github/lykmapipo/mongoose-faker/badge.svg?branch=master)](https://coveralls.io/github/lykmapipo/mongoose-faker?branch=master)
[![GitHub License](https://img.shields.io/github/license/lykmapipo/mongoose-faker)](https://github.com/lykmapipo/mongoose-faker/blob/develop/LICENSE)

[![Commitizen Friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Code Style](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)
[![npm version](https://img.shields.io/npm/v/@lykmapipo/mongoose-faker)](https://www.npmjs.com/package/@lykmapipo/mongoose-faker)

mongoose plugin to generate fake model data

## Requirements

- NodeJS v6.5+
- [NodeJS v13+](https://nodejs.org)
- [Npm v6.12+](https://www.npmjs.com/)
- [MongoDB v4+](https://www.mongodb.com/)
- [Mongoose v5.7+](https://github.com/Automattic/mongoose)

## Install
```sh
$ npm install --save @lykmapipo/mongoose-faker
$ npm install --save mongoose @lykmapipo/mongoose-faker
```

## Usage

```js
const mongoose = require('mongoose');
mongoose.plugin(require('mongoose-faker'));
import mongoose from 'mongoose';
import mongooseFaker from 'mongoose-faker';

mongoose.plugin(mongooseFaker);
const Schema = mongoose.Schema;

const UserSchema = new Schema({
Expand Down Expand Up @@ -120,10 +131,10 @@ It will be nice, if you open an issue first so that we can know what is going on
## Licence
The MIT License (MIT)

Copyright (c) 2015 lykmapipo & Contributors
Copyright (c) lykmapipo & Contributors

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.
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.
3 changes: 3 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Security

If you find a security vulnerability in mongoose-faker, file a [new issue](https://github.com/lykmapipo/mongoose-faker/issues).
Empty file added examples/.env
Empty file.
7 changes: 7 additions & 0 deletions examples/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": ["airbnb-base", "plugin:prettier/recommended"],
"plugins": ["prettier"],
"rules": {
"no-console": "off"
}
}
Empty file added examples/.gitkeep
Empty file.
22 changes: 22 additions & 0 deletions examples/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import mongoose from 'mongoose';
import mongooseFaker from '../src';

mongoose.plugin(mongooseFaker);
const { Schema } = mongoose;

const UserSchema = new Schema({
name: {
type: String,
fake: {
generator: 'name',
type: 'firstName',
},
},
});
const User = mongoose.model('User', UserSchema);

const user = User.fake();
console.log(user);

const users = User.fake(50);
console.log(users);

0 comments on commit 0d47af8

Please sign in to comment.