Sha256: 2af88ccad346cae21eb4cd8e6204409e23eab633be2bc440ee44d33e1b2af121

Contents?: true

Size: 1.38 KB

Versions: 9

Compression:

Stored size: 1.38 KB

Contents

require 'open-uri'

module Dpl
  module Providers
    class Surge < Provider
      status :alpha

      description sq(<<-str)
        tbd
      str

      node_js '>= 8.8.1'

      gem 'json'
      npm :surge
      env :surge

      opt '--login EMAIL', 'Surge login (the email address you use with Surge)', required: true
      opt '--token TOKEN', 'Surge login token (can be retrieved with `surge token`)', required: true, secret: true
      opt '--domain NAME', 'Domain to publish to. Not required if the domain is set in the CNAME file in the project folder.'
      opt '--project PATH', 'Path to project directory relative to repo root', default: '.'

      cmds deploy: 'surge %{project} %{domain}'

      msgs invalid_project: '%{project} is not a directory',
           missing_domain:  'Please set the domain in .travis.yml or in a CNAME file in the project directory'

      def login
        ENV['SURGE_LOGIN'] ||= opts[:login]
        ENV['SURGE_TOKEN'] ||= opts[:token]
      end

      def validate
      	error :invalid_project if invalid_project?
      	error :missing_domain  if missing_domain?
      end

      def deploy
        shell :deploy
      end

      def invalid_project?
        !File.directory?(project)
      end

      def missing_domain?
        !domain && !File.exist?("#{project}/CNAME")
      end

      def project
        expand(super, build_dir)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dpl-2.0.0.alpha.11 lib/dpl/providers/surge.rb
dpl-2.0.0.alpha.10 lib/dpl/providers/surge.rb
dpl-2.0.0.alpha.9 lib/dpl/providers/surge.rb
dpl-2.0.0.alpha.8 lib/dpl/providers/surge.rb
dpl-2.0.0.alpha.7 lib/dpl/providers/surge.rb
dpl-2.0.0.alpha.6 lib/dpl/providers/surge.rb
dpl-2.0.0.alpha.5 lib/dpl/providers/surge.rb
dpl-2.0.0.alpha.2 lib/dpl/providers/surge.rb
dpl-2.0.0.alpha.1 lib/dpl/providers/surge.rb