dbdiff-app 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { execSync } from "child_process";
4
4
  import fs from "fs";
5
+ import os from "os";
5
6
  import path from "path";
6
7
  import { fileURLToPath } from "url";
7
8
 
@@ -26,58 +27,31 @@ const pkg = JSON.parse(
26
27
 
27
28
  console.log(`\nInstalling dbdiff v${pkg.version} from source...\n`);
28
29
 
29
- // Step 1: Install all dependencies (including devDependencies needed for building)
30
- console.log("Installing dependencies...");
31
- execSync("npm install --include=dev", { cwd: packageDir, stdio: "inherit" });
30
+ // When run via npx, the package lives inside node_modules/ which causes npm to
31
+ // hoist dependencies to the parent. electron-builder then can't find production
32
+ // deps to bundle into the app. Fix: copy to a standalone temp directory first.
33
+ const insideNodeModules = packageDir
34
+ .split(path.sep)
35
+ .includes("node_modules");
32
36
 
33
- // Step 2: Build the Electron app
34
- console.log("\nBuilding...");
35
- execSync("npm run build:electron", { cwd: packageDir, stdio: "inherit" });
37
+ let buildDir = packageDir;
36
38
 
37
- // Step 3: Find the built .app bundle
38
- const releaseDir = path.join(packageDir, "release");
39
- const entries = fs.readdirSync(releaseDir).filter((e) => e.startsWith("mac"));
40
- let appPath = null;
41
-
42
- for (const entry of entries) {
43
- const candidate = path.join(releaseDir, entry, "dbdiff.app");
44
- if (fs.existsSync(candidate)) {
45
- appPath = candidate;
46
- break;
47
- }
39
+ if (insideNodeModules) {
40
+ buildDir = fs.mkdtempSync(path.join(os.tmpdir(), "dbdiff-build-"));
41
+ console.log("Copying source to temporary build directory...");
42
+ execSync(`cp -R "${packageDir}/." "${buildDir}"`, { stdio: "inherit" });
48
43
  }
49
44
 
50
- if (!appPath) {
51
- console.error("Build failed — could not find dbdiff.app in release/");
52
- process.exit(1);
53
- }
54
-
55
- // Step 4: Install to /Applications
56
- const dest = "/Applications/dbdiff.app";
57
-
58
- let wasRunning = false;
59
45
  try {
60
- execSync("pkill -f '/Applications/dbdiff.app'", { stdio: "pipe" });
61
- wasRunning = true;
62
- console.log("\nQuit running dbdiff instance.");
63
- } catch {
64
- // Not running that's fine
65
- }
66
-
67
- if (fs.existsSync(dest)) {
68
- console.log("Removing existing /Applications/dbdiff.app...");
69
- execSync(`rm -rf "${dest}"`);
70
- }
71
-
72
- console.log(
73
- `Copying ${path.basename(path.dirname(appPath))}/dbdiff.app → /Applications/`,
74
- );
75
- execSync(`cp -R "${appPath}" "${dest}"`);
76
-
77
- console.log("\nInstalled dbdiff to /Applications/dbdiff.app");
78
- console.log("Launch it from Spotlight or your Applications folder.\n");
79
-
80
- if (wasRunning) {
81
- console.log("Reopening dbdiff...");
82
- execSync("open /Applications/dbdiff.app");
46
+ // Step 1: Install all dependencies (including devDependencies needed for building)
47
+ console.log("Installing dependencies...");
48
+ execSync("npm install --include=dev", { cwd: buildDir, stdio: "inherit" });
49
+
50
+ // Step 2: Build and install the Electron app
51
+ console.log("\nBuilding...");
52
+ execSync("npm run install-from-source", { cwd: buildDir, stdio: "inherit" });
53
+ } finally {
54
+ if (insideNodeModules) {
55
+ fs.rmSync(buildDir, { recursive: true, force: true });
56
+ }
83
57
  }
package/electron/main.js CHANGED
@@ -161,7 +161,10 @@ app.whenReady().then(() => {
161
161
  if (isMac) {
162
162
  app.dock.setIcon(path.join(__dirname, "icon.png"));
163
163
  }
164
- createWindow();
164
+ createWindow().catch((err) => {
165
+ console.error("Failed to create window:", err);
166
+ app.quit();
167
+ });
165
168
  });
166
169
 
167
170
  app.on("window-all-closed", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbdiff-app",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "A database client for PostgreSQL",
5
5
  "author": "Louis Arge",
6
6
  "type": "module",
@@ -32,7 +32,7 @@
32
32
  "typecheck": "tsc -p tsconfig.app.json --noEmit",
33
33
  "lint": "eslint .",
34
34
  "format": "prettier --write \"src/**/*.{ts,tsx}\" \"server/**/*.ts\"",
35
- "install-local-production": "npm run build:electron && node bin/install-local.js"
35
+ "install-from-source": "npm run build:electron && node bin/install-local.js"
36
36
  },
37
37
  "dependencies": {
38
38
  "@codemirror/lang-sql": "^6.10.0",