File size: 3,404 Bytes
c7d34c1
 
 
 
f250aec
c7d34c1
 
 
f250aec
c7d34c1
 
 
 
 
 
 
 
 
 
 
 
 
704e84f
c7d34c1
 
 
 
 
 
96bdf6c
c7d34c1
 
 
 
704e84f
c7d34c1
 
 
 
 
 
 
704e84f
c7d34c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
704e84f
 
 
c7d34c1
704e84f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c7d34c1
 
 
 
 
 
 
704e84f
 
 
 
 
 
 
 
c7d34c1
704e84f
c7d34c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
@echo off
setlocal

cd /d "%~dp0"
title Visual Journal Launcher

echo.
echo ========================================
echo Visual Journal Launcher
echo ========================================
echo.

if not exist "package.json" (
    echo [ERROR] package.json was not found. Please keep this file in the project root.
    echo.
    pause
    exit /b 1
)

where node >nul 2>nul
if errorlevel 1 (
    echo [ERROR] Node.js was not found.
    echo Please install Node.js 22.15.0 or later: https://nodejs.org/
    echo Then run this file again.
    echo.
    pause
    exit /b 1
)

node -e "import('./scripts/node-version.mjs').then(function(module){process.exit(module.isSupportedNodeVersion()?0:1)})"
if errorlevel 1 (
    echo [ERROR] Node.js version is too old.
    echo Current version:
    node -v
    echo Required: Node.js 22.15.0 or later. Download: https://nodejs.org/
    echo.
    pause
    exit /b 1
)

where npm >nul 2>nul
if errorlevel 1 (
    echo [ERROR] npm was not found. Please reinstall Node.js 22.15.0 or later.
    echo.
    pause
    exit /b 1
)

node -e "const net=require('net'); const s=net.createServer(); s.once('error',()=>process.exit(1)); s.once('listening',()=>s.close(()=>process.exit(0))); s.listen(4783)" >nul 2>nul
if errorlevel 1 (
    echo [ERROR] Port 4783 is already in use. Please stop the existing service and run this file again.
    echo.
    pause
    exit /b 1
)

if not exist ".env.local" (
    if exist ".env.example" (
        copy ".env.example" ".env.local" >nul
        echo [INFO] Created .env.local from .env.example.
        echo [INFO] You can edit .env.local or use API Settings in the browser.
        echo.
    ) else (
        echo [WARN] .env.example was not found. Skipping env file setup.
        echo.
    )
) else (
    echo [INFO] .env.local found.
)

node scripts\dependency-installation.mjs
if errorlevel 1 (
    echo [INFO] Dependencies are missing or incomplete. Installing from package-lock.json. This may take a few minutes.
    echo.
    call npm run install-scripts:check
    if errorlevel 1 (
        echo.
        echo [ERROR] Dependency install script policy validation failed.
        echo.
        pause
        exit /b 1
    )
    node scripts\npm-install-policy.mjs
    if errorlevel 1 (
        echo.
        echo [ERROR] Current npm does not support --strict-allow-scripts. Upgrade npm before installing dependencies.
        echo.
        pause
        exit /b 1
    )
    call npm ci --strict-allow-scripts
    if errorlevel 1 (
        echo.
        echo [ERROR] Dependency installation failed. Please check the network and run again.
        echo.
        pause
        exit /b 1
    )
    call npm run dependencies:check
    if errorlevel 1 (
        echo.
        echo [ERROR] Dependency installation completed with an incomplete package tree. Please run the install command again.
        echo.
        pause
        exit /b 1
    )
) else (
    echo [INFO] Dependencies match package-lock.json. Skipping installation.
)

echo.
echo [INFO] Starting local server. Keep this window open.
echo [INFO] Browser URL: http://localhost:4783
echo [INFO] If the browser does not open automatically, copy the URL above.
echo.

start "" /b powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Sleep -Seconds 5; Start-Process 'http://localhost:4783'"
set PORT=4783
call npm run dev

echo.
echo [INFO] Server stopped.
pause