141 Commits

Author SHA1 Message Date
Juan Cruz Viotti
a74e6b53cd chore: fix lzma-native not building for the x86 Linux CLI (#1448)
There are various problems that contributed to this issue:

- `node-pre-gyp` doesn't detect the 6.10.3 node version. We reverted to
  6.1.0, which the module recognised, and which shares the same v8 ABI

- Passing `--force` to `npm install` causes npm to swallow any errors
  and silently continue

- The x86 Docker container has problems writing to `$HOME/.node-gyp`.
  The solution is to enable `unsafe-perm` given that the container is
  running as `root`

Fixes: https://github.com/resin-io/etcher/issues/1444
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-05-17 17:10:00 -04:00
Juan Cruz Viotti
1048150654 chore: check that there are no unstaged shrinkwrap changes (#1379)
See: https://github.com/resin-io/etcher/pull/1372
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-05-15 12:58:20 -04:00
Juan Cruz Viotti
9c055fb165 fix(CLI): workaround absolute paths in Browserify bundles (#1409)
For some strange reason, Browserify will hardcode absolute paths from
the machine that generated the bundle to be able to resolve `__dirname`
and `__filename` calls. This makes no sense, given that it means that
the Browserify bundle will not work when we move it to another machine,
which went undetected probably for months.

The Browserify community apparently makes modules to fix this particular
issue (like `bundle-collapser`, and `intreq`), however none of this seem
to solve the problem for the Etcher CLI bundle.

I also gave https://github.com/zeit/pkg a go, however I gave up after
not being able to make use of native modules (nothing seems to work; the
packager result will simply not find the addons).

Finally, I ended up making the following workarounds:

- Edit the Browserify bundle file to use its own `__dirname` to
  dynamically resolve the values of `__dirname` and `__filename` of the
  files it contains

- Patch `lzma-native` to statically require its add-on rather than
  relying on dynamic requires from `node-pre-gyp`, which makes it
  impossible to resolve on the final bundle

See: https://github.com/resin-io/etcher/issues/355
See: http://stackoverflow.com/questions/21993073/browserify-with-paths-to-folders-in-my-system
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-05-11 15:37:45 -04:00
Juan Cruz Viotti
b02da2d0cd chore(CLI): fix cli-develop Make target headers version (#1407)
The `cli-develop` target was pointing `node-gyp` to the Electron
headers, which caused native add-ons to not work.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-05-11 06:51:49 -04:00
Juan Cruz Viotti
d521fbbd2c chore(CLI): minify Etcher CLI code (#1401)
UglifyJS v3 was recently released, which includes support for
compressing ES6 code.

This commit introduces the following changes:

- Add a boolean `-m` option to `concatenate-javascript.sh`, which when
  set, will minify the final concatenated JavaScript file

- Install `uglify-es` in the CI servers

See: https://news.ycombinator.com/item?id=14285179
See: https://github.com/mishoo/UglifyJS2/tree/harmony
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-05-10 15:15:41 -04:00
Juan Cruz Viotti
7ddc5d525c refactor: address code review comments from #1366 (#1390)
See: https://github.com/resin-io/etcher/pull/1366
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-05-09 19:33:45 -04:00
Juan Cruz Viotti
60754250d9 chore: add ensure-npm-valid-dependencies.sh to sanity-checks make target (#1378)
We forgot to do so on the PR that introduces this script.

This commit also moves all the CI code to separate scripts.

See: https://github.com/resin-io/etcher/pull/1371
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-05-07 17:35:22 -04:00
Juan Cruz Viotti
b75dfd3ece feat(GUI): implement Windows elevation using a native module (#1366)
Sentry error reports showcase that elevation errors on Windows are one
of the most frequent Windows errors.

In order to perform Windows elevation, we ship compiled EXEs of a third
party CLI elevation application (http://code.kliu.org/misc/elevate/)
that has several limitations:

- We have the scan the output of the script to determine if a user
  cancelled the elevation request, which causes all sorts of issues on
  computers where English is not the main language

- The application displays a `cmd.exe` window for some milliseconds,
  which is bad UX, that we have to workaround by distributing a patched
  version of the tool

- The CLI application has to be spawned, which seems to be problematic
  if users have anti-virus software, leading to hard to debug issues

- We don't have any control if something goes wrong

For these reasons, we decided to implement our own elevation mechanism
in C++ as a Node.js add-on, based on the `elevate.exe` code we where
previously using.

Misc changes:

- Introduce a `lib/shared/bindings.js` module to easily require local native
  add-ons

- Install `cpplint` and configure it to lint C++ files

Note that for practical reasons, the C++ code lives in this repository
rather than in a separate module. We will release this functionality in
a more accessible way in the future as part of the Etcher SDK project.

Change-Type: patch
Changelog-Entry: Fix uncaught errors when cancelling elevation requests on Windows when the system's language is not English.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-05-02 18:36:57 -04:00
Juan Cruz Viotti
bc01e151c4 upgrade: electron to v1.6.6 (#1357)
Some changes that we're particularly interested in:

- https://github.com/electron/electron/pull/8590
- https://github.com/electron/electron/pull/8852
- https://github.com/electron/electron/pull/7631

Note that the `electron-prebuilt` packaged has been renamed to
`electron`.

Change-Type: patch
Changelog-Entry: Upgrade Electron to v1.6.6.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-25 15:52:19 -04:00
Juan Cruz Viotti
0f8ad15e45 chore(CLI): create basic CLI package installers (#1240)
This commit packages the Etcher CLI as a ZIP archive for Windows, and as
a tarball for GNU/Linux and macOS. These basic "installers" are the
foundation to provide Chocolatey/Brew/AUR/etc packages.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-04-21 12:17:36 -04:00
Andrew Scheller
57045ef1f6 chore: small tweak to the jq-insert.sh syntax (#1287) 2017-04-12 18:33:03 -04:00
Ștefan Daniel Mihăilă
91a1c3d107 feat(GUI): use resin-corvus in AnalyticsService (#1208)
Change-Type: patch
Changelog-Entry: Start reporting errors to Sentry instead of to TrackJS.
Fixes: https://github.com/resin-io/etcher/issues/1027
2017-04-10 15:06: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
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
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
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
0873b1d161 chore: fix lzma-native build issues on Windows (#1191)
* chore: fix `lzma-native` build issues on Windows

We've been recently hitting a weird `lzma-native` build error on Windows
(both locally and on Appveyor CI):

```
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  build
  The input line is too long.

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1. [C:\projects\etcher\node_modules\lzma-native\build\liblzma.vcxproj]
```

After a lot of experimentation, we realised the issue was gone if we
removed `node-sass` from the development dependencies.

The issue is that `node-gyp` was recently upgraded to v3.6.0, which was
picked up by `node-sass`, which declares `node-gyp` as a dependency. For
some reason, if `node-sass` causes `node-gyp` to be updated, then
`lzma-native` fails with the above cryptic error.

I was able to trace down the error to the following `node-gyp` commit:

ae141e1906

As a solution, this commit starts to shrinkwrap development
dependencies, and locks `node-gyp` to v3.5.0 until the issue is fixed.

Fixes: https://github.com/addaleax/lzma-native/issues/30
See: https://github.com/nodejs/node-gyp/issues/1151
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>

* chore: ensure some modules in npm-shrinkwrap stay at specific versions

* Address code review comments

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-20 15:03:10 -04:00
Juan Cruz Viotti
66c0cb6e17 chore: automatically enforce compatible angular core module versions (#1175)
We've recently had an incident were the `angular-mocks` version we were
running was incompatible with the `angular` version.

Each AngularJS core module is versioned equally, therefore we can write
a small script that automatically tests that they match, so we're
guarded against forgetting to similarly upgrade different dependencies.

See: https://github.com/resin-io/etcher/pull/1168
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-15 10:43:20 -04:00
Juan Cruz Viotti
33e044806b chore: support generating armv7l .deb packages (#1038)
This is the architecture of the Raspberry Pi 3. The following changes
were necessary:

- Detect the architecture using `uname -m`
- Set the Debian equivalent architecture to `armhf`
- Handle the new architecture correctly on `dependencies-npm.sh` and
  `electron-download-package.sh`, referring to it as simply `arm` (which
  is what `node-gyp` expects)

This PR also includes `architecture-convert.sh`, which is a script to
find an architecture equivalence for Node and Debian.

Steps to test this PR:

- `make electron-installer-debian` from a Raspberry Pi 3

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-03-10 14:08:15 -04:00
Juan Cruz Viotti
8d71307831 chore: define S3_BUCKET in Makefile (#1141)
We use that variable in the Makefile but we're not defining it, which
means that maintainers publishing Etcher need to remember to pass that
as an option.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-27 17:05:58 -04:00
Juan Cruz Viotti
d9bd509d22 chore: fix various code-signing Windows issues (#1135)
- Add missing backslash that caused the command to not be interpreted
  completely

- Update `electron-sign-exe.exe` to `electron-sign-exe-win32.exe` in
  Makefile

- Use hyphen options instead of Windows slash style, which confuses bash

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-27 10:08:44 -04:00
Juan Cruz Viotti
108a43512d chore: add support for Windows builds in Makefile (#1079)
This commits introduces the following Windows rules:

- `electron-installer-zip`
- `electron-installer-nsis`

Other changes:

- Remove `scripts/build/windows.bat`
- Update `docs/RUNNING-LOCALLY.md` to point to Makefile
- Update `docs/PUBLISHING.md` to point to Makefile
- Remove `7z` from `docs/RUNNING-LOCALLY.md` pre-requisites

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-02-09 14:30:39 -04:00
Juan Cruz Viotti
f0020d9fcf chore: fix undefined TEMPORARY_DIRECTORY variable (#1059)
This variable was renamed to `BUILD_TEMPORARY_DIRECTORY`, but the
Makefile silently expands this to nothing and carries on with the build.

Now that the variable is expanded correctly, we must add it as an
order-only prerequisite so it gets created.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-27 18:01:56 -04:00
Juan Cruz Viotti
7c50f3e742 chore: add a package Makefile target (#1058)
This target would easily allow us to create a package for the
application without being wrapped into an installer, which is
particularly useful to provide custom builds, or test asar related
issues, for example.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-27 13:14:15 -04:00
Juan Cruz Viotti
1c99b4b5fc chore: don't print Makefile comments (#1039)
We have a big comment block in the `electron-develop` target which gets
printed everytime the target gets executed.

After some research, turns out GNU Make will ignore the comments if they
are not indented.

See: http://stackoverflow.com/a/18363477/1641422
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-01-24 11:54:13 -04:00
Juan Cruz Viotti
2c64f0da23 chore: add support for snapshot builds (#968)
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>
2017-01-10 21:37:54 -04:00
Juan Cruz Viotti
404eeffbeb chore: compile CSS into lib/gui/css (#1002)
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>
2017-01-06 15:55:07 -04:00
Juan Cruz Viotti
2dac3ac079 chore: build x64 and x86 jobs for GNU/Linux (#964)
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>
2017-01-06 11:32:53 -04:00
Juan Cruz Viotti
8e7599b366 chore: implement electron-configure-package-win32.sh (#962)
This script configures an Electron package on Windows.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-12-13 11:04:09 -04:00
Juan Cruz Viotti
cc96a0c1fe chore: persist temporary artifacts during AppImage builds (#936)
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>
2016-12-13 10:53:10 -04:00
Andrew Scheller
07713fe6b1 chore: remove backslash-escaping in Makefile errors & warnings (#972)
They're unnecessary, and actually cause the backslash to get printed.
2016-12-12 15:34:58 -04:00
Andrew Scheller
d42291ef9d chore: add distclean target to Makefile (#971)
This new target also deletes the `node_modules` and `bower_components`
directories, taking the project directory to a totally pristine state.
2016-12-12 15:34:47 -04:00
Juan Cruz Viotti
e6d5d9c910 chore: run tests in x64 and x86 in Appveyor (#963)
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>
2016-12-12 14:33:16 -04:00
Andrew Scheller
c4a92d772d chore: fix error functions in Makefile (#970)
`$(error ...)` (and `$(warning ...)`) functions in a Makefile can't be indented - if they are make displays a `*** commands commence before first target. Stop.` error.
2016-12-11 18:45:26 -04:00
Juan Cruz Viotti
db379bd341 chore: use $(BUILD_OUTPUT_DIRECTORY) in PUBLISH_* accumulators (#965)
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-12-11 18:43:00 -04:00
Juan Cruz Viotti
446e457b5b chore: move directory creation responsibility to Makefile (#946)
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>
2016-12-09 10:40:15 -04:00
Juan Cruz Viotti
b0f94b58ca chore: fix small spacing issue in Makefile (#960)
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-12-08 15:26:46 -04:00
Andrew Scheller
d9148d585e chore: add publishing Makefile targets (#955)
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.
2016-12-08 13:47:42 -04:00
Andrew Scheller
4090fe93ad chore: speed up make startup time by using jq (#958)
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!
2016-12-08 11:57:22 -04:00
Juan Cruz Viotti
c14257720f chore: group build scripts inside scripts/build (#940)
This makes it easier to have re-usable functionality that we can
call/source from all scripts, like logic to determine the current
operating system, or to check for a dependency in the `$PATH`.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-12-08 11:06:35 -04:00
Andrew Scheller
316d462526 chore: add help Makefile target to show available targets (#954)
Also sets `help` as the default target, so that typing just `make` displays
the list of possible targets. Also customises the list of targets based on
TARGET_PLATFORM (because you can't build e.g. `electron-installer-dmg` when
you're on Linux).
2016-12-07 11:22:41 -04:00
Juan Cruz Viotti
b63f967d44 chore: set msvs version on dependencies-npm.sh when running on Windows (#943)
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-12-05 23:01:04 -04:00
Juan Cruz Viotti
457ce16722 chore: make code-signing optional in OS X (#939)
Code-signing in OS X now relies on the presence of a
`CODE_SIGN_IDENTITY` variable. If it doesn't exist, all the builds will
gracefully complete without code-signing.

As a consequence of this change, the `electron-installer-dmg.sh` script
has been divided into `electron-create-readwrite-dmg.sh`,
`electron-create-readwrite-dmg.sh`, and `electron-sign-dmg.sh`.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-12-05 22:21:28 -04:00
Juan Cruz Viotti
92bc79df15 chore: move electron package caching responsibility to GNU Make (#926)
Currently, `scripts/unix/electron-download-package.sh` contains its own
logic to determine if the package was already downloaded.

This commit takes the electron package uncompressing task to the
configure scripts, and reduce `electron-download-package.sh` to a script
that simply downloads the zip to a certain location, since this change
allows us to have a separate Make rule to download the Electron zip (and
thus have Make take care of caching).

After this change, the `electron-configure-package-*.sh` scripts are no
longer routines that modify a certain directory, but scripts that take
the zip as an input and actually create the package directory, which
aligns better with Make's design.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-12-05 12:28:35 -04:00
Juan Cruz Viotti
9c02f976ae style: use GNU Make foreach instead of a shell for loop (#927)
Just for conciseness and style.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-12-02 10:27:25 -04:00
Juan Cruz Viotti
832bfad9d1 chore: reuse npm/bower dependencies across builds (#923)
Currently, we create a "resources app" and install dependencies on it.
This means that to create another "resources app", the whole dependency
installation process needs to be repeated.

As a solution, we cache dependencies at
`release/electron-$(TARGET_PLATFORM)-$(TARGET_ARCH)-dependencies/` and
copy them to the resources apps as we need them.

This has the additional benefit that the resources app depends on the
dependencies rather than the other way around (dependencies depend on
the resources app), which didn't feel right.

In order to accomodate to these changes, the dependencies scripts are
now in charge of taking their corresponding manifests with them when the
prefix option is passed, given that neither `npm` nor `bower` allow to
customise the output location.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-12-01 19:52:07 -04:00
Juan Cruz Viotti
2b7f36a3c7 style: convert spaces to tabs in Makefile (#924)
Additionally, we setup an EditorConfig rule to automatically switch to
tab style on Makefile.

Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2016-12-01 19:51:53 -04:00