UNPKG

zapier-platform-cli

Version:

The CLI for apps in the Zapier Developer Platform.

39 lines (33 loc) 2.37 kB
'use strict'; var utils = require('../utils'); var exampleApps = require('../utils/example-apps'); var constants = require('../constants'); var appTemplates = require('../app-templates'); var init = function init(context, location) { context.line('Welcome to the Zapier Platform! :-D'); context.line(); context.line(constants.ART); context.line(); context.line('Let\'s initialize your app!'); context.line(); var template = global.argOpts.template || 'minimal'; var createApp = function createApp(tempAppDir) { utils.printStarting('Downloading zapier/zapier-platform-example-app-' + template + ' starter app'); return exampleApps.downloadAndUnzipTo(template, tempAppDir).then(function () { return exampleApps.removeReadme(tempAppDir); }).then(function () { return utils.printDone(); }); }; return utils.initApp(context, location, createApp).then(function () { context.line('\nFinished! You might need to `npm install` then try `zapier test`!'); }); }; init.argsSpec = [{ name: 'path', required: true }]; init.argOptsSpec = { template: { help: 'select a starting app template', choices: appTemplates, 'default': 'minimal' } }; init.help = 'Initializes a new Zapier app in a directory.'; init.example = 'zapier init path'; init.docs = '\nInitializes a new Zapier app. If you specify a template, will download and install the app from that template.\n\nAfter running this, you\'ll have a new example app in your directory. If you re-run this command on an existing directory it will leave existing files alone and not clobber them.\n\n> Note: this doesn\'t register or deploy the app with Zapier - try `zapier register "Example"` and `zapier push` for that!\n\n**Arguments**\n\n' + utils.argsFragment(init.argsSpec) + '\n' + utils.argOptsFragment(init.argOptsSpec) + '\n\n' + '```' + 'bash\n$ zapier init example-app --template=minimal\n# Let\'s initialize your app!\n#\n# Downloading zapier/zapier-platform-example-app-minimal starter app - done!\n# Copy /users/username/code/example-app/.gitignore - done!\n# Copy /users/username/code/example-app/index.js - done!\n# Copy /users/username/code/example-app/package.json - done!\n# Copy /users/username/code/example-app/test/index.js - done!\n#\n# Finished! You might need to `npm install` then try `zapier test`!\n' + '```' + '\n'; module.exports = init;