Add export runtime synchronization script and update build process
This commit is contained in:
parent
813ed998f5
commit
90a54cb791
3 changed files with 88 additions and 3 deletions
|
|
@ -6,7 +6,17 @@ const path = require("path")
|
|||
const afterPack = async (context) => {
|
||||
if (context.electronPlatformName === "darwin") {
|
||||
const appPath = context.appOutDir
|
||||
const fastapiPath = path.join(appPath, "Presenton.app/Contents/Resources/app/resources/fastapi/fastapi")
|
||||
const appBundleName = `${context.packager.appInfo.productFilename}.app`
|
||||
const resourcesRoot = path.join(
|
||||
appPath,
|
||||
appBundleName,
|
||||
"Contents",
|
||||
"Resources",
|
||||
"app",
|
||||
"resources"
|
||||
)
|
||||
const fastapiPath = path.join(resourcesRoot, "fastapi", "fastapi")
|
||||
const convertPath = path.join(resourcesRoot, "export", "py", "convert")
|
||||
|
||||
console.log("Setting executable permissions for FastAPI binary...")
|
||||
console.log("FastAPI path:", fastapiPath)
|
||||
|
|
@ -18,10 +28,25 @@ const afterPack = async (context) => {
|
|||
console.warn("⚠ FastAPI binary not found at:", fastapiPath)
|
||||
}
|
||||
|
||||
const fastapiDir = path.join(appPath, "Presenton.app/Contents/Resources/app/resources/fastapi")
|
||||
console.log("Setting executable permissions for export converter binary...")
|
||||
console.log("Converter path:", convertPath)
|
||||
|
||||
if (fs.existsSync(convertPath)) {
|
||||
fs.chmodSync(convertPath, 0o755)
|
||||
console.log("✓ Execute permissions set for converter")
|
||||
} else {
|
||||
console.warn("⚠ Converter binary not found at:", convertPath)
|
||||
}
|
||||
|
||||
const fastapiDir = path.join(resourcesRoot, "fastapi")
|
||||
if (fs.existsSync(fastapiDir)) {
|
||||
console.log("FastAPI directory contents:", fs.readdirSync(fastapiDir))
|
||||
}
|
||||
|
||||
const exportPyDir = path.join(resourcesRoot, "export", "py")
|
||||
if (fs.existsSync(exportPyDir)) {
|
||||
console.log("Export py directory contents:", fs.readdirSync(exportPyDir))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,10 +34,11 @@
|
|||
"build:ts": "rm -rf app_dist && tsc",
|
||||
"build:css": "tailwindcss -i ./resources/ui/assets/css/tailwind.import.css -o ./resources/ui/assets/css/tailwind.css --watch",
|
||||
"build:vectorstore": "cd servers/fastapi && uv run python build_vectorstore.py",
|
||||
"build:export-runtime": "node sync_export_runtime.js",
|
||||
"build:nextjs": "rm -rf resources/nextjs && cd servers/nextjs && cross-env BUILD_TARGET=electron npm run build && cp -r .next-build ../../resources/nextjs && cp -r app/presentation-templates ../../resources/nextjs/presentation-templates",
|
||||
"build:fastapi": "rm -rf resources/fastapi && npm run build:vectorstore && (cp ../servers/fastapi/alembic/versions/*.py servers/fastapi/alembic/versions/ 2>/dev/null || true) && cd servers/fastapi && uv run python -m PyInstaller --distpath ../../resources server.spec",
|
||||
"generate:version": "node generate_update.js",
|
||||
"build:electron": "npm run generate:version && rm -rf app_dist && tsc && node build.js",
|
||||
"build:electron": "npm run generate:version && npm run build:export-runtime && rm -rf app_dist && tsc && node build.js",
|
||||
"build:all": "npm run clean:build && npm run setup:env && npm run build:ts && npm run install:pyinstaller && npm run build:nextjs && npm run build:fastapi && npm run build:electron",
|
||||
"clean:build": "rm -rf resources/nextjs && rm -rf resources/fastapi && rm -rf app_dist"
|
||||
},
|
||||
|
|
|
|||
59
electron/sync_export_runtime.js
Normal file
59
electron/sync_export_runtime.js
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { spawnSync } = require("child_process");
|
||||
|
||||
const repoRoot = path.resolve(__dirname, "..");
|
||||
const exportProjectDir = path.join(repoRoot, "presenton-export-opensource");
|
||||
const sourceIndex = path.join(exportProjectDir, "dist", "index.js");
|
||||
const sourceConvert = path.join(exportProjectDir, "dist", "py", "convert");
|
||||
const targetRoot = path.join(__dirname, "resources", "export");
|
||||
const targetPyDir = path.join(targetRoot, "py");
|
||||
const targetIndex = path.join(targetRoot, "index.js");
|
||||
const targetConvert = path.join(targetPyDir, "convert");
|
||||
|
||||
function run(command, args, cwd) {
|
||||
const result = spawnSync(command, args, {
|
||||
cwd,
|
||||
stdio: "inherit",
|
||||
shell: process.platform === "win32",
|
||||
});
|
||||
|
||||
if (result.status !== 0) {
|
||||
throw new Error(`Command failed: ${command} ${args.join(" ")}`);
|
||||
}
|
||||
}
|
||||
|
||||
function ensureExists(filePath, label) {
|
||||
if (!fs.existsSync(filePath)) {
|
||||
throw new Error(`${label} not found at: ${filePath}`);
|
||||
}
|
||||
}
|
||||
|
||||
function copyFile(source, target) {
|
||||
fs.mkdirSync(path.dirname(target), { recursive: true });
|
||||
fs.copyFileSync(source, target);
|
||||
}
|
||||
|
||||
function chmodIfPossible(filePath) {
|
||||
if (process.platform !== "win32") {
|
||||
fs.chmodSync(filePath, 0o755);
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
console.log("[export-runtime] Building export runtime artifacts...");
|
||||
run("bun", ["run", "build:all"], exportProjectDir);
|
||||
|
||||
ensureExists(sourceIndex, "Export runtime JS bundle");
|
||||
ensureExists(sourceConvert, "Export runtime converter binary");
|
||||
|
||||
copyFile(sourceIndex, targetIndex);
|
||||
copyFile(sourceConvert, targetConvert);
|
||||
chmodIfPossible(targetConvert);
|
||||
|
||||
console.log("[export-runtime] Synced files:");
|
||||
console.log(` - ${targetIndex}`);
|
||||
console.log(` - ${targetConvert}`);
|
||||
}
|
||||
|
||||
main();
|
||||
Loading…
Add table
Reference in a new issue