Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

73 feature plugins #83

Merged
merged 30 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0d93d18
feat(#73): Base for plugins with test plugin
Mr-Artemus Sep 14, 2022
d6e471a
feat(#73): Switch from functions to service
Mr-Artemus Sep 16, 2022
274d90d
feat(#73): Plugins services & bot ready info
Mr-Artemus Sep 17, 2022
7f6330e
feat(#73): Support of `plugin.json`
Mr-Artemus Sep 17, 2022
76c8eeb
feat(#73): Optional plugin folder
Mr-Artemus Sep 19, 2022
c13dd28
feat(#73): NPM script to install plugins dependencies
Mr-Artemus Sep 19, 2022
c7c3278
feat(#73): Support for plugins .env
Mr-Artemus Sep 19, 2022
be9deb9
feat(#73): Support for plugins main.ts
Mr-Artemus Sep 19, 2022
4127617
feat(#73): Move `plugins` folder inside the `src` folder
Mr-Artemus Sep 19, 2022
76a2d58
feat(#73): Missing plugins folder
Mr-Artemus Sep 20, 2022
ffb0fdd
feat(#73): fix path in PluginsManager
Mr-Artemus Sep 24, 2022
29e11be
feat(#73):Edit ready to show plugins count
Mr-Artemus Sep 24, 2022
f6ea8e1
feat(#73): Load and unload plugin translations auto
Mr-Artemus Sep 26, 2022
4f4dcde
feat(#73):Force storeTranslationsToDisk when syncing translations
Mr-Artemus Sep 26, 2022
3ee3c30
merge: branch 'main' into 73-feature-plugins
Oct 5, 2022
fc3d5bc
feat(npm): preinstall script
Oct 5, 2022
661b049
feat(#73): Custom translation for plugins
Mr-Artemus Oct 5, 2022
be204cb
feat(#73): drop support for `.env` inside plugins
Mr-Artemus Oct 11, 2022
c978375
feat(#73): Add method to check if a plugin is loaded
Mr-Artemus Oct 11, 2022
0b27765
feat(#73): Auto detect locales for plugins
Mr-Artemus Oct 11, 2022
eeca93c
merge: main into 73-feature-plugins
Oct 12, 2022
c45c942
fix(#73): cwd path
Oct 13, 2022
32b5f1e
chore(deps): use `installoop` instead of `recursive-install`
Oct 13, 2022
43edac8
fix(devops/docker): postinstall script erroring
Oct 13, 2022
ca8770e
fix(#73): docker build fail
barthofu Oct 15, 2022
45ac967
fix(#73): source code path differ between prod and dev
barthofu Oct 15, 2022
8c39f27
fix(#73): plugins packages install on build
Oct 17, 2022
53d2b09
chore: remove `twilio` plugin from versioning
Oct 17, 2022
6e6960e
feat(#73): Add comments to config
Mr-Artemus Oct 17, 2022
2a1acf0
refactor(#73): cleaned code
Oct 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions .docker/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
## build runner
FROM node:16.17-alpine as build-runner
FROM node:16.17-buster-slim as build-runner

# Set temp directory
WORKDIR /tmp/app

# Move package.json and package-lock.json
COPY package.json .
COPY package-lock.json .
COPY src ./src

# Install dependencies from package-lock.json
RUN npm ci && npm cache clean --force

# Move source files
COPY src ./src
# and install dependencies for plugins (because postinstall script doesn't work in docker)
RUN npm ci

COPY .swcrc .
COPY tsconfig.json .
Expand All @@ -21,7 +20,7 @@ COPY tsconfig.json .
RUN npm run build

## producation runner
FROM node:16.17-alpine as prod-runner
FROM node:16.17-buster-slim as prod-runner

# set production mode
ARG NODE_ENV=production
Expand All @@ -34,12 +33,12 @@ WORKDIR /app
COPY --from=build-runner /tmp/app/package.json /app/package.json
COPY --from=build-runner /tmp/app/package-lock.json /app/package-lock.json

# Install dependencies from package-lock.json
RUN npm ci --omit=dev

# Move build files
COPY --from=build-runner /tmp/app/build /app/build
# COPY assets /app/assets

# Install dependencies from package-lock.json
# and install dependencies for plugins (because plugins:install script doesn't work in docker)
RUN npm ci --omit=dev && npm cache clean --force

# Finaly start the bot
CMD ["node", "build/main.js"]
34 changes: 29 additions & 5 deletions .swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,47 @@
"target": "es2021",
"baseUrl": "./",
"paths": {
"@types": ["src/utils/types"],

"@decorators": ["src/utils/decorators"],
"@decorators/*": ["src/plugins/*/utils/decorators"],

"@errors": ["src/utils/errors"],
"@errors/*": ["src/plugins/*/utils/errors"],

"@entities": ["src/entities"],
"@entities/*": ["src/plugins/*/entities"],

"@guards": ["src/guards"],
"@guards/*": ["src/plugins/*/guards"],

"@services": ["src/services"],
"@services/*": ["src/plugins/*/services"],

"@i18n": ["src/i18n"],
"@i18n/*": ["src/plugins/*/i18n"],

"@config": ["src/config"],

"@core/*": ["src/core/*"],
"@utils/*": ["src/utils/*"],
"@api/*": ["src/api/*"]
"@config/*": ["src/plugins/*/config"],

"@utils/classes": ["src/utils/classes"],
"@utils/classes/*": ["src/plugins/*/utils/classes"],

"@utils/functions": ["src/utils/functions"],
"@utils/functions/*": ["src/plugins/*/utils/functions"],

"@api/controllers": ["src/api/controllers"],
"@api/controllers/*": ["src/plugins/*/api/controllers"],

"@api/middlewares": ["src/api/middlewares"],
"@api/middlewares/*": ["src/plugins/*/api/middlewares"],

"@api/server": ["src/api/server.ts"]
},
"transform": {
"decoratorMetadata": true
}
},
"exclude": ["node_modules", ".git"],
"module": {
"type": "commonjs"
}
Expand Down
17 changes: 15 additions & 2 deletions mikro-orm.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
import { mikroORMConfig } from './src/config/database'
import { mikroORMConfig } from "./src/config/database"
import * as entities from "@entities"
import { PluginsManager } from "@services"
import { Options } from "@mikro-orm/core"
import { resolveDependency } from "@utils/functions"

export default async () => {
const pluginsManager = await resolveDependency(PluginsManager)
await pluginsManager.loadPlugins()

return {
...mikroORMConfig[process.env.NODE_ENV || 'development'] as Options<DatabaseDriver>,
entities: [...Object.values(entities), ...pluginsManager.getEntities()]
}
}

export default mikroORMConfig[process.env.NODE_ENV || 'development']
Loading