940 Commits

Author SHA1 Message Date
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
Ștefan Daniel Mihăilă
465a0e9e04 style(GUI): reduce eslint-disable no-var scope (#1163)
Change-Type: patch
2017-03-10 13:12:13 -04:00
Juan Cruz Viotti
e4a9a03239 refactor: unify error related tasks (#1154)
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>
2017-03-10 13:11:45 -04:00
Juan Cruz Viotti
a624b24bfc fix(GUI): stop drive scanning loop if an error occurs (#1169)
If the drive scanning scripts cause an error, the error will be
presented to the user over and over again. Not only this is terrible UX,
which even makes hard to close the application since dialogs keep coming
in, but it also spams TrackJS, our error reporting service, and makes it
seem that errors happened dozens of times, and thus obscuring real
trending errors.

Change-Type: patch
Changelog-Entry: Stop drive scanning loop if an error occurs.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-09 11:58:14 -04:00
Juan Cruz Viotti
df8611df11 chore: add ESLint Lodash plugin (#1148)
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>
2017-03-08 19:11:15 -04:00
Juan Cruz Viotti
6c8bc117ab chore: revise ESLint built-in configuration (#1149)
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>
2017-03-07 23:46:44 -04:00
Juan Cruz Viotti
98284bd5e2 fix(GUI): don't report "invalid archive" errors to TrackJS (#1152)
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>
2017-03-02 12:21:48 -04:00
Juan Cruz Viotti
1a00430999 chore: fix JSDoc warnings (#1151)
- The type in `@type` should be surrounded by curly braces
- We should use `@type` in some cases where we used `@property`
- `@module` descriptions should go above such tag
- Namespaces should not declare their access type

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-02 12:13:28 -04:00
Juan Cruz Viotti
dfd5f70013 style(GUI): fix small chain indentation issue (#1150)
I couldn't find an ESLint rule that would protect us from this in the
future.

See: https://github.com/resin-io/etcher/pull/1148#discussion_r103525165
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-01 18:52:29 -04:00
Juan Cruz Viotti
4172291a10 chore: improve JSDoc ESLint rules (#1147)
- Prefer `@returns` to `@return`
- Prefer `@param` to `@arg`
- Prefer capitalised types

See: https://github.com/resin-io/etcher/pull/1111#discussion_r103483879
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-01 14:26:47 -04:00
Benedict Aas
33a4ed8c95 feat(GUI): allow opening drive selector modal when no drives (#1146)
We change the drive selector button text to be a static 'select drive'
and allow the user to open the dialog even if there are no drives,
displaying the 'no drives' warning inside the modal.

Closes: https://github.com/resin-io/etcher/issues/884
Changelog-Entry: Allow opening the drive selector modal when there are no
drives.
2017-03-01 10:27:26 -04:00
Ștefan Daniel Mihăilă
4604e89b4f chore: add aknowledge->acknowledge to codespell dictionary 2017-02-28 11:45:29 -04:00
Ștefan Daniel Mihăilă
5b9104e8aa feat(GUI): warn when atempting to burn Windows images (#1043)
Change-Type: minor
Changelog-Entry: Show warning when user tries to flash a Windows image
Closes: https://github.com/resin-io/etcher/issues/1035
2017-02-24 15:12:03 -04:00
Juan Cruz Viotti
f4c92676a9 fix(GUI): update notifier transformRequest error at startup (#1122)
Etcher checks what is the latest version by making an HTTP request to S3
in order to see if it should present the update notifier modal at
startup.

If the user is not connected to the internet, or is on an unstable
connection, the request might fail completely or timeout, leading to a
weird error message being presented to the user:

```json
{
  "data": null,
  "status": -1,
  "config": {
    "method": "GET",
    "transformRequest": [null],
    "transformResponse": [null],
    "url": "https://resin-production-downloads.s3.amazonaws.com",
    "headers": {
      "Accept": "application/json, text/plain, */*"
    }
  },
  "statusText": ""
}
```

To solve the error, we tweak `UpdateNotifierService.getLatestVersion()`
to resolve the current version if there was a problem making the request
(e.g: the response didn't come through at all), which after some
experimentation, we can check by comparing the `status` property with
`-1`.

This error happens in all operating systems, and currently is trending
on TrackJS.

Change-Type: patch
Changelog-Entry: Fix `transformRequest` error at startup when not connected to the internet, or when on an unstable connection.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-23 11:20:10 -04:00
Juan Cruz Viotti
c3e7e07532 docs: group CLI developer oriented documentation at lib/cli/README.md (#1105)
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-21 17:43:25 -04:00
Juan Cruz Viotti
9aa23c1590 docs: add developer documentation to the lib/image-stream module (#1107)
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-21 17:43:10 -04:00
Benedict Aas
295585fb06 feat(gui): new flashing step icon (#1119)
We update the flashing step's icon to the new lightning strike icon.

Changelog-Type: Update flashing step's icon to a lightning strike.
2017-02-21 08:12:09 -04:00
Benedict Aas
78ff320d98 minifix: re-build css (#1120) 2017-02-21 08:11:50 -04:00
Benedict Aas
7adb5b5485 feat(GUI): update image step icon (#1118)
We replace the old image step with the more general 'plus' icon.

Changelog-Entry: Update the image step icon with an hexagonal "plus" icon.
2017-02-20 09:03:55 -04:00
Juan Cruz Viotti
cf4dc5ff37 refactor(GUI): remove component-drive-selector-body outdated class (#1072)
The rules inside this class should be moved to
`.modal-drive-selector-modal`.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-13 14:59:29 -04:00
Juan Cruz Viotti
a60f7134fc chore: add an HTML linter and fix its warnings (#1077)
This PR creates a script at `scripts/html-lint.js` that runs a NodeJS
HTML linter package that understands AngularJS on top of all our HTML
templates.

The following error was detected and fixed:

```
1 errors at lib/gui/pages/finish/templates/success.tpl.html
  [4:63] Duplicate attribute “class”.
```

This script will run as part of `npm run lint`, but you can call it
independently as `npm run htmllint`.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-13 14:58:29 -04:00
Juan Cruz Viotti
43c08d1547 docs: explain the "robot" module in a high level way (#1081)
This commit adds a README file at `lib/shared/robot` explaining in
detail how the "robot" mechanism works, and why it is needed.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-10 11:59:23 -04:00
Benedict Aas
db8f7d0862 refactor(gui): revert drive/image selection step order swap (#1086)
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
2017-02-10 11:59:01 -04:00
Juan Cruz Viotti
6bdba5ffd4 style(GUI): move update notifier checkbox inside modal body (#1071)
This is a small step towards unifying all the modal skeletons that we
use through the application.

By moving the checkbox to the modal body we can declare the footer and
the header once in a single place.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-09 11:30:19 -04:00
Benedict Aas
838f3cc50d minifix: re-build css (#1088) 2017-02-09 11:29:57 -04:00
Juan Cruz Viotti
b55ff3eef8 style(GUI): use a OS dialog to show the "exit while flashing" warning (#1070)
For better OS integration purposes.

This commit also fixes a bug where the dialog would be shown for some
milliseconds even if the application is not flashing.

Change-Type: minor
Changelog-Entry: Use a OS dialog to show the "exit while flashing" warning.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-08 10:04:45 -04:00
Ștefan Daniel Mihăilă
92fdba3642 upgrade: angular to v1.6.1; angular-ui-bootstrap to v2.5.0 (#1083)
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
2017-02-07 19:12:32 -04:00
Ștefan Daniel Mihăilă
f4c6597b3d style(GUI): minor fixes in comments (#1084) 2017-02-07 17:31:30 -04:00
Juan Cruz Viotti
05fdd5cc29 refactor(GUI): unify modal body styles (#1073)
- Remove unnecessary `.modal-text` wrapper
- Move drive selector specific styles to `_drive-selector.scss`

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-07 16:14:15 -04:00
Juan Cruz Viotti
70c7ddc52a fix(GUI): don't auto select system drives in unsafe mode
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>
2017-02-07 13:34:07 -04:00
Shou
048aac5ac2 feat(gui): update main page design
We match the main page design to its updated style.

* Remove help icon text.
* 'Change' image/drive buttons are now violet blue.
* Remove step number icons and accompanying descriptions.
* Flash progress button now turns into a striking orange, from blue.

Changelog-Entry: Update main page design to its new style.
2017-02-07 12:21:45 -04:00
Juan Cruz Viotti
c7d4ac6518 upgrade: drivelist to v5.0.9
This version doesn't throw an error if there is `stderr` output from the
scripts but the scripts exit with code zero.

Instead, the module prints the `stderr` output to a `debug` channel, so
we enable debug information by setting a `localStorage` value in order
to see what's going on.

Fixes: https://github.com/resin-io/etcher/issues/1034
Change-Type: patch
Changelog-Entry: Ignore `stderr` output from drive detection scripts if they exit with code zero.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-06 14:53:38 -04:00
Juan Cruz Viotti
8e5840ce69 chore: integrate codespell and fix existing spelling issues
This tool scans the comments of every source file and reports back
spelling errors.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-06 14:53:20 -04:00
Juan Cruz Viotti
95d4f2f608 fix(GUI): prevent flashing the drive where the source image is located
Currently Etcher will allow you to flash an image to the same drive that
contains the image. As a way to protect against that case we introduce
the concept of a "source drive", which means a drive that contains the
source image.

This commit adds the following logic around this new concept:

- Don't auto-select a source drive
- De-select an already selected drive if an image inside it is selected
- Disable the drive in the drive selector modal
- Add a "Source Drive" badge to the drive in the drive selector modal

Fixes: https://github.com/resin-io/etcher/issues/830
Change-Type: minor
Changelog-Entry: Prevent flashing the drive where the source image is located.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-06 14:53:08 -04:00
Juan Cruz Viotti
4f621f6ae3 style(GUI): capitalize every text for consitency purposes (#1056)
Fixes: https://github.com/resin-io/etcher/issues/881
Change-Type: patch
Changelog-Entry: Capitalize every text throughout the application.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-27 11:08:49 -04:00
Juan Cruz Viotti
fd9d3ce749
Revert "refactor: remove extended archives extra functionality (#1055)"
This reverts commit b78473ea0ebd76233217fb4f236bb34be635da90.
2017-01-26 18:36:33 -04:00
Juan Cruz Viotti
b78473ea0e refactor: remove extended archives extra functionality (#1055)
We currently attempt to read extra metadata from ZIP files, such as a
logo, image name, image url, etc. In order to simplify the metadata
story, we decided that this metadata will not live on the image itself,
but rather on a centralised repo, which greatly simplified our custom
archive extraction logic and allows us to make use of these nice
features even when streaming the image directly from the internet.

We'll be working on bringing back this functionality from a centralised
repo in subsequent commits.

Change-Type: major
Changelog-Entry: Remove extended archives metadata extraction logic.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-26 15:21:01 -04:00
Juan Cruz Viotti
1bfcee06e2 refactor(image-stream): stream original/final sizes (#1050)
The `image-stream` module currently returns a readable stream, a
transform stream, a "size", and an optional "estimatedUncompressedSize".

Based on this information, its hard to say what "size" represents. Some
format handlers return the compressed size and provide a decompression
transform stream while others return the decompressed stream directly
and put the decompressed size in "size".

As a way to simplify this, every format handler now returns a "size"
object with the following properties:

- `original`: The original compressed size
- `final.estimated`: Whether the final size is an estimation or not
- `final.value`: The final uncompressed size

As a bonus, we extract the file size retrieval logic to
`imageStream.getFromFilePath()`, which is the onlt part where the
concept of a file should be referred to.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-26 12:01:53 -04:00
Benedict Aas
b25b2d1179 feat(GUI): swap drive and image selection step order (#1049)
Change the first step to be drive selection and the second step to be
image selection, instead of vice versa as it previously was.

Changelog-Entry: Swap the order of the drive and image selection steps.
2017-01-26 12:01:10 -04:00
Juan Cruz Viotti
9dd9065305 refactor(GUI): reuse WarningModalService in FlashErrorModal (#1051)
This is the first commit in a series of changes to normalise the use of
modals throughout the application.

`FlashStateModel` is basically a `WarningModalService` that cleans the
flash state, therefore making it re-use `WarningModalService` directly
removes unnecessary duplication.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-25 17:06:49 -04:00
Juan Cruz Viotti
4649bace00 style(GUI): change WarningModal title to "Attention" (#1052)
See: https://github.com/resin-io/etcher/pull/1043
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-25 17:06:16 -04:00
Juan Cruz Viotti
7165c60f0d fix(GUI): normalize button text casing (#1046)
Some button texts are all uppercase, while the remaining of them are
capitalised. This commit capitalises all button texts for consistency
purposes.

Fixes: https://github.com/resin-io/etcher/issues/881
Change-Type: patch
Changelog-Entry: Normalize button text casing.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-25 10:57:47 -04:00