3402 Commits

Author SHA1 Message Date
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
Jonas Hermsmeier
d5ec71c5da chore(package): Make clean-shrinkwrap remove optional dependencies (#1236)
Previously dependencies weren't actually removed from `node_modules`,
this runs `npm rm` on the optional dependencies, effectively excluding
them, and their dependencies from the shrinkwrap file.

Also the script has been hooked to the `preshrinkwrap` hook,
to remove the need of having to run it manually.

Change-Type: patch
2017-03-31 14:35:50 -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
Andrew Scheller
63c7eed2a9 chore: add a require() checking script (#1237)
* chore: Add a require() checking script

This adds another sanity-check bash script to scan the Etcher source files
and check all required node modules are available.

* Workaround for jq crash on Windows
2017-03-31 11:00:59 -04:00
Juan Cruz Viotti
4f790afe49 chore: remove unused tail related modules (#1242)
We used to rely on these modules before we started passing progress
information from the writer to the GUI using IPC.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-31 10:53:31 -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
55dc17d9a7
Revert "chore(package.json): add dynamic dependencies as optional dependencies (#1228)"
This reverts commit 396145d62586fa5c887f87303ecfc295b9668ea4.
2017-03-29 15:09:30 -04:00
Juan Cruz Viotti
4616f4bfd9
Revert "chore: make thread-sleep and spawn-sync production dependencies (#1235)"
This reverts commit 85cac531c96c422912431b4f00870a2afe56119a.
2017-03-29 15:08:59 -04:00
Juan Cruz Viotti
85cac531c9 chore: make thread-sleep and spawn-sync production dependencies (#1235)
These are dynamic dependencies we've recently added to the list of top
level optional dependencies in order to be able to resolve them when
using browserify to package the Etcher CLI.

The issue is that `thread-sleep` is using a very old `node-pre-gyp`
version (0.6.9) that doesn't support Electron at all, thus resulting in
the following error when setting `npm_config_runtime=electron`:

```
node-pre-gyp ERR! UNCAUGHT EXCEPTION
node-pre-gyp ERR! stack Error: Unknown Runtime: 'electron'
```

This commit makes these dependencies production dependencies, so we can
tweak the `node-pre-gyp` version to make it work.

See: https://github.com/resin-io/etcher/pull/1228
See: https://github.com/mapbox/node-pre-gyp/issues/281
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-29 13:32:08 -04:00
Juan Cruz Viotti
af921a0cb3 docs(README): uninstall instructions for debian/brew (#1231)
We have inline instructions to install Etcher from package managers.
This commit extends them to quickly mention how to uninstall as well.

Fixes: https://github.com/resin-io/etcher/issues/1225
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-29 12:43:32 -04:00
Jonas Hermsmeier
4f7d160513 chore(package): remove extraneous dependencies from shrinkwrap (#1234)
Change-Type: patch
2017-03-29 11:50:06 -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
3c1882d2b4 chore(travis): move deploy command to a separate script (#1224)
We're passing a shell conditional to `deploy.script`, however Travis CI
seems to get confused about this in the deploy section, causing
GNU/Linux to run `make publish-aws-s3` directly on the Travis CI build
instead of in the Docker container, which causes the deployment to
eventually fail because of missing dependencies.

According to Travis CI:

> `deploy.script` must be a scalar pointing to an executable file or
> command.

See https://travis-ci.org/resin-io/etcher/jobs/214723725 for a failure
example.

We also move the Appveyor deploy script to a separate file for symmetry
purposes.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-28 14:15:52 -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
396145d625 chore(package.json): add dynamic dependencies as optional dependencies (#1228)
In order to package the Etcher CLI, we concatenate all the code from the
`lib/cli/etcher.js` entry point using browserify.

There are some dependencies down the hierarchy that dynamically require
other dependencies, by enclosing `require()` calls in `try`/`catch`
blocks. The dynamic dependencies these modules require are not even
present in the `package.json`, and thus rightfully confuse browserify.

See https://github.com/ForbesLindesay/spawn-sync/blob/master/lib/spawn-sync.js#L10
See https://github.com/IndigoUnited/node-cross-spawn/blob/master/index.js#L32

There are two solutions to this problem:

- Make browserify stub these problematic dependencies with a blank file
  by using `--ignore`

This approach initially looks like the way to go, however it means that
every module that requires this particular dependency will receive just
a blank stub. It might be that some other dependencies rely on them, so
this approach could cause very obscure bugs later on.

- Add them to `package.json`

This is the approach taken by this commit. We add them to
`optionalDependencies` instead of `dependencies`, so we can still make
use of tools that analyse the code base for unused dependencies.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-28 09:41:53 -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
Andrew Scheller
68d50ba2f5 chore: don't bother sending any build context to Docker (#1226)
We don't actually use any build context, as we just mount the local
directory as a volume anyway. Omitting it speeds up the container
start-up time. This is an enhanced version of #1173
2017-03-26 18:19:40 -04:00
Jonas Hermsmeier
cbc9dfecf6 chore(scripts): rebuild instead of removing node_modules (#1215)
As removing the `node_modules` completely and then re-installing
is quite time consuming and SSD-thrashing, resort to pruning
and rebuilding native add-ons when switching targets.

Change-Type: patch
2017-03-24 12:56:26 -04:00
Jonas Hermsmeier
f50feba78d doc: add option to install win build tools via npm (#1218)
This adds the option to install the Windows C++ Build Tools
via npm to the RUNNING-LOCALLY docs

Change-Type: patch
2017-03-24 12:56: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
Jonas Hermsmeier
198ddb7433 chore(travis): Use node base, instead of cpp (#1216)
This changes the `.travis.yml` to use the `node_js` language
as a base instead of `cpp` to avoid installing & setting up node
manually.

Change-Type: patch
2017-03-24 11:57:13 -04:00
Peter Dave Hello
d028ed9f6c chore: speed up nvm installation on Travis CI
You don't need to have the whole commit history of `nvm`, let's speed up the clone process.
2017-03-24 11:13:18 -04:00
Andrew Scheller
f595f4ad04 style: fix typo in code-comment (#1213) 2017-03-24 11:10:52 -04:00
Juan Cruz Viotti
7033f7f7c4 chore: add libyaml-dev to GNU/Linux Docker dependencies (#1204)
`pip install awscli` outputs the following warning:

```
Running setup.py install for PyYAML
  checking if libyaml is compilable
  i686-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/check_libyaml.c -o build/temp.linux-x86_64-2.7/check_libyaml.o
  build/temp.linux-x86_64-2.7/check_libyaml.c:2:18: fatal error: yaml.h: No such file or directory
   #include <yaml.h>
                    ^
  compilation terminated.

  libyaml is not found or a compiler error: forcing --without-libyaml
  (if libyaml is installed correctly, you may need to
   specify the option --include-dirs or uncomment and
   modify the parameter include_dirs in setup.cfg)
```

The installation gracefully continues anyway (the `--without-libyaml` is
automatically forced).

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-23 22:31:25 -04:00
Juan Cruz Viotti
f73bcb78a8 docs: revise PUBLISHING.md S3 section (#1197)
- Mention the production and snapshot S3 bucket
- Remove the note that `aws-s3.sh` doesn't run on Windows
- Don't document `./scripts/publish/aws-s3.sh`. Encourage maintainers to
  use `make publish-aws-s3` instead

See: https://github.com/resin-io/etcher/pull/1078#discussion_r107259159
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-23 22:31:18 -04:00
Andrew Scheller
1731e77a25 chore: check that all text files only contain expected ASCII chars (#1205) 2017-03-23 14:00:14 -04:00
Pierre-Yves
003d937a6e chore: make use of 'uname -m' to detect host on GNU/Linux
replace uname -p with uname -m to detect HOST_ARCH on HOST_PLATFORM = linux
2017-03-23 13:33:27 -04:00
Juan Cruz Viotti
063fde1a02 chore: automatic CLI packaging (#1132)
This commit introduces the phony `package-cli` target, used to package
the Electron CLI in a directory.

Other related changes:

- The `package` target has been renamed to `package-electron`

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-23 10:10:01 -04:00
Andrew Scheller
61f7c85060 chore: fix small dependency-checking typo (#1201) 2017-03-23 10:09:32 -04:00
Andrew Scheller
a7da396a4c chore: fix copying of variables into Docker (#1203)
Fixes `set -u` errors, and prevents variables being set to undefined values

Change-type: patch
2017-03-23 10:04:31 -04:00
Juan Cruz Viotti
fbfd6f0b47 chore: fix errors during snapshot deployments (#1196)
This commit addresses some issues with snapshot builds that we didn't
caught given we never ran the deployment step in a "real" deployment
scenario.

- On Travis CI, the service reverts all changes in the source tree
  before starting the `deploy` section, which seems to trigger some
  issues when deleting `node_modules`. The solution is to set the
  `skip_cleanup` option

See
https://s3.amazonaws.com/archive.travis-ci.org/jobs/213614487/log.txt

```
...
warning: failed to remove node_modules/helper-date/node_modules/moment/locale/es.js
warning: failed to remove node_modules/helper-date/node_modules/moment/locale/ky.js
warning: failed to remove node_modules/helper-date/node_modules/moment/locale/pt-br.js
warning: failed to remove node_modules/helper-date/node_modules/moment/locale/hu.js
warning: failed to remove node_modules/helper-date/node_modules/moment/locale/en-nz.js
...
```

- On Appveyor CI, `curl` is not installed

See
https://ci.appveyor.com/project/resin-io/etcher/build/job/54i0erd9tsa1cg5p
as an example.

See: https://github.com/resin-io/etcher/pull/1078
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-22 10:27:51 -04:00
Juan Cruz Viotti
799ebc6aa0 chore: publish snapshot builds to S3 (#1078)
This commit makes Appveyor and Travis CI publish snapshot builds to S3
when a pull request is merged, by making use of the `publish-aws-s3`
Makefile target.

The changes required for such type of deployment are the followings:

- Set `S3_BUCKET` to `resin-nightly-downloads` when doing snapshot
  builds

- Add deploy sections to `.travis.yml` and `appveyor.yml` that run `make
  publish-aws-s3`

- Don't change `PRODUCT_NAME` when doing snapshot builds (given we'll be
  publishing to a different S3 bucket)

- Install `awscli` in Appveyor CI and Travis CI

- Make GNU/Linux Docker containers inherit `AWS_ACCESS_KEY_ID` and
  `AWS_SECRET_ACCESS_KEY` from the environment (so `awscli` is
  configured correctly inside them)

- Add a prefix option to `aws-s3.sh` publish script to prepend a string
  to the S3 path, so we can add a timestamp to more easily distinguish
  files inside the `resin-nightly-downloads` bucket

- Print the published URL from `aws-s3.sh` for convenience purposes, so
  we can click it when skimming through CI builds logs

- Add the `-R` and `-L` options when recursively copying `node_modules`
  during a snapshot build to prevent weird Appveyor errors related to
  hard links. The options listed before make sure that we recursively
  resolve every link while copying

- Move from `wget` to `curl` to avoid certificate check failures

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-21 18:35:44 -04:00
Andrew Scheller
5a01f4854c chore: setup .gitattributes to perform correct line-ending conversions (#1192)
This allows `npm run lint` to pass regardless of the `core.autocrlf`
setting in git
2017-03-21 14:32:21 -04:00
Juan Cruz Viotti
4417d94913 upgrade: unbzip2-stream to v1.0.11 (#1194)
We believe this issue fixes the "rawr i'm a dinosaur" error on certain
problematic images.

Gives this only happens on a minority of images, we couldn't confirm
that the fix really solves the issue, but we'll include the upgrade on
the next Etcher version and see how it goes in the real world.

Change-Type: patch
Changelog-Entry: Fix "rawr i'm a dinosaur" bzip2 error.
Fixes: https://github.com/resin-io/etcher/issues/734
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-21 14:31:58 -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
Juan Cruz Viotti
254da05964 chore: don't compress binaries/libraries with upx (#1188)
upx allows to reduce the package size by some mega bytes, but also
considerably slows down the application start time.

This commit ditches upx, since we can re-gain those benefits (and even
increase them) by other means (e.g: minifying JavaScript).

See: https://github.com/resin-io/etcher/issues/1138
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-21 11:16:48 -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