From 8330069999000c97d8af9efcfc612a9e642ab88d Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Fri, 2 Feb 2024 21:04:20 -0800 Subject: [PATCH] chore: remove form-data dependency --- .github/workflows/test.yml | 6 ++++++ cli/package-lock.json | 13 ++++++------- cli/package.json | 4 +++- cli/src/commands/upload.command.ts | 10 ++++------ 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bff3f484a9d731..027ef273faf5c0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -103,6 +103,9 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + - name: Run setup typescript-sdk run: npm ci && npm run build working-directory: ./open-api/typescript-sdk @@ -143,6 +146,9 @@ jobs: with: submodules: "recursive" + - name: Setup Node + uses: actions/setup-node@v4 + - name: Run setup typescript-sdk run: npm ci && npm run build working-directory: ./open-api/typescript-sdk diff --git a/cli/package-lock.json b/cli/package-lock.json index 9c218f78b99e72..3d8ba6005f4310 100644 --- a/cli/package-lock.json +++ b/cli/package-lock.json @@ -14,7 +14,6 @@ "byte-size": "^8.1.1", "cli-progress": "^3.12.0", "commander": "^11.0.0", - "form-data": "^4.0.0", "glob": "^10.3.1", "yaml": "^2.3.1" }, @@ -27,8 +26,8 @@ "@types/cli-progress": "^3.11.0", "@types/mock-fs": "^4.13.1", "@types/node": "^20.3.1", - "@typescript-eslint/eslint-plugin": "^6.0.0", - "@typescript-eslint/parser": "^6.0.0", + "@typescript-eslint/eslint-plugin": "^6.4.1", + "@typescript-eslint/parser": "^6.4.1", "@vitest/coverage-v8": "^1.2.2", "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", @@ -56,7 +55,7 @@ }, "../server": { "name": "immich", - "version": "1.93.3", + "version": "1.94.1", "dev": true, "license": "UNLICENSED", "dependencies": { @@ -79,6 +78,7 @@ "axios": "^1.5.0", "bcrypt": "^5.1.1", "bullmq": "^4.8.0", + "chokidar": "^3.5.3", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", "cookie-parser": "^1.4.6", @@ -129,7 +129,6 @@ "@types/ua-parser-js": "^0.7.36", "@typescript-eslint/eslint-plugin": "^6.4.1", "@typescript-eslint/parser": "^6.4.1", - "chokidar": "^3.5.3", "dotenv": "^16.3.1", "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", @@ -149,7 +148,7 @@ "ts-loader": "^9.4.4", "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", - "typescript": "^5.2.2", + "typescript": "^5.3.3", "utimes": "^5.2.1" } }, @@ -8828,7 +8827,7 @@ "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", "typeorm": "^0.3.17", - "typescript": "^5.2.2", + "typescript": "^5.3.3", "ua-parser-js": "^1.0.35", "utimes": "^5.2.1" } diff --git a/cli/package.json b/cli/package.json index 9e32061e3d0f1b..64691b5cdd33fb 100644 --- a/cli/package.json +++ b/cli/package.json @@ -18,7 +18,6 @@ "byte-size": "^8.1.1", "cli-progress": "^3.12.0", "commander": "^11.0.0", - "form-data": "^4.0.0", "glob": "^10.3.1", "yaml": "^2.3.1" }, @@ -58,5 +57,8 @@ "type": "git", "url": "github:immich-app/immich", "directory": "cli" + }, + "engines": { + "node": ">=20.0.0" } } diff --git a/cli/src/commands/upload.command.ts b/cli/src/commands/upload.command.ts index f026e374df2b23..b5ea6aa0fda797 100644 --- a/cli/src/commands/upload.command.ts +++ b/cli/src/commands/upload.command.ts @@ -1,8 +1,7 @@ import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'; import byteSize from 'byte-size'; import cliProgress from 'cli-progress'; -import FormData from 'form-data'; -import fs, { ReadStream, createReadStream } from 'node:fs'; +import fs, { createReadStream } from 'node:fs'; import { CrawlService } from '../services/crawl.service'; import { BaseCommand } from './base-command'; import { basename } from 'node:path'; @@ -47,14 +46,14 @@ class Asset { // TODO: doesn't xmp replace the file extension? Will need investigation const sideCarPath = `${this.path}.xmp`; - let sidecarData: ReadStream | undefined = undefined; + let sidecarData: Blob | undefined = undefined; try { await access(sideCarPath, constants.R_OK); - sidecarData = createReadStream(sideCarPath); + sidecarData = new File([await fs.openAsBlob(sideCarPath)], basename(sideCarPath)); } catch {} const data: any = { - assetData: createReadStream(this.path), + assetData: new File([await fs.openAsBlob(this.path)], basename(this.path)), deviceAssetId: this.deviceAssetId, deviceId: 'CLI', fileCreatedAt: this.fileCreatedAt, @@ -269,7 +268,6 @@ export class UploadCommand extends BaseCommand { url, headers: { 'x-api-key': this.immichApi.apiKey, - ...data.getHeaders(), }, maxContentLength: Number.POSITIVE_INFINITY, maxBodyLength: Number.POSITIVE_INFINITY,