UNPKG

zapier-platform-cli

Version:

The CLI for apps in the Zapier Developer Platform.

42 lines (37 loc) 2.12 kB
'use strict'; var constants = require('../constants'); var utils = require('../utils'); var path = require('path'); var register = function register(context, title) { var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, _ref$printWhenDone = _ref.printWhenDone, printWhenDone = _ref$printWhenDone === undefined ? true : _ref$printWhenDone; var appDir = path.resolve('.'); context.line('Registering a new app on Zapier named "' + title + '"'); context.line(); return utils.checkCredentials().then(function () { utils.printDone(); utils.printStarting('Confirming registation of app "' + title + '"'); return utils.callAPI('/apps', { method: 'POST', body: { title: title } }); }).then(function (app) { utils.printDone(); utils.printStarting('Linking app to current directory with `' + constants.CURRENT_APP_FILE + '`'); return utils.writeLinkedAppConfig(app, appDir); }).then(function () { utils.printDone(); if (printWhenDone) { context.line('\nFinished! Now that your app is registered with Zapier, you can `zapier push` a version!'); } }); }; register.argsSpec = [{ name: 'title', required: true, example: 'My App Name' }]; register.argOptsSpec = {}; register.help = 'Registers a new app in your account.'; register.example = 'zapier register "Example"'; register.docs = '\nThis command registers your app with Zapier. After running this, you can run `zapier push` to push a version of your app that you can use in the Zapier editor.\n\n> This will change the `./' + constants.CURRENT_APP_FILE + '` (which identifies the app associated with the current directory).\n\n**Arguments**\n\n' + utils.argsFragment(register.argsSpec) + '\n' + utils.argOptsFragment(register.argOptsSpec) + '\n\n' + '```' + 'bash\n$ zapier register "Example"\n# Let\'s register your app "Example" on Zapier!\n#\n# Creating a new app named "Example" on Zapier - done!\n# Setting up .zapierapprc file - done!\n# Applying entry point file - done!\n#\n# Finished!\n' + '```' + '\n'; module.exports = register;