zapier-platform-cli
Version:
The CLI for apps in the Zapier Developer Platform.
36 lines (29 loc) • 2.32 kB
JavaScript
;
var _ = require('lodash');
var utils = require('../utils');
var constants = require('../constants');
var register = require('./register');
var build = require('./build');
var createIfNeeded = function createIfNeeded(context) {
if (!utils.fileExistsSync(constants.CURRENT_APP_FILE)) {
context.line('Looks like this is your first push. Let\'s register your app on Zapier.');
return utils.getInput('Enter app title (Ctrl-C to cancel):\n\n ').then(function (title) {
return register(context, title, { printWhenDone: false });
});
}
return Promise.resolve();
};
var push = function push(context) {
context.line('Preparing to build and upload your app.\n');
return createIfNeeded(context).then(function () {
return utils.buildAndUploadDir();
}).then(function () {
context.line('\nBuild and upload complete! You should see it in your Zapier editor at ' + constants.BASE_ENDPOINT + '/app/editor now!');
});
};
push.argsSpec = [];
push.argOptsSpec = _.extend({}, build.argOptsSpec);
push.help = 'Build and upload the current app - does not promote.';
push.example = 'zapier push';
push.docs = '\nA shortcut for `zapier build && zapier upload` - this is our recommended way to push an app. This is a common workflow:\n\n1. Make changes in `index.js` or other files.\n2. Run `zapier test`.\n3. Run `zapier push`.\n4. QA/experiment in the Zapier.com Zap editor.\n5. Go to 1 and repeat.\n\n> Note: this is always a safe operation as live/production apps are protected from pushes. You must use `zapier promote` or `zapier migrate` to impact live users.\n\nIf you have not yet registered your app, this command will prompt you for your app title and register the app.\n\n' + '```' + 'bash\n$ zapier push\n# Preparing to build and upload app.\n#\n# Copying project to temp directory - done!\n# Installing project dependencies - done!\n# Applying entry point file - done!\n# Validating project - done!\n# Building app definition.json - done!\n# Zipping project and dependencies - done!\n# Cleaning up temp directory - done!\n# Uploading version 1.0.0 - done!\n#\n# Build and upload complete! Try loading the Zapier editor now, or try `zapier promote` to put it into rotation or `zapier migrate` to move users over\n' + '```' + '\n';
module.exports = push;