Skip to content

Commit

Permalink
chore: convert upgrade scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jun 8, 2021
1 parent bfa0997 commit 200ebc7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 46 deletions.
17 changes: 6 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ var actions = require('./actions');
var feedback = require('./feedback');
var presets = require('./presets');
var setup = require('./setup');
var upgrades = require('./upgrades');
var upgradeScripts= require('./upgrades');
var variables = require('./variables');

var debug;
var log;

/**
* Companion instance class for the Blackmagic SmartView/SmartScope Monitors.
*
Expand Down Expand Up @@ -45,10 +42,7 @@ class instance extends instance_skel {
...feedback,
...presets,
...variables,
...upgrades
});;

this.addUpgradeScripts();
});

this.PRESETS_STATES = [
{ action: 'bright', group: 'Brightness', label: 'Brightness\\n\\n@ ', choices: [{id: 0, label: '0'}, {id: 127, label: '127'}, {id: 255, label: '255'}] },
Expand Down Expand Up @@ -76,6 +70,10 @@ class instance extends instance_skel {
this.actions(); // export actions
}

static GetUpgradeScripts() {
return upgradeScripts
}

/**
* Setup the actions.
*
Expand Down Expand Up @@ -279,9 +277,6 @@ class instance extends instance_skel {
* @since 1.0.0
*/
init() {
debug = this.debug;
log = this.log;

this.initVariables();
this.initFeedbacks();
this.initPresets();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bmd-smartview",
"version": "1.1.2",
"version": "1.1.3",
"api_version": "1.0.0",
"keywords": [
"Scope",
Expand Down
54 changes: 20 additions & 34 deletions upgrades.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,26 @@
module.exports = {
module.exports = [
// v1.1.0 (convert border col to val)
function (context, config, actions, feedbacks) {
var changed = false;

/**
* INTERNAL: add various upgrade scripts
*
* @access protected
* @since 1.1.0
*/
addUpgradeScripts() {

// v1.1.0 (convert border col to val)
this.addUpgradeScript((config, actions, releaseActions, feedbacks) => {
var changed = false;

let upgradePass = function(action, changed) {
switch (action.action) {
case 'border':
if (action.options !== undefined && action.options.col !== undefined) {
action.options.val = action.options.col;
delete action.options.col;
changed = true;
}
break;
}

return changed;
let upgradePass = function(action, changed) {
switch (action.action) {
case 'border':
if (action.options !== undefined && action.options.col !== undefined) {
action.options.val = action.options.col;
delete action.options.col;
changed = true;
}
break;
}

for (let k in actions) {
changed = upgradePass(actions[k], changed);
}
return changed;
}

for (let k in releaseActions) {
changed = upgradePass(releaseActions[k], changed);
}
for (let k in actions) {
changed = upgradePass(actions[k], changed);
}

return changed;
});
return changed;
}
}
]

0 comments on commit 200ebc7

Please sign in to comment.