Files
api/plugin/builder/utils/paths.ts
Pujit Mehrotra 9f492bf217 feat: api plugin system & offline versioned dependency vendoring (#1252)
- **New Features**
- Created a dynamic plugin system for the API to enable community
augmentation of GraphQL, CLI, and Cron functionalities capabilities.
- Included an example plugin under `packages/unraid-api-plugin-health`
that adds a new graphql query for API health checks.
- Added `rc.unraid-api` commands for backing up, restoring, and
installing production dependencies, streamlining maintenance and
deployment.
- Improved dependency vendoring by bundling a versioned pnpm store
(instead of `node_modules`). Versioning will allow users to add plugins
to a specific api release without requiring an internet connection on
subsequent reboots.

- **Chores**
- Upgraded build workflows and versioning processes to ensure more
reliable artifact handling and production packaging.
2025-03-27 13:23:55 -04:00

58 lines
1.3 KiB
TypeScript

import { join } from "path";
import {
getTxzName,
pluginName,
pluginNameWithExt,
startingDir,
} from "./consts";
export interface PathConfig {
startingDir: string;
}
export interface TxzPathConfig extends PathConfig {
pluginVersion?: string;
}
export const deployDir = "deploy" as const;
export const apiDir = join(
startingDir,
"source",
pluginName,
"usr",
"local",
"unraid-api"
);
/**
* Get the path to the root plugin directory
* @param startingDir - The starting directory
* @returns The path to the root plugin directory
*/
export function getRootPluginPath({ startingDir }: PathConfig): string {
return join(startingDir, "/plugins/", pluginNameWithExt);
}
/**
* Get the path to the deploy plugin directory
* @param startingDir - The starting directory
* @returns The path to the deploy plugin directory
*/
export function getDeployPluginPath({ startingDir }: PathConfig): string {
return join(startingDir, deployDir, pluginNameWithExt);
}
/**
* Get the path to the TXZ file
* @param startingDir - The starting directory
* @param pluginVersion - The plugin version
* @returns The path to the TXZ file
*/
export function getTxzPath({
startingDir,
pluginVersion,
}: TxzPathConfig): string {
return join(startingDir, deployDir, getTxzName(pluginVersion));
}