Skip to content

Commit

Permalink
Merge branch 'master' into errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Kathund committed Oct 7, 2024
2 parents 3592c0f + de55e9f commit fc75b55
Show file tree
Hide file tree
Showing 247 changed files with 22,322 additions and 4,869 deletions.
9 changes: 5 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

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

[*.{md,markdown}]
trim_trailing_whitespace = false
insert_final_newline = false
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
HYPIXEL_KEY=HYPIXEL_API_KEY
79 changes: 79 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Contributing

If you want to contribute to hypixel-api-reborn, feel free to fork the repository and submit pull request.

## Table of contents

- [Requirements](#requirements)
- [Project Setup](#project-setup)
- [Testing your changes](#testing-your-changes)
- [Submitting a pull request](#submitting-a-pull-request)
- [Common issues](#common-issues)

### Requirements

- [Node v20.16.0 or higher](https://nodejs.org/en/learn/getting-started/how-to-install-nodejs)
- [pnpm v9.7.1 or higher](https://pnpm.io/installation)

### Project Setup

Once you have the requirements installed, you can clone the repository and install the dependencies.

```bash
pnpm install
```

Once you have all the packages installed, you will need to create a `.env` file. This file will contain the Hypixel API
key. You can get one by going to the [Hypixel Developer Portal.](https://developer.hypixel.net/) This key will be used
in the tests. Your `.env` file should look like this:

```env
HYPIXEL_KEY=HYPIXEL_API_KEY
```

**If your using vscode** With vscode we have a few recommended extensions that you can install to help with development.
You will be promoted to install these when you open the project in vscode. If you don't see the prompt, you can install
the extensions manually. Here are the recommended extensions:

- [Editor Config](https://marketplace.visualstudio.com/items?itemName=editorconfig.editorconfig)
- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
- [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
- [Gitlens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens)
- [Better Comments](https://marketplace.visualstudio.com/items?itemName=aaron-bond.better-comments)
- [Vitest](https://marketplace.visualstudio.com/items?itemName=vitest.explorer)
- [GitHub Pull Requests](https://marketplace.visualstudio.com/items?itemName=github.vscode-pull-request-github)

### Testing your changes

Before submitting a pull request, make sure to test your changes. You can run the tests with the following command:

```bash
pnpm test
```

### Submitting a pull request

When submitting a pull request, make sure to provide a detailed description of the changes you made. If you are adding a
new feature, make sure to include tests for it. If you are fixing a bug, make sure to include the bug report
information. When making a pull request we have a few requirements:

- Tests must pass (`pnpm test`)
- Code must be linted (`pnpm lint`)
- Code must be formatted (`pnpm prettier`)
- A clear and detailed description of the changes that you have done
- Checkboxes for the changes you made
- Screenshots of the code running (if applicable)

### Common issues

There are a few common issues that can come up when contributing to the project. Here are a few of them:

- **Tests failing**: Tests will fail when making a pull request. This is because it's missing an API key set in github
actions. If this is the case, you can ignore the tests and someone will run them for you when reviewing the pull
request.

- **Code formatting**: Code must be formatted and the github actions will check for this. If the code is not formatted,
the github action will fail and you will need to correct this before the pull request can be merged.

- **Code using npm**: Any code that includes an npm lock file will not be accepted. This is because we use pnpm for
package management. If you have an npm lock file, you will need to remove it and use pnpm to install the packages.
13 changes: 11 additions & 2 deletions .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,14 @@ about: Report a bug

### Bug report

- Part of code where error occurred
- What error occurred
- Part of code where error occurred:
- What error occurred:

### Expected behavior

- What you expected to happen:

### Additional context

- Node version:
- Package version:
9 changes: 4 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
<details>
<summary>Checkboxes</summary>

- [x] I've added new features. (methods or parameters)
- [ ] I've added jsdoc and typings.
- [ ] I've added new features. (methods or parameters)
- [ ] I've fixed bug. (_optional_ you can mention a issue if there is one)
- [ ] I've corrected the spelling in README, documentation, etc.
- [ ] I've tested my code. (`npm run tests`)
- [ ] I've check for issues. (`npm run eslint`)
- [ ] I've fixed my formatting. (`npm run prettier`)
- [ ] I've tested my code. (`pnpm test`)
- [ ] I've check for issues. (`pnpm lint`)
- [ ] I've fixed my formatting. (`pnpm prettier`)

</details>
2 changes: 1 addition & 1 deletion .github/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ be no issue and the team will be greatful for your actions.
To report a vulnerability you can do so in the [Discord Server](https://discord.gg/NSEBNMM) by openeing a support ticket
or you can contact the primary contributor of this repository using the following contact methods:

- @kathund. on Discord
- @.kathund on Discord
- @kathundd on Telegram
54 changes: 54 additions & 0 deletions .github/checkCoverage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { parseString } from 'xml2js';
import { readFile } from 'fs';

function parseXMLFile(): Promise<any> {
return new Promise((resolve, reject) => {
readFile('.github/coverageData.xml', 'utf8', (err, data) => {
if (err) {
reject('File Dose not exist!');
return;
}

parseString(data, (err, result) => {
if (err) {
reject('Something Went wrong!');
return;
}

resolve(result);
});
});
});
}

const data = await parseXMLFile();
const codeStats = data.coverage.project[0].metrics[0].$;
const info = {
statements: Number(codeStats.statements),
coveredstatements: Number(codeStats.coveredstatements),
conditionals: Number(codeStats.conditionals),
coveredconditionals: Number(codeStats.coveredconditionals),
methods: Number(codeStats.methods),
coveredmethods: Number(codeStats.coveredmethods)
};

if (95 > (info.coveredstatements / info.statements) * 100) {
throw new Error('Statements is required to be 95% or higher');
}

if (95 > (info.coveredconditionals / info.conditionals) * 100) {
throw new Error('Conditionals is required to be 95% or higher');
}

if (95 > (info.coveredmethods / info.methods) * 100) {
throw new Error('Methods is required to be 95% or higher');
}

if (
95 >
((info.coveredstatements + info.coveredconditionals + info.coveredmethods) /
(info.statements + info.conditionals + info.methods)) *
100
) {
throw new Error('Everythng Combinded is required to be 95% or higher');
}
1 change: 1 addition & 0 deletions renovate.json → .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"assignees": ["kathund"],
"reviewers": ["kathund"],
"schedule": "before 5am every weekday",
"ignoreDeps": ["pnpm", "node"],
"npm": {
"rangeStrategy": "bump",
"packageRules": [
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,10 @@ jobs:
- name: Check tests
env:
HYPIXEL_KEY: ${{ secrets.HYPIXEL_KEY }}
run: pnpm test
run: pnpm test:coverage

- name: Move Coverage Data
run: mv coverage/clover.xml .github/coverageData.xml

- name: Check Coverage
run: npx tsx .github/checkCoverage.ts
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ oldreborn/
dist/
.eslintcache
coverage/
.github/coverageData.xml
4 changes: 2 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
node_modules/
oldreborn/
.env
dist/
.eslintcache
.git
.gitignore
coverage/
coverage/
.github/coverageData.xml
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"esbenp.prettier-vscode",
"eamodio.gitlens",
"aaron-bond.better-comments",
"vitest.explorer"
"vitest.explorer",
"github.vscode-pull-request-github"
]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.tabSize": 2,
"prettier.useTabs": false,
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"editor.trimAutoWhitespace": true
}
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
<div align="center">
<img src="https://i.imgur.com/cDFoQZU.png?1">
<h1>Hypixel API • Reborn</h1>
<a href="https://discord.gg/NSEBNMM"><img src="https://discordapp.com/api/guilds/660416184252104705/embed.png"></a>
<a href="https://travis-ci.org/StavZ/hypixel-api-reborn"><img src="https://flat.badgen.net/travis/hypixel-api-reborn/hypixel-api-reborn"></a>
<a href="https://app.codacy.com/gh/Hypixel-API-Reborn/hypixel-api-reborn?utm_source=github.com&utm_medium=referral&utm_content=Hypixel-API-Reborn/hypixel-api-reborn&utm_campaign=Badge_Grade"><img src="https://flat.badgen.net/codacy/grade/71cd7e95499b496cb2dd11c29b9def33/master"></a>
<img src="https://flat.badgen.net/npm/v/hypixel-api-reborn">
<img src="https://flat.badgen.net/npm/node/hypixel-api-reborn">
<img src="https://flat.badgen.net/npm/license/hypixel-api-reborn">
<a href="https://github.com/Hypixel-API-Reborn/hypixel-api-reborn"><img src="https://flat.badgen.net/github/stars/hypixel-api-reborn/hypixel-api-reborn"></a>
<a href="https://www.npmjs.com/package/hypixel-api-reborn"><img src="https://nodei.co/npm/hypixel-api-reborn.png?compact=true"></a>
<h2>A feature-rich Hypixel API wrapper for Node.js</h2>
<br>
</div>

### Links

[Discord Support](https://discord.gg/NSEBNMM) | [Documentation](https://hypixel-api-reborn.github.io/) |
[NPM](https://www.npmjs.com/package/hypixel-api-reborn) |
[GitHub](https://github.com/Hypixel-API-Reborn/hypixel-api-reborn) |

#### Requirements

**For Node.js users >= v20.16.0** <br> **For TypeScript users >= v5.5.4**

### Installation & Usage

```shell
npm i hypixel-api-reborn@next
```

**Do note that you are installing a beta version of v12.0.0.** Any issues or bugs you encounter, please report them in
the [Discord Support](https://discord.gg/NSEBNMM).
8 changes: 7 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import globals from 'globals';
import prettier from 'eslint-config-prettier';
import sortImports from '@j4cobi/eslint-plugin-sort-imports';
import ts from 'typescript-eslint';
import globals from 'globals';

export default [
...ts.configs.recommended,
Expand All @@ -15,7 +16,12 @@ export default [
...globals.node
}
},
plugins: { 'sort-imports': sortImports },
rules: {
'sort-imports/sort-imports': [
'error',
{ ignoreCase: false, ignoreMemberSort: false, memberSyntaxSortOrder: ['all', 'single', 'multiple', 'none'] }
],
'max-len': ['error', { code: 120, ignoreUrls: true, ignoreComments: true }],
'@typescript-eslint/no-unused-vars': ['error', { args: 'none' }],
'no-constant-condition': ['error', { checkLoops: false }],
Expand Down
46 changes: 27 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "hypixel-api-reborn",
"version": "12.0.0",
"version": "12.0.0-4",
"description": "Feature-rich Hypixel API wrapper for Node.js",
"main": "./src/index.ts",
"types": "./src/typings/index.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "dist/index.js",
"keywords": [
"minecraft",
"client",
Expand All @@ -22,40 +23,47 @@
"prettier": "npx prettier --write src/",
"build": "npx tsc",
"test": "npx vitest run",
"test:coverage": "npx vitest --ui --coverage"
"test:coverage": "npx vitest run --coverage && mv coverage/clover.xml .github/coverageData.xml && npx tsx .github/checkCoverage.ts",
"test:ui": "npx vitest --ui --coverage"
},
"engines": {
"node": ">=20.17.0"
"node": ">=20.16.0"
},
"type": "module",
"packageManager": "[email protected]",
"author": "Kathund",
"dependencies": {
"axios": "^1.7.5",
"farming-weight": "^0.5.0",
"node-cache": "^5.1.2",
"prismarine-nbt": "^2.5.0",
"prismarine-nbt": "github:prismarinejs/prismarine-nbt#70323d8c7f771698a02f3f40aa676bcecc60c5e7",
"rss-parser": "^3.13.0",
"skyhelper-networth": "^1.24.0"
"skyhelper-networth": "^1.25.0"
},
"license": "MIT",
"readme": "https://github.com/Hypixel-API-Reborn/hypixel-api-reborn?tab=readme-ov-file#hypixel-api--reborn",
"repository": {
"url": "https://github.com/Hypixel-API-Reborn/hypixel-api-reborn"
"url": "git+https://github.com/Hypixel-API-Reborn/hypixel-api-reborn.git"
},
"files": [
"dist/**/*"
],
"publisher": "Kathund",
"devDependencies": {
"@eslint/js": "^9.9.1",
"@types/eslint": "^9.6.0",
"@vitest/coverage-v8": "^2.0.5",
"@vitest/ui": "^2.0.5",
"@eslint/js": "^9.12.0",
"@j4cobi/eslint-plugin-sort-imports": "^1.0.2",
"@types/eslint": "^9.6.1",
"@types/node": "^20.16.10",
"@types/xml2js": "^0.4.14",
"@vitest/coverage-v8": "^2.1.2",
"@vitest/ui": "^2.1.2",
"dotenv": "^16.4.5",
"@types/node": "^20.16.1",
"eslint": "^9.9.1",
"eslint": "^9.12.0",
"eslint-config-prettier": "^9.1.0",
"globals": "^15.9.0",
"globals": "^15.10.0",
"prettier": "^3.3.3",
"typescript": "^5.5.4",
"typescript-eslint": "^8.2.0",
"vitest": "^2.0.5"
"typescript": "^5.6.2",
"typescript-eslint": "^8.8.0",
"vitest": "^2.1.2",
"xml2js": "^0.6.2"
}
}
Loading

0 comments on commit fc75b55

Please sign in to comment.