[tools]
node = "24.11.0"
flutter = "3.35.7"
pnpm = "10.19.0"
terragrunt = "0.91.2"
opentofu = "1.10.6"

[tools."github:CQLabs/homebrew-dcm"]
version = "1.30.0"
bin = "dcm"
postinstall = "chmod +x $MISE_TOOL_INSTALL_PATH/dcm"

[settings]
experimental = true
pin = true

# .github
[tasks."github:install"]
run = "pnpm install --filter github --frozen-lockfile"

[tasks."github:format"]
env._.path = "./.github/node_modules/.bin"
dir = ".github"
run = "prettier --check ."

[tasks."github:format-fix"]
env._.path = "./.github/node_modules/.bin"
dir = ".github"
run = "prettier --write ."

# @immich/cli
[tasks."cli:install"]
run = "pnpm install --filter @immich/cli --frozen-lockfile"

[tasks."cli:build"]
env._.path = "./cli/node_modules/.bin"
dir = "cli"
run = "vite build"

[tasks."cli:test"]
env._.path = "./cli/node_modules/.bin"
dir = "cli"
run = "vite"

[tasks."cli:lint"]
env._.path = "./cli/node_modules/.bin"
dir = "cli"
run = "eslint \"src/**/*.ts\" --max-warnings 0"

[tasks."cli:lint-fix"]
run = "mise run cli:lint --fix"

[tasks."cli:format"]
env._.path = "./cli/node_modules/.bin"
dir = "cli"
run = "prettier --check ."

[tasks."cli:format-fix"]
env._.path = "./cli/node_modules/.bin"
dir = "cli"
run = "prettier --write ."

[tasks."cli:check"]
env._.path = "./cli/node_modules/.bin"
dir = "cli"
run = "tsc --noEmit"

# @immich/sdk
[tasks."sdk:install"]
run = "pnpm install --filter @immich/sdk --frozen-lockfile"

[tasks."sdk:build"]
env._.path = "./open-api/typescript-sdk/node_modules/.bin"
dir = "./open-api/typescript-sdk"
run = "tsc"

# docs
[tasks."docs:install"]
run = "pnpm install --filter documentation --frozen-lockfile"

[tasks."docs:start"]
env._.path = "./docs/node_modules/.bin"
dir = "docs"
run = "docusaurus --port 3005"

[tasks."docs:build"]
env._.path = "./docs/node_modules/.bin"
dir = "docs"
run = [
  "jq -c < ../open-api/immich-openapi-specs.json > ./static/openapi.json || exit 0",
  "docusaurus build",
]


[tasks."docs:preview"]
env._.path = "./docs/node_modules/.bin"
dir = "docs"
run = "docusaurus serve"


[tasks."docs:format"]
env._.path = "./docs/node_modules/.bin"
dir = "docs"
run = "prettier --check ."

[tasks."docs:format-fix"]
env._.path = "./docs/node_modules/.bin"
dir = "docs"
run = "prettier --write ."


# e2e
[tasks."e2e:install"]
run = "pnpm install --filter immich-e2e --frozen-lockfile"

[tasks."e2e:test"]
env._.path = "./e2e/node_modules/.bin"
dir = "e2e"
run = "vitest --run"

[tasks."e2e:test-web"]
env._.path = "./e2e/node_modules/.bin"
dir = "e2e"
run = "playwright test"

[tasks."e2e:format"]
env._.path = "./e2e/node_modules/.bin"
dir = "e2e"
run = "prettier --check ."

[tasks."e2e:format-fix"]
env._.path = "./e2e/node_modules/.bin"
dir = "e2e"
run = "prettier --write ."

[tasks."e2e:lint"]
env._.path = "./e2e/node_modules/.bin"
dir = "e2e"
run = "eslint \"src/**/*.ts\" --max-warnings 0"

[tasks."e2e:lint-fix"]
run = "mise run e2e:lint --fix"

[tasks."e2e:check"]
env._.path = "./e2e/node_modules/.bin"
dir = "e2e"
run = "tsc --noEmit"

# i18n
[tasks."i18n:format"]
run = "mise run i18n:format-fix"

[tasks."i18n:format-fix"]
run = "pnpm dlx sort-json ./i18n/*.json"


# server
[tasks."server:install"]
run = "pnpm install --filter immich --frozen-lockfile"

[tasks."server:build"]
env._.path = "./server/node_modules/.bin"
dir = "server"
run = "nest build"

[tasks."server:test"]
env._.path = "./server/node_modules/.bin"
dir = "server"
run = "vitest --config test/vitest.config.mjs"

[tasks."server:test-medium"]
env._.path = "./server/node_modules/.bin"
dir = "server"
run = "vitest --config test/vitest.config.medium.mjs"

[tasks."server:format"]
env._.path = "./server/node_modules/.bin"
dir = "server"
run = "prettier --check ."

[tasks."server:format-fix"]
env._.path = "./server/node_modules/.bin"
dir = "server"
run = "prettier --write ."

[tasks."server:lint"]
env._.path = "./server/node_modules/.bin"
dir = "server"
run = "eslint \"src/**/*.ts\" \"test/**/*.ts\" --max-warnings 0"

