From 67e9f5c5b6c48e82b9557e482977246e4c297c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Weber?= Date: Fri, 31 Mar 2017 18:16:52 -0400 Subject: [PATCH] Updated readme and example --- README.md | 2 +- example/index.js | 28 +++++++++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 09de04b..07e9405 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ var barracks = new Barracks({ }); ``` -### Check for an update: +### Check for new packages and package updates: ```js var packages = [ { diff --git a/example/index.js b/example/index.js index 3837b73..f853c7f 100644 --- a/example/index.js +++ b/example/index.js @@ -13,24 +13,38 @@ process.argv.forEach(function (val, index) { ** documentation for more information. **/ var barracksBaseUrl = args.baseUrl; var barracksApiKey = args.apiKey; +var isSelfSigned = args.selfSigned; if (!barracksApiKey) { console.log('Argument --apiKey is mandatory.'); console.log(' is your user api key that you can find on the Account page of Barracks.'); console.log('You can also use the argument --baseUrl if you want to request another domain than the default one.'); + console.log('And the argument --selfSigned with value 1 or 0 if your baseUrl use a self signed certificate.'); process.exit(); } -var device = { - versionId: 'v0.0.0', - unitId: 'unit9' -}; +var unitId = 'SDK-example-unit'; + +var packages = [ + { + reference: 'greg.pckg.test', + version: '0.2.0' + }, + { + reference: 'com.test.1234', + version: 'v-1490894199' + }, + { + reference: 'ref-package-1490294068', + version: 'coucou' + } +]; var barracks = new Barracks({ baseURL: barracksBaseUrl, apiKey: barracksApiKey, - unitId: device.unitId, - downloadFilePath: '/tmp/file.tmp' + unitId: unitId, + allowSelfSigned: (isSelfSigned ? (isSelfSigned === '1') : false) }); function donwloadPackages(packages) { @@ -77,7 +91,7 @@ function handleUnavailablePackages(packages) { function waitAndDisplayUpdate() { setTimeout(function () { - barracks.checkUpdate(device.versionId, { gender: 'Female' }).then(function (response) { + barracks.checkUpdate(packages, { test: 'coucou' }).then(function (response) { handleAvailablePackages(response.available); handleChangedPackages(response.changed); handleUnchangedPackages(response.unchanged);