web/website/scripts/deployment-package.mjs
unimatrixgit 33507e7be7
All checks were successful
DuneRealms Web CI / web (push) Successful in 3m20s
Ship verified private Lobby configuration in the canonical operations artifact
2026-12-02 11:43:02 +01:00

17 lines
1 KiB
JavaScript

import {mkdirSync,readFileSync,writeFileSync} from 'node:fs';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import {createHash} from 'node:crypto';
export function packageDeploymentScripts(output,sourceCommit=null,{sourceDirectory=fileURLToPath(new URL('../ops/',import.meta.url))}={}){
if(sourceCommit!==null&&!/^[a-f0-9]{40}$/.test(sourceCommit))throw Error('Invalid deployment source commit');
const files={};
for(const name of ['dunerealms-ci-trigger','dunerealms-build-release','configure-lobby-account.py']){
const bytes=Buffer.from(readFileSync(path.join(sourceDirectory,name),'utf8').replaceAll('\r\n','\n'));
files[name]={sha256:createHash('sha256').update(bytes).digest('hex'),bytes:bytes.length};
mkdirSync(output,{recursive:true});writeFileSync(path.join(output,name),bytes);
}
const manifest={schema:1,sourceRepository:'https://www.dunerealms.com/git/unimatrix/web.git',sourceCommit,files};
writeFileSync(path.join(output,'manifest.json'),JSON.stringify(manifest,null,2)+'\n');
return manifest;
}