Skip to content

Commit

Permalink
feat(cli) Add new CLI (immich-app#3066)
Browse files Browse the repository at this point in the history
* Add new cli

* Remove old readme

* Add documentation to readme file

* Add github workflow tests for cli

* Fix typo in docs

* Add usage info to readme

* Add package-lock.json

* Fix tsconfig

* Cleanup

* Fix lint

* Cleanup package.json

* Fix accidental server change

* Remove rootdir from cli

* Remove tsbuildinfo

* Add prettierignore

* Make CLI use internal openapi specs

* Add ignore and dry-run features

* Sort paths alphabetically

* Don't remove substring

* Remove shorthand for delete

* Remove unused import

* Remove chokidar

* Set correct openapi cli generator script

* Add progress bar

* Rename target to asset

* Add deletion progress bar

* Ignore require statement

* Use read streams instead of readfile

* Fix github feedback

* Fix upload requires

* More github comments

* Cleanup messages

* Cleaner pattern concats

* Github comments

---------

Co-authored-by: Alex Tran <[email protected]>
  • Loading branch information
etnoy and alextran1502 authored Jul 6, 2023
1 parent 37edef8 commit 6f4449d
Show file tree
Hide file tree
Showing 53 changed files with 21,349 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,32 @@ jobs:
run: npm run test:cov
if: ${{ !cancelled() }}

cli-unit-tests:
name: Run cli test suites
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./cli

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run npm install
run: npm ci

- name: Run linter
run: npm run lint
if: ${{ !cancelled() }}

- name: Run formatter
run: npm run format
if: ${{ !cancelled() }}

- name: Run unit tests & coverage
run: npm run test:cov
if: ${{ !cancelled() }}

web-unit-tests:
name: Run web unit test suites and checks
runs-on: ubuntu-latest
Expand Down
20 changes: 20 additions & 0 deletions cli/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

[*.{ts,js}]
quote_type = single

[*.{md,mdx}]
max_line_length = off
trim_trailing_whitespace = false

[*.{yml,yaml}]
quote_type = double
1 change: 1 addition & 0 deletions cli/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dist
23 changes: 23 additions & 0 deletions cli/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
tsconfigRootDir: __dirname,
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'prettier/prettier': 0,
},
};
13 changes: 13 additions & 0 deletions cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*-debug.log
*-error.log
/.nyc_output
/dist
/lib
/tmp
/yarn.lock
node_modules
oclif.manifest.json

.vscode
.idea
/coverage/
18 changes: 18 additions & 0 deletions cli/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.DS_Store
node_modules
/build
/package
.env
.env.*
!.env.example
src/api/open-api
*.md
*.json
coverage
dist
**/migrations/**

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
6 changes: 6 additions & 0 deletions cli/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120,
"semi": true
}
46 changes: 46 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
A command-line interface for interfacing with Immich

# Getting started

$ ts-node cli/src

To start using the CLI, you need to login with an API key first:

$ ts-node cli/src login-key https://your-immich-instance/api your-api-key

NOTE: This will store your api key under ~/.config/immich/auth.yml

Next, you can run commands:

$ ts-node cli/src server-info

When you're done, log out to remove the credentials from your filesystem

$ ts-node cli/src logout

# Usage

```
Usage: immich [options] [command]
Immich command line interface
Options:
-h, --help display help for command
Commands:
upload [options] [paths...] Upload assets
import [options] [paths...] Import existing assets
server-info Display server information
login-key [instanceUrl] [apiKey] Login using an API key
help [command] display help for command
```

# Todo

- Sidecar should check both .jpg.xmp and .xmp
- Sidecar check could be case-insensitive

# Known issues

- Upload can't use sdk due to multiple issues
Empty file added cli/asdf
Empty file.
8 changes: 8 additions & 0 deletions cli/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { Config } from 'jest';

const config: Config = {
preset: 'ts-jest',
setupFilesAfterEnv: ['jest-extended/all'],
};

export default config;
Loading

0 comments on commit 6f4449d

Please sign in to comment.