Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 20 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
@elibosley @pujitm @mdatelle @zackspear
# Default owners for everything in the repo
* @elibosley @pujitm @mdatelle @zackspear

# API specific files
/api/ @elibosley @pujitm @mdatelle

# Web frontend files
/web/ @elibosley @mdatelle @zackspear

# Plugin related files
/plugin/ @elibosley

# Unraid UI specific files
/unraid-ui/ @mdatelle @zackspear @pujitm

# GitHub workflows and configuration
/.github/ @elibosley

# Documentation
*.md @elibosley @pujitm @mdatelle @zackspear
2 changes: 1 addition & 1 deletion api/dev/states/myservers.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ dynamicRemoteAccessType="DISABLED"
ssoSubIds=""
allowedOrigins="/var/run/unraid-notifications.sock, /var/run/unraid-php.sock, /var/run/unraid-cli.sock, http://localhost:8080, https://localhost:4443, https://tower.local:4443, https://192.168.1.150:4443, https://tower:4443, https://192-168-1-150.thisisfourtyrandomcharacters012345678900.myunraid.net:4443, https://85-121-123-122.thisisfourtyrandomcharacters012345678900.myunraid.net:8443, https://10-252-0-1.hash.myunraid.net:4443, https://10-252-1-1.hash.myunraid.net:4443, https://10-253-3-1.hash.myunraid.net:4443, https://10-253-4-1.hash.myunraid.net:4443, https://10-253-5-1.hash.myunraid.net:4443, https://10-100-0-1.hash.myunraid.net:4443, https://10-100-0-2.hash.myunraid.net:4443, https://10-123-1-2.hash.myunraid.net:4443, https://221-123-121-112.hash.myunraid.net:4443, https://google.com, https://test.com, https://connect.myunraid.net, https://connect-staging.myunraid.net, https://dev-my.myunraid.net:4000, https://studio.apollographql.com"
[connectionStatus]
minigraph="ERROR_RETRYING"
minigraph="PRE_INIT"
upnpStatus=""
2 changes: 1 addition & 1 deletion api/docs/developer/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Installation

