Skip to content

Batchwork is a automate software it will run all the selection files on startup

Notifications You must be signed in to change notification settings

mdhira-ai/batchwork

Repository files navigation

Getting Started

Follow these instructions to set up and run the project.

Prerequisites

Ensure you have the following installed on your machine:

  • Node.js (v14.x or later)
  • Yarn (v1.x or later) or npm (v6.x or later)

Installation

  1. Create a Next.js application:

    Using Yarn:

    yarn create next-app

    Using npm:

    npx create-next-app@latest
  2. Install development dependencies:

    Using Yarn:

    yarn add --dev electron electron-builder concurrently

    Using npm:

    npm install electron electron-builder concurrently --save-dev
  3. Install electron-serve:

    Using Yarn:

    yarn add electron-serve

    Using npm:

    npm install electron-serve

Project Structure

  1. Update package.json to include the following:

    {
      "main": "main/main.js",
      "author": "Md Habibor Rahman Hira",
      "description": "Boreal software company",
      "scripts": {
        "dev": "concurrently -n \"NEXT,ELECTRON\" -c \"yellow,blue\" --kill-others \"next dev\" \"electron .\"",
        "build": "next build && electron-builder"
      }
    }
  2. Create next.config.js:

    const nextConfig = {
      output: "export",
      images: {
        unoptimized: true
      }
    };
    
    module.exports = nextConfig;
  3. Create main/main.js:

    const { app, BrowserWindow } = require("electron");
    const path = require("path");
    
    let appServe;
    
    if (app.isPackaged) {
      (async () => {
        appServe = (await import('electron-serve')).default({
          directory: path.join(__dirname, "../out")
        });
      })();
    }
    
    const createWindow = () => {
      const win = new BrowserWindow({
        width: 800,
        height: 600,
        webPreferences: {
          preload: path.join(__dirname, "preload.js")
        }
      });
    
      if (app.isPackaged) {
        appServe(win).then(() => {
          win.loadURL("app://-");
        });
      } else {
        win.loadURL("http://localhost:3000");
        win.webContents.openDevTools();
        win.webContents.on("did-fail-load", (e, code, desc) => {
          win.webContents.reloadIgnoringCache();
        });
      }
    };
    
    app.on("ready", () => {
      createWindow();
    });
    
    app.on("window-all-closed", () => {
      if (process.platform !== "darwin") {
        app.quit();
      }
    });
  4. Create main/preload.js:

    const { contextBridge, ipcRenderer } = require("electron");
    
    contextBridge.exposeInMainWorld("electronAPI", {
      on: (channel, callback) => {
        ipcRenderer.on(channel, callback);
      },
      send: (channel, args) => {
        ipcRenderer.send(channel, args);
      }
    });
  5. Create electron-builder.yaml:

    appId: "app.Borealsoftwarecompany.com"
    productName: "Boreal software company"
    copyright: "Copyright (c) 2023 Boreal software company"
    win:
      target: ["dir", "portable", "zip"]
      icon: "resources/icon.ico"
    linux:
      target: ["dir", "appimage", "zip"]
      icon: "resources/icon.png"
    mac:
      target: ["dir", "dmg", "zip"]
      icon: "resources/icon.icns"

Adding Updates

  1. Install electron-updater:

    Using Yarn:

    yarn add electron-updater

    Using npm:

    npm install electron-updater
  2. Update package.json to include the following for building and publishing:

    {
      "build": {
        "appId": "com.Borealsoftwarecompany.myappname",
        "files": [
          "!node_modules"
        ],
        "nsis": {
          "oneClick": false,
          "perMachine": true
        },
        "productName": "myappname",
        "win": {
          "icon": "/resources/icon.png",
          "publish": [
            "github"
          ]
        },
        "linux": {
          "icon": "/resources/icon.png",
          "publish": [
            "github"
          ]
        }
      },
      "electronBuilder": {
        "asar": true,
        "compression": "maximum"
      },
      "repository": "https://github.com/mdhira-ai/batchwork",
      "license": "MIT",
      "publish": {
        "provider": "github",
        "releaseType": "release"
      }
    }

Running the Application

  1. Development:

    yarn dev

    or

    npm run dev
  2. Build:

    yarn build

    or

    npm run build

Author

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Special thanks to the Electron and Next.js communities for their invaluable resources and support.