{"id":26655620,"url":"https://github.com/gramiojs/autoload","last_synced_at":"2025-04-11T09:37:58.520Z","repository":{"id":226957531,"uuid":"770066574","full_name":"gramiojs/autoload","owner":"gramiojs","description":"Autoload commands plugin for GramIO","archived":false,"fork":false,"pushed_at":"2025-01-01T19:09:34.000Z","size":111,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-25T06:36:33.217Z","etag":null,"topics":["autoload","gramio","gramio-plugin","telegram","telegram-api","telegram-bot-api"],"latest_commit_sha":null,"homepage":"https://gramio.netlify.app/plugins/official/autoload.html","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gramiojs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-10T20:26:32.000Z","updated_at":"2025-01-01T19:09:37.000Z","dependencies_parsed_at":"2024-03-10T20:31:49.917Z","dependency_job_id":"6167f983-af5d-403c-82e7-42fab6887eab","html_url":"https://github.com/gramiojs/autoload","commit_stats":null,"previous_names":["gramiojs/autoload"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gramiojs%2Fautoload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gramiojs%2Fautoload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gramiojs%2Fautoload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gramiojs%2Fautoload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gramiojs","download_url":"https://codeload.github.com/gramiojs/autoload/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248368744,"owners_count":21092446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autoload","gramio","gramio-plugin","telegram","telegram-api","telegram-bot-api"],"created_at":"2025-03-25T06:36:42.301Z","updated_at":"2025-04-11T09:37:58.480Z","avatar_url":"https://github.com/gramiojs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @gramio/autoload\n\n[![npm](https://img.shields.io/npm/v/@gramio/autoload?logo=npm\u0026style=flat\u0026labelColor=000\u0026color=3b82f6)](https://www.npmjs.org/package/@gramio/autoload)\n[![JSR](https://jsr.io/badges/@gramio/autoload)](https://jsr.io/@gramio/autoload)\n[![JSR Score](https://jsr.io/badges/@gramio/autoload/score)](https://jsr.io/@gramio/autoload)\n\nAutoload commands plugin for GramIO with [`Bun.build`](#bun-build-usage) support.\n\n## Usage\n\n\u003e [full example](https://github.com/gramiojs/autoload/tree/main/example)\n\n\u003e [!IMPORTANT]\n\u003e Please read about [Lazy-load plugins](https://gramio.dev/plugins/official/autoload.html)\n\n## Register the plugin\n\n```ts\n// index.ts\nimport { Bot } from \"gramio\";\nimport { autoload } from \"@gramio/autoload\";\n\nconst bot = new Bot(process.env.TOKEN as string)\n    .extend(await autoload())\n    .onStart(console.log);\n\nbot.start();\n\nexport type BotType = typeof bot;\n```\n\n## Create command\n\n```ts\n// commands/command.ts\nimport type { BotType } from \"..\";\n\nexport default (bot: BotType) =\u003e\n    bot.command(\"start\", (context) =\u003e context.send(\"hello!\"));\n```\n\n## Options\n\n| Key               | Type                                                                                               | Default                    | Description                                                               |\n| ----------------- | -------------------------------------------------------------------------------------------------- | -------------------------- | ------------------------------------------------------------------------- |\n| pattern?          | string \\| string[]                                                                                 | \"\\*\\*\\/\\*.{ts,js,cjs,mjs}\" | [Glob patterns](\u003chttps://en.wikipedia.org/wiki/Glob_(programming)\u003e)       |\n| path?             | string                                                                                             | \"./commands\"               | Path to the folder                                                        |\n| import?           | string \\| (file: any) =\u003e string                                                                    | \"default\"                  | Import a specific `export` from a file                                    |\n| failGlob?         | boolean                                                                                            | true                       | Throws an error if no matches are found                                   |\n| skipImportErrors? | boolean                                                                                            | false                      | Skip imports where needed `export` not defined                            |\n| onLoad?           | (params: { absolute: string; relative: string }) =\u003e unknown                                        |                            | Hook that is called when loading a file                                   |\n| onFinish?         | (paths: { absolute: string; relative: string }[]) =\u003e unknown;                                      |                            | Hook that is called after loading all files                               |\n| fdir?             | [Options](https://github.com/thecodrr/fdir/blob/HEAD/documentation.md#method-chaining-alternative) |                            | Options to configure [fdir](https://github.com/thecodrr/fdir)             |\n| picomatch?        | [PicomatchOptions](https://github.com/micromatch/picomatch?tab=readme-ov-file#picomatch-options)   |                            | Options to configure [picomatch](https://www.npmjs.com/package/picomatch) |\n\n### [Bun build](https://bun.sh/docs/bundler) usage\n\nYou can use this plugin with [`Bun.build`](https://bun.sh/docs/bundler), thanks to [esbuild-plugin-autoload](https://github.com/kravetsone/esbuild-plugin-autoload)!\n\n```ts\n// @filename: build.ts\nimport { autoload } from \"esbuild-plugin-autoload\"; // default import also supported\n\nawait Bun.build({\n    entrypoints: [\"src/index.ts\"],\n    target: \"bun\",\n    outdir: \"out\",\n    plugins: [autoload(\"./src/commands\")],\n}).then(console.log);\n```\n\nThen, build it with `bun build.ts` and run with `bun out/index.ts`.\n\n### [Bun compile](https://bun.sh/docs/bundler/executables) usage\n\nYou can bundle and then compile it into a [single executable binary file](https://bun.sh/docs/bundler/executables)\n\n```ts\nimport { autoload } from \"esbuild-plugin-autoload\"; // default import also supported\n\nawait Bun.build({\n    entrypoints: [\"src/index.ts\"],\n    target: \"bun\",\n    outdir: \"out\",\n    plugins: [autoload(\"./src/commands\")],\n}).then(console.log);\n\nawait Bun.$`bun build --compile out/index.js`;\n```\n\n\u003e [!WARNING]\n\u003e You cannot use it in `bun build --compile` mode without extra step ([Feature issue](https://github.com/oven-sh/bun/issues/11895))\n\n[Read more](https://github.com/kravetsone/esbuild-plugin-autoload)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgramiojs%2Fautoload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgramiojs%2Fautoload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgramiojs%2Fautoload/lists"}