import { execSync, exec } from 'child_process' import { lsFolder } from '../files.js' import { AO_MANUAL_PATH } from '../manual.js' export function manualStatus() { // There are at least eighteen items in the manual if(lsFolder(AO_MANUAL_PATH).length >= 18) { return 'installed' } return 'off' } export async function updateManual() { exec('cd ' + process.env.HOME + '/.ao/manual && git pull origin main 2>&1', (error, stdout, stderr) => { //console.log('error:', error, 'stdout:', stdout, 'stderr:', stderr) if(error) { console.log('git pull failed with error:', error) } if(stdout.includes('Already up to date.')) { return } console.log('/nAO User Manual was updated.') }) } // Downloads the ao-manual repo to ~/.ao/manual/. Returns false if it fails, which usually means the folder already exists (update instead). export function downloadManual() { try { execSync('git clone http://git.coalitionofinvisiblecolleges.org:3009/autonomousorganization/ao-manual.git ' + AO_MANUAL_PATH + ' 2>&1') } catch(err) { switch(err.code) { case 128: return false } } return true } export default { name: 'Manual', description: 'AO user manual', status: manualStatus, install: downloadManual, update: updateManual }