From 2687adf694623865e447a9285253780ca4a32896 Mon Sep 17 00:00:00 2001 From: MaxSMokeSkaarj Date: Fri, 29 Nov 2024 13:55:21 +1000 Subject: [PATCH] =?utf8?q?=D0=90=D0=B2=D1=82=D0=BE=D0=BE=D0=B1=D0=BD=D0=BE?= =?utf8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20RobustToolbox?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Tools/publish_multi_request_local.mjs | 102 -------------------------- 1 file changed, 102 deletions(-) delete mode 100644 Tools/publish_multi_request_local.mjs 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(); - -- 2.52.0