// Packages only the reviewed fixed-purpose CLI; excludes website code/secrets. import {readFileSync,writeFileSync} from 'node:fs';import {createHash} from 'node:crypto'; const files=Object.fromEntries(['jarvis-dev-key.mjs','jarvis-dev-clan-reset.mjs','jarvis-dev-clan-reset-cli.mjs'].map(name=>{const bytes=readFileSync(new URL(name,import.meta.url));return [name,{data:bytes.toString('base64'),sha256:createHash('sha256').update(bytes).digest('hex')}];})); const output=process.argv[2];if(!output)throw Error('Output path required'); writeFileSync(output,`#!/usr/bin/python3 import os,sys,json,base64,hashlib,subprocess,stat if os.geteuid()!=0: raise SystemExit('Run with server administrator authority') if len(sys.argv)!=2 or sys.argv[1] not in ('--plan','--apply'): raise SystemExit('Use --plan or --apply') files=json.loads(${JSON.stringify(JSON.stringify(files))}) target='/usr/local/libexec/dunerealms-dev/keytest-20261118' for directory in ['/usr/local/libexec','/usr/local/libexec/dunerealms-dev',target]: if os.path.lexists(directory): st=os.lstat(directory) if not stat.S_ISDIR(st.st_mode) or st.st_uid!=0 or st.st_mode & 0o022: raise SystemExit('Unsafe installation directory') else: os.mkdir(directory,0o755) for name,item in files.items(): data=base64.b64decode(item['data']) if hashlib.sha256(data).hexdigest()!=item['sha256']: raise SystemExit('Package hash mismatch') dest=os.path.join(target,name) if os.path.islink(dest): raise SystemExit('Unsafe installation target') temporary=dest+'.install-'+str(os.getpid()) fd=os.open(temporary,os.O_WRONLY|os.O_CREAT|os.O_EXCL|os.O_NOFOLLOW,0o600) with os.fdopen(fd,'wb') as out: out.write(data);out.flush();os.fsync(out.fileno()) os.chmod(temporary,0o644);os.replace(temporary,dest) node='/home/dunerealms/.nvm/versions/node/v22.23.3/bin/node' for name in files: subprocess.run([node,'--check',os.path.join(target,name)],check=True) raise SystemExit(subprocess.run([node,os.path.join(target,'jarvis-dev-clan-reset-cli.mjs'),sys.argv[1]]).returncode) `); console.log(JSON.stringify({output,files:Object.keys(files),containsSecrets:false}));