mirror of
https://github.com/unraid/api.git
synced 2026-01-01 06:01:18 -06:00
separates Unraid Connect from the API ## Summary by CodeRabbit - **New Features** - Introduced a unified, JSON-schema-based settings system for API configuration and plugin settings, accessible via new GraphQL queries and mutations. - Added modular NestJS plugin architecture for Unraid Connect, including new modules for cloud, remote access, and system/network management. - Added granular connection and remote access state tracking, with new GraphQL types and resolvers for cloud and connection status. - Implemented event-driven and service-based management for SSO users, API keys, and dynamic remote access. - Enhanced UI components and queries to support unified settings and restart detection. - **Improvements** - Refactored configuration and state management to use service-based patterns, replacing direct store access and Redux logic. - Migrated legacy config files to new JSON formats with validation and persistence helpers. - Centralized global dependencies and shared services for plugins and CLI modules. - Improved logging, error handling, and lifecycle management for connections and background jobs. - Updated and expanded documentation for plugin development and settings management. - **Bug Fixes** - Improved handling of missing config files and ensured safe persistence. - Enhanced error reporting and validation in remote access and connection services. - **Removals** - Removed deprecated Redux slices, listeners, and legacy cloud/remote access logic. - Deleted obsolete test files, scripts, and unused code related to the old state/store approach. - **Tests** - Added new unit tests for settings merging, URL resolution, and cloud connectivity checks. - **Style** - Applied consistent formatting, import reorganization, and code style improvements across modules. - **Chores** - Updated build scripts, Dockerfiles, and development environment setup to support new dependencies and workflows. - Expanded .gitignore and configuration files for improved build artifact management.
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import { Command } from "commander";
|
|
import { z } from "zod";
|
|
import { getVersion } from "../utils/version";
|
|
|
|
/**
|
|
* Common base environment fields shared between different build setups
|
|
*/
|
|
export const baseEnvSchema = z.object({
|
|
ci: z.boolean().optional().default(false),
|
|
apiVersion: z.string(),
|
|
baseUrl: z.string().url(),
|
|
tag: z.string().optional().default(""),
|
|
});
|
|
|
|
export type BaseEnv = z.infer<typeof baseEnvSchema>;
|
|
|
|
/**
|
|
* Generate a default base URL for local development
|
|
*/
|
|
export const getDefaultBaseUrl = (): string => {
|
|
return process.env.CI === "true"
|
|
? "This is a CI build, please set the base URL manually"
|
|
: `http://${process.env.HOST_LAN_IP || "localhost"}:5858`;
|
|
};
|
|
|
|
/**
|
|
* Common CLI options shared across different command setups
|
|
*/
|
|
export const addCommonOptions = (program: Command) => {
|
|
return program
|
|
.option("--ci", "CI mode", process.env.CI === "true")
|
|
.requiredOption(
|
|
"--api-version <version>",
|
|
"API version",
|
|
process.env.API_VERSION || getVersion().version
|
|
)
|
|
.requiredOption(
|
|
"--base-url <url>",
|
|
"Base URL for assets",
|
|
getDefaultBaseUrl()
|
|
)
|
|
.option(
|
|
"--tag <tag>",
|
|
"Tag (used for PR and staging builds)",
|
|
process.env.TAG
|
|
);
|
|
};
|