-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildenv.cmd
More file actions
128 lines (88 loc) · 3.2 KB
/
buildenv.cmd
File metadata and controls
128 lines (88 loc) · 3.2 KB
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
125
126
127
128
@echo off
REM Configures the environment variables required to build NEONDOCS projects.
REM
REM buildenv [ <source folder> ]
REM
REM Note that <source folder> defaults to the folder holding this
REM batch file.
REM
REM This must be [RUN AS ADMINISTRATOR].
echo ============================================
echo * NEONDOCS Build Environment Configurator *
echo ============================================
REM Default ND_ROOT to the folder holding this batch file after stripping
REM off the trailing backslash.
set ND_ROOT=%~dp0
set ND_ROOT=%ND_ROOT:~0,-2%
if not [%1]==[] set ND_ROOT=%1
if exist %ND_ROOT%\.neon-doc goto goodPath
echo The [%ND_ROOT%\.neon-doc] file does not exist. Please pass the path
echo to the [neon-docs] repo folder.
goto done
:goodPath
echo.
echo Configuring...
echo.
REM Set NF_REPOS to the parent directory holding the NEONFORGE repositories.
pushd "%NF_ROOT%\.."
set NF_REPOS=%cd%
popd
REM Set other environment variables.
set ND_SITE_ROOT=%NF_REPOS%\nforgeio-docs
set ND_NODEJS_VERSION=20.11.1
REM Persist the environment variables.
setx ND_ROOT "%ND_ROOT%" /M > nul
setx ND_SITE_ROOT "%NF_REPOS%\nforgeio-docs.github.io" /M > nul
setx ND_NODEJS_VERSION "%ND_NODEJS_VERSION%" /M > nul
REM Temporarily add [%NF_ROOT%\neonSDK\ToolBin] to the PATH so
REM we'll be able to use things like [pathtool].
REM
REM NOTE: This assumes that NeonSDK is configured first.
set PATH=%PATH%;%NF_ROOT%\neonSDK\ToolBin
REM Check whether NVM (Node Version Manager) is installed and install
REM if it's not present.
where NVM > nul 2> nul
if NOT ERRORLEVEL 0 (
echo "Installing NVM Node Version Manager"
echo.
echo "*** Answer YES to manage any installed Node.js versions."
"%ND_ROOT%\toolbin\nvm-setup.exe" /silent
echo.
REM The NVM environment variables aren't set locally after
REM setup, so we'll do this explicitly here.
set NVM_HOME=%APPDATA%\nvm
set NVM_SYMLINK=%ProgramFiles%\nodejs
pathtool -dedup -system -add "%NVM_HOME%"
pathtool -dedup -system -add "%ProgramFiles%\nodejs"
pathtool -dedup -system -add "%NVM_SYMLINK%"
)
REM Configure the PATH.
pathtool -dedup -system -add "%ND_ROOT%\toolbin"
REM Install the required version of [Node.js] if
REM it's not already installed.
where node > nul 2> nul
if NOT ERRORLEVEL 0 goto installNode
node --version | grep --quiet --regexp '%ND_NODEJS_VERSION%\s'
if ERRORLEVEL 0 goto nodeInstalled
:installNode
nvm install %ND_NODEJS_VERSION%
nvm use %ND_NODEJS_VERSION%
:nodeInstalled
REM Install Yarn (essentially a NOP if already installed)
cd %ND_ROOT%
npm install --global yarn
REM Install the Docusaurus tools (essentially a NOP if already installed)
cd %ND_ROOT%
npm install
REM Update latest browser information.
echo y | npx update-browserslist-db@latest
REM Build the documentation to: $/build
REM
REM NOTE: Publication is performed using the NEONCLOUD neon-kube tool.
npm run build
:done
echo.
echo ============================================================================================
echo * Be sure to close and reopen Visual Studio and any command windows to pick up the changes *
echo ============================================================================================
pause