Skip to content

Commit

Permalink
Merge tweak(ext/system-resources): improve artifact-based system reso…
Browse files Browse the repository at this point in the history
…urces handling (mr-186)

 - 1ec451a tweak(ext/system-resources): improve artifact-based system resources handling
  • Loading branch information
thorium-cfx committed Feb 12, 2024
2 parents 40fb043 + 1ec451a commit 68751bf
Show file tree
Hide file tree
Showing 5 changed files with 348 additions and 16 deletions.
27 changes: 26 additions & 1 deletion ext/system-resources/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# `system-resources`

Build scripts for bundled system resources.
Build scripts for bundled system resources.

## Index of resources

1. Chat - basic chat functionality
- Source-code-based
2. Monitor - server manager, txAdmin
- Artifact-based
- Source code: https://github.com/tabarra/txAdmin
- Using ready-built artifacts from the source code repository

## Updating artifact-based resources

Update artifact URL, version and SHA256 hash using this command:

```
$ node manager.js update --name=%RESOURCE_NAME% --url=%RESOURCE_ARTIFACT_URL% --version=%RESOURCE_VERSION%
```

## Adding artifact-based resource

```
$ node manager.js add --name=%RESOURCE_NAME% --url=%RESOURCE_ARTIFACT_URL% --version=%RESOURCE_VERSION%
```

> Requires adding extra build steps to `build.cmd` and `build.sh` scripts.
42 changes: 30 additions & 12 deletions ext/system-resources/build.cmd
Original file line number Diff line number Diff line change
@@ -1,58 +1,76 @@
@echo off

where /q node

if errorlevel 1 (
exit /B 1
goto :error
)

if "%1" == "chat" goto chat
if "%1" == "chat" (
goto :chat
)

set SRRoot=%~dp0\data
pushd %~dp0


:: txAdmin
set MonitorArtifactURL="https://github.com/tabarra/txAdmin/releases/download/v7.0.0/monitor.zip"
echo Adding monitor

set MonitorPath=%SRRoot%\monitor
set MonitorArtifactPath=%SRRoot%\monitor.zip

rmdir /s /q %MonitorPath%
mkdir %MonitorPath%

curl -Lo %MonitorArtifactPath% %MonitorArtifactURL%
tar -C %MonitorPath%\ -xf %MonitorArtifactPath%
node manager.js download --name=monitor --file=%MonitorArtifactPath% || goto :error

tar -C %MonitorPath%\ -xf %MonitorArtifactPath% || goto :error
del %MonitorArtifactPath%

echo Done adding monitor
:: /txAdmin


:: chat
:chat
echo Adding chat

pushd resources\chat
rmdir /s /q dist

node %~dp0\..\native-doc-gen\yarn_cli.js
node %~dp0\..\native-doc-gen\yarn_cli.js || goto :error

set NODE_OPTIONS=""
FOR /F %%g IN ('node -v') do (set NODE_VERSION_STRING=%%g)
set /a NODE_VERSION="%NODE_VERSION_STRING:~1,2%"
IF %NODE_VERSION% GEQ 18 (set NODE_OPTIONS=--openssl-legacy-provider)

call node_modules\.bin\webpack.cmd
call node_modules\.bin\webpack.cmd || goto :error
popd

rmdir /s /q %SRRoot%\chat\

rmdir /s /q resources\chat\node_modules\

xcopy /y /e resources\chat\ %SRRoot%\chat\
xcopy /y /e resources\chat\ %SRRoot%\chat\ || goto :error
del %SRRoot%\chat\yarn.lock
del %SRRoot%\chat\package.json

rmdir /s /q %SRRoot%\chat\html\
mkdir %SRRoot%\chat\html\vendor\

xcopy /y /e resources\chat\html\vendor %SRRoot%\chat\html\vendor
xcopy /y /e resources\chat\html\vendor %SRRoot%\chat\html\vendor || goto :error
popd

:: done!
exit /B 0
echo Done adding chat
goto :success
:: /chat


:error
echo Failed to build system resources
exit /b %errorlevel%


:success
exit /b 0
5 changes: 2 additions & 3 deletions ext/system-resources/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ npm install -g [email protected]
mkdir -p data

# txAdmin
MONITOR_ARTIFACT_URL="https://github.com/tabarra/txAdmin/releases/download/v7.0.0/monitor.zip"

MONITOR_PATH=data/monitor
MONITOR_ARTIFACT_PATH=data/monitor.zip

rm -rf $MONITOR_PATH
mkdir -p $MONITOR_PATH

curl -Lo $MONITOR_ARTIFACT_PATH $MONITOR_ARTIFACT_URL
node manager.js download --name=monitor --file=$MONITOR_ARTIFACT_PATH

unzip $MONITOR_ARTIFACT_PATH -d $MONITOR_PATH
rm $MONITOR_ARTIFACT_PATH

Expand Down
Loading

0 comments on commit 68751bf

Please sign in to comment.