From 687b10fdba0a80e886b9b0e1119b300f57cf8cab Mon Sep 17 00:00:00 2001 From: Onur Temizkan Date: Tue, 19 Sep 2023 11:33:33 +0100 Subject: [PATCH] fix(remix): Fix Remix version and TS checks. --- src/remix/remix-wizard.ts | 2 +- src/remix/sdk-setup.ts | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/remix/remix-wizard.ts b/src/remix/remix-wizard.ts index 47d7d322..e9464675 100644 --- a/src/remix/remix-wizard.ts +++ b/src/remix/remix-wizard.ts @@ -105,7 +105,7 @@ async function runRemixWizardWithTelemetry( await traceStep('Initialize Sentry on server entry', async () => { try { - await initializeSentryOnEntryServer(dsn, isTS, isV2); + await initializeSentryOnEntryServer(dsn, isV2, isTS); } catch (e) { clack.log.warn(`Could not initialize Sentry on server entry. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/`); diff --git a/src/remix/sdk-setup.ts b/src/remix/sdk-setup.ts index d9c6250d..e8b6fbe0 100644 --- a/src/remix/sdk-setup.ts +++ b/src/remix/sdk-setup.ts @@ -12,7 +12,7 @@ import * as url from 'url'; // @ts-expect-error - clack is ESM and TS complains about that. It works though import clack from '@clack/prompts'; import chalk from 'chalk'; -import { parse } from 'semver'; +import { gte, minVersion } from 'semver'; // @ts-expect-error - magicast is ESM and TS complains about that. It works though import { builders, generateCode, loadFile, writeFile } from 'magicast'; @@ -97,8 +97,17 @@ export function isRemixV2( packageJson: PackageDotJson, ): boolean { const remixVersion = getPackageVersion('@remix-run/react', packageJson); - const remixVersionMajor = remixVersion && parse(remixVersion)?.major; - const isV2Remix = remixVersionMajor && remixVersionMajor >= 2; + if (!remixVersion) { + return false; + } + + const minVer = minVersion(remixVersion); + + if (!minVer) { + return false; + } + + const isV2Remix = gte(minVer, '2.0.0'); return isV2Remix || remixConfig?.future?.v2_errorBoundary || false; }