afterlife 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/afterlife/cli.rb +4 -15
- data/lib/afterlife/config/cli.rb +21 -0
- data/lib/afterlife/config/provider.rb +31 -0
- data/lib/afterlife/config.rb +1 -24
- data/lib/afterlife/deploy/cdn_deployment.rb +8 -3
- data/lib/afterlife/deploy/cdn_stenciljs_deployment.rb +30 -0
- data/lib/afterlife/deploy/deployment.rb +1 -1
- data/lib/afterlife/deploy.rb +6 -7
- data/lib/afterlife/exec.rb +1 -1
- data/lib/afterlife/repo/config.rb +54 -0
- data/lib/afterlife/repo/provider.rb +47 -0
- data/lib/afterlife/repo.rb +5 -43
- data/lib/afterlife/version.rb +1 -1
- data/lib/afterlife.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed6b64b46c70114724bb7961af7c384c079bc7917a69e83a3c4f5dce62152ecc
|
4
|
+
data.tar.gz: 8da0219c81a43ac90190721388bc5cc4afc685ec377caebe8a8ab04331fe3df0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fbb65c54f1e464917dab23183f6e376cd594de9de50aa9462225f06285234759cc6ec6092f164a2dc674426ad674938d2d03d958195bc2286de6dad470833d8
|
7
|
+
data.tar.gz: c57a701252b3b7c919a45c4164c26d5ce10086f55f222d66bf0afe8592dacb28875ffadf69d04a10d021b5530c36daf36d5c18a5f309e50e3e24001a8da50cb7
|
data/lib/afterlife/cli.rb
CHANGED
@@ -22,21 +22,8 @@ module Afterlife
|
|
22
22
|
log_success 'afterlife is ready!'
|
23
23
|
end
|
24
24
|
|
25
|
-
desc 'config
|
26
|
-
|
27
|
-
path = path.split('.').map(&:to_sym)
|
28
|
-
result = repo.conf.dig(*path)
|
29
|
-
case result
|
30
|
-
when Hash
|
31
|
-
say JSON.generate(result)
|
32
|
-
when Array
|
33
|
-
result.each do |item|
|
34
|
-
say item
|
35
|
-
end
|
36
|
-
else
|
37
|
-
say result
|
38
|
-
end
|
39
|
-
end
|
25
|
+
desc 'config', 'Repo configuration options'
|
26
|
+
subcommand 'config', Config::Cli
|
40
27
|
|
41
28
|
desc 'cdn', 'CDN stuff'
|
42
29
|
subcommand 'cdn', Cdn::Cli
|
@@ -49,6 +36,8 @@ module Afterlife
|
|
49
36
|
option :yes, type: :boolean
|
50
37
|
def deploy(stage)
|
51
38
|
invoke Deploy::Cli, :call, [stage], options
|
39
|
+
rescue Deploy::Error
|
40
|
+
fatal!(e.message)
|
52
41
|
rescue Interrupt
|
53
42
|
log_interrupted
|
54
43
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Afterlife
|
4
|
+
module Config
|
5
|
+
class Cli < Thor
|
6
|
+
include BaseCli
|
7
|
+
def self.exit_on_failure?
|
8
|
+
true
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'get <path>', 'get config path'
|
12
|
+
def get(path)
|
13
|
+
Repo::Config.read(path) do |value|
|
14
|
+
say value
|
15
|
+
end
|
16
|
+
rescue Repo::Config::Error => e
|
17
|
+
fatal!(e.message)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Afterlife
|
4
|
+
module Config
|
5
|
+
class Provider
|
6
|
+
def self.file
|
7
|
+
Afterlife.local_path.join('config.yml')
|
8
|
+
end
|
9
|
+
|
10
|
+
def respond_to_missing?(sym, include_all)
|
11
|
+
config.key?(sym) || super
|
12
|
+
end
|
13
|
+
|
14
|
+
def method_missing(sym, *args, &block)
|
15
|
+
config.key?(sym) ? config[sym] : super
|
16
|
+
end
|
17
|
+
|
18
|
+
def stages
|
19
|
+
@stages ||= config.delete(:stages)&.to_h do |name, val|
|
20
|
+
[name, Stage.new(val.merge(name: name.to_s))]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def config
|
27
|
+
@config ||= YAML.load_file(Provider.file).deep_symbolize_keys
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/afterlife/config.rb
CHANGED
@@ -1,29 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Afterlife
|
4
|
-
|
5
|
-
def self.file
|
6
|
-
Afterlife.local_path.join('config.yml')
|
7
|
-
end
|
8
|
-
|
9
|
-
def respond_to_missing?(sym, include_all)
|
10
|
-
config.key?(sym) || super
|
11
|
-
end
|
12
|
-
|
13
|
-
def method_missing(sym, *args, &block)
|
14
|
-
config.key?(sym) ? config[sym] : super
|
15
|
-
end
|
16
|
-
|
17
|
-
def stages
|
18
|
-
@stages ||= config.delete(:stages)&.to_h do |name, val|
|
19
|
-
[name, Stage.new(val.merge(name: name.to_s))]
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def config
|
26
|
-
@config ||= YAML.load_file(Config.file).deep_symbolize_keys
|
27
|
-
end
|
4
|
+
module Config
|
28
5
|
end
|
29
6
|
end
|
@@ -48,18 +48,23 @@ module Afterlife
|
|
48
48
|
--exclude '*.ts'
|
49
49
|
--exclude '*.tsx'
|
50
50
|
--size-only
|
51
|
-
--cache-control '
|
51
|
+
--cache-control 'public, max-age=31540000'
|
52
52
|
BASH
|
53
53
|
end
|
54
54
|
|
55
55
|
def revision
|
56
56
|
<<-BASH
|
57
|
-
echo "#{repo.current_revision}" |
|
57
|
+
echo "#{repo.current_revision}" |
|
58
|
+
aws s3 cp --content-type text/plain --cache-control 'no-cache' - #{s3_revision_path}
|
58
59
|
BASH
|
59
60
|
end
|
60
61
|
|
62
|
+
def s3_revision_path
|
63
|
+
"s3://#{Afterlife.current_stage.bucket}/#{repo.full_name}/revision"
|
64
|
+
end
|
65
|
+
|
61
66
|
def s3_full_path
|
62
|
-
"s3://#{Afterlife.current_stage.bucket}/#{repo.full_name}"
|
67
|
+
"s3://#{Afterlife.current_stage.bucket}/#{repo.full_name}/#{repo.current_revision}"
|
63
68
|
end
|
64
69
|
end
|
65
70
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Afterlife
|
4
|
+
module Deploy
|
5
|
+
class CdnStenciljsDeployment < CdnDeployment
|
6
|
+
private
|
7
|
+
|
8
|
+
def commands
|
9
|
+
[
|
10
|
+
add_revision_command,
|
11
|
+
repo_command || javascripts,
|
12
|
+
revision,
|
13
|
+
]
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_revision_command
|
17
|
+
Dir["#{repo.dist_path}/*.esm.js"].map do |file|
|
18
|
+
next if file.include?(repo.current_revision)
|
19
|
+
|
20
|
+
new_name = file.gsub('.esm.js', "-#{repo.current_revision}.esm.js")
|
21
|
+
"mv #{file} #{new_name}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def s3_full_path
|
26
|
+
"s3://#{Afterlife.current_stage.bucket}/#{repo.full_name}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/afterlife/deploy.rb
CHANGED
@@ -16,12 +16,10 @@ module Afterlife
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def klass
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
CustomDeployment
|
24
|
-
end
|
19
|
+
klass = "#{current_type.gsub('-', '_')}_deployment".classify
|
20
|
+
fail Error, "deployment type '#{current_type}' is invalid" unless const_defined?(klass)
|
21
|
+
|
22
|
+
const_get(klass)
|
25
23
|
end
|
26
24
|
|
27
25
|
def current_type
|
@@ -32,8 +30,9 @@ module Afterlife
|
|
32
30
|
|
33
31
|
def setup_stage(stage)
|
34
32
|
unless Afterlife.config.stages.key?(stage.to_sym)
|
35
|
-
|
33
|
+
fail Error, "invalid stage '#{stage}'. Possible values: #{Afterlife.config.stages.keys.map(&:to_s)}"
|
36
34
|
end
|
35
|
+
|
37
36
|
Afterlife.current_stage = Afterlife.config.stages[stage.to_sym]
|
38
37
|
end
|
39
38
|
|
data/lib/afterlife/exec.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Afterlife
|
4
|
+
class Repo
|
5
|
+
class Config
|
6
|
+
Error = Class.new StandardError
|
7
|
+
|
8
|
+
attr_reader :path
|
9
|
+
|
10
|
+
def self.read(path, &block)
|
11
|
+
new(path).read(&block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(path)
|
15
|
+
@path = path.split('.').map(&:to_sym)
|
16
|
+
end
|
17
|
+
|
18
|
+
def read(&block) # rubocop:disable Metrics/MethodLength
|
19
|
+
case from_yml
|
20
|
+
when Hash
|
21
|
+
yield(JSON.generate(from_yml))
|
22
|
+
when Array
|
23
|
+
from_yml.each(&block)
|
24
|
+
when String, Symbol
|
25
|
+
yield(from_yml)
|
26
|
+
else
|
27
|
+
fail Error, "No config with path '#{path.join('.')}'" unless repo_method?
|
28
|
+
|
29
|
+
yield(repo.public_send(repo_method))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def repo_method?
|
36
|
+
path.count == 1 && repo.public_methods(false).include?(repo_method)
|
37
|
+
end
|
38
|
+
|
39
|
+
def repo_method
|
40
|
+
@repo_method ||= path.first.to_s.gsub('-', '_').to_sym
|
41
|
+
end
|
42
|
+
|
43
|
+
def repo
|
44
|
+
Afterlife.current_repo
|
45
|
+
end
|
46
|
+
|
47
|
+
def from_yml
|
48
|
+
return @from_yml if defined?(@from_yml)
|
49
|
+
|
50
|
+
@from_yml ||= repo.conf.dig(*path)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Afterlife
|
4
|
+
class Repo
|
5
|
+
class Provider
|
6
|
+
CONFIG_NAME = '.afterlife.yml'
|
7
|
+
|
8
|
+
attr_reader :full_path
|
9
|
+
|
10
|
+
def initialize(full_path)
|
11
|
+
@full_path = full_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def config
|
15
|
+
return @config if defined?(@config)
|
16
|
+
|
17
|
+
if config_file.exist?
|
18
|
+
@config = base_config
|
19
|
+
@config = parent.deep_merge(base_config) if parent
|
20
|
+
end
|
21
|
+
|
22
|
+
@config ||= {}
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def parent
|
28
|
+
return @parent if defined?(@parent)
|
29
|
+
|
30
|
+
inherit_from = base_config.delete(:inherit_from)
|
31
|
+
return @parent = nil unless inherit_from
|
32
|
+
|
33
|
+
@parent = Provider.new(full_path.join(inherit_from)).config
|
34
|
+
@parent[:cdn]&.delete(:packages)
|
35
|
+
@parent
|
36
|
+
end
|
37
|
+
|
38
|
+
def base_config
|
39
|
+
@base_config ||= YAML.load_file(config_file).deep_symbolize_keys
|
40
|
+
end
|
41
|
+
|
42
|
+
def config_file
|
43
|
+
@config_file ||= full_path.join(CONFIG_NAME)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/afterlife/repo.rb
CHANGED
@@ -74,6 +74,10 @@ module Afterlife
|
|
74
74
|
@current_revision ||= `git rev-parse HEAD`.chomp
|
75
75
|
end
|
76
76
|
|
77
|
+
def current_revision_short
|
78
|
+
@current_revision_short ||= `git rev-parse --short HEAD`.chomp
|
79
|
+
end
|
80
|
+
|
77
81
|
def name
|
78
82
|
full_name.split('/').last.gsub('-', '_')
|
79
83
|
end
|
@@ -110,49 +114,7 @@ module Afterlife
|
|
110
114
|
end
|
111
115
|
|
112
116
|
def conf
|
113
|
-
@conf ||=
|
114
|
-
end
|
115
|
-
|
116
|
-
class Config
|
117
|
-
CONFIG_NAME = '.afterlife.yml'
|
118
|
-
|
119
|
-
attr_reader :full_path
|
120
|
-
|
121
|
-
def initialize(full_path)
|
122
|
-
@full_path = full_path
|
123
|
-
end
|
124
|
-
|
125
|
-
def config
|
126
|
-
return @config if defined?(@config)
|
127
|
-
|
128
|
-
if config_file.exist?
|
129
|
-
@config = base_config
|
130
|
-
@config = parent.deep_merge(base_config) if parent
|
131
|
-
end
|
132
|
-
|
133
|
-
@config ||= {}
|
134
|
-
end
|
135
|
-
|
136
|
-
private
|
137
|
-
|
138
|
-
def parent
|
139
|
-
return @parent if defined?(@parent)
|
140
|
-
|
141
|
-
inherit_from = base_config.delete(:inherit_from)
|
142
|
-
return @parent = nil unless inherit_from
|
143
|
-
|
144
|
-
@parent = Config.new(full_path.join(inherit_from)).config
|
145
|
-
@parent[:cdn]&.delete(:packages)
|
146
|
-
@parent
|
147
|
-
end
|
148
|
-
|
149
|
-
def base_config
|
150
|
-
@base_config ||= YAML.load_file(config_file).deep_symbolize_keys
|
151
|
-
end
|
152
|
-
|
153
|
-
def config_file
|
154
|
-
@config_file ||= full_path.join(CONFIG_NAME)
|
155
|
-
end
|
117
|
+
@conf ||= Provider.new(full_path).config
|
156
118
|
end
|
157
119
|
end
|
158
120
|
end
|
data/lib/afterlife/version.rb
CHANGED
data/lib/afterlife.rb
CHANGED
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.
|
4
|
+
version: 1.2.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: 2023-11-
|
11
|
+
date: 2023-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -122,8 +122,11 @@ files:
|
|
122
122
|
- lib/afterlife/cdn/server.rb
|
123
123
|
- lib/afterlife/cli.rb
|
124
124
|
- lib/afterlife/config.rb
|
125
|
+
- lib/afterlife/config/cli.rb
|
126
|
+
- lib/afterlife/config/provider.rb
|
125
127
|
- lib/afterlife/deploy.rb
|
126
128
|
- lib/afterlife/deploy/cdn_deployment.rb
|
129
|
+
- lib/afterlife/deploy/cdn_stenciljs_deployment.rb
|
127
130
|
- lib/afterlife/deploy/cli.rb
|
128
131
|
- lib/afterlife/deploy/custom_deployment.rb
|
129
132
|
- lib/afterlife/deploy/deployment.rb
|
@@ -136,6 +139,8 @@ files:
|
|
136
139
|
- lib/afterlife/release/helper.rb
|
137
140
|
- lib/afterlife/release/pre_helper.rb
|
138
141
|
- lib/afterlife/repo.rb
|
142
|
+
- lib/afterlife/repo/config.rb
|
143
|
+
- lib/afterlife/repo/provider.rb
|
139
144
|
- lib/afterlife/stage.rb
|
140
145
|
- lib/afterlife/version.rb
|
141
146
|
- logs/.keep
|