[tasks."server:lint-fix"]
run = "mise run server:lint --fix"

[tasks."server:check"]
env._.path = "./server/node_modules/.bin"
dir = "server"
run = "tsc --noEmit"

[tasks."server:sql"]
dir = "server"
run = "node ./dist/bin/sync-open-api.js"

[tasks."server:open-api"]
dir = "server"
run = "node ./dist/bin/sync-open-api.js"

[tasks."server:migrations"]
dir = "server"
run = "node ./dist/bin/migrations.js"
description = "Run database migration commands (create, generate, run, debug, or query)"

[tasks."server:schema-drop"]
run = "mise run server:migrations query 'DROP schema public cascade; CREATE schema public;'"

[tasks."server:schema-reset"]
run = "mise run server:schema-drop && mise run server:migrations run"

[tasks."server:email-dev"]
env._.path = "./server/node_modules/.bin"
dir = "server"
run = "email dev -p 3050 --dir src/emails"

[tasks."server:checklist"]
run = [
  "mise run server:install",
  "mise run server:format",
  "mise run server:lint",
  "mise run server:check",
  "mise run server:test-medium --run",
  "mise run server:test --run",
]


# web
[tasks."web:install"]
run = "pnpm install --filter immich-web --frozen-lockfile"

[tasks."web:svelte-kit-sync"]
env._.path = "./web/node_modules/.bin"
dir = "web"
run = "svelte-kit sync"

[tasks."web:build"]
env._.path = "./web/node_modules/.bin"
dir = "web"
run = "vite build"

[tasks."web:build-stats"]
env.BUILD_STATS = "true"
env._.path = "./web/node_modules/.bin"
dir = "web"
run = "vite build"

[tasks."web:preview"]
env._.path = "./web/node_modules/.bin"
dir = "web"
run = "vite preview"

[tasks."web:start"]
env._.path = "web/node_modules/.bin"
dir = "web"
run = "vite dev --host 0.0.0.0 --port 3000"

[tasks."web:test"]
depends = "web:svelte-kit-sync"
env._.path = "web/node_modules/.bin"
dir = "web"
run = "vitest"

[tasks."web:format"]
env._.path = "web/node_modules/.bin"
dir = "web"
run = "prettier --check ."

[tasks."web:format-fix"]
env._.path = "web/node_modules/.bin"
dir = "web"
run = "prettier --write ."

[tasks."web:lint"]
env._.path = "web/node_modules/.bin"
dir = "web"
run = "eslint . --max-warnings 0 --concurrency 4"

[tasks."web:lint-fix"]
run = "mise run web:lint --fix"

[tasks."web:check"]
depends = "web:svelte-kit-sync"
env._.path = "web/node_modules/.bin"
dir = "web"
run = "tsc --noEmit"

[tasks."web:check-svelte"]
depends = "web:svelte-kit-sync"
env._.path = "web/node_modules/.bin"
dir = "web"
run = "svelte-check --no-tsconfig --fail-on-warnings"

[tasks."web:checklist"]
run = [
  "mise run web:install",
  "mise run web:format",
  "mise run web:check",
  "mise run web:test --run",
  "mise run web:lint",
]


# mobile
[tasks."mobile:codegen:dart"]
alias = "mobile:codegen"
description = "Execute build_runner to auto-generate dart code"
dir = "mobile"
sources = [
  "pubspec.yaml",
  "build.yaml",
  "lib/**/*.dart",
  "infrastructure/**/*.drift",
]
outputs = { auto = true }
run = "dart run build_runner build --delete-conflicting-outputs"

[tasks."mobile:codegen:pigeon"]
alias = "mobile:pigeon"
description = "Generate pigeon platform code"
dir = "mobile"
depends = [
  "mobile:pigeon:native-sync",
  "mobile:pigeon:thumbnail",
  "mobile:pigeon:background-worker",
  "mobile:pigeon:background-worker-lock",
  "mobile:pigeon:connectivity",
]

[tasks."mobile:codegen:translation"]
alias = "mobile:translation"
description = "Generate translations from i18n JSONs"
dir = "mobile"
run = [
  { task = "i18n:format-fix" },
  { tasks = [
    "mobile:i18n:loader",
    "mobile:i18n:keys",
  ] },
]

[tasks."mobile:codegen:app-icon"]
description = "Generate app icons"
dir = "mobile"
run = "flutter pub run flutter_launcher_icons:main"

[tasks."mobile:codegen:splash"]
description = "Generate splash screen"
dir = "mobile"
run = "flutter pub run flutter_native_splash:create"

[tasks."mobile:test"]
description = "Run mobile tests"
dir = "mobile"
run = "flutter test"

[tasks."mobile:lint"]
description = "Analyze Dart code"
dir = "mobile"
depends = ["mobile:analyze:dart", "mobile:analyze:dcm"]

[tasks."mobile:lint-fix"]
description = "Auto-fix Dart code"
dir = "mobile"
depends = ["mobile:analyze:fix:dart", "mobile:analyze:fix:dcm"]

