Giter Club home page Giter Club logo

electron-global's Introduction

electron-global

Travis Downloads PayPal Discord

A tool for building lightweight Electron apps using a global Electron instance. Forget about 100MB for a Hello World app in Electron!

How it works?

electron-global creates a custom Electron distributable with a small app launcher which checks the app's package.json and downloads corresponding major version and the newest in case of minor and patch. The Electron versions are being saved to:

  • on macOS and Linux: ~/.electron-global/x
  • on Windows: %HOMEPATH%/.electron-global/x

Where x is the major version of Electron (e.g. 6).

Then the distributable can be used with electron-builder to build the app installers.

Installation

The electron-builder package is also required to successfully build an app.

$ npm install --save-dev electron-global electron-builder

Usage

You need to create electron-builder.json file in your project directory, configure it and specify electronDist directory to where the electron-global generates the output (default is ./electron-global). Example:

{
  ...
  "electronDist": "./electron-global"
  ...
}

Then you can run the following command (example for macOS):

$ electron-global -m && electron-builder -m

CLI Options:

Usage: electron-global [options]

Options:
  -m, --mac                Create Electron dist for macOS.
  -l, --linux              Create Electron dist for Linux.
  -w, --windows            Create Electron dist for Windows.
  -o, --output <path>      Output path of the created Electron runtime launcher. Defaults to `./dist/runtime`.
  --projectDir, --project  The path to project directory. Defaults to current working directory.
  -h, --help               output usage information

Known limitations

  • electronDist also applies to rebuilding native modules, therefore these won't work.
  • It does not remove unused Electron versions.
  • Apps will be listed in task managers as Electron, not as processes with the actual app name and icon.

electron-global's People

Contributors

dependabot[bot] avatar orta avatar sentialx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

electron-global's Issues

Unable to codesign with electron-builder

The electron-runtime launcher needs to be codesigned in order to codesign other Electron apps with electron-builder, but codesigning for macOS (and probably for Windows) costs.

  ⨯ Command failed: codesign --sign x --force --options runtime --entitlements .../node_modules/app-builder-lib/templates/entitlements.mac.plist
...: code object is not signed at all
In subcomponent: .../Contents/MacOS/electron_url
  stackTrace=

"build" section in package.json cause ignore electron-global to run in build process.

I need to use "build" section in package.json file to customize electron-builder output. But when i use "build" section in package.json, electron-global never be invoked.

Here is with "build" section messages:

  • electron-builder version=20.44.4
  • loaded configuration file=package.json ("build" field)
  • writing effective config file=release\builder-effective-config.yaml
  • no native production dependencies
  • packaging       platform=win32 arch=x64 electron=5.0.10 appOutDir=release\win-unpacked
  • default Electron icon is used reason=application icon is not set
  • building        target=nsis file=release\Setup 2.0.0.exe archs=x64 oneClick=false perMachine=true
  • building block map blockMapFile=release\Setup 2.0.0.exe.blockmap

Without "build" section:

 • electron-builder version=20.44.4
  • loaded configuration file=C:\Users\...\electron-builder.json
  • writing effective config file=dist\builder-effective-config.yaml
  • no native production dependencies
  • packaging       platform=win32 arch=x64 electron=5.0.10 appOutDir=dist\win-unpacked
  • copying Electron source=C:\Users\...\electron-global destination=C:\Users\...\dist\win-unpacked

You'll see "copying Electron..." and it means now invoked electron-global.
Is this a bug or something else?

Env: Win10-x64 build 1903 latest update, node 12.10.0, and please don't mind electron-builder version :)

electron-global (macOS) requires GTK+3 but does not bundle it

Launching an app built electron-global results in

dyld: Library not loaded: /usr/local/opt/gtk+3/lib/libgtk-3.0.dylib
Referenced from: /Applications/TeleDrive.app/Contents/MacOS/TeleDrive
Reason: image not found
[1] 66490 abort /Applications/TeleDrive.app/Contents/MacOS/TeleDrive

Workaround (per install)

brew install gtk+3

Not working on Linux

Description

After following the Usage section of the README file, I tried running electron-builder --linux --windows, but ended up with error:

Downloading electron-global binaries
Downloading electron-global binaries
[
  [Error: ENOENT: no such file or directory, lstat '/home/akepinski/dev/elcalc/node_modules/electron-global/download/linux/electron'] {
    errno: -2,
    code: 'ENOENT',
    syscall: 'lstat',
    path: '/home/akepinski/dev/elcalc/node_modules/electron-global/download/linux/electron'
  }
]
Done!
  • electron-builder  version=21.2.0 os=4.15.0-54-generic
  • loaded configuration  file=/home/akepinski/dev/elcalc/electron-builder.json
  • writing effective config  file=dist/builder-effective-config.yaml
  • packaging       platform=linux arch=x64 electron=6.0.4 appOutDir=dist/linux-unpacked
  • copying Electron  source=/home/akepinski/dev/elcalc/electron-global destination=/home/akepinski/dev/elcalc/dist/linux-unpacked
  ⨯ ENOENT: no such file or directory, rename '/home/akepinski/dev/elcalc/dist/linux-unpacked/electron' -> '/home/akepinski/dev/elcalc/dist/linux-unpacked/elcalc'  stackTrace=Error: ENOENT: no such file or directory, rename '/home/akepinski/dev/elcalc/dist/linux-unpacked/electron' -> '/home/akepinski/dev/elcalc/dist/linux-unpacked/elcalc'

After checking the ./electron-global directory, it only contains the electron_version file, which is empty 😢

Electron Builder configuration

{
  "appId": "me.kepinski.elcalc",
  "files": [
    "app/**/*",
    "package.json"
  ],
  "directories": {
    "buildResources": "resources"
  },
  "electronDist": "./electron-global",
  "mac": {
    "category": "public.app-category.utilities"
  },
  "dmg": {
    "iconSize": 150
  },
  "linux": {
    "target": [
      "AppImage",
      "deb",
      "rpm"
    ],
    "synopsis": "Cross-Platform Calculator",
    "description": "Cross-Platform calculator built with Electron.",
    "category": "Utility;Calculator"
  },
  "publish": null
}

Additional details

  • OS: Linux Mint 19.1 Xfce
  • Node.js version: 12.8.0
  • npm version: 6.10.2
  • electron-builder version: 21.2.0
  • electron-global version: 0.0.1

TypeError when building

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (9)
    at Object.writeFile (internal/fs/promises.js:542:5)
    at Object.<anonymous> (/home/heath/SyncedProjects/pakkit/node_modules/electron-global/build/index.js:91:29)
    at Generator.next (<anonymous>)
    at fulfilled (/home/heath/SyncedProjects/pakkit/node_modules/electron-global/build/index.js:4:58) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Caching

I have a little understanding of how it work internally

I remember having cache (localstorage, cookies, etc..) issues when sharing electron binaries
How do you handle that?

Use a proper file location on Windows

Windows is not linux and as such you shouldn't dump .folders in user home directory.

If you don't want to use %PROGRAMFILES% (which requires admin permissions) then the correct location to put files is %PROGRAMDATA%\electron-global. Just make sure to give write/read permissions to the local users group to the created folder.

Infer OS when no parameters are passed

Running

electron-global

without -m, -w or -l causes electron-global to exit with code 0 without changes.

electron-global should infer the OS automatically like electron-builder

electron-runtime: command not found

Since I had already installed electron builder, installed only electron runtime using this
npm install --save-dev electron-runtime and updated package.json script as "dist": "electron-runtime -m && electron-builder -m"

When i run npm run dist, I get electron-runtime command not found. Electron Builder works fine.

Am I missing something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.