Code Monkey home page Code Monkey logo

gulp-atom-electron's Introduction

Deprecated

Please use the official way of requiring Electron: https://electronjs.org/docs/tutorial/first-app

--

gulp-atom-electron

Build Status

Installation

npm install --save-dev gulp-atom-electron

Usage

You can use this module in two distinct ways: to package your application and/or to download a version of Electron to disk.

How to Package Your Application

You should source your app's files using gulp.src and pipe them through gulp-atom-electron. The following task will create your application in the app folder, ready for launch.

var gulp = require("gulp");
var symdest = require("gulp-symdest");
var electron = require("gulp-atom-electron");

gulp.task("default", function () {
  return gulp
    .src("src/**")
    .pipe(electron({ version: "0.34.1", platform: "darwin" }))
    .pipe(symdest("app"));
});

Note: It is important to use gulp-symdest only because of the OS X platform. An application bundle has symlinks within and if you use gulp.dest to pipe the built app to disk, those will be missing. symdest will make sure symlinks are taken into account.

Finally, you can always pipe it to a zip archive for easy distribution. joaomoreno/gulp-vinyl-zip is recommended:

var gulp = require("gulp");
var zip = require("gulp-vinyl-zip");
var electron = require("gulp-atom-electron");

gulp.task("default", function () {
  return gulp
    .src("src/**")
    .pipe(electron({ version: "0.34.1", platform: "darwin" }))
    .pipe(zip.dest("app-darwin.zip"));
});

How to Download Electron

There's also a very handy export electron.dest() function that makes sure you always have the exact version of Electron in a directory:

var gulp = require("gulp");
var electron = require("gulp-atom-electron");

gulp.task("default", function () {
  return electron.dest("electron-build", {
    version: "0.34.1",
    platform: "darwin",
  });
});

This will place a vanilla Electron build into the electron-build directory. If you run it consecutively and it detects that the version in the destination directory is the intended one, it will end up in a no-op. Else it will download the provided version and replace it.

Options

You must provide the following options:

  • version - the Electron version to use
  • platform - kind of OS (darwin, linux, win32)

The following options are optional:

  • quiet - suppress a progress bar when downloading

  • token - GitHub access token(to avoid request limit. You can grab it here)

  • arch - the processor architecture (ia32, x64)

  • Windows

    • winIcon - path to an .ico file
    • companyName - company name
    • copyright - copyright statement
  • Darwin

    • darwinIcon - path to an .icns file
    • darwinHelpBookFolder - the CFBundleHelpBookFolder value
    • darwinHelpBookName - the CFBundleHelpBookName value
    • darwinBundleDocumentTypes - (reference) array of dictionaries, each containing the following structure:
      • name - the CFBundleTypeName value
      • role - the CFBundleTypeRole value
      • ostypes - the CFBundleTypeOSTypes value, a string array
      • utis - the LSItemContentTypes value, a string array
      • extensions - the CFBundleTypeExtensions value, a string array of file extensions
      • iconFile - the CFBundleTypeIconFile value
    • darwinForceDarkModeSupport - Forces Mojave dark mode support to be enabled for older Electron versions
  • Linux

    • linuxExecutableName - overwrite the name of the executable in Linux

gulp-atom-electron's People

Contributors

alexdima avatar bpasero avatar christopherbock avatar chrmarti avatar codebytere avatar deepak1556 avatar dependabot[bot] avatar headmelted avatar jeremyloy avatar joaomoreno avatar josh- avatar jpalumickas avatar marshallofsound avatar mathphreak avatar mattdsteele avatar nasum avatar rsesek avatar rzhao271 avatar sbatten avatar weinand avatar yshrsmz 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

gulp-atom-electron's Issues

Fails to with no error after updating packages

Hi,
Sorry that im unable to find the route cause but after hours of looking i'm hoping that someone will know the solution off the top of their head.

