Sha256: d846d8ae244d5386f96e7034e1b6f0b0b1432c2604d6fe15a7832b37eab06df7

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module DPL
  class Provider
    class Nodejitsu < Provider
      CONFIG_FILE = '.dpl/jitsu.json'

      experimental "Nodejitsu"
      requires 'json'
      npm_g 'jitsu'

      def config
        {
          "username"     => option(:username),
          "apiToken"     => option(:api_key),
          "apiTokenName" => "travis"
        }
      end

      def check_auth
        File.open(CONFIG_FILE, 'w') { |f| f << config.to_json }
      end

      def check_app
        error "missing package.json" unless File.exist? 'package.json'

        package = JSON.parse File.read('package.json')
        message = "missing %s in package.json, see https://www.nodejitsu.com/documentation/appendix/package-json/"
        error message % "subdomain"    unless package['subdomain']
        error message % "node version" unless package['engines'] and package['engines']['node']
        error message % "start script" unless package['scripts'] and package['scripts']['start']
      end

      def needs_key?
        false
      end

      def push_app
        system "jitsu deploy -j #{CONFIG_FILE}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dpl-1.0.3 lib/dpl/provider/nodejitsu.rb