-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnodejs_downloader.cmd
101 lines (77 loc) · 3.35 KB
/
nodejs_downloader.cmd
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
@ECHO OFF
TITLE Portable Automated NodeJS and revolt.js with Revolt Bot Example.
ECHO __________________________________________________________________________
ECHO.
ECHO Starting Automated NodeJS and revolt.js with Revolt Bot Example.
ECHO __________________________________________________________________________
SET "requirements_met=true"
ECHO Checking Requirements...
FOR %%X IN (curl.exe tar.exe) DO (
IF NOT EXIST "%SYSTEMROOT%\System32\%%X" (
ECHO - %%X command not found. Please install %%X and add it to PATH environment variable.
SET "requirements_met=false"
) ELSE (
ECHO + %%X command found.
)
)
IF "%requirements_met%"=="true" (
ECHO All requirements met. You can run the script.
) ELSE (
ECHO Please install the missing requirements and try again. && PAUSE && EXIT
)
SET "nodeDirectory=*node-*"
IF EXIST ".\%nodeDirectory%" (
CD ".\%nodeDirectory%"
IF EXIST "completed_tar_extraction_of_nodejs" (
"./node.exe" "./bot.js"
PAUSE && EXIT
) ELSE (
ECHO Tar extraction of NodeJS was not completed previously.
)
)
REM Download SHASUMS256.txt to FIND latest NodeJS release filename
ECHO 1. Downloading SHASUMS256.txt
curl https://nodejs.org/dist/latest/SHASUMS256.txt > ".\SHASUMS256.txt"
ECHO 2. Parsing each line of second column of SHASUMS256.txt
FOR /F "tokens=1,2" %%a IN (SHASUMS256.txt) DO (
ECHO %%b | FIND /I "win-x64.zip" >NUL && (
ECHO NodeJS filename found. (%%b^)
SET "Filename=%%b"
SET "SHA256=%%a"
) || (
REM ECHO %%i filename does not contain string.
)
)
ECHO Hash: %SHA256%
IF "%Filename%"=="" ECHO Latest release filename Not found in the SHASUMS256.txt of https://nodejs.org/dist/latest/ && PAUSE && EXIT
ECHO 3. Splitting filename between .zip file extension and filename (%Filename%)
FOR %%f IN ("%Filename%") DO SET "Filename_without_extension=%%~nf"
ECHO 4. Downloading latest NodeJS using Filename.
curl "https://nodejs.org/dist/latest/%Filename%" -O
IF %ERRORLEVEL% NEQ 0 echo An error occurred while downloading NodeJS. && pause && exit /b
ECHO 5. Extracting downloaded NodeJS archive in the current directory
tar -xvf "./%Filename%" -C "./"
IF %ERRORLEVEL% equ 0 (
ECHO > "./%Filename_without_extension%/completed_tar_extraction_of_nodejs"
)
ECHO 6. Deleting Downloaded files.
DEL "./%Filename%"
DEL ".\SHASUMS256.txt"
ECHO 7. [Prevention] Reinstall NodeJS NPM to prevent deletion of NPM after first NPM package download/installation.
CD ".\%Filename_without_extension%"
CALL .\npm install -D npm
ECHO 8. NodeJS NPM: Install revolt.js
CALL .\npm i revolt.js
ECHO 9. Downloading Revolt.js bot example.
curl -L "https://github.com/publicdomain-nocopyright/Portable-Automated-NodeJS-with-revolt.js-and-Revolt-Bot-Example/releases/download/refs%%2Fheads%%2Fmain/bot.js" -O
ECHO 10. Please insert Bot Token:
ECHO A Browser Window to browse your bots will be opened.
TIMEOUT /T 10
tasklist /FI "IMAGENAME eq chrome.exe" 2>NUL | find /I /N "chrome.exe">NUL && (
echo Google Chrome is running. & start chrome.exe "https://app.revolt.chat/settings/bots") || (
echo Google Chrome is not running. & start explorer "https://app.revolt.chat/settings/bots")
SET /p "bot_token=Enter Bot Token: "
ECHO|SET /p="%bot_token%">"./bot_token.txt"
ECHO 11. Starting Revolt.js bot example.
node "./bot.js" "%bot_token%"
cmd ".\"