Manual install can be done with the following routes:
Manual install of the staging and production plugins can be done with the following routes:
[production](https://stable.dl.unraid.net/unraid-api/dynamix.unraid.net.plg)
[staging](https://preview.dl.unraid.net/unraid-api/dynamix.unraid.net.staging.plg)

Expand Down
6 changes: 3 additions & 3 deletions api/docs/developer/repo-organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ The repository consists of:
- Core Modules
- Tests

## API Server Architecture
## API Server Architecture

The API server is built with NestJS and provides the core functionality for interacting with Unraid systems.

### Key Components:
### Key Components

- `src/unraid-api/` - Core NestJS implementation
- `src/core/` - Legacy business logic and utilities
Expand Down Expand Up @@ -61,7 +61,7 @@ The store syncs data in two ways:
The repository is organized into several packages:

- `api/` - NestJS API server
- `plugin/` - Unraid plugin package
- `plugin/` - Unraid plugin package
- `web/` - Frontend application
- `unraid-ui/` - Shared UI components

Expand Down
217 changes: 217 additions & 0 deletions api/docs/developer/workflows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
# Unraid API Development Workflows

This document outlines the various workflow styles available for developing, building, and deploying the Unraid API monorepo.

## Repository Structure

The Unraid API monorepo consists of several packages:

- `api`: The Unraid API backend
- `web`: The web frontend components
- `plugin`: The Unraid plugin
- `unraid-ui`: UI components library

## Development Workflows

### Local Development

To start all development servers in the monorepo:

```bash
pnpm dev
```

This command runs all development servers concurrently:

- API server: <http://localhost:3001>
- Web components: <http://localhost:4321>
- UI components: <http://localhost:5173>

### Package-Specific Development

If you want to work on a specific package, you can run its development server individually:

#### API Development

```bash
cd api
pnpm dev
```

#### Web Development

```bash
cd web
pnpm dev
```

#### UI Component Development

```bash
cd unraid-ui
pnpm dev
```

## Building Workflows

### Building All Packages

To build all packages in the monorepo:

```bash
pnpm build
```

### Watch Mode Building

For continuous building during development:

```bash
pnpm build:watch
```

This is useful when you want to see your changes reflected without manually rebuilding. This will also allow you to install a local plugin to test your changes.

### Package-Specific Building

#### API Building

```bash
cd api
pnpm build
```

#### Web Building

```bash
cd web
pnpm build
```

#### Development Build for Web

```bash
cd web
pnpm build:dev
```

## Deployment Workflows

### Deploying to Development Unraid Server

To deploy to a development Unraid server:

```bash
pnpm unraid:deploy <SERVER_IP>
```

This command builds and deploys all components to the specified Unraid server.

### Package-Specific Deployment

#### API Deployment

```bash
cd api
pnpm unraid:deploy <SERVER_IP>
```

#### Web Deployment

```bash
cd web
pnpm unraid:deploy <SERVER_IP>
```

#### Plugin Deployment

```bash
cd plugin
pnpm unraid:deploy <SERVER_IP>
```

## Testing

To run tests across all packages:

```bash
pnpm test
```

### Package-Specific Testing

```bash
cd <package-directory>
pnpm test
```

## Code Quality Workflows

### Linting

To lint all packages:

```bash
pnpm lint
```

To automatically fix linting issues:

```bash
pnpm lint:fix
```

### Type Checking

To run type checking across all packages:

```bash
pnpm type-check
```

## GraphQL Codegen Workflows

For packages that use GraphQL, you can generate types from your schema:

```bash
cd <package-directory>
pnpm codegen
```

To watch for changes and regenerate types:

```bash
cd <package-directory>
pnpm codegen:watch
```

## Docker Workflows

The API package supports Docker-based development:

```bash
cd api
pnpm container:build # Build the Docker container
pnpm container:start # Start the container
pnpm container:stop # Stop the container
pnpm container:enter # Enter the container shell
pnpm container:test # Run tests in the container
```

## CLI Commands

When working with a deployed Unraid API, you can use the CLI:

```bash
unraid-api --help
```

## Recommended Workflow for New Developers

1. Clone the repository: `git clone git@github.com:unraid/api.git`
2. Set up the monorepo: `just setup` or `pnpm install`
3. Start development servers: `pnpm dev`
4. Make your changes
5. Test your changes: `pnpm test`
6. Deploy to a development server: `pnpm unraid:deploy <SERVER_IP>`
7. Verify your changes on the Unraid server
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"// Build and Deploy": "",
"build": "vite build --mode=production",
"postbuild": "chmod +x dist/main.js && chmod +x dist/cli.js",
"build:watch": "vite build --mode=production --watch",
"build:watch": "nodemon --watch src --ext ts,js,json --exec 'tsx ./scripts/build.ts'",
"build:docker": "./scripts/dc.sh run --rm builder",
"build:release": "tsx ./scripts/build.ts",
"preunraid:deploy": "pnpm build",
Expand Down
2 changes: 0 additions & 2 deletions api/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { getDeploymentVersion } from './get-deployment-version.js';

try {
// Create release and pack directories
// Clean existing deploy folder
await rm('./deploy', { recursive: true }).catch(() => {});
await mkdir('./deploy/release', { recursive: true });
await mkdir('./deploy/pack', { recursive: true });

Expand Down
33 changes: 13 additions & 20 deletions api/scripts/deploy-dev.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
#!/bin/bash

# Path to store the last used server name
state_file="$HOME/.deploy_state"

# Read the last used server name from the state file
if [[ -f "$state_file" ]]; then
last_server_name=$(cat "$state_file")
else
last_server_name=""
fi

# Read the server name from the command-line argument or use the last used server name as the default
server_name="${1:-$last_server_name}"
# Arguments
# $1: SSH server name (required)

# Check if the server name is provided
if [[ -z "$server_name" ]]; then
echo "Please provide the SSH server name."
if [[ -z "$1" ]]; then
echo "Error: SSH server name is required."
echo "Usage: $0 <server_name>"
exit 1
fi

# Save the current server name to the state file
echo "$server_name" > "$state_file"
# Set server name from command-line argument
server_name="$1"

# Source directory path
source_directory="./dist"
Expand All @@ -34,9 +25,11 @@ if [ ! -d "$source_directory" ]; then
fi
fi

# Change ownership on copy
# Destination directory path
destination_directory="/usr/local/unraid-api"

# Replace the value inside the rsync command with the user's input
rsync_command="rsync -avz -e ssh $source_directory root@${server_name}:/usr/local/unraid-api"
rsync_command="rsync -avz --progress --stats -e ssh \"$source_directory\" \"root@${server_name}:$destination_directory\""

echo "Executing the following command:"
echo "$rsync_command"
Expand All @@ -46,10 +39,10 @@ eval "$rsync_command"
exit_code=$?

# Chown the directory
ssh root@"${server_name}" "chown -R root:root /usr/local/unraid-api"
ssh root@"${server_name}" 'chown -R root:root /usr/local/unraid-api'

# Run unraid-api restart on remote host
ssh root@"${server_name}" "INTROSPECTION=true LOG_LEVEL=trace unraid-api restart"
ssh root@"${server_name}" 'INTROSPECTION=true LOG_LEVEL=trace unraid-api restart'

# Play built-in sound based on the operating system
if [[ "$OSTYPE" == "darwin"* ]]; then
Expand Down
2 changes: 0 additions & 2 deletions plugin/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
PR=35
# Skip validation (default: true for local testing)
SKIP_VALIDATION=true
# Local file server URL (optional)
LOCAL_FILESERVER_URL=http://192.168.1.100:8080
4 changes: 2 additions & 2 deletions plugin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ RUN corepack enable && pnpm install
# Install a simple http server
RUN npm install -g http-server

# Expose port 8080
EXPOSE 8080
# Expose port 5858
EXPOSE 5858

COPY scripts/entrypoint.sh /start.sh
RUN chmod +x /start.sh
Expand Down
Loading
Loading