mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 14:22:28 +08:00
chore: bump version to 0.4.5 (#346)
* chore: bump version to 0.4.5 and add desktop app to README * style: auto-format with Biome --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@@ -6,19 +6,19 @@
|
||||
const { cpSync, existsSync } = require("fs")
|
||||
const path = require("path")
|
||||
|
||||
module.exports = async function (context) {
|
||||
module.exports = async (context) => {
|
||||
const appOutDir = context.appOutDir
|
||||
const resourcesDir = path.join(
|
||||
appOutDir,
|
||||
context.packager.platform.name === "mac"
|
||||
? `${context.packager.appInfo.productFilename}.app/Contents/Resources`
|
||||
: "resources"
|
||||
: "resources",
|
||||
)
|
||||
const standaloneDir = path.join(resourcesDir, "standalone")
|
||||
const sourceNodeModules = path.join(
|
||||
context.packager.projectDir,
|
||||
"electron-standalone",
|
||||
"node_modules"
|
||||
"node_modules",
|
||||
)
|
||||
const targetNodeModules = path.join(standaloneDir, "node_modules")
|
||||
|
||||
@@ -29,11 +29,15 @@ module.exports = async function (context) {
|
||||
console.log("[afterPack] node_modules copied successfully")
|
||||
} else {
|
||||
console.error("[afterPack] Source or target directory not found!")
|
||||
console.error(` Source: ${sourceNodeModules} exists: ${existsSync(sourceNodeModules)}`)
|
||||
console.error(` Target dir: ${standaloneDir} exists: ${existsSync(standaloneDir)}`)
|
||||
console.error(
|
||||
` Source: ${sourceNodeModules} exists: ${existsSync(sourceNodeModules)}`,
|
||||
)
|
||||
console.error(
|
||||
` Target dir: ${standaloneDir} exists: ${existsSync(standaloneDir)}`,
|
||||
)
|
||||
throw new Error(
|
||||
"[afterPack] Failed: Required directories not found. " +
|
||||
"Ensure 'npm run electron:prepare' was run before building."
|
||||
"Ensure 'npm run electron:prepare' was run before building.",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
*/
|
||||
|
||||
import { spawn } from "node:child_process"
|
||||
import { fileURLToPath } from "node:url"
|
||||
import { existsSync, readFileSync, watch } from "node:fs"
|
||||
import path from "node:path"
|
||||
import os from "node:os"
|
||||
import path from "node:path"
|
||||
import { fileURLToPath } from "node:url"
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const rootDir = path.join(__dirname, "..")
|
||||
@@ -29,9 +29,18 @@ function getUserDataPath() {
|
||||
const appName = "next-ai-draw-io"
|
||||
switch (process.platform) {
|
||||
case "darwin":
|
||||
return path.join(os.homedir(), "Library", "Application Support", appName)
|
||||
return path.join(
|
||||
os.homedir(),
|
||||
"Library",
|
||||
"Application Support",
|
||||
appName,
|
||||
)
|
||||
case "win32":
|
||||
return path.join(process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming"), appName)
|
||||
return path.join(
|
||||
process.env.APPDATA ||
|
||||
path.join(os.homedir(), "AppData", "Roaming"),
|
||||
appName,
|
||||
)
|
||||
default:
|
||||
return path.join(os.homedir(), ".config", appName)
|
||||
}
|
||||
@@ -57,7 +66,7 @@ function loadPresetConfig() {
|
||||
return null
|
||||
}
|
||||
|
||||
const preset = data.presets.find(p => p.id === data.currentPresetId)
|
||||
const preset = data.presets.find((p) => p.id === data.currentPresetId)
|
||||
if (!preset) {
|
||||
console.log("📋 Active preset not found, using .env.local")
|
||||
return null
|
||||
@@ -207,31 +216,42 @@ async function main() {
|
||||
}
|
||||
|
||||
try {
|
||||
configWatcher = watch(configPath, { persistent: false }, async (eventType) => {
|
||||
if (eventType === "change" && !restartPending) {
|
||||
restartPending = true
|
||||
console.log("\n🔄 Preset configuration changed, restarting Next.js server...")
|
||||
configWatcher = watch(
|
||||
configPath,
|
||||
{ persistent: false },
|
||||
async (eventType) => {
|
||||
if (eventType === "change" && !restartPending) {
|
||||
restartPending = true
|
||||
console.log(
|
||||
"\n🔄 Preset configuration changed, restarting Next.js server...",
|
||||
)
|
||||
|
||||
// Kill current Next.js process
|
||||
nextProcess.kill()
|
||||
// Kill current Next.js process
|
||||
nextProcess.kill()
|
||||
|
||||
// Wait a bit for process to die
|
||||
await new Promise(r => setTimeout(r, 1000))
|
||||
// Wait a bit for process to die
|
||||
await new Promise((r) => setTimeout(r, 1000))
|
||||
|
||||
// Reload preset and restart
|
||||
const newPresetEnv = loadPresetConfig()
|
||||
nextProcess = startNextServer(newPresetEnv)
|
||||
// Reload preset and restart
|
||||
const newPresetEnv = loadPresetConfig()
|
||||
nextProcess = startNextServer(newPresetEnv)
|
||||
|
||||
try {
|
||||
await waitForServer(NEXT_URL)
|
||||
console.log("✅ Next.js server restarted with new configuration\n")
|
||||
} catch (err) {
|
||||
console.error("❌ Failed to restart Next.js:", err.message)
|
||||
try {
|
||||
await waitForServer(NEXT_URL)
|
||||
console.log(
|
||||
"✅ Next.js server restarted with new configuration\n",
|
||||
)
|
||||
} catch (err) {
|
||||
console.error(
|
||||
"❌ Failed to restart Next.js:",
|
||||
err.message,
|
||||
)
|
||||
}
|
||||
|
||||
restartPending = false
|
||||
}
|
||||
|
||||
restartPending = false
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
console.log("👀 Watching for preset configuration changes...")
|
||||
} catch (err) {
|
||||
// File might not exist yet, that's ok
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* that electron-builder can properly include
|
||||
*/
|
||||
|
||||
import { cpSync, rmSync, existsSync, mkdirSync } from "node:fs"
|
||||
import { cpSync, existsSync, mkdirSync, rmSync } from "node:fs"
|
||||
import { join } from "node:path"
|
||||
import { fileURLToPath } from "node:url"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user