Skip to content

Commit

Permalink
feat(core): initial code commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Jan 30, 2022
1 parent 7ef5799 commit f269062
Show file tree
Hide file tree
Showing 19 changed files with 402 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# EditorConfig is awesome: https://EditorConfig.org

root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{js,d.ts,ts}]
charset = utf-8
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[package.json,*.yaml]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
31 changes: 31 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Code of Conduct

Like the technical community as a whole, the Faker Javascript team and community is made up of a mixture of professionals and volunteers from all over the world, working on every aspect of the mission - including mentorship, teaching, and connecting people.

Diversity is one of our strengths. With that, challenges will arise that can lead to communication issues and unhappiness. To that end, we have a few ground rules that we ask people to adhere to. This code applies equally to founders, mentors and those seeking help and guidance.

This isn’t an exhaustive list of things that you can’t do. Rather, take it in the spirit in which it’s intended - a guide to make it easier to enrich all of us and the technical communities in which we participate.

This code of conduct applies to all spaces used by the Faker Javascript community for communication. This includes Discord, GitHub, Twitter, Facebook, meetups, conferences, and any other relevant forums. Violations of this code outside of any spaces managed by the Faker Javascript team will still affect a person’s ability to participate within them.

If you believe someone is violating the code of conduct, we ask that you report it by contacting us from [support@flextype.org](mailto:[email protected]). We take all reports seriously, and your identity will remain confidential.

- **Be friendly and patient.**
- **Be welcoming.** We strive to be a community that welcomes and supports people of all backgrounds and identities. This includes, but is not limited to members of any race, ethnicity, culture, national origin, colour, immigration status, social and economic class, educational level, sex, sexual orientation, gender identity and expression, age, size, family status, political belief, religion, and mental and physical ability.
- **Be considerate.** Your work will be used by other people, and you in turn will depend on the work of others. Any decision you take will affect users and colleagues, and you should take those consequences into account when making decisions. Remember that we’re a world-wide community, so you might not be communicating in someone else’s primary language.
- **Be respectful.** Not all of us will agree all the time, but disagreement is no excuse for poor behavior and poor manners. We might all experience some frustration now and then, but we cannot allow that frustration to turn into a personal attack. It’s important to remember that a community where people feel uncomfortable or threatened is not a productive one. Members of the Faker Javascript community should be respectful when dealing with other members as well as with people outside the Faker Javascript community.
- **Be careful in the words that you choose.** We are a community of professionals, and we conduct ourselves professionally. Be kind to others. Do not insult or put down other participants. Harassment and other exclusionary behavior aren’t acceptable. This includes, but is not limited to:

- Violent threats or language directed against another person.
- Discriminatory jokes and language.
- Exclusionary gendered language (guys, gentlemen, bros, etc).
- Posting sexually explicit or violent material.
- Posting (or threatening to post) other people’s personally identifying information ("doxing").
- Personal insults, especially those using racist or sexist terms.
- Unwelcome sexual attention.
- Advocating for, or encouraging, any of the above behavior.
- Repeated harassment of others. In general, if someone asks you to stop, then stop.

- **When we disagree, try to understand why.** Disagreements, both social and technical, happen all the time and Faker Javascript is no exception. It is important that we resolve disagreements and differing views constructively. Remember that we’re different. The strength of Faker Javascript comes from its varied community, people from a wide range of backgrounds. Different people have different perspectives on issues. Being unable to understand why someone holds a viewpoint doesn’t mean that they’re wrong. Don’t forget that it is human to err and blaming each other doesn’t get us anywhere. Instead, focus on helping to resolve issues and learning from mistakes.

