Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const codeDiff = diffValues(currentConfig, newConfig)
if (!codeDiff) {
logger('No changes, exiting early')
return false
}
logger()
const msg = `Updating ${addonName} add-on config values...`
logger(`${chalk.white.bold(msg)}`)
logger()
logger(`${codeDiff}\n`)
logger()
let updateAddonResponse
try {
// TODO update updateAddon to https://open-api.netlify.com/#/default/updateServiceInstance
updateAddonResponse = await updateAddon(settings, accessToken)
} catch (e) {
error(e.message)
}
if (updateAddonResponse.code === 404) {
logger(`No add-on "${addonName}" found. Please double check your add-on name and try again`)
return false
}
logger(`Add-on "${addonName}" successfully updated`)
return updateAddonResponse
}
// Parse flags
const rawFlags = parseRawFlags(raw)
// TODO diff rawFlags and currentConfig and dont make API call if equal
// Merge current config with new values passed in
const newConfigValue = mergewith(currentConfig, rawFlags)
const settings = {
siteId: siteId,
instanceId: currentAddon.id,
addon: addonName,
config: newConfigValue
}
const updateAddonResponse = await updateAddon(settings, accessToken)
// this.log('addonResponse', updateAddonResponse)
if (updateAddonResponse.code === 404) {
this.log(`No addon "${addonName}" found. Please double check your addon name and try again`)
return false
}
this.log(`Addon "${addonName}" updated`)
}
}