Snapping an Electron App Up

Hello my snappy friends!

I maintain an Electron app, which is really just a wrapper around the Habitica website (but I love it nonetheless).

Here is the repo.

I was hoping someone could point me at the best documentation to go from knowing nothing, to snapping this app up, to submitting it to the Ubuntu App Store.

Figured this would help me and anyone else going through this process to post this here. :slight_smile:

@elopio @kyrofa Who’d be the best person to help here?

You can probably get some help from @Wimpress as he’s been working on this lately.
Another alternative is to use electron-builder to produce the snap directly, that said there’s an npm bug which is forcing our hand into moving to yarn to drive the builds so that will only be available in snapcraft 2.29

2 Likes

Hi @ryanleesipes :relaxed:

I’m out this evening, but I’ll be in touch. Currently working on some documentation, but I’ll contact you via your GitHub project.

1 Like

Also, if you’d be so kind to post in here. That would be good for users who are interested in snapping up their own electron apps. And puts some content in here that will attract more users to join the forums. (As I could just ping you on Telegram, but that doesn’t benefit the world like this does).

4 Likes

@Wimpress made another Electron app to snap:

Woah, I just snapped it up! Will share the code shortly once I install and verify it works!

It is published!

It is in the edge channel! Install via:

snap install snapcraft-forum --edge

Are you using Node from the Ubuntu archives or from NodeSource? I asked because I see you’ve used electron-builder :ok_hand: but that is failing with npm for many Electron projects right now. Would like to get some feedback on your configuration.

I am using the nodesource LTS repo, so node v6.10.1 and npm v3.10.10.

electron-builder works great in this setup (have to check what version I’m using on my work machine, but I’m betting it’s the same).

On an unrelated note, passing along a webpage on snapcraft-forum is proving to be quite difficult in the normal snap environment (strict with default plugs as listed here. Any ideas as to what plugs I need to enable in order to get this working?

Working fine for me on yakkety without --devmode

i have added a PR to your tree that should at least provide a workaround (ctrl+click will open in external browser)

You shouldn’t have to enable any plugs. This is likely due to the way that xdg-open is currently wired. There’s some discussion on improvements in that area here:

1 Like

nope, this also happens in a normal browser, links are always opened in the same tab when klicking them in the forum, this must be some discourse setting (also xdg-open just works in most snaps nowadays (if you have the snapd-xdg-open package installed, at least when not opening through some fancy toolkit wrapper.)

@niemeyer @ogra with the way it is currently coded that uses child_process (as you recommended @ogra) and xdg-open+url. It still fails as a snap to open links externally.

Error org.freedesktop.DBus.Error.ServiceUnknown: The name com.canonical.SafeLauncher was not provided by any .service files

And I get a javascript error with ctrl+click

Uncaught Exception:
ReferenceError: child_process is not defined
at WebContents. (/snap/snapcraft-forum/x2/resources/app.asar/main.js:87:11)
at emitMany (events.js:127:13)
at WebContents.emit (events.js:201:7)
at EventEmitter. (/snap/snapcraft-forum/x2/resources/electron.asar/browser/guest-window-manager.js:245:16)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
at WebContents.webContents.on (/snap/snapcraft-forum/x2/resources/electron.asar/browser/api/browser-window.js:29:13)
at emitMany (events.js:127:13)
at WebContents.emit (events.js:201:7)

Going to pop this into the issue tracker on the repo about this issue.

Update!

With snapd-xdg-open installed it does work properly. That means this is a dependency that needs to be fulfilled in order to have everything work properly. I guess I need to jump on the thread you pointed to @niemeyer.

1 Like

https://github.com/ryanleesipes/snapcraft-forum/pull/3

should make all external links as well as a ctrl+click operations on a link use xdg-open. as long as snapd-xdg-open is installed this should spawn a new tab in your default browser then.