Everything was working fine until the beginning of the week, after running npm install a package must of updated, now gulp-atom-electron fails stopping gulp from running.

The resource/app file is created and my apps contents copies across then build stops (doesnt fail, just stops)

Any ideas?

Sorry again.

zfsdest does not create intervening directories

Given the following stream:

  return gulp.src([
    `.tmp/built/${cli.app}/**/*`,
    `support/atom/**/*`,
    ])
    .pipe($.atomShell({
      version: '0.20.4',
      productName: cli.app,
      productVersion: '0.0.1',
      platform: 'darwin'
    }))
    .pipe($.atomShell.zfsdest(`./dist/atom/${cli.app}.zip`))
    ;

I get the following error from the gulp console:

[20:27:01] Error: Could not write to archive.hello-world.app/Contents/Resources/app/head.bundle.js

In this instance ./dist/atom does not exist. Changing the destination to an existing directory fixes the problem. Since gulp.dest will create intervening directories for you, I personally expected zfdest to work the same.

Thanks!

[feature request] platforms option

I want to specify some platforms at once.
So please consider platforms option.

Usage:

        .pipe(atomshell({
            version: '0.21.3',
            productName: 'some product',
            productVersion: '1.0.0',
            winIcon: './images/icon.ico',
            darwinIcon: './images/icon.icns',
            platforms: ['linux', 'win32', 'darwin']
        }))

Error handling is broken

@sbatten

$ /__w/1/s/node_modules/.bin/npm-run-all -lp 'electron x64' playwright-install
[electron x64      ] $ node build/lib/electron x64
[electron x64      ] (node:11811) UnhandledPromiseRejectionWarning: HttpError: Not Found
[electron x64      ]     at /__w/1/s/node_modules/@octokit/request/dist-node/index.js:66:23
[electron x64      ]     at processTicksAndRejections (internal/process/task_queues.js:97:5)
[electron x64      ]     at async getDownloadUrl (/__w/1/s/node_modules/gulp-atom-electron/src/util.js:15:28)
[electron x64      ] (node:11811) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
[electron x64      ] (node:11811) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[electron x64      ] (node:11811) UnhandledPromiseRejectionWarning: HttpError: Not Found
[electron x64      ]     at /__w/1/s/node_modules/@octokit/request/dist-node/index.js:66:23
[electron x64      ]     at processTicksAndRejections (internal/process/task_queues.js:97:5)
[electron x64      ]     at async getDownloadUrl (/__w/1/s/node_modules/gulp-atom-electron/src/util.js:15:28)
[electron x64      ] (node:11811) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
Finishing: Download Electron and Playwright

The download stream doens't throw an error. It just spits out an unhandled promise reject warning and acts as if nothing has happened.

No Output?

outputPath is in the README, but nowhere to be found in the code. Where is the actual output? I'm not sure it's even doing anything... what am I doing wrong?

Ideas for Mac OS build

