Giter Site home page Giter Site logo

sapphiredev / pieces Goto Github PK

View Code? Open in Web Editor NEW
19.0 19.0 12.0 14.3 MB

Piece loader for @sapphire/framework

Home Page: https://www.sapphirejs.dev/

License: MIT License

TypeScript 98.65% JavaScript 1.35%
discord discord-js hacktoberfest pieces sapphire sapphire-framework sapphire-piece-loader

pieces's Introduction

Sapphire Logo

Sapphire Dev

GitHub app for Sapphire

GitHub

Description

The GitHub app that we use in Sapphire for automating various tasks.

Usage

Setup

# Install dependencies
yarn install

You will need to configure the Wrangler secrets for Cloudflare Workers environment. You will need the following secrets:

  • APP_ID

  • WEBHOOK_SECRET

  • PRIVATE_KEY

The private-key.pem file from GitHub needs to be transformed from the PKCS#1 format to PKCS#8, as the crypto APIs do not support PKCS#1:

openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in private-key.pem -out private-key-pkcs8.pem

Then set the private key

cat private-key-pkcs8.pem | wrangler secret put PRIVATE_KEY

For information on what these values are and how to get them see this guide

Buy us some doughnuts

Sapphire Community is and always will be open source, even if we don't get donations. That being said, we know there are amazing people who may still want to donate just to show their appreciation. Thank you very much in advance!

We accept donations through Open Collective, Ko-fi, Paypal, Patreon and GitHub Sponsorships. You can use the buttons below to donate through your method of choice.

Donate With Address
Open Collective Click Here
Ko-fi Click Here
Patreon Click Here
PayPal Click Here

Contributors

Please make sure to read the Contributing Guide before making a pull request.

Thank you to all the people who already contributed to Sapphire!

pieces's People

Contributors

allcontributors[bot] avatar dependabot[bot] avatar depfu[bot] avatar favna avatar hblomqvist avatar kyranet avatar leonardssh avatar lioness100 avatar quantumlyy avatar qyurila avatar r-priyam avatar realshadownova avatar renovate[bot] avatar soumil-07 avatar stitch07 avatar vladfrangu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pieces's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (github>sapphiredev/readme:sapphire-renovate)

bug: incorrect implementation

Describe the bug
The LoaderStrategy class doesn't implement it's counter interface on the onLoad, onUnload, onLoadAll and onUnloadAll methods.

To Reproduce

  1. Check the typings while extending LoaderStrategy
  2. You won't see the parameters as expected from ILoaderStrategy

Expected behavior
You won't see the parameters as expected from ILoaderStrategy

Screenshots
I will tomorrow, this is an express issue. Gotta sleep. I'll update you tomorrow.

Additional context

  • Using ST 4
  • Node v16
  • NPM Latest

request: Bun Support

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

As the title says, basic bun support. Below is my patch for said implementation.
Ref: sapphiredev/framework#671

Desired solution

A very basic patch for bun support. This adds support for checking if the runtime is bun (in order to enable typescript imports) as well as throws out the old import and require methods in favor of Bun's native imports which handle everything on the backend.

This is a bun specific patch. Checks should be implemented to make sure the import method is only called when using bun.

@sapphire+pieces+3.10.0.patch

All this does is edit 3 lines in LoaderStrategy

Alternatives considered

Wait for Bun to release 1.0.15 for proper support or update to canary today and face unforeseen consequences.

Additional context

For those wanting to test it out, follow the steps below.

  1. Be on the latest canary version of Bun which supports fs.promise
  2. Add the patch to your patches folder in the root directory. If one doesn't exist, make one.
  3. package.json > scripts > "postinstall": "bunx patch-package"
  4. Install as normal with bun install

bug: ES Imports

Describe the bug

For some reason, I can't import named exports from pieces. It says it's a CJS module which was working fine like a month or two ago.

To Reproduce

  1. Import any named exports from pieces.
  2. Run it with node from a file.

Expected behavior

Node should throw an error why I needed to do a default import rather than a named import.

Screenshots

Additional context

