feat: convert to pnpm monorepo (#1137)

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

- **New Features**
- Introduced enhanced project management scripts for building, testing,
and deploying the monorepo.
- Added an automated testing pipeline for improved reliability of the
Libvirt functionality.
- Provided a new plugin installation script that ensures thorough
cleanup during removal.

- **Improvements**
- Updated container mappings and dependency configurations for more
stable and efficient operations.
- Refined web application settings and build commands for smoother
performance.
- Streamlined continuous integration workflows with optimized caching
and dependency management.
  - Updated allowed origins in configuration for enhanced security.

- **Chores/Refactor**
- Removed outdated configuration files to simplify maintenance and
enhance consistency.
- Enhanced event listener management in the web application for better
error handling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Eli Bosley
2025-02-19 13:41:23 -05:00
committed by GitHub
parent 93980f929d
commit ad6b6589db
35 changed files with 23691 additions and 13660 deletions

View File

@@ -42,30 +42,40 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version-file: "api/.nvmrc"
node-version-file: ".nvmrc"
- name: Cache APT Packages
uses: awalsh128/cache-apt-pkgs-action@v1.4.3
with:
packages: bash procps python3 libvirt-dev jq zstd git build-essential
version: 1.0
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 8
version: 10
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('api/pnpm-lock.yaml') }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: PNPM Install
run: pnpm install
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm run lint
@@ -86,12 +96,12 @@ jobs:
- name: Install Node
uses: actions/setup-node@v4
with:
node-version-file: "api/.nvmrc"
node-version-file: ".nvmrc"
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 8
version: 10
run_install: false
- name: Get pnpm store directory
@@ -104,7 +114,7 @@ jobs:
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('api/pnpm-lock.yaml') }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
@@ -115,11 +125,17 @@ jobs:
version: 1.0
- name: PNPM Install
run: pnpm install
run: |
cd ${{ github.workspace }}
pnpm install --frozen-lockfile
- name: Lint
run: pnpm run lint
- name: Type Check
run: pnpm run type-check
continue-on-error: true
- name: Build
run: pnpm run build
@@ -131,7 +147,7 @@ jobs:
PACKAGE_LOCK_VERSION=$(jq -r '.version' package.json)
API_VERSION=$([[ -n "$IS_TAGGED" ]] && echo "$PACKAGE_LOCK_VERSION" || echo "${PACKAGE_LOCK_VERSION}+${GIT_SHA}")
export API_VERSION
- name: Build
run: pnpm run build-and-pack
@@ -151,19 +167,44 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install node
- name: Install Node
uses: actions/setup-node@v4
with:
cache: "npm"
cache-dependency-path: |
unraid-ui/package-lock.json
node-version-file: ".nvmrc"
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 10
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Cache APT Packages
uses: awalsh128/cache-apt-pkgs-action@v1.4.3
with:
packages: bash procps python3 libvirt-dev jq zstd git build-essential
version: 1.0
- name: Install dependencies
run: npm install
run: |
cd ${{ github.workspace }}
pnpm install --frozen-lockfile --filter @unraid/ui
- name: Build
run: npm run build:wc
run: pnpm run build:wc
- name: Upload Artifact to Github
uses: actions/upload-artifact@v4
@@ -193,32 +234,49 @@ jobs:
echo VITE_CALLBACK_KEY=${{ vars.VITE_CALLBACK_KEY }} >> .env
cat .env
- name: Install node
- name: Install Node
uses: actions/setup-node@v4
with:
cache: "npm"
cache-dependency-path: |
web/package-lock.json
node-version-file: "web/.nvmrc"
node-version-file: ".nvmrc"
- name: Setup Just
uses: extractions/setup-just@v2
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 10
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: PNPM Install
run: |
cd ${{ github.workspace }}
pnpm install --frozen-lockfile --filter @unraid/web --filter @unraid/ui
- name: Build Unraid UI
run: just ../unraid-ui/setup
- name: Installing node deps
run: npm install
run: |
cd ${{ github.workspace }}/unraid-ui
pnpm run build
- name: Lint files
continue-on-error: true
run: npm run lint
run: pnpm run lint
- name: Test
run: npm run test:ci
run: pnpm run test:ci
- name: Build
run: npm run build
run: pnpm run build
- name: Upload build to Github artifacts
uses: actions/upload-artifact@v4
@@ -243,15 +301,37 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install node
- name: Install Node
uses: actions/setup-node@v4
with:
cache: "npm"
cache-dependency-path: |
plugin/package-lock.json
node-version-file: ".nvmrc"
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 10
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: npm ci
run: |
cd ${{ github.workspace }}
pnpm install --frozen-lockfile --filter @unraid/connect-plugin
- name: Download Unraid Web Components
uses: actions/download-artifact@v4
with:
@@ -275,7 +355,7 @@ jobs:
echo "TAG=${TAG}" >> $GITHUB_OUTPUT
fi
npm run build
pnpm run build
- name: Upload binary txz and plg to Github artifacts
uses: actions/upload-artifact@v4
with:

