1131 Commits

Author SHA1 Message Date
Jonas Hermsmeier
6c930e2d8d fix(image-stream): fix Apple disk image detection & reading (#1283)
This fixes two things: The format detection, and a bug in `udif`.

First, by categorizing the `.dmg` extension as compressed image,
`.isSupportedImage()` would attempt to detect the format after stripping
the extension, causing it to be misdetected.

Second, `udif`'s ReadStream didn't add the `dataForkOffset` to its
position when reading blocks, causing the wrong data to be read for some images,
in turn causing zlib to error on invalid headers.

Changes:
- Classify `.dmg` as `type: 'image'`
- Update `udif` to 0.8.0

Change-Type: patch
Changelog-Entry: Fix Apple disk image detection & streaming
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-15 00:17:41 -04:00
Juan Cruz Viotti
0b500d2585 fix(GUI): correctly log debugging messages on Windows (#1303)
Windows will not react to dynamically set environment variables (e.g:
`process.env.MOUNTUTILS_DEBUG = '1'`), so in order to workaround this
limitation, we set `MOUNTUTILS_DEBUG` in
`lib/child-writer/writer-proxy.js` when spawning the CLI, and we also
set `DEBUG='*'` in `lib/start.js`, so it gets picked up by the child
writer module, which spawns the writer proxy by inheriting the
environment.
2017-04-14 16:41:00 -04:00
Juan Cruz Viotti
ebd2d85de7 upgrade: mountutils to v1.0.5 (#1302)
This version accepts a `MOUNTUTILS_DEBUG` environment variable to make
the module output extra logging information, which we enable in this
commit as well.

See: https://github.com/resin-io-modules/mountutils/pull/25
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-14 14:59:27 -04:00
Juan Cruz Viotti
c5a9a1fca4 fix(GUI): show a friendly message when the drive is unplugged half-way through (#1301)
This commit shows a user friendly message when Etcher loses access to
the drive while flashing/validating, and prevents the cryptic errors
from getting to Sentry.

See: https://github.com/resin-io-modules/etcher-image-write/pull/96
Change-Type: minor
Changelog-Entry: Show a user friendly message when the drive is unplugged half-way through.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-14 14:24:06 -04:00
Juan Cruz Viotti
e66d805672 feat(child-writer): log non-robot messages for debugging purposes (#1295)
Currently, if the child writer receives a message from the writer
process that is not a valid robot object, then it will throw an error.

Now, we check if the message is a robot message, and if so, we try to
parse it (throwing errors if its indeed a malformed/incomplete robot
message), however we log it if not.

The main motivation behind this feature is that it will allows us to
print debugging information on the mountutils module, and have it
redirected to DevTools.

Change-Type: minor
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-14 14:07:00 -04:00
Juan Cruz Viotti
0890b1e369 refactor(GUI): move SupportedFormatsModel to lib/shared (#1251)
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-13 14:38:30 -04:00
Juan Cruz Viotti
64c8eb594b refactor(GUI): make OSWindowProgress a simple CommonJS module (#1253)
There is no need to tie this module to Angular by using an Angular
service.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-13 14:38:22 -04:00
Juan Cruz Viotti
68f87435de fix(CLI): throw error if image is inaccessible (#1281)
Consider the following scenario:

- The user selects an image from an external drive
- The user selects a drive
- The user unmounts/ejects the external drive
- The user clicks flash

The application state will contain an image path that is no longer
accessible, causing an ENOENT error when spawning the CLI process.

Change-Type: patch
Changelog-Entry: Display a user error if the image is no longer accessible when the writer starts.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-11 00:59:08 -04:00
Juan Cruz Viotti
cf271100f5 fix(image-stream): throw user error if image is a directory (#1279)
If the user tries to drag and drop a directory to the application, then
he'll get a scary `EISDIR` error message. This commit catches this
error, and display a nice user friendly message instead.

Change-Type: patch
Changelog-Entry: Prevent uncaught `EISDIR` when dropping a directory to the application.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-11 00:34:21 -04:00
Juan Cruz Viotti
44094680fb fix(image-stream): return a path from the handler (#1278)
The `application/x-apple-diskimage` handler doesn't return a path,
causing an issue when fetching the image metadata, and trying using the
path to determine if its a supported image type.

Change-Type: patch
Changelog-Entry: Fix "Path must be a string. Received undefined" when selecting Apple images.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-10 23:49:22 -04:00
Juan Cruz Viotti
fc46958ac0 fix(image-stream): interpret iso9660 as application/octet-stream (#1277)
This is a regression caused by
https://github.com/resin-io/etcher/pull/1257, which introduced a new way
to detect mime types by using the `mime-types` module.

This module, contrary to `file-type`, will detect certain ISO files as
`application/x-iso9660-image`, which Etcher doesn't know how to handle,
and will therefore should at the user that the format is unsupported.

Change-Type: patch
Changelog-Entry: Don't interpret certain ISO images as unsupported.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-10 23:49:11 -04:00
Juan Cruz Viotti
f87a690df1 fix(GUI): correctly reference the eta property in lib/gui/app.js (#1273)
See: https://github.com/resin-io/etcher/pull/1264/files#r110662965
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-10 16:57:20 -04:00
Ștefan Daniel Mihăilă
91a1c3d107 feat(GUI): use resin-corvus in AnalyticsService (#1208)
Change-Type: patch
Changelog-Entry: Start reporting errors to Sentry instead of to TrackJS.
Fixes: https://github.com/resin-io/etcher/issues/1027
2017-04-10 15:06:32 -04:00
Juan Cruz Viotti
1b68e9394b style(shared): fix given that is -> given that it typo (#1272)
See: https://github.com/resin-io/etcher/pull/1262#discussion_r110541438
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-10 14:36:01 -04:00
Benedict Aas
b28c345ba0 refactor(GUI): remove Angular from FlashStateModel and rename (#1264)
We remove the usage of Angular from 'FlashStateModel' and its usage
throughout the project comes under the new 'flashState' moniker.


Depends: https://github.com/resin-io/etcher/pull/1261
2017-04-10 14:30:21 -04:00
Benedict Aas
19dd2834fb fix(GUI): replace Math object usage in progressButton directive (#1263)
We were using `Math.min` in a progressButton's template expression,
however such object is not exposed to the Angular expression context.
2017-04-10 09:59:13 -04:00
Juan Cruz Viotti
3cdd925c41 refactor: get rid of is-elevated (#1262)
This commit implements our own version of the `is-elevated` module. The
reason behind this is that `is-elevated` relies on lots of unnecessary
modules, that eventually require `spawn-sync` and `try-thread-sleep`,
which conditionally require dependencies that are not even declared in
their `package.json`, causing issues when concatenating the Etcher CLI.

See: https://github.com/resin-io/etcher/pull/1235
See: https://github.com/resin-io/etcher/pull/1228
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-08 20:15:17 -04:00
Jonas Hermsmeier
b3b928ae4f feat(image-stream): Support Apple Disk Images (#1257)
This adds support for flashing Apple Disk Images (.dmg)

Change-Type: minor
2017-04-07 21:34:18 +02:00
Benedict Aas
ff495a45a8 refactor(GUI): remove angular from SettingsModel and rename (#1261)
We remove the usage of Angular in SettingsModel in our efforts to make
Etcher as agnostic as possible as we make our move to React.
2017-04-07 10:45:43 -04:00
Jonas Hermsmeier
07b6dd247d feat(robot): Support logging arbitrary data to the console (#1212)
This adds a new command recognition for message type "log",
to enable `console.log()`ing arbitrary data to the parent process console.

Not sure if we'd really want this in, but it's very handy for debugging,
and would keep us from writing these 3 lines every time
we want to inspect something in between those processes.

Change-Type: minor
2017-04-06 14:40:38 -04:00
Ștefan Daniel Mihăilă
7fe503c89a feat(GUI): add analytics image / drive info on flash done / error events (#1255)
Change-Type: patch
2017-04-06 14:39:49 -04:00
Juan Cruz Viotti
802d9abb1d refactor: unify image objects across GUI and image-stream (#1229)
`image-stream` returns image objects that look like this:

```js
{
  stream: <readable stream>,
  transform: <transform stream>,
  size: {
    original: <number>,
    final: {
      value: <number>,
      estimation: <boolean>
    }
  },
  ...
}
```

While the GUI handles image objects that look like this:

```sh
{
  path: <string>,
  size: <number>,
  ...
}
```

It looks like we should share a common structure between both, so we can
use `image-stream` images in `drive-constraints`, for example.

Turns out that we actually transform `image-stream` image objects to GUI
image objects when the user selects an image using the image selector
dialog, which is another indicator that we should normalise this
situation.

As a solution, this commit does the following:

- Add `path` to `image-stream` image object
- Reuse `image-stream` image objects in the GUI, given they are a
  superset of GUI image objects

See: https://github.com/resin-io/etcher/pull/1223#discussion_r108165110
Fixes: https://github.com/resin-io/etcher/issues/1232
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-06 09:41:08 -04:00
Benedict Aas
63901ccf77 fix(GUI): limit button progress and width to 100 (#1256)
We limit the progress button width by limiting the progress to a maximum
value of 100.

Change-Type: patch
Changelog-Entry: Prevent progress button percentage to exceed 100%.
2017-04-05 12:00:59 -04:00
Juan Cruz Viotti
e16234e3e8 refactor(GUI): get rid of drive-constraints Angular factory wrapper (#1250)
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-04 13:44:03 -04:00
Juan Cruz Viotti
71d5fad2b0 refactor(image-stream): get rid of rindle (#1246)
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-04 09:49:00 -04:00
Juan Cruz Viotti
c5a711af0f refactor(CLI): make use of mountutils to unmount drives (#1209)
`mountutils` is a native C++ NodeJS addon the Etcher team has been
working on to solve several issues we've been having with third party
unmount programs.

We'll see how this little module behaves after some real world usage.
I'm confident that it will fix the issues linked in this commit.

This commit also upgrades `npm` to 4.4.4 in Appveyor, given there is a
known building issue on Windows that is solved in a recent version.

Change-Type: minor
Changelog-Entry: Fix several unmount related issues in all platforms.
See: https://github.com/resin-io-modules/mountutils
Fixes: https://github.com/resin-io/etcher/issues/1177
Fixes: https://github.com/resin-io/etcher/issues/985
Fixes: https://github.com/resin-io/etcher/issues/750
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-02 21:34:05 -04:00
Juan Cruz Viotti
997133c979 refactor(GUI): get rid of basename Angular filter (#1252)
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-01 14:52:06 -04:00
Juan Cruz Viotti
4a3a123f42 refactor(image-stream): get rid of read-chunk (#1243)
We also took the opportunity to make `utils.getArchiveMimeType()`
asynchronous.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-01 14:47:14 -04:00
Juan Cruz Viotti
8fff29224d refactor(image-stream): get rid of gzip-uncompressed-size (#1247)
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-31 13:38:32 -04:00
Juan Cruz Viotti
8a12e9cf94 refactor(image-stream): get rid of isstream (#1244)
The dependency is not yet removed from `npm-shrinkwrap.json` given that
there another one that keeps requiring it.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-31 10:53:23 -04:00
Juan Cruz Viotti
bc2512ac5e refactor(GUI): get rid of the username module (#1245)
This module contains various fallbacks in case `os.userInfo()` doesn't
exist, which does exist in Electron.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-31 10:52:21 -04:00
Juan Cruz Viotti
4f66d6713f style(CLI): improve drive not large enough message wording (#1239)
See: https://github.com/resin-io/etcher/pull/1223#discussion_r108707741
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-30 01:42:34 +01:00
Andrew Scheller
06be2e9dfb style: fix require() typo in lib/cli/writer.js 2017-03-29 18:13:31 -04:00
Juan Cruz Viotti
0e8dee0506 fix(GUI): provide a friendly message when no polkit agent is available (#1221)
`sudo-prompt`, the module we use to provide elevation for GNU/Linux,
relies on polkit to show the elevation dialog. Polkit implements a
"backend" to control privileges, but relies on different packages to
provide a GUI frontend.

If no GUI frontend can be found on the system, then `sudo-prompt` will
fail with a `No polkit authentication agent found.` In this case, we
shouldn't present a scary stack trace to the user, and we should also
not send this error to TrackJS.

As a solution, we intercept such error in
`lib/child-writer/writer-proxy.js`, and convert it into a human readable
user error using `errors.createUserError()`, which is passed to the
Etcher GUI using the "robot" mechanism.

Fixes: https://github.com/resin-io/etcher/issues/1179
Change-Type: patch
Changelog-Entry: Provide a user friendly error message when no polkit authentication agent is available on the system.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-29 11:26:34 -04:00
Benedict Aas
e7f0613d82 feat(GUI): display drive name and description in tooltip (#1233)
In the main page we show the drive description, and on hover a tooltip
shows the drive name. The tooltip behaviour is changed to show both,
un-truncated.

Closes: https://github.com/resin-io/etcher/issues/1170
Changelog-Entry: Add the un-truncated drive description to the selected drive step tooltip.
2017-03-29 09:12:45 -04:00
Juan Cruz Viotti
78a3206295 fix(CLI): prevent flashing an image that is larger than the drive (#1223)
The CLI still happily let you flash an image that doesn't fit on the
drive. This commit prevents such scenario right before flashing, but we
should still implement a smarter CLI drive detection widget for when the
user runs the CLI interactively.

Change-Type: patch
Changelog-Entry: Prevent flashing an image that is larger than the drive with the CLI.
Fixes: https://github.com/resin-io/etcher/issues/858
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-28 13:55:58 -04:00
Juan Cruz Viotti
57952f6f55 fix(CLI): don't print stack traces by default (#1206)
Currently, the Etcher CLI will print scary stack traces for every single
error (e.g: if you forgot to pass an image to the tool), given that
`errors.getDescription()` will return a stack trace if no other
description could be found.

This commit introduces an `ETCHER_CLI_DEBUG` environment variable, which
when set, it will cause the Etcher CLI to output stack traces, plus a
boolean `userFriendlyDescriptionsOnly` option to
`errors.getDescription()`, so we can control whether
`errors.getDescription()` returns things like stack traces, or
stringified error objects.

Change-Type: minor
Changelog-Entry: Don't print stack traces by default in the CLI.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-28 09:43:15 -04:00
Juan Cruz Viotti
da85aa31aa style(CLI): improve error message when drive doesn't exist anymore (#1222)
The current message is short and unfriendly.

Fixes: https://github.com/resin-io/etcher/issues/1125
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-28 09:41:38 -04:00
Juan Cruz Viotti
63dda89035 fix(GUI): prevent blank application when sending SIGINT (#1220)
This issue only affects GNU/Linux and macOS. If the user sends SIGINT to
the application, the main process dies, but we get an orphaned blank
browser window. The problem only seems to occur when there is a
`beforeunload` window event handlers, which we use to warn the user when
quitting while flashing.

Change-Type: patch
Changelog-Entry: Prevent blank application when sending SIGINT on GNU/Linux and macOS.
Fixes: https://github.com/resin-io/etcher/issues/1028
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-28 09:39:23 -04:00
Juan Cruz Viotti
724d47fb6a doc(image-stream): document that .getFromFilePath also resolves metadata (#1217)
See: https://github.com/resin-io/etcher/pull/1211#issuecomment-288896853
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-27 09:58:55 -04:00
Juan Cruz Viotti
180802b985 fix(GUI): disallow reloading the app in macOS using Cmd+R (#1219)
Users can currently force the browser window to reload by using Cmd+R in
macOS. The `will-navigate` event handler in this same file is supposed
to protect us from this case, however it's not fired at all just in
macOS for some reason.

As a solution, we attach dummy keyboard shortcut handlers for Cmd+R,
Ctrl+R, and F5, to override the normal browser window behaviour.

The reason behind disallowing reloads is that a reload during a critical
operation such as writing, validation, elevating, unmounting, drive
scanning, etc will cause undefined behaviour, resulting in nonsense
errors that we can't solve coming to TrackJS.

See: https://github.com/electron/electron/issues/8841
Fixes: https://github.com/resin-io/etcher/issues/1210
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-26 19:29:11 -04:00
Jonas Hermsmeier
3d68688f33 fix(image-stream): destroy unused image streams (#1211)
When fetching metadata, a stream is opened, but never consumed.
This destroys the stream when retrieving metadata to avoid
dangling open file descriptors and such.

Change-Type: patch
Changelog-Entry: Fix unmounting freezing in macOS.
Fixes: https://github.com/resin-io/etcher/issues/985
2017-03-24 11:58:13 -04:00
Andrew Scheller
f595f4ad04 style: fix typo in code-comment (#1213) 2017-03-24 11:10:52 -04:00
Juan Cruz Viotti
9f3798978d upgrade: is-elevated to v2.0.1 (#1184)
This version contains a fix for correctly checking whether a process is
running with administrator right or not, without depending on the
"Server" service.

Fixes: https://github.com/resin-io/etcher/issues/1180
See: https://github.com/sindresorhus/is-admin/pull/4
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-21 11:17:02 -04:00
Benedict Aas
58f30494b4 feat(GUI): show drive name instead of device name (#1181)
We show the friendly drive name on the main page with the drive's device name
or mount point now inside a tooltip. Drive names longer than 11 characters are
truncated with a middle ellipsis.

Change-Type: minor
Changelog-Entry: Show friendly drive name instead of device name in the main screen.
Closes: https://github.com/resin-io/etcher/issues/1170
2017-03-20 17:00:07 -04:00
Andrew Scheller
c9702c3a6d chore: get the CI tests working again (#1182)
* chore: get the CI tests working again
 * an updated eslint-plugin-lodash was creating extra linter errors where we
   were using built-in String methods instead of the lodash equivalents
 * an updated codespell package now installs with a different executable-name
   (no .py extension), and now supports multiple dictionaries
 * while I was at it I replaced the messy double-quoting-string logic with the
   command-join module

Changelog-type: patch

* chore: downgrade codespell to 1.9.2 because the latest version has issues running on Windows
(we'll hopefully be able to revert this commit when codespell works again properly!)
2017-03-15 16:32:25 -04:00
Ștefan Daniel Mihăilă
fe20f5061f fix(GUI): don't log absolute paths in Mixpanel (#1161)
The event data may contain absolute paths that contain user information that
should not be logged in Mixpanel. Instead, we replace absolute path properties
with their base name.

Change-Type: patch
Changelog-Entry: Don't include user paths in Mixpanel analytics events.
2017-03-15 00:05:48 -04:00
Juan Cruz Viotti
2342831104 fix(GUI): avoid duplicated TrackJS errors (#1176)
I've noticed that errors reported to TrackJS appear twice. Turns out
that TrackJS pipes output of `console.error()` as errors, rather than as
extra logging.

The `AnalyticsService.logException()` function reports the exception to
TrackJS using `$window.trackJS.track()`, but then prints it to `stderr`
as well (so it appears on DevTools), causing TrackJS to report that one
too.

The solution is to disable the `console.error` boolean property of the
`_trackJs` object. From the TrackJS documentation:

```
// By default any calls to console.error() will automatically trigger an
// error. Set this to false if you don't want console.error() to
// trigger errors.
error: true,
```

See: http://docs.trackjs.com/tracker/configuration
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-13 11:00:26 -04:00
Andrew Scheller
ee2bbef9da chore: codespell improvements (#1174)
* fix the command so it actually works - see https://github.com/lucasdemarchi/codespell/issues/101
 * check the spelling of more files
 * ignore known-binary filetypes
 * fix a couple of spelling mistakes it caught

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-11 18:10:54 -04:00
Ștefan Daniel Mihăilă
34c85eb150 feat(GUI): improve analytics events (#1111)
* feat(GUI): improve analytics events

This commit adds more events to our current analytics.
Will further improve in a future commit.

Change-Type: patch
See: https://github.com/resin-io/etcher/issues/1100

* refactor(gui): use single function to set normal and dangerous settings

Change-Type: patch
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-10 15:18:49 -04:00