Electron v1.6.1 introduced checkbox support to the native message
dialog, giving us everything that was needed to implement the update
notifier modal using a native dialog.
This change allows us to get rid of a lot code.
See: https://github.com/electron/electron/pull/8590
Change-Type: patch
Changelog-Entry: Turn the update notifier modal into a native dialog.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
When the user is behind a firewall, then the HTTP request to query the
latest available version from S3 may throw an EACCES error, eventually
causing a confusin "You don't have access to this resource" error
window.
Change-Type: patch
Changelog-Entry: Fix "You don't have access to this resource" error at startup when behind a firewall.
Fixes: https://github.com/resin-io/etcher/issues/1458
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
Querying S3 to determine the latest available versions might throw
`ECONNRESET` and `ECONNREFUSED`. This commit extends the
`s3Packages.getRemoteVersions()` function to handle these errors and
return no available version if so, like we already do with other similar
HTTP errors.
Change-Type: patch
Changelog-Entry: Fix `ECONNRESET` and `ECONNREFUSED` errors when checking for updates on unstable connections.
Fixes: https://github.com/resin-io/etcher/issues/1396
Fixes: https://github.com/resin-io/etcher/issues/1388
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
* Centralise drive error/warning messages with a function
`.getDriveImageCompatibilityStatuses` in `lib/shared/drive-constraints.js`
-- tests included
* Fix an error where several labels show at once
* Clarify the source drive label to 'Drive Contains Image'
* Remove label icons and make text bold to match Zeplin's design
Closes: https://github.com/resin-io/etcher/issues/1143
Closes: https://github.com/resin-io/etcher/issues/1144
We limit the Store state flashing percentage to be within 0-100,
throwing errors otherwise. Comes with tests.
Changelog-Type: Bound flash progress percentage within 0-100 range.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This displays a user error if the reading the image causes an error,
instead of letting it fall through and get reported.
This is to avoid reporting errors that are not due to malfunction of the software,
but due to malformatted images.
Change-Type: minor
Changelog-Entry: Display nicer error dialog when reading an invalid image
Using `mime-types` in that place made it impossible to use other
other file extensions like `.sdcard` and have them treated as `application/octet-stream`
when drag and dropping images into Etcher.
This moves the fallback logic in `lib/image-stream` to `.getFromFilePath()`,
to still facilitate proper MIME type detection, while allowing it to fall back
to the octet-stream handler, if there's no available handler for a specific type.
Change-Type: patch
Changelog-Entry: Fix not treating unknown images as octet-stream
This utility function is useful to avoid duplicating the logic of
checking whether an error is a user error across the code base.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
`etcher-latest-version` was kept in a separate repository in order to
re-use it with the Etcher website, however the Etcher website is not
using it at all, and we're moving towards having the website in the main
repository.
Therefore, this commit brings back the logic from
`etcher-latest-version`, but introduces it as
`lib/shared/s3-packages.js`, in order to not tie ourselves to the
AngularJS framework, and as a step towards the Etcher SDK.
As a nice little bonus, this commit adds support for an
`ETCHER_FAKE_S3_LATEST_VERSION` environment variable that can be used to
trick Etcher that there is an available update, and therefore show the
update notifier modal.
Also, this commit adds support for snapshot builds update-checks, by
checking the `resin-nightly-downloads` S3 bucket if the current version
contains a git commit hash build number.
If the version is not a production release, then the update notifier
modal doesn't present the checkbox to disable update notifications for X
days.
We also add a property called `updates.semverRange` to `package.json`,
which can be used to fine control which versions are considered as
candidates for an update notification.
This commit adds a setting called `includeUnstableChannel`, which can be
used to tweak whether unstable (beta) releases are considered or not
when checking for the latest available version.
See: https://github.com/resin-io-modules/etcher-latest-version
Fixes: https://github.com/resin-io/etcher/issues/953
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
The elevation mechanism currently embedded in
`lib/child-writer/writer-proxy.js` is extracted as a separate re-usable
function in `lib/shared/permissions.js`.
This change hugely simplifies the writer proxy, while allowing us to
iterate faster on the elevation core functionality.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
Currently, both of these functions accept two arguments: the error
title, and the error description. This function signature makes is hard
to keep adding options to these error creation functions, like an error
code, so this commit refactors them to take a single argument: an
options object containing `title` and `description` properties.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
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>
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>
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>
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>
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>
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
This changes the test cases to just return the Promises,
to avoid timing out on failures and to provide better
error messages and stack traces.
Change-Type: patch
`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>
`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>
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>
* 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!)
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.
* 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>
The current error handling logic is a mess. We have code that tries to
fetch information about errors in different places throughout the
application, and its incredibly hard to ensure certain types of error
get decent human friendly error messages.
This commit groups, improves, and tests all error related functions in
`lib/shared/errors.js`.
Here's a summary of the changes, in more detail:
- Move the `HUMAN_FRIENDLY` object to `shared/errors.js`
- Extend `HUMAN_FRIENDLY` with error descriptions
- Add `ENOMEM` to `shared/errors.js`
- Group CLI and `OSDialogService` mechanisms for getting an error title
and an error description
- Move error serialisation routines from `robot` to `shared/errors.js`
- Create and use `createError()` and `createUserError()` utility
functions
- Add user friendly descriptions to many errors
- Don't report user errors to TrackJS
Fixes: https://github.com/resin-io/etcher/issues/1098
Change-Type: minor
Changelog-Entry: Make errors more user friendly throughout the application.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This is one step towards enforcing the linter until we barely have to
check for style issues on code reviews.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
There are a lot of new rules since the last time I revised the ESLint
rules documentation.
I've updated the main `.eslintrc.yml` to include some newer additions,
plus I added another ESLint configuration file inside `tests`, so we can
add some stricted rules to the production code while relaxing them for
the test suite (due to the fact that Mocha is not very ES6 friendly and
Angular tests require a bit of dark magic to setup).
This is a summary of the most important changes:
- Disallow "magic numbers"
These should now be extracted to constants, which forces us to think of
a good name for them, and thus make the code more self-documenting (I
had to Google up the meaning of some existing magic numbers, so I guess
this will be great for readability purposes).
- Require consistent `return` statements
Some functions relied on JavaScript relaxed casting mechanism to work,
which now have explicit return values. This flag also helped me detect
some promises that were not being returned, and therefore risked not
being caught by the exception handlers in case of errors.
- Disallow redefining function arguments
Immutability makes functions easier to reason about.
- Enforce JavaScript string templates instead of string concatenation
We were heavily mixing boths across the codebase.
There are some extra rules that I tweaked, however most of codebase
changes in this commit are related to the rules mentioned above.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
These errors happen when the user selects an archive that contains no
image, or multiple images, and represents a user error, rather than an
unhandled exception.
For this reason, we should not report this to TrackJS.
This means, however, that we need a reliable way to know whether an
error should be reporter or not. This commit implements
`AnalyticsService.shouldReportError()` for this purpose, which will
check an optional `report` property of the error object.
In order to ensure that errors that we don't control are reported, the
function will return `true` if the error object doesn't have that
property.
Change-Type: patch
Changelog-Entry: Don't report "invalid archive" errors to TrackJS.
Fixes: https://github.com/resin-io/etcher/issues/1103
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
We revert the drive and image selection step order swap back from drive
selection first and image second, to image first and drive second.
See: https://github.com/resin-io/etcher/pull/1049
Angular 1.5 has a bug that causes angular's `$exceptionHandler`
to be called for rejected `$q` promises even if they have
a rejection handler. This bug caused duplicate error messages
in Etcher.
A consequence of upgrading to Angular 1.6 is that `$q` promises
without a rejection handler will throw `Possibly unhandled rejection`
errors. To avoid these errors, this commit moves code responsible
for opening a tooltip from the template to the controller and handles
the rejection.
Other packages upgraded:
- angular-moment to v1.0.1
- angular-ui-router to v0.4.2
- angular-mocks to v1.6.1
Change-type: patch
Changelog-Entry: Fix duplicate error messages
Fixes: https://github.com/resin-io/etcher/issues/1082
See: https://github.com/angular/angular.js/issues/7992
See: https://github.com/angular/angular.js/pull/13662
Currently Etcher will auto-select a system drive if its the only
available one when the "unsafe mode" is enabled, which doesn't feel
right.
Change-Type: patch
Changelog-Entry: Don't auto select system drives in unsafe mode.
See: https://github.com/resin-io/etcher/pull/1061
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>