@@ -5,8 +5,6 @@ const Table = require("cli-table");
55const { log } = require ( "./logger" ) ;
66const {
77 env,
8- cleanCache,
9- getCache,
108 getLatestVersion,
119 getNpmFetchOptions,
1210 parseEnv
@@ -32,26 +30,10 @@ const searchEndpoint = async function(keyword, registry) {
3230 }
3331} ;
3432
35- const searchOld = async function ( keyword , shouldCleanCache ) {
36- // clean cache if needed
37- if ( shouldCleanCache ) cleanCache ( ) ;
38- // load cache
39- let cache = getCache ( ) ;
40- let cacheKey = env . namespace + ".all" ;
41- if ( process . env . NODE_ENV == "test" ) cacheKey = "test." + cacheKey ;
42- cacheKey = cacheKey + ".json" ;
43- let cached = cache [ cacheKey ] || { } ;
44- let cachedLen = ( cached . objects || [ ] ) . length ;
45- log . verbose (
46- "cache" ,
47- `has ${ cachedLen } package(s), updated at ${ cached . _updated } `
48- ) ;
33+ const searchOld = async function ( keyword ) {
4934 // all endpoint
50- let serverUrl = cached . _updated
51- ? `/-/all/since?stale=update_after&startkey=${ cached . _updated } `
52- : `/-/all` ;
5335 try {
54- const results = await npmFetch . json ( serverUrl , getNpmFetchOptions ( ) ) ;
36+ const results = await npmFetch . json ( "/-/all" , getNpmFetchOptions ( ) ) ;
5537 log . verbose ( "endpoint.all" , results ) ;
5638 let objects = [ ] ;
5739 if ( results ) {
@@ -64,14 +46,8 @@ const searchOld = async function(keyword, shouldCleanCache) {
6446 objects = Object . values ( results ) ;
6547 }
6648 }
67- // contact cached objects and remote objects
68- const allObjects = objects . concat ( cached . objects || [ ] ) ;
69- // save to cache
70- cached . objects = allObjects ;
71- cached . _updated = Math . round ( new Date ( ) . getTime ( ) ) ;
72- cache [ cacheKey ] = cached ;
7349 // prepare rows
74- const rows = allObjects . map ( pkg => {
50+ const rows = objects . map ( pkg => {
7551 let name = pkg . name ;
7652 let version = getLatestVersion ( pkg ) ;
7753 let date =
@@ -107,7 +83,7 @@ module.exports = async function(keyword, options) {
10783 let results = await searchEndpoint ( keyword ) ;
10884 // search old search
10985 if ( results === undefined ) {
110- results = ( await searchOld ( keyword , options . cleanCache ) ) || [ ] ;
86+ results = ( await searchOld ( keyword ) ) || [ ] ;
11187 }
11288 // search upstream
11389 // if (env.upstream) {
0 commit comments