Skip to content

Commit

Permalink
Merge pull request #3 from Detachment025/development
Browse files Browse the repository at this point in the history
Merge for v1.4.0 release
  • Loading branch information
BenjaminHerrera authored Aug 21, 2023
2 parents 6c68755 + 15cfc8d commit d2b3e18
Show file tree
Hide file tree
Showing 23 changed files with 14,759 additions and 33,224 deletions.
19 changes: 18 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,22 @@
"editor.tabSize": 2,
"editor.rulers": [
80
]
],
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
".class": true,
".vscode": true,
"**/__pycache__": true,
"**/.classpath": true,
"**/.factorypath": true,
"**/.project": true,
"**/.settings": true,
"env": true
},
"hide-files.files": []
}
25 changes: 16 additions & 9 deletions dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const path = require("path");
const fs = require("fs");
const os = require("os");

// Disable hardware acceleration
app.disableHardwareAcceleration();

// Function to create a new window
function createWindow() {
// Create a new window with the following configurations
Expand Down Expand Up @@ -31,17 +34,21 @@ const userHomeDirectory = os.homedir();
const trackerDirectory = path.join(userHomeDirectory, ".tracker");

// Create directory if it doesn't exist
if (!fs.existsSync(trackerDirectory)) {
fs.mkdirSync(trackerDirectory);
}
if (!fs.existsSync(trackerDirectory)) fs.mkdirSync(trackerDirectory);

// Define the path for the data.json file
const dataFilePath = path.join(trackerDirectory, 'data.json');
// Define the path for the data.json file and cfg.json
const dataFilePath = path.join(trackerDirectory, "data.json");
const cfgFilePath = path.join(trackerDirectory, "cfg.json");

// Check if the data.json file exists, if not, create it with empty JSON object
if (!fs.existsSync(dataFilePath)) {
fs.writeFileSync(dataFilePath, JSON.stringify({}), 'utf8');
}
// Check if the JSON file exists, if not, create it with empty JSON object
if (!fs.existsSync(dataFilePath))
fs.writeFileSync(dataFilePath, JSON.stringify({}), "utf8");
if (!fs.existsSync(cfgFilePath))
fs.writeFileSync(
cfgFilePath,
JSON.stringify({ datapath: dataFilePath }),
"utf8"
);

// When Electron has finished initialization and is ready
// to create browser windows, call the createWindow function
Expand Down
62 changes: 34 additions & 28 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
// Import required modules
const { app, BrowserWindow } = require("electron");
const express = require('express');
const waitOn = require('wait-on');
const path = require('path');
const next = require('next');
const fs = require('fs');
const express = require("express");
const waitOn = require("wait-on");
const path = require("path");
const next = require("next");
const fs = require("fs");
const os = require("os");

// Variable declaration
let server;

// Disable hardware acceleration
app.disableHardwareAcceleration();

// Function to create a new window
function createWindow() {
// Create a new window with the following configurations
Expand All @@ -19,35 +22,39 @@ function createWindow() {
autoHideMenuBar: true,
outline: "none",
webPreferences: {
enableRemoteModule: true
enableRemoteModule: true,
},
title: "PDT and Awards Tracker",
icon: ".\\src\\public\\icon.ico"
icon: ".\\src\\public\\icon.ico",
});

// Maximize window
window.maximize();

// Loads the URL of the app
window.loadURL('http://localhost:3000');
window.loadURL("http://localhost:3000");
}

// Calculate user's tracker directory
const userHomeDirectory = os.homedir();
const trackerDirectory = path.join(userHomeDirectory, '.tracker');
const trackerDirectory = path.join(userHomeDirectory, ".tracker");

// Create directory if it doesn't exist
if (!fs.existsSync(trackerDirectory)) {
fs.mkdirSync(trackerDirectory);
}

// Define the path for the data.json file
const dataFilePath = path.join(trackerDirectory, 'data.json');

// Check if the data.json file exists, if not, create it with empty JSON object
if (!fs.existsSync(dataFilePath)) {
fs.writeFileSync(dataFilePath, JSON.stringify({}), 'utf8');
}
if (!fs.existsSync(trackerDirectory)) fs.mkdirSync(trackerDirectory);

// Define the path for the data.json file and cfg.json
const dataFilePath = path.join(trackerDirectory, "data.json");
const cfgFilePath = path.join(trackerDirectory, "cfg.json");

// Check if the JSON file exists, if not, create it with empty JSON object
if (!fs.existsSync(dataFilePath))
fs.writeFileSync(dataFilePath, JSON.stringify({}), "utf8");
if (!fs.existsSync(cfgFilePath))
fs.writeFileSync(
dataFilePath,
JSON.stringify({ datapath: dataFilePath }),
"utf8"
);

// Your express server code
const nextApp = next({ dev: false });
Expand All @@ -59,7 +66,7 @@ nextApp.prepare().then(() => {
server = express();

// Router call
server.all('*', (req, res) => {
server.all("*", (req, res) => {
return handle(req, res);
});

Expand All @@ -69,9 +76,9 @@ nextApp.prepare().then(() => {
if (err) throw err;

// Wait for server to be ready before creating the window
waitOn({ resources: ['http-get://localhost:3000'] }, (err) => {
waitOn({ resources: ["http-get://localhost:3000"] }, (err) => {
if (err) {
console.error('Error waiting for resource:', err);
console.error("Error waiting for resource:", err);
return;
}

Expand All @@ -82,19 +89,18 @@ nextApp.prepare().then(() => {

// Run server
app.whenReady().then(() => {
app.on('activate', () => {
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});


// Quit the application when all windows are closed
// (except on macOS)
app.on("window-all-closed", function () {
// Kill all associated processes
if (process.platform !== 'darwin') {
if (process.platform !== "darwin") {
if (server) {
server.close();
}
Expand All @@ -104,7 +110,7 @@ app.on("window-all-closed", function () {

// When the application gets activated, create a window if
// there isn't one already
app.on('activate', function () {
app.on("activate", function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});

Expand Down Expand Up @@ -135,4 +141,4 @@ app.on('activate', function () {
// // .| |. \\
// .' |_./ | | \._| '.
// / _.-||| |||-._ \
// \__.-' \||/\||/ '-.__/
// \__.-' \||/\||/ '-.__/
Loading

0 comments on commit d2b3e18

Please sign in to comment.