1.0.0 • Published 7 years ago

plg-cli v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

Pling Workflow CLI was done to provide easy and fast access to Github PRs and branch management.

These docs are available here, the CLI docs are available here, and you can view all the schema definitions here.

Table of Contents

Getting Started

What is an App?

A CLI App is an implementation of your app's API. You build a Node.js application that exports a single object (JSON Schema) and upload it to Pling. Pling Workflow CLI introspects that definition to find out what your app is capable of and what options to present end users in the Zap Editor.

For those not familiar with Pling terminology, here is how concepts in the CLI map to the end user experience:

  • Authentication, (usually) which lets us know what credentials to ask users for. This is used during the "Connect Accounts" section of the Zap Editor.
  • Triggers, which read data from your API. These have their own section in the Zap Editor.
  • Creates, which send data to your API to create new records. These are listed under "Actions" in the Zap Editor.
  • Searches, which find specific records in your system. These are also listed under "Actions" in the Zap Editor.
  • Resources, which define an object type in your API (say a contact) and the operations available to perform on it. These are automatically extracted into Triggers, Searches, and Creates.

How does the CLI Platform Work

Pling Workflow CLI takes the App you upload and sends it over to Amazon Web Service's Lambda. We then make calls to execute the operations your App defines as we execute Zaps. Your App takes the input data we provide (if any), makes the necessary HTTP calls, and returns the relevant data, which gets fed back into Pling.

CLI vs the Web Builder Platform

From a user perspective, both the CLI and the existing web builder platform offer the same experience. The biggest difference is how they're developed. The CLI takes a much more code-first approach, allowing you to develop your Pling app just like you would any other programming project. The web builder, on the other hand, is much better for folks who want to make an app with minimal coding involved. Both will continue to coexist, so pick whichever fits your needs best!

Requirements

All Pling CLI apps are run using Node.js v6.11.0.

You can develop using any version of Node you'd like, but your code has to run on Node v6.10.2. You can accomplish this by developing on your preferred version and then transpiling with Babel (or similar).

To ensure stability for our users, we also require that you run your tests on v6.10.2 as well. If you don't have it available, we recommend using either nvm or n to install v6.10.2 and run the tests locally. On Windows you can use nvm-windows or nodist.

For NVM on Mac (via homebrew):

brew install nvm
nvm install v6.10.2

You can then either swap to that version with nvm use v6.10.2, or do nvm exec v6.10.2 plg-workflow test so you can run tests without having to switch versions while developing.

Quick Setup Guide

Be sure to check the Requirements before you start! Also, we recommend the Tutorial for a more thorough introduction.

# install the CLI globally
npm install -g plg-workflow-cli

Your Pling Workflow CLI should be installed and ready to go at this point. Next up, we'll create our first app!

# create a directory with the minimum required files
zapier init example-app

# move into the new directory
cd example-app

# install all the libraries needed for your app
npm install

Note: there are plenty of templates & example apps to choose from! View all Example Apps here.

You should now have a working local app. You can run several local commands to try it out.

# run the local tests
# the same as npm test, but adds some extra things to the environment
zapier test

Next, you'll probably want to upload app to Zapier itself so you can start testing live.

# push your app to Zapier
zapier push

Go check out our full CLI reference documentation to see all the other commands!

Tutorial

For a full tutorial, head over to our wiki for a comprehensive walkthrough for creating your first app. If this isn't your first rodeo, read on! helpful information about your app

Local Project Structure

In your app's folder, you should see this general recommended structure. The index.js is Zapier's entry point to your app. Zapier expects you to export an App definition there.

$ tree .
.
├── README.md
├── index.js
├── package.json
├── triggers
│   └── contact-by-tag.js
├── resources
│   └── Contact.js
├── test
│   ├── basic.js
│   ├── triggers.js
│   └── resources.js
├── build
│   └── build.zip
└── node_modules
    ├── ...
    └── ...

Local App Definition

The core definition of your App will look something like this, and is what your index.js should provide as the only export:

const App = {
  // both version strings are required
  version: require('./package.json').version,
  platformVersion: require('plg-workflow-cli').version,

  // see "Authentication" section below
  authentication: {
  },

  // see "Dehydration" section below
  hydrators: {
  },

  // see "Making HTTP Requests" section below
  requestTemplate: {
  },
  beforeRequest: [
  ],
  afterResponse: [
  ],

  // See "Resources" section below
  resources: {
  },

  // See "Triggers/Searches/Creates" section below
  triggers: {
  },
  searches: {
  },
  creates: {
  }
};

module.exports = App;

Tip: you can use higher order functions to create any part of your App definition!

Get Help!

You can get help by either emailing engineers@pling.net.br.

How to use

  1. Fork the project
  2. git clone git@github.com:<YOUR_USER_NAME>/<PROJECT>.git
  3. cd <PROJECT>
  4. npm install
  5. plg-cli init

Commands

plg-cli start <issue_number> Começa uma issue a partir de pp.

plg-cli start <issue_number> <base_issue_number> Começa uma issue a partir de pp incluindo os commits de outra issue que esteja em seu fork local.

plg-cli sync Sincroniza a issue atual com a pp.

plg-cli sync <base_issue_number> Sincroniza a issue atual com outra issue que esteja em seu fork local.

plg-cli deploy <place_to_deploy> Faz o deploy da issue com a branch ou environment desejado em pull request.

plg-cli deploy <place_to_deploy> <base_issue_number> Faz o deploy da issue com a branch ou environment desejado em pull request quando a branch foi criada a partir de outra que não seja a pp.