From d0e283f687fd190d01f76c2e0d171f382e64f2b0 Mon Sep 17 00:00:00 2001 From: Abhinav Valecha Date: Mon, 17 Mar 2025 23:27:59 +0530 Subject: [PATCH] feat(server): version command for immich-admin #9611 (#16924) * feat(server): Add version command for immich-admin #9611 * chore: clean up --------- Co-authored-by: Jason Rasmussen --- docs/docs/administration/server-commands.md | 8 +++++++ server/src/commands/index.ts | 2 ++ server/src/commands/version.command.ts | 24 +++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 server/src/commands/version.command.ts diff --git a/docs/docs/administration/server-commands.md b/docs/docs/administration/server-commands.md index 355ee10e39..b414f5deaa 100644 --- a/docs/docs/administration/server-commands.md +++ b/docs/docs/administration/server-commands.md @@ -11,6 +11,7 @@ The `immich-server` docker image comes preinstalled with an administrative CLI ( | `enable-oauth-login` | Enable OAuth login | | `disable-oauth-login` | Disable OAuth login | | `list-users` | List Immich users | +| `version` | Print Immich version | ## How to run a command @@ -80,3 +81,10 @@ immich-admin list-users } ] ``` + +Print Immich Version + +``` +immich-admin version +v1.129.0 +``` diff --git a/server/src/commands/index.ts b/server/src/commands/index.ts index 016a26cb34..59846628bf 100644 --- a/server/src/commands/index.ts +++ b/server/src/commands/index.ts @@ -2,6 +2,7 @@ import { ListUsersCommand } from 'src/commands/list-users.command'; import { DisableOAuthLogin, EnableOAuthLogin } from 'src/commands/oauth-login'; import { DisablePasswordLoginCommand, EnablePasswordLoginCommand } from 'src/commands/password-login'; import { PromptPasswordQuestions, ResetAdminPasswordCommand } from 'src/commands/reset-admin-password.command'; +import { VersionCommand } from 'src/commands/version.command'; export const commands = [ ResetAdminPasswordCommand, @@ -11,4 +12,5 @@ export const commands = [ EnableOAuthLogin, DisableOAuthLogin, ListUsersCommand, + VersionCommand, ]; diff --git a/server/src/commands/version.command.ts b/server/src/commands/version.command.ts new file mode 100644 index 0000000000..585f097b6a --- /dev/null +++ b/server/src/commands/version.command.ts @@ -0,0 +1,24 @@ +import { Command, CommandRunner } from 'nest-commander'; +import { VersionService } from 'src/services/version.service'; + +@Command({ + name: 'version', + description: 'Print Immich version', +}) +export class VersionCommand extends CommandRunner { + constructor(private service: VersionService) { + super(); + } + + run(): Promise { + try { + const version = this.service.getVersion(); + console.log(`v${version.major}.${version.minor}.${version.patch}`); + } catch (error) { + console.error(error); + console.error('Unable to get version'); + } + + return Promise.resolve(); + } +}