mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 14:22:28 +08:00
chore: clean up root folder by relocating config files (#448)
* chore: clean up root folder by moving config files - Move renovate.json to .github/renovate.json - Move electron-builder.yml to electron/electron-builder.yml - Move electron.d.ts to electron/electron.d.ts - Delete proxy.ts (unused dead code) - Update package.json dist scripts with --config flag - Use tsconfig.json files array for electron.d.ts (bypasses exclude) Reduces git-tracked root files from 23 to 19. * chore: regenerate package-lock.json to fix CI * fix: regenerate package-lock.json with cross-platform deps
This commit is contained in:
0
renovate.json → .github/renovate.json
vendored
0
renovate.json → .github/renovate.json
vendored
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -29,7 +29,7 @@ jobs:
|
|||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm install
|
||||||
|
|
||||||
- name: Type check
|
- name: Type check
|
||||||
run: npx tsc --noEmit
|
run: npx tsc --noEmit
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ WORKDIR /app
|
|||||||
COPY package.json package-lock.json* ./
|
COPY package.json package-lock.json* ./
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN npm ci
|
RUN npm install
|
||||||
|
|
||||||
# Stage 2: Build application
|
# Stage 2: Build application
|
||||||
FROM node:24-alpine AS builder
|
FROM node:24-alpine AS builder
|
||||||
|
|||||||
0
electron.d.ts → electron/electron.d.ts
vendored
0
electron.d.ts → electron/electron.d.ts
vendored
42926
package-lock.json
generated
42926
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -21,11 +21,11 @@
|
|||||||
"electron:compile": "npx esbuild electron/main/index.ts electron/preload/index.ts electron/preload/settings.ts --bundle --platform=node --outdir=dist-electron --external:electron --sourcemap --packages=external && npx shx cp -r electron/settings dist-electron/",
|
"electron:compile": "npx esbuild electron/main/index.ts electron/preload/index.ts electron/preload/settings.ts --bundle --platform=node --outdir=dist-electron --external:electron --sourcemap --packages=external && npx shx cp -r electron/settings dist-electron/",
|
||||||
"electron:start": "npx cross-env NODE_ENV=development npx electron .",
|
"electron:start": "npx cross-env NODE_ENV=development npx electron .",
|
||||||
"electron:prepare": "node scripts/prepare-electron-build.mjs",
|
"electron:prepare": "node scripts/prepare-electron-build.mjs",
|
||||||
"dist": "npm run electron:build && npm run electron:prepare && npx electron-builder",
|
"dist": "npm run electron:build && npm run electron:prepare && npx electron-builder --config electron/electron-builder.yml",
|
||||||
"dist:mac": "npm run electron:build && npm run electron:prepare && npx electron-builder --mac",
|
"dist:mac": "npm run electron:build && npm run electron:prepare && npx electron-builder --config electron/electron-builder.yml --mac",
|
||||||
"dist:win": "npm run electron:build && npm run electron:prepare && npx electron-builder --win",
|
"dist:win": "npm run electron:build && npm run electron:prepare && npx electron-builder --config electron/electron-builder.yml --win",
|
||||||
"dist:linux": "npm run electron:build && npm run electron:prepare && npx electron-builder --linux",
|
"dist:linux": "npm run electron:build && npm run electron:prepare && npx electron-builder --config electron/electron-builder.yml --linux",
|
||||||
"dist:all": "npm run electron:build && npm run electron:prepare && npx electron-builder --mac --win --linux"
|
"dist:all": "npm run electron:build && npm run electron:prepare && npx electron-builder --config electron/electron-builder.yml --mac --win --linux"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ai-sdk/amazon-bedrock": "^4.0.1",
|
"@ai-sdk/amazon-bedrock": "^4.0.1",
|
||||||
|
|||||||
63
proxy.ts
63
proxy.ts
@@ -1,63 +0,0 @@
|
|||||||
import { match as matchLocale } from "@formatjs/intl-localematcher"
|
|
||||||
import Negotiator from "negotiator"
|
|
||||||
import type { NextRequest } from "next/server"
|
|
||||||
import { NextResponse } from "next/server"
|
|
||||||
import { i18n } from "./lib/i18n/config"
|
|
||||||
|
|
||||||
function getLocale(request: NextRequest): string | undefined {
|
|
||||||
// Negotiator expects plain object so we need to transform headers
|
|
||||||
const negotiatorHeaders: Record<string, string> = {}
|
|
||||||
request.headers.forEach((value, key) => {
|
|
||||||
negotiatorHeaders[key] = value
|
|
||||||
})
|
|
||||||
|
|
||||||
// @ts-expect-error locales are readonly
|
|
||||||
const locales: string[] = i18n.locales
|
|
||||||
|
|
||||||
// Use negotiator and intl-localematcher to get best locale
|
|
||||||
const languages = new Negotiator({ headers: negotiatorHeaders }).languages(
|
|
||||||
locales,
|
|
||||||
)
|
|
||||||
|
|
||||||
const locale = matchLocale(languages, locales, i18n.defaultLocale)
|
|
||||||
|
|
||||||
return locale
|
|
||||||
}
|
|
||||||
|
|
||||||
export function proxy(request: NextRequest) {
|
|
||||||
const pathname = request.nextUrl.pathname
|
|
||||||
|
|
||||||
// Skip API routes, static files, and Next.js internals
|
|
||||||
if (
|
|
||||||
pathname.startsWith("/api/") ||
|
|
||||||
pathname.startsWith("/_next/") ||
|
|
||||||
pathname.includes("/favicon") ||
|
|
||||||
/\.(.*)$/.test(pathname)
|
|
||||||
) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if there is any supported locale in the pathname
|
|
||||||
const pathnameIsMissingLocale = i18n.locales.every(
|
|
||||||
(locale) =>
|
|
||||||
!pathname.startsWith(`/${locale}/`) && pathname !== `/${locale}`,
|
|
||||||
)
|
|
||||||
|
|
||||||
// Redirect if there is no locale
|
|
||||||
if (pathnameIsMissingLocale) {
|
|
||||||
const locale = getLocale(request)
|
|
||||||
|
|
||||||
// Redirect to localized path
|
|
||||||
return NextResponse.redirect(
|
|
||||||
new URL(
|
|
||||||
`/${locale}${pathname.startsWith("/") ? "" : "/"}${pathname}`,
|
|
||||||
request.url,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const config = {
|
|
||||||
// Matcher ignoring `/_next/` and `/api/`
|
|
||||||
matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],
|
|
||||||
}
|
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
"@/*": ["./*"]
|
"@/*": ["./*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"files": ["electron/electron.d.ts"],
|
||||||
"include": [
|
"include": [
|
||||||
"next-env.d.ts",
|
"next-env.d.ts",
|
||||||
"**/*.ts",
|
"**/*.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user