import pacote from "pacote" ; import { ExtensionManager } from "../main" ; import { Extension } from "./extension" ; /**
 * A Package is a representation of a npm package.
 *
 * Once installed, a Package is an Extension
 */ export class Package { public constructor ( public resolvedInfo , public packageMetadata , public extensionManager ) { } public get id ( ) : string { return this . packageMetadata . _id ! ; } public get name ( ) : string { return this . packageMetadata . name ; } public get version ( ) : string { return this . packageMetadata . version ; } public get source ( ) : string { if ( this . resolvedInfo . type === "version" && this . resolvedInfo . registry === true ) { return this . packageMetadata . _spec + "*" ; } return this . packageMetadata . _spec as any ; } public async install ( force = false ) { return this . extensionManager . installPackage ( this , force ) ; } public get allVersions ( ) : Promise < Array < string > > { return this . extensionManager . getPackageVersions ( this . name ) ; } }