mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(cli): organize files, simplify types, use @immich/sdk (#6747)
This commit is contained in:
parent
64fad67713
commit
64da2c1698
32 changed files with 308 additions and 350 deletions
|
|
@ -1,13 +1,31 @@
|
|||
import { BaseOptionsDto } from 'src/cores/dto/base-options-dto';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { ImmichApi } from '../src/services/api.service';
|
||||
|
||||
export const TEST_CONFIG_DIR = '/tmp/immich/';
|
||||
export const TEST_AUTH_FILE = path.join(TEST_CONFIG_DIR, 'auth.yml');
|
||||
export const TEST_IMMICH_INSTANCE_URL = 'https://test/api';
|
||||
export const TEST_IMMICH_API_KEY = 'pNussssKSYo5WasdgalvKJ1n9kdvaasdfbluPg';
|
||||
|
||||
export const CLI_BASE_OPTIONS: BaseOptionsDto = { config: TEST_CONFIG_DIR };
|
||||
export const CLI_BASE_OPTIONS = { config: TEST_CONFIG_DIR };
|
||||
|
||||
export const setup = async () => {
|
||||
const api = new ImmichApi(process.env.IMMICH_INSTANCE_URL as string, '');
|
||||
await api.authenticationApi.signUpAdmin({
|
||||
signUpDto: { email: 'cli@immich.app', password: 'password', name: 'Administrator' },
|
||||
});
|
||||
const { data: admin } = await api.authenticationApi.login({
|
||||
loginCredentialDto: { email: 'cli@immich.app', password: 'password' },
|
||||
});
|
||||
const { data: apiKey } = await api.keyApi.createApiKey(
|
||||
{ aPIKeyCreateDto: { name: 'CLI Test' } },
|
||||
{ headers: { Authorization: `Bearer ${admin.accessToken}` } },
|
||||
);
|
||||
|
||||
api.setApiKey(apiKey.secret);
|
||||
|
||||
return api;
|
||||
};
|
||||
|
||||
export const spyOnConsole = () => jest.spyOn(console, 'log').mockImplementation();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue