We recently sent a PR to handle multiple buffered IPC messages being
reported as a single message, confusing `JSON.parse()` in
`lib/shared/child-writer/index.js`, by only sending the last message,
and ignoring the rest, under the assumption that the loss of some state
messages is not critical for the application and the writing process to
work property.
As @lurch pointed out, however, a buffer set of messages might contain
an error object somewhere, and by ignoring all but the last message, we
ignore any error that happened in the way.
See: https://github.com/resin-io/etcher/issues/898
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
Currently the `DriveConstraintsModel` errors when given an `undefined`
drive, or image; this commit changes that behaviour. Comes with tests.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This commit makes Travis CI run GNU/Linux tests inside Ubuntu 14.04
i386/x86_64 docker containers.
It includes a set of Dockerfiles with everything needed to
run/build/package Etcher while a nice `run-command.sh` script that can
be used to easily run a command on such Dockerfiles with access to the
Etcher source code.
The main motivation behind change is that generating cross-architecture
AppImages is not possible at the moment (although there are PRs on the
way), so this permits us to configure Travis CI to build and publish
AppImages for all architectures.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
The `.modal-menu` class holds buttons that are shown at the bottom of
the modal. If there are two buttons, the class will show them side by
side with equal sizes, however if there is only one button, it will be
incorrectly resized to 50% of the available space.
Change-Type: patch
Changelog-Entry: Fix alignment of single call to action buttons inside modals.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This commit extracts the byte-related conversions from the `byte-size`
AngularJS module and the `FlashStateModel` to a re-usable generic
CommonJS module at `lib/shared/units.js`, than can also be used by the
CLI.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
There are certain application messages that should be re-used between
the CLI and the GUI. In order to allow such re-usability, we extract out
the application messages used in JavaScript into
`lib/shared/messages.js` as a collection of Lodash `_.template`
templates.
Notice this file doesn't include application messages included in
Angular templates directly since it'd be hard to refactor all of them.
We plan to move to React soon, which will allow moving the remaining
messages very easily.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
- Inline dictionary of common error codes and friendly descriptions
We used to rely on `resin-cli-errors` for this, however the friendly
descriptions set there can be usually very Resin CLI specific, and thus
confusing to Etcher users.
The dictionary, along with other error related utilities live in
`lib/cli/errors.js`.
- Print error descriptions and codes if they are found
- Move `utils.printError()` to `errors.print()`
Change-Type: minor
Changelog-Entry: Improve Etcher CLI error messages.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
Somehow some development dependencies slipped into the shrinkwrap file,
and in some cases, dependencies we don't use anymore didn't remove its
own now unneeded dependencies when running `npm uninstall`.
This PR carefully removes the packages that are not needed anymore,
which are a lot.
See: https://github.com/resin-io/etcher/issues/820
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
We were previously using the `undocked` mode, which would open DevTools
in a seaprate window, however the user was still allows to pick a new
mode, causing DevTools to be shown inside the main application and
completely ruining the UI.
The `detach` mode in the other hand, completely prevents user from
putting DevTools in the main application, therefore allowing no way to
make the UI look broken.
See: http://electron.atom.io/docs/api/web-contents/
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This commit introduces a `RELEASE_TYPE` option to the Makefile, which
can be either `production` or `snapshot`. If its `production`, the
behaviour its same as it was before.
If `RELEASE_TYPE` is `snapshot`, the shorter version of the current
commit hash is appended to the version (replacing the
`APPLICATION_VERSION` in the Makefile, as well as the `package.json`
version inside the `.asar`), and the publish scripts get configured to
deploy to different "snapshot" locations.
This commit also reduces the size of the version tag in the bottom right
corner a bit so that it fits when the commit hash is appended to it.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
These utilities were extracted to `lib/shared/child-writer/cli.js`, and
unit tests have been written for them.
As a result of testing, `.getBooleanArgumentForm()` has been extended to
support single letter options.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
The "min" mocha reporter clears the screen after each run, causing any
error/warning from the renderer process tests to be visually overwritten
by the main process tests.
Therefore, we now make use of the "spec" mocha reporter.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
The `--robot` option of the CLI causes the program to output
machine-parseable strings, which can be easily consumed by the GUI to
update progress and other information.
The problem is that if the CLI fails to parse its command line arguments
when being called from the GUI for whatever reason, the `.fail()` Yargs
handler will be called, which doesn't output error information in the
usual "robot" format, causing the GUI to not understand the error
message.
Since the `.fail()` Yargs handler doesn't have access to the passed
options, we moved the "robot" functionality to an environment variable,
which we can easily check from there.
As a bonus, this PR refactors the whole robot logic into
`lib/shared/robot.js` and adds unit tests to it.
See: https://github.com/resin-io/etcher/issues/986
Change-Type: major
Changelog-Entry: Replace the `--robot` CLI option with an `ETCHER_CLI_ROBOT` environment variable.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
The image selection dialog is attached to the parent window so it is a modal.
Change-Type: patch
Changelog-Entry: Make the image file picker attach to the main window.
We've recently moved the compiled CSS output to `lib/gui/css/main.css`,
however we didn't update the relative path to Bootstrap icon web font,
causing every icon to break.
See: https://github.com/resin-io/etcher/pull/1002
Change-Type: patch
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
We've recently PRed a commit that handles multiple IPC messages being
triggered at the same time, confusing `JSON.parse()`. As a solution to
such problem, we are splitting the CLI output on new lines, based on the
assumption that each line represents a different object, however we
didn't consider that in the case of errors, we include an `stacktrace`
property which usually includes new line characters, causing such
information to be completely garbled and cause `JSON.parse()` once again
to get confused.
As a solution, we only split by new lines that are not surrounded by
quotes (since they represent a JSON property).
See: https://github.com/resin-io/etcher/pull/997
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
We currently compile CSS into `build/css`, however we plan to use
node-gyp in this project, which can't be configured to build to a
directory other than `build`, therefore, the compiled CSS must move
somewhere else.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
`SelectionStateModel`'s methods `isSystemDrive` and `isDriveLocked`
don't depend on application state. They have been extracted in a different
AngularJS service: `DriveConstraintsModel`. The new service's actual
implementation is in `lib/src`, in order to be reused by the CLI.
Miscellaneous changes:
- Rename `lib/src` to `lib/shared`
- Refactor `drive-constraints` to throw when image is undefined
The default behaviour was to pretend that we're all good if the if
the image is not specified. We're not using this "feature", and
it can be dangerous if we forget to pass in the image.
- Make `isSystemDrive` return `false` if `system` property is undefined
- Use `drive-constraints` in `store.js`
Change-Type: patch
This change makes Travis CI spawn 3 jobs:
- GNU/Linux with TARGET_ARCH=x64
- GNU/Linux with TARGET_ARCH=x86
- macOS with TARGET_ARCH=x64
We add `make info` before starting the build for convenience.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
The GUI executes the CLI and pipes every line of output coming from
either `stdout` or `stderr` to the IPC server as "messages."
In some scenarios, the child process data handler might receive multiple
lines of output at the same time. Since the CLI outputs stringified JSON
objects each in a different line, trying to parse two JSON objects
separated by a new line causes the parser to crash.
As a solution, we split the data coming in by new lines (`\r\n` in
Windows), and emit a message for only the last one.
Fixes: https://github.com/resin-io/etcher/issues/898
Changelog-Entry: Fix "Invalid message" error caused by the IPC client emitting multiple JSON objects as a single message.
Change-Type: patch
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
Running `npm install -g npm` causes npm to be upgraded to v4, which
seems to have the following bug when running `npm install`:
```
npm ERR! Callback called more than once.
```
Not upgrading npm on our Appveyor builds causes npm to stay at v3, and
the problem dissapears.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
We sort the supported file extensions listed in the file picker
in alphabetical order.
See: https://github.com/resin-io/etcher/issues/984
Changelog-Entry: Sort supported extensions alphabetically in the image file-picker.
Change-Type: patch
System drives in the drive-list widget now have a red warning label
beneath. Also new is the `isSystemDrive()` method under
`SelectionStateModel` and its unit-tests.
See: https://github.com/resin-io/etcher/issues/888
Changelog-Entry: Label system drives in the drive-list widget
Because of NPM shrinkwrap, we recommend having a clean dependency tree
in `CONTRIBUTING.md` before upgrading a dependency. We currently
recommend maually wiping out `node_modules`, but since the
`electron-develop` make target already does that, is more user friendly
to recommend that instead.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
Currently, `electron-installer-appimage.sh` deletes temporary stuff it
needs as it goes (like the AppDir, AppImageAssistant, or even the
AppImage after creating a ZIP). Since this is not very Make-friendly,
the script has been split into the following smaller scripts that
perform a single task:
- `electron-create-appimage-linux.sh`
- `electron-create-appdir.sh`
Utilising them in different Makefile rules effectively results in Make
persisting the "temporary artifacts".
See: https://github.com/resin-io/etcher/pull/913#discussion_r90801230
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This avoids the failure-mode where wget got interrupted (e.g. network error
or server timeout), which caused the download-tool.sh to stop, which caused
the current make to stop. However if you then ran make again, it would see
that the file existed (and not know that it was incomplete / corrupt) and so
not try downloading it again. This commit fixes the problem by modifying
download-tool.sh to download to a temporary filename, and only rename to the
final destination filename after the checksum has been verified.
This will allow us to later publish development builds for both
architectures from Appveyor. In order to easily do so, the Makefile is
used instead of the current `./scripts/build/windows.bat`.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
`$(error ...)` (and `$(warning ...)`) functions in a Makefile can't be indented - if they are make displays a `*** commands commence before first target. Stop.` error.
`electron-sign-dmg-darwin.sh` was incorrectly referring to
`scripts/build/electron-sign-app-darwin.sh` as
`scripts/darwin/electron-sign-app.sh`, causing the DMG builds to fail in
OS X.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
We have a little snippet to check if a dependency is installed on the
system that we're literally copy-pasting in every single script in the
build system script collection.
For re-usability purposes, this snippet has been extracted to a
`check-dependency.sh` that is called by every script that needs it.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This commit adds new rules to create directories and sets order only
pre-requisites to the existing rules as a way to centralise directory
creation, which is currently scattered around all the build scripts.
See: https://github.com/resin-io/etcher/pull/923#discussion_r90881453
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
- The Electron npm headers can now be downloaded from
https://atom.io/download/electron
- We can configure gyp to build from source by using the
`npm_config_build_from_source` environment variable rather than having
to pass `--build-from-source`
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
If there are any files publishable to S3 then a `publish-aws-s3` target will
automagically exist, and similarly if there are any files publishable to
Bintray then a `publish-bintray-debian` target will automagically exist.
Like all phony targets, these get displayed by `make help` when available.
This script is in charge of downloading any asset from the internet
required by the build system. It accepts a SHA256 checksum and it uses
it to ensure the downloaded file integrity.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
We are now going to be adding links to files published in AWS S3 in
GitHub Releases, so that people used to finding pre-built versions of
the software in GitHub Releases will be re-directed to the right place,
while we still keep the analytics advantages that S3 provides us.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
By changing the `Makefile` to use `jq` instead of `node` for getting settings
from `package.json`, the time to do `make help` drops from over 1.5 seconds to
under 0.05 seconds!