From 20e914c85b44c034804b541df5489ad38e016367 Mon Sep 17 00:00:00 2001 From: Vikramjit Borah Date: Thu, 10 Jul 2025 21:13:16 +0530 Subject: [PATCH 01/20] change to ignore list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index db36c85..c1fe8e3 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ package-lock.json /output /db /data +/dist /Bruno /tsconfig.tsbuildinfo /public/generated.css From 3b99c79495e2a5d0b30b21f87b3f897346cc0906 Mon Sep 17 00:00:00 2001 From: Vikramjit Borah Date: Thu, 10 Jul 2025 21:43:56 +0530 Subject: [PATCH 02/20] - Update ENTRYPOINT to run dist/src/index.js instead of dist/index.js - Ensure /data directory exists for SQLite database creation - Remove unnecessary config files from final image --- Dockerfile | 7 +++++-- package.json | 3 ++- tsconfig.json | 12 ++++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index c731410..1e8f424 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,10 +75,13 @@ RUN apt-get update && apt-get install -y \ COPY --from=install /temp/prod/node_modules node_modules COPY --from=prerelease /app/public/generated.css /app/public/ -COPY . . +COPY --from=prerelease /app/dist /app/dist + +# COPY . . +RUN mkdir data EXPOSE 3000/tcp # used for calibre ENV QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox" ENV NODE_ENV=production -ENTRYPOINT [ "bun", "run", "./src/index.tsx" ] \ No newline at end of file +ENTRYPOINT [ "bun", "run", "dist/src/index.js" ] diff --git a/package.json b/package.json index 23a19bd..e53b75a 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "format": "run-p 'format:*'", "format:eslint": "eslint --fix .", "format:prettier": "prettier --write .", - "build": "bun x @tailwindcss/cli -i ./src/main.css -o ./public/generated.css", + "build:js": "tsc", + "build": "bun x @tailwindcss/cli -i ./src/main.css -o ./public/generated.css && bun run build:js", "lint": "run-p 'lint:*'", "lint:tsc": "tsc --noEmit", "lint:knip": "knip", diff --git a/tsconfig.json b/tsconfig.json index 500a42a..90304aa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,8 +5,9 @@ "target": "ES2021", "moduleResolution": "bundler", "moduleDetection": "force", - "allowImportingTsExtensions": true, - "noEmit": true, + // "allowImportingTsExtensions": true, + "outDir": "dist", + "noEmit": false, "composite": true, "strict": true, "downlevelIteration": true, @@ -24,7 +25,10 @@ // "noUnusedParameters": true, "exactOptionalPropertyTypes": true, "noFallthroughCasesInSwitch": true, - "noImplicitOverride": true + "noImplicitOverride": true, + "resolveJsonModule": true, + "esModuleInterop": true // "noImplicitReturns": true - } + }, + "include": ["src", "package.json"] } From 99c689657ff0f7872c6178a02295f4e0ccdceaee Mon Sep 17 00:00:00 2001 From: C4illin Date: Sun, 3 Aug 2025 19:24:46 +0200 Subject: [PATCH 03/20] ci: remove hardcoded ghcr image name --- .github/workflows/docker-publish.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 27d33c8..8ae6e02 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -10,7 +10,6 @@ on: branches: ["main"] workflow_dispatch: env: - GHCR_IMAGE: ghcr.io/c4illin/convertx IMAGE_NAME: ${{ github.repository }} DOCKERHUB_USERNAME: c4illin @@ -53,11 +52,15 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: downcase REPO + run: | + echo "REPO=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}" + - name: Docker meta default id: meta uses: docker/metadata-action@v5 with: - images: ${{ env.GHCR_IMAGE }} + images: ghcr.io/${{ env.REPO }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -82,7 +85,7 @@ jobs: platforms: ${{ matrix.platform }} labels: ${{ steps.meta.outputs.labels }} annotations: ${{ steps.meta.outputs.annotations }} - outputs: type=image,name=${{ env.GHCR_IMAGE }},push-by-digest=true,name-canonical=true,push=true,oci-mediatypes=true + outputs: type=image,name=ghcr.io/${{ env.REPO }},push-by-digest=true,name-canonical=true,push=true,oci-mediatypes=true cache-from: type=gha,scope=${{ matrix.platform }} cache-to: type=gha,mode=max,scope=${{ matrix.platform }} @@ -119,12 +122,16 @@ jobs: pattern: digests-* merge-multiple: true + - name: downcase REPO + run: | + echo "REPO=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}" + - name: Extract Docker metadata id: meta uses: docker/metadata-action@v5 with: images: | - ${{ env.GHCR_IMAGE }} + ghcr.io/${{ env.REPO }} ${{ env.IMAGE_NAME }} - name: Set up Docker Buildx @@ -157,8 +164,8 @@ jobs: --annotation='index:org.opencontainers.image.created=${{ steps.timestamp.outputs.timestamp }}' \ --annotation='index:org.opencontainers.image.url=${{ github.event.repository.url }}' \ --annotation='index:org.opencontainers.image.source=${{ github.event.repository.url }}' \ - $(printf '${{ env.GHCR_IMAGE }}@sha256:%s ' *) + $(printf 'ghcr.io/${{ env.REPO }}@sha256:%s ' *) - name: Inspect image run: | - docker buildx imagetools inspect '${{ env.GHCR_IMAGE }}:${{ steps.meta.outputs.version }}' + docker buildx imagetools inspect 'ghcr.io/${{ env.REPO }}:${{ steps.meta.outputs.version }}' From 363efc2e7f73bdc29425df8f85dd05cea36afe16 Mon Sep 17 00:00:00 2001 From: C4illin Date: Sun, 3 Aug 2025 19:55:15 +0200 Subject: [PATCH 04/20] chore: add converter request template --- .github/ISSUE_TEMPLATE/converter_request.md | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/converter_request.md diff --git a/.github/ISSUE_TEMPLATE/converter_request.md b/.github/ISSUE_TEMPLATE/converter_request.md new file mode 100644 index 0000000..1560423 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/converter_request.md @@ -0,0 +1,22 @@ +--- +name: Converter request +about: Suggest an converter for this project +title: "[Converter Request]" +labels: "converter request" +assignees: '' + +--- + +**What file formats is missing?** + + +**What converter should be added** + + +**Are you willing to add it?** + +[ ] Yes +[ ] No + +**Additional context** + \ No newline at end of file From fed587b4a4851365c26cdba4025bbec55f6ed97b Mon Sep 17 00:00:00 2001 From: C4illin Date: Sun, 3 Aug 2025 20:03:26 +0200 Subject: [PATCH 05/20] chore: fix template checklist --- .github/ISSUE_TEMPLATE/converter_request.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/converter_request.md b/.github/ISSUE_TEMPLATE/converter_request.md index 1560423..609d75d 100644 --- a/.github/ISSUE_TEMPLATE/converter_request.md +++ b/.github/ISSUE_TEMPLATE/converter_request.md @@ -15,8 +15,8 @@ assignees: '' **Are you willing to add it?** -[ ] Yes -[ ] No +- [ ] Yes +- [ ] No **Additional context** \ No newline at end of file From 2295f2372528ce041f9a8fc7a73aa73f3468e878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emrik=20=C3=96stling?= Date: Sun, 3 Aug 2025 20:09:05 +0200 Subject: [PATCH 06/20] chore: update README.md --- README.md | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/README.md b/README.md index 0d65690..3d24b74 100644 --- a/README.md +++ b/README.md @@ -133,19 +133,10 @@ Tutorial in chinese: 2. `bun install` 3. `bun run dev` -Pull requests are welcome! See below and open issues for the list of todos. +Pull requests are welcome! See open issues for the list of todos. The ones tagged with "converter request" are quite easy. Help with docs and cleaning up in issues are also very welcome! Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) for commit messages. -## Todo - -- [ ] Add options for converters -- [ ] Add tests -- [ ] Make errors logs visible from the web ui -- [ ] Add more converters: - - [ ] [deark](https://github.com/jsummers/deark) - - [ ] LibreOffice - ## Contributors From 068d9b8716aa6bcc8d7b8a33ba6def49f0ede698 Mon Sep 17 00:00:00 2001 From: C4illin Date: Sun, 3 Aug 2025 20:37:07 +0200 Subject: [PATCH 07/20] chore: hardcode ghcr token --- .github/workflows/docker-publish.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 8ae6e02..369824c 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -12,6 +12,7 @@ on: env: IMAGE_NAME: ${{ github.repository }} DOCKERHUB_USERNAME: c4illin + GHCR_USERNAME: c4illin concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -72,8 +73,8 @@ jobs: uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + username: ${{ env.GHCR_USERNAME }} + password: ${{ secrets.GHCR_TOKEN }} - name: Build and push by digest id: build @@ -141,8 +142,8 @@ jobs: uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + username: ${{ env.GHCR_USERNAME }} + password: ${{ secrets.GHCR_TOKEN }} - name: Login to Docker Hub uses: docker/login-action@v3 From 93fbdbe0f3777921e73b0e86b9dc0637e5980178 Mon Sep 17 00:00:00 2001 From: C4illin Date: Sun, 3 Aug 2025 21:15:04 +0200 Subject: [PATCH 08/20] chore: test global permissions --- .github/workflows/docker-publish.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 369824c..c09c9aa 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -12,12 +12,15 @@ on: env: IMAGE_NAME: ${{ github.repository }} DOCKERHUB_USERNAME: c4illin - GHCR_USERNAME: c4illin concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +permissions: + contents: write + packages: write + jobs: # The build job builds the Docker image for each platform specified in the matrix. build: @@ -33,7 +36,7 @@ jobs: packages: write attestations: write checks: write - actions: read + actions: write runs-on: ${{ matrix.platform == 'linux/amd64' && 'ubuntu-24.04' || matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' }} @@ -73,8 +76,8 @@ jobs: uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ env.GHCR_USERNAME }} - password: ${{ secrets.GHCR_TOKEN }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push by digest id: build @@ -142,8 +145,8 @@ jobs: uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ env.GHCR_USERNAME }} - password: ${{ secrets.GHCR_TOKEN }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Login to Docker Hub uses: docker/login-action@v3 From d24e8b402796a9c2449c724f52e6f273a62cb06a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 6 Aug 2025 02:26:18 +0000 Subject: [PATCH 09/20] chore(deps): update actions/download-artifact action to v5 --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index c09c9aa..a41057c 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -120,7 +120,7 @@ jobs: - build steps: - name: Download digests - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v5 with: path: /tmp/digests pattern: digests-* From b4fedc1c1dfe3c6c230d90da45e69cc08cda1c61 Mon Sep 17 00:00:00 2001 From: C4illin Date: Thu, 7 Aug 2025 23:18:30 +0200 Subject: [PATCH 10/20] chore: downgrade bun-types to correct version --- bun.lock | 6 ++---- package.json | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/bun.lock b/bun.lock index 4bdeb22..c379458 100644 --- a/bun.lock +++ b/bun.lock @@ -22,7 +22,7 @@ "@types/bun": "1.2.2", "@types/node": "^24.0.0", "@typescript-eslint/parser": "^8.34.0", - "bun-types": "1.2.17", + "bun-types": "1.2.2", "eslint": "^9.28.0", "eslint-plugin-better-tailwindcss": "^3.1.0", "eslint-plugin-simple-import-sort": "^12.1.1", @@ -275,7 +275,7 @@ "braces": ["braces@3.0.3", "", { "dependencies": { "fill-range": "^7.1.1" } }, "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA=="], - "bun-types": ["bun-types@1.2.17", "", { "dependencies": { "@types/node": "*" } }, "sha512-ElC7ItwT3SCQwYZDYoAH+q6KT4Fxjl8DtZ6qDulUFBmXA8YB4xo+l54J9ZJN+k2pphfn9vk7kfubeSd5QfTVJQ=="], + "bun-types": ["bun-types@1.2.2", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-RCbMH5elr9gjgDGDhkTTugA21XtJAy/9jkKe/G3WR2q17VPGhcquf9Sir6uay9iW+7P/BV0CAHA1XlHXMAVKHg=="], "callsites": ["callsites@3.1.0", "", {}, "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ=="], @@ -655,8 +655,6 @@ "@tailwindcss/oxide-wasm32-wasi/tslib": ["tslib@2.8.1", "", { "bundled": true }, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="], - "@types/bun/bun-types": ["bun-types@1.2.2", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-RCbMH5elr9gjgDGDhkTTugA21XtJAy/9jkKe/G3WR2q17VPGhcquf9Sir6uay9iW+7P/BV0CAHA1XlHXMAVKHg=="], - "@typescript-eslint/eslint-plugin/ignore": ["ignore@7.0.4", "", {}, "sha512-gJzzk+PQNznz8ysRrC0aOkBNVRBDtE1n53IqyqEf3PXrYwomFs5q4pGMizBMJF+ykh03insJ27hB8gSrD2Hn8A=="], "@typescript-eslint/typescript-estree/minimatch": ["minimatch@9.0.5", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow=="], diff --git a/package.json b/package.json index 4ac248a..e3260c8 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "@types/bun": "1.2.2", "@types/node": "^24.0.0", "@typescript-eslint/parser": "^8.34.0", - "bun-types": "1.2.17", + "bun-types": "1.2.2", "eslint": "^9.28.0", "eslint-plugin-better-tailwindcss": "^3.1.0", "eslint-plugin-simple-import-sort": "^12.1.1", From b89afe1b0c904a1bea8656ad6edb73b6d3c2d21c Mon Sep 17 00:00:00 2001 From: C4illin Date: Thu, 7 Aug 2025 23:19:31 +0200 Subject: [PATCH 11/20] chore: add ignored deps --- renovate.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/renovate.json b/renovate.json index 3418a44..eac34ee 100644 --- a/renovate.json +++ b/renovate.json @@ -4,5 +4,9 @@ "lockFileMaintenance": { "enabled": true, "automerge": true - } + }, + "ignoreDeps": [ + "bun-types", + "@types/bun" + ] } From 858ee28ef25d82dd8d5dd96d4904bd17534f7543 Mon Sep 17 00:00:00 2001 From: C4illin Date: Thu, 7 Aug 2025 23:27:55 +0200 Subject: [PATCH 12/20] ci: check formatting --- .github/workflows/check-lint.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/check-lint.yml diff --git a/.github/workflows/check-lint.yml b/.github/workflows/check-lint.yml new file mode 100644 index 0000000..353903a --- /dev/null +++ b/.github/workflows/check-lint.yml @@ -0,0 +1,31 @@ +name: Check Lint + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + name: Run linting checks + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: oven-sh/setup-bun@v2 + with: + bun-version: 1.2.2 + + - name: Install dependencies + run: bun install + + - name: Run lint + run: bun run lint From 81f109f8304768cb873a3a836a29cd7824f45c0c Mon Sep 17 00:00:00 2001 From: C4illin Date: Thu, 7 Aug 2025 23:28:02 +0200 Subject: [PATCH 13/20] chore: format files --- .github/ISSUE_TEMPLATE/bug_report.md | 7 ++--- .github/ISSUE_TEMPLATE/converter_request.md | 10 ++++--- .github/ISSUE_TEMPLATE/feature_request.md | 3 +-- CHANGELOG.md | 3 +-- README.md | 1 - renovate.json | 5 +--- src/converters/calibre.ts | 28 +++++++++---------- src/converters/main.ts | 30 +++++++++------------ src/converters/msgconvert.ts | 12 ++++++--- src/helpers/env.ts | 7 +++-- src/pages/convert.tsx | 5 ++++ src/pages/download.tsx | 17 +++++++++--- src/pages/results.tsx | 6 ++--- src/pages/root.tsx | 4 ++- src/theme/theme.css | 2 +- 15 files changed, 77 insertions(+), 63 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 175d11a..d6ed108 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,10 +1,9 @@ --- name: Bug report about: Create a report to help us improve -title: '' +title: "" labels: bug -assignees: '' - +assignees: "" --- **Describe the bug** @@ -12,10 +11,12 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: + 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error **Checklist:** + - [ ] I am accessing ConvertX over HTTPS or have `HTTP_ALLOWED=true` diff --git a/.github/ISSUE_TEMPLATE/converter_request.md b/.github/ISSUE_TEMPLATE/converter_request.md index 609d75d..910feec 100644 --- a/.github/ISSUE_TEMPLATE/converter_request.md +++ b/.github/ISSUE_TEMPLATE/converter_request.md @@ -3,20 +3,24 @@ name: Converter request about: Suggest an converter for this project title: "[Converter Request]" labels: "converter request" -assignees: '' - +assignees: "" --- **What file formats is missing?** + **What converter should be added** + **Are you willing to add it?** + + - [ ] Yes - [ ] No **Additional context** - \ No newline at end of file + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 7e3bd6b..5140554 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -3,8 +3,7 @@ name: Feature request about: Suggest an idea for this project title: "[Feature Request]" labels: enhancement -assignees: '' - +assignees: "" --- **Describe the solution you'd like** diff --git a/CHANGELOG.md b/CHANGELOG.md index 0654d68..49b69ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,9 @@ ## [0.14.1](https://github.com/C4illin/ConvertX/compare/v0.14.0...v0.14.1) (2025-06-04) - ### Bug Fixes -* change to baseline build ([6ea3058](https://github.com/C4illin/ConvertX/commit/6ea3058e66262f7a14633bddcecd5573948f524a)), closes [#311](https://github.com/C4illin/ConvertX/issues/311) +- change to baseline build ([6ea3058](https://github.com/C4illin/ConvertX/commit/6ea3058e66262f7a14633bddcecd5573948f524a)), closes [#311](https://github.com/C4illin/ConvertX/issues/311) ## [0.14.0](https://github.com/C4illin/ConvertX/compare/v0.13.0...v0.14.0) (2025-06-03) diff --git a/README.md b/README.md index 3d24b74..446a4e9 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,6 @@ All are optional, JWT_SECRET is recommended to be set. | LANGUAGE | en | Language to format date strings in, specified as a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) | | UNAUTHENTICATED_USER_SHARING | false | Shares conversion history between all unauthenticated users | - ### Docker images There is a `:latest` tag that is updated with every release and a `:main` tag that is updated with every push to the main branch. `:latest` is recommended for normal use. diff --git a/renovate.json b/renovate.json index eac34ee..ec32b06 100644 --- a/renovate.json +++ b/renovate.json @@ -5,8 +5,5 @@ "enabled": true, "automerge": true }, - "ignoreDeps": [ - "bun-types", - "@types/bun" - ] + "ignoreDeps": ["bun-types", "@types/bun"] } diff --git a/src/converters/calibre.ts b/src/converters/calibre.ts index 8ebdbd1..f217b07 100644 --- a/src/converters/calibre.ts +++ b/src/converters/calibre.ts @@ -66,24 +66,20 @@ export async function convert( options?: unknown, ): Promise { return new Promise((resolve, reject) => { - execFile( - "ebook-convert", - [filePath, targetPath], - (error, stdout, stderr) => { - if (error) { - reject(`error: ${error}`); - } + execFile("ebook-convert", [filePath, targetPath], (error, stdout, stderr) => { + if (error) { + reject(`error: ${error}`); + } - if (stdout) { - console.log(`stdout: ${stdout}`); - } + if (stdout) { + console.log(`stdout: ${stdout}`); + } - if (stderr) { - console.error(`stderr: ${stderr}`); - } + if (stderr) { + console.error(`stderr: ${stderr}`); + } - resolve("Done"); - }, - ); + resolve("Done"); + }); }); } diff --git a/src/converters/main.ts b/src/converters/main.ts index 63106ff..c74ff62 100644 --- a/src/converters/main.ts +++ b/src/converters/main.ts @@ -1,3 +1,4 @@ +import { Cookie } from "elysia"; import db from "../db/db"; import { MAX_CONVERT_PROCESS } from "../helpers/env"; import { normalizeFiletype, normalizeOutputFiletype } from "../helpers/normalizeFiletype"; @@ -119,11 +120,11 @@ const properties: Record< }; function chunks(arr: T[], size: number): T[][] { - if(size <= 0){ - return [arr] + if (size <= 0) { + return [arr]; } return Array.from({ length: Math.ceil(arr.length / size) }, (_: T, i: number) => - arr.slice(i * size, i * size + size) + arr.slice(i * size, i * size + size), ); } @@ -133,17 +134,15 @@ export async function handleConvert( userOutputDir: string, convertTo: string, converterName: string, - jobId: any + jobId: Cookie, ) { - const query = db.query( "INSERT INTO file_names (job_id, file_name, output_file_name, status) VALUES (?1, ?2, ?3, ?4)", ); - for (const chunk of chunks(fileNames, MAX_CONVERT_PROCESS)) { const toProcess: Promise[] = []; - for(const fileName of chunk) { + for (const fileName of chunk) { const filePath = `${userUploadsDir}${fileName}`; const fileTypeOrig = fileName.split(".").pop() ?? ""; const fileType = normalizeFiletype(fileTypeOrig); @@ -154,21 +153,16 @@ export async function handleConvert( ); const targetPath = `${userOutputDir}${newFileName}`; toProcess.push( - new Promise((resolve, reject) => { - mainConverter( - filePath, - fileType, - convertTo, - targetPath, - {}, - converterName, - ).then(r => { + new Promise((resolve, reject) => { + mainConverter(filePath, fileType, convertTo, targetPath, {}, converterName) + .then((r) => { if (jobId.value) { query.run(jobId.value, fileName, newFileName, r); } resolve(r); - }).catch(c => reject(c)); - }) + }) + .catch((c) => reject(c)); + }), ); } await Promise.all(toProcess); diff --git a/src/converters/msgconvert.ts b/src/converters/msgconvert.ts index b6bf826..8e95496 100644 --- a/src/converters/msgconvert.ts +++ b/src/converters/msgconvert.ts @@ -23,7 +23,7 @@ export function convert( // msgconvert will output to the same directory as the input file with .eml extension // We need to use --outfile to specify the target path const args = ["--outfile", targetPath, filePath]; - + execFile("msgconvert", args, (error, stdout, stderr) => { if (error) { reject(new Error(`msgconvert failed: ${error.message}`)); @@ -33,13 +33,19 @@ export function convert( if (stderr) { // Log sanitized stderr to avoid exposing sensitive paths const sanitizedStderr = stderr.replace(/(\/[^\s]+)/g, "[REDACTED_PATH]"); - console.warn(`msgconvert stderr: ${sanitizedStderr.length > 200 ? sanitizedStderr.slice(0, 200) + '...' : sanitizedStderr}`); + console.warn( + `msgconvert stderr: ${sanitizedStderr.length > 200 ? sanitizedStderr.slice(0, 200) + "..." : sanitizedStderr}`, + ); } resolve(targetPath); }); } else { - reject(new Error(`Unsupported conversion from ${fileType} to ${convertTo}. Only MSG to EML conversion is currently supported.`)); + reject( + new Error( + `Unsupported conversion from ${fileType} to ${convertTo}. Only MSG to EML conversion is currently supported.`, + ), + ); } }); } diff --git a/src/helpers/env.ts b/src/helpers/env.ts index 6722c54..4c8c067 100644 --- a/src/helpers/env.ts +++ b/src/helpers/env.ts @@ -16,7 +16,10 @@ export const WEBROOT = process.env.WEBROOT ?? ""; export const LANGUAGE = process.env.LANGUAGE?.toLowerCase() || "en"; -export const MAX_CONVERT_PROCESS = process.env.MAX_CONVERT_PROCESS && Number(process.env.MAX_CONVERT_PROCESS) > 0 ? Number(process.env.MAX_CONVERT_PROCESS) : 0 +export const MAX_CONVERT_PROCESS = + process.env.MAX_CONVERT_PROCESS && Number(process.env.MAX_CONVERT_PROCESS) > 0 + ? Number(process.env.MAX_CONVERT_PROCESS) + : 0; export const UNAUTHENTICATED_USER_SHARING = - process.env.UNAUTHENTICATED_USER_SHARING?.toLowerCase() === "true" || false; \ No newline at end of file + process.env.UNAUTHENTICATED_USER_SHARING?.toLowerCase() === "true" || false; diff --git a/src/pages/convert.tsx b/src/pages/convert.tsx index 3dbb892..fe4c325 100644 --- a/src/pages/convert.tsx +++ b/src/pages/convert.tsx @@ -46,6 +46,11 @@ export const convert = new Elysia().use(userService).post( const convertTo = normalizeFiletype(body.convert_to.split(",")[0] ?? ""); const converterName = body.convert_to.split(",")[1]; + + if (!converterName) { + return redirect(`${WEBROOT}/`, 302); + } + const fileNames = JSON.parse(body.file_names) as string[]; for (let i = 0; i < fileNames.length; i++) { diff --git a/src/pages/download.tsx b/src/pages/download.tsx index 3333396..e5d7576 100644 --- a/src/pages/download.tsx +++ b/src/pages/download.tsx @@ -1,11 +1,11 @@ +import path from "node:path"; import { Elysia } from "elysia"; import sanitize from "sanitize-filename"; +import * as tar from "tar"; import { outputDir } from ".."; import db from "../db/db"; import { WEBROOT } from "../helpers/env"; import { userService } from "./user"; -import path from "node:path"; -import * as tar from "tar"; export const download = new Elysia() .use(userService) @@ -58,8 +58,17 @@ export const download = new Elysia() const userId = decodeURIComponent(params.userId); const jobId = decodeURIComponent(params.jobId); const outputPath = `${outputDir}${userId}/${jobId}`; - const outputTar = path.join(outputPath, `converted_files_${jobId}.tar`) + const outputTar = path.join(outputPath, `converted_files_${jobId}.tar`); - await tar.create({file: outputTar, cwd: outputPath, filter: (path) => { return !path.match(".*\\.tar"); }}, ["."]); + await tar.create( + { + file: outputTar, + cwd: outputPath, + filter: (path) => { + return !path.match(".*\\.tar"); + }, + }, + ["."], + ); return Bun.file(outputTar); }); diff --git a/src/pages/results.tsx b/src/pages/results.tsx index edd70e7..c881f55 100644 --- a/src/pages/results.tsx +++ b/src/pages/results.tsx @@ -1,4 +1,5 @@ import { Html } from "@elysiajs/html"; +import { JWTPayloadSpec } from "@elysiajs/jwt"; import { Elysia } from "elysia"; import { BaseHtml } from "../components/base"; import { Header } from "../components/header"; @@ -6,7 +7,6 @@ import db from "../db/db"; import { Filename, Jobs } from "../db/types"; import { ALLOW_UNAUTHENTICATED, WEBROOT } from "../helpers/env"; import { userService } from "./user"; -import { JWTPayloadSpec } from "@elysiajs/jwt"; function ResultsArticle({ user, @@ -26,7 +26,7 @@ function ResultsArticle({

