Commit Graph

613 Commits

Author SHA1 Message Date
CanbiZ
644222e958 Fix db.js - require index.js explicitly 2025-11-28 14:08:39 +01:00
CanbiZ
31a5fd97d4 Fix db.js - use absolute path to .prisma/client 2025-11-28 14:07:54 +01:00
CanbiZ
b54fbf15f6 Fix db.js - use createRequire to load .prisma/client CJS module 2025-11-28 14:07:22 +01:00
CanbiZ
a787e60e7c Fix db.js - import from .prisma/client runtime location 2025-11-28 14:06:35 +01:00
CanbiZ
1e250306dc Fix db.js - use CommonJS-style import for @prisma/client 2025-11-28 14:05:37 +01:00
CanbiZ
d64a296ebe Fix db.js - import PrismaClient from @prisma/client for Node ESM compatibility 2025-11-28 14:04:58 +01:00
CanbiZ
691b27c924 Fix db.js import - add .js extension for Prisma client 2025-11-28 14:04:05 +01:00
CanbiZ
dbc591aa63 Add JS wrappers for ESM compatibility (repositoryService, githubJsonService) and fix .js import extensions 2025-11-28 14:01:18 +01:00
CanbiZ
5ea6828f8c Fix ESM import in database-prisma.js - add .js extension 2025-11-28 13:58:05 +01:00
CanbiZ
3dabacd055 Revert "Auto-initialize default repositories on first API call"
This reverts commit aebc8a6171.
2025-11-28 13:56:29 +01:00
CanbiZ
e8ee829577 Add explicit type annotations and return types
This commit adds TypeScript type definitions for database entities and updates all methods in DatabaseServicePrisma to use explicit type annotations and return types. This improves type safety, code clarity, and maintainability by ensuring consistent return values and better integration with Prisma-generated types.
2025-11-28 13:50:44 +01:00
CanbiZ
aebc8a6171 Auto-initialize default repositories on first API call 2025-11-28 13:41:21 +01:00
CanbiZ
c5db169441 Fix login race condition: don't call checkAuth after successful login 2025-11-28 13:34:51 +01:00
CanbiZ
bef5bef875 Remove .js extensions from dynamic imports 2025-11-28 13:32:51 +01:00
CanbiZ
3a4f86942f Remove circular import wrapper files (githubJsonService.js, localScripts.js) 2025-11-28 13:30:17 +01:00
CanbiZ
94eb772467 Fix cross-origin cookie issues: use lax SameSite and add CORS headers 2025-11-28 13:28:53 +01:00
CanbiZ
3a2a1b2cd6 Add datasource property to Prisma config for migrate/db push support 2025-11-28 13:25:33 +01:00
CanbiZ
69c10b05ac Ensure recursive creation of ssh-keys directory
Updated the initialization logic to use the 'recursive' option when creating the data/ssh-keys directory, ensuring parent directories are created if they do not exist.
2025-11-28 13:23:31 +01:00
Michel Roegl-Brunner
7833d5d408 Fix type errors 2025-11-28 13:21:37 +01:00
CanbiZ
e0baa79d6b Remove file extensions from import statements
Updated import statements across several server files to omit explicit file extensions. This improves compatibility with module resolution and aligns with common import practices.
2025-11-28 13:21:03 +01:00
CanbiZ
737c9c94f3 Fix repositoryService import extension in autoSyncInit.js 2025-11-28 13:19:53 +01:00
CanbiZ
c57586acae Fix Prisma import path in db.js and update allowedDevOrigins format 2025-11-28 13:18:29 +01:00
CanbiZ
74030b5806 Refactor lint comments and minor code improvements
Removed or updated unnecessary eslint-disable comments across several server and service files to improve code clarity. Fixed import paths and added TypeScript ignore comments where needed for compatibility. Minor formatting adjustments were made for readability.
2025-11-28 13:13:01 +01:00
CanbiZ
cc276ddff3 Improve script downloader and auto-sync services
Added detailed JSDoc comments and type annotations to ScriptDownloaderService for better maintainability and clarity. Refactored initialization logic to always set scriptsDirectory and repoUrl. Enhanced autoSyncService to specify cron job timezone and options. Updated PrismaClient import path for compatibility with generated client structure.
2025-11-28 13:10:20 +01:00
CanbiZ
375c551a3a Update Prisma to v7 and add better-sqlite3 adapter
Upgraded Prisma and related dependencies to version 7.0.1 and added @prisma/adapter-better-sqlite3 and better-sqlite3 to support the new adapter. This enables improved SQLite integration and compatibility with the latest Prisma features.
2025-11-28 13:06:40 +01:00
CanbiZ
e3e4556f83 Add type annotations and improve script services
Enhanced type safety and documentation in several files, including adding explicit type annotations for script objects and function parameters. Improved error handling and code clarity in scriptDownloader.js, and updated autoSyncService.js to remove unnecessary cron job options. Refactored prisma.config.ts for schema configuration and updated server.js to support backup storage and improve parameter defaults.
2025-11-28 13:06:16 +01:00
CanbiZ
7fa132e09c Update Prisma adapter and type annotations
Replaces usage of PrismaBetterSQLite3 with PrismaBetterSqlite3 for consistency and correct casing. Updates type annotations in several components and API router for improved type safety. Also adjusts PrismaClient import paths in db files.
2025-11-28 13:02:34 +01:00
CanbiZ
1a1dbe6975 upgrade betterauthsql 2025-11-28 12:57:56 +01:00
CanbiZ
1a5881c935 Migration to Prisma 7 2025-11-28 12:55:32 +01:00
CanbiZ
2d7176914e Enable JS type checking in tsconfig.json
Set `checkJs` to true to allow type checking for JavaScript files. Updated include/exclude patterns to support JS and CJS files in the project.
2025-11-28 12:51:07 +01:00
CanbiZ
987ac3da1b Fix: Remove .js extensions from TypeScript imports for Next.js bundler 2025-11-28 12:48:10 +01:00
CanbiZ
03e31d66a7 Refactor type usage and improve data normalization
Updated several components to use explicit TypeScript types for better type safety. Normalized appriseUrls to always be an array in auto-sync settings API. Improved handling of optional server_id in BackupsTab and adjusted IP detection logic in InstalledScriptsTab. Removed unnecessary eslint-disable comments and improved code clarity in various places.
2025-11-28 12:47:09 +01:00
CanbiZ
7547dff67d Fix type annotations and module imports
Added explicit type annotations to array mapping functions for better type safety. Updated incorrect TypeScript import extensions from .ts to .js for compatibility. Ensured default values for optional parameters and improved code clarity in API routers.
2025-11-28 12:29:15 +01:00
CanbiZ
1945b14694 Update ESLint config to use FlatCompat and expand ignores
Switched to using FlatCompat for ESLint configuration and extended the ignore list to include 'next-env.d.ts', 'postcss.config.js', and 'prettier.config.js'. This improves compatibility and prevents linting of config and environment files.
2025-11-28 12:23:47 +01:00
CanbiZ
ec23600861 Switch ESLint config to eslint-config-next/core-web-vitals
Replaces @eslint/eslintrc and FlatCompat with eslint-config-next/core-web-vitals for ESLint configuration. Updates linting scripts in package.json to use eslint directly instead of next lint. Removes @eslint/eslintrc from devDependencies.
2025-11-28 12:20:53 +01:00
CanbiZ
41a9c0ae11 Switch to ESLint CLI (Deprecation of ESLint)
Added and updated eslint-disable comments in repositoryService, restoreService, and storageService to cover additional TypeScript rules. Simplified error handling by removing unused variables and catch parameters, and removed unused imports and variables in restoreService for cleaner code.
2025-11-28 12:19:47 +01:00
CanbiZ
c266c4cb3c Refactor InstalledScriptsTab for code style consistency
Updated InstalledScriptsTab.tsx to use double quotes and consistent formatting throughout the file. Improved type annotations, code readability, and standardized state initialization and mutation usage. No functional changes were made; this is a style and maintainability refactor.
2025-11-28 12:16:18 +01:00
CanbiZ
b5bce88398 Refactor InstalledScriptsTab for code style consistency
Standardizes quote usage, formatting, and code style in InstalledScriptsTab.tsx. Improves readability and maintains consistent conventions across the file without changing logic or functionality.
2025-11-28 12:15:27 +01:00
CanbiZ
48cf86a449 Refactor nullish checks and add type safety
Replaces many uses of logical OR (||) with nullish coalescing (??) for more accurate handling of undefined/null values. Adds explicit type annotations and interfaces to improve type safety, especially in API routes and server-side code. Updates SSH connection test handling and config parsing in installedScripts router for better reliability. Minor fixes to deduplication logic, cookie handling, and error reporting.
2025-11-28 12:10:15 +01:00
CanbiZ
d40aeb6c82 Refactor scripts grid and filter handling for robustness
Improves type safety and normalization in filter, repository, and script status handling across multiple components. Refactors ScriptsGrid for better readability, deduplication, and error messaging, and updates UI markup for consistency. Also adds explicit types for auto-sync settings and ensures string conversion for credential fields.
2025-11-28 11:58:38 +01:00
CanbiZ
9c759ba99b fix: ESLint/TypeScript fixes - nullish coalescing, regexp-exec, optional-chain, unescaped-entities, unused-vars, type-safety 2025-11-28 11:53:04 +01:00
root
f467b9ad7b fix vulnerabilities 2025-11-28 11:49:39 +01:00
Michel Roegl-Brunner
7fe2a8b453 Merge pull request #353 from community-scripts/fix/vm_detection
Add VM status check and UI improvements
2025-11-28 11:46:39 +01:00
Michel Roegl-Brunner
5274737ab8 Add VM status check and UI improvements
- Add VM status checking using qm status command
- Hide update button for VMs (only show for LXC containers)
- Hide shell button for VMs (only show for LXC containers)
- Hide LXC Settings option for VMs
- Display VM/LXC indicator badges in table before script names
- Update statistics cards to differentiate between LXC and VMs
- Update container control to support both pct (LXC) and qm (VM) commands
- Improve status parsing to handle both container types
2025-11-28 11:44:58 +01:00
CanbiZ
40805f39f7 Update dependencies and adjust TypeScript JSX setting
Upgraded multiple dependencies and devDependencies in package.json to their latest versions for improved stability and features. Changed the TypeScript 'jsx' compiler option from 'react-jsx' to 'preserve' in tsconfig.json to better align with project requirements.
2025-11-28 11:44:26 +01:00
Michel Roegl-Brunner
f9af7536d0 Update Confirmation modal 2025-11-28 11:27:12 +01:00
Michel Roegl-Brunner
0d39a9bbd0 Update update.sh to inlcude node update 2025-11-26 11:33:26 +01:00
Michel Roegl-Brunner
66f8a84260 Various small fixes (#349)
* Fix script viewer to support vm/ and tools/ scripts

- Update ScriptDetailModal to extract scriptName from any path (ct/, vm/, tools/)
- Refactor TextViewer to use actual script paths from install_methods
- Remove hardcoded path assumptions and use dynamic script paths
- Only show Install Script tab for ct/ scripts that have install scripts
- Rename CT Script tab to Script for better clarity

* Fix downloaded scripts count to include vm/ and tools/ scripts

- Update matching logic to use same robust approach as DownloadedScriptsTab
- Add normalized slug matching to handle filename-based slugs vs JSON slugs
- Add multiple fallback matching strategies for better script detection
- Fixes issue where scripts in vm/ and tools/ directories weren't being counted

* Filter categories to only show those with scripts

- Add filter to exclude categories with count 0 from category sidebar
- Only categories with at least one script will be displayed
- Reduces UI clutter by hiding empty categories

* Fix intermittent page reloads from VersionDisplay reconnect logic

- Add guards to prevent reload when not updating
- Use refs to track isUpdating and isNetworkError state in interval callbacks
- Add hasReloadedRef flag to prevent multiple reloads
- Clear reconnect interval when update completes or component unmounts
- Only start reconnect attempts when actually updating
- Prevents false positive reloads when server responds normally

* Fix Next.js HMR WebSocket and static asset handling

- Add WebSocket upgrade detection to only intercept /ws/script-execution
- Pass all other WebSocket upgrades (including HMR) to Next.js handler
- Ensure _next routes and static assets are properly handled by Next.js
- Fixes 400 errors for Next.js HMR WebSocket connections
- Fixes 403 errors for static assets by ensuring proper routing

* Fix WebSocket upgrade handling to properly route Next.js HMR

- Create WebSocketServer with noServer: true to avoid auto-attaching
- Manually handle upgrade events to route /ws/script-execution to our WebSocketServer
- Route all other WebSocket upgrades (including Next.js HMR) to Next.js handler
- This ensures Next.js HMR WebSocket connections are properly handled
- Fixes 400 errors for /_next/webpack-hmr WebSocket connections

* Revert WebSocket handling to simpler approach

- Go back to attaching WebSocketServer directly with path option
- Remove manual upgrade event handling that was causing errors
- The path option should filter to only /ws/script-execution
- Next.js should handle its own HMR WebSocket upgrades naturally

* Fix WebSocket upgrade handling to preserve Next.js HMR handlers

- Save existing upgrade listeners before adding our own
- Call existing listeners for non-matching paths to allow Next.js HMR
- Only handle /ws/script-execution ourselves
- This ensures Next.js can handle its own WebSocket upgrades for HMR

* Fix random page reloads during normal app usage

- Memoize startReconnectAttempts with useCallback to prevent recreation on every render
- Fix useEffect dependency arrays to include memoized function
- Add stricter guards checking refs before starting reconnect attempts
- Ensure reconnect logic only runs when actually updating (not during normal usage)
- Add early return in fallback useEffect to prevent false triggers
- Add ref guards in ResyncButton to prevent multiple simultaneous sync operations
- Only reload after sync if it was user-initiated

* Fix critical bug: prevent reloads from stale updateLogsData.isComplete

- Add isUpdating guard before processing updateLogsData.isComplete
- Reset shouldSubscribe when update completes or fails
- Prevent stale isComplete data from triggering reloads during normal usage

* Add update confirmation modal with changelog display

- Add UpdateConfirmationModal component that shows changelog before update
- Modify getVersionStatus to include release body (changelog) in response
- Update VersionDisplay to show confirmation modal instead of starting update directly
- Users must review changelog and click 'Proceed with Update' to start update
- Ensures users see potential breaking changes before updating
2025-11-26 10:21:14 +01:00
Michel Roegl-Brunner
2a9921a4e1 Merge pull request #348 from community-scripts/fix/update_script
fix: Detect script changes from remote repository to allow Script updates
2025-11-26 08:43:27 +01:00
Michel Roegl-Brunner
50f657ba00 Update Node.js version to 24.x in workflow 2025-11-26 08:33:50 +01:00