afterlife 1.6.1 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/afterlife.gemspec +0 -4
- data/lib/afterlife/cdn/cli.rb +14 -1
- data/lib/afterlife/cdn/server.rb +2 -4
- data/lib/afterlife/config/provider.rb +13 -6
- data/lib/afterlife/deploy/cdn_deployment.rb +1 -1
- data/lib/afterlife/deploy/deployment.rb +2 -1
- data/lib/afterlife/deploy/kubernetes_deployment.rb +15 -0
- data/lib/afterlife/deploy.rb +9 -2
- data/lib/afterlife/exec.rb +9 -6
- data/lib/afterlife/release/change_version.rb +0 -2
- data/lib/afterlife/release/cli.rb +14 -0
- data/lib/afterlife/release/create_helper.rb +0 -2
- data/lib/afterlife/repo/provider.rb +14 -2
- data/lib/afterlife/repo.rb +0 -2
- data/lib/afterlife/stage.rb +4 -0
- data/lib/afterlife/version.rb +1 -1
- data/lib/afterlife.rb +0 -2
- metadata +2 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ffc976585b365c8ca8aef05a6a29cda8a17a75e23e11b5c63bbaf87b642dadd
|
4
|
+
data.tar.gz: caffb4ab8840d0b4e9ab421aa002479e3a425627c6ed75f0db283bd96bc6a3ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7867557a8d55c92e4ff347761f6f0b2df9dc7ee563de9d334b8fe2652cc33b36058cfe4b179292ad9c649700c7012935fc360bbdc31d418ba7366b0ff9805944
|
7
|
+
data.tar.gz: c58bd6f13ae95e3a7b612458a49db8da74a4736779621c0458424d0f1f96793a54f4c6c6114558c6999557cd8d0fbf318ce175249f2dbc5f3db4eefa50871bb2
|
data/README.md
CHANGED
@@ -7,14 +7,15 @@ TODO: Delete this and the text abovxe, and describe your gem
|
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
1. Execute `bin/install` in the repository root
|
10
|
-
2. Put a `
|
10
|
+
2. Put a `config.yml` on ~/.afterlife/config.yml based on the AWS credentials found on mifiel's bitwarden vault
|
11
11
|
3. Install AWS CLI following the [official guide](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).
|
12
12
|
|
13
13
|
## Usage
|
14
|
-
Run `afterlife help` for a list of all available commands
|
15
14
|
|
15
|
+
Run `afterlife help` for a list of all available commands
|
16
16
|
|
17
17
|
## About CDN
|
18
|
+
|
18
19
|
Logs can be found on `~/.afterlife/logs/cdn.log`
|
19
20
|
|
20
21
|
Running `afterlife cdn start` will run the CDN web server in the background. Running in foreground using `afterlife cdn start --foreground` will display errors and content normally found in logs in console instead.
|
data/afterlife.gemspec
CHANGED
@@ -28,10 +28,6 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ['lib']
|
30
30
|
|
31
|
-
spec.add_dependency 'activesupport'
|
32
|
-
spec.add_dependency 'git'
|
33
|
-
spec.add_dependency 'puma'
|
34
|
-
spec.add_dependency 'rackup'
|
35
31
|
spec.add_dependency 'thor'
|
36
32
|
spec.add_dependency 'zeitwerk'
|
37
33
|
|
data/lib/afterlife/cdn/cli.rb
CHANGED
@@ -20,9 +20,10 @@ module Afterlife
|
|
20
20
|
aliases: '-f'
|
21
21
|
option 'no-link', type: :boolean
|
22
22
|
def start
|
23
|
+
assert_rackup_dependency
|
23
24
|
Cdn.link unless options['no-link']
|
24
25
|
say_status 'Starting', "http://localhost:#{options[:port]}"
|
25
|
-
Cdn::Server.start(options.
|
26
|
+
Cdn::Server.start(options.slice('port', 'foreground'))
|
26
27
|
log_success "The server started at http://localhost:#{options[:port]}"
|
27
28
|
rescue Afterlife::Error => e
|
28
29
|
log_error(e)
|
@@ -54,6 +55,18 @@ module Afterlife
|
|
54
55
|
Cdn.link
|
55
56
|
log_success('Repos successfully linked to local CDN path')
|
56
57
|
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def assert_rackup_dependency
|
62
|
+
require 'rackup'
|
63
|
+
rescue LoadError
|
64
|
+
fatal!(
|
65
|
+
'rackup is not installed: In order to use the `afterlife cdn` ' \
|
66
|
+
'you need to install rackup: `gem install rackup`. ' |
|
67
|
+
'Aditionaly, for improved logging, you may want to install puma.',
|
68
|
+
)
|
69
|
+
end
|
57
70
|
end
|
58
71
|
end
|
59
72
|
end
|
data/lib/afterlife/cdn/server.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'rackup'
|
4
|
-
|
5
3
|
module Afterlife
|
6
4
|
module Cdn
|
7
5
|
class Server
|
@@ -31,10 +29,10 @@ module Afterlife
|
|
31
29
|
@instance = Rackup::Server.new(
|
32
30
|
environment: ENV['RACK_ENV'] || 'development',
|
33
31
|
quiet: true, # we setup log in config.ru
|
34
|
-
Port: args[
|
32
|
+
Port: args['port'],
|
35
33
|
config: Afterlife.root.join('config.ru').to_s,
|
36
34
|
pid: Server.pid_file.to_s,
|
37
|
-
daemonize: !args[
|
35
|
+
daemonize: !args['foreground'],
|
38
36
|
)
|
39
37
|
end
|
40
38
|
|
@@ -3,6 +3,18 @@
|
|
3
3
|
module Afterlife
|
4
4
|
module Config
|
5
5
|
class Provider
|
6
|
+
PROFILES = [
|
7
|
+
PROFILE_PRODUCTION = 'mifiel-production',
|
8
|
+
PROFILE_TESTING = 'mifiel-sandbox',
|
9
|
+
].freeze
|
10
|
+
# {stage} => {profile}
|
11
|
+
CLOUD_PROFILES = {
|
12
|
+
staging: PROFILE_TESTING,
|
13
|
+
qa: PROFILE_TESTING,
|
14
|
+
sandbox: PROFILE_PRODUCTION,
|
15
|
+
production: PROFILE_PRODUCTION,
|
16
|
+
}.freeze
|
17
|
+
|
6
18
|
def respond_to_missing?(sym, include_all)
|
7
19
|
config.key?(sym) || super
|
8
20
|
end
|
@@ -31,16 +43,11 @@ module Afterlife
|
|
31
43
|
|
32
44
|
def config
|
33
45
|
@config ||= !file_exist? && default_config
|
34
|
-
@config ||= YAML.load_file(file)
|
46
|
+
@config ||= YAML.load_file(file, symbolize_names: true)
|
35
47
|
end
|
36
48
|
|
37
49
|
def default_config
|
38
50
|
{
|
39
|
-
credentials: {
|
40
|
-
aws: {
|
41
|
-
profile: ENV.fetch('AWS_PROFILE', nil),
|
42
|
-
},
|
43
|
-
},
|
44
51
|
stages: {},
|
45
52
|
}
|
46
53
|
end
|
@@ -14,7 +14,7 @@ module Afterlife
|
|
14
14
|
def setup
|
15
15
|
# only use the defined AWS_PROFILE if its not already been defined
|
16
16
|
repo.env.set(
|
17
|
-
'AWS_PROFILE' => Afterlife.
|
17
|
+
'AWS_PROFILE' => Afterlife.current_stage.profile,
|
18
18
|
'AWS_BUCKET' => Afterlife.current_stage.bucket,
|
19
19
|
'AWS_REGION' => Afterlife.current_stage.region,
|
20
20
|
)
|
@@ -75,11 +75,26 @@ module Afterlife
|
|
75
75
|
def apply_kubernetes_settings
|
76
76
|
return if options['no-apply']
|
77
77
|
|
78
|
+
assert_correct_context unless ENV['CI']
|
78
79
|
<<-BASH
|
79
80
|
kubectl apply -k #{kubelocation}
|
80
81
|
BASH
|
81
82
|
end
|
82
83
|
|
84
|
+
def assert_correct_context
|
85
|
+
return if current_context == expected_context
|
86
|
+
|
87
|
+
fail Error, "kubectl context should be '#{expected_context}' but you are in '#{current_context}'"
|
88
|
+
end
|
89
|
+
|
90
|
+
def expected_context
|
91
|
+
"aws-#{Afterlife.current_stage.profile}"
|
92
|
+
end
|
93
|
+
|
94
|
+
def current_context
|
95
|
+
@current_context ||= Exec.result('kubectl config current-context')
|
96
|
+
end
|
97
|
+
|
83
98
|
# utils
|
84
99
|
|
85
100
|
def local_stage?
|
data/lib/afterlife/deploy.rb
CHANGED
@@ -4,6 +4,13 @@ module Afterlife
|
|
4
4
|
module Deploy
|
5
5
|
module_function
|
6
6
|
|
7
|
+
DEPLOYMENTS = {
|
8
|
+
cdn: 'CdnDeployment',
|
9
|
+
cdn_stenciljs: 'CdnStenciljsDeployment',
|
10
|
+
custom: 'CustomDeployment',
|
11
|
+
kubernetes: 'KubernetesDeployment',
|
12
|
+
}.freeze
|
13
|
+
|
7
14
|
def call(stage, options)
|
8
15
|
deployment = klass.new(options)
|
9
16
|
Afterlife.current_stage = stage
|
@@ -14,8 +21,8 @@ module Afterlife
|
|
14
21
|
end
|
15
22
|
|
16
23
|
def klass
|
17
|
-
klass =
|
18
|
-
fail Error, "deployment type '#{current_type}' is invalid" unless
|
24
|
+
klass = DEPLOYMENTS[current_type.gsub('-', '_').to_sym]
|
25
|
+
fail Error, "deployment type '#{current_type}' is invalid" unless klass
|
19
26
|
|
20
27
|
const_get(klass)
|
21
28
|
end
|
data/lib/afterlife/exec.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# adds String#squish and others
|
4
|
-
require 'active_support/core_ext/string'
|
5
|
-
|
6
3
|
module Afterlife
|
7
4
|
class Exec
|
8
5
|
def self.result(arg)
|
@@ -17,7 +14,7 @@ module Afterlife
|
|
17
14
|
|
18
15
|
def self.parse(arg, env)
|
19
16
|
Array(arg.flatten.compact).flatten.map do |command|
|
20
|
-
format(command, env.
|
17
|
+
format(command, env.transform_keys(&:to_sym))
|
21
18
|
end
|
22
19
|
end
|
23
20
|
|
@@ -31,9 +28,9 @@ module Afterlife
|
|
31
28
|
parsed_commands.map do |command|
|
32
29
|
Afterlife.cli.log_info(command) if Afterlife.cli.options['verbose']
|
33
30
|
next if Afterlife.cli.options['dry-run']
|
34
|
-
next `#{command}
|
31
|
+
next squish(`#{command}`) if result
|
35
32
|
|
36
|
-
system(env_hash, command
|
33
|
+
system(env_hash, squish(command), exception: true)
|
37
34
|
end.compact
|
38
35
|
rescue RuntimeError => e
|
39
36
|
raise Error, e
|
@@ -50,5 +47,11 @@ module Afterlife
|
|
50
47
|
def env_hash
|
51
48
|
repo.env.env
|
52
49
|
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def squish(str)
|
54
|
+
str.gsub(/[[:space:]]+/, ' ').strip
|
55
|
+
end
|
53
56
|
end
|
54
57
|
end
|
@@ -23,6 +23,7 @@ module Afterlife
|
|
23
23
|
default: CreateHelper::DEFAULT_BASE_BRANCH,
|
24
24
|
desc: 'Base branch'
|
25
25
|
def create(part)
|
26
|
+
assert_git_dependency
|
26
27
|
fatal! "Part '#{part}' is not allowed" unless CreateHelper::PARTS.include?(part.to_sym)
|
27
28
|
|
28
29
|
CreateHelper.call(self, options.merge(part: part))
|
@@ -30,6 +31,7 @@ module Afterlife
|
|
30
31
|
|
31
32
|
desc 'hotfix', 'create a hotfix branch'
|
32
33
|
def hotfix
|
34
|
+
assert_git_dependency
|
33
35
|
args = options.merge(part: :patch, from: :master, prefix: :hotfix)
|
34
36
|
CreateHelper.call(self, args)
|
35
37
|
end
|
@@ -37,8 +39,20 @@ module Afterlife
|
|
37
39
|
desc 'pre', 'create a prerelease tag'
|
38
40
|
option :push, type: :boolean, default: true
|
39
41
|
def pre
|
42
|
+
assert_git_dependency
|
40
43
|
PreHelper.call(self, options)
|
41
44
|
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def assert_git_dependency
|
49
|
+
require 'git'
|
50
|
+
rescue LoadError
|
51
|
+
fatal!(
|
52
|
+
'Git is not installed: In order to use the `afterlife release` ' \
|
53
|
+
'you need to install git: `gem install git`',
|
54
|
+
)
|
55
|
+
end
|
42
56
|
end
|
43
57
|
end
|
44
58
|
end
|
@@ -17,7 +17,7 @@ module Afterlife
|
|
17
17
|
|
18
18
|
if config_file.exist?
|
19
19
|
@config = base_config
|
20
|
-
@config =
|
20
|
+
@config = deep_merge(parent, base_config) if parent
|
21
21
|
end
|
22
22
|
|
23
23
|
@config ||= {}
|
@@ -37,12 +37,24 @@ module Afterlife
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def base_config
|
40
|
-
@base_config ||= YAML.load_file(config_file)
|
40
|
+
@base_config ||= YAML.load_file(config_file, symbolize_names: true)
|
41
41
|
end
|
42
42
|
|
43
43
|
def config_file
|
44
44
|
@config_file ||= full_path.join(CONFIG_NAME)
|
45
45
|
end
|
46
|
+
|
47
|
+
# teken from
|
48
|
+
# https://github.com/rails/rails/blob/main/activesupport/lib/active_support/deep_mergeable.rb#L34
|
49
|
+
def deep_merge(one, two)
|
50
|
+
one.merge(two) do |_key, this_val, other_val|
|
51
|
+
if this_val.is_a?(Hash) && other_val.is_a?(Hash)
|
52
|
+
deep_merge(this_val, other_val)
|
53
|
+
else
|
54
|
+
other_val
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
46
58
|
end
|
47
59
|
end
|
48
60
|
end
|
data/lib/afterlife/repo.rb
CHANGED
data/lib/afterlife/stage.rb
CHANGED
data/lib/afterlife/version.rb
CHANGED
data/lib/afterlife.rb
CHANGED
metadata
CHANGED
@@ -1,71 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: afterlife
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
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-
|
11
|
+
date: 2024-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: activesupport
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: git
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: puma
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rackup
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
13
|
- !ruby/object:Gem::Dependency
|
70
14
|
name: thor
|
71
15
|
requirement: !ruby/object:Gem::Requirement
|