Results

- + > {files.length === job.num_files ? "Download All" : "Converting..."} diff --git a/src/pages/root.tsx b/src/pages/root.tsx index b8aaf1b..fa4c8a8 100644 --- a/src/pages/root.tsx +++ b/src/pages/root.tsx @@ -34,7 +34,9 @@ export const root = new Elysia() let user: ({ id: string } & JWTPayloadSpec) | false = false; if (ALLOW_UNAUTHENTICATED) { const newUserId = String( - UNAUTHENTICATED_USER_SHARING ? 0 : randomInt(2 ** 24, Math.min(2 ** 48 + 2 ** 24 - 1, Number.MAX_SAFE_INTEGER)), + UNAUTHENTICATED_USER_SHARING + ? 0 + : randomInt(2 ** 24, Math.min(2 ** 48 + 2 ** 24 - 1, Number.MAX_SAFE_INTEGER)), ); const accessToken = await jwt.sign({ id: newUserId, diff --git a/src/theme/theme.css b/src/theme/theme.css index cc55666..34a0051 100644 --- a/src/theme/theme.css +++ b/src/theme/theme.css @@ -44,4 +44,4 @@ /* lime-400 */ --accent-400: oklch(84.1% 0.238 128.85); } -} \ No newline at end of file +} From de10436c1a898a99ac8102e5766f610390bc4a46 Mon Sep 17 00:00:00 2001 From: C4illin Date: Thu, 7 Aug 2025 23:32:42 +0200 Subject: [PATCH 14/20] chore: remove bun-types --- bun.lock | 1 - knip.json | 3 +-- package.json | 1 - src/converters/main.ts | 2 +- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/bun.lock b/bun.lock index c379458..b1c5902 100644 --- a/bun.lock +++ b/bun.lock @@ -22,7 +22,6 @@ "@types/bun": "1.2.2", "@types/node": "^24.0.0", "@typescript-eslint/parser": "^8.34.0", - "bun-types": "1.2.2", "eslint": "^9.28.0", "eslint-plugin-better-tailwindcss": "^3.1.0", "eslint-plugin-simple-import-sort": "^12.1.1", diff --git a/knip.json b/knip.json index 0fc4de8..c531436 100644 --- a/knip.json +++ b/knip.json @@ -1,7 +1,6 @@ { "$schema": "https://unpkg.com/knip@5/schema.json", - "entry": ["src/index.tsx"], - "project": ["src/**/*.ts", "src/**/*.tsx", "src/main.css"], + "project": ["src/**/*.ts", "src/**/*.tsx"], "tailwind": { "entry": ["src/main.css"] }, diff --git a/package.json b/package.json index e3260c8..81459b4 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "@types/bun": "1.2.2", "@types/node": "^24.0.0", "@typescript-eslint/parser": "^8.34.0", - "bun-types": "1.2.2", "eslint": "^9.28.0", "eslint-plugin-better-tailwindcss": "^3.1.0", "eslint-plugin-simple-import-sort": "^12.1.1", diff --git a/src/converters/main.ts b/src/converters/main.ts index c74ff62..8c59e55 100644 --- a/src/converters/main.ts +++ b/src/converters/main.ts @@ -169,7 +169,7 @@ export async function handleConvert( } } -export async function mainConverter( +async function mainConverter( inputFilePath: string, fileTypeOriginal: string, convertTo: string, From eefd33ac886bb297dadf4584a1d9b3fff1e94ed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emrik=20=C3=96stling?= Date: Thu, 7 Aug 2025 23:34:38 +0200 Subject: [PATCH 15/20] Update .github/ISSUE_TEMPLATE/converter_request.md Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/converter_request.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/converter_request.md b/.github/ISSUE_TEMPLATE/converter_request.md index 910feec..8d743f5 100644 --- a/.github/ISSUE_TEMPLATE/converter_request.md +++ b/.github/ISSUE_TEMPLATE/converter_request.md @@ -1,6 +1,6 @@ --- name: Converter request -about: Suggest an converter for this project +about: Suggest a converter for this project title: "[Converter Request]" labels: "converter request" assignees: "" From 1db0c0f5318f1edd59ebe64fb85ff1548c3ef24c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emrik=20=C3=96stling?= Date: Thu, 7 Aug 2025 23:34:53 +0200 Subject: [PATCH 16/20] Update .github/ISSUE_TEMPLATE/converter_request.md Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/converter_request.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/converter_request.md b/.github/ISSUE_TEMPLATE/converter_request.md index 8d743f5..7de554d 100644 --- a/.github/ISSUE_TEMPLATE/converter_request.md +++ b/.github/ISSUE_TEMPLATE/converter_request.md @@ -6,7 +6,7 @@ labels: "converter request" assignees: "" --- -**What file formats is missing?** +**What file formats are missing?** From e5939aaa5d8f855ded577a234933307a8cdcf79d Mon Sep 17 00:00:00 2001 From: C4illin Date: Thu, 7 Aug 2025 23:42:10 +0200 Subject: [PATCH 17/20] chore: test with id-token permissions --- .github/workflows/docker-publish.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index a41057c..eb6bafc 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -17,10 +17,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -permissions: - contents: write - packages: write - jobs: # The build job builds the Docker image for each platform specified in the matrix. build: @@ -35,8 +31,7 @@ jobs: contents: write packages: write attestations: write - checks: write - actions: write + id-token: write runs-on: ${{ matrix.platform == 'linux/amd64' && 'ubuntu-24.04' || matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' }} @@ -112,9 +107,10 @@ jobs: runs-on: ubuntu-latest permissions: - attestations: write - contents: read + contents: write packages: write + attestations: write + id-token: write needs: - build From d390dce8430e97b0cbf88e3eda6a350319694fb8 Mon Sep 17 00:00:00 2001 From: C4illin Date: Fri, 8 Aug 2025 00:07:47 +0200 Subject: [PATCH 18/20] chore: test without push --- .github/workflows/docker-publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index eb6bafc..c7e392c 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -84,7 +84,8 @@ jobs: platforms: ${{ matrix.platform }} labels: ${{ steps.meta.outputs.labels }} annotations: ${{ steps.meta.outputs.annotations }} - outputs: type=image,name=ghcr.io/${{ env.REPO }},push-by-digest=true,name-canonical=true,push=true,oci-mediatypes=true + outputs: type=image,name=ghcr.io/${{ env.REPO }},push-by-digest=true,name-canonical=true,push=false,oci-mediatypes=true + push: false cache-from: type=gha,scope=${{ matrix.platform }} cache-to: type=gha,mode=max,scope=${{ matrix.platform }} From 43081c51798ddd9d1e9eaef67e8e0e82c34c38df Mon Sep 17 00:00:00 2001 From: C4illin Date: Fri, 8 Aug 2025 00:14:08 +0200 Subject: [PATCH 19/20] chore: attempt to restrict push when allowed --- .github/workflows/docker-publish.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index c7e392c..1eeb66d 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -84,8 +84,8 @@ jobs: platforms: ${{ matrix.platform }} labels: ${{ steps.meta.outputs.labels }} annotations: ${{ steps.meta.outputs.annotations }} - outputs: type=image,name=ghcr.io/${{ env.REPO }},push-by-digest=true,name-canonical=true,push=false,oci-mediatypes=true - push: false + outputs: type=image,name=ghcr.io/${{ env.REPO }},push-by-digest=true,name-canonical=true,oci-mediatypes=true + push: ${{ github.event.pull_request.head.repo.full_name == github.repository }} cache-from: type=gha,scope=${{ matrix.platform }} cache-to: type=gha,mode=max,scope=${{ matrix.platform }} @@ -104,6 +104,7 @@ jobs: retention-days: 1 merge: + if: github.event.pull_request.head.repo.full_name == github.repository name: Merge Docker manifests runs-on: ubuntu-latest From 15b03d75614e782a01d27b4112250ca446380818 Mon Sep 17 00:00:00 2001 From: C4illin Date: Fri, 8 Aug 2025 01:02:20 +0200 Subject: [PATCH 20/20] chore: fix tseslint config --- eslint.config.ts | 19 +++++++++++++------ tsconfig.json | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/eslint.config.ts b/eslint.config.ts index 6bf8f24..ebb2d16 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -1,12 +1,11 @@ import js from "@eslint/js"; import eslintParserTypeScript from "@typescript-eslint/parser"; -import type { Linter } from "eslint"; import eslintPluginBetterTailwindcss from "eslint-plugin-better-tailwindcss"; import simpleImportSortPlugin from "eslint-plugin-simple-import-sort"; import globals from "globals"; import tseslint from "typescript-eslint"; -export default [ +export default tseslint.config( js.configs.recommended, ...tseslint.configs.recommended, // ...tailwind.configs["flat/recommended"], @@ -15,7 +14,7 @@ export default [ "simple-import-sort": simpleImportSortPlugin, "better-tailwindcss": eslintPluginBetterTailwindcss, }, - ignores: ["**/node_modules/**"], + ignores: ["**/node_modules/**", "eslint.config.ts"], languageOptions: { parser: eslintParserTypeScript, parserOptions: { @@ -26,10 +25,9 @@ export default [ }, globals: { ...globals.node, - ...globals.browser, }, }, - files: ["**/*.{js,mjs,cjs,jsx,tsx,ts}"], + files: ["**/*.{tsx,ts}"], settings: { "better-tailwindcss": { entryPoint: "src/main.css", @@ -63,4 +61,13 @@ export default [ ], }, }, -] as Linter.Config[]; + { + files: ["**/*.{js,cjs,mjs,jsx}"], + extends: [tseslint.configs.disableTypeChecked], + languageOptions: { + globals: { + ...globals.browser, + }, + }, + }, +); diff --git a/tsconfig.json b/tsconfig.json index 90304aa..234339b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -30,5 +30,5 @@ "esModuleInterop": true // "noImplicitReturns": true }, - "include": ["src", "package.json"] + "include": ["src", "package.json", "reset.d.ts"] }