Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(release): release version v2.0.0 #53

Merged
merged 25 commits into from
Jul 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
185078b
chore: turn into monorepo architecture and change return to instance …
omermorad Jul 17, 2021
3239064
refactor(mockingbird-ts): change the name of mock factory to be mock …
omermorad Jul 17, 2021
cf56561
refactor(mockingbird-ts): arrange classes - change mock-factory to mo…
omermorad Jul 18, 2021
0468412
refactor(parser): change faker methods (that were deprecated) to new …
omermorad Jul 18, 2021
656661f
test: add some more test cases (and increase code coverage) (#57)
omermorad Jul 19, 2021
3831855
refactor: change generics type, remove 'type' type and add 'class' ty…
omermorad Jul 19, 2021
93d53e4
chore(release): release packages
omermorad Jul 19, 2021
7f9390d
revert(repo): release packages
omermorad Jul 19, 2021
a2950f1
chore(repo): change entry points in package.json files and change tsc…
omermorad Jul 20, 2021
cc5710d
feat(mockingbird-ts): add mock factory fluent/builder api (#60)
omermorad Jul 21, 2021
f72dbe3
ci(repo): add lerna command to publish with temp alpha dist tag
omermorad Jul 22, 2021
d068698
chore(repo): version packages and add changelogs
omermorad Jul 22, 2021
f4e3092
fix(types): add build to export a js file to include the faker instan…
omermorad Jul 23, 2021
244adb1
chore(repo): add publish access config in package.json for all packages
omermorad Jul 22, 2021
9fafea3
chore(release): release packages
omermorad Jul 23, 2021
9d8ccf3
chore(repo): add lerna commit message for version command
omermorad Jul 23, 2021
a777095
docs(repo): update readme and the api docs [skip ci]
omermorad Jul 23, 2021
a858cb4
fix(types): change the values inside 'files' array in package.json
omermorad Jul 23, 2021
163f1f5
chore(repo): version packages
omermorad Jul 23, 2021
45bb67c
chore(repo): update docs and sample (#62)
omermorad Jul 23, 2021
c80a064
feat(mockingbird-ts,parser): add ability to pass an object for extra …
omermorad Jul 24, 2021
6a70320
chore(repo): add codecov.yml file (#67)
omermorad Jul 27, 2021
6dedb38
chore(repo): update codecov settings
omermorad Jul 27, 2021
eba46e8
feat(mockingbird-ts): extend builder abilities (#68)
omermorad Jul 31, 2021
3f2fb8c
ci(repo): remove release from master
omermorad Jul 31, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
deprecated
packages/**/index.js
packages/**/index.d.ts
packages/**/dist/**/*
node_modules/*
coverage/*
dist
dist/*
*.js
*.d.ts
index.ts
jest.config.js
jest.config.base.js
commitlint.config.js
jest.config.js
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"prettier"
// "prettier/@typescript-eslint"
],
"parserOptions": {
"ecmaVersion": 8
Expand Down Expand Up @@ -38,7 +40,6 @@
"trailingComma": "es5"
}
],
"react/forbid-prop-types": 0,
"no-unused-expressions": 0,
"one-var": 0,
"no-underscore-dangle": [
Expand All @@ -60,6 +61,7 @@
"lines-between-class-members": "off"
},
"env": {
"node": true,
"jest": true
}
}
33 changes: 17 additions & 16 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
pull_request:
branches:
- master
- release

jobs:
build-and-test:
Expand All @@ -20,37 +21,37 @@ jobs:
with:
ref: ${{ github.head_ref }}

- name: Get NPM Cache Directory Path
id: npm-cache-dir
run: echo "::set-output name=dir::$(npm config get cache)"

- name: Lint Commit Message
run: |
npm i -D @commitlint/config-conventional
echo $(git log -1 --pretty=format:"%s") | npx commitlint
- name: Get Yarn Cache Directory Path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Use NodeJS ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: NPM CI
id: npm-cache
- name: Yarn Init
id: yarn-cache
uses: actions/cache@v2
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-
${{ runner.os }}-yarn-

- name: Lint Commit Message
run: |
yarn add -D -W @commitlint/config-conventional
echo $(git log -1 --pretty=format:"%s") | yarn commitlint

- name: Lint Source
run: npm run lint
run: yarn lint-staged

- name: Build
run: npm run build
run: yarn build

- name: Test
run: npm run test:cov
run: yarn test:cov

- name: Upload Report to Codecov
uses: codecov/codecov-action@v1
Expand Down
29 changes: 12 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ name: Release
on:
push:
branches:
- release
- alpha
- beta
- master

jobs:
main:
name: Main
Expand All @@ -21,32 +20,28 @@ jobs:
with:
node-version: 14

- name: Install Dependecies
run: npm install
- name: Yarn Install Dependecies
run: yarn

- name: Lint Commit Message
run: echo $(git log -1 --pretty=format:"%s") | npx commitlint
run: |
yarn add -D -W @commitlint/config-conventional
echo $(git log -1 --pretty=format:"%s") | yarn commitlint

- name: Lint Source
run: npm run lint
run: yarn lint

- name: Build
run: npm run build
run: yarn build

- name: Test
run: npm run test:cov
run: yarn test:cov

- name: Upload Report to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage
fail_ci_if_error: true
fail_ci_if_error: false
files: ./coverage/cobertura-coverage.xml
name: codecov-umbrella

- name: Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
name: codecov-umbrella
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lerna-debug.log*
.DS_Store

# Tests
/coverage
coverage
/sample/coverage
/.nyc_output

Expand All @@ -38,3 +38,4 @@ lerna-debug.log*
junit.xml
.gitconfig
.circleci
!.husky
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
42 changes: 0 additions & 42 deletions .releaserc.json

This file was deleted.

64 changes: 34 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
[![ISC license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
[![npm version](http://img.shields.io/npm/v/mockingbird-ts.svg?style=flat)](https://npmjs.org/package/mockingbird-ts "View this project on npm")
[![Codecov Coverage](https://img.shields.io/codecov/c/github/omermorad/mockingbird-ts/master.svg?style=flat-square)](https://codecov.io/gh/omermorad/mockingbird-ts)
[![Master](https://github.com/omermorad/mockingbird-ts/actions/workflows/release.yml/badge.svg?branch=release)](https://github.com/omermorad/mockingbird-ts/actions)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)

<p align="center">
<img width="450" src="https://raw.githubusercontent.com/omermorad/mockingbird-ts/master/docs/logo.png" alt="Mockingbird Logo" />

<h1 align="center">Mockingbird</h1>

<h3 align="center">
Decorator Powered TypeScript Library for Creating Mocks
The First TypeScript Mocking Framework
</h3>

<h4 align="center">
Expand All @@ -19,10 +18,9 @@
</p>

## Installation
Install the package alongside `faker` and `@types/faker` peer dependencies:

```bash
npm i mockingbird-ts faker @types/faker
npm i -D mockingbird-ts
```

## Usage
Expand All @@ -35,58 +33,64 @@ import { Mock, MockFactory } from 'mockingbird-ts';
class Dog {
@Mock(faker => faker.name.firstName())
readonly name: string;

@Mock()
readonly birthday: Date; // Will generate a recent date

@Mock()
readonly goodPoints: number; // Will generate a random number
}

const result = MockFactory.create<Dog>(Dog);
const oneDog = MockFactory(Dog).one();
const lotsOfDogs = MockFactory(Dog).many(3);
```

## Documentation

There are many more options that you can use with the `@Mock` decorator (and also the `MockFactory`). \
[Click here to jump to the full documentation and explore the full API](https://github.com/omermorad/faker.ts/blob/master/docs/README.md)

**Besides, we have also created a full working example for you; [you can find it under
the sample folder](https://github.com/omermorad/mockingbird-ts/tree/master/sample)**

**Besides, we have also created a full working example for
you; [you can find it under the sample folder](https://github.com/omermorad/mockingbird-ts/tree/master/sample)**

## Playground
**We have created a [REPL Playground](https://repl.it/@omermorad/Mockingbird-Playground) where you can see Mockingbird in action!**

**We have created a [REPL Playground](https://repl.it/@omermorad/Mockingbird-Playground) where you can see Mockingbird
in action!**

## Use Cases
- Generate fake (but reasonable) data for your integration tests
- Prepare as many of different fixtures for your tests
- Persist the

## Motivation
When it comes to writing unit tests of large projects containing different and
diverse entities, mocks are widely used to simulate real data.

Creating mocks can be a tedious and cumbersome process and is usually created
manually or by using libraries like Faker or Chance, which also do not offer a complete solution,
especially not when deciding to develop in TypeScript and most of the code becomes object oriented.
When it comes to writing tests of large projects containing different and diverse entities, mocks (sometimes called "
fixtures") are widely used to simulate real data.

Therefore, we thought of a convenient and efficient solution that allows the use
of only one decorator, Mock decorator that allows to create mocks by placing it above the properties of the class.
Creating mocks (or fixtures) can be a tedious and cumbersome process and is usually created manually or by using
libraries like Faker or Chance, which also do not offer a complete solution, especially not when you write TypeScript
only, and most of the code is object-oriented and arranged with classes.

Mockingbird offers several options for creating mocks, including the use of the
well-known library Faker, which allows you to create information such as a fake email, a fake username,
a fake address and more.
We came up with a simple (and efficient) yet super convenient solution: all you have to do to get fixtures out of the
box is to decorate your classes (whether it's an entity, or a model representing the database layer) and generate simple
or complex fixtures.

### What is faker.js (aka Faker)?
For those of you who are unfamiliar with `faker.js`, it is an old library written
with pure JavaScript, which is used to "generate massive amounts of fake data in
the browser and Node".
Mockingbird offers several options for creating mocks, including the use of the well-known library Faker, which allows
you to create data such as a fake email, a fake username, a fake address and more.u to create information such as a fake
email, a fake username, a fake address and more.

Fake data is usually needed for testing purposes, to assist in the development process itself,
and sometimes, also for the purpose of demonstrations and training.
### What is `faker.js` (aka Faker)?

Mockingbird uses Faker under the hood and making it possible to use faker.js in
a "TypeScript" way, and thereby allows to create mocks that are meaningful like
email, first name, address and many more.
For those of you who are unfamiliar with `faker.js`, it is a library which is used to "generate massive amounts of fake data in the browser and Node".

Mockingbird uses `faker.js` under the hood, making it possible to use Faker in it's "TypeScript" way, and thereby allows
to create mocks that are meaningful like email, first name, address and many more.

## License

Distributed under the MIT License. See `LICENSE` for more information.

## Acknowledgements

[faker.js](https://github.com/marak/Faker.js)
8 changes: 8 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
coverage:
status:
project:
default:
target: 95%
patch:
default:
target: 95%
18 changes: 18 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const {
utils: { getPackages },
} = require('@commitlint/config-lerna-scopes');

module.exports = {
extends: ['@commitlint/config-conventional', '@commitlint/config-lerna-scopes'],
rules: {
'scope-enum': async (ctx) => [
2,
'always',
[
...(await getPackages(ctx)),
'release',
'repo',
],
],
},
};
Loading