Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Liuliu/windows build #10

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added build/appx/LargeTile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/appx/SmallTile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/appx/SplashScreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/appx/Square150x150Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/appx/Square44x44Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/appx/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/appx/Wide310x150Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/appx/icon.ico
Binary file not shown.
Binary file added build/appx/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed build/icon.icns
Binary file not shown.
Binary file modified build/icon.ico
Binary file not shown.
Binary file added build/mac/AppIcon.icns
Binary file not shown.
Binary file added build/mac/AppleDevelopment.provisionprofile
Binary file not shown.
Binary file added build/mac/Assets.car
Binary file not shown.
Binary file added build/mac/MacAppStore.provisionprofile
Binary file not shown.
12 changes: 12 additions & 0 deletions build/mac/entitlements.inherit.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
11 changes: 11 additions & 0 deletions build/mac/entitlements.mas.inherit.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.inherit</key>
<true/>

</dict>
</plist>
18 changes: 18 additions & 0 deletions build/mac/entitlements.mas.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>FK9YU86WZ5.com.dolthub.dolt-workbench</string>
</array>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
</dict>
</plist>
18 changes: 18 additions & 0 deletions build/mac/entitlements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
Binary file added build/mac/icon.iconset/icon_128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/icon_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/icon_256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/icon_32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/icon_512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/mac/icon.iconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 0 additions & 48 deletions builder-config.yaml

This file was deleted.

14 changes: 10 additions & 4 deletions graphql-server/src/fileStore/fileStore.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Injectable } from "@nestjs/common";
import * as fs from "fs";
import { resolve } from "path";
import path, { resolve } from "path";
import { DatabaseConnection } from "../databases/database.model";

const storePath = resolve(__dirname, "../../store/store.json");
const storePath =
process.env.NEXT_PUBLIC_FOR_ELECTRON === "true"
? path.join(process.env.NEXT_PUBLIC_USER_DATA_PATH || "", "store.json")
: resolve(__dirname, "../../store/store.json");

@Injectable()
export class FileStoreService {
Expand Down Expand Up @@ -37,8 +40,11 @@ export class FileStoreService {
}

store.push(item);

if (!fs.existsSync(resolve(__dirname, "../../store"))) {
if (process.env.NEXT_PUBLIC_FOR_ELECTRON === "true") {
if (!fs.existsSync(process.env.NEXT_PUBLIC_USER_DATA_PATH || "")) {
fs.mkdirSync(process.env.NEXT_PUBLIC_USER_DATA_PATH || "");
}
} else if (!fs.existsSync(resolve(__dirname, "../../store"))) {
fs.mkdirSync(resolve(__dirname, "../../store"));
}

Expand Down
36 changes: 25 additions & 11 deletions main/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const schemaPath = isProd
: "graphql-server/schema.gql";
process.env.SCHEMA_PATH = schemaPath;
process.env.NEXT_PUBLIC_FOR_ELECTRON = "true";
process.env.NEXT_PUBLIC_USER_DATA_PATH = userDataPath;

if (isProd) {
serve({ directory: "app" });
Expand Down Expand Up @@ -70,36 +71,52 @@ async function isGraphQLServerReady(url: string): Promise<boolean> {
});
return response.ok;
} catch (error) {
console.error("Error pinging GraphQL server:", error);
console.error("GraphQL server is not ready:", error);
return false;
}
}

