mirror of
https://github.com/immich-app/immich.git
synced 2026-02-12 03:47:51 +03:00
* Allow building and installing cli * feat: add format fix * docs: remove cli folder * feat: use immich scoped package * feat: rewrite cli readme * docs: add info on running without building * cleanup * chore: remove import functionality from cli * feat: add logout to cli * docs: add todo for file format from server * docs: add compilation step to cli * fix: success message spacing * feat: can create albums * fix: add check step to cli * fix: typos * feat: pull file formats from server * chore: use crawl service from server * chore: fix lint * docs: add cli documentation * chore: rename ignore pattern * chore: add version number to cli * feat: use sdk * fix: cleanup * feat: album name on windows * chore: remove skipped asset field * feat: add more info to server-info command * chore: cleanup * chore: remove unneeded packages * chore: fix docs links * feat: add cli v2 milestone * fix: set correct cli date --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
29 lines
839 B
TypeScript
29 lines
839 B
TypeScript
import { CrawlOptionsDto } from 'src/cores/dto/crawl-options-dto';
|
|
import { glob } from 'glob';
|
|
|
|
export class CrawlService {
|
|
private readonly extensions!: string[];
|
|
|
|
constructor(image: string[], video: string[]) {
|
|
this.extensions = image.concat(video).map((extension) => extension.replace('.', ''));
|
|
}
|
|
|
|
crawl(crawlOptions: CrawlOptionsDto): Promise<string[]> {
|
|
const { pathsToCrawl, exclusionPatterns, includeHidden } = crawlOptions;
|
|
if (!pathsToCrawl) {
|
|
return Promise.resolve([]);
|
|
}
|
|
|
|
const base = pathsToCrawl.length === 1 ? pathsToCrawl[0] : `{${pathsToCrawl.join(',')}}`;
|
|
const extensions = `*{${this.extensions}}`;
|
|
|
|
return glob(`${base}/**/${extensions}`, {
|
|
absolute: true,
|
|
nocase: true,
|
|
nodir: true,
|
|
dot: includeHidden,
|
|
ignore: exclusionPatterns,
|
|
});
|
|
}
|
|
}
|