update
This commit is contained in:
parent
ce2751e383
commit
d9573937d0
@ -1,5 +1,6 @@
|
|||||||
import * as plugins from './smartnpm.plugins'
|
import * as plugins from './smartnpm.plugins'
|
||||||
import {}
|
|
||||||
|
|
||||||
|
export * from './smartnpm.classes.npmregistry'
|
||||||
|
export * from './smartnpm.classes.npmpackage'
|
||||||
|
|
||||||
export let standardExport = 'Hi there! :) This is a exported string'
|
export let standardExport = 'Hi there! :) This is a exported string'
|
||||||
|
@ -5,9 +5,14 @@ interface ISearchObject {
|
|||||||
author?: string
|
author?: string
|
||||||
maintainer: string
|
maintainer: string
|
||||||
scope?: string
|
scope?: string
|
||||||
|
keywords: string[]
|
||||||
|
|
||||||
|
// status
|
||||||
deprecated?: boolean
|
deprecated?: boolean
|
||||||
unstable?: boolean
|
unstable?: boolean
|
||||||
insecure?: boolean
|
insecure?: boolean
|
||||||
|
|
||||||
|
// search behaviour
|
||||||
boostExact: boolean
|
boostExact: boolean
|
||||||
scoreEffect: number
|
scoreEffect: number
|
||||||
|
|
||||||
@ -18,7 +23,50 @@ interface ISearchObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class NpmRegistry {
|
export class NpmRegistry {
|
||||||
search (searchObject: ISearchObject) {
|
private searchDomain = 'https://api.npms.io/v2/search?q='
|
||||||
let response = await plugins.Smartrequest
|
search (searchObjectArg: ISearchObject) {
|
||||||
|
let searchString = ''
|
||||||
|
let addToSearchString = (addStringArg: string) => {
|
||||||
|
searchString = `${searchString} ${addStringArg}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// metadata
|
||||||
|
if (searchObjectArg.author) { addToSearchString(`author:${searchObjectArg.author}`) }
|
||||||
|
if (searchObjectArg.maintainer) { addToSearchString(`maintainer:${searchObjectArg.maintainer}`) }
|
||||||
|
if (searchObjectArg.scope) { addToSearchString(`scope:${searchObjectArg.scope}`) }
|
||||||
|
|
||||||
|
// status
|
||||||
|
if (searchObjectArg.deprecated) {
|
||||||
|
if (searchObjectArg.deprecated === true) {
|
||||||
|
addToSearchString(`is:deprecated`)
|
||||||
|
} else {
|
||||||
|
addToSearchString(`not:deprecated`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (searchObjectArg.unstable) {
|
||||||
|
if (searchObjectArg.unstable === true) {
|
||||||
|
addToSearchString(`is:unstable`)
|
||||||
|
} else {
|
||||||
|
addToSearchString(`not:unstable`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (searchObjectArg.insecure) {
|
||||||
|
if (searchObjectArg.insecure === true) {
|
||||||
|
addToSearchString(`is:insecure`)
|
||||||
|
} else {
|
||||||
|
addToSearchString(`not:insecure`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// search behaviour
|
||||||
|
if (searchObjectArg.boostExact) { addToSearchString(`boost-exact:${searchObjectArg.boostExact}`) }
|
||||||
|
if (searchObjectArg.scoreEffect) { addToSearchString(`score-effect:${searchObjectArg.scoreEffect}`) }
|
||||||
|
|
||||||
|
// analytics
|
||||||
|
if (searchObjectArg.qualityWeight) { addToSearchString(`author:${searchObjectArg.qualityWeight}`) }
|
||||||
|
if (searchObjectArg.popularityWeight) { addToSearchString(`author:${searchObjectArg.popularityWeight}`) }
|
||||||
|
if (searchObjectArg.maintenanceWeight) { addToSearchString(`author:${searchObjectArg.maintenanceWeight}`) }
|
||||||
|
|
||||||
|
let response = (await plugins.smartrequest.get(this.searchDomain, {}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user