async function waitForGraphQLServer(
url: string,
timeout: number = 30000,
timeout: number = 50000,
): Promise<void> {
const startTime = Date.now();
while (Date.now() - startTime < timeout) {
const isReady = await isGraphQLServerReady(url);
if (isReady) {
if (await isGraphQLServerReady(url)) {
return;
}
await new Promise((resolve) => setTimeout(resolve, 1000));
}
throw new Error("Timed out starting GraphQL server");
throw new Error("GraphQL server did not become ready in time");
}

app.on("ready", async () => {
// Function to create the loading window
function createLoadingWindow() {
mainWindow = createWindow("main", {
width: 1280,
height: 680,
icon:
process.platform === "darwin"
? "build/mac/AppIcon.icns"
: path.join(process.resourcesPath, "icon.ico"),
webPreferences: {
preload: path.join(__dirname, "preload.js"),
},
});
Menu.setApplicationMenu(initMenu(mainWindow, isProd));
if (isProd) {
mainWindow.loadURL(path.join(process.resourcesPath, "./loading.html"));
} else {
mainWindow.loadFile(path.join(__dirname, "../main/loading.html"));
}
}

app.on("ready", async () => {
createLoadingWindow();

createGraphqlSeverProcess();

Menu.setApplicationMenu(initMenu(mainWindow, isProd));

await waitForGraphQLServer("http://localhost:9002/graphql");

if (isProd) {
Expand Down Expand Up @@ -148,10 +165,7 @@ app.on("before-quit", () => {
});

app.on("window-all-closed", () => {
// On macOS, closing all windows shouldn't exit the process
if (process.platform !== "darwin") {
app.quit();
}
app.quit();
});

// This does not work
Expand Down
4 changes: 2 additions & 2 deletions main/helpers/create-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export const createWindow = (
});
};

const ensureVisibleOnSomeDisplay = windowState => {
const visible = screen.getAllDisplays().some(display => {
const ensureVisibleOnSomeDisplay = (windowState) => {
const visible = screen.getAllDisplays().some((display) => {
return windowWithinBounds(windowState, display.bounds);
});
if (!visible) {
Expand Down
47 changes: 47 additions & 0 deletions main/loading.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Starting...</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: Arial, sans-serif;
background-color: #f0f0f0;
}

.spinner {
width: 24px;
height: 24px;
border: 4px solid rgba(0, 0, 0, 0.1);
border-top-color: #333;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-right: 10px;
}

@keyframes spin {
to {
transform: rotate(360deg);
}
}

.loading {
font-size: 12px;
color: #333;
display: flex;
align-items: center;
}
</style>
</head>
<body>
<div class="loading">
<div class="spinner"></div> <!-- The spinner -->
Starting, please wait...
</div>
</body>
</html>
85 changes: 85 additions & 0 deletions package-dmg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"private": true,
"name": "dolt-workbench",
"description": "SQL workbench for MySQL and PostgreSQL databases",
"version": "0.2.13",
"main": "app/background.js",
"workspaces": {
"packages": [
"graphql-server",
"web"
]
},
"packageManager": "[email protected]",
"scripts": {
"dev": "nextron",
"build": "nextron build",
"postinstall": "electron-builder install-app-deps",
"clean": "npm-run-all 'clean:*'",
"clean:web": "yarn workspace @dolt-sql-workbench/web clean",
"clean:misc": "rimraf node_modules '*/node_modules' '*/.eslintcache' '*/*.tsbuildinfo' '*/dist' web/.next",
"compile": "npm-run-all 'compile:*'",
"compile:graphql-server": "yarn workspace @dolt-sql-workbench/graphql-server compile",
"compile:web": "yarn workspace @dolt-sql-workbench/web compile"
},
"build": {
"appId": "com.dolthub.dolt-workbench",
"productName": "Dolt Workbench",
"buildVersion": "0.2.13",
"copyright": "Copyright © 2024 <DoltHub Inc>",
"files": [
"app",
"package.json"
],
"extraFiles": [
"graphql-server/dist/*",
"graphql-server/dist/**/*",
"graphql-server/node_modules",
"!**/node_modules/@nestjs/cli/node_modules/fsevents/**",
{
"from": "build/mac/Assets.car",
"to": "Resources/Assets.car"
},
{
"from": "build/mac/AppIcon.icns",
"to": "Resources/AppIcon.icns"
}
],
"mac": {
"category": "public.app-category.developer-tools",
"icon": "build/mac/AppIcon.icns",
"extendInfo": {
"CFBundleIconName": "AppIcon",
"CFBundleIconFile": "AppIcon",
"CFBundleDisplayName": "Dolt Workbench"
},
"artifactName": "${productName}-mac-${arch}.${ext}",
"target": "dmg",
"hardenedRuntime": true,
"gatekeeperAssess": false,
"provisioningProfile": "build/mac/AppleDevelopment.provisionprofile",
"entitlements": "build/mac/entitlements.plist",
"entitlementsInherit": "build/mac/entitlements.inherit.plist"
}
},
"dependencies": {
"electron-serve": "^1.3.0",
"electron-store": "^8.2.0"
},
"devDependencies": {
"@electron/osx-sign": "^1.3.1",
"@types/node": "^22.5.2",
"@types/react": "^18.3.5",
"autoprefixer": "^10.4.19",
"electron": "^31.0.1",
"electron-builder": "^25.1.7",
"next": "^14.2.4",
"nextron": "^9.1.0",
"npm-run-all": "4.1.5",
"postcss": "^8.4.40",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"rimraf": "^6.0.1",
"typescript": "^5.4.5"
}
}
Loading