feat: depot dodnloader node js

This commit is contained in:
TrèsAbhi committed 2024-01-22 13:40:37 -06:00
1 parent 3157bc5e1b
commit d70a980058
4 files changed
+48 -31

No files matched your search

+17 -27
View File
@@ -2,44 +2,34 @@ name: Build Assets
on: on:
push: push:
branches: branches: 1.16.0
- 1.16.0
workflow_dispatch: workflow_dispatch:
jobs: jobs:
build: build:
runs-on: windows-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Set up .NET - name: Use node
uses: actions/setup-dotnet@v3 uses: actions/setup-node@v3
with: with:
dotnet-version: '6.0' node-version: 18
cache: 'npm'
- name: Get latest release info - name: Install Yarn
id: release run: npm install --location=global yarn
run: |
$RELEASE_JSON = Invoke-RestMethod -Uri https://api.github.com/repos/SteamRE/DepotDownloader/releases/latest
$DOWNLOAD_URL = $RELEASE_JSON.assets[0].browser_download_url
Write-Output "##vso[task.setvariable variable=tag_name;isOutput=true]$($RELEASE_JSON.tag_name)"
Write-Output "##vso[task.setvariable variable=download_url;isOutput=true]$DOWNLOAD_URL"
- name: Download file as depotdownload.zip - name: Use node_modules cache
run: | uses: actions/cache@v3
$DOWNLOAD_URL = $env:download_url with:
if (-not $DOWNLOAD_URL) { path: '**/node_modules'
Write-Error "Download URL is null or empty. Check GitHub API response." key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
exit 1
}
Invoke-WebRequest -Uri $DOWNLOAD_URL -OutFile depotdownload.zip
- name: Extract zip file - name: Install dependencies
run: Expand-Archive -Path depotdownload.zip -DestinationPath . run: yarn
- name: Run DepotDownloader.dll - name: Setup DepotDownloader
run: | run: yarn setup:depotdownloader
$DLL_PATH = ".\DepotDownloader.dll"
dotnet $DLL_PATH
+3 -3
View File
@@ -19,13 +19,13 @@
"start:website": "next start", "start:website": "next start",
"host:docs": "vitepress preview docs", "host:docs": "vitepress preview docs",
"publish:ratingsleaderboard": "vite-node --script scripts/buildRatingsLeaderboard --publish", "publish:ratingsleaderboard": "vite-node --script scripts/buildRatingsLeaderboard --publish",
"zip": "zip -r dist.zip dist",
"lint": "npx tsc", "lint": "npx tsc",
"lint:website": "next lint", "lint:website": "next lint",
"format": "prettier --write \"**/*.@(json|js|jsx|css|md|ts|tsx|html|xml|yml|gltf)\"", "format": "prettier --write \"**/*.@(json|js|jsx|css|md|ts|tsx|html|xml|yml|gltf)\"",
"lint:version": "vite-node --script scripts/checkVersionMissMatch", "lint:version": "vite-node --script scripts/checkVersionMissMatch",
"knip": "knip", "knip": "knip",
"update": "yarn upgrade --latest" "update": "yarn upgrade --latest",
"setup:depotdownloader": "vite-node --script scripts/setupDepotDownloader"
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -74,7 +74,7 @@
}, },
"devDependencies": { "devDependencies": {
"@total-typescript/ts-reset": "^0.5.1", "@total-typescript/ts-reset": "^0.5.1",
"@types/decompress": "^4.2.6", "@types/decompress": "^4.2.7",
"@types/escape-html": "^1.0.2", "@types/escape-html": "^1.0.2",
"@types/express": "^4.17.18", "@types/express": "^4.17.18",
"@types/js-yaml": "^4.0.8", "@types/js-yaml": "^4.0.8",
+27
View File
@@ -0,0 +1,27 @@
import decompress from 'decompress';
import { existsSync } from 'fs';
import { mkdir, writeFile } from 'fs/promises';
if (!existsSync('temp')) {
console.log('Creating temp directory...');
await mkdir('temp');
}
console.log('Downloading depot downloader...');
await fetch(
'https://api.github.com/repos/SteamRE/DepotDownloader/releases/latest',
)
.then(
(response) =>
response.json() as Promise<{
assets: { browser_download_url: string }[];
}>,
)
.then(({ assets }) => fetch(assets[0].browser_download_url))
.then((response) => response.arrayBuffer())
.then((arrayBuffer) =>
writeFile('temp/depotDownloader.zip', Buffer.from(arrayBuffer)),
);
console.log('Unzipping...');
decompress('temp/depotDownloader.zip', 'temp/depotDownloader');
+1 -1
View File
@@ -2275,7 +2275,7 @@
dependencies: dependencies:
"@types/node" "*" "@types/node" "*"
"@types/decompress@^4.2.6": "@types/decompress@^4.2.7":
version "4.2.7" version "4.2.7"
resolved "https://registry.yarnpkg.com/@types/decompress/-/decompress-4.2.7.tgz#604f69b69d519ecb74dea1ea0829f159b85e1332" resolved "https://registry.yarnpkg.com/@types/decompress/-/decompress-4.2.7.tgz#604f69b69d519ecb74dea1ea0829f159b85e1332"
integrity sha512-9z+8yjKr5Wn73Pt17/ldnmQToaFHZxK0N1GHysuk/JIPT8RIdQeoInM01wWPgypRcvb6VH1drjuFpQ4zmY437g== integrity sha512-9z+8yjKr5Wn73Pt17/ldnmQToaFHZxK0N1GHysuk/JIPT8RIdQeoInM01wWPgypRcvb6VH1drjuFpQ4zmY437g==