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
41 lines • 1.62 kB
JavaScript
import { Profile } from '../../lib/profile.js';
import { Logger } from '../../utils/logger.js';
import { DRegistryPackageManagerError } from './error.js';
export class ContextCommand {
async execute({ options, subcommand }) {
try {
const name = options?.name ?? Profile.loadStaticSync().name;
const profile = new Profile(name);
switch (subcommand) {
case 'create':
await profile.context.create(options);
await profile.save();
break;
case 'read':
profile.context.read(options);
break;
case 'update':
profile.context.update(options);
profile.context.save({ name: profile.context.name, context: profile.context.data });
break;
case 'delete':
profile.context.delete(options);
profile.context.save({ name: profile.context.name, context: profile.context.data });
break;
case 'backup':
profile.context.backup(options);
break;
case 'recover':
profile.context.recover(options);
break;
default:
throw new DRegistryPackageManagerError(`ContextCommand: Unknown action ${subcommand}`);
}
}
catch (error) {
Logger.error(error.message);
throw error;
}
}
}
//# sourceMappingURL=context.js.map