MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / checkForUpdate

Function checkForUpdate

packages/core/api/src/update-check.ts:267–286  ·  view source on GitHub ↗
(
  currentVersion: string,
  options?: ResolveDistTagsOptions,
)

Source from the content-addressed store, hash-verified

265 * Best-effort: an unreachable registry yields `updateAvailable: false`.
266 */
267export const checkForUpdate = async (
268 currentVersion: string,
269 options?: ResolveDistTagsOptions,
270): Promise<UpdateStatus> => {
271 const channel = resolveUpdateChannel(currentVersion);
272 const command = `npm i -g ${EXECUTOR_PACKAGE_NAME}@${channel}`;
273
274 // No dist-tag can legitimately be compared against this version (unstamped
275 // dev build, or a prerelease channel that never gets published) — do not
276 // even hit the registry, since the answer is already known.
277 const comparisonChannel = resolveComparisonChannel(currentVersion);
278 if (comparisonChannel === null) {
279 return { updateAvailable: false, currentVersion, latestVersion: null, channel, command };
280 }
281
282 const tags = await resolveDistTags(options);
283 const latestVersion = tags[comparisonChannel] ?? null;
284 const updateAvailable = isUpdateAvailable(currentVersion, latestVersion);
285 return { updateAvailable, currentVersion, latestVersion, channel, command };
286};

Callers 2

runForegroundSessionFunction · 0.90

Calls 4

resolveUpdateChannelFunction · 0.85
resolveComparisonChannelFunction · 0.85
resolveDistTagsFunction · 0.85
isUpdateAvailableFunction · 0.85

Tested by

no test coverage detected