MCPcopy Create free account
hub / github.com/nodejs/node / #getOutdatedInfo

Method #getOutdatedInfo

deps/npm/lib/commands/outdated.js:158–220  ·  view source on GitHub ↗
(edge)

Source from the content-addressed store, hash-verified

156 }
157
158 async #getOutdatedInfo (edge) {
159 const alias = safeNpa(edge.spec)?.subSpec
160 const spec = npa(alias ? alias.name : edge.name)
161 const node = edge.to || edge
162 const { path, location, package: { version: current } = {} } = node
163
164 const type = edge.optional ? 'optionalDependencies'
165 : edge.peer ? 'peerDependencies'
166 : edge.dev ? 'devDependencies'
167 : 'dependencies'
168
169 for (const omitType of this.npm.flatOptions.omit) {
170 if (node[omitType]) {
171 return
172 }
173 }
174
175 // deps different from prod not currently on disk are not included in the output
176 if (edge.error === MISSING && type !== 'dependencies') {
177 return
178 }
179
180 // if it's not a range, version, or tag, skip it
181 if (!safeNpa(`${edge.name}@${edge.spec}`)?.registry) {
182 return null
183 }
184
185 try {
186 const packument = await this.#getPackument(spec)
187 const expected = alias ? alias.fetchSpec : edge.spec
188 const { minReleaseAgeExclude } = this.npm.flatOptions
189 // Packages matching `min-release-age-exclude` resolve to their newest
190 // version, so drop the `before` constraint for them.
191 const pickOpts = isReleaseAgeExcluded(packument.name, minReleaseAgeExclude)
192 ? { ...this.npm.flatOptions, before: null }
193 : this.npm.flatOptions
194 const wanted = pickManifest(packument, expected, pickOpts)
195 const latest = pickManifest(packument, '*', pickOpts)
196 if (!current || current !== wanted.version || wanted.version !== latest.version) {
197 this.#list.push({
198 name: alias ? edge.spec.replace('npm', edge.name) : edge.name,
199 path,
200 type,
201 current,
202 location,
203 wanted: wanted.version,
204 latest: latest.version,
205 workspaceDependent: edge.from?.isWorkspace ? edge.from.pkgid : null,
206 dependedByLocation: edge.from?.name
207 ? edge.from?.location
208 : 'global',
209 dependent: edge.from?.name ?? 'global',
210 homepage: packument.homepage,
211 })
212 }
213 } catch (err) {
214 // silently catch and ignore ETARGET, E403 & E404 errors
215 // deps are just skipped

Callers 1

execMethod · 0.95

Calls 4

#getPackumentMethod · 0.95
safeNpaFunction · 0.85
includesMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected