Add a sync.js script to allow syncing a running supervisor container on a local device

This handy tool uses the resin-sync module to rsync javascript changes into the running container
on a device in the local network. It allows rapid iterations when testing the supervisor on a real device.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
Pablo Carranza Velez 2017-08-29 00:23:51 -07:00
parent 2be9e18e25
commit 9cc2e47e70
3 changed files with 27 additions and 2 deletions

View File

@ -126,6 +126,7 @@ WORKDIR /usr/src/app
RUN apt-get update \
&& apt-get install -y \
g++ \
git \
libsqlite3-dev \
make \
python \

View File

@ -46,9 +46,10 @@
"pinejs-client": "^2.4.0",
"pubnub": "^3.7.13",
"request": "^2.51.0",
"resumable-request": "^1.0.0",
"resin-lint": "^1.3.1",
"resin-register-device": "^3.0.0",
"resin-sync": "^9.1.0",
"resumable-request": "^1.0.0",
"rimraf": "^2.5.4",
"rwlock": "^5.0.0",
"semver": "^5.3.0",
@ -57,4 +58,4 @@
"versionist": "^2.8.0",
"webpack": "^3.0.0"
}
}
}

23
sync.js Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env node
// Sync changes in the javascript code to a running supervisor on a device in the local network
//
// Usage:
// ./sync.js <device IP>
//
// The script will first build a non-optimized version of the js code and sync the resulting app.js
// onto the supervisor container at the specified IP. It will also restart the supervisor container.
// The device must be a development variant of Resin OS and the supervisor must be running.
doSync = require('resin-sync').sync('local-resin-os-device').sync;
opts = {
deviceIp: process.argv[2],
baseDir: __dirname + '/dist',
destination: '/usr/src/app/dist',
appName: 'resin_supervisor',
skipGitignore: true,
before: 'npm install && npm run build-no-optimize'
};
doSync(opts);