Files
klz-cables.com/.pnpm-store/v10/files/22/ef4720dcbb948ff400f8387a1685b0e2349bafb65f260820501b6cd74b79cf9e61fcfd06c5e98467d1817c25ea251d367fca2f931a797828732c34b9348a53
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

133 lines
4.7 KiB
Plaintext

/**
* This was taken and modified from https://github.com/getsentry/sentry-javascript/blob/15256034ee8150a5b7dcb97d23eca1a5486f0cae/packages/nextjs/src/config/util.ts
*
* MIT License
*
* Copyright (c) 2012 Functional Software, Inc. dba Sentry
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
/**
* @param {string | undefined} input
* @returns {number}
*/
function _parseInt(input) {
return parseInt(input || '', 10);
}
/**
* Represents Semantic Versioning object
* @typedef {Object} SemVer
* @property {string} [buildmetadata]
* @property {number} [canaryVersion] - undefined if not a canary version
* @property {number} [major]
* @property {number} [minor]
* @property {number} [patch]
* @property {string} [prerelease]
*/ // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
const SEMVER_REGEXP = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*))*))?(?:\+([0-9a-z-]+(?:\.[0-9a-z-]+)*))?$/i;
/**
* Parses input into a SemVer interface
* @param {string} input - string representation of a semver version
* @returns {SemVer}
*/
export function parseSemver(input) {
const match = input.match(SEMVER_REGEXP) || [];
const major = _parseInt(match[1]);
const minor = _parseInt(match[2]);
const patch = _parseInt(match[3]);
const prerelease = match[4];
const canaryVersion = prerelease?.startsWith('canary.') ? parseInt(prerelease.split('.')[1] || '0', 10) : undefined;
return {
buildmetadata: match[5],
canaryVersion,
major: isNaN(major) ? undefined : major,
minor: isNaN(minor) ? undefined : minor,
patch: isNaN(patch) ? undefined : patch,
prerelease: match[4]
};
}
/**
* Returns the version of Next.js installed in the project, or undefined if it cannot be determined.
* @returns {SemVer | undefined}
*/
export function getNextjsVersion() {
try {
/** @type {string} */let pkgPath;
// Check if we're in ESM or CJS environment
if (typeof import.meta?.resolve === 'function') {
// ESM environment - use import.meta.resolve
const pkgUrl = import.meta.resolve('next/package.json');
// Use fileURLToPath for proper cross-platform path handling (Windows, macOS, Linux)
// new URL().pathname returns '/C:/path' on Windows which causes path resolution issues
pkgPath = fileURLToPath(pkgUrl);
} else {
// CJS environment - use require.resolve
pkgPath = require.resolve('next/package.json');
}
const pkgJson = JSON.parse(readFileSync(pkgPath, 'utf8'));
return parseSemver(pkgJson.version);
} catch (e) {
console.error('Payload: Error getting Next.js version', e);
return undefined;
}
}
/**
* Checks if the current Next.js version supports Turbopack externalize transitive dependencies.
* This was introduced in Next.js v16.1.0-canary.3
* @param {SemVer | undefined} version
* @returns {boolean}
*/
export function supportsTurbopackExternalizeTransitiveDependencies(version) {
if (!version) {
return false;
}
const {
canaryVersion,
major,
minor,
patch
} = version;
if (major === undefined || minor === undefined) {
return false;
}
if (major > 16) {
return true;
}
if (major === 16) {
if (minor > 1) {
return true;
}
if (minor === 1) {
// 16.1.1+ and canaries support this feature
if (patch > 0) {
return true;
}
if (canaryVersion !== undefined) {
// 16.1.0-canary.3+
return canaryVersion >= 3;
} else {
// Next.js 16.1.0
return true;
}
}
}
return false;
}
//# sourceMappingURL=withPayload.utils.js.map