From 2dcce0335250a593e7990ad5717ec997cfc143a7 Mon Sep 17 00:00:00 2001
From: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com>
Date: Wed, 20 Mar 2024 21:25:33 +0100
Subject: [PATCH] chore(server): move commands (#8121)

move commands
---
 .../commands/list-users.command.ts                  | 13 +++++++++++--
 .../src/{immich-admin => }/commands/oauth-login.ts  |  0
 .../{immich-admin => }/commands/password-login.ts   |  0
 .../commands/reset-admin-password.command.ts        |  0
 server/src/immich-admin/app.module.ts               | 11 ++++-------
 server/src/immich-admin/constants.ts                | 10 ----------
 6 files changed, 15 insertions(+), 19 deletions(-)
 rename server/src/{immich-admin => }/commands/list-users.command.ts (62%)
 rename server/src/{immich-admin => }/commands/oauth-login.ts (100%)
 rename server/src/{immich-admin => }/commands/password-login.ts (100%)
 rename server/src/{immich-admin => }/commands/reset-admin-password.command.ts (100%)
 delete mode 100644 server/src/immich-admin/constants.ts

diff --git a/server/src/immich-admin/commands/list-users.command.ts b/server/src/commands/list-users.command.ts
similarity index 62%
rename from server/src/immich-admin/commands/list-users.command.ts
rename to server/src/commands/list-users.command.ts
index 8ab882396e..eeda72d1c2 100644
--- a/server/src/immich-admin/commands/list-users.command.ts
+++ b/server/src/commands/list-users.command.ts
@@ -1,6 +1,6 @@
 import { Command, CommandRunner } from 'nest-commander';
 import { UserService } from 'src/domain/user/user.service';
-import { CLI_USER } from 'src/immich-admin/constants';
+import { UserEntity } from 'src/infra/entities/user.entity';
 
 @Command({
   name: 'list-users',
@@ -13,7 +13,16 @@ export class ListUsersCommand extends CommandRunner {
 
   async run(): Promise<void> {
     try {
-      const users = await this.userService.getAll(CLI_USER, true);
+      const users = await this.userService.getAll(
+        {
+          user: {
+            id: 'cli',
+            email: 'cli@immich.app',
+            isAdmin: true,
+          } as UserEntity,
+        },
+        true,
+      );
       console.dir(users);
     } catch (error) {
       console.error(error);
diff --git a/server/src/immich-admin/commands/oauth-login.ts b/server/src/commands/oauth-login.ts
similarity index 100%
rename from server/src/immich-admin/commands/oauth-login.ts
rename to server/src/commands/oauth-login.ts
diff --git a/server/src/immich-admin/commands/password-login.ts b/server/src/commands/password-login.ts
similarity index 100%
rename from server/src/immich-admin/commands/password-login.ts
rename to server/src/commands/password-login.ts
diff --git a/server/src/immich-admin/commands/reset-admin-password.command.ts b/server/src/commands/reset-admin-password.command.ts
similarity index 100%
rename from server/src/immich-admin/commands/reset-admin-password.command.ts
rename to server/src/commands/reset-admin-password.command.ts
diff --git a/server/src/immich-admin/app.module.ts b/server/src/immich-admin/app.module.ts
index 277b39a902..b491fbb556 100644
--- a/server/src/immich-admin/app.module.ts
+++ b/server/src/immich-admin/app.module.ts
@@ -1,12 +1,9 @@
 import { Module } from '@nestjs/common';
+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 { DomainModule } from 'src/domain/domain.module';
-import { ListUsersCommand } from 'src/immich-admin/commands/list-users.command';
-import { DisableOAuthLogin, EnableOAuthLogin } from 'src/immich-admin/commands/oauth-login';
-import { DisablePasswordLoginCommand, EnablePasswordLoginCommand } from 'src/immich-admin/commands/password-login';
-import {
-  PromptPasswordQuestions,
-  ResetAdminPasswordCommand,
-} from 'src/immich-admin/commands/reset-admin-password.command';
 import { InfraModule } from 'src/infra/infra.module';
 
 @Module({
diff --git a/server/src/immich-admin/constants.ts b/server/src/immich-admin/constants.ts
deleted file mode 100644
index 237f66e637..0000000000
--- a/server/src/immich-admin/constants.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { AuthDto } from 'src/domain/auth/auth.dto';
-import { UserEntity } from 'src/infra/entities/user.entity';
-
-export const CLI_USER: AuthDto = {
-  user: {
-    id: 'cli',
-    email: 'cli@immich.app',
-    isAdmin: true,
-  } as UserEntity,
-};