@cubocicloide/stack-frappe 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +33 -0
- package/README.md +37 -0
- package/dist/commands/lint/checks/APP/001.d.ts +13 -0
- package/dist/commands/lint/checks/APP/001.js +73 -0
- package/dist/commands/lint/checks/APP/001.js.map +1 -0
- package/dist/commands/lint/checks/APP/002.d.ts +12 -0
- package/dist/commands/lint/checks/APP/002.js +94 -0
- package/dist/commands/lint/checks/APP/002.js.map +1 -0
- package/dist/commands/lint/checks/APP/003.d.ts +12 -0
- package/dist/commands/lint/checks/APP/003.js +94 -0
- package/dist/commands/lint/checks/APP/003.js.map +1 -0
- package/dist/commands/lint/checks/APP/004.d.ts +12 -0
- package/dist/commands/lint/checks/APP/004.js +117 -0
- package/dist/commands/lint/checks/APP/004.js.map +1 -0
- package/dist/commands/lint/checks/DT/001.d.ts +11 -0
- package/dist/commands/lint/checks/DT/001.js +57 -0
- package/dist/commands/lint/checks/DT/001.js.map +1 -0
- package/dist/commands/lint/checks/DT/002.d.ts +12 -0
- package/dist/commands/lint/checks/DT/002.js +74 -0
- package/dist/commands/lint/checks/DT/002.js.map +1 -0
- package/dist/commands/lint/checks/DT/003.d.ts +13 -0
- package/dist/commands/lint/checks/DT/003.js +96 -0
- package/dist/commands/lint/checks/DT/003.js.map +1 -0
- package/dist/commands/lint/checks/DT/004.d.ts +12 -0
- package/dist/commands/lint/checks/DT/004.js +101 -0
- package/dist/commands/lint/checks/DT/004.js.map +1 -0
- package/dist/commands/lint/checks/PY/001.d.ts +12 -0
- package/dist/commands/lint/checks/PY/001.js +87 -0
- package/dist/commands/lint/checks/PY/001.js.map +1 -0
- package/dist/commands/lint/checks/PY/002.d.ts +12 -0
- package/dist/commands/lint/checks/PY/002.js +80 -0
- package/dist/commands/lint/checks/PY/002.js.map +1 -0
- package/dist/commands/lint/checks/PY/003.d.ts +11 -0
- package/dist/commands/lint/checks/PY/003.js +56 -0
- package/dist/commands/lint/checks/PY/003.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1987 -0
- package/dist/index.js.map +1 -0
- package/dude.stack.json +12 -0
- package/package.json +41 -0
- package/templates/aws-ecs/_dockerignore +11 -0
- package/templates/aws-ecs/docker/Dockerfile.prod.hbs +80 -0
- package/templates/aws-ecs/docker/nginx-entrypoint.sh +17 -0
- package/templates/aws-ecs/docker/nginx-template.conf +95 -0
- package/templates/aws-ecs/docs/docs/deploy.md.hbs +53 -0
- package/templates/aws-ecs/iac/README.md.hbs +113 -0
- package/templates/aws-ecs/iac/_gitignore +14 -0
- package/templates/aws-ecs/iac/runner/Dockerfile +35 -0
- package/templates/aws-ecs/iac/terraform/bootstrap/main.tf.hbs +93 -0
- package/templates/aws-ecs/iac/terraform/bootstrap/outputs.tf +14 -0
- package/templates/aws-ecs/iac/terraform/bootstrap/variables.tf.hbs +17 -0
- package/templates/aws-ecs/iac/terraform/environments/dev/backend.hcl.hbs +12 -0
- package/templates/aws-ecs/iac/terraform/environments/dev/terraform.tfvars.hbs +32 -0
- package/templates/aws-ecs/iac/terraform/main.tf.hbs +1205 -0
- package/templates/aws-ecs/iac/terraform/outputs.tf.hbs +103 -0
- package/templates/aws-ecs/iac/terraform/providers.tf +19 -0
- package/templates/aws-ecs/iac/terraform/variables.tf.hbs +139 -0
- package/templates/aws-ecs/iac/terraform/versions.tf +19 -0
- package/templates/base/.claude/rules/APP/001.md +26 -0
- package/templates/base/.claude/rules/APP/002.md +26 -0
- package/templates/base/.claude/rules/APP/003.md +25 -0
- package/templates/base/.claude/rules/APP/004.md +27 -0
- package/templates/base/.claude/rules/DT/001.md +25 -0
- package/templates/base/.claude/rules/DT/002.md +25 -0
- package/templates/base/.claude/rules/DT/003.md +24 -0
- package/templates/base/.claude/rules/DT/004.md +22 -0
- package/templates/base/.claude/rules/PY/001.md +30 -0
- package/templates/base/.claude/rules/PY/002.md +31 -0
- package/templates/base/.claude/rules/PY/003.md +29 -0
- package/templates/base/.claude/settings.json +42 -0
- package/templates/base/.claude/skills/create-doctype/SKILL.md +99 -0
- package/templates/base/.dude/commands/README.md +85 -0
- package/templates/base/.dude/commands/hello.ts +34 -0
- package/templates/base/.dude/lint/checks/PRJ/001.ts +26 -0
- package/templates/base/.dude/lint/checks/README.md +69 -0
- package/templates/base/.vscode/tasks.json +44 -0
- package/templates/base/CLAUDE.md.hbs +49 -0
- package/templates/base/README.md.hbs +68 -0
- package/templates/base/_env.example.hbs +5 -0
- package/templates/base/_env.hbs +12 -0
- package/templates/base/_gitignore +26 -0
- package/templates/base/_npmrc +2 -0
- package/templates/base/apps/README.md +24 -0
- package/templates/base/apps/ticketing/README.md +43 -0
- package/templates/base/apps/ticketing/pyproject.toml +34 -0
- package/templates/base/apps/ticketing/ticketing/__init__.py +1 -0
- package/templates/base/apps/ticketing/ticketing/api.py +35 -0
- package/templates/base/apps/ticketing/ticketing/events/__init__.py +0 -0
- package/templates/base/apps/ticketing/ticketing/events/hd_ticket.py +32 -0
- package/templates/base/apps/ticketing/ticketing/fixtures/workflow.json +55 -0
- package/templates/base/apps/ticketing/ticketing/fixtures/workflow_action_master.json +12 -0
- package/templates/base/apps/ticketing/ticketing/fixtures/workflow_state.json +20 -0
- package/templates/base/apps/ticketing/ticketing/hooks.py +54 -0
- package/templates/base/apps/ticketing/ticketing/modules.txt +1 -0
- package/templates/base/apps/ticketing/ticketing/patches/__init__.py +0 -0
- package/templates/base/apps/ticketing/ticketing/patches/v1_0/__init__.py +0 -0
- package/templates/base/apps/ticketing/ticketing/patches/v1_0/set_default_branding.py +26 -0
- package/templates/base/apps/ticketing/ticketing/patches.txt +5 -0
- package/templates/base/apps/ticketing/ticketing/public/images/favicon.png +0 -0
- package/templates/base/apps/ticketing/ticketing/public/images/logo.png +0 -0
- package/templates/base/apps/ticketing/ticketing/tasks.py +99 -0
- package/templates/base/apps/ticketing/ticketing/templates/__init__.py +0 -0
- package/templates/base/apps/ticketing/ticketing/templates/pages/__init__.py +0 -0
- package/templates/base/apps/ticketing/ticketing/templates/pages/ticket_stats.html +30 -0
- package/templates/base/apps/ticketing/ticketing/templates/pages/ticket_stats.py +14 -0
- package/templates/base/apps/ticketing/ticketing/ticketing/__init__.py +0 -0
- package/templates/base/apps/ticketing/ticketing/ticketing/doctype/__init__.py +0 -0
- package/templates/base/apps/ticketing/ticketing/ticketing/doctype/ticket_escalation_rule/__init__.py +0 -0
- package/templates/base/apps/ticketing/ticketing/ticketing/doctype/ticket_escalation_rule/test_ticket_escalation_rule.py +32 -0
- package/templates/base/apps/ticketing/ticketing/ticketing/doctype/ticket_escalation_rule/ticket_escalation_rule.js +23 -0
- package/templates/base/apps/ticketing/ticketing/ticketing/doctype/ticket_escalation_rule/ticket_escalation_rule.json +99 -0
- package/templates/base/apps/ticketing/ticketing/ticketing/doctype/ticket_escalation_rule/ticket_escalation_rule.py +18 -0
- package/templates/base/docker/init.sh +114 -0
- package/templates/base/docker-compose.yml.hbs +62 -0
- package/templates/base/docs/docs/api.md +21 -0
- package/templates/base/docs/docs/dude.md.hbs +220 -0
- package/templates/base/docs/docs/extending.md +238 -0
- package/templates/base/docs/docs/frappe.md.hbs +223 -0
- package/templates/base/docs/docs/index.md.hbs +101 -0
- package/templates/base/docs/docs/mkdocs.md +235 -0
- package/templates/base/docs/mkdocs.yml.hbs +54 -0
- package/templates/base/package.json.hbs +11 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# First-boot provisioning + process runner for the local Frappe bench.
|
|
4
|
+
#
|
|
5
|
+
# Idempotent: every step checks whether its work is already done, so the
|
|
6
|
+
# container can be restarted freely. State lives in the `bench_home` volume
|
|
7
|
+
# (the bench itself) and `mariadb_data` (the database). To start over from a
|
|
8
|
+
# clean slate run `dude down --volumes`.
|
|
9
|
+
#
|
|
10
|
+
set -euo pipefail
|
|
11
|
+
|
|
12
|
+
BENCH_DIR=/home/frappe/frappe-bench
|
|
13
|
+
SITE_NAME="${SITE_NAME:?SITE_NAME must be set}"
|
|
14
|
+
ADMIN_PASSWORD="${ADMIN_PASSWORD:-admin}"
|
|
15
|
+
MARIADB_ROOT_PASSWORD="${MARIADB_ROOT_PASSWORD:-admin}"
|
|
16
|
+
INSTALL_HELPDESK="${INSTALL_HELPDESK:-true}"
|
|
17
|
+
|
|
18
|
+
log() { echo "[init] $*"; }
|
|
19
|
+
|
|
20
|
+
# ── 1. Bench ──────────────────────────────────────────────────────────────────
|
|
21
|
+
if [ ! -d "$BENCH_DIR" ]; then
|
|
22
|
+
log "Creating bench (first boot — this downloads Frappe and takes a few minutes)…"
|
|
23
|
+
bench init --skip-redis-config-generation --frappe-branch version-15 "$BENCH_DIR"
|
|
24
|
+
fi
|
|
25
|
+
cd "$BENCH_DIR"
|
|
26
|
+
|
|
27
|
+
# Point the bench at the compose services (idempotent) and strip the local
|
|
28
|
+
# redis processes from the Procfile — redis runs as dedicated containers.
|
|
29
|
+
bench set-config -g db_host mariadb
|
|
30
|
+
bench set-config -g redis_cache redis://redis-cache:6379
|
|
31
|
+
bench set-config -g redis_queue redis://redis-queue:6379
|
|
32
|
+
bench set-config -g redis_socketio redis://redis-queue:6379
|
|
33
|
+
sed -i '/redis/d' ./Procfile
|
|
34
|
+
|
|
35
|
+
# ── 2. Site ───────────────────────────────────────────────────────────────────
|
|
36
|
+
if [ ! -d "sites/$SITE_NAME" ]; then
|
|
37
|
+
log "Creating site $SITE_NAME…"
|
|
38
|
+
bench new-site "$SITE_NAME" \
|
|
39
|
+
--mariadb-root-password "$MARIADB_ROOT_PASSWORD" \
|
|
40
|
+
--admin-password "$ADMIN_PASSWORD" \
|
|
41
|
+
--no-mariadb-socket
|
|
42
|
+
bench --site "$SITE_NAME" set-config developer_mode 1
|
|
43
|
+
bench --site "$SITE_NAME" clear-cache
|
|
44
|
+
bench use "$SITE_NAME"
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
installed_apps() { bench --site "$SITE_NAME" list-apps 2>/dev/null || true; }
|
|
48
|
+
|
|
49
|
+
# `bench get-app`/`bench new-app` do not reliably leave a trailing newline
|
|
50
|
+
# after the last entry of sites/apps.txt — appending to it naively then
|
|
51
|
+
# concatenates onto the previous line (e.g. "telephony" + "ticketing" ->
|
|
52
|
+
# "telephonyticketing", which frappe then fails to import as a module).
|
|
53
|
+
append_app_txt() {
|
|
54
|
+
if [ -s sites/apps.txt ] && [ -n "$(tail -c1 sites/apps.txt)" ]; then
|
|
55
|
+
echo >>sites/apps.txt
|
|
56
|
+
fi
|
|
57
|
+
echo "$1" >>sites/apps.txt
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# ── 3. Frappe Helpdesk (the ticketing UI) ─────────────────────────────────────
|
|
61
|
+
# Helpdesk declares `required_apps = ["telephony"]` (VoIP/calling
|
|
62
|
+
# integration) — frappe resolves that at install time but does NOT fetch it
|
|
63
|
+
# for you, so it must already be present in the bench or install-app fails
|
|
64
|
+
# with a bare ModuleNotFoundError.
|
|
65
|
+
if [ "$INSTALL_HELPDESK" = "true" ]; then
|
|
66
|
+
if [ ! -d apps/telephony ]; then
|
|
67
|
+
log "Fetching Frappe Telephony (Helpdesk's required_apps dependency)…"
|
|
68
|
+
bench get-app telephony
|
|
69
|
+
fi
|
|
70
|
+
if [ ! -d apps/helpdesk ]; then
|
|
71
|
+
log "Fetching Frappe Helpdesk…"
|
|
72
|
+
bench get-app helpdesk
|
|
73
|
+
fi
|
|
74
|
+
if ! installed_apps | grep -qw helpdesk; then
|
|
75
|
+
log "Installing Frappe Helpdesk on $SITE_NAME…"
|
|
76
|
+
bench --site "$SITE_NAME" install-app helpdesk
|
|
77
|
+
fi
|
|
78
|
+
fi
|
|
79
|
+
|
|
80
|
+
# ── 4. Custom apps from the repo ──────────────────────────────────────────────
|
|
81
|
+
# Every directory under apps/ in the project repo (mounted at /workspace/apps)
|
|
82
|
+
# that looks like a Frappe app is linked into the bench in editable mode, so
|
|
83
|
+
# code changes on the host reload live inside the container.
|
|
84
|
+
for app_dir in /workspace/apps/*/; do
|
|
85
|
+
[ -d "$app_dir" ] || continue
|
|
86
|
+
app="$(basename "$app_dir")"
|
|
87
|
+
[ -f "$app_dir/pyproject.toml" ] || continue
|
|
88
|
+
[ -f "$app_dir/$app/hooks.py" ] || continue
|
|
89
|
+
|
|
90
|
+
if [ ! -e "apps/$app" ]; then
|
|
91
|
+
log "Linking custom app $app…"
|
|
92
|
+
ln -s "/workspace/apps/$app" "apps/$app"
|
|
93
|
+
fi
|
|
94
|
+
grep -qx "$app" sites/apps.txt 2>/dev/null || append_app_txt "$app"
|
|
95
|
+
./env/bin/pip install --quiet -e "apps/$app"
|
|
96
|
+
if ! installed_apps | grep -qw "$app"; then
|
|
97
|
+
log "Installing custom app $app on $SITE_NAME…"
|
|
98
|
+
bench --site "$SITE_NAME" install-app "$app"
|
|
99
|
+
fi
|
|
100
|
+
# `bench get-app` builds assets on fetch; a symlinked custom app never goes
|
|
101
|
+
# through that path, so /assets/$app/... (branding images, etc.) would 404
|
|
102
|
+
# without an explicit build.
|
|
103
|
+
if [ ! -e "sites/assets/$app" ]; then
|
|
104
|
+
log "Building assets for $app…"
|
|
105
|
+
bench build --app "$app"
|
|
106
|
+
fi
|
|
107
|
+
done
|
|
108
|
+
|
|
109
|
+
# Apply pending migrations/fixtures from custom-app changes on every boot.
|
|
110
|
+
bench --site "$SITE_NAME" migrate
|
|
111
|
+
|
|
112
|
+
# ── 5. Run ────────────────────────────────────────────────────────────────────
|
|
113
|
+
log "Starting bench (web :8000, socketio :9000)…"
|
|
114
|
+
exec bench start
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
services:
|
|
2
|
+
mariadb:
|
|
3
|
+
image: mariadb:10.6
|
|
4
|
+
restart: unless-stopped
|
|
5
|
+
command:
|
|
6
|
+
- --character-set-server=utf8mb4
|
|
7
|
+
- --collation-server=utf8mb4_unicode_ci
|
|
8
|
+
- --skip-character-set-client-handshake
|
|
9
|
+
- --skip-innodb-read-only-compressed
|
|
10
|
+
environment:
|
|
11
|
+
MYSQL_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD:-admin}
|
|
12
|
+
healthcheck:
|
|
13
|
+
test: ["CMD-SHELL", "mysqladmin ping -h localhost -u root -p$$MYSQL_ROOT_PASSWORD | grep -q 'mysqld is alive'"]
|
|
14
|
+
interval: 5s
|
|
15
|
+
timeout: 5s
|
|
16
|
+
retries: 30
|
|
17
|
+
volumes:
|
|
18
|
+
- mariadb_data:/var/lib/mysql
|
|
19
|
+
|
|
20
|
+
redis-cache:
|
|
21
|
+
image: redis:6.2-alpine
|
|
22
|
+
restart: unless-stopped
|
|
23
|
+
|
|
24
|
+
redis-queue:
|
|
25
|
+
image: redis:6.2-alpine
|
|
26
|
+
restart: unless-stopped
|
|
27
|
+
|
|
28
|
+
# Development bench: provisions the bench + site on first boot (see
|
|
29
|
+
# docker/init.sh), then runs `bench start` (web, socketio, watcher,
|
|
30
|
+
# scheduler and workers in one container — dev only).
|
|
31
|
+
bench:
|
|
32
|
+
image: frappe/bench:latest
|
|
33
|
+
restart: unless-stopped
|
|
34
|
+
command: bash /workspace/docker/init.sh
|
|
35
|
+
working_dir: /home/frappe
|
|
36
|
+
environment:
|
|
37
|
+
SITE_NAME: ${SITE_NAME:-{{projectName}}.localhost}
|
|
38
|
+
ADMIN_PASSWORD: ${ADMIN_PASSWORD:-admin}
|
|
39
|
+
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD:-admin}
|
|
40
|
+
{{#if withHelpdesk}}
|
|
41
|
+
INSTALL_HELPDESK: ${INSTALL_HELPDESK:-true}
|
|
42
|
+
{{else}}
|
|
43
|
+
INSTALL_HELPDESK: ${INSTALL_HELPDESK:-false}
|
|
44
|
+
{{/if}}
|
|
45
|
+
depends_on:
|
|
46
|
+
mariadb:
|
|
47
|
+
condition: service_healthy
|
|
48
|
+
redis-cache:
|
|
49
|
+
condition: service_started
|
|
50
|
+
redis-queue:
|
|
51
|
+
condition: service_started
|
|
52
|
+
ports:
|
|
53
|
+
- "8000:8000" # web (werkzeug dev server)
|
|
54
|
+
- "9000:9000" # socketio (realtime)
|
|
55
|
+
volumes:
|
|
56
|
+
- bench_home:/home/frappe
|
|
57
|
+
- ./docker:/workspace/docker:ro
|
|
58
|
+
- ./apps:/workspace/apps
|
|
59
|
+
|
|
60
|
+
volumes:
|
|
61
|
+
mariadb_data:
|
|
62
|
+
bench_home:
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Command reference
|
|
2
|
+
|
|
3
|
+
!!! info "Auto-generated"
|
|
4
|
+
This page is generated from the **live `dude` command catalog** every time you
|
|
5
|
+
run `dude docs`, so it always matches your project's actual commands —
|
|
6
|
+
including the choices made at `dude init` (Helpdesk, IaC…) and any
|
|
7
|
+
project-local commands under `.dude/commands/`.
|
|
8
|
+
|
|
9
|
+
You're seeing this placeholder because the docs haven't been served yet. Run:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
dude docs
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
and this page will be replaced with the full reference. You can also print it
|
|
16
|
+
yourself at any time:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
dude help --format md # this page, as Markdown
|
|
20
|
+
dude help --format json # the same catalog as JSON (for tooling / LLMs)
|
|
21
|
+
```
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Working with dude
|
|
2
|
+
|
|
3
|
+
[`dude`](https://github.com/cubocicloide/dude) is the project CLI — a single
|
|
4
|
+
entry point for all development tasks. Run `dude help` for a live overview, and
|
|
5
|
+
`dude help <command>` (or `dude help <group> <sub>`) for a command's flags.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
`dude` is published on the public npm registry. What you install
|
|
12
|
+
globally is the tiny **launcher** (`@cubocicloide/dude-launcher`); it then runs
|
|
13
|
+
each project's *pinned* CLI + stack automatically — no manual version switching.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# 1. Install the launcher globally (the only global install).
|
|
17
|
+
npm install -g @cubocicloide/dude-launcher
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Then, inside this project, provision the pinned toolchain (the launcher would
|
|
21
|
+
also do this on the first `dude` command, but doing it explicitly is clearer):
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm install # installs the pinned @cubocicloide/dude CLI + stack
|
|
25
|
+
dude version # verify the resolved CLI + stack versions
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Getting started
|
|
32
|
+
|
|
33
|
+
### First run
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
dude up
|
|
37
|
+
dude logs --service bench # follow the provisioning
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The **first** boot does real work — `docker/init.sh` creates the bench
|
|
41
|
+
(downloads Frappe v15), creates the site{{#if withHelpdesk}}, installs Frappe
|
|
42
|
+
Helpdesk{{/if}}, installs every custom app under `apps/`, and runs
|
|
43
|
+
`bench migrate` — expect several minutes. Every later `dude up` reuses the
|
|
44
|
+
provisioned bench (persisted in the `bench_home` volume) and is fast. The
|
|
45
|
+
script is idempotent, so restarting mid-provision is safe.
|
|
46
|
+
|
|
47
|
+
### Services
|
|
48
|
+
|
|
49
|
+
Once `bench start` is running:
|
|
50
|
+
|
|
51
|
+
| Service | URL | Notes |
|
|
52
|
+
|---------|-----|-------|
|
|
53
|
+
| **Desk** | http://{{projectName}}.localhost:8000/app | Admin UI — `Administrator` / `admin` |
|
|
54
|
+
{{#if withHelpdesk}}| **Helpdesk** | http://{{projectName}}.localhost:8000/helpdesk | Agent UI (Frappe Helpdesk) |
|
|
55
|
+
{{/if}}| **Portal example** | http://{{projectName}}.localhost:8000/ticket_stats | Public page from `apps/ticketing` |
|
|
56
|
+
| **API example** | http://{{projectName}}.localhost:8000/api/method/ticketing.api.ticket_stats | Whitelisted method |
|
|
57
|
+
|
|
58
|
+
### Hot reload
|
|
59
|
+
|
|
60
|
+
`apps/` is mounted into the container and installed in **editable mode**: edit
|
|
61
|
+
Python under `apps/ticketing/` on the host and the dev server reloads within a
|
|
62
|
+
second or two. Changes to a DocType **schema** (`.json`) or to fixtures need
|
|
63
|
+
`dude site migrate`; changes to `hooks.py` need a restart (`dude up`).
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Infrastructure
|
|
68
|
+
|
|
69
|
+
All services run in Docker. The `docker-compose.yml` at the project root
|
|
70
|
+
defines every service (`mariadb`, `redis-cache`, `redis-queue`, `bench`).
|
|
71
|
+
|
|
72
|
+
| Command | Description |
|
|
73
|
+
|---------|-------------|
|
|
74
|
+
| `dude up` | Start all services (detached) |
|
|
75
|
+
| `dude up --build` | Rebuild images first |
|
|
76
|
+
| `dude down` | Stop and remove containers (bench + DB volumes survive) |
|
|
77
|
+
| `dude down --volumes` | Also remove volumes — **destroys the bench and the database** |
|
|
78
|
+
| `dude logs` | Follow logs for all services |
|
|
79
|
+
| `dude logs --service bench` | Follow logs for one service |
|
|
80
|
+
| `dude shell` | Interactive shell in the bench container, inside `frappe-bench/` |
|
|
81
|
+
| `dude shell --service mariadb` | Shell into another service |
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Bench passthrough
|
|
86
|
+
|
|
87
|
+
`bench` is Frappe's own CLI. Anything `dude` doesn't wrap explicitly is one
|
|
88
|
+
passthrough away — everything after `dude bench` runs verbatim as `bench …`
|
|
89
|
+
inside the bench container:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
dude bench --site all migrate
|
|
93
|
+
dude bench --site all execute ticketing.tasks.escalate_overdue_tickets
|
|
94
|
+
dude bench --site all export-fixtures --app ticketing
|
|
95
|
+
dude bench version
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Site operations
|
|
101
|
+
|
|
102
|
+
Day-to-day operations on the default site (`SITE_NAME` from `.env`):
|
|
103
|
+
|
|
104
|
+
| Command | Description |
|
|
105
|
+
|---------|-------------|
|
|
106
|
+
| `dude site migrate` | Apply pending schema changes, patches and fixtures (`bench migrate`) |
|
|
107
|
+
| `dude site console` | IPython console with the site loaded — try `frappe.get_all("Ticket Escalation Rule")` |
|
|
108
|
+
| `dude site backup` | Backup the database → `sites/<site>/private/backups` |
|
|
109
|
+
| `dude site backup --files` | Also include public/private files |
|
|
110
|
+
| `dude site clear-cache` | Clear the site + website cache |
|
|
111
|
+
| `dude site mariadb` | SQL client connected to the site's database |
|
|
112
|
+
|
|
113
|
+
Run `dude site migrate` after: adding/editing a DocType JSON, changing
|
|
114
|
+
fixtures, or pulling schema changes from git. (It also runs automatically on
|
|
115
|
+
every container boot.)
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## App management
|
|
120
|
+
|
|
121
|
+
Custom apps live in `apps/` in this repo (see `apps/README.md`).
|
|
122
|
+
|
|
123
|
+
| Command | Description |
|
|
124
|
+
|---------|-------------|
|
|
125
|
+
| `dude app new --name my_app` | Scaffold a new app (`bench new-app`) and relocate it into `apps/` |
|
|
126
|
+
| `dude app install --name my_app` | Install an app from the bench onto the site |
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Testing
|
|
131
|
+
|
|
132
|
+
Tests use Frappe's `FrappeTestCase` (each test runs in a rolled-back
|
|
133
|
+
transaction) and run inside the bench via `bench run-tests`.
|
|
134
|
+
|
|
135
|
+
| Command | Description |
|
|
136
|
+
|---------|-------------|
|
|
137
|
+
| `dude test` | Run the `ticketing` app's test suite |
|
|
138
|
+
| `dude test --app my_app` | Test a different app |
|
|
139
|
+
| `dude test --module ticketing.ticketing.doctype.ticket_escalation_rule.test_ticket_escalation_rule` | Run a single test module |
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Code quality
|
|
144
|
+
|
|
145
|
+
| Command | Description |
|
|
146
|
+
|---------|-------------|
|
|
147
|
+
| `dude lint` | Structural Frappe conventions over `apps/` (APP/DT/PY rules — see `.claude/rules/`) |
|
|
148
|
+
| `dude lint --quiet` | Errors only, no warnings |
|
|
149
|
+
| `dude format` | `ruff format` + autofix over `apps/` (Frappe style — tabs) |
|
|
150
|
+
| `dude review` | One pass: stack lint rules + `ruff check` (no autofix) |
|
|
151
|
+
| `dude upgrade` | Update the pinned `dude` CLI and stack versions for this project |
|
|
152
|
+
|
|
153
|
+
### Project lint rules
|
|
154
|
+
|
|
155
|
+
`dude lint` also runs any rules you define under `.dude/lint/checks/` — the
|
|
156
|
+
rule code is derived from the path (`.dude/lint/checks/PRJ/001.ts` → `PRJ001`)
|
|
157
|
+
and the contract is the same one the stack's own checks use. See
|
|
158
|
+
`.dude/lint/checks/README.md` and the `PRJ/001.ts` example. To disable a
|
|
159
|
+
built-in rule, list its code in `dude.json`:
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{ "lint": { "disable": ["PY001"] } }
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Upgrading pinned versions
|
|
166
|
+
|
|
167
|
+
`dude upgrade` updates version pins only. It does **not** migrate existing
|
|
168
|
+
project files.
|
|
169
|
+
|
|
170
|
+
| Command | Description |
|
|
171
|
+
|---------|-------------|
|
|
172
|
+
| `dude upgrade` | Upgrade both the CLI pin in `package.json` and the stack pin in `dude.json` |
|
|
173
|
+
| `dude upgrade --cli` | Upgrade only `@cubocicloide/dude` |
|
|
174
|
+
| `dude upgrade --stack` | Upgrade only the active stack version |
|
|
175
|
+
| `dude upgrade --cli --cli-version 0.6.1` | Pin the CLI to an explicit version |
|
|
176
|
+
| `dude upgrade --stack --stack-version 0.2.0` | Pin the stack to an explicit version |
|
|
177
|
+
|
|
178
|
+
If a newer version causes issues, roll back by pinning the previous one again,
|
|
179
|
+
then `pnpm install`.
|
|
180
|
+
{{#if withIac}}
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Deploy (infrastructure as code)
|
|
185
|
+
|
|
186
|
+
This project can provision AWS infrastructure (ECS Fargate) and release the
|
|
187
|
+
app with the `dude iac` command group. Every `iac` command is **scoped to one
|
|
188
|
+
environment via `--env <name>`, which is required** — run any `iac` command
|
|
189
|
+
without `--env` to list the environments discovered on disk.
|
|
190
|
+
|
|
191
|
+
The full runbook — bootstrap, provisioning, building and shipping images, and
|
|
192
|
+
teardown — lives on the **[Deploy (AWS ECS)](deploy.md)** page; the live
|
|
193
|
+
command list is in `dude help` (and the [Command reference](api.md)).
|
|
194
|
+
{{/if}}
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Documentation
|
|
199
|
+
|
|
200
|
+
| Command | Description |
|
|
201
|
+
|---------|-------------|
|
|
202
|
+
| `dude docs` | Serve this documentation in dev mode at <http://localhost:8001> |
|
|
203
|
+
| `dude docs --port 9000` | Use a custom port |
|
|
204
|
+
| `dude help --format md` | Print the full command reference as Markdown |
|
|
205
|
+
| `dude help --format json` | Print the same catalog as JSON (for tooling / LLMs) |
|
|
206
|
+
|
|
207
|
+
The **Command reference** page in this site is auto-generated from the live
|
|
208
|
+
command catalog every time you run `dude docs`, so it always matches your
|
|
209
|
+
project's actual commands — including your `dude init` choices and any
|
|
210
|
+
project-local commands under `.dude/commands/`. (It is gitignored; regenerate it
|
|
211
|
+
any time with `dude docs` or `dude help --format md`.)
|
|
212
|
+
|
|
213
|
+
The docs site live-reloads when you edit files under `docs/docs/`.
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
dude docs
|
|
217
|
+
# → open http://localhost:8001
|
|
218
|
+
# → edit docs/docs/*.md
|
|
219
|
+
# → browser refreshes automatically
|
|
220
|
+
```
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# Extending the app
|
|
2
|
+
|
|
3
|
+
Recipes for the things you will actually do, in the order you will probably do
|
|
4
|
+
them. Each recipe follows the patterns already present in `apps/ticketing/` —
|
|
5
|
+
copy from the example, don't start from a blank file — and ends with the
|
|
6
|
+
`dude lint` rules that check your work (prose descriptions live in
|
|
7
|
+
`.claude/rules/{APP,DT,PY}/`).
|
|
8
|
+
|
|
9
|
+
The universal inner loop:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
dude site migrate # sync schema + fixtures after model/fixture changes
|
|
13
|
+
dude lint # structural checks over apps/
|
|
14
|
+
dude test --app <app>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Add a DocType
|
|
20
|
+
|
|
21
|
+
Two equivalent paths — same result: a JSON schema committed inside your app.
|
|
22
|
+
|
|
23
|
+
=== "Via the Desk UI (recommended)"
|
|
24
|
+
|
|
25
|
+
The site runs with `developer_mode = 1`, so DocTypes created in Desk are
|
|
26
|
+
**written back into the app's source tree**:
|
|
27
|
+
|
|
28
|
+
1. Open <code>/app/doctype/new</code> in Desk.
|
|
29
|
+
2. Set the **Module** to one of your app's modules (e.g. `Ticketing` —
|
|
30
|
+
modules are listed in `apps/<app>/<app>/modules.txt`). The module
|
|
31
|
+
determines *which app on disk* receives the files.
|
|
32
|
+
3. Add fields, tick the permission roles, save.
|
|
33
|
+
4. The full bundle appears under
|
|
34
|
+
`apps/<app>/<app>/<module>/doctype/<snake_case_name>/` — JSON, a stub
|
|
35
|
+
controller, `__init__.py`. Add a `test_<name>.py` (copy the escalation
|
|
36
|
+
rule's) and commit everything.
|
|
37
|
+
|
|
38
|
+
=== "By hand (copy the example)"
|
|
39
|
+
|
|
40
|
+
1. Copy `apps/ticketing/ticketing/ticketing/doctype/ticket_escalation_rule/`
|
|
41
|
+
to a sibling directory named after your DocType (snake_case).
|
|
42
|
+
2. Rename the files inside to match, then edit the JSON: `name`, `module`,
|
|
43
|
+
`autoname`, the `fields` array (snake_case `fieldname`s), and the
|
|
44
|
+
`permissions` array (never leave it empty).
|
|
45
|
+
3. Rename the controller class to the CamelCase DocType name.
|
|
46
|
+
4. Update the test file.
|
|
47
|
+
5. Apply it: `dude site migrate` (creates the table).
|
|
48
|
+
|
|
49
|
+
Either way, finish with:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
dude site migrate
|
|
53
|
+
dude lint
|
|
54
|
+
dude test --app <app>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
!!! tip "Guided version"
|
|
58
|
+
The project ships a Claude skill for this: `/create-doctype` walks through
|
|
59
|
+
the manual path interactively.
|
|
60
|
+
|
|
61
|
+
**Lint rules**: DT001 (complete bundle: JSON + controller + tests together),
|
|
62
|
+
DT002 (permissions declared), DT003 (module registered in `modules.txt`),
|
|
63
|
+
DT004 (snake_case fieldnames), PY003 (tests present).
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Add a scheduled task
|
|
68
|
+
|
|
69
|
+
1. Write a plain, **idempotent** function in `apps/<app>/<app>/tasks.py` —
|
|
70
|
+
`apps/ticketing/ticketing/tasks.py` shows the shape, including the
|
|
71
|
+
"did I already do this?" guard.
|
|
72
|
+
2. Register it in `hooks.py` under `scheduler_events`, keyed by frequency
|
|
73
|
+
(`all`, `hourly`, `daily`, `weekly`, `monthly`, or `cron`):
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
scheduler_events = {
|
|
77
|
+
"hourly": ["ticketing.tasks.escalate_overdue_tickets"],
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
3. Restart (`dude up`) so the scheduler process picks up the new hook.
|
|
82
|
+
4. Don't wait an hour to test it — run it right now:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
dude bench --site all execute ticketing.tasks.escalate_overdue_tickets
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Lint rules**: APP002 (every dotted path declared in `hooks.py` must resolve
|
|
89
|
+
to a real function).
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Hook another app's DocType (doc_events)
|
|
94
|
+
|
|
95
|
+
To run your code when *someone else's* documents change — the way `ticketing`
|
|
96
|
+
extends `HD Ticket` without forking Helpdesk:
|
|
97
|
+
|
|
98
|
+
1. Write handlers as plain functions taking `(doc, method)` in a dedicated
|
|
99
|
+
module — see `apps/ticketing/ticketing/events/hd_ticket.py`.
|
|
100
|
+
2. Declare them in `hooks.py` under `doc_events`:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
doc_events = {
|
|
104
|
+
"HD Ticket": {
|
|
105
|
+
"after_insert": "ticketing.events.hd_ticket.after_insert",
|
|
106
|
+
"on_update": "ticketing.events.hd_ticket.on_update",
|
|
107
|
+
},
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
3. Restart (`dude up`). Available events include `validate`, `before_save`,
|
|
112
|
+
`after_insert`, `on_update`, `on_submit`, `on_trash`, ….
|
|
113
|
+
|
|
114
|
+
Hooks on a DocType that isn't installed are harmless — the handlers simply
|
|
115
|
+
never fire (which is why the example app also works without Helpdesk).
|
|
116
|
+
Detect field changes with `doc.get_doc_before_save()`, as `on_update` does.
|
|
117
|
+
|
|
118
|
+
**Lint rules**: APP002 (handler dotted paths must resolve).
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Add a workflow
|
|
123
|
+
|
|
124
|
+
Workflows are **records, not code**, so the loop is: build in the UI, export
|
|
125
|
+
as a fixture, declare in `hooks.py`.
|
|
126
|
+
|
|
127
|
+
1. In Desk, create the Workflow (search "Workflow"): pick the DocType, define
|
|
128
|
+
the states, and the role-restricted transitions between them.
|
|
129
|
+
2. Declare it (and its linked masters — order matters) in `hooks.py`:
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
fixtures = [
|
|
133
|
+
{"dt": "Workflow State", "filters": [["name", "in", ["Draft", "Approved", "Rejected"]]]},
|
|
134
|
+
{"dt": "Workflow Action Master", "filters": [["name", "in", ["Approve", "Reject"]]]},
|
|
135
|
+
{"dt": "Workflow", "filters": [["name", "in", ["My Workflow"]]]},
|
|
136
|
+
]
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
3. Export the records into the app:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
dude bench --site all export-fixtures --app <app>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
JSON files land in `apps/<app>/<app>/fixtures/` — commit them. From now
|
|
146
|
+
on every `dude site migrate` re-imports them, so the workflow exists on
|
|
147
|
+
every environment.
|
|
148
|
+
|
|
149
|
+
`apps/ticketing/ticketing/fixtures/workflow.json` is the shipped example
|
|
150
|
+
(Draft → Approved/Rejected on `Ticket Escalation Rule`).
|
|
151
|
+
|
|
152
|
+
!!! warning "Filters are not optional"
|
|
153
|
+
Always filter fixtures to *your* records (as above). `{"dt": "Workflow"}`
|
|
154
|
+
with no filters would export every workflow on the site — including other
|
|
155
|
+
apps' — into your app.
|
|
156
|
+
|
|
157
|
+
**Lint rules**: APP003 (fixtures declared in `hooks.py` ↔ JSON files shipped
|
|
158
|
+
in `fixtures/` stay in sync).
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Add a portal page
|
|
163
|
+
|
|
164
|
+
A server-rendered public web page:
|
|
165
|
+
|
|
166
|
+
1. Create the pair under `apps/<app>/<app>/templates/pages/`:
|
|
167
|
+
`<route>.html` (Jinja template) and `<route>.py` with a
|
|
168
|
+
`get_context(context)` function. The route is the filename:
|
|
169
|
+
`ticket_stats.*` → `/ticket_stats`.
|
|
170
|
+
2. Put data on `context` in `get_context` — it becomes available to the
|
|
171
|
+
template. Set `context.no_cache = 1` for dynamic pages.
|
|
172
|
+
3. No registration needed. If the page doesn't show up, clear the website
|
|
173
|
+
cache: `dude site clear-cache`.
|
|
174
|
+
|
|
175
|
+
Example: `apps/ticketing/ticketing/templates/pages/ticket_stats.{py,html}` —
|
|
176
|
+
note how the `.py` reuses the whitelisted API function rather than duplicating
|
|
177
|
+
the query.
|
|
178
|
+
|
|
179
|
+
**Lint rules**: PY002 (no string-interpolated SQL — use `frappe.get_all` /
|
|
180
|
+
parameterised queries in your context code).
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Add an API endpoint
|
|
185
|
+
|
|
186
|
+
1. Add a function to `apps/<app>/<app>/api.py` and decorate it:
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
@frappe.whitelist()
|
|
190
|
+
def my_endpoint() -> dict:
|
|
191
|
+
...
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
2. It is immediately callable at `/api/method/<app>.api.my_endpoint`
|
|
195
|
+
(authenticated by session cookie or API token).
|
|
196
|
+
3. Query through the ORM (`frappe.get_all`, `frappe.get_doc`) so DocType
|
|
197
|
+
permissions are respected; take parameters as keyword arguments.
|
|
198
|
+
|
|
199
|
+
Do **not** add `allow_guest=True` unless the data is genuinely public — every
|
|
200
|
+
guest-exposed method is an unauthenticated door into your site.
|
|
201
|
+
|
|
202
|
+
Example: `apps/ticketing/ticketing/api.py` (`ticket_stats`), consumed by both
|
|
203
|
+
the portal page and HTTP clients.
|
|
204
|
+
|
|
205
|
+
**Lint rules**: PY001 (guest-exposed whitelisted methods are flagged), PY002
|
|
206
|
+
(no raw/interpolated SQL).
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Create a whole new app
|
|
211
|
+
|
|
212
|
+
When a feature doesn't belong in `ticketing`, give it its own app:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
dude app new --name my_app # bench new-app, relocated into apps/my_app
|
|
216
|
+
dude app install --name my_app # install it on the site
|
|
217
|
+
dude up # restart so init.sh links everything
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The new app lives in `apps/my_app/` in this repo, symlinked into the bench in
|
|
221
|
+
editable mode — exactly like `ticketing`. From here, every recipe above
|
|
222
|
+
applies; keep its `hooks.py` declarative and give each DocType the full
|
|
223
|
+
bundle.
|
|
224
|
+
|
|
225
|
+
**Lint rules**: APP001 (canonical app layout: `pyproject.toml`,
|
|
226
|
+
`<app>/hooks.py`, `<app>/modules.txt`, …) — and everything else on this page
|
|
227
|
+
as the app grows.
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Verify everything
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
dude lint # all APP/DT/PY structural checks; exit 1 on errors
|
|
235
|
+
dude review # lint + ruff check in one pass
|
|
236
|
+
dude test # the ticketing app's tests (use --app for others)
|
|
237
|
+
dude format # ruff format + autofix (Frappe style — tabs)
|
|
238
|
+
```
|