diff --git a/extension/src/dependency-installer/installers/flow-cli-installer.ts b/extension/src/dependency-installer/installers/flow-cli-installer.ts index bededc68..50b03415 100644 --- a/extension/src/dependency-installer/installers/flow-cli-installer.ts +++ b/extension/src/dependency-installer/installers/flow-cli-installer.ts @@ -98,10 +98,9 @@ export class InstallFlowCLI extends Installer { } } - async checkVersion (vsn: semver.SemVer): Promise { + async checkVersion (version: semver.SemVer): Promise { // Get user's version informaton this.#context.cliProvider.refresh() - const version = vsn if (version == null) return false if (!semver.satisfies(version, COMPATIBLE_FLOW_CLI_VERSIONS, { diff --git a/extension/src/flow-cli/binary-versions-provider.ts b/extension/src/flow-cli/binary-versions-provider.ts index fd44f0db..ac2bb01f 100644 --- a/extension/src/flow-cli/binary-versions-provider.ts +++ b/extension/src/flow-cli/binary-versions-provider.ts @@ -12,6 +12,8 @@ export enum KNOWN_FLOW_COMMANDS { CADENCE_V1 = 'flow-c1', } +// This regex matches a string like "Version: v{SEMVER}" and extracts the version number +// It uses the official semver regex from https://semver.org/ const LEGACY_VERSION_REGEXP = /Version:\s*(v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(\s|$)/m export interface CliBinary {