Here is some ideas for building Mac OS apps

  • Rename icns file to productName and set CFBundleIconFile to productName.incs (product name lower cased)
  • Set default productName to first letter uppercase
  • Set CFBundleDisplayName to productName (It's normal to do that?)
  • Set CFBundleExecutable to productName (It's normal to do that?)
  • Change CFBundleIdentifier to maybe com.productName.atom (Should be lower cased and underscored if there is a spaces)

Typo in readme ?

In Readme, Usage section, looks like there is a typo for the configuration of the destination.
At the moment it is electron.dest, which is not working.
Shouldn't it be gulp.dest instead ?

Error while creating Electron app package on Windows 8

Hi,

I am using following code to package my electron app.

var atomelectron = require('gulp-atom-electron'),
  os = require('os');
gulp.task('make', function () {
  var prop = {
    version: '0.26.1',
    platform: os.platform()
  }
  if (os.platform() === 'darwin') {
    prop.darwinIcon = 'icon.icns';    
  }
  else {
    // properties related to windows executables       
    prop.arch = "x64";
  }  
  return gulp.src('src/**')
      .pipe(atomelectron (prop))
      .pipe(atomelectron .zfsdest('app.zip'))     
      .on('end', function() { console.log('Your app package is ready.') })      
});

Works perfectly on Mac but gives following error on Windows 8.

[15:27:51] Starting 'make'...
↓ electron-v0.26.1-win32-ia32.zip [=-------------------] 5%events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: EISDIR, read
    at Error (native)

it does... nothing?!

Hi,

I run the example gulp configuration for building a darwin app, pointed to the right source and dest folder, but I only get:

[11:11:41] Finished 'download-electron' after 36 s
[11:11:41] Starting 'build'...
bash-3.2$

and nothing... no error, no warning... nothing...

My gulp config is:

gulp.task('default', function () {
return gulp.src('./build/**')
.pipe(electron({ version: '1.4.12', platform: 'darwin' }))
.pipe(symdest('./app'));
});

Anything else to configure)?

Best wishes,
Martin

Unable to load file

Hi,

I cannot package my electron app. I always got this error message:

stream.js:74
      throw er; // Unhandled stream error in pipe.
      ^
Fatal error: Unable to load file

The relevant gulp task:

gulp.task('package:windows', function() {
  return gulp.src(config.buildDir + '/**')
  .pipe(debug({title: 'before:'}))
  .pipe(electron({
      version: '1.4.3',
      platform: 'win32',
      arch: 'x64'
    }))
//    .pipe(debug({title: 'after:'}))
    .pipe(symdest(config.packagesDir + '/windows'));
});

I run out of ideas howto debug it ny further.

Any idea?

Thanks!

Add option for creating asar archive

Add the option to pack the application resources into an asar archive. That would be really helpful and should be fast implemented.
Also consider deleting the "atom.asar" from the prebuild resource folder.

Allow to use electron binary from node_modules folder

Electron distributes binaries as electron NPM package. Once installed, the Electron binary is on disk. Would be great if gulp-atom-electron could optionally get the binary from that location and not download it if possible.

Setting Application Menu removes it

Does gulp-atom-electronuse electron-prebuilt? I am having trouble setting up a menubar from both the main process or the renderer process. When setting anymenubar using Menu.setApplicationMenu() (OSX) the menu disappears completely, also disabling the ⌘Q shortcut

Emit an error if no package.json is found

Hello, I spent a couple of minutes trying to figure out why no package was being built only to discover that if no package.json is part of the src stream nothing would be built.

I think it would make sense to notify the user that a package.json is expected but was not found.

Piping gulp-atom-shell output into directory using gulp.dest (instead of into a zip using zfsdest) produces a corrupted build

Given the stream:

  return gulp.src([
    `.tmp/built/${cli.app}/**/*`,
    `support/atom/**/*`,
    ])
    .pipe($.atomShell({
      version: '0.20.4',
      productName: cli.app,
      productVersion: '0.0.1',
      platform: 'darwin'
    }))
    .pipe(gulp.dest(`./dist/atom/${cli.app}`))
    .pipe($.atomShell.zfsdest(`./${cli.app}.zip`))
    ;

You'll end up with a zipped archive and an unzipped .app file. If you unzip the archive, and then open the .app that was unpacked, everything works fine. If you try to open the .app that was never zipped, you get a crash on launch with the following message:

problem_report_for_hello-world

Can't create right icon on windows

As title, after putting right path into winIcon field (with right format : name.ico), gulp-atom-electron still can't show the icon on Windows. After reading through the codebase, it seems that rcedit.exe does executed and put contents into .exe.

In order to make the test more accurate, I made the build on Windows 10 to make sure rcedit.exe would execute correctly. Any idea ?

EISDIR: illegal operation on a directory, read

I'm currently having some trouble getting the task up and running. It might be that I'm providing the wrong path to the scr, app structure or I have something else going on entirely. I'm still new to electron so it could be something totally noobish as well. Any thoughts?

Exception from build:

➜  electron-quick-start: gulp default
[20:48:19] Using gulpfile ~/Projects/electron-quick-start/gulpfile.js
[20:48:19] Starting 'default'...
events.js:154
      throw er; // Unhandled 'error' event
      ^
Error: EISDIR: illegal operation on a directory, read
    at Error (native)

Current gulp task:

var gulp = require('gulp');
var symdest = require('gulp-symdest');
var electron = require('gulp-atom-electron');

gulp.task('default', function () {
    return gulp.src(['./**/*', '!./build'])
        .pipe(electron({ version: '0.37.2', platform: 'darwin' }))
        .pipe(symdest('build'));
});

Directory structure post failed build:
screen shot 2016-03-17 at 9 03 54 pm

Unable to create package on Mac

Every time I try to package my app with the latest version (0.12.0), I get an error like this:

↓ electron-v0.26.1-darwin-x64.zip [===-----------------] 13%buffer.js:68
    throw new TypeError('must start with number, buffer, array or string');
    ^
TypeError: must start with number, buffer, array or string
    at new Buffer (buffer.js:68:11)
    at DestroyableTransform.through.obj.stream.push.File.path [as _transform] (/Users/evan/code/javascript/neonsolitude/node_modules/gulp-atom-electron/node_modules/gulp-vinyl-zip/lib/zip/index.js:24:21)
    at DestroyableTransform.Transform._read (/Users/evan/code/javascript/neonsolitude/node_modules/gulp-atom-electron/node_modules/gulp-vinyl-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (/Users/evan/code/javascript/neonsolitude/node_modules/gulp-atom-electron/node_modules/gulp-vinyl-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/Users/evan/code/javascript/neonsolitude/node_modules/gulp-atom-electron/node_modules/gulp-vinyl-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer (/Users/evan/code/javascript/neonsolitude/node_modules/gulp-atom-electron/node_modules/gulp-vinyl-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
    at DestroyableTransform.Writable.write (/Users/evan/code/javascript/neonsolitude/node_modules/gulp-atom-electron/node_modules/gulp-vinyl-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
    at DestroyableTransform._transform (/Users/evan/code/javascript/neonsolitude/node_modules/gulp-atom-electron/node_modules/gulp-vinyl-zip/lib/dest/index.js:13:9)
    at DestroyableTransform.Transform._read (/Users/evan/code/javascript/neonsolitude/node_modules/gulp-atom-electron/node_modules/gulp-vinyl-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (/Users/evan/code/javascript/neonsolitude/node_modules/gulp-atom-electron/node_modules/gulp-vinyl-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/Users/evan/code/javascript/neonsolitude/node_modules/gulp-atom-electron/node_modules/gulp-vinyl-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer (/Users/evan/code/javascript/neonsolitude/node_modules/gulp-atom-electron/node_modules/gulp-vinyl-zip/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)

The download progress always stops, but never at the same percentage. I thought it was a problem with my network, but nothing I change on my end fixes it.

My gulp task looks like this:

gulp.task('package:mac', function() {
  return gulp.src(['./**/*', '!./build'])
    .pipe(electron({
      version: '0.26.1',
      platform: 'darwin'
    }))
    .pipe(electron.zfsdest('./build/mac.zip');
});

I also tried adding a GitHub token, but that didn't change anything.

Request to Not Rely on GitHub Releases

Now we use GitHub Releases to download assets, which in my opinion is not to be relied on. It almost always fails in certain regions. Even if it can be accessed, the speed is extremely slow. This has made my experience of building VS Code full of pain.

So I suggest to provide alternative ways for downloading. Perhaps the default option is to download direct from github.com/electron/electron/releases/download/.... While I may specify a mirror in the environment variables, or as a download option. In that case the reliability of this package will be visibly increased.

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.