71
.github/workflows/test-libvirt.yml vendored Normal file
View File

@@ -0,0 +1,71 @@
name: Test Libvirt
on:
push:
branches:
- main
paths:
- "libvirt/**"
pull_request:
paths:
- "libvirt/**"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./libvirt
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Cache APT Packages
uses: awalsh128/cache-apt-pkgs-action@v1.4.3
with:
packages: libvirt-dev
version: 1.0
- name: Set Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('libvirt/package.json') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: pnpm install
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build
- name: test
run: pnpm run test

View File

@@ -1,8 +1,6 @@
{
"recommendations": [
"natizyskunk.sftp",
"davidanson.vscode-markdownlint",
"bmewburn.vscode-intelephense-client",
"foxundermoon.shell-format",
"timonwong.shellcheck",
"esbenp.prettier-vscode"

View File

@@ -1,2 +0,0 @@
node-linker=hoisted
shamefully-hoist=true

View File

@@ -1 +0,0 @@
v20

View File

@@ -28,7 +28,7 @@ RUN corepack enable && corepack prepare pnpm@8.15.4 --activate && npm i -g npm@l
COPY tsconfig.json .eslintrc.ts .prettierrc.cjs .npmrc .env.production .env.staging package.json pnpm-lock.yaml .npmrc ./
# Install deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
EXPOSE 3001

View File

@@ -1,5 +1,5 @@
[api]
version="3.11.0"
version="4.0.1"
extraOrigins="https://google.com,https://test.com"
[local]
sandbox="yes"

View File

@@ -1,5 +1,5 @@
[api]
version="3.11.0"
version="4.0.1"
extraOrigins="https://google.com,https://test.com"
[local]
sandbox="yes"

View File

@@ -2,6 +2,7 @@ x-common: &common
volumes:
- ./:/app
- pnpm-store:/pnpm/store
- ../libvirt:/libvirt
environment:
- IS_DOCKER=true
- GIT_SHA=${GIT_SHA:-unknown}

View File

@@ -10,7 +10,7 @@
"author": "Lime Technology, Inc. <unraid.net>",
"license": "UNLICENSED",
"engines": {
"pnpm": ">=8.15.4"
"pnpm": ">=8.0.0"
},
"scripts": {
"// Main application commands": "",
@@ -56,6 +56,7 @@
"@graphql-tools/schema": "^10.0.7",
"@graphql-tools/utils": "^10.5.5",
"@nestjs/apollo": "^12.2.1",
"@nestjs/common": "^10.4.7",
"@nestjs/core": "^10.4.7",
"@nestjs/graphql": "^12.2.1",
"@nestjs/passport": "^10.0.3",
@@ -63,9 +64,9 @@
"@nestjs/schedule": "^4.1.1",
"@nestjs/throttler": "^6.2.1",
"@reduxjs/toolkit": "^2.3.0",
"@reflet/cron": "^1.3.1",
"@runonflux/nat-upnp": "^1.0.2",
"@types/diff": "^7.0.1",
"@unraid/libvirt": "^1.0.5",
"accesscontrol": "^2.2.1",
"bycontract": "^2.0.11",
"bytes": "^3.1.2",
@@ -78,6 +79,7 @@
"command-exists": "^1.2.9",
"convert": "^5.5.1",
"cookie": "^1.0.2",
"cron": "3.2.1",
"cross-fetch": "^4.0.0",
"diff": "^7.0.0",
"docker-event-emitter": "^0.3.0",
@@ -104,7 +106,6 @@
"lodash-es": "^4.17.21",
"multi-ini": "^2.3.2",
"mustache": "^4.2.0",
"nest-access-control": "^3.1.0",
"nest-authz": "^2.11.0",
"nest-commander": "^3.15.0",
"nestjs-pino": "^4.1.0",
@@ -184,13 +185,11 @@
"vitest": "^3.0.5",
"zx": "^8.3.2"
},
"optionalDependencies": {
"@vmngr/libvirt": "github:unraid/libvirt"
},
"overrides": {
"eslint": {
"jiti": "2"
}
},
"packageManager": "pnpm@8.15.4+sha512.0bd3a9be9eb0e9a692676deec00a303ba218ba279d99241475616b398dbaeedd11146f92c2843458f557b1d127e09d4c171e105bdcd6b61002b39685a8016b9e"
}
"packageManager": "pnpm@8.15.4+sha512.0bd3a9be9eb0e9a692676deec00a303ba218ba279d99241475616b398dbaeedd11146f92c2843458f557b1d127e09d4c171e105bdcd6b61002b39685a8016b9e",
"private": true
}

