Compare commits
8 Commits
v1.2.11-rc
...
v1.2.11-rc
| Author | SHA1 | Date | |
|---|---|---|---|
| b10dbcb23f | |||
| 65bb9c620a | |||
| 63853ffa89 | |||
| 9694c77ef7 | |||
| 2c11b5026a | |||
| eaa90c65f1 | |||
| 2a47d22e26 | |||
| 33d2d67774 |
@@ -1,5 +1,15 @@
|
||||
node_modules
|
||||
.next
|
||||
.DS_Store
|
||||
.git
|
||||
.gitignore
|
||||
.gitea
|
||||
.github
|
||||
public/uploads
|
||||
directus/uploads
|
||||
.turbo
|
||||
reference/
|
||||
.next
|
||||
!.next/cache
|
||||
.git
|
||||
.DS_Store
|
||||
|
||||
3
.env
3
.env
@@ -35,4 +35,5 @@ GATEKEEPER_PASSWORD=klz2026
|
||||
COOKIE_DOMAIN=localhost
|
||||
INFRA_DIRECTUS_URL=http://localhost:8059
|
||||
INFRA_DIRECTUS_TOKEN=59fb8f4c1a51b18fe28ad947f713914e
|
||||
GATEKEEPER_ORIGIN=http://klz.localhost
|
||||
GATEKEEPER_ORIGIN=http://klz.localhost
|
||||
OPENROUTER_API_KEY=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
|
||||
@@ -46,8 +46,19 @@ jobs:
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.REGISTRY_PASS }}
|
||||
|
||||
- name: Setup Turbo cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: .turbo
|
||||
key: ${{ runner.os }}-turbo-${{ github.ref_name }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-turbo-${{ github.ref_name }}-
|
||||
${{ runner.os }}-turbo-
|
||||
|
||||
- name: 🧪 QA Checks
|
||||
run: pnpm check:mdx && pnpm lint && pnpm typecheck && pnpm test
|
||||
env:
|
||||
TURBO_TELEMETRY_DISABLED: "1"
|
||||
run: npx turbo run check:mdx lint typecheck test --cache-dir=".turbo"
|
||||
|
||||
- name: 🏗️ Build
|
||||
run: pnpm build
|
||||
|
||||
@@ -171,15 +171,22 @@ jobs:
|
||||
echo "//${{ vars.REGISTRY_HOST || 'npm.infra.mintel.me' }}/:_authToken=${{ secrets.REGISTRY_PASS }}" >> .npmrc
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Setup Turbo cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: .turbo
|
||||
key: ${{ runner.os }}-turbo-${{ github.ref_name }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-turbo-${{ github.ref_name }}-
|
||||
${{ runner.os }}-turbo-
|
||||
|
||||
- name: 🔒 Security Audit
|
||||
run: pnpm audit --audit-level high
|
||||
- name: 🧪 QA Checks
|
||||
if: github.event.inputs.skip_checks != 'true'
|
||||
run: |
|
||||
pnpm lint
|
||||
pnpm check:spell
|
||||
pnpm typecheck
|
||||
pnpm test
|
||||
env:
|
||||
TURBO_TELEMETRY_DISABLED: "1"
|
||||
run: npx turbo run lint check:spell typecheck test --cache-dir=".turbo"
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────────────────
|
||||
# JOB 3: Build & Push
|
||||
@@ -205,6 +212,8 @@ jobs:
|
||||
push: true
|
||||
provenance: false
|
||||
platforms: linux/arm64
|
||||
cache-from: type=gha,scope=nextjs-build-${{ needs.prepare.outputs.target }}
|
||||
cache-to: type=gha,mode=max,scope=nextjs-build-${{ needs.prepare.outputs.target }}
|
||||
build-args: |
|
||||
NEXT_PUBLIC_BASE_URL=${{ needs.prepare.outputs.next_public_url }}
|
||||
NEXT_PUBLIC_TARGET=${{ needs.prepare.outputs.target }}
|
||||
|
||||
10
.gitignore
vendored
10
.gitignore
vendored
@@ -1,6 +1,7 @@
|
||||
node_modules
|
||||
.next
|
||||
.DS_Store
|
||||
public/uploads
|
||||
|
||||
# Lighthouse CI
|
||||
.lighthouseci/
|
||||
@@ -18,4 +19,11 @@ directus/uploads
|
||||
# Pa11y CI
|
||||
.pa11yci/
|
||||
|
||||
.htmlvalidate-tmp
|
||||
.htmlvalidate-tmp
|
||||
|
||||
# Turborepo
|
||||
.turbo
|
||||
|
||||
# Test Outputs
|
||||
html-errors*.json
|
||||
reference/
|
||||
@@ -41,7 +41,10 @@ CMD ["pnpm", "dev:local"]
|
||||
# Build application
|
||||
# Stage 3: Builder (Production)
|
||||
FROM base AS builder
|
||||
RUN pnpm build
|
||||
RUN --mount=type=cache,target=/app/.next/cache,id=nextjs-cache \
|
||||
pnpm build && \
|
||||
mkdir -p /app/.next-cache-tmp && \
|
||||
cp -r /app/.next/cache/* /app/.next-cache-tmp/ || true
|
||||
|
||||
# Stage 3: Runner
|
||||
FROM registry.infra.mintel.me/mintel/runtime:v1.7.10 AS runner
|
||||
@@ -60,6 +63,6 @@ ENV NODE_ENV=production
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/cache ./.next/cache
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next-cache-tmp ./.next/cache
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
|
||||
@@ -16,12 +16,18 @@ export default function Error({
|
||||
const t = useTranslations('Error');
|
||||
|
||||
useEffect(() => {
|
||||
// Treat "Failed to find Server Action" as a deployment sync issue and reload
|
||||
if (error?.message?.includes('Failed to find Server Action')) {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
|
||||
const services = getAppServices();
|
||||
services.errors.captureException(error);
|
||||
services.logger.error('Application error caught by boundary', {
|
||||
message: error.message,
|
||||
stack: error.stack,
|
||||
digest: error.digest
|
||||
message: error?.message || 'Unknown error',
|
||||
stack: error?.stack,
|
||||
digest: error?.digest,
|
||||
});
|
||||
}, [error]);
|
||||
|
||||
@@ -36,19 +42,14 @@ export default function Error({
|
||||
<Heading level={1} className="text-6xl md:text-8xl font-bold mb-2 text-saturated">
|
||||
500
|
||||
</Heading>
|
||||
<Scribble
|
||||
variant="underline"
|
||||
className="w-full h-6 -bottom-2 left-0 text-saturated/40"
|
||||
/>
|
||||
<Scribble variant="underline" className="w-full h-6 -bottom-2 left-0 text-saturated/40" />
|
||||
</div>
|
||||
|
||||
<Heading level={2} className="text-2xl md:text-3xl font-bold mb-4">
|
||||
{t('title')}
|
||||
</Heading>
|
||||
|
||||
<p className="text-white/60 mb-10 max-w-md text-lg">
|
||||
{t('description')}
|
||||
</p>
|
||||
|
||||
<p className="text-white/60 mb-10 max-w-md text-lg">{t('description')}</p>
|
||||
|
||||
<div className="flex flex-col sm:flex-row gap-4">
|
||||
<Button onClick={() => reset()} variant="saturated" size="lg">
|
||||
|
||||
@@ -223,7 +223,7 @@ export default async function ProductPage({ params }: ProductPageProps) {
|
||||
href={`/${locale}/${await mapFileSlugToTranslated('products', locale)}`}
|
||||
className="hover:text-accent transition-colors"
|
||||
>
|
||||
{t.has('breadcrumb') ? t('breadcrumb') : t('title').replace(/<[^>]*>/g, '')}
|
||||
{t.has('breadcrumb') ? t('breadcrumb') : 'Products'}
|
||||
</Link>
|
||||
<span className="mx-3 opacity-30">/</span>
|
||||
<span className="text-white/90">{categoryTitle}</span>
|
||||
@@ -384,7 +384,7 @@ export default async function ProductPage({ params }: ProductPageProps) {
|
||||
href={`/${locale}/${await mapFileSlugToTranslated('products', locale)}`}
|
||||
className="hover:text-accent transition-colors"
|
||||
>
|
||||
{t.has('breadcrumb') ? t('breadcrumb') : t('title').replace(/<[^>]*>/g, '')}
|
||||
{t.has('breadcrumb') ? t('breadcrumb') : 'Products'}
|
||||
</Link>
|
||||
<span className="mx-4 opacity-20">/</span>
|
||||
<Link
|
||||
|
||||
@@ -12,7 +12,11 @@ export default async function Image({ params }: { params: Promise<{ locale: stri
|
||||
const t = await getTranslations({ locale, namespace: 'Products' });
|
||||
const fonts = await getOgFonts();
|
||||
|
||||
const title = t('meta.title') || t('breadcrumb') || t('title').replace(/<[^>]*>/g, '');
|
||||
const title = t.has('meta.title')
|
||||
? t('meta.title')
|
||||
: t.has('breadcrumb')
|
||||
? t('breadcrumb')
|
||||
: 'Products';
|
||||
const description = t('meta.description') || t('subtitle');
|
||||
|
||||
return new ImageResponse(
|
||||
|
||||
@@ -17,7 +17,11 @@ interface ProductsPageProps {
|
||||
export async function generateMetadata({ params }: ProductsPageProps): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
const t = await getTranslations({ locale, namespace: 'Products' });
|
||||
const title = t('meta.title') || t('breadcrumb') || t('title').replace(/<[^>]*>/g, '');
|
||||
const title = t.has('meta.title')
|
||||
? t('meta.title')
|
||||
: t.has('breadcrumb')
|
||||
? t('breadcrumb')
|
||||
: 'Products';
|
||||
const description = t('meta.description') || t('subtitle');
|
||||
return {
|
||||
title,
|
||||
|
||||
@@ -43,7 +43,11 @@ export default function ProductCategories() {
|
||||
|
||||
return (
|
||||
<Section className="bg-neutral-light py-0 md:py-0 lg:py-0 -mt-px">
|
||||
{t('title') && <h2 className="sr-only">{t('title')}</h2>}
|
||||
{t.has('title') && (
|
||||
<h2 className="sr-only">
|
||||
{t.rich('title', { green: (chunks: any) => <span>{chunks}</span> })}
|
||||
</h2>
|
||||
)}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4">
|
||||
{categories.map((category, idx) => (
|
||||
<Link
|
||||
|
||||
@@ -155,7 +155,7 @@ services:
|
||||
- default
|
||||
|
||||
klz-imgproxy:
|
||||
image: darthsim/imgproxy:latest
|
||||
image: registry.infra.mintel.me/mintel/image-processor:latest
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- default
|
||||
@@ -165,12 +165,10 @@ services:
|
||||
- "cms.klz.localhost:host-gateway"
|
||||
- "host.docker.internal:host-gateway"
|
||||
environment:
|
||||
IMGPROXY_URL_MAPPING: "${NEXT_PUBLIC_BASE_URL}:http://klz-app:3000,${DIRECTUS_URL}:http://klz-cms:8055"
|
||||
IMGPROXY_USE_ETAG: "true"
|
||||
IMGPROXY_MAX_SRC_RESOLUTION: 20
|
||||
IMGPROXY_IGNORE_SSL_ERRORS: "true"
|
||||
OPENROUTER_API_KEY: ${OPENROUTER_API_KEY}
|
||||
# explicitly map localhost, production and staging to bypass gatekeeper
|
||||
IMGPROXY_URL_MAPPING: "https://staging.klz-cables.com:http://klz-app:3000,https://klz-cables.com:http://klz-app:3000,https://${TRAEFIK_HOST:-klz.localhost}:http://klz-app:3000,${DIRECTUS_URL}:http://klz-cms:8055,https://cms.klz-cables.com:http://klz-cms:8055"
|
||||
IMGPROXY_LOG_LEVEL: debug
|
||||
IMGPROXY_ALLOW_LOCAL_NETWORKS: "true"
|
||||
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
|
||||
@@ -39,34 +39,21 @@ export function getImgproxyUrl(src: string, options: ImgproxyOptions = {}): stri
|
||||
// Also handle direct container names if needed
|
||||
}
|
||||
|
||||
const {
|
||||
width = 0,
|
||||
height = 0,
|
||||
resizing_type = 'fit',
|
||||
gravity = 'sm', // Default to smart gravity
|
||||
enlarge = false,
|
||||
extension = '',
|
||||
} = options;
|
||||
const { width = 0, height = 0, enlarge = false, extension = '' } = options;
|
||||
|
||||
// Processing options
|
||||
// Format: /rs:<type>:<width>:<height>:<enlarge>/g:<gravity>
|
||||
const processingOptions = [
|
||||
`rs:${resizing_type}:${width}:${height}:${enlarge ? 1 : 0}`,
|
||||
`g:${gravity}`,
|
||||
].join('/');
|
||||
let quality = 80;
|
||||
if (extension) quality = 90;
|
||||
|
||||
// Using Base64 encoding for the source URL.
|
||||
// This completely eliminates any risk of intermediate proxies (Traefik/Next.js)
|
||||
// URL-decoding the path, which corrupts the double-slash (// to /) and causes 403 errors.
|
||||
// Imgproxy expects URL-safe Base64 (RFC 4648) without padding.
|
||||
const b64 =
|
||||
typeof window === 'undefined'
|
||||
? Buffer.from(absoluteSrc).toString('base64')
|
||||
: btoa(unescape(encodeURIComponent(absoluteSrc)));
|
||||
// Re-map imgproxy URL to our new parameter structure
|
||||
// e.g. /process?url=...&w=...&h=...&q=...&format=...
|
||||
const queryParams = new URLSearchParams({
|
||||
url: absoluteSrc,
|
||||
});
|
||||
|
||||
const urlSafeB64 = b64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
||||
if (width > 0) queryParams.set('w', width.toString());
|
||||
if (height > 0) queryParams.set('h', height.toString());
|
||||
if (extension) queryParams.set('format', extension.replace('.', ''));
|
||||
if (quality) queryParams.set('q', quality.toString());
|
||||
|
||||
const suffix = extension ? `.${extension}` : '';
|
||||
|
||||
return `${baseUrl}/unsafe/${processingOptions}/${urlSafeB64}${suffix}`;
|
||||
return `${baseUrl}/process?${queryParams.toString()}`;
|
||||
}
|
||||
|
||||
2
next-env.d.ts
vendored
2
next-env.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
import "./.next/dev/types/routes.d.ts";
|
||||
import "./.next/types/routes.d.ts";
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"name": "klz-cables-nextjs",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@10.18.3",
|
||||
"dependencies": {
|
||||
"@directus/sdk": "^21.0.0",
|
||||
"@mintel/mail": "1.8.3",
|
||||
@@ -79,6 +80,7 @@
|
||||
"start-server-and-test": "^2.1.3",
|
||||
"tailwindcss": "^4.1.18",
|
||||
"tsx": "^4.21.0",
|
||||
"turbo": "^2.8.10",
|
||||
"typescript": "^5.7.2",
|
||||
"vitest": "^4.0.16"
|
||||
},
|
||||
@@ -124,7 +126,7 @@
|
||||
"prepare": "husky",
|
||||
"preinstall": "npx only-allow pnpm"
|
||||
},
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1-rc.0",
|
||||
"pnpm": {
|
||||
"overrides": {
|
||||
"next": "16.1.6",
|
||||
|
||||
64
pnpm-lock.yaml
generated
64
pnpm-lock.yaml
generated
@@ -235,6 +235,9 @@ importers:
|
||||
tsx:
|
||||
specifier: ^4.21.0
|
||||
version: 4.21.0
|
||||
turbo:
|
||||
specifier: ^2.8.10
|
||||
version: 2.8.10
|
||||
typescript:
|
||||
specifier: ^5.7.2
|
||||
version: 5.9.3
|
||||
@@ -7166,6 +7169,40 @@ packages:
|
||||
engines: {node: '>=18.0.0'}
|
||||
hasBin: true
|
||||
|
||||
turbo-darwin-64@2.8.10:
|
||||
resolution: {integrity: sha512-A03fXh+B7S8mL3PbdhTd+0UsaGrhfyPkODvzBDpKRY7bbeac4MDFpJ7I+Slf2oSkCEeSvHKR7Z4U71uKRUfX7g==}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
turbo-darwin-arm64@2.8.10:
|
||||
resolution: {integrity: sha512-sidzowgWL3s5xCHLeqwC9M3s9M0i16W1nuQF3Mc7fPHpZ+YPohvcbVFBB2uoRRHYZg6yBnwD4gyUHKTeXfwtXA==}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
turbo-linux-64@2.8.10:
|
||||
resolution: {integrity: sha512-YK9vcpL3TVtqonB021XwgaQhY9hJJbKKUhLv16osxV0HkcQASQWUqR56yMge7puh6nxU67rQlTq1b7ksR1T3KA==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
turbo-linux-arm64@2.8.10:
|
||||
resolution: {integrity: sha512-3+j2tL0sG95iBJTm+6J8/45JsETQABPqtFyYjVjBbi6eVGdtNTiBmHNKrbvXRlQ3ZbUG75bKLaSSDHSEEN+btQ==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
turbo-windows-64@2.8.10:
|
||||
resolution: {integrity: sha512-hdeF5qmVY/NFgiucf8FW0CWJWtyT2QPm5mIsX0W1DXAVzqKVXGq+Zf+dg4EUngAFKjDzoBeN6ec2Fhajwfztkw==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
turbo-windows-arm64@2.8.10:
|
||||
resolution: {integrity: sha512-QGdr/Q8LWmj+ITMkSvfiz2glf0d7JG0oXVzGL3jxkGqiBI1zXFj20oqVY0qWi+112LO9SVrYdpHS0E/oGFrMbQ==}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
turbo@2.8.10:
|
||||
resolution: {integrity: sha512-OxbzDES66+x7nnKGg2MwBA1ypVsZoDTLHpeaP4giyiHSixbsiTaMyeJqbEyvBdp5Cm28fc+8GG6RdQtic0ijwQ==}
|
||||
hasBin: true
|
||||
|
||||
type-check@0.4.0:
|
||||
resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
|
||||
engines: {node: '>= 0.8.0'}
|
||||
@@ -15498,6 +15535,33 @@ snapshots:
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.3
|
||||
|
||||
turbo-darwin-64@2.8.10:
|
||||
optional: true
|
||||
|
||||
turbo-darwin-arm64@2.8.10:
|
||||
optional: true
|
||||
|
||||
turbo-linux-64@2.8.10:
|
||||
optional: true
|
||||
|
||||
turbo-linux-arm64@2.8.10:
|
||||
optional: true
|
||||
|
||||
turbo-windows-64@2.8.10:
|
||||
optional: true
|
||||
|
||||
turbo-windows-arm64@2.8.10:
|
||||
optional: true
|
||||
|
||||
turbo@2.8.10:
|
||||
optionalDependencies:
|
||||
turbo-darwin-64: 2.8.10
|
||||
turbo-darwin-arm64: 2.8.10
|
||||
turbo-linux-64: 2.8.10
|
||||
turbo-linux-arm64: 2.8.10
|
||||
turbo-windows-64: 2.8.10
|
||||
turbo-windows-arm64: 2.8.10
|
||||
|
||||
type-check@0.4.0:
|
||||
dependencies:
|
||||
prelude-ls: 1.2.1
|
||||
|
||||
20
turbo.json
Normal file
20
turbo.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"$schema": "https://turbo.build/schema.json",
|
||||
"tasks": {
|
||||
"lint": {
|
||||
"outputs": []
|
||||
},
|
||||
"typecheck": {
|
||||
"outputs": []
|
||||
},
|
||||
"test": {
|
||||
"outputs": []
|
||||
},
|
||||
"check:spell": {
|
||||
"outputs": []
|
||||
},
|
||||
"check:mdx": {
|
||||
"outputs": []
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user