Skip to content

Commit 754284e

Browse files
authored
Merge pull request #494 from devforth/pnpm-for-dev-demo
dev-demo: add taskfile for installing plugins/adapters
2 parents 000b770 + 0fff20d commit 754284e

File tree

8 files changed

+159
-88
lines changed

8 files changed

+159
-88
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
node_modules
22
plugins/*
3-
!plugins/install-plugins.sh
3+
!plugins/README.md
44
adapters/*
5-
!adapters/install-adapters.sh
5+
!adapters/README.md
66
background-jobs-dbs

adapters/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This folder will be filled with adapters, after dev_demo setup

adapters/install-adapters.sh

Lines changed: 0 additions & 41 deletions
This file was deleted.

dev-demo/Taskfile.yaml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
version: '3'
2+
3+
vars:
4+
PLUGINS_DIR: "../plugins"
5+
ADAPTERS_DIR: "../adapters"
6+
PULL_JOBS: 30
7+
PNPM_JOBS: 10
8+
PLUGINS:
9+
- "adminforth-audit-log"
10+
- "adminforth-email-password-reset"
11+
- "adminforth-foreign-inline-list"
12+
- "adminforth-i18n"
13+
- "adminforth-import-export"
14+
- "adminforth-text-complete"
15+
- "adminforth-open-signup"
16+
- "adminforth-rich-editor"
17+
- "adminforth-two-factors-auth"
18+
- "adminforth-upload"
19+
- "adminforth-oauth"
20+
- "adminforth-list-in-place-edit"
21+
- "adminforth-inline-create"
22+
- "adminforth-markdown"
23+
- "adminforth-foreign-inline-show"
24+
- "adminforth-email-invite"
25+
- "adminforth-bulk-ai-flow"
26+
- "adminforth-universal-search"
27+
- "adminforth-login-captcha"
28+
- "adminforth-user-soft-delete"
29+
- "adminforth-clone-row"
30+
- "adminforth-quick-filters"
31+
- "adminforth-many2many"
32+
- "adminforth-background-jobs"
33+
34+
ADAPTERS:
35+
- "adminforth-completion-adapter-open-ai-chat-gpt"
36+
- "adminforth-email-adapter-aws-ses"
37+
- "adminforth-email-adapter-mailgun"
38+
- "adminforth-google-oauth-adapter"
39+
- "adminforth-github-oauth-adapter"
40+
- "adminforth-facebook-oauth-adapter"
41+
- "adminforth-keycloak-oauth-adapter"
42+
- "adminforth-microsoft-oauth-adapter"
43+
- "adminforth-twitch-oauth-adapter"
44+
- "adminforth-image-generation-adapter-openai"
45+
- "adminforth-storage-adapter-amazon-s3"
46+
- "adminforth-storage-adapter-local"
47+
- "adminforth-image-vision-adapter-openai"
48+
- "adminforth-key-value-adapter-ram"
49+
- "adminforth-login-captcha-adapter-cloudflare"
50+
- "adminforth-login-captcha-adapter-recaptcha"
51+
- "adminforth-completion-adapter-google-gemini"
52+
- "adminforth-key-value-adapter-redis"
53+
- "adminforth-key-value-adapter-leveldb"
54+
55+
56+
tasks:
57+
58+
pull_repos:
59+
internal: true
60+
cmds:
61+
- |
62+
set -euo pipefail
63+
mkdir -p "{{.DIR}}"
64+
cd "{{.DIR}}"
65+
66+
repos=({{range .REPOS}}{{.}} {{end}})
67+
68+
printf '%s\n' "${repos[@]}" | xargs -n1 -P"{{.PULL_JOBS}}" -I{} bash -c '
69+
set -euo pipefail
70+
repo="$1"
71+
repo_url="https://github.com/devforth/${repo}.git"
72+
name="$(basename "${repo}" .git)"
73+
74+
if [ -d "${name}" ]; then
75+
echo "Pulling ${name}"
76+
(cd "${name}" && git pull)
77+
else
78+
echo "Cloning ${name}"
79+
git clone "${repo_url}" "${name}"
80+
fi
81+
' _ {}
82+
83+
pnpm_repos:
84+
internal: true
85+
cmds:
86+
- |
87+
set -euo pipefail
88+
cd "{{.DIR}}"
89+
90+
repos=({{range .REPOS}}{{.}} {{end}})
91+
92+
printf '%s\n' "${repos[@]}" | xargs -n1 -P"{{.PNPM_JOBS}}" -I{} bash -c '
93+
set -euo pipefail
94+
name="$1"
95+
96+
if [ -d "${name}" ]; then
97+
echo "Installing dependencies for ${name}"
98+
(cd "${name}" && pnpm install)
99+
else
100+
echo "Directory ${name} does not exist, skipping"
101+
fi
102+
' _ {}
103+
104+
pull_plugins:
105+
desc: Pull plugin repositories
106+
cmds:
107+
- task: pull_repos
108+
vars:
109+
DIR: "{{.PLUGINS_DIR}}"
110+
REPOS:
111+
ref: .PLUGINS
112+
113+
pull_adapters:
114+
desc: Pull adapter repositories
115+
cmds:
116+
- task: pull_repos
117+
vars:
118+
DIR: "{{.ADAPTERS_DIR}}"
119+
REPOS:
120+
ref: .ADAPTERS
121+
122+
pnpm_plugins:
123+
desc: Install plugin dependencies
124+
cmds:
125+
- task: pnpm_repos
126+
vars:
127+
DIR: "{{.PLUGINS_DIR}}"
128+
REPOS:
129+
ref: .PLUGINS
130+
131+
pnpm_adapters:
132+
desc: Install adapter dependencies
133+
cmds:
134+
- task: pnpm_repos
135+
vars:
136+
DIR: "{{.ADAPTERS_DIR}}"
137+
REPOS:
138+
ref: .ADAPTERS

dev-demo/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
"migrate:mysql": "npm run _env:dev -- npx --yes prisma migrate deploy --schema=./migrations/prisma/mysql/schema.mysql.prisma",
1414
"makemigration:postgres": "npm run _env:dev -- npx --yes prisma migrate dev --create-only --schema=./migrations/prisma/postgres/schema.postgres.prisma",
1515
"migrate:postgres": "npm run _env:dev -- npx --yes prisma migrate deploy --schema=./migrations/prisma/postgres/schema.postgres.prisma",
16-
"migrate:clickhouse": "npx clickhouse-migrations migrate --host=http://localhost:28124/demo --user=demo --password=demo --db=demo --migrations-home=./migrations/clickhouse_migrations",
17-
"install-plugins": "cd ../plugins && bash install-plugins.sh",
18-
"install-adapters": "cd ../adapters && bash install-adapters.sh",
16+
"migrate:clickhouse": "npx clickhouse-migrations migrate --host=http://localhost:28124 --user=demo --password=demo --db=demo --migrations-home=./migrations/clickhouse_migrations",
17+
"install-plugins": "task pull_plugins && task pnpm_plugins",
18+
"install-adapters": "task pull_adapters && task pnpm_adapters",
1919
"build-adminforth": "cd ../adminforth && npm ci && npm run build && npm link",
2020
"migrate:all": "npm run migrate:sqlite && npm run migrate:mysql && npm run migrate:postgres && npm run migrate:clickhouse",
2121
"preinstall": "node scripts/check-node.js",
2222
"check-docker": "node scripts/check-docker.js",
23-
"setup-dev-demo": "npm run preinstall && npm run check-docker && npm run build-adminforth && cp .env.local .env && npm run install-plugins && npm run install-adapters && npm install && npm link adminforth && bash ./scripts/run_inventory.sh"
23+
"check-task": "node scripts/check-task.js",
24+
"setup-dev-demo": "npm run preinstall && npm run check-docker && npm run check-task && npm run build-adminforth && cp .env.local .env && npm run install-plugins && npm run install-adapters && npm install && npm link adminforth && bash ./scripts/run_inventory.sh"
2425
},
2526
"author": "",
2627
"license": "ISC",

dev-demo/scripts/check-task.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { execSync } from 'node:child_process';
2+
3+
try {
4+
execSync('task --version', { stdio: 'ignore' });
5+
console.log('✅ Taskfile is installed');
6+
} catch {
7+
console.error(
8+
'❌ Taskfile is not installed or not available in PATH.\n' +
9+
'Please install Task: https://taskfile.dev/#/installation'
10+
);
11+
process.exit(1);
12+
}

plugins/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This folder will be filled with adapters, after dev_demo setup

plugins/install-plugins.sh

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)