11053
api/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -40,7 +40,7 @@ try {
console.log('Installing production dependencies...');
$.verbose = true;
await $`pnpm install --prod`;
await $`pnpm install --prod --ignore-workspace --node-linker hoisted`;
// chmod the cli
await $`chmod +x ./dist/cli.js`;

View File

@@ -19,7 +19,7 @@ const states = {
*/
export const getDomains = async () => {
try {
const { ConnectListAllDomainsFlags } = await import('@vmngr/libvirt');
const { ConnectListAllDomainsFlags } = await import('@unraid/libvirt');
const { UnraidHypervisor } = await import('@app/core/utils/vms/get-hypervisor');
const hypervisor = await UnraidHypervisor.getInstance().getHypervisor();

View File

@@ -1,7 +1,7 @@
import { constants } from 'fs';
import { access } from 'fs/promises';
import type { Hypervisor as HypervisorType } from '@vmngr/libvirt';
import { type Hypervisor as HypervisorType } from '@unraid/libvirt';
import { libvirtLogger } from '@app/core/log';
@@ -42,7 +42,7 @@ export class UnraidHypervisor {
this.hypervisor = null;
throw new Error('Libvirt is not running');
}
const { Hypervisor } = await import('@vmngr/libvirt');
const { Hypervisor } = await import('@unraid/libvirt');
this.hypervisor = new Hypervisor({ uri });
await this.hypervisor.connectOpen().catch((error: unknown) => {
libvirtLogger.error(

View File

@@ -1,4 +1,4 @@
import { Cron, Expression, Initializer } from '@reflet/cron';
import { CronJob } from 'cron';
import { KEEP_ALIVE_INTERVAL_MS, ONE_MINUTE_MS } from '@app/consts';
import { minigraphLogger, mothershipLogger, remoteAccessLogger } from '@app/core/log';
@@ -9,10 +9,15 @@ import { store } from '@app/store/index';
import { setRemoteAccessRunningType } from '@app/store/modules/dynamic-remote-access';
import { clearSubscription } from '@app/store/modules/remote-graphql';
export class PingTimeoutJobs extends Initializer<typeof PingTimeoutJobs> {
@Cron.PreventOverlap
@Cron(Expression.EVERY_MINUTE)
@Cron.Start
class PingTimeoutJobs {
private cronJob: CronJob;
private isRunning: boolean = false;
constructor() {
// Run every minute
this.cronJob = new CronJob('* * * * *', this.checkForPingTimeouts.bind(this));
}
async checkForPingTimeouts() {
const state = store.getState();
if (!isAPIStateDataFullyLoaded(state)) {
@@ -78,16 +83,34 @@ export class PingTimeoutJobs extends Initializer<typeof PingTimeoutJobs> {
store.dispatch(setRemoteAccessRunningType(DynamicRemoteAccessType.DISABLED));
}
}
start() {
if (!this.isRunning) {
this.cronJob.start();
this.isRunning = true;
}
}
stop() {
if (this.isRunning) {
this.cronJob.stop();
this.isRunning = false;
}
}
isJobRunning(): boolean {
return this.isRunning;
}
}
let pingTimeoutJobs: ReturnType<typeof PingTimeoutJobs.init<PingTimeoutJobs>> | null = null;
let pingTimeoutJobs: PingTimeoutJobs | null = null;
export const initPingTimeoutJobs = (): boolean => {
if (!pingTimeoutJobs) {
pingTimeoutJobs = PingTimeoutJobs.init();
pingTimeoutJobs = new PingTimeoutJobs();
}
pingTimeoutJobs.startAll();
return pingTimeoutJobs.get('checkForPingTimeouts').running ?? false;
pingTimeoutJobs.start();
return pingTimeoutJobs.isJobRunning();
};
export const stopPingTimeoutJobs = () => {
@@ -96,7 +119,6 @@ export const stopPingTimeoutJobs = () => {
minigraphLogger.warn('PingTimeoutJobs Handler not found.');
return;
}
pingTimeoutJobs.stopAll();
pingTimeoutJobs.clear();
pingTimeoutJobs.stop();
pingTimeoutJobs = null;
};

View File

@@ -1,6 +1,5 @@
import { Query, ResolveField, Resolver, Subscription } from '@nestjs/graphql';
import { UseRoles } from 'nest-access-control';
import { AuthActionVerb, AuthPossession, UsePermissions } from 'nest-authz';
import { baseboard, system } from 'systeminformation';

View File

@@ -1,31 +1,55 @@
import { Cron, Expression, Initializer } from '@reflet/cron';
import { CronJob } from 'cron';
import { upnpLogger } from '@app/core/log';
import { store } from '@app/store';
import { enableUpnp } from '@app/store/modules/upnp';
export class UPNPJobManager extends Initializer<typeof UPNPJobManager> {
@Cron.PreventOverlap
@Cron(Expression.EVERY_30_MINUTES)
async renewUpnpLeaseJob() {
upnpLogger.trace('Running UPNP Renewal Job');
await store.dispatch(enableUpnp());
class UPNPJobManager {
private renewalTask: CronJob | null = null;
constructor() {
this.renewalTask = new CronJob(
'*/30 * * * *',
async () => {
try {
upnpLogger.trace('Running UPNP Renewal Job');
await store.dispatch(enableUpnp());
} catch (error) {
upnpLogger.error('Error in UPNP renewal job:', error);
}
},
null, // onComplete
false, // start
'UTC' // timezone
);
}
start() {
this.renewalTask?.start();
return this.isRunning();
}
stop() {
this.renewalTask?.stop();
return this.isRunning();
}
isRunning(): boolean {
return this.renewalTask?.running ?? false;
}
}
let upnpJobs: UPNPJobManager | null = null;
export const initUpnpJobs = (): boolean => {
if (!upnpJobs) {
upnpJobs = UPNPJobManager.init();
upnpJobs = new UPNPJobManager();
}
upnpJobs.get('renewUpnpLeaseJob').start();
return upnpJobs.get('renewUpnpLeaseJob').running ?? false;
return upnpJobs.start();
};
export const stopUpnpJobs = (): boolean => {
upnpLogger.debug('Stopping UPNP Jobs');
upnpJobs?.get('renewUpnpLeaseJob').stop();
return upnpJobs?.get('renewUpnpLeaseJob').running ?? false;
return upnpJobs?.stop() ?? false;
};
let upnpJobs: ReturnType<typeof UPNPJobManager.init<UPNPJobManager>> | null = null;

34
package.json Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "unraid-monorepo",
"private": true,
"scripts": {
"build": "pnpm -r build",
"dev": "pnpm -r dev",
"test": "pnpm -r test",
"lint": "pnpm -r lint",
"lint:fix": "pnpm -r lint:fix",
"check": "manypkg check"
},
"pnpm": {
"peerDependencyRules": {
"allowAny": [
"vue"
]
},
"onlyBuiltDependencies": [
"@apollo/protobufjs",
"@nestjs/core",
"@parcel/watcher",
"@swc/core",
"@unraid/libvirt",
"cpu-features",
"esbuild",
"nestjs-pino",
"ssh2",
"vue-demi"
]
},
"dependencies": {
"@manypkg/cli": "^0.23.0"
}
}

View File

@@ -5,3 +5,4 @@ deploy/*
.github/*
.vscode/*
.DS_Store
node_modules

View File

@@ -16,9 +16,9 @@ RUN git config --global --add safe.directory /app
WORKDIR /app
COPY package.json package-lock.json ./
COPY package.json ./
RUN npm i
RUN npm install --include=dev
COPY . .

2481
plugin/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,6 @@
{
"name": "@unraid/connect-plugin",
"private": true,
"dependencies": {
"conventional-changelog": "^6.0.0",
"date-fns": "^4.1.0",
@@ -17,7 +19,7 @@
"build:validate": "npm run env:validate && npm run build",
"// Docker commands": "",
"docker:build": "docker build -t plugin-builder .",
"docker:run": "docker run --env-file .env -v $(pwd)/deploy:/app/deploy -v $(cd ../ && pwd)/.git:/app/.git -v $(pwd)/source:/app/source plugin-builder",
"docker:run": "docker run --env-file .env -v $(pwd)/:/app/ -v $(cd ../ && pwd)/.git:/app/.git -v $(pwd)/source:/app/source -v $(pwd)/scripts:/app/scripts plugin-builder",
"docker:build-and-run": "npm run docker:build && npm run docker:run",
"http-server": "http-server ./deploy/release/ -p 8080 --cors",
"// Environment management": "",

View File

@@ -203,6 +203,9 @@ echo "**********************************\n";
echo "🧹 CLEANING UP - may take a minute\n";
echo "**********************************\n";
# Clean up node_modules before package removal
rm -rf /usr/local/unraid-api/node_modules
if (file_exists("/boot/.git")) {
if (file_exists("/etc/rc.d/rc.flash_backup")) {
# stop flash backup service

View File

@@ -0,0 +1,10 @@
#!/bin/sh
# This runs both during package removal and installation
# $1 will be "remove" during package removal
# $1 will be "install" during package installation
if [ "$1" = "remove" ]; then
# Clean up node_modules before package removal
rm -rf /usr/local/unraid-api/node_modules
fi

23340
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

6
pnpm-workspace.yaml Normal file
View File

@@ -0,0 +1,6 @@
packages:
- "./api"
- "./libvirt"
- "./plugin"
- "./unraid-ui"
- "./web"

View File

@@ -1,2 +0,0 @@
shamefully-hoist=true
strict-peer-dependencies=false

View File

@@ -5,15 +5,15 @@ list-commands:
# Prepares the repo for development
setup:
npm install
npm run build
pnpm install
pnpm run build
clean:
npm run clean
pnpm run clean
rm -rf node_modules
build-wc:
REM_PLUGIN=true npx vite build -c vite.web-component.ts --mode production
REM_PLUGIN=true vite build -c vite.web-component.ts --mode production
deploy server_name:
rsync -avz -e ssh ./dist/ root@{{server_name}}:/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components

View File

@@ -14,7 +14,7 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"build:wc": "REM_PLUGIN=true npx vite build -c vite.web-component.ts --mode production",
"build:wc": "REM_PLUGIN=true vite build -c vite.web-component.ts --mode production",
"preview": "vite preview",
"test": "vitest",
"test:ui": "vitest --ui",

View File

@@ -1,2 +0,0 @@
shamefully-hoist=true
strict-peer-dependencies=false

View File

@@ -1 +0,0 @@
20

View File

@@ -74,16 +74,16 @@ const handleKeydown = (event: KeyboardEvent) => {
if (sequenceIndex === keySequence.length) {
activationCodeStore.setActivationModalHidden(true);
window.location.href = '/Tools/Registration';
window.location.href = '/Tools/Registration';
}
};
onMounted(() => {
window.addEventListener('keydown', handleKeydown);
window?.addEventListener('keydown', handleKeydown);
});
onUnmounted(() => {
window.removeEventListener('keydown', handleKeydown);
window?.removeEventListener('keydown', handleKeydown);
});
</script>

View File

@@ -5,9 +5,9 @@ export const preventClose = (e: { preventDefault: () => void; returnValue: strin
};
export const addPreventClose = () => {
window.addEventListener('beforeunload', preventClose);
window?.addEventListener('beforeunload', preventClose);
};
export const removePreventClose = () => {
window.removeEventListener('beforeunload', preventClose);
window?.removeEventListener('beforeunload', preventClose);
};

View File

@@ -1,20 +1,5 @@
import { readFileSync } from 'fs';
import { parse } from 'dotenv';
import removeConsole from 'vite-plugin-remove-console';
const envConfig = parse(readFileSync('.env'));
console.log('\n');
console.log('==============================');
console.log('========= ENV VALUES =========');
console.log('==============================');
for (const k in envConfig) {
process.env[k] = envConfig[k];
console.log(`[${k}]`, process.env[k]);
}
console.log('==============================');
console.log('\n');
/**
* Used to avoid redeclaring variables in the webgui codebase.
* @see alt solution https://github.com/terser/terser/issues/1001, https://github.com/terser/terser/pull/1038
@@ -73,11 +58,6 @@ export default defineNuxtConfig({
// typescript: {
// typeCheck: true
// },
shadcn: {
prefix: '',
componentDir: './components/shadcn',
},
vite: {
plugins: [
// Only remove non-critical console methods when VITE_ALLOW_CONSOLE_LOGS is false
@@ -101,7 +81,10 @@ export default defineNuxtConfig({
},
},
},
shadcn: {
prefix: '',
componentDir: './components/shadcn',
},
customElements: {
entries: [
{

View File

@@ -1,5 +1,5 @@
{
"name": "connect-components",
"name": "@unraid/web",
"version": "3.10.0",
"private": true,
"scripts": {
@@ -8,12 +8,12 @@
"lint:fix": "eslint . --fix",
"type-check": "nuxi typecheck",
"prebuild:dev": "./scripts/prebuild-webgui-set-env.sh .env.staging",
"build:dev": "nuxt build && npm run manifest-ts && npm run deploy-to-unraid:dev",
"build:dev": "nuxt build && pnpm run manifest-ts && pnpm run deploy-to-unraid:dev",
"postbuild:dev": "./scripts/postbuild-webgui-restore-env.sh",
"prebuild:webgui": "./scripts/prebuild-webgui-set-env.sh",
"build:webgui": "npm run type-check && nuxt build && npm run manifest-ts && npm run copy-to-webgui-repo",
"build:webgui": "pnpm run type-check && nuxt build && pnpm run manifest-ts && pnpm run copy-to-webgui-repo",
"postbuild:webgui": "./scripts/postbuild-webgui-restore-env.sh",
"build": "NODE_ENV=production npm run type-check && nuxt build && npm run manifest-ts",
"build": "NODE_ENV=production nuxt build && pnpm run manifest-ts",
"deploy-to-unraid:dev": "./scripts/deploy-dev.sh",
"copy-to-webgui-repo": "./scripts/copy-to-webgui-repo.sh",
"manifest-ts": "node ./scripts/add-timestamp-webcomponent-manifest.js",
@@ -66,7 +66,7 @@
"@heroicons/vue": "^2.2.0",
"@nuxtjs/color-mode": "^3.5.2",
"@pinia/nuxt": "^0.9.0",
"@unraid/ui": "file:../unraid-ui",
"@unraid/ui": "link:../unraid-ui",
"@vue/apollo-composable": "^4.2.1",
"@vueuse/components": "^12.0.0",
"@vueuse/integrations": "^12.0.0",