UNPKG

dwnpm

Version:

Decentralized Registry Package Manager (DRPM) helps developers publish, install, find and manage Decentralized Packages (DPKs) published to Decentralized Web Nodes (DWNs). DRPM does this by looking up a Decentralized Identifier (DID) to find its DID docum

62 lines 2.41 kB
import { DWeb5 } from '../../lib/dweb5.js'; import { DwnProtocols, DwnRecords, DwnSync } from '../../lib/dwn.js'; import { Profile } from '../../lib/profile.js'; import { Logger } from '../../utils/logger.js'; import { DRegistryPackageManagerError } from './error.js'; export class DwnCommand { async execute({ options, subcommand }) { try { const name = options.name ?? Profile.loadStaticSync().name; options.connection = await DWeb5.connect({ name }); switch (subcommand) { case 'protocols': { const protocols = new DwnProtocols(); if (options.action === 'configure') { await protocols.configure(); } else if (options.action === 'query') { await protocols.query(); } } break; case 'records': { const records = new DwnRecords(); if (options.action === 'create') { await records.create(); } else if (options.action === 'read') { await records.read(); } else if (options.action === 'update') { await records.update(); } else if (options.action === 'delete') { await records.delete(); } break; } case 'sync': { const sync = new DwnSync(); if (options.action === 'start') { await sync.start(); } else if (options.action === 'stop') { await sync.stop(); } else if (options.action === 'sync') { await sync.sync(); } break; } default: throw new DRegistryPackageManagerError(`ProfileCommand: Unknown subcommand ${subcommand}`); } } catch (error) { Logger.error(error.message); throw error; } } } //# sourceMappingURL=dwn.js.map