fanforce-factory

The simplest way to create and manage a folder of Fanforce addons (plugins, widgets, and apps). This gem provides bulk commands that you can run against your entire list of addons.

Installation

Run this command from your command line:

gem install fanforce-factory

Usage

Run this command to view usage instructions

$ factory

Filtering Commands by Addon Type

Filtering is supported in version 0.1.0 and higher for all bulk commands. To filter a command, just prefix it with a colon (:) and the filter you want to apply (:[FILTER]). Filter can be any addon_type (plugin, widget, or app), singular or plural. For example, the following command would only run bundle update on apps:

factory :apps bundle update

If you are using the addon type of "plugins", you can further filter by any of the plugin types (data_connector, data_processor, broadcaster, identifier, behavior):

factory :plugins:behaviors bundle update

If you want to get really specific, you can filter on a specific directory:

factory :plugin-watch-youtube bundle update

Customizing Your Factory Setup with .factoryconfig

You can add a .factoryconfig to any factory folder you've setup for your addons. It accepts any valid YAML markup. Below is a example file that sets a custom local path for plugin, app, and widget gems, plus a version for app gems.

factory_gems:

  plugin:
    path: '../../fanforce-plugin-factory'

  app:
    path: '../../fanforce-app-factory'
    version: '~> 0.1.3'

  widget:
    path: '../../fanforce-widget-factory'

For more options see BitBucket and Heroku below.

Run Factory Inside an Addon

Sometimes you'll want to use factory commands inside a specific addon. You can as long as the folder contains a config.ru file, and the addon is a subdirectory of a factory folder containing a .factoryconfig file.

Supercharge Your Factory

Fanforce-factory comes with a special application when you're running commands on a long list of addons and each command is taking a long time to run. It forks each command and runs them in parallel. Only a subset of the full factory commands are available with factory-supercharge. Run the following from your terminal to see your available options:

factory-supercharge

BitBucket: Creating Repositories and Pushing

A BitBucket repository will be automatically setup for each new addon if a bitbucket object is defined in your .factoryconfig file:

bitbucket:
    user: fanforce-factory
    password: zE27fbitbucket

Heroku Apps: Creating and Updating

A heroku app will be automatically setup for each new addon if a heroku object is defined in your .factoryconfig file. You'll need one for each environment (qa|production) you want apps setup for.

heroku:
    production:
        user: [email protected]
        git_ssh_domain: heroku_fanforce_factory
        password: zE27fheroku
        app_domain: ffapp.io
        plugin_domain: ffplugin.io
        widget_domain: ffwidget.io
        smarturl_domain: fanforce.io

The git_ssh_domain variable listed above is needed if you're pushing to multiple Heroku accounts as you'll need to specify the SSH key that must be used (each Heroku account requires a unique ssh key). For example, the above git_ssh_domain variable references the following lines in ~/.ssh/config:

Host heroku_fanforce_factory
  HostName heroku.com
  User [email protected]
  IdentityFile ~/.ssh/heroku_fanforce_factory

See http://www.springloops.com/blog/git-config-for-mutiply-ssh-keys/ for more info.

Environment Variables

Fanforce-factory allows you to setup a list of env variables that can be loaded by your app it's running in your local development environment, pushed to Heroku, or tasks setup on IronWorker.

First, you need to setup a folder called ".env" in your factory folder with a series of YAML files inside. The only required file is _bind.yaml:

constantcontact:
  - app-constantcontact
  - plugin-constantcontact-subscribers

facebook:
  - app-facebook
  - plugin-facebook-friends
  - plugin-facebook-posts

iron: ALL

Each key is the filename (minus .yaml) of the YAML file holding a list of ENV variables. The array underneath is the folder names of addons that these ENV variables will be loaded into. Alternatively, you can specify the keyword ALL if those ENV variables should be loaded into all addons.

Second, you'll need to setup the filenames references in _bind.yaml. Each file contains a hash of ENV key/values organized by RACK_ENV. Here's is an example of facebook.yaml (of course, you'll need to provide legit facebook api_keys and api_secrets):

development:
  api_key: 175620799120142
  api_secret: b4e86cbf9db2ch5777609396b1d0a52f

qa:
  api_key: 362017347478160
  api_secret: cf3605c0cnda02c95ddd1bb983a59e7a

Using IronWorker

Fanforce-factory comes with built in support for using IronWorker in your addons:

factory iron_workers upload:development

There are a couple things you'll want to setup first:

1. Env Variables

  • IRON_TOKEN
  • IRON_PROJECT_ID

2.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request