Method: CapsuleCD::Javascript::JavascriptEngine#release_step

Defined in:
lib/capsulecd/javascript/javascript_engine.rb

#release_stepObject

this step should push the release to the package repository (ie. npm, chef supermarket, rubygems)



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/capsulecd/javascript/javascript_engine.rb', line 155

def release_step
  super

  if @_is_npm
    npmrc_path = File.expand_path('~/.npmrc')

    unless @config.npm_auth_token
      fail CapsuleCD::Error::ReleaseCredentialsMissing, 'cannot deploy page to npm, credentials missing'
    end

    # write the knife.rb config file.
    File.open(npmrc_path, 'w+') do |file|
      file.write("//registry.npmjs.org/:_authToken=#{@config.npm_auth_token}")
    end

    # run npm publish
    Open3.popen3('npm publish .', chdir: @source_git_local_path) do |_stdin, stdout, stderr, external|
      { stdout: stdout, stderr: stderr }. each do |name, stream_buffer|
        Thread.new do
          until (line = stream_buffer.gets).nil?
            puts "#{name} -> #{line}"
          end
        end
      end
      # wait for process
      external.join
      unless external.value.success?
        fail CapsuleCD::Error::ReleasePackageError, 'npm publish failed. Check log for exact error'
      end
    end
  end
end