From 7ee1b977c1694c70d48203471abe5cd1a043ccd5 Mon Sep 17 00:00:00 2001 From: Jorge Montejo Date: Wed, 8 Oct 2025 19:08:33 +0200 Subject: [PATCH] feat(cli): add debug development config (#22712) * add debug and change ts-node with tsx * update pr changes * update pnpm-lock * remove ts-node from readme * typo * resolve conflicts * remove tsx * launch from dist * add preLaunchTask * update readme * undo main in package.json * remove typo * Apply suggestion from @bwees Co-authored-by: Brandon Wees * revert pnpm-lock changes * @jrasm91 suggestions * chore: run node with source maps --------- Co-authored-by: Jason Rasmussen Co-authored-by: Brandon Wees --- .vscode/launch.json | 14 ++++++++++++++ .vscode/tasks.json | 5 +++++ cli/README.md | 16 ++++++++++++---- cli/package.json | 1 + 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0cc9b256ca..9ed2bb77b8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -18,6 +18,20 @@ "name": "Immich Workers", "remoteRoot": "/usr/src/app/server", "localRoot": "${workspaceFolder}/server" + }, + { + "type": "node", + "request": "launch", + "name": "Immich CLI", + "program": "${workspaceFolder}/cli/dist/index.js", + "args": ["upload", "--help"], + "runtimeArgs": ["--enable-source-maps"], + "console": "integratedTerminal", + "resolveSourceMapLocations": ["${workspaceFolder}/cli/dist/**/*.js.map"], + "sourceMaps": true, + "outFiles": ["${workspaceFolder}/cli/dist/**/*.js"], + "skipFiles": ["/**"], + "preLaunchTask": "Build Immich CLI" } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 278e7e4fd3..478a46b4bd 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -70,6 +70,11 @@ "runOn": "folderOpen" }, "problemMatcher": [] + }, + { + "label": "Build Immich CLI", + "type": "shell", + "command": "pnpm --filter cli build:dev" } ] } diff --git a/cli/README.md b/cli/README.md index 09f5b163f7..b9d61fce09 100644 --- a/cli/README.md +++ b/cli/README.md @@ -13,15 +13,23 @@ Then, to build the open-api client run the following in the open-api folder: $ ./bin/generate-open-api.sh -To run the Immich CLI from source, run the following in the cli folder: +## Run from build + +Go to the cli folder and build it: $ pnpm install $ pnpm run build - $ ts-node . + $ node dist/index.js -You'll need ts-node, the easiest way to install it is to use pnpm: +## Run and Debug from source (VSCode) - $ pnpm i -g ts-node +With VScode you can run and debug the Immich CLI. Go to the launch.json file, find the Immich CLI config and change this with the command you need to debug + +`"args": ["upload", "--help"],` + +replace that for the command of your choice. + +## Install from build You can also build and install the CLI using diff --git a/cli/package.json b/cli/package.json index dfd2cc3610..3fff0c1031 100644 --- a/cli/package.json +++ b/cli/package.json @@ -43,6 +43,7 @@ }, "scripts": { "build": "vite build", + "build:dev": "vite build --sourcemap true", "lint": "eslint \"src/**/*.ts\" --max-warnings 0", "lint:fix": "npm run lint -- --fix", "prepack": "npm run build",