diff --git a/packages/core/src/dev/beta.ts b/packages/core/src/dev/beta.ts index 7718d1f49fc..fbcf3bf4748 100644 --- a/packages/core/src/dev/beta.ts +++ b/packages/core/src/dev/beta.ts @@ -21,8 +21,10 @@ import { CancellationError } from '../shared/utilities/timeoutUtils' import { isAmazonQ, isCloud9, productName } from '../shared/extensionUtilities' import * as config from './config' import { isReleaseVersion } from '../shared/vscode/env' +import { getRelativeDate } from '../shared/datetime' const localize = nls.loadMessageBundle() +const logger = getLogger('dev/beta') const downloadIntervalMs = 1000 * 60 * 60 * 24 // A day in milliseconds @@ -57,12 +59,13 @@ export async function activate(ctx: vscode.ExtensionContext) { * If this is the first time we are watching the beta version or if its been 24 hours since it was last checked then try to prompt for update */ export function watchBetaVSIX(vsixUrl: string): vscode.Disposable { - getLogger().info(`dev: watching ${vsixUrl} for beta artifacts`) - const toolkit = getBetaToolkitData(vsixUrl) + const lastCheckRel = toolkit ? getRelativeDate(new Date(toolkit.lastCheck)) : '' + logger.info('watching beta artifacts url (lastCheck: %s): %s', lastCheckRel, vsixUrl) + if (!toolkit || toolkit.needUpdate || Date.now() - toolkit.lastCheck > downloadIntervalMs) { runAutoUpdate(vsixUrl).catch((e) => { - getLogger().error('runAutoUpdate failed: %s', (e as Error).message) + logger.error('runAutoUpdate failed: %s', (e as Error).message) }) } @@ -71,13 +74,13 @@ export function watchBetaVSIX(vsixUrl: string): vscode.Disposable { } async function runAutoUpdate(vsixUrl: string) { - getLogger().debug(`dev: checking ${vsixUrl} for a new version`) + logger.debug(`checking url for a new version: %s`, vsixUrl) try { await telemetry.aws_autoUpdateBeta.run(() => checkBetaUrl(vsixUrl)) } catch (e) { if (!isUserCancelledError(e)) { - getLogger().warn(`dev: beta extension auto-update failed: %s`, e) + logger.warn('beta extension auto-update failed: %s', e) } } } @@ -165,7 +168,7 @@ async function promptInstallToolkit(pluginPath: vscode.Uri, newVersion: string, switch (response) { case installBtn: try { - getLogger().info(`dev: installing artifact ${vsixName}`) + logger.info(`installing artifact: ${vsixName}`) await vscode.commands.executeCommand('workbench.extensions.installExtension', pluginPath) await updateBetaToolkitData(vsixUrl, { lastCheck: Date.now(),