From: MaxSMokeSkaarj Date: Fri, 29 Nov 2024 03:55:21 +0000 (+1000) Subject: Автообновление RobustToolbox X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=2687adf694623865e447a9285253780ca4a32896;p=space-station-14.git Автообновление RobustToolbox --- diff --git a/Tools/publish_multi_request_local.mjs b/Tools/publish_multi_request_local.mjs deleted file mode 100644 index 0fac6dd0cc..0000000000 --- a/Tools/publish_multi_request_local.mjs +++ /dev/null @@ -1,102 +0,0 @@ -import { exec, spawn } from 'node:child_process'; -import * as path from 'node:path'; -import { request } from 'node:https'; -import { Buffer } from 'node:buffer'; - -const RobustCDNURLStr = 'https://ss14.smokeofanarchy.ru/cdn'; -const ForkID = 'SMoA'; - -const ReleaseDir = 'release'; - -const PublishToken = process.env.PUBLISH_TOKEN; - -const RobustCDNURL = new URL(RobustCDNURLStr); - -const getEngineVersion = () => { - return new Promise( (res,rej) => { - exec('cd RobustToolbox && git describe --tags --abbrev=0', (err, stdout, stderr) => { - if (err) { - console.error(err); - rej(err); - } - res(stdout); - }); - }); -}; - -const getVersion = () => { - return new Promise( (res,rej) => { - exec('git rev-parse HEAD', (err, stdout, stderr) => { - if (err) { - console.error(err); - rej(err); - }; - res(stdout); - }); - }); -}; - -const getFilesToPublish = () => { - return new Promise( (res,rej) => { - exec(`cd ${ReleaseDir} && ls`, (err, stdout, stderr) => { - if (err) { - console.error(err); - rej(err); - }; - res(stdout); - }); - }); -}; - -const repoSHA = await getVersion(); -const engineVersion = await getEngineVersion(); -const FilesToUpload = (await getFilesToPublish()).split('\n').filter( (file) => {return file}); - -const headers = { - 'Content-Type': 'application/json', - 'Authorization': `Bearer ${PublishToken}`, -} - -const optionsStart = { - hostname: RobustCDNURL.host.split(':')[0], - port: RobustCDNURL.port, - path: `${RobustCDNURL.pathname}/fork/${ForkID}/publish/start`, - method: 'POST', - headers, -}; - -const optionsFile = { - hostname: RobustCDNURL.host.split(':')[0], - port: RobustCDNURL.port, - path: `${RobustCDNURL.pathname}/fork/${ForkID}/publish/file`, - method: 'POST', - headers, -}; - -const optionsFinish = { - hostname: RobustCDNURL.host.split(':')[0], - port: RobustCDNURL.port, - path: `${RobustCDNURL.pathname}/fork/${ForkID}/publish/finish`, - method: 'POST', - headers, -}; - -const data = { - "version": repoSHA.trim(), - "engineVersion": engineVersion.trim() -} - -const req = request(optionsStart, (res) => { - console.log('statusCode:', res.statusCode); - console.log('headers:', res.headers); - res.on('data', (d) => { - //d = JSON.parse(d.toString()) - console.log(d.toString()); - }); -}); -req.write(JSON.stringify(data)); -req.on('error', (e) => { - console.error(e); -}); -req.end(); -