forked from dark_thunder/immich

* 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 * wip * chore: remove unneeded packages * e2e test can start * git ignore for geocode in cli * add cli e2e to github actions * can do e2e tests in the cli * simplify e2e test * cleanup * set matrix strategy in workflow * run npm ci in server * choose different working directory * check out submodules too * increase test timeout * set node version * cli docker e2e tests * fix cli docker file * run cli e2e in correct folder * set docker context * correct docker build * remove cli from dockerignore * chore: fix docs links * feat: add cli v2 milestone * fix: set correct cli date * remove submodule * chore: add npmignore * chore(cli): push to npm * fix: server e2e * run npm ci in server * remove state from e2e * run npm ci in server * reshuffle docker compose files * use new e2e composes in makefile * increase test timeout to 10 minutes * make github actions run makefile e2e tests * cleanup github test names * assert on server version * chore: split cli e2e tests into one file per command * chore: set cli release working dir * chore: add repo url to npmjs * chore: bump node setup to v4 * chore: normalize the github url * check e2e code in lint * fix lint * test key login flow * feat: allow configurable config dir * fix session service tests * create missing dir * cleanup * bump cli version to 2.0.4 * remove form-data * feat: allow single files as argument * add version option * bump dependencies * fix lint * wip use axios as upload * version bump * cApiTALiZaTiON * don't touch package lock * wip: don't use job queues * don't use make for cli e2e * fix server e2e * feat: always skip hashing when adding albums * feat: create album with specific name * check asset duplication before adding to album * update documentation * use correct check for when to create albums --------- Co-authored-by: Alex <alex.tran1502@gmail.com> Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
76 lines
2.5 KiB
JavaScript
76 lines
2.5 KiB
JavaScript
#! /usr/bin/env node
|
|
|
|
import { Option, Command } from 'commander';
|
|
import Upload from './commands/upload';
|
|
import ServerInfo from './commands/server-info';
|
|
import LoginKey from './commands/login/key';
|
|
import Logout from './commands/logout';
|
|
import { version } from '../package.json';
|
|
|
|
import path from 'node:path';
|
|
import os from 'os';
|
|
|
|
const userHomeDir = os.homedir();
|
|
const configDir = path.join(userHomeDir, '.config/immich/');
|
|
|
|
const program = new Command()
|
|
.name('immich')
|
|
.version(version)
|
|
.description('Command line interface for Immich')
|
|
.addOption(new Option('-d, --config', 'Configuration directory').env('IMMICH_CONFIG_DIR').default(configDir));
|
|
|
|
program
|
|
.command('upload')
|
|
.description('Upload assets')
|
|
.usage('[options] [paths...]')
|
|
.addOption(new Option('-r, --recursive', 'Recursive').env('IMMICH_RECURSIVE').default(false))
|
|
.addOption(new Option('-i, --ignore [paths...]', 'Paths to ignore').env('IMMICH_IGNORE_PATHS'))
|
|
.addOption(new Option('-h, --skip-hash', "Don't hash files before upload").env('IMMICH_SKIP_HASH').default(false))
|
|
.addOption(new Option('-i, --include-hidden', 'Include hidden folders').env('IMMICH_INCLUDE_HIDDEN').default(false))
|
|
.addOption(
|
|
new Option('-a, --album', 'Automatically create albums based on folder name')
|
|
.env('IMMICH_AUTO_CREATE_ALBUM')
|
|
.default(false),
|
|
)
|
|
.addOption(
|
|
new Option('-A, --album-name <name>', 'Add all assets to specified album')
|
|
.env('IMMICH_ALBUM_NAME')
|
|
.conflicts('album'),
|
|
)
|
|
.addOption(
|
|
new Option('-n, --dry-run', "Don't perform any actions, just show what will be done")
|
|
.env('IMMICH_DRY_RUN')
|
|
.default(false),
|
|
)
|
|
.addOption(new Option('--delete', 'Delete local assets after upload').env('IMMICH_DELETE_ASSETS'))
|
|
.argument('[paths...]', 'One or more paths to assets to be uploaded')
|
|
.action(async (paths, options) => {
|
|
options.exclusionPatterns = options.ignore;
|
|
await new Upload(program.opts()).run(paths, options);
|
|
});
|
|
|
|
program
|
|
.command('server-info')
|
|
.description('Display server information')
|
|
.action(async () => {
|
|
await new ServerInfo(program.opts()).run();
|
|
});
|
|
|
|
program
|
|
.command('login-key')
|
|
.description('Login using an API key')
|
|
.argument('[instanceUrl]')
|
|
.argument('[apiKey]')
|
|
.action(async (paths, options) => {
|
|
await new LoginKey(program.opts()).run(paths, options);
|
|
});
|
|
|
|
program
|
|
.command('logout')
|
|
.description('Remove stored credentials')
|
|
.action(async () => {
|
|
await new Logout(program.opts()).run();
|
|
});
|
|
|
|
program.parse(process.argv);
|