2021-09-21T08:36:53.651404+00:00 app[worker.1]: file:///app/dist/lib/core/CoreGame.js:1
2021-09-21T08:36:53.651420+00:00 app[worker.1]: import { AliasPiece, AliasStore } from '@sapphire/pieces';
2021-09-21T08:36:53.651420+00:00 app[worker.1]:          ^^^^^^^^^^
2021-09-21T08:36:53.651430+00:00 app[worker.1]: SyntaxError: Named export 'AliasPiece' not found. The requested module '@sapphire/pieces' is a CommonJS module, which may not support all module.exports as named exports.
2021-09-21T08:36:53.651430+00:00 app[worker.1]: CommonJS modules can always be imported via the default export, for example using:
2021-09-21T08:36:53.651431+00:00 app[worker.1]: 
2021-09-21T08:36:53.651431+00:00 app[worker.1]: import pkg from '@sapphire/pieces';
2021-09-21T08:36:53.651431+00:00 app[worker.1]: const { AliasPiece, AliasStore } = pkg;
2021-09-21T08:36:53.651431+00:00 app[worker.1]: 
2021-09-21T08:36:53.651432+00:00 app[worker.1]:     at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
2021-09-21T08:36:53.651432+00:00 app[worker.1]:     at async ModuleJob.run (node:internal/modules/esm/module_job:179:5)
2021-09-21T08:36:53.651432+00:00 app[worker.1]:     at async Loader.import (node:internal/modules/esm/loader:178:24)
2021-09-21T08:36:53.651432+00:00 app[worker.1]:     at async Object.loadESM (node:internal/process/esm_loader:68:5)
2021-09-21T08:36:53.651433+00:00 app[worker.1]:     at async handleMainPromise (node:internal/modules/run_main:63:12)

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update dependency @types/node to ^20.14.9

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/auto-deprecate.yml
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/codeql-analysis.yml
  • actions/checkout v4
  • github/codeql-action v3
  • github/codeql-action v3
  • github/codeql-action v3
.github/workflows/continuous-delivery.yml
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/continuous-integration.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/deprecate-on-merge.yml
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/documentation.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/upload-artifact v4
  • actions/checkout v4
  • actions/setup-node v4
  • actions/download-artifact v4
  • actions/checkout v4
  • nick-fields/retry v3
.github/workflows/labelsync.yml
  • actions/checkout v4
  • crazy-max/ghaction-github-labeler v5
.github/workflows/publish.yml
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/release-crosspost.yml
  • kludge-cs/gitcord-release-changelogger v3.0.0@5592170408dc081d7cb6a74ce025911bd1fcb7c3
npm
package.json
  • @discordjs/collection ^1.5.3
  • @sapphire/utilities ^3.16.2
  • tslib ^2.6.3
  • @commitlint/cli ^19.3.0
  • @commitlint/config-conventional ^19.2.2
  • @favware/cliff-jumper ^4.0.2
  • @favware/npm-deprecate ^1.0.7
  • @favware/rollup-type-bundler ^3.3.0
  • @sapphire/eslint-config ^5.0.5
  • @sapphire/prettier-config ^2.0.0
  • @sapphire/ts-config ^5.0.1
  • @types/node ^20.14.8
  • concurrently ^8.2.2
  • cz-conventional-changelog ^3.3.0
  • esbuild-plugin-file-path-extensions ^2.1.2
  • eslint ^8.57.0
  • eslint-config-prettier ^9.1.0
  • eslint-plugin-prettier ^5.1.3
  • lint-staged ^15.2.7
  • prettier ^3.3.2
  • rimraf ^5.0.7
  • tsup ^8.1.0
  • vitest ^1.6.0
  • acorn ^8.12.0
  • ansi-regex ^5.0.1
  • minimist ^1.2.8
  • yarn 4.3.1

  • Check this box to trigger a request for Renovate to run again on this repository

bug: Bun not loading classes due to clientUsesESModules being set to false.

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

I'm using bun tu run my djs bot, however both listeners and commands aren't loaded. Because of a error:

error: A compatible class export was not found. [/home/username/Source/mybot/src/commands/other/say.ts]
 path: "/home/username/Source/mybot/src/commands/other/say.ts"
      at new _LoaderError (/home/username/Source/mybot/node_modules/@sapphire/pieces/dist/esm/lib/errors/LoaderError.mjs:14:5)
      at new _MissingExportsError (/home/username/Source/mybot/node_modules/@sapphire/pieces/dist/esm/lib/errors/MissingExportsError.mjs:6:5)
      at /home/username/Source/mybot/node_modules/@sapphire/pieces/dist/esm/lib/strategies/LoaderStrategy.mjs:71:13

I've debugged a bit and it looks like LoaderStrategy will import the file in the wrong way.

When I manually set the clientUsesESModules property to true it worked flawlessly.

Steps To Reproduce

  1. Use Bun to either load commands or listeners from .ts files
  2. Error on load

Expected behavior

For the framework to load the commands/listeners successfully

Screenshots

image
image

Additional context

No response

System Info

System:
    OS: Linux 6.5 Ubuntu 23.10 23.10 (Mantic Minotaur)
    CPU: (16) x64 AMD Ryzen 7 5700U with Radeon Graphics
    Memory: 9.46 GB / 14.94 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 21.0.0 - /usr/local/bin/node
    Yarn: 1.22.21 - /usr/local/bin/yarn
    npm: 10.1.0 - ~/.local/share/pnpm/npm
    pnpm: 8.15.3 - ~/.local/share/pnpm/pnpm
    bun: 1.1.6 - ~/.local/share/pnpm/bun

request: bun compat

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

it'd be nice if /pieces would run on bun, seems to be the only part that is having trouble

Desired solution

haven't looked alto much into it but it's probably somewhat related to the module resolution within pieces, since it complains about all paths being undefined/thing/module.js

Alternatives considered

nop

Additional context

https://adriancastro.dev/wujc8lds16bo.png

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.