feat: improve local dev with install path (#1221)

- also add better watcher support

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added a helper that displays a local installation URL to simplify
setting up the plugin.

- **Chores**
- Updated service and container port configurations to ensure consistent
network connectivity (changed from 8080 to 5858).
- Refined container management to gracefully handle running instances
during startup.
- Improved build and installation routines for streamlined deployment
and enhanced reliability.
- Enhanced documentation to clarify installation and usage instructions
for better user experience.
- Introduced a new document outlining development workflows for better
guidance.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1209561202532053
This commit is contained in:
Eli Bosley
2025-03-17 09:44:10 -04:00
committed by GitHub
parent 1b0fbaf81a
commit ce61fee41c
20 changed files with 533 additions and 108 deletions

21
.github/CODEOWNERS vendored
View File

@@ -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

View File

@@ -20,5 +20,5 @@ dynamicRemoteAccessType="DISABLED"
ssoSubIds="" 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" 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] [connectionStatus]
minigraph="ERROR_RETRYING" minigraph="PRE_INIT"
upnpStatus="" upnpStatus=""

View File

@@ -2,7 +2,7 @@
## Installation ## 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) [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) [staging](https://preview.dl.unraid.net/unraid-api/dynamix.unraid.net.staging.plg)

View File

@@ -11,11 +11,11 @@ The repository consists of:
- Core Modules - Core Modules
- Tests - Tests
## API Server Architecture ## API Server Architecture
The API server is built with NestJS and provides the core functionality for interacting with Unraid systems. 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/unraid-api/` - Core NestJS implementation
- `src/core/` - Legacy business logic and utilities - `src/core/` - Legacy business logic and utilities
@@ -61,7 +61,7 @@ The store syncs data in two ways:
The repository is organized into several packages: The repository is organized into several packages:
- `api/` - NestJS API server - `api/` - NestJS API server
- `plugin/` - Unraid plugin package - `plugin/` - Unraid plugin package
- `web/` - Frontend application - `web/` - Frontend application
- `unraid-ui/` - Shared UI components - `unraid-ui/` - Shared UI components

View File

@@ -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

View File

@@ -20,7 +20,7 @@
"// Build and Deploy": "", "// Build and Deploy": "",
"build": "vite build --mode=production", "build": "vite build --mode=production",
"postbuild": "chmod +x dist/main.js && chmod +x dist/cli.js", "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:docker": "./scripts/dc.sh run --rm builder",
"build:release": "tsx ./scripts/build.ts", "build:release": "tsx ./scripts/build.ts",
"preunraid:deploy": "pnpm build", "preunraid:deploy": "pnpm build",

View File

@@ -8,8 +8,6 @@ import { getDeploymentVersion } from './get-deployment-version.js';
try { try {
// Create release and pack directories // Create release and pack directories
// Clean existing deploy folder
await rm('./deploy', { recursive: true }).catch(() => {});
await mkdir('./deploy/release', { recursive: true }); await mkdir('./deploy/release', { recursive: true });
await mkdir('./deploy/pack', { recursive: true }); await mkdir('./deploy/pack', { recursive: true });

View File

@@ -1,26 +1,17 @@
#!/bin/bash #!/bin/bash
# Path to store the last used server name # Arguments
state_file="$HOME/.deploy_state" # $1: SSH server name (required)
# 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}"
# Check if the server name is provided # Check if the server name is provided
if [[ -z "$server_name" ]]; then if [[ -z "$1" ]]; then
echo "Please provide the SSH server name." echo "Error: SSH server name is required."
echo "Usage: $0 <server_name>"
exit 1 exit 1
fi fi
# Save the current server name to the state file # Set server name from command-line argument
echo "$server_name" > "$state_file" server_name="$1"
# Source directory path # Source directory path
source_directory="./dist" source_directory="./dist"
@@ -34,9 +25,11 @@ if [ ! -d "$source_directory" ]; then
fi fi
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 # 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 "Executing the following command:"
echo "$rsync_command" echo "$rsync_command"
@@ -46,10 +39,10 @@ eval "$rsync_command"
exit_code=$? exit_code=$?
# Chown the directory # 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 # 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 # Play built-in sound based on the operating system
if [[ "$OSTYPE" == "darwin"* ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then

View File

@@ -2,5 +2,3 @@
PR=35 PR=35
# Skip validation (default: true for local testing) # Skip validation (default: true for local testing)
SKIP_VALIDATION=true SKIP_VALIDATION=true
# Local file server URL (optional)
LOCAL_FILESERVER_URL=http://192.168.1.100:8080

View File

@@ -23,8 +23,8 @@ RUN corepack enable && pnpm install
# Install a simple http server # Install a simple http server
RUN npm install -g http-server RUN npm install -g http-server
# Expose port 8080 # Expose port 5858
EXPOSE 8080 EXPOSE 5858
COPY scripts/entrypoint.sh /start.sh COPY scripts/entrypoint.sh /start.sh
RUN chmod +x /start.sh RUN chmod +x /start.sh

View File

@@ -8,22 +8,35 @@ import { cleanupTxzFiles } from "./utils/cleanup";
// Recursively search for manifest files // Recursively search for manifest files
const findManifestFiles = async (dir: string): Promise<string[]> => { const findManifestFiles = async (dir: string): Promise<string[]> => {
const entries = await readdir(dir, { withFileTypes: true }); try {
const files: string[] = []; const entries = await readdir(dir, { withFileTypes: true });
const files: string[] = [];
for (const entry of entries) { for (const entry of entries) {
const fullPath = join(dir, entry.name); const fullPath = join(dir, entry.name);
if (entry.isDirectory()) { if (entry.isDirectory()) {
files.push(...(await findManifestFiles(fullPath))); try {
} else if ( files.push(...(await findManifestFiles(fullPath)));
entry.isFile() && } catch (error) {
(entry.name === "manifest.json" || entry.name === "ui.manifest.json") // Log and continue if a subdirectory can't be read
) { console.warn(`Warning: Could not read directory ${fullPath}: ${error.message}`);
files.push(entry.name); }
} else if (
entry.isFile() &&
(entry.name === "manifest.json" || entry.name === "ui.manifest.json")
) {
files.push(entry.name);
}
} }
}
return files; return files;
} catch (error) {
if (error.code === 'ENOENT') {
console.warn(`Directory does not exist: ${dir}`);
return [];
}
throw error; // Re-throw other errors
}
}; };
const validateSourceDir = async (validatedEnv: TxzEnv) => { const validateSourceDir = async (validatedEnv: TxzEnv) => {

View File

@@ -1,7 +1,7 @@
services: services:
plugin-builder: plugin-builder:
ports: ports:
- 8080:8080 - 5858:5858
build: . build: .
volumes: volumes:
- ./:/app - ./:/app

View File

@@ -17,11 +17,11 @@
"license": "GPL-2.0-only", "license": "GPL-2.0-only",
"scripts": { "scripts": {
"// Build scripts": "", "// Build scripts": "",
"build": "pnpm run build:txz && pnpm run build:plugin", "build": "pnpm run build:txz && pnpm run build:plugin && ./scripts/output-local-url.sh",
"build:txz": "tsx builder/build-txz.ts", "build:txz": "tsx builder/build-txz.ts",
"build:plugin": "tsx builder/build-plugin.ts", "build:plugin": "tsx builder/build-plugin.ts",
"build:validate": "npm run env:validate && npm run build", "build:validate": "npm run env:validate && npm run build",
"build:watcher": "nodemon --watch 'source/**/*' --exec 'pnpm run build'", "build:watcher": "nodemon --verbose --watch 'source/**/*' --ext ts,js --ignore '*.test.ts' --ignore 'node_modules/**' --ignore 'source/dynamix.unraid.net/install/**' --delay 5s --exec 'pnpm run build'",
"// Docker commands": "", "// Docker commands": "",
"build:watch": "./scripts/dc.sh pnpm run build:watcher", "build:watch": "./scripts/dc.sh pnpm run build:watcher",
"docker:build": "docker compose build", "docker:build": "docker compose build",

View File

@@ -17,4 +17,15 @@ fi
CI=${CI:-false} CI=${CI:-false}
TAG="LOCAL_PLUGIN_BUILD" TAG="LOCAL_PLUGIN_BUILD"
docker compose run --service-ports --rm -e HOST_LAN_IP="$HOST_LAN_IP" -e CI="$CI" -e TAG="$TAG" plugin-builder "$@"
# Define container name for easier management
CONTAINER_NAME="plugin-builder"
# Stop any running plugin-builder container first
echo "Stopping any running plugin-builder containers..."
docker ps -q --filter "name=${CONTAINER_NAME}" | xargs -r docker stop
# Start the container with the specified environment variables
echo "Starting plugin-builder container..."
docker compose run --remove-orphans --service-ports -e HOST_LAN_IP="$HOST_LAN_IP" -e CI="$CI" -e TAG="$TAG" ${CONTAINER_NAME} "$@"

View File

@@ -1,30 +1,18 @@
#!/bin/bash #!/bin/bash
# Arguments # Arguments
# $1: SSH server name # $1: SSH server name (required)
# $2: {--wc-deploy|--wc-build|--wc-skip} / deploy or build web components w/o prompt # $2: {--wc-deploy|--wc-build|--wc-skip} / deploy or build web components w/o prompt
# 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}"
# Check if the server name is provided # Check if the server name is provided
if [[ -z "$server_name" ]]; then if [[ -z "$1" ]]; then
echo "Please provide the SSH server name." echo "Error: SSH server name is required."
echo "Usage: $0 <server_name> [--wc-deploy|--wc-build|--wc-skip]"
exit 1 exit 1
fi fi
# Save the current server name to the state file # Set server name from command-line argument
echo "$server_name" > "$state_file" server_name="$1"
# Source directory path # Source directory path
source_directory="plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins" source_directory="plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins"

View File

@@ -3,7 +3,7 @@
mkdir -p /app/deploy/ mkdir -p /app/deploy/
# Start http-server with common fileserver settings # Start http-server with common fileserver settings
http-server /app/deploy/ \ http-server /app/deploy/ \
--port 8080 \ --port 5858 \
--host 0.0.0.0 \ --host 0.0.0.0 \
--cors \ --cors \
--gzip \ --gzip \

View File

@@ -0,0 +1,10 @@
#!/bin/bash
# Use ANSI escape codes for color and formatting
# \e[1m = bold, \e[32m = green, \e[0m = reset formatting
echo -e "\e[1m\e[32m"
echo "=============================================================="
echo " INSTALL THE LOCAL PLUGIN USING THIS URL: "
echo " http://${HOST_LAN_IP}:5858/dynamix.unraid.net.plg "
echo "=============================================================="
echo -e "\e[0m"

View File

@@ -110,3 +110,207 @@ fi
( cd usr/local/unraid-api/node_modules/esbuild/node_modules/.bin ; ln -sf ../../bin/esbuild esbuild ) ( cd usr/local/unraid-api/node_modules/esbuild/node_modules/.bin ; ln -sf ../../bin/esbuild esbuild )
( cd usr/local/unraid-api/node_modules/request/node_modules/.bin ; rm -rf uuid ) ( cd usr/local/unraid-api/node_modules/request/node_modules/.bin ; rm -rf uuid )
( cd usr/local/unraid-api/node_modules/request/node_modules/.bin ; ln -sf ../uuid/bin/uuid uuid ) ( cd usr/local/unraid-api/node_modules/request/node_modules/.bin ; ln -sf ../uuid/bin/uuid uuid )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf apollo-pbjs )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../@apollo/protobufjs/bin/pbjs apollo-pbjs )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf apollo-pbts )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../@apollo/protobufjs/bin/pbts apollo-pbts )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf blessed )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../blessed/bin/tput.js blessed )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf esbuild )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../esbuild/bin/esbuild esbuild )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf escodegen )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../escodegen/bin/escodegen.js escodegen )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf esgenerate )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../escodegen/bin/esgenerate.js esgenerate )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf esparse )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../esprima/bin/esparse.js esparse )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf esvalidate )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../esprima/bin/esvalidate.js esvalidate )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf fxparser )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../fast-xml-parser/src/cli/cli.js fxparser )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf glob )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../glob/dist/esm/bin.mjs glob )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf js-yaml )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../js-yaml/bin/js-yaml.js js-yaml )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf jsesc )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../jsesc/bin/jsesc jsesc )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf loose-envify )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../loose-envify/cli.js loose-envify )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf mime )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../mime/cli.js mime )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf mkdirp )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../mkdirp/bin/cmd.js mkdirp )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf mustache )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../mustache/bin/mustache mustache )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf needle )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../needle/bin/needle needle )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf node-which )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../which/bin/node-which node-which )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf opencollective )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../@nuxtjs/opencollective/bin/opencollective.js opencollective )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf parser )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../@babel/parser/bin/babel-parser.js parser )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf pino )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../pino/bin.js pino )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf pino-pretty )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../pino-pretty/bin.js pino-pretty )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf pm2 )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../pm2/bin/pm2 pm2 )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf pm2-dev )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../pm2/bin/pm2-dev pm2-dev )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf pm2-docker )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../pm2/bin/pm2-docker pm2-docker )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf pm2-runtime )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../pm2/bin/pm2-runtime pm2-runtime )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf prettier )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../prettier/bin/prettier.cjs prettier )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf relay-compiler )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../@ardatan/relay-compiler/bin/relay-compiler relay-compiler )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf resolve )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../resolve/bin/resolve resolve )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf semver )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../semver/bin/semver.js semver )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf sha.js )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../sha.js/bin.js sha.js )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf sshpk-conv )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../sshpk/bin/sshpk-conv sshpk-conv )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf sshpk-sign )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../sshpk/bin/sshpk-sign sshpk-sign )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf sshpk-verify )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../sshpk/bin/sshpk-verify sshpk-verify )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf systeminformation )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../systeminformation/lib/cli.js systeminformation )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf tsc )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../typescript/bin/tsc tsc )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf tsserver )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../typescript/bin/tsserver tsserver )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf tsx )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../tsx/dist/cli.mjs tsx )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf ua-parser-js )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../ua-parser-js/script/cli.js ua-parser-js )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf uuid )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../uuid/dist/esm/bin/uuid uuid )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf xss )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../xss/bin/xss xss )
( cd usr/local/unraid-api/node_modules/@apollo/protobufjs/node_modules/.bin ; rm -rf apollo-pbjs )
( cd usr/local/unraid-api/node_modules/@apollo/protobufjs/node_modules/.bin ; ln -sf ../../bin/pbjs apollo-pbjs )
( cd usr/local/unraid-api/node_modules/@apollo/protobufjs/node_modules/.bin ; rm -rf apollo-pbts )
( cd usr/local/unraid-api/node_modules/@apollo/protobufjs/node_modules/.bin ; ln -sf ../../bin/pbts apollo-pbts )
( cd usr/local/unraid-api/node_modules/@apollo/server/node_modules/.bin ; rm -rf uuid )
( cd usr/local/unraid-api/node_modules/@apollo/server/node_modules/.bin ; ln -sf ../uuid/dist/bin/uuid uuid )
( cd usr/local/unraid-api/node_modules/@nestjs/core/node_modules/.bin ; rm -rf opencollective )
( cd usr/local/unraid-api/node_modules/@nestjs/core/node_modules/.bin ; ln -sf ../../../../@nuxtjs/opencollective/bin/opencollective.js opencollective )
( cd usr/local/unraid-api/node_modules/@nestjs/graphql/node_modules/.bin ; rm -rf uuid )
( cd usr/local/unraid-api/node_modules/@nestjs/graphql/node_modules/.bin ; ln -sf ../uuid/dist/esm/bin/uuid uuid )
( cd usr/local/unraid-api/node_modules/@pm2/agent/node_modules/.bin ; rm -rf semver )
( cd usr/local/unraid-api/node_modules/@pm2/agent/node_modules/.bin ; ln -sf ../semver/bin/semver.js semver )
( cd usr/local/unraid-api/node_modules/@pm2/io/node_modules/.bin ; rm -rf semver )
( cd usr/local/unraid-api/node_modules/@pm2/io/node_modules/.bin ; ln -sf ../semver/bin/semver.js semver )
( cd usr/local/unraid-api/node_modules/esbuild/node_modules/.bin ; rm -rf esbuild )
( cd usr/local/unraid-api/node_modules/esbuild/node_modules/.bin ; ln -sf ../../bin/esbuild esbuild )
( cd usr/local/unraid-api/node_modules/nestjs-pino/node_modules/.bin ; rm -rf pino )
( cd usr/local/unraid-api/node_modules/nestjs-pino/node_modules/.bin ; ln -sf ../../../pino/bin.js pino )
( cd usr/local/unraid-api/node_modules/request/node_modules/.bin ; rm -rf uuid )
( cd usr/local/unraid-api/node_modules/request/node_modules/.bin ; ln -sf ../uuid/bin/uuid uuid )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf apollo-pbjs )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../@apollo/protobufjs/bin/pbjs apollo-pbjs )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf apollo-pbts )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../@apollo/protobufjs/bin/pbts apollo-pbts )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf blessed )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../blessed/bin/tput.js blessed )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf esbuild )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../esbuild/bin/esbuild esbuild )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf escodegen )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../escodegen/bin/escodegen.js escodegen )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf esgenerate )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../escodegen/bin/esgenerate.js esgenerate )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf esparse )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../esprima/bin/esparse.js esparse )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf esvalidate )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../esprima/bin/esvalidate.js esvalidate )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf fxparser )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../fast-xml-parser/src/cli/cli.js fxparser )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf glob )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../glob/dist/esm/bin.mjs glob )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf js-yaml )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../js-yaml/bin/js-yaml.js js-yaml )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf jsesc )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../jsesc/bin/jsesc jsesc )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf loose-envify )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../loose-envify/cli.js loose-envify )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf mime )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../mime/cli.js mime )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf mkdirp )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../mkdirp/bin/cmd.js mkdirp )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf mustache )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../mustache/bin/mustache mustache )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf needle )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../needle/bin/needle needle )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf node-which )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../which/bin/node-which node-which )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf opencollective )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../@nuxtjs/opencollective/bin/opencollective.js opencollective )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf parser )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../@babel/parser/bin/babel-parser.js parser )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf pino )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../pino/bin.js pino )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf pino-pretty )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../pino-pretty/bin.js pino-pretty )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf pm2 )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../pm2/bin/pm2 pm2 )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf pm2-dev )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../pm2/bin/pm2-dev pm2-dev )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf pm2-docker )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../pm2/bin/pm2-docker pm2-docker )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf pm2-runtime )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../pm2/bin/pm2-runtime pm2-runtime )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf prettier )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../prettier/bin/prettier.cjs prettier )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf relay-compiler )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../@ardatan/relay-compiler/bin/relay-compiler relay-compiler )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf resolve )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../resolve/bin/resolve resolve )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf semver )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../semver/bin/semver.js semver )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf sha.js )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../sha.js/bin.js sha.js )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf sshpk-conv )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../sshpk/bin/sshpk-conv sshpk-conv )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf sshpk-sign )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../sshpk/bin/sshpk-sign sshpk-sign )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf sshpk-verify )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../sshpk/bin/sshpk-verify sshpk-verify )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf systeminformation )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../systeminformation/lib/cli.js systeminformation )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf tsc )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../typescript/bin/tsc tsc )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf tsserver )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../typescript/bin/tsserver tsserver )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf tsx )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../tsx/dist/cli.mjs tsx )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf ua-parser-js )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../ua-parser-js/script/cli.js ua-parser-js )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf uuid )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../uuid/dist/esm/bin/uuid uuid )
( cd usr/local/unraid-api/node_modules/.bin ; rm -rf xss )
( cd usr/local/unraid-api/node_modules/.bin ; ln -sf ../xss/bin/xss xss )
( cd usr/local/unraid-api/node_modules/@apollo/protobufjs/node_modules/.bin ; rm -rf apollo-pbjs )
( cd usr/local/unraid-api/node_modules/@apollo/protobufjs/node_modules/.bin ; ln -sf ../../bin/pbjs apollo-pbjs )
( cd usr/local/unraid-api/node_modules/@apollo/protobufjs/node_modules/.bin ; rm -rf apollo-pbts )
( cd usr/local/unraid-api/node_modules/@apollo/protobufjs/node_modules/.bin ; ln -sf ../../bin/pbts apollo-pbts )
( cd usr/local/unraid-api/node_modules/@apollo/server/node_modules/.bin ; rm -rf uuid )
( cd usr/local/unraid-api/node_modules/@apollo/server/node_modules/.bin ; ln -sf ../uuid/dist/bin/uuid uuid )
( cd usr/local/unraid-api/node_modules/@nestjs/core/node_modules/.bin ; rm -rf opencollective )
( cd usr/local/unraid-api/node_modules/@nestjs/core/node_modules/.bin ; ln -sf ../../../../@nuxtjs/opencollective/bin/opencollective.js opencollective )
( cd usr/local/unraid-api/node_modules/@nestjs/graphql/node_modules/.bin ; rm -rf uuid )
( cd usr/local/unraid-api/node_modules/@nestjs/graphql/node_modules/.bin ; ln -sf ../uuid/dist/esm/bin/uuid uuid )
( cd usr/local/unraid-api/node_modules/@pm2/agent/node_modules/.bin ; rm -rf semver )
( cd usr/local/unraid-api/node_modules/@pm2/agent/node_modules/.bin ; ln -sf ../semver/bin/semver.js semver )
( cd usr/local/unraid-api/node_modules/@pm2/io/node_modules/.bin ; rm -rf semver )
( cd usr/local/unraid-api/node_modules/@pm2/io/node_modules/.bin ; ln -sf ../semver/bin/semver.js semver )
( cd usr/local/unraid-api/node_modules/esbuild/node_modules/.bin ; rm -rf esbuild )
( cd usr/local/unraid-api/node_modules/esbuild/node_modules/.bin ; ln -sf ../../bin/esbuild esbuild )
( cd usr/local/unraid-api/node_modules/nestjs-pino/node_modules/.bin ; rm -rf pino )
( cd usr/local/unraid-api/node_modules/nestjs-pino/node_modules/.bin ; ln -sf ../../../pino/bin.js pino )
( cd usr/local/unraid-api/node_modules/request/node_modules/.bin ; rm -rf uuid )
( cd usr/local/unraid-api/node_modules/request/node_modules/.bin ; ln -sf ../uuid/bin/uuid uuid )

View File

@@ -21,7 +21,7 @@
<br /> <br />
<div align="center"> <div align="center">
<a href="https://github.com/unraid/api"> <a href="https://github.com/unraid/api">
<img src=".github/unraid.svg" alt="Logo" width="80" height="80"> <img src=".github/unraid.svg" alt="Logo" width="80" height="80"/>
</a> </a>
<h3 align="center">Unraid Connect</h3> <h3 align="center">Unraid Connect</h3>
@@ -112,39 +112,25 @@ Once you have your key pair, add your public SSH key to your Unraid server:
1. Clone and enter the repo 1. Clone and enter the repo
```sh ```sh
# Optionally, give the cloned folder a more specific name git clone git@github.com:unraid/api.git
gh repo clone unraid/api api-monorepo cd api
cd api-monorepo
``` ```
2. Run the monorepo setup command. 2. Run the monorepo setup command.
```sh ```sh
just setup pnpm install
``` ```
This will run installation scripts, container builds, and some git scripts to reduce noise (i.e. personal editor customizations, etc). 3. Run the build watcher to build the components and serve a local plugin file that can be installed on your Unraid server.
Alternatively, run `pnpm install` for a lighter, less opinionated setup.
3. Run dev servers
```sh ```sh
pnpm dev pnpm build:watch
``` ```
This will run every dev server in the monorepo. By default, this means: Navigate to Plugins->Install and install the local plugin file that is output to the console.
* The unraid-api will be available at localhost:3001 ## View other workflows (local dev, etc.) in the [Developer Workflows](./api/docs/developer/workflows.md)
* The dev server for "rich" web components (like the User Profile Component) will be at localhost:4321 -- Note that shipping to unraid is preferred, as the dev environment is significantly different.
* The vite server for unraid-ui development will be at localhost:5173
4. Test on Unraid
```js
pnpm unraid:deploy <SERVER_IP>
```
This will ship a staging build of unraid-api, unraid-ui, and unraid-components to an Unraid server located at `<SERVER_IP>`.
<p align="right">(<a href="#readme-top">back to top</a>)</p> <p align="right">(<a href="#readme-top">back to top</a>)</p>

View File

@@ -1,26 +1,14 @@
#!/bin/bash #!/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}"
# Check if the server name is provided # Check if the server name is provided
if [[ -z "$server_name" ]]; then if [[ -z "$1" ]]; then
echo "Please provide the SSH server name." echo "Error: SSH server name is required."
echo "Usage: $0 <server_name>"
exit 1 exit 1
fi fi
# Save the current server name to the state file # Set server name from command-line argument
echo "$server_name" > "$state_file" server_name="$1"
# Source directory path # Source directory path
source_directory=".nuxt/nuxt-custom-elements/dist/unraid-components" source_directory=".nuxt/nuxt-custom-elements/dist/unraid-components"