mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-26 13:19:34 +07:00
fix: scripts support win32 (#12613)
Co-authored-by: Innei <tukon479@gmail.com>
This commit is contained in:
2
.github/workflows/deploy-device-gateway.yml
vendored
2
.github/workflows/deploy-device-gateway.yml
vendored
@@ -8,7 +8,7 @@ on:
|
||||
branches: [canary]
|
||||
paths:
|
||||
- 'apps/device-gateway/**'
|
||||
workflow_dispatch:
|
||||
workflow_dispatch: {}
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "wrangler dev",
|
||||
"deploy": "wrangler deploy",
|
||||
"dev": "wrangler dev",
|
||||
"type-check": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { DurableObject } from 'cloudflare:workers';
|
||||
|
||||
import { DeviceAttachment, Env } from './types';
|
||||
import type { DeviceAttachment, Env } from './types';
|
||||
|
||||
export class DeviceGatewayDO extends DurableObject<Env> {
|
||||
private pendingRequests = new Map<
|
||||
@@ -95,7 +95,11 @@ export class DeviceGatewayDO extends DurableObject<Env> {
|
||||
);
|
||||
}
|
||||
|
||||
const { deviceId, timeout = 30_000, toolCall } = (await request.json()) as {
|
||||
const {
|
||||
deviceId,
|
||||
timeout = 30_000,
|
||||
toolCall,
|
||||
} = (await request.json()) as {
|
||||
deviceId?: string;
|
||||
timeout?: number;
|
||||
toolCall: unknown;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { importJWK, jwtVerify } from 'jose';
|
||||
|
||||
import { Env } from './types';
|
||||
import type { Env } from './types';
|
||||
|
||||
let cachedKey: CryptoKey | null = null;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { verifyDesktopToken } from './auth';
|
||||
import { DeviceGatewayDO } from './DeviceGatewayDO';
|
||||
import { Env } from './types';
|
||||
import type { Env } from './types';
|
||||
|
||||
export { DeviceGatewayDO };
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
"build:docker": "pnpm run build:spa && pnpm run build:spa:mobile && pnpm run build:spa:copy && cross-env NODE_OPTIONS=--max-old-space-size=8192 DOCKER=true next build && pnpm run build-sitemap",
|
||||
"build:next": "cross-env NODE_OPTIONS=--max-old-space-size=6144 next build",
|
||||
"build:spa": "rm -rf public/spa && cross-env NODE_OPTIONS=--max-old-space-size=6144 vite build",
|
||||
"build:spa:copy": "mkdir -p public/spa && for dir in assets i18n vendor; do ([ -d dist/desktop/$dir ] && cp -r dist/desktop/$dir public/spa/ || true) && ([ -d dist/mobile/$dir ] && cp -r dist/mobile/$dir public/spa/ || true); done && tsx scripts/generateSpaTemplates.mts",
|
||||
"build:spa:copy": "tsx scripts/copySpaBuild.mts && tsx scripts/generateSpaTemplates.mts",
|
||||
"build:spa:mobile": "cross-env NODE_OPTIONS=--max-old-space-size=8192 MOBILE=true vite build",
|
||||
"build:vercel": "bun run build && bun run db:migrate",
|
||||
"build-migrate-db": "bun run db:migrate",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist"
|
||||
},
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
|
||||
21
scripts/copySpaBuild.mts
Normal file
21
scripts/copySpaBuild.mts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { cpSync, existsSync, mkdirSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
const root = path.resolve(import.meta.dirname, '..');
|
||||
const spaDir = path.resolve(root, 'public/spa');
|
||||
const distDirs = ['desktop', 'mobile'] as const;
|
||||
const copyDirs = ['assets', 'i18n', 'vendor'] as const;
|
||||
|
||||
mkdirSync(spaDir, { recursive: true });
|
||||
|
||||
for (const distDir of distDirs) {
|
||||
for (const dir of copyDirs) {
|
||||
const sourceDir = path.resolve(root, `dist/${distDir}/${dir}`);
|
||||
const targetDir = path.resolve(spaDir, dir);
|
||||
|
||||
if (!existsSync(sourceDir)) continue;
|
||||
|
||||
cpSync(sourceDir, targetDir, { recursive: true });
|
||||
console.log(`Copied dist/${distDir}/${dir} -> public/spa/${dir}`);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { type ChildProcess, spawn } from 'node:child_process';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import net from 'node:net';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
const NEXT_HOST = 'localhost';
|
||||
|
||||
@@ -17,7 +17,9 @@ const resolveNextPort = (): number => {
|
||||
const match = devNext.match(/(?:--port|-p)\s+(\d+)/);
|
||||
if (match) return Number(match[1]);
|
||||
}
|
||||
} catch { /* fallback */ }
|
||||
} catch {
|
||||
/* fallback */
|
||||
}
|
||||
return 3010;
|
||||
};
|
||||
|
||||
@@ -36,6 +38,7 @@ const runNpmScript = (scriptName: string) =>
|
||||
spawn(npmCommand, ['run', scriptName], {
|
||||
env: process.env,
|
||||
stdio: 'inherit',
|
||||
shell: process.platform === 'win32',
|
||||
});
|
||||
|
||||
const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
Reference in New Issue
Block a user