Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/dev/configs/api.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.25.3",
"version": "4.27.2",
"extraOrigins": [],
"sandbox": true,
"ssoSubIds": [],
Expand Down
22 changes: 0 additions & 22 deletions api/ecosystem.config.json

This file was deleted.

4 changes: 2 additions & 2 deletions api/generated-schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1673,8 +1673,8 @@ type PackageVersions {
"""npm version"""
npm: String

"""pm2 version"""
pm2: String
"""nodemon version"""
nodemon: String

"""Git version"""
git: String
Expand Down
2 changes: 1 addition & 1 deletion api/legacy/generated-schema-legacy.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ type Versions {
openssl: String
perl: String
php: String
pm2: String
nodemon: String
postfix: String
postgresql: String
python: String
Expand Down
17 changes: 17 additions & 0 deletions api/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"watch": [
"dist/main.js"
],
"ignore": [
"node_modules",
"src",
".env.*"
],
"exec": "node ./dist/main.js",
"signal": "SIGTERM",
"ext": "js,json",
"restartable": "rs",
"env": {
"NODE_ENV": "production"
}
}
3 changes: 1 addition & 2 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"pino": "9.9.0",
"pino-http": "10.5.0",
"pino-pretty": "13.1.1",
"pm2": "6.0.8",
"nodemon": "3.1.10",
"reflect-metadata": "^0.1.14",
"rxjs": "7.8.2",
"semver": "7.7.2",
Expand Down Expand Up @@ -203,7 +203,6 @@
"eslint-plugin-no-relative-import-paths": "1.6.1",
"eslint-plugin-prettier": "5.5.4",
"jiti": "2.5.1",
"nodemon": "3.1.10",
"prettier": "3.6.2",
"rollup-plugin-node-externals": "8.1.0",
"supertest": "7.1.4",
Expand Down
4 changes: 2 additions & 2 deletions api/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { exit } from 'process';
import type { PackageJson } from 'type-fest';
import { $, cd } from 'zx';

import { getDeploymentVersion } from './get-deployment-version.js';
import { getDeploymentVersion } from '@app/../scripts/get-deployment-version.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify the import path change for getDeploymentVersion.

The import path changed from './get-deployment-version.js' (resolving to api/scripts/get-deployment-version.js) to '@app/../scripts/get-deployment-version.js' (resolving to scripts/get-deployment-version.js at repo root). This suggests the file was moved from the api/scripts directory to a root-level scripts directory.

Run the following script to verify the file exists at the expected location:


🏁 Script executed:

#!/bin/bash
# Description: Verify get-deployment-version.js exists at the new location

echo "Checking for get-deployment-version.js..."
if [ -f "scripts/get-deployment-version.js" ]; then
    echo "✓ Found at scripts/get-deployment-version.js"
    echo "File contents preview:"
    head -10 scripts/get-deployment-version.js
elif [ -f "api/scripts/get-deployment-version.js" ]; then
    echo "⚠ File still exists at old location: api/scripts/get-deployment-version.js"
    echo "The import path may be incorrect"
else
    echo "✗ File not found at either location"
fi

Length of output: 77


The file doesn't exist at either location. Let me search the entire repository to determine where this file actually is:


🏁 Script executed:

#!/bin/bash
# Search for any files with get-deployment-version in the name

echo "Searching for get-deployment-version files in repo..."
fd "get-deployment-version" --type f

echo -e "\n---"
echo "Checking if file exists anywhere with different extension..."
fd "get-deployment-version" --type f -e ts -e js -e mjs

echo -e "\n---"
echo "Searching for references to getDeploymentVersion..."
rg "getDeploymentVersion" -n --type ts --type js 2>/dev/null | head -20

Length of output: 632


Let me verify the module alias configuration to understand how @app resolves:


🏁 Script executed:

#!/bin/bash
# Find tsconfig or path alias configuration

echo "Looking for tsconfig.json files..."
fd "tsconfig" --type f

echo -e "\n---"
echo "Checking for path alias configuration in tsconfig..."
rg '"@app"' --type json -A2 -B2

echo -e "\n---"
echo "Checking import in build.ts context..."
rg -n -B2 -A5 "import.*getDeploymentVersion" git/api/scripts/build.ts

Length of output: 885


Let me check the specific tsconfig.json in the api directory where build.ts is located:


🏁 Script executed:

#!/bin/bash
# Check the api tsconfig.json for @app alias

echo "Contents of api/tsconfig.json:"
cat git/api/tsconfig.json

echo -e "\n---"
echo "Checking for package.json in api directory:"
cat git/api/package.json 2>/dev/null | head -40

echo -e "\n---"
echo "Double-checking - what is the correct relative import from build.ts to get-deployment-version.ts?"
echo "build.ts location: api/scripts/build.ts"
echo "get-deployment-version.ts location: api/scripts/get-deployment-version.ts"
echo "Correct import should be: './get-deployment-version.js' or './get-deployment-version.ts'"

Length of output: 4417


Fix broken import path and extension in build.ts line 10.

The import path is incorrect on multiple levels:

  • @app/../scripts/get-deployment-version.js resolves to ./scripts/get-deployment-version.js (repo root) via the @app alias mapping ("@app/*": ["./src/*"] in api/tsconfig.json)
  • The actual file is located at api/scripts/get-deployment-version.ts (same directory as build.ts)
  • The file does not exist at the resolved path

Change line 10 to:

import { getDeploymentVersion } from './get-deployment-version.js';
🤖 Prompt for AI Agents
In api/scripts/build.ts around line 10, the import path uses the @app alias and
points to @app/../scripts/get-deployment-version.js which resolves incorrectly
to the repo root and the target file doesn't exist there; update the import to
reference the local sibling module by changing it to import from
'./get-deployment-version.js' so it correctly loads
api/scripts/get-deployment-version.ts (compiled .js at runtime).


type ApiPackageJson = PackageJson & {
version: string;
Expand Down Expand Up @@ -94,7 +94,7 @@ try {

await writeFile('./deploy/pack/package.json', JSON.stringify(parsedPackageJson, null, 4));
// Copy necessary files to the pack directory
await $`cp -r dist README.md .env.* ecosystem.config.json ./deploy/pack/`;
await $`cp -r dist README.md .env.* nodemon.json ./deploy/pack/`;

// Change to the pack directory and install dependencies
cd('./deploy/pack');
Expand Down
5 changes: 0 additions & 5 deletions api/src/__test__/core/utils/pm2/dummy-process.js

This file was deleted.

222 changes: 0 additions & 222 deletions api/src/__test__/core/utils/pm2/unraid-api-running.integration.test.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';

import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest';

describe('isUnraidApiRunning (nodemon pid detection)', () => {
let tempDir: string;
let pidPath: string;

beforeAll(() => {
tempDir = mkdtempSync(join(tmpdir(), 'unraid-api-'));
pidPath = join(tempDir, 'nodemon.pid');
});

afterAll(() => {
rmSync(tempDir, { recursive: true, force: true });
});

afterEach(() => {
vi.resetModules();
});

async function loadIsRunning() {
vi.doMock('@app/environment.js', async () => {
const actual =
await vi.importActual<typeof import('@app/environment.js')>('@app/environment.js');
return { ...actual, NODEMON_PID_PATH: pidPath };
});

const module = await import('@app/core/utils/process/unraid-api-running.js');
return module.isUnraidApiRunning;
}

it('returns false when pid file is missing', async () => {
const isUnraidApiRunning = await loadIsRunning();

expect(await isUnraidApiRunning()).toBe(false);
});

it('returns true when a live pid is recorded', async () => {
writeFileSync(pidPath, `${process.pid}`);
const isUnraidApiRunning = await loadIsRunning();

expect(await isUnraidApiRunning()).toBe(true);
});

it('returns false when pid file is invalid', async () => {
writeFileSync(pidPath, 'not-a-number');
const isUnraidApiRunning = await loadIsRunning();

expect(await isUnraidApiRunning()).toBe(false);
});
});
Loading
Loading