#!/usr/bin/env node
// Lädt publish/latest.html als EINMALIGEN, permanenten Zeiger nach Arweave.
// Die TxID dieser Datei ist die stabile Adresse der Site — sie ändert sich
// nie, weil die Seite selbst per GraphQL das neueste Manifest findet.
// Nur neu ausführen, wenn latest.html sich inhaltlich ändern MUSS (neue TxID
// heißt: Ronny müsste den Redirect anfassen).
const fs = require('fs');
const path = require('path');
const { TurboFactory, EthereumSigner } = require('@ardrive/turbo-sdk');
async function main() {
const key = JSON.parse(fs.readFileSync(path.join(__dirname, 'signing-key.json'), 'utf8')).privateKey;
const turbo = TurboFactory.authenticated({ signer: new EthereumSigner(key), token: 'ethereum' });
const buf = fs.readFileSync(path.join(__dirname, 'latest.html'));
const res = await turbo.uploadFile({
fileStreamFactory: () => buf,
fileSizeFactory: () => buf.byteLength,
dataItemOpts: {
tags: [
{ name: 'Content-Type', value: 'text/html; charset=utf-8' },
{ name: 'App-Name', value: 'kiel-pointer' },
],
},
});
console.log('Pointer-TxID:', res.id);
console.log('URL: https://arweave.net/' + res.id);
fs.writeFileSync(path.join(__dirname, 'pointer-tx.json'), JSON.stringify(res, null, 2));
}
main().catch(e => { console.error('FEHLER:', e.message || e); process.exit(1); });