From 8e97584ae7c352f0908f709fddc4856506840d1f Mon Sep 17 00:00:00 2001 From: Tony <97451137+TonybynMp4@users.noreply.github.com> Date: Thu, 17 Oct 2024 08:13:14 +0200 Subject: [PATCH] feat: github files --- .editorconfig | 9 ++ .github/CODE_OF_CONDUCT.md | 73 +++++++++++++++++ .github/FUNDING.yml | 2 +- .github/ISSUE_TEMPLATE/bug_report.yml | 62 ++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.yml | 32 ++++++++ .github/actions/bump-manifest-version.js | 15 ++++ .github/contributing.md | 95 ++++++++++++++++++++++ .github/pull_request_template.md | 10 +++ .github/workflows/lint.yml | 23 ++++++ .github/workflows/release-action.yml | 57 +++++++++++++ .github/workflows/release.yml | 42 ++++++++++ .vscode/extensions.json | 8 ++ .vscode/settings.json | 12 +++ 13 files changed, 439 insertions(+), 1 deletion(-) create mode 100644 .editorconfig create mode 100644 .github/CODE_OF_CONDUCT.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/actions/bump-manifest-version.js create mode 100644 .github/contributing.md create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/release-action.yml create mode 100644 .github/workflows/release.yml create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9c97eb2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = false +indent_style = space +charset = utf-8 +trim_trailing_whitespace = true +indent_size = 4 diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..7d53132 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,73 @@ +# Contributor Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, race, +religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team in the discord at https://discord.gg/Z6Whda5hHA. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 66bcef0..f6d774f 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -ko_fi: ynot_ +ko_fi: ynot_ diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..7ae18dd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,62 @@ +name: Bug report +description: Create a report to help us improve or fix something +labels: ['bug', 'need repro'] +body: + - type: markdown + attributes: + value: | + Thank you for taking the time to fill out a bug report! + - type: input + id: summary + attributes: + label: Summary + description: Write a short and concise description of your bug. + validations: + required: true + - type: textarea + id: repro + attributes: + label: Reproduction + description: What did you do to make this happen? + placeholder: | + 1. Using ... + 2. Do ... + 3. Then use ... + 4. See error + validations: + required: true + - type: textarea + id: expected + attributes: + label: Expected behavior + description: What did you expect to happen? + validations: + required: true + - type: textarea + id: actual + attributes: + label: Actual behavior + description: What actually happened? + validations: + required: true + - type: textarea + id: additional + attributes: + label: Additional context + description: If you have any other context about the problem such as screenshots or videos, add them here. + - type: input + id: updated + attributes: + label: Current Version + description: What version of the resource are you currently using? + placeholder: e.g. v1.3.0, v1.4.0 + validations: + required: true + - type: input + id: custom + attributes: + label: Custom Resources + description: Are you using custom resources? Which ones? + placeholder: e.g. zdiscord, qtarget + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..830026f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,32 @@ +name: Feature request +description: Suggest an idea for this resource +labels: enhancement +body: + - type: textarea + id: problem + attributes: + label: The problem + description: A clear and concise description of what the problem is, or what feature you want to be implemented. + placeholder: | + Some examples: + I'm frustrated that ... + It would be nice if ... + validations: + required: true + - type: textarea + id: solution + attributes: + label: Ideal solution + description: A clear and concise description of what you want to happen, with as much detail as possible. + validations: + required: true + - type: textarea + id: alternatives + attributes: + label: Alternative solutions + description: A clear and concise description of any alternative solutions or features you've considered. + - type: textarea + id: additional + attributes: + label: Additional context + description: If you have any other context about the problem such as screenshots or videos, add them here. diff --git a/.github/actions/bump-manifest-version.js b/.github/actions/bump-manifest-version.js new file mode 100644 index 0000000..2980cfc --- /dev/null +++ b/.github/actions/bump-manifest-version.js @@ -0,0 +1,15 @@ +const fs = require('fs') + +const version = process.env.TGT_RELEASE_VERSION +const newVersion = version.replace('v', '') + +const manifestFile = fs.readFileSync('fxmanifest.lua', {encoding: 'utf8'}) + +const versionStr = `version '${newVersion}'` +let newFileContent = manifestFile.replace(/\bversion\s+(.*)$/gm, versionStr) + +if (!newFileContent.includes(versionStr)) { + newFileContent = manifestFile.replace(/\bgame\s+(.*)$/gm, `game 'gta5'\n${versionStr}`); +} + +fs.writeFileSync('fxmanifest.lua', newFileContent) \ No newline at end of file diff --git a/.github/contributing.md b/.github/contributing.md new file mode 100644 index 0000000..2661332 --- /dev/null +++ b/.github/contributing.md @@ -0,0 +1,95 @@ +# Contributing to Ybox + +Thank you for taking the time to contribute! + +These guidelines will help you help us in the best way possible regardless of your skill level. We ask that you try to read everything related to the way you'd like to contribute and try and use your best judgement for anything not covered. + +Make sure to also read our [Contributor Code of Conduct](./CODE_OF_CONDUCT.md). + +## Issues + +Open a new issue to report a bug or request a new feature or improvement. + +Before opening a new issue: + +- [Search](https://github.com/issues?q=is%3Aissue+org%3AYbox-Project) for existing issues; maybe someone else already experienced the same problem that you're having! Duplicate issues will be closed. +- Download the latest release of the resource you are opening the issue for to make sure that it wasn't already fixed. Issues that are already fixed are considered invalid and will be closed. + +When opening a new issue, make sure to pick the right type of form and fill it out. The more information you provide, the easier it will be for us to work on your new issue. Issues that are invalid or do not follow the correct form may be ignored or even closed. + +## Pull Requests + +Open a new pull request to contribute code. + +You can use your own editor of choice, but we recommend using [VSCode](https://code.visualstudio.com/) with these extensions: + +- [GitLens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens) +- [Lua Language Server](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) +- [EditorConfig](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig) +- [CfxLua IntelliSense](https://marketplace.visualstudio.com/items?itemName=overextended.cfxlua-vscode) + +If you are new to contributing code, you can check out and try to fix issues marked with [`good first issue`](https://github.com/issues?q=is%3Aissue+is%3Aopen+org%3AYbox-Project+label%3A%22good+first+issue%22). + +If you want to contribute code but don't know what to do, please check out issues marked with [`help wanted`](https://github.com/issues?q=is%3Aissue+is%3Aopen+org%3AYbox-Project+label%3A%22help+wanted%22) as those are issues that we actually *need* help with. + +If you want to contribute code unrelated to an existing issue, you should open an issue yourself to discuss it before working on it, especially if you are planning on adding new features or large designs. + +Before opening a pull request: + +- Make sure that your contribution fits our [code conventions](#code-conventions) described below. After opening a pull request your code will be checked according to them. +- Make sure that your pull request is small and focused. Break it into multiple smaller pull requests if not (see [Small Pull Request Manifesto](https://github.com/PlaytikaOSS/small-pull-request-manifesto)). +- It is recommended to test your changes to make sure they work and don't break existing functionality. + +When opening a pull request, make sure to follow the template and explain your changes. If you are trying to contribute something related to a GitHub issue, make sure to mention it as well. + +## Code Conventions + +Below are conventions that you must follow when contributing code. + +### Commit Message Conventions + +- The first line of a commit message must be 72 characters at most. +- Commit messages and pull request titles must follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). + - Use `fix:` when patching a bug. + - Use `feat:` when introducing a new feature. + - Use `refactor:` when altering code without changing functionality. + - Use `chore:` when your changes don't alter production code. + - Append a `!` after the type/scope of the feature when you change code and introduce a breaking API change. Optionally add a footer to the bottom of your commit message separated by 2 newlines, starting with `BREAKING CHANGE:`, and explaining the breaking change. + +### Lua Conventions + +#### General Style + +- Use 4 space indentation. +- Prefer creating local variables over global ones. +- Don't repeat yourself. If you're using the same operations in multiple different places convert them into a flexible function. +- Exported functions must be properly annotated (see [LuaLS Annotations](https://luals.github.io/wiki/annotations/)). +- Utilize [ox_lib](https://overextended.dev/ox_lib) to make your life easier. Prefer lib calls over native ones. +- Make use of config options where it makes sense to make features optional and/or customizable. Configs should not be modified by other code. + +#### Optimization & Security + +- Consider [this Lua Performance guide](https://springrts.com/wiki/Lua_Performance). +- Don't create unnecessary threads. Always try to find a better method of triggering events. +- Set longer `Wait` calls in distance checking loops when the player is out of range. +- Don't waste cycles; job specific loops should only run for players with that job. +- When possible don't trust the client, *especially* with transactions. +- Balance security and optimizations. +- Use `#(vector3 - vector3)` instead of `GetDistanceBetweenCoords()`. +- Use `myTable[#myTable + 1] = 'value'` instead of `table.insert(myTable, 'value')`. +- Use `myTable['key'] = 'value'` instead of `table.insert(myTable, 'key', 'value')`. + +#### Naming + +- Use `camelCase` for local variables and functions. +- Use `PascalCase` for global variables and functions. +- Avoid acronyms as they can be confusing and context dependant. +- Be descriptive; make it easy for the reader. + - Booleans may be prefixed with `is`, `has`, `are`, etc. + - Arrays should have plural names. + +### JavaScript/TypeScript Conventions + +Consider following the [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html) and the [Google TypeScript Style Guide](https://google.github.io/styleguide/tsguide.html). + +[discord link]: https://discord.gg/Z6Whda5hHA diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..29e5361 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,10 @@ +## Description + + + +## Checklist + + + +- [ ] I have personally loaded this code into an updated Qbox project and checked all of its functionality. +- [ ] My pull request fits the contribution guidelines & code conventions. diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..d19aba5 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,23 @@ +name: Lint +on: [push, pull_request_target] +jobs: + lint: + name: Lint Resource + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Lint + uses: iLLeniumStudios/fivem-lua-lint-action@v2 + with: + capture: "junit.xml" + args: "-t --formatter JUnit" + extra_libs: ox_lib+mysql+qblocales+qbox+qbox_playerdata+qbox_lib + - name: Generate Lint Report + if: always() + uses: mikepenz/action-junit-report@v4 + with: + report_paths: "**/junit.xml" + check_name: Linting Report + fail_on_failure: false diff --git a/.github/workflows/release-action.yml b/.github/workflows/release-action.yml new file mode 100644 index 0000000..28c6169 --- /dev/null +++ b/.github/workflows/release-action.yml @@ -0,0 +1,57 @@ +name: "release-action" + +on: + push: + tags: + - "v*" + +jobs: + release-action: + name: "Create Release" + runs-on: "ubuntu-latest" + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.repository.default_branch }} + + - name: Install ZIP + run: sudo apt install zip + + - name: Bundle files + run: | + rm -rf ./.github ./.git + shopt -s extglob + mkdir ./${{ github.event.repository.name }} + cp -r !(${{ github.event.repository.name }}) ${{ github.event.repository.name }} + zip -r ./${{ github.event.repository.name }}.zip ./${{ github.event.repository.name }} + + - name: Get App Token + uses: actions/create-github-app-token@v1 + id: generate_token + with: + app-id: ${{ secrets.APP_ID }} + private-key: ${{ secrets.PRIVATE_KEY }} + + - name: Update CHANGELOG + id: changelog + uses: requarks/changelog-action@v1 + with: + token: ${{ steps.generate_token.outputs.token }} + tag: ${{ github.ref_name }} + includeInvalidCommits: true + useGitmojis: false + writeToFile: false + + - name: Create Release + uses: ncipollo/release-action@v1.14.0 + with: + allowUpdates: true + draft: false + makeLatest: true + name: ${{ github.ref_name }} + tag: ${{ github.ref_name }} + body: ${{ steps.changelog.outputs.changes }} + artifacts: ${{ github.event.repository.name }}.zip + token: ${{ steps.generate_token.outputs.token }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f5cc276 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,42 @@ +name: Create New Release + +on: + workflow_dispatch: + inputs: + version: + required: true + +jobs: + create-release: + name: Create New Release + runs-on: ubuntu-latest + steps: + - name: Get App Token + uses: actions/create-github-app-token@v1 + id: generate_token + with: + app-id: ${{ secrets.APP_ID }} + private-key: ${{ secrets.PRIVATE_KEY }} + + - name: Checkout Repository + uses: actions/checkout@v4 + with: + token: ${{ steps.generate_token.outputs.token }} + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Bump manifest version + run: node .github/actions/bump-manifest-version.js + env: + TGT_RELEASE_VERSION: ${{ inputs.version }} + + - name: Push manifest change + uses: EndBug/add-and-commit@v9 + with: + add: fxmanifest.lua + push: true + message: 'chore: bump manifest version to ${{ inputs.version }}' + tag: ${{ inputs.version }} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..5de9729 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "sumneko.lua", + "overextended.cfxlua-vscode", + "ihyajb.qbcore-code-snippets", + "EditorConfig.EditorConfig", + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f56fbb6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,12 @@ +{ + "Lua.runtime.nonstandardSymbol": ["/**/", "`", "+=", "-=", "*=", "/="], + "Lua.runtime.version": "Lua 5.4", + "Lua.diagnostics.globals": [ + "lib", + "cache", + "locale", + "MySQL", + "QBX", + "qbx" + ] +}