-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(cli): organize files, simplify types, use @immich/sdk #6747
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,21 @@ | ||
import { ImmichApi } from '../api/client'; | ||
import { SessionService } from '../services/session.service'; | ||
import { LoginError } from '../cores/errors/login-error'; | ||
import { exit } from 'node:process'; | ||
import { ServerVersionResponseDto, UserResponseDto } from '@immich/sdk'; | ||
import { BaseOptionsDto } from 'src/cores/dto/base-options-dto'; | ||
import { ImmichApi } from '../services/api.service'; | ||
import { SessionService } from '../services/session.service'; | ||
|
||
export abstract class BaseCommand { | ||
protected sessionService!: SessionService; | ||
protected immichApi!: ImmichApi; | ||
protected user!: UserResponseDto; | ||
protected serverVersion!: ServerVersionResponseDto; | ||
|
||
constructor(options: BaseOptionsDto) { | ||
constructor(options: { config?: string }) { | ||
if (!options.config) { | ||
throw new Error('Config directory is required'); | ||
} | ||
this.sessionService = new SessionService(options.config); | ||
} | ||
|
||
public async connect(): Promise<void> { | ||
try { | ||
this.immichApi = await this.sessionService.connect(); | ||
} catch (error) { | ||
if (error instanceof LoginError) { | ||
console.log(error.message); | ||
exit(1); | ||
} else { | ||
throw error; | ||
} | ||
} | ||
this.immichApi = await this.sessionService.connect(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { BaseCommand } from './base-command'; | ||
|
||
export class LoginCommand extends BaseCommand { | ||
public async run(instanceUrl: string, apiKey: string): Promise<void> { | ||
await this.sessionService.login(instanceUrl, apiKey); | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { BaseCommand } from './base-command'; | ||
|
||
export class LogoutCommand extends BaseCommand { | ||
public static readonly description = 'Logout and remove persisted credentials'; | ||
public async run(): Promise<void> { | ||
await this.sessionService.logout(); | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { BaseCommand } from './base-command'; | ||
|
||
export class ServerInfoCommand extends BaseCommand { | ||
public async run() { | ||
await this.connect(); | ||
const { data: versionInfo } = await this.immichApi.serverInfoApi.getServerVersion(); | ||
const { data: mediaTypes } = await this.immichApi.serverInfoApi.getSupportedMediaTypes(); | ||
const { data: statistics } = await this.immichApi.assetApi.getAssetStatistics(); | ||
|
||
console.log(`Server Version: ${versionInfo.major}.${versionInfo.minor}.${versionInfo.patch}`); | ||
console.log(`Image Types: ${mediaTypes.image.map((extension) => extension.replace('.', ''))}`); | ||
console.log(`Video Types: ${mediaTypes.video.map((extension) => extension.replace('.', ''))}`); | ||
console.log( | ||
`Statistics:\n Images: ${statistics.images}\n Videos: ${statistics.videos}\n Total: ${statistics.total}`, | ||
); | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally you get a
.xmp
after the original extension, sofoo.jpg.xmp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually not standardized! I've used a bunch of photo tools in my workflow and some use foo.xmp and some use foo.jpg.xmp. This is something on my backlog to fix across all of Immich, currently we only support one format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh really? I hate this.