mirror of
https://github.com/unraid/api.git
synced 2026-01-04 07:29:48 -06:00
due to issues and redundancies in vendoring postinstall side-effects, such as compiled bindings for libvirt, we reverted to vendoring `node_modules`, installed via `npm` instead of a global pnpm store generated by `pnpm`. This should resolve runtime issues with e.g. the libvirt bindings because `node_modules` will contain the correct "side-effects." ## Summary by CodeRabbit - **New Features** - Introduced a command to remove stale archive files during the cleanup process. - Added functionality to archive the `node_modules` directory. - Enhanced dependency resolution with new overrides for specific packages. - **Chores** - Updated dependency settings by replacing one key dependency with an alternative and removing two unused ones, ensuring optimal deployment. - Enhanced the installation process to operate strictly in offline mode. - Updated artifact naming conventions for clarity and consistency in workflows. - Modified volume mappings in the Docker Compose configuration to reflect new artifact names. - Improved error handling in the GitHub Actions workflow by adding checks for required files. - Updated references in the build process to use a vendor store instead of the PNPM store. - Removed the management of PNPM store archives from the build process.
43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
import { apiDir, deployDir } from "./utils/paths";
|
|
import { join } from "path";
|
|
import { readFileSync } from "node:fs";
|
|
import { startingDir } from "./utils/consts";
|
|
import { copyFile } from "node:fs/promises";
|
|
|
|
/**
|
|
* Get the version of the API from the package.json file
|
|
*
|
|
* Throws if package.json is not found or is invalid JSON.
|
|
* @returns The version of the API
|
|
*/
|
|
function getVersion(): string {
|
|
const packageJsonPath = join(apiDir, "package.json");
|
|
const packageJsonString = readFileSync(packageJsonPath, "utf8");
|
|
const packageJson = JSON.parse(packageJsonString);
|
|
return packageJson.version;
|
|
}
|
|
|
|
/**
|
|
* The name of the node_modules archive that will be vendored with the plugin.
|
|
* @returns The name of the node_modules bundle file
|
|
*/
|
|
export function getVendorBundleName(): string {
|
|
const version = getVersion();
|
|
return `node_modules-for-v${version}.tar.xz`;
|
|
}
|
|
|
|
/**
|
|
* Prepare a versioned bundle of the API's node_modules to vendor dependencies.
|
|
*
|
|
* It expects a generic `packed-node-modules.tar.xz` archive to be available in the `startingDir`.
|
|
* It copies this archive to the `deployDir` directory and adds a version to the filename.
|
|
* It does not actually create the packed node_modules archive; that is done inside the API's build script.
|
|
*
|
|
* After this operation, the vendored node_modules will be available inside the `deployDir`.
|
|
*/
|
|
export async function bundleVendorStore(): Promise<void> {
|
|
const storeArchive = join(startingDir, "packed-node-modules.tar.xz");
|
|
const vendorStoreTarPath = join(deployDir, getVendorBundleName());
|
|
await copyFile(storeArchive, vendorStoreTarPath);
|
|
}
|