UNPKG

zapier-platform-cli

Version:

The CLI for apps in the Zapier Developer Platform.

34 lines (31 loc) 2.6 kB
'use strict'; var utils = require('../utils'); var deprecate = function deprecate(context, version, deprecationDate) { if (!deprecationDate) { var message = 'Error: No version or deprecation date - provide a version like "1.0.0" and "2017-01-20"...'; return Promise.reject(new Error(message)); } return utils.checkCredentials().then(function () { return utils.getLinkedApp(); }).then(function (app) { context.line('Preparing to deprecate version ' + version + ' your app "' + app.title + '".\n'); var url = '/apps/' + app.id + '/versions/' + version + '/deprecate'; utils.printStarting('Deprecating ' + version); return utils.callAPI(url, { method: 'PUT', body: { deprecation_date: deprecationDate } }); }).then(function () { utils.printDone(); context.line(' Deprecation successful!\n'); context.line('We\'ll let users know that this version is no longer recommended and will cease to work on ' + deprecationDate + '.'); }); }; deprecate.argsSpec = [{ name: 'version', example: '1.0.0', required: true, help: 'the version to deprecate' }, { name: 'deprecationDate', example: '2017-01-20', required: true, help: 'date Zapier will make the version unavailable' }]; deprecate.argOptsSpec = {}; deprecate.help = 'Mark a non-production version of your app as deprecated, with removal by a certain date.'; deprecate.example = 'zapier deprecate 1.0.0 2017-01-20'; deprecate.docs = '\nA utility to alert users of breaking changes that require the deprecation of an app version.\n\nUse this when an app version will not be supported or start breaking at a known date.\n\nZapier will send an email warning users of the deprecation once a date is set, they\'ll start seeing it as "Deprecated" in the UI, and once the deprecation date arrives, if the Zaps weren\'t updated, they\'ll be paused and the users will be emailed again explaining what happened.\n\nAfter the deprecation date has passed it will be safe to delete that app version.\n\n> Do not use this if you have non-breaking changes, for example, just fixing help text or labels is a very safe operation.\n\n**Arguments**\n\n' + utils.argsFragment(deprecate.argsSpec) + '\n' + utils.argOptsFragment(deprecate.argOptsSpec) + '\n\n' + '```' + 'bash\n$ zapier deprecate 1.0.0 2017-01-20\n# Preparing to deprecate version 1.0.0 your app "Example".\n#\n# Deprecating 1.0.0 - done!\n# Deprecation successful!\n#\n# We\'ll let users know that this version is no longer recommended and will cease to work on 2017-01-20.\n' + '```' + '\n'; module.exports = deprecate;