Skip to content

A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.

chore: automate windows installer creation

towfiqi29656e178be4
diff --git a/.gitignore b/.gitignore
index 45a7c87..4fd0122 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,7 @@ dist-lib
*.AppImage
*.zsync
.DirIcon
+*.generated.iss
# Editor directories and files
diff --git a/installers/windows/build-installer.js b/installers/windows/build-installer.js
new file mode 100644
index 0000000..4ead1ef
--- /dev/null
+++ b/installers/windows/build-installer.js
@@ -0,0 +1,143 @@
+/**
+ * Build script for Windows Inno Setup Installer
+ *
+ * Usage:
+ * node build-installer.js # Build with defaults (Pluton)
+ * node build-installer.js --name pluton-pro # Build PRO edition
+ *
+ * This script:
+ * 1. Reads version from backend/package.json
+ * 2. Updates the .iss file with correct version and name
+ * 3. Runs Inno Setup compiler (iscc.exe)
+ */
+
+import { execSync } from "child_process";
+import { readFileSync, writeFileSync, existsSync } from "fs";
+import { join, dirname } from "path";
+import { fileURLToPath } from "url";
+
+const __filename = fileURLToPath(import.meta.url);
+const __dirname = dirname(__filename);
+const rootDir = join(__dirname, "..", "..");
+
+// Parse command line arguments
+const args = process.argv.slice(2);
+const nameIndex = args.indexOf("--name");
+const outputName =
+ nameIndex !== -1 && args[nameIndex + 1] ? args[nameIndex + 1] : "pluton";
+
+// Capitalize first letter and handle hyphenated names (pluton-pro -> Pluton Pro)
+const displayName = outputName
+ .split("-")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(" ");
+
+// Service name (no spaces, PascalCase: pluton-pro -> PlutonPro)
+const serviceName = outputName
+ .split("-")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join("");
+
+// Get version from backend/package.json
+const backendPackageJson = JSON.parse(
+ readFileSync(join(rootDir, "backend", "package.json"), "utf-8")
+);
+const version = backendPackageJson.version || "0.0.0";
+
+console.log("╔═══════════════════════════════════════════════════════════╗");
+console.log("║ 🪟 Windows Installer Build Script ║");
+console.log("╚═══════════════════════════════════════════════════════════╝\n");
+console.log(` Name: ${displayName}`);
+console.log(` Service: ${serviceName}`);
+console.log(` Version: ${version}`);
+console.log(` Output Name: ${outputName}`);
+console.log("");
+
+// Path to the template and working .iss file
+const templateIssPath = join(__dirname, "pluton-setup.iss");
+const workingIssPath = join(__dirname, "pluton-setup.generated.iss");
+
+// Check if template exists
+if (!existsSync(templateIssPath)) {
+ console.error(`❌ Template file not found: ${templateIssPath}`);
+ process.exit(1);
+}
+
+// Read the template
+let issContent = readFileSync(templateIssPath, "utf-8");
+
+// Replace the #define values at the top of the file
+issContent = issContent.replace(
+ /#define MyAppName ".*"/,
+ `#define MyAppName "${displayName}"`
+);
+issContent = issContent.replace(
+ /#define MyAppVersion ".*"/,
+ `#define MyAppVersion "${version}"`
+);
+issContent = issContent.replace(
+ /#define MyAppServiceName ".*"/,
+ `#define MyAppServiceName "${serviceName}"`
+);
+
+// Update file paths to use the correct distribution folder
+// pluton-win-x64 or pluton-pro-win-x64
+const distFolderName = `${outputName}-win-x64`;
+issContent = issContent.replace(/pluton-win-x64/g, distFolderName);
+
+// Update output filename
+issContent = issContent.replace(
+ /OutputBaseFilename=.*/,
+ `OutputBaseFilename=${outputName}-setup`
+);
+
+// Write the generated .iss file
+writeFileSync(workingIssPath, issContent, "utf-8");
+console.log(`✅ Generated: ${workingIssPath}`);
+
+// Find Inno Setup compiler
+const possibleIsccPaths = [
+ "C:\\Program Files (x86)\\Inno Setup 6\\ISCC.exe",
+ "C:\\Program Files\\Inno Setup 6\\ISCC.exe",
+ "C:\\Program Files (x86)\\Inno Setup 5\\ISCC.exe",
+ "C:\\Program Files\\Inno Setup 5\\ISCC.exe",
+];
+
+let isccPath = null;
+for (const path of possibleIsccPaths) {
+ if (existsSync(path)) {
+ isccPath = path;
+ break;
+ }
+}
+
+if (!isccPath) {
+ console.error("❌ Inno Setup compiler (ISCC.exe) not found!");
+ console.error(
+ " Please install Inno Setup from: https://jrsoftware.org/isdownload.php"
+ );
+ console.error(" Expected locations:");
+ possibleIsccPaths.forEach((p) => console.error(` - ${p}`));
+ process.exit(1);
+}
+
+console.log(`\n📦 Using Inno Setup: ${isccPath}`);
+console.log(`\n🔨 Building installer...\n`);
+
+// Run Inno Setup compiler
+try {
+ execSync(`"${isccPath}" "${workingIssPath}"`, {
+ stdio: "inherit",
+ cwd: __dirname,
+ });
+
+ console.log(
+ "\n╔═══════════════════════════════════════════════════════════╗"
+ );
+ console.log("║ ✅ Windows Installer Build Complete! ║");
+ console.log("╚═══════════════════════════════════════════════════════════╝");
+ console.log(`\n📁 Output: dist/installers/${outputName}-setup.exe\n`);
+} catch (error) {
+ console.error("\n❌ Failed to build installer");
+ process.exit(1);
+}
diff --git a/package.json b/package.json
index 626016a..bb95aa1 100644
--- a/package.json
+++ b/package.json
@@ -7,6 +7,7 @@
"build": "turbo run build",
"build:executables": "node ./scripts/build-executables.js",
"build:appimage:local": "wsl -e bash -c \"cd /mnt/f/JS/apps/pluton/codebase/pluton-app/pluton/installers/linux && ./build-appimage.sh all pluton\"",
+ "build:exe:local": "node ./installers/windows/build-installer.js",
"dev:backend": "pnpm --filter @plutonhq/core-backend dev",
"dev:frontend": "pnpm --filter @plutonhq/core-frontend dev",
"dev": "concurrently \"pnpm dev:backend\" \"pnpm dev:frontend\" "
diff --git a/scripts/build-executables.js b/scripts/build-executables.js
index 00d0ccc..526fd9d 100644
--- a/scripts/build-executables.js
+++ b/scripts/build-executables.js
@@ -16,9 +16,18 @@ const rootDir = resolve(__dirname, "..");
const backendDir = resolve(rootDir, "backend");
const frontendDir = resolve(rootDir, "frontend");
+// Parse command line arguments for output name
+// Usage: node build-executables.js [--name <output-name>]
+// Example: node build-executables.js --name pluton-pro
+const args = process.argv.slice(2);
+const nameIndex = args.indexOf("--name");
+const OUTPUT_NAME =
+ nameIndex !== -1 && args[nameIndex + 1] ? args[nameIndex + 1] : "pluton";
+
console.log("╔═══════════════════════════════════════════════════════════╗");
console.log("║ 🚀 Pluton Multi-Platform Executable Build Script ║");
console.log("╚═══════════════════════════════════════════════════════════╝\n");
+console.log(`📛 Output name: ${OUTPUT_NAME}\n`);
// Version configuration - Update these to use latest versions
const BETTER_SQLITE3_VERSION = "12.4.4"; // Latest: Check https://github.com/WiseLibs/better-sqlite3/releases
@@ -148,25 +157,42 @@ async function fileExists(path) {
}
/**
- * Step 1: Build Frontend
+ * Step 1: Install Dependencies
+ */
+async function installDependencies() {
+ console.log("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
+ console.log(
+ "📦 Step 1: Install Dependencies",
+ process.env.USE_LOCAL_CORE ? "(Skipped)" : ""
+ );
+ console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
+ // FOR PRO: If USE_LOCAL_CORE is set, skip installing dependencies
+ // As it breaks the linking to local core packages
+ if (!process.env.USE_LOCAL_CORE) {
+ exec("pnpm install", { cwd: rootDir });
+ console.log("✅ Dependencies installed");
+ }
+}
+
+/**
+ * Step 2: Build Frontend
*/
async function buildFrontend() {
console.log("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
- console.log("📦 Step 1: Building Frontend");
+ console.log("📦 Step 2: Building Frontend");
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
- exec("pnpm install", { cwd: frontendDir });
exec("pnpm run build", { cwd: frontendDir });
console.log("✅ Frontend build completed");
}
/**
- * Step 2: Copy Frontend Build to Backend
+ * Step 3: Copy Frontend Build to Backend
*/
async function copyFrontendToBackend() {
console.log("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
- console.log("📦 Step 2: Copying Frontend Build to Backend");
+ console.log("📦 Step 3: Copying Frontend Build to Backend");
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
const frontendDistDir = join(frontendDir, "dist");
@@ -205,19 +231,6 @@ async function copyDirectory(src, dest) {
}
}
-/**
- * Step 3: Install Backend Dependencies
- */
-async function installBackendDeps() {
- console.log("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
- console.log("📦 Step 3: Installing Backend Dependencies");
- console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
-
- exec("pnpm install", { cwd: backendDir });
-
- console.log("✅ Backend dependencies installed");
-}
-
/**
* Step 4: Compile TypeScript Backend
*/
@@ -642,9 +655,10 @@ async function generateExecutables() {
console.log(`\n🔨 Building executables for all platforms...`);
console.log(` Targets: ${pkgTargets}`);
+ console.log(` Output name: ${OUTPUT_NAME}`);
// Output to pkg-builds directory to avoid naming conflicts with distribution folders
- const pkgCommand = `npx pkg ${entryPoint} --targets ${pkgTargets} --output ${join(pkgBuildsDir, "pluton")} --compress GZip --public --public-packages "*" --options expose-gc --no-bytecode`;
+ const pkgCommand = `npx pkg ${entryPoint} --targets ${pkgTargets} --output ${join(pkgBuildsDir, OUTPUT_NAME)} --compress GZip --public --public-packages "*" --options expose-gc --no-bytecode`;
try {
exec(pkgCommand, { cwd: rootDir });
@@ -671,7 +685,7 @@ async function createDistributionPackages() {
for (const [platform, config] of Object.entries(targets)) {
console.log(`\n📦 Creating distribution package for ${platform}...`);
- const packageDir = join(executablesDir, `pluton-${platform}`);
+ const packageDir = join(executablesDir, `${OUTPUT_NAME}-${platform}`);
const packageBinariesDir = join(
packageDir,
"binaries",
@@ -683,7 +697,10 @@ async function createDistributionPackages() {
// Determine the source executable name generated by pkg
// pkg might strip the node version from the filename or add .exe on Windows
- let executableSource = join(pkgBuildsDir, `pluton-${config.pkgTarget}`);
+ let executableSource = join(
+ pkgBuildsDir,
+ `${OUTPUT_NAME}-${config.pkgTarget}`
+ );
// Check for variations if the exact target name doesn't exist
if (!(await fileExists(executableSource))) {
@@ -693,7 +710,7 @@ async function createDistributionPackages() {
}
// Try without the node version (e.g. pluton-linux-x64 instead of pluton-node24-linux-x64)
else {
- const simplifiedName = `pluton-${platform}`;
+ const simplifiedName = `${OUTPUT_NAME}-${platform}`;
const simplifiedSource = join(pkgBuildsDir, simplifiedName);
if (await fileExists(simplifiedSource)) {
@@ -837,7 +854,7 @@ async function createDistributionPackages() {
console.warn(` ⚠️ Drizzle migrations not found at ${drizzleSrc}`);
}
- console.log(`✅ Distribution package created: pluton-${platform}/`);
+ console.log(`✅ Distribution package created: ${OUTPUT_NAME}-${platform}/`);
}
console.log("\n✅ All distribution packages created successfully");
@@ -851,9 +868,9 @@ async function main() {
try {
const startTime = Date.now();
+ await installDependencies();
await buildFrontend();
await copyFrontendToBackend();
- await installBackendDeps();
await compileBackend();
await setupBetterSqlite3();
await setupKeyring();