Extract complex npm scripts to separate files

This commit is contained in:
2025-11-03 11:43:15 +03:00
Unverified
parent 852ab15bd8
commit 6d970dbd61
4 changed files with 26 additions and 24 deletions
+1 -20
View File
@@ -5,28 +5,9 @@
* @version 1.0.0 * @version 1.0.0
*/ */
/**
* Base domain name for all requests in production
* @constant
*/
export const BASE_DOMAIN = import.meta.env.VITE_API_BASE_URL ?? "fromchat.ru";
/** export const BASE_DOMAIN = import.meta.env.VITE_API_BASE_URL || "fromchat.ru";
* Base API endpoint for all backend requests
* @constant
*/
export const API_BASE_URL = `${location.host ? "" : `https://${BASE_DOMAIN}`}/api`; export const API_BASE_URL = `${location.host ? "" : `https://${BASE_DOMAIN}`}/api`;
/**
* Full API URL including hostname and port for WebSocket connections
* @constant
*/
export const API_WS_BASE_URL = `${location.host || BASE_DOMAIN}/api`; export const API_WS_BASE_URL = `${location.host || BASE_DOMAIN}/api`;
/**
* Application name displayed in UI and document title
* @constant
*/
export const PRODUCT_NAME = "FromChat"; export const PRODUCT_NAME = "FromChat";
export const MINIMUM_WIDTH = 800; export const MINIMUM_WIDTH = 800;
+4 -4
View File
@@ -8,13 +8,13 @@
"license": "GPL-3.0", "license": "GPL-3.0",
"authors": "denis0001-dev", "authors": "denis0001-dev",
"scripts": { "scripts": {
"backend:run": "cd backend && dotenv -e ../deployment/.env -- ../.venv/bin/uvicorn main:app --host 127.0.0.1 --port 8300 --reload --reload-exclude './alembic' --reload-exclude './alembic/*' --reload-exclude './alembic/versions/*' --access-log", "backend:run": "bash ./scripts/backend:run.sh",
"backend:dependencies": "python3 -m venv .venv && ./.venv/bin/pip3 install -r backend/requirements.txt", "backend:dependencies": "python3 -m venv .venv && ./.venv/bin/pip3 install -r backend/requirements.txt",
"backend:reinstall": "rm -rf .venv && npm run backend:dependencies", "backend:reinstall": "rm -rf .venv && npm run backend:dependencies",
"backend:clean": "rm -rf backend/data", "backend:clean": "rm -rf backend/data",
"frontend:dev": "vite frontend", "frontend:dev": "dotenv -e deployment/.env -- vite frontend",
"frontend:typecheck": "tsc --project frontend", "frontend:typecheck": "tsc --project frontend",
"frontend:build": "npm run frontend:typecheck && vite build frontend", "frontend:build": "npm run frontend:typecheck && dotenv -e deployment/.env -- vite build frontend",
"frontend:electron:dev": "VITE_ELECTRON=true npm run frontend:dev", "frontend:electron:dev": "VITE_ELECTRON=true npm run frontend:dev",
"frontend:electron:build": "VITE_ELECTRON=true npm run frontend:build && rm -rf out && electron-forge make --force --arch arm64,x64", "frontend:electron:build": "VITE_ELECTRON=true npm run frontend:build && rm -rf out && electron-forge make --force --arch arm64,x64",
"frontend:preview": "vite preview frontend", "frontend:preview": "vite preview frontend",
@@ -29,7 +29,7 @@
"clean": "npm run backend:clean && npm run frontend:clean && npm run preview:clean", "clean": "npm run backend:clean && npm run frontend:clean && npm run preview:clean",
"install": "npm run backend:dependencies && npm run generate:env", "install": "npm run backend:dependencies && npm run generate:env",
"prepare": "husky", "prepare": "husky",
"generate:env": "echo \"JWT_SECRET=\\\"$(openssl rand -base64 32)\\\"\" > deployment/.env && ./.venv/bin/python3 backend/generate_vapid_keys.py 1>>deployment/.env && echo \"TURN_USERNAME=\\\"set-your-username\\\"\\nTURN_SECRET=\\\"set-your-secret\\\"\" >> deployment/.env" "generate:env": "bash ./scripts/generate:env.sh"
}, },
"files": [ "files": [
"frontend/build/electron" "frontend/build/electron"
+10
View File
@@ -0,0 +1,10 @@
cd backend
dotenv -e ../deployment/.env -- \
../.venv/bin/uvicorn main:app \
--host 127.0.0.1 \
--port 8300 \
--reload \
--reload-exclude './alembic' \
--reload-exclude './alembic/*' \
--reload-exclude './alembic/versions/*' \
--access-log
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
echo > deployment/.env
./.venv/bin/python3 backend/generate_vapid_keys.py >> deployment/.env
cat >> deployment/.env <<EOF
JWT_SECRET="$(openssl rand -base64 32)"
TURN_USERNAME=<set>
TURN_SECRET=<set>
EOF