afterlife 1.5.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e03a1499e1af905014e5fb48d8865601a0bb354a856d56dc0a629a3b3c08a99b
4
- data.tar.gz: 345db972b71109a69d3117e3ef5e3a8fc8cc4aec094c230f9b49ea46e2c206e3
3
+ metadata.gz: 39b1dc76a5dcf45f83fcde8b8d8198b0d8d9849915f7e80cab37f82fbc6621b6
4
+ data.tar.gz: 806c05f05b5c7729bd765b1f66757a45daa3f17e425a2a1aecb6d951d62e8813
5
5
  SHA512:
6
- metadata.gz: 2a4b14afb3f286756663da5d5c6c039cd0c327cf8a9ad60a3c20b04d994fdba73b2270892b209cbf9ece8f424e17e2e6eab9798f93416c254aa4549b486a41fc
7
- data.tar.gz: 89e9ec3e6d10345f8baeea198d0dde968d96b438cc5312a7d2f545176b4755bd6953b0ad0ad60663015c33b8ac477f5bacb3aa1948bc320a1495cfd1602396ef
6
+ metadata.gz: 2d57810ac8356dd463d272ece6bf10dc06c2cefd47ec0d1248d0799a9dd95048dc665bdd2b49f38e3efeefe28955671dbb3f5266fed965869be8024a42924c5c
7
+ data.tar.gz: '0393f5f21e8fc2a6e79f8c345f803579681f3aa07a796a280ee7ac1267eb7ccef19dd506bdfcccdc2e6f985057a82514c151b967ca60549763e97a81d792fd83'
@@ -23,6 +23,10 @@ module Afterlife
23
23
  end
24
24
  end
25
25
 
26
+ def deploy_notification_url
27
+ config[:deploy_notification_url]
28
+ end
29
+
26
30
  private
27
31
 
28
32
  def config
@@ -20,6 +20,7 @@ module Afterlife
20
20
  --exclude '*.ts'
21
21
  --exclude '*.tsx'
22
22
  --exclude '*.esm.js'
23
+ --exclude '*.map'
23
24
  --size-only
24
25
  --cache-control 'public, max-age=31540000'
25
26
  BASH
@@ -13,10 +13,8 @@ module Afterlife
13
13
  Afterlife.cli = self
14
14
  Deploy.call(stage, options) do |deployment|
15
15
  setup_deploy(deployment)
16
- say_status 'Deploying', deployment.initial_message
17
- deployment.run
18
- say_status 'Deployed', deployment.output
19
- run_after_hooks
16
+ process_deploy(deployment)
17
+ Notify.call(Afterlife.current_repo.name, Afterlife.current_stage.name)
20
18
  end
21
19
  rescue Afterlife::Error => e
22
20
  fatal!(e.message)
@@ -24,6 +22,13 @@ module Afterlife
24
22
 
25
23
  private
26
24
 
25
+ def process_deploy(deployment)
26
+ say_status 'Deploying', deployment.initial_message
27
+ deployment.run
28
+ say_status 'Deployed', deployment.output
29
+ run_after_hooks
30
+ end
31
+
27
32
  def run_after_hooks
28
33
  return if options['skip-after-hooks']
29
34
 
@@ -3,7 +3,6 @@
3
3
  module Afterlife
4
4
  module Deploy
5
5
  class Deployment
6
-
7
6
  attr_reader :options
8
7
 
9
8
  def initialize(options)
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'net/http'
4
+
5
+ module Afterlife
6
+ module Notify
7
+ module_function
8
+
9
+ def call(repository, branch)
10
+ return if notification_url.empty?
11
+
12
+ response = send_request(repository, branch)
13
+
14
+ return if response.code == '200'
15
+
16
+ fail Error,
17
+ "The deploy notification URL returned a #{response.code} status code, " \
18
+ 'and the notification may not have been sent.'
19
+ end
20
+
21
+ def notification_url
22
+ @notification_url ||= ENV.fetch('AFTERLIFE_DEPLOY_NOTIFICATION_URL', nil) \
23
+ || Afterlife.config.deploy_notification_url \
24
+ || Afterlife.current_repo.conf.dig(:deploy, :deploy_notification_url) \
25
+ || ''
26
+ end
27
+
28
+ def send_request(repository, branch)
29
+ uri = URI(notification_url)
30
+ body = {
31
+ branch: branch,
32
+ repository: repository,
33
+ }
34
+ headers = { 'Content-Type': 'application/json' }
35
+ Net::HTTP.post(uri, body.to_json, headers)
36
+ end
37
+ end
38
+ end
@@ -39,7 +39,7 @@ module Afterlife
39
39
  end
40
40
 
41
41
  def repo_method
42
- @repo_method ||= path.first.to_s.gsub('-', '_').to_sym
42
+ @repo_method ||= path.to_s.gsub('-', '_').to_sym
43
43
  end
44
44
 
45
45
  def repo
@@ -91,7 +91,7 @@ module Afterlife
91
91
  end
92
92
 
93
93
  def full_name
94
- package_json[:name]
94
+ package_json[:name] || File.basename(full_path)
95
95
  end
96
96
 
97
97
  # Files that define versions
@@ -114,6 +114,8 @@ module Afterlife
114
114
 
115
115
  def package_json
116
116
  @pkg_path ||= conf.dig(:cdn, :package_json) || full_path.join('package.json')
117
+ return {} unless File.exist?(@pkg_path)
118
+
117
119
  @package_json ||= JSON.parse(File.read(@pkg_path), symbolize_names: true)
118
120
  end
119
121
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Afterlife
4
- VERSION = '1.5.0'
4
+ VERSION = '1.6.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: afterlife
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genaro Madrid
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-31 00:00:00.000000000 Z
11
+ date: 2024-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -133,6 +133,7 @@ files:
133
133
  - lib/afterlife/deploy/kubernetes_deployment.rb
134
134
  - lib/afterlife/environment.rb
135
135
  - lib/afterlife/exec.rb
136
+ - lib/afterlife/notify.rb
136
137
  - lib/afterlife/release.rb
137
138
  - lib/afterlife/release/change_version.rb
138
139
  - lib/afterlife/release/cli.rb