This implements an SDK.Scanner which handles any given
adapters and manages the scans. This change enables continuous
scanning without the need to `.scan()` scheduling in other places.
Change-Type: minor
We fix the DEBUG environment variable by setting it on the `electron.remote`
instead, and we also move the code to `lib/gui/app.js` and away from
`lib/gui/index.html`.
Changelog-Entry: Set the DEBUG environment variable on the remote
electron process.
Change-Type: patch
* use debug.enabled, fix drivelist env setting
* fix: set debug env variable on remote electron process
* feat(GUI): use tabindex and focus to navigate
We make navigating with the tab key easier by highlighting focused
elements more visibly, adding `tabindex` attributes to elements, and
making `open-external` links respond to keyboard events.
Change-Type: minor
Changelog-Entry: Improve tab-key navigation through tabindex and visual improvements.
Connects-To: https://github.com/resin-io/etcher/issues/1734
* outline with 10s timeout
* use orange "warning colour" as outline
* smaller outline on settings buttons, fix order on settings page
* allow selection in drive-selector
* fix typo, better tabindexes
This is a workaround to prevent the USB device from disappearing after
the file server phase, until the resulting block device comes up.
By adding a delay after the file server phase, we prevent the USB
scanner from getting triggered again, therefore keeping the current USB
device visible in the drive selector modal.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This commit re-architects the usbboot adapter to prepare the drives in
the background, while emitting scan results every 2s, where each drive
has a `progress` percentage property.
Change-Type: minor
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
We prompt the user with a sudo-prompt upon launch on Linux-based systems
to ensure the program has enough permissions for features needed
throughout the program's runtime.
Changelog-Entry: Add a sudo-prompt upon launch on Linux-based systems.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
* refactor(SDK): make adaptor scan functions event based
This change will allow us to start emitting progress events out of the
adaptors scan functions.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
* refactor(sdk): Make adapters event emitters
We show a progress bar for any drive objects with a `progress` field
that isn't falsy, e.g. `undefined` or `0`.
Changelog-Type: minor
Changelog-Entry: Add optional progress bars to drive-selector drives.
The combination of bus number and device address is the only way to
uniquely identify a USB device, so we'll use that for the `device` and
`raw` properties.
Also, we store the USB vendor and product IDs as properties of the
drives, since they will be handy when implementing the prepare function.
Change-Type: patch
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Consider the following scenario:
- Usbboot runs successfully on a device
- Before the block device gets a chance to appear, we run usbboot again
If we're fast enough, usbboot will try to claim the device interface,
but then the drive might not be there anymore, causing a
`LIBUSB_ERROR_NO_DEVICE`.
This commit addresses that scenario, and simply ignores the drive.
Change-Type: patch
Changelog-Entry: Fix `LIBUSB_ERROR_NO_DEVICE` error at the end of usbboot.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
We currently ship with `bootcode.bin` and `start.elf` from the Raspberry
Pi Foundation, which provide a writing speed of about 6 MB/s. This PR
includes new boot files by resin.io that boost the speed to ~20 MB/s.
Change-Type: minor
Changelog-Entry: Increase the flashing speed of usbboot discovered devices.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This commit handles errors that can come up when unplugging the drive
halfway through the process. After tons of experimentation, the errors
than seem to occur are:
- `LIBUSB_TRANSFER_CANCELLED`
- `LIBUSB_ERROR_NO_DEVICE`
When these errors happen, we can omit the drive, and also not try to
close it, since given the device is no longer there, the close operation
bails out with a strange error message.
Change-Type: patch
Changelog-Entry: Gracefully handle scenarios where a USB drive is disconnected halfway through the usbboot procedure.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
We have a debug message that prints `device.name`, which is not a valid
property, and therefore the debug logs show `undefined` instead of the
USB id pair.
Change-Type: patch
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Some devices don't have a size, like USB devices in the usbboot adaptor.
The `.isDriveLargeEnough()` correctly returns `false` in this case,
however we don't want to show the `TOO SMALL` badge for aesthetics
purposes.
So if a drive has a size that equals `null`, we don't allow such drive
to be selected, and we don't show a badge for it.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Some drives, like usbboot USB devices, don't have a size associated with
them, which results in the drive selection widget showing a hyphen with
nothing at the side, which looks a bit weird.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This commit introduces a boolean `disabled` property rather than a
`pending` flag. Making this distinction clearer means that we can now
treat pending drives in different ways needed to improve the usbboot
experience.
Also, for usbboot, this commit removes the "pending" badge and uses a
more descriptive drive description instead.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
At the moment the progress button which has slightly rounded corners
allows the "__bar" to overflow. This causes the corners to become
angular again which looks weird. I set the button's "overflow" to
"hidden" to fix this issue.
Changelog-Entry: Make sure the progress button is always rounded.
Change-Type: patch
- Add a nice icon in the drive selector dialog when a device has been
discovered through usbboot
- Change the name of usbboot-initialized devices to "Compute Module"
Change-Type: minor
Changelog-Entry: Add eye candy to usbboot initialized devices.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
We experienced timeouts when sending big files (ie ~14 MBs). Setting the
timeout to 0 makes the timeout infinite.
Change-Type: patch
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This commit installs `node-usb` v1.3.0 from GitHub, since that version
was never published to NPM, and is the only one that works with Visual
Studio 2015 (see https://github.com/tessel/node-usb/issues/109).
The usbboot communicates with a Raspberry Pi / Amber through USB and
eventually mounts it as a block device we can write to.
This feature bundles bootcode.bin and start.elf from the original
usbboot implementation.
The flow is the following:
- On each scan, the usbboot scanner will try to get a usbboot compatible
USB device to the next "phase", until they are all transformed to
block devices the user can flash to as usual
Change-Type: minor
Changelog-Entry: Integrate Raspberry Pi's usbboot technology.
Fixes: https://github.com/resin-io/etcher/issues/1541
See: https://github.com/raspberrypi/usbboot
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This allows selection of images without a secondary file extension
(i.e. `example.gz`, compared to `example.img.gz`) by defaulting to `img`
in the image-stream handlers, should no secondary extension be found.
Further this adjusts `.getPenultimateFileExtension()` to return `null`
if the detected penultimate extension is not a known file extension.
Change-Type: patch
This removes `Bluebird.props()` from the image type handlers,
as it's just a remnant when some properties in the return value
were Promises that needed resolving.
Change-Type: patch
Connects To: #1724
We recently added a "pending" flag to all drives that represents whether
the drive is ready for selection or not. This flag will be used by the
"usbboot" flashing adaptor, which will emit various "pending" USB
devices while it converts them to block devices that can actually be
flashed.
In terms of the GUI, the following visible changes were made:
- Drives with a `pending: true` property will be disabled in the drive
selector window
- Drives with a `pending: true` property have a "PENDING" red badge
See: https://github.com/resin-io/etcher/pull/1707
See: https://github.com/resin-io/etcher/pull/1686
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This is a major first step towards adopting an SDK architecture. This
commit creates an SDK adaptor with a `.scan()` function that uses
`drivelist` under the hood. Then, an SDK orchestrator is used to provide
drive scanning capabilities to the GUI.
Here's a list of some particularly interesting changes:
- The drives returned by the SDK adaptor now have a "pending" and an
"adaptor" property. The "pending" property is a boolean flag that
determines if the drive is ready to be used (this will come handy for
usbboot), while the "adaptor" property simply contains the name of the
adaptor that drive came from
- The GUI drive scanner Rx implementation was replaces with a "promise
loop." Before, the drive scanning routine would be called every 2
seconds (without waiting for the previous scan to complete), while
now, the next scan happens *after* the previous scan completes. For
this reason, I reduced the drive scanning interval timeout to match
the timing we had before
Change-Type: patch
See: https://github.com/resin-io/etcher/pull/1686
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
As another step towards moving to GitHub Releases, this commit makes the
application care much less about the actual release type of the current
version, instead checking if the application is stable or not, which is
more aligned to what GitHub provides us.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This disables full wildcard debug output by default now,
leave the possibility to manually enable selective debug output
via the `DEBUG` environment variable.
Change-Type: patch
This checks for `parsererror`s in the DOMParser's returned document,
to prevent re-use of the previous image and avoid displaying an error
document in the SVG icon slot.
Change-Type: patch
Changelog-Entry: Avoid "broken" icon when selecting a zip image archive with invalid SVG.
We send an HTTP request to S3 to determine the latest available version.
There are various error that can happen that we don't have control over
(like `ETIMEDOUT`).
The current approach is to whitelist certain errors and pretend there is
no update available, however this commit improves that whole situation.
Instead of swallowing these errors, we throw a user error from the
function that determines the latest available version. From the
application code, we check if that function throws a user error, and if
so, instead of showing it to the user, we log a mixpanel event and carry
on.
This change is motivated by the latest reporter error we can't do
anything about: `UNABLE_TO_GET_ISSUER_CERT_LOCALLY`.
Fixes: https://github.com/resin-io/etcher/issues/1525
Change-Type: patch
Changelog-Entry: Fix `UNABLE_TO_GET_ISSUER_CERT_LOCALLY` error at startup when behind certain proxies.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
- Extend the `standard` ESLint configuration
- Remove ESLint rules that are defined in the `standard` configuration
- Get rid of semi-colons
See: https://github.com/resin-io/etcher/pull/1657
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This commit changes the whole codebase to adhere to all StandardJS
guidelines rules except semicolons, since the removal of semicolons
affect pretty much all lines, and the final diff is very hard to follow
(and to assess other more involved changes).
In a nutshell:
- When using `function`, we now require a space before the opening
parenthesis
- If a line with operators is broken into multiple lines, the operator
should now go after the line break
- Unnecessary padding lines are now forbidden
There were also some minor things that the `standard` CLI caught that I
updated here.
See: https://standardjs.com
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
There's not much we can do if we can't connect to S3 to determine the
latest available versions when checking if we should show an update
notification dialog or not.
As with similar errors, lets swallow this particular one, and try again
the next time Etcher runs.
Change-Type: patch
Changelog-Entry: Fix `EHOSTDOWN` error at startup.
Fixes: https://github.com/resin-io/etcher/issues/1645
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Change-Type: patch
Changelog-Entry: Display a user-friendly error message if the user is not in the sudoers file.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
We make the size units used the closest relative unit through a new
filter `closestUnit` replacing the old `gigabyte` filter.
Changelog-Entry: Round byte sizes to the more appropriate unit.
* remove filters folder
* new shrinkwrap, add to package.json
* test
We make the svg-icon component accept XML in its path argument to handle
archive-embedded SVG icons.
Changelog-Entry: Make archive-embedded SVG icons work again.
Fixes: https://github.com/resin-io/etcher/issues/1636
The `flashComplete` message takes the drive object and the image
basename as arguments. This was updated on the GUI, but causes the CLI
to throw an error upon completion.
Change-Type: patch
Changelog-Entry: Fix "imageBasename is not defined" error on the CLI.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Support the rpi-sdcard image file type output by Yocto for
the Raspberry Pi device.
Change-Id: Ia7e3aef0d90fdf21d373a560e6dd2b96e6b51da8
Changelog-Entry: Add support for `.rpi-sdcard` images.
This is part of the process of implementing support for a configuration
file. We previously decoupled the Redux store from localStorage by
moving the logic that actually persists the data to localStorage to a
local-settings.js file, however the localStorage API is synchronous, so
it follows that at the moment, all functions that interact with are also
synchronous.
Moving to storing the settings to a file means turning all these
functions to promises, which we do in this commit, in order to not mix
the addition of the configuration file feature with the huge amount of
refactoring it requires.
See: https://github.com/resin-io/etcher/issues/1356
Change-Type: patch
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This commit refactors the xz and gzip image handlers to pass/use a
custom read function to be able to determine the uncompressed size, and
other needed metadata.
By using this function (which currently only uses the `fs` module), we
can implement support for getting the uncompressed size of compressed
files using HTTP Ranges.
Change-Type: patch
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Simply running `_.merge` on an Error object results in an empty plain
object `{}` being sent to Mixpanel/Sentry.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>