[tasks."mobile:format"]
description = "Format Dart code"
dir = "mobile"
run = "dart format --set-exit-if-changed $(find lib -name '*.dart' -not \\( -name '*.g.dart' -o -name '*.drift.dart' -o -name '*.gr.dart' \\))"

[tasks."mobile:build:android"]
description = "Build Android release"
dir = "mobile"
run = "flutter build appbundle"

[tasks."mobile:drift:migration"]
alias = "mobile:migration"
description = "Generate database migrations"
dir = "mobile"
run = "dart run drift_dev make-migrations"


# mobile internal tasks
[tasks."mobile:pigeon:native-sync"]
description = "Generate native sync API pigeon code"
dir = "mobile"
hide = true
sources = ["pigeon/native_sync_api.dart"]
outputs = [
  "lib/platform/native_sync_api.g.dart",
  "ios/Runner/Sync/Messages.g.swift",
  "android/app/src/main/kotlin/app/alextran/immich/sync/Messages.g.kt",
]
run = [
  "dart run pigeon --input pigeon/native_sync_api.dart",
  "dart format lib/platform/native_sync_api.g.dart",
]

[tasks."mobile:pigeon:thumbnail"]
description = "Generate thumbnail API pigeon code"
dir = "mobile"
hide = true
sources = ["pigeon/thumbnail_api.dart"]
outputs = [
  "lib/platform/thumbnail_api.g.dart",
  "ios/Runner/Images/Thumbnails.g.swift",
  "android/app/src/main/kotlin/app/alextran/immich/images/Thumbnails.g.kt",
]
run = [
  "dart run pigeon --input pigeon/thumbnail_api.dart",
  "dart format lib/platform/thumbnail_api.g.dart",
]

[tasks."mobile:pigeon:background-worker"]
description = "Generate background worker API pigeon code"
dir = "mobile"
hide = true
sources = ["pigeon/background_worker_api.dart"]
outputs = [
  "lib/platform/background_worker_api.g.dart",
  "ios/Runner/Background/BackgroundWorker.g.swift",
  "android/app/src/main/kotlin/app/alextran/immich/background/BackgroundWorker.g.kt",
]
run = [
  "dart run pigeon --input pigeon/background_worker_api.dart",
  "dart format lib/platform/background_worker_api.g.dart",
]

[tasks."mobile:pigeon:background-worker-lock"]
description = "Generate background worker lock API pigeon code"
dir = "mobile"
hide = true
sources = ["pigeon/background_worker_lock_api.dart"]
outputs = [
  "lib/platform/background_worker_lock_api.g.dart",
  "android/app/src/main/kotlin/app/alextran/immich/background/BackgroundWorkerLock.g.kt",
]
run = [
  "dart run pigeon --input pigeon/background_worker_lock_api.dart",
  "dart format lib/platform/background_worker_lock_api.g.dart",
]

[tasks."mobile:pigeon:connectivity"]
description = "Generate connectivity API pigeon code"
dir = "mobile"
hide = true
sources = ["pigeon/connectivity_api.dart"]
outputs = [
  "lib/platform/connectivity_api.g.dart",
  "ios/Runner/Connectivity/Connectivity.g.swift",
  "android/app/src/main/kotlin/app/alextran/immich/connectivity/Connectivity.g.kt",
]
run = [
  "dart run pigeon --input pigeon/connectivity_api.dart",
  "dart format lib/platform/connectivity_api.g.dart",
]

[tasks."mobile:i18n:loader"]
description = "Generate i18n loader"
dir = "mobile"
hide = true
sources = ["i18n/"]
outputs = "lib/generated/codegen_loader.g.dart"
run = [
  "dart run easy_localization:generate -S ../i18n",
  "dart format lib/generated/codegen_loader.g.dart",
]

[tasks."mobile:i18n:keys"]
description = "Generate i18n keys"
dir = "mobile"
hide = true
sources = ["i18n/en.json"]
outputs = "lib/generated/intl_keys.g.dart"
run = [
  "dart run bin/generate_keys.dart",
  "dart format lib/generated/intl_keys.g.dart",
]

[tasks."mobile:analyze:dart"]
description = "Run Dart analysis"
dir = "mobile"
hide = true
run = "dart analyze --fatal-infos"

[tasks."mobile:analyze:dcm"]
description = "Run Dart Code Metrics"
dir = "mobile"
hide = true
run = "dcm analyze lib --fatal-style --fatal-warnings"

[tasks."mobile:analyze:fix:dart"]
description = "Auto-fix Dart analysis"
dir = "mobile"
hide = true
run = "dart fix --apply"

[tasks."mobile:analyze:fix:dcm"]
description = "Auto-fix Dart Code Metrics"
dir = "mobile"
hide = true
run = "dcm fix lib"

# docs deployment
[tasks."tg:fmt"]
run = "terragrunt hclfmt"
description = "Format terragrunt files"

[tasks.tf]
run = "terragrunt run --all"
description = "Wrapper for terragrunt run-all"
dir = "{{cwd}}"

[tasks."tf:fmt"]
run = "tofu fmt -recursive tf/"
description = "Format terraform files"

[tasks."tf:init"]
run = "mise run tf init -- -reconfigure"
dir = "{{cwd}}"
