Skip to content

Commit

Permalink
updated CLI, compatibility watch script & docker files
Browse files Browse the repository at this point in the history
  • Loading branch information
GhomKrosmonaute committed Nov 27, 2024
1 parent a543c4b commit b139c78
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 5 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Dev Tests


on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:

jobs:
bun:
name: Test on Bun v1.1.34
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.1.34

- name: Install dependencies
run: bun install

- name: Start the bot
env:
BOT_MODE: test
run: bun run src/index.test.ts


Binary file modified bun.lockb
Binary file not shown.
5 changes: 5 additions & 0 deletions compatibility.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
"bun": "bun run src/index.test.ts",
"deno": "deno -A src/index.test.ts"
},
"watch": {
"default": "echo \"No watch support for this runtime\" && exit 1",
"bun": "bun run --watch src/index.ts",
"deno": "deno -A --watch src/index.ts"
},
"format": "{npx} prettier --write src scripts",
"lint": "{npx} eslint src/**/*.ts --fix",
"update": "{run-file} scripts/update-framework.js",
Expand Down
9 changes: 8 additions & 1 deletion compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ services:
container_name: ${BOT_NAME}
restart: always
volumes:
- ./data:/data
- ./data:/data

sqlite:
image: sqlite
container_name: sqlite
volumes:
- ./data:/data

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"bot": "bunx @ghom/bot.ts-cli",
"build": "rimraf dist && bunx rollup -c && bun run scripts/copy-keepers.js",
"final": "rimraf node_modules && bun install --production && bun run build",
"watch": "bun run build -w",
"watch": "bun run --watch src/index.ts",
"start": "bun run src/index.ts",
"start.test": "bun run src/index.test.ts",
"format": "bunx prettier --write src scripts",
Expand Down Expand Up @@ -88,7 +88,7 @@
"@eslint/compat": "^1.2.0",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.12.0",
"@ghom/bot.ts-cli": "9.0.2",
"@ghom/bot.ts-cli": "9.0.3",
"@rollup/plugin-alias": "^5.1.1",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-typescript": "^12.1.1",
Expand Down Expand Up @@ -116,5 +116,4 @@
"npm": ">=10.x.x",
"yarn": ">=1.22.22"
}
}

}
57 changes: 57 additions & 0 deletions templates/compose.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
services:
bot:
build:
context: .
dockerfile: Dockerfile
container_name: ${BOT_NAME}
restart: always
volumes:
<%-
client === "sqlite3" ? "- ./data:/data" :
client === "pg" ? "- ./data:/var/lib/postgresql/data" :
client === "mysql" ? "- ./data:/var/lib/mysql" : ""
%>
<%
if (client === "sqlite3") {
%>
sqlite:
image: sqlite
container_name: sqlite
volumes:
- ./data:/data
<%
} else if (client === "pg") {
%>
postgres:
image: postgres
container_name: postgres
environment:
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_DB=${DB_DATABASE}
volumes:
- ./data:/var/lib/postgresql/data
<% if (process.env.DB_PORT) { %>
ports:
- "${DB_PORT}:5432"
<% } %>
<%
} else if (client === "mysql") {
%>
mysql:
image: mysql
container_name: mysql
environment:
- MYSQL_USER=${DB_USER}
- MYSQL_PASSWORD=${DB_PASSWORD}
- MYSQL_DATABASE=${DB_DATABASE}
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
volumes:
- ./data:/var/lib/mysql
<% if (process.env.DB_PORT) { %>
ports:
- "${DB_PORT}:3306"
<% } %>
<%
}
%>
43 changes: 43 additions & 0 deletions templates/dockerfile.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<% if (runtime === 'bun') {
%>FROM oven/bun:latest<%
} else if (runtime === 'node') {
%>FROM node:latest<%
} else if (runtime === 'deno') {
%>FROM denoland/deno:alpine<%
} %>

WORKDIR /app

COPY package.json .

<% if (packageManager === 'bun') {
%>RUN bun install<%
} else if (packageManager === 'npm') {
%>RUN npm install
<% if (client === 'sqlite3' && runtime === 'node') { %>
RUN npm rebuild sqlite3<%
} %><%
} else if (packageManager === 'yarn') {
%>RUN yarn install
<% if (client === 'sqlite3' && runtime === 'node') { %>
RUN yarn rebuild sqlite3<%
} %><%
} else if (packageManager === 'pnpm') {
%>RUN pnpm install
<% if (client === 'sqlite3' && runtime === 'node') { %>
RUN pnpm rebuild sqlite3<%
} %><%
} else if (packageManager === 'deno') {
%>RUN deno install --global --allow-read --allow-write --allow-net --allow-env --allow-run<%
} %>

COPY . .

<% if (runtime === 'bun') {
%>CMD ["bun", "run", "start"]<%
} else if (runtime === 'node') {
%>RUN npm build
CMD ["node", "dist/index.js"]<%
} else if (runtime === 'deno') {
%>CMD ["deno", "run", "--allow-read", "--allow-write", "--allow-net", "--allow-env", "--allow-run", "src/index.ts"]<%
} %>

0 comments on commit b139c78

Please sign in to comment.