Skip to content

Commit

Permalink
Merge 9806b9e into 18e2a5f
Browse files Browse the repository at this point in the history
  • Loading branch information
busticated committed Jul 10, 2021
2 parents 18e2a5f + 9806b9e commit 46e5a68
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
1 change: 1 addition & 0 deletions settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var settings = {
access_token: null,
minimumApiDelay: 500,
useSudoForDfu: false,
flashWarningShownOn: null,
// TODO set to false once we give flags to control this
disableUpdateCheck: envValueBoolean('PARTICLE_DISABLE_UPDATE', false),
updateCheckInterval: 24 * 60 * 60 * 1000, // 24 hours
Expand Down
1 change: 1 addition & 0 deletions src/cmd/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ module.exports = class CloudCommand extends CLICommandBase {
return createAPI().markAsDevelopmentDevice(deviceId, true, product);
})
.then(() => {
this.ui.logFirstTimeFlashWarning();
this.ui.stdout.write(`attempting to flash firmware to your device ${deviceId}${os.EOL}`);
return createAPI().flashDevice(deviceId, fileMapping, targetVersion, product);
})
Expand Down
16 changes: 11 additions & 5 deletions src/cmd/flash.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const fs = require('fs');
const VError = require('verror');
const dfu = require('../lib/dfu');
const temp = require('temp').track();
const ModuleParser = require('binary-version-reader').HalModuleParser;
const ModuleInfo = require('binary-version-reader').ModuleInfo;
const deviceSpecs = require('../lib/deviceSpecs');
const ensureError = require('../lib/utilities').ensureError;
const temp = require('temp').track();
const dfu = require('../lib/dfu');
const CLICommandBase = require('./base');

const systemModuleIndexToString = {
1: 'systemFirmwareOne',
Expand All @@ -14,14 +15,19 @@ const systemModuleIndexToString = {
};


module.exports = class FlashCommand {
module.exports = class FlashCommand extends CLICommandBase {
constructor(...args){
super(...args);
}
flash(device, binary, files, { usb, serial, factory, force, target, port, yes }){
if (!device && !binary){
// if no device nor files are passed, show help
// TODO: Replace by UsageError
return Promise.reject();
}

this.ui.logFirstTimeFlashWarning();

let result;
if (usb){
result = this.flashDfu({ binary, factory, force });
Expand All @@ -32,7 +38,7 @@ module.exports = class FlashCommand {
}

return result.then(() => {
console.log ('\nFlash success!');
this.ui.write('\nFlash success!');
});
}

Expand Down Expand Up @@ -89,7 +95,7 @@ module.exports = class FlashCommand {
})
.then(info => {
if (info.suffixInfo.suffixSize === 65535){
console.log('warn: unable to verify binary info');
this.ui.write('warn: unable to verify binary info');
return;
}

Expand Down
12 changes: 12 additions & 0 deletions src/lib/ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const os = require('os');
const Chalk = require('chalk').constructor;
const Spinner = require('cli-spinner').Spinner;
const platformsById = require('../../cmd/constants').platformsById;
const settings = require('../../../settings');


module.exports = class UI {
Expand Down Expand Up @@ -50,6 +51,17 @@ module.exports = class UI {
});
}

logFirstTimeFlashWarning(){
if (settings.flashWarningShownOn){
return;
}
this.write(':::: NOTICE:');
this.write(':::: Your first flash may take up to 10m to complete - during');
this.write(':::: this time, your device may regularly change LED states');
this.write(':::: as Device OS upgrades are applied.');
settings.override(settings.profile, 'flashWarningShownOn', Date.now());
}

logDeviceDetail(devices, { varsOnly = false, fnsOnly = false } = {}){
const { EOL, chalk } = this;
const deviceList = Array.isArray(devices) ? devices : [devices];
Expand Down

0 comments on commit 46e5a68

Please sign in to comment.