*Credits for the sources and inspiration of this code of conduct go to the [Speak Up! project.](http://web.archive.org/web/20141109123859/http://speakup.io/coc.html)*
58 changes: 58 additions & 0 deletions .github/COMMIT_CONVENTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Git Commit Message Convention
We have very precise rules over how our git commit messages can be formatted. This leads to more readable messages that are easy to follow when looking through the project history.

## Commit Message Format
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
format that includes a **type**, a **scope** and a **subject**:

```
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```

The **header** is mandatory and the **scope** of the header is optional.

Any line of the commit message cannot be longer 72 characters! This allows the message to be easier
to read on GitHub as well as in various git tools.

The footer should contain a [closing reference to an issue](https://help.github.com/articles/closing-issues-via-commit-messages/) if any.

Samples: (even more [samples](https://github.com/faker-javascript/house/commits/master))

### Revert
If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.

### Type
The type of the made changes. Should be one of:
* **feat** - some feature development
* **fix** - bug fix
* **docs** - changes in documentation
* **style** - changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
* **perf**: A code change that improves performance
* **refactor** - changes those do not fix a bug or implement a feature. Simple refactoring
* **test** - adding missing tests or correcting existing tests
* **chore** - any other changes, not affecting code
* **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)

### Scope
The scope could be anything specifying the place of the commit change. For example core, docs, etc...

### Subject
The subject contains a succinct description of the change:

* use the imperative, present tense: "change" not "changed" nor "changes"
* don't capitalize the first letter
* no dot (.) at the end

### Body
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
The body should include the motivation for the change and contrast this with previous behavior.

### Footer
The footer should contain any information about **Breaking Changes** and is also the place to
reference GitHub issues that this commit **Closes**.

**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms

patreon: awilum
custom: ['https://paypal.me/awilum']
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: CI
on: ['push', 'pull_request']
jobs:
test:
name: Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [^12, ^14, ^16, ^17]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Global
node_modules/
coverage
package-lock.json

# OS Generated
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
*.swp

# phpstorm
.idea/*
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a name="1.0.0"></a>
# [1.0.0](https://github.com/faker-javascript/house) (2022-01-30)
* Initial release
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) Sergey Romanenko

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.
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,46 @@
# house
<h1 align="center">House</h1>
<p align="center">House package provides functionality to generate a fake house value.</p>

<p align="center">
<a href="https://github.com/faker-javascript/house/releases"><img alt="Version" src="https://img.shields.io/github/release/faker-javascript/house.svg?label=version&color=green"></a> <img src="https://img.shields.io/npm/dt/@fakerjs/house"> <img alt="node-current" src="https://img.shields.io/node/v/@fakerjs/house"> <a href="https://github.com/faker-javascript/house/actions/workflows/ci.yml"><img src="https://github.com/faker-javascript/house/actions/workflows/ci.yml/badge.svg"></a> <a href="https://github.com/faker-javascript/house"><img src="https://img.shields.io/badge/license-MIT-blue.svg?color=green" alt="License"></a>
</p>

## Install

npm
```
npm install @fakerjs/house --save-dev
```

yarn
```
yarn add @fakerjs/house -D
```

## Usage

```js
import house from '@fakerjs/house';

house({locale: 'en_US'}).room();
//=> kitchen
// Allowed locale: en_US

house().room();
//=> kitchen

house().furniture();
//=> chair
```

## Tests

Run tests

```
npm run test
```

## License
[The MIT License (MIT)](https://github.com/faker-javascript/house/blob/master/LICENSE)
Copyright (c) [Sergey Romanenko](https://github.com/Awilum)
13 changes: 13 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
interface Options {
locale?: string;
}
type Items = Record<string, string>;
declare class House {
rooms: Items;
furnitures: Items;
defaultLocale: string;
room(): string;
furniture(): string;
_selectRandom(items: Items): string;
}
export default function house(options?: Options): House;
34 changes: 34 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import path from 'node:path';
import fs from 'node:fs';
import {loadJsonFileSync} from 'load-json-file';

class House {
furnitures = {};
rooms = {};
defaultLocale = 'en_US';
options = {};

constructor(options) {
this.options = options || {};
const furnitureFilePath = `./locales/${this.options.locale || this.defaultLocale}/furniture.json`;
const roomFilePath = `./locales/${this.options.locale || this.defaultLocale}/room.json`;
this.furnitures = fs.existsSync(path.resolve(furnitureFilePath)) ? loadJsonFileSync(furnitureFilePath) : loadJsonFileSync(path.resolve('node_modules/@fakerjs/house/', furnitureFilePath));
this.rooms = fs.existsSync(path.resolve(roomFilePath)) ? loadJsonFileSync(roomFilePath) : loadJsonFileSync(path.resolve('node_modules/@fakerjs/house/', roomFilePath));
}

_selectRandom(items) {
return items[Math.floor(Math.random() * items.length)];
}

furniture() {
return this._selectRandom(this.furnitures);
}

room() {
return this._selectRandom(this.rooms);
}
}

export default function house(options) {
return new House(options);
}
6 changes: 6 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {expectType} from 'tsd';
import house from './index.js';

expectType<string>(house({locale: 'en_US'}).room());
expectType<string>(house().room());
expectType<string>(house().furniture());
17 changes: 17 additions & 0 deletions locales/en_US/furniture.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
"chair",
"armchair",
"table",
"dining table",
"stool",
"sofa",
"couch",
"bath",
"bed",
"cupboard",
"drawers",
"dresser",
"floor lamp",
"bedside table",
"futon"
]
19 changes: 19 additions & 0 deletions locales/en_US/room.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
"kitchen",
"living room",
"reception room",
"bedroom",
"master bedroom",
"guest room",
"drawing room",
"conservatory",
"porch",
"hallway",
"pantry",
"sunroom",
"bathroom",
"ensuite bathroom",
"cellar",
"attic",
"loft"
]
Loading

0 comments on commit f269062

Please sign in to comment.