afterlife 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/afterlife/config/provider.rb +28 -5
- data/lib/afterlife/deploy/cdn_deployment.rb +10 -10
- data/lib/afterlife/deploy/cdn_stenciljs_deployment.rb +21 -9
- data/lib/afterlife/deploy/cli.rb +1 -1
- data/lib/afterlife/deploy.rb +7 -4
- data/lib/afterlife/environment.rb +15 -1
- data/lib/afterlife/exec.rb +6 -2
- data/lib/afterlife/repo.rb +1 -1
- data/lib/afterlife/stage.rb +10 -1
- data/lib/afterlife/version.rb +1 -1
- data/lib/afterlife.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 785bb4c634a1b73338a56cb64b6119389ca07904457159b14af3a00ad48869f0
|
4
|
+
data.tar.gz: 0f24b2547eb32ab72ae1807f2c5bcb813a5cc09f9dee589f6343bbd047c32c26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ff42032daec81547cc0075ab8ed71d250b2cec8ac677383f6a9702e75124ebb27d173c085c8e5d155cfd9c0b63f49e79c3a7f35630de88424127816f3de4593
|
7
|
+
data.tar.gz: 48d016ace44ecc8f285eee917e6493766bc914adc324cc582f0e7a7c495fdc9ede0548f5c3529fb6ac296a2e529ed8b83a0208c5f9ae87e5d6d43eafad540afc
|
@@ -3,10 +3,6 @@
|
|
3
3
|
module Afterlife
|
4
4
|
module Config
|
5
5
|
class Provider
|
6
|
-
def self.file
|
7
|
-
Afterlife.local_path.join('config.yml')
|
8
|
-
end
|
9
|
-
|
10
6
|
def respond_to_missing?(sym, include_all)
|
11
7
|
config.key?(sym) || super
|
12
8
|
end
|
@@ -15,6 +11,12 @@ module Afterlife
|
|
15
11
|
config.key?(sym) ? config[sym] : super
|
16
12
|
end
|
17
13
|
|
14
|
+
def file_exist?
|
15
|
+
return @file_exist if defined?(@file_exist)
|
16
|
+
|
17
|
+
@file_exist ||= file.exist?
|
18
|
+
end
|
19
|
+
|
18
20
|
def stages
|
19
21
|
@stages ||= config.delete(:stages)&.to_h do |name, val|
|
20
22
|
[name, Stage.new(val.merge(name: name.to_s))]
|
@@ -24,7 +26,28 @@ module Afterlife
|
|
24
26
|
private
|
25
27
|
|
26
28
|
def config
|
27
|
-
@config ||=
|
29
|
+
@config ||= !file_exist? && default_config
|
30
|
+
@config ||= YAML.load_file(file).deep_symbolize_keys
|
31
|
+
end
|
32
|
+
|
33
|
+
def default_config
|
34
|
+
{
|
35
|
+
credentials: {
|
36
|
+
aws: {
|
37
|
+
profile: ENV.fetch('AWS_PROFILE', nil),
|
38
|
+
},
|
39
|
+
},
|
40
|
+
stages: {},
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def file
|
45
|
+
Pathname(
|
46
|
+
ENV.fetch(
|
47
|
+
'AFTERLIFE_CONFIG_PATH',
|
48
|
+
Afterlife.local_path.join('config.yml'),
|
49
|
+
),
|
50
|
+
)
|
28
51
|
end
|
29
52
|
end
|
30
53
|
end
|
@@ -12,12 +12,14 @@ module Afterlife
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def setup
|
15
|
-
|
16
|
-
|
15
|
+
# only use the defined AWS_PROFILE if its not already been defined
|
16
|
+
repo.env.set(
|
17
|
+
'AWS_PROFILE' => Afterlife.config&.credentials&.dig(:aws, :profile),
|
17
18
|
'AWS_BUCKET' => Afterlife.current_stage.bucket,
|
18
19
|
'AWS_REGION' => Afterlife.current_stage.region,
|
19
|
-
'S3_FULL_PATH' => s3_full_path,
|
20
20
|
)
|
21
|
+
# in nested deployments we need the current path, not the parent's
|
22
|
+
repo.env.set!('S3_FULL_PATH' => s3_full_path)
|
21
23
|
end
|
22
24
|
|
23
25
|
def initial_message
|
@@ -33,14 +35,12 @@ module Afterlife
|
|
33
35
|
|
34
36
|
def commands
|
35
37
|
[
|
36
|
-
repo_command ||
|
37
|
-
|
38
|
-
]
|
38
|
+
repo_command || upload_javascripts,
|
39
|
+
upload_revision,
|
40
|
+
]
|
39
41
|
end
|
40
42
|
|
41
|
-
def
|
42
|
-
# by default we use no-cache, if something else is needed
|
43
|
-
# do it in the deploy.command option
|
43
|
+
def upload_javascripts
|
44
44
|
<<-BASH
|
45
45
|
aws s3 sync
|
46
46
|
%<DIST_PATH>s
|
@@ -52,7 +52,7 @@ module Afterlife
|
|
52
52
|
BASH
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
55
|
+
def upload_revision
|
56
56
|
<<-BASH
|
57
57
|
echo "#{repo.current_revision}" |
|
58
58
|
aws s3 cp --content-type text/plain --cache-control 'no-cache' - #{s3_revision_path}
|
@@ -7,19 +7,31 @@ module Afterlife
|
|
7
7
|
|
8
8
|
def commands
|
9
9
|
[
|
10
|
-
|
11
|
-
|
12
|
-
revision,
|
10
|
+
repo_command || [upload_parts, upload_esm],
|
11
|
+
upload_revision,
|
13
12
|
]
|
14
13
|
end
|
15
14
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
15
|
+
def upload_parts
|
16
|
+
<<-BASH
|
17
|
+
aws s3 sync
|
18
|
+
%<DIST_PATH>s
|
19
|
+
%<S3_FULL_PATH>s
|
20
|
+
--exclude '*.ts'
|
21
|
+
--exclude '*.tsx'
|
22
|
+
--exclude '*.esm.js'
|
23
|
+
--size-only
|
24
|
+
--cache-control 'public, max-age=31540000'
|
25
|
+
BASH
|
26
|
+
end
|
19
27
|
|
20
|
-
|
21
|
-
|
22
|
-
|
28
|
+
def upload_esm
|
29
|
+
<<-BASH
|
30
|
+
aws s3 cp
|
31
|
+
--cache-control 'public, max-age=31540000'
|
32
|
+
#{repo.dist_path}/#{repo.name}.esm.js
|
33
|
+
#{s3_full_path}/#{repo.name}-#{repo.current_revision}.esm.js
|
34
|
+
BASH
|
23
35
|
end
|
24
36
|
|
25
37
|
def s3_full_path
|
data/lib/afterlife/deploy/cli.rb
CHANGED
data/lib/afterlife/deploy.rb
CHANGED
@@ -8,7 +8,7 @@ module Afterlife
|
|
8
8
|
|
9
9
|
def call(stage)
|
10
10
|
deployment = klass.new
|
11
|
-
|
11
|
+
Afterlife.current_stage = find_stage(stage)
|
12
12
|
fill_env
|
13
13
|
deployment.setup
|
14
14
|
yield deployment
|
@@ -28,16 +28,19 @@ module Afterlife
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def find_stage(stage)
|
32
|
+
return Stage.build(stage) unless Afterlife.config.file_exist?
|
33
|
+
|
32
34
|
unless Afterlife.config.stages.key?(stage.to_sym)
|
33
35
|
fail Error, "invalid stage '#{stage}'. Possible values: #{Afterlife.config.stages.keys.map(&:to_s)}"
|
34
36
|
end
|
35
37
|
|
36
|
-
Afterlife.
|
38
|
+
Afterlife.config.stages[stage.to_sym]
|
37
39
|
end
|
38
40
|
|
39
41
|
def fill_env
|
40
|
-
|
42
|
+
# in nested deployments we need the current definition, not the parent's
|
43
|
+
Afterlife.current_repo.env.set!(
|
41
44
|
'DIST_PATH' => Afterlife.current_repo.dist_path.to_s,
|
42
45
|
'CURRENT_BRANCH' => Afterlife.current_repo.current_branch,
|
43
46
|
'AFTERLIFE_STAGE' => Afterlife.current_stage.name,
|
@@ -5,7 +5,7 @@ module Afterlife
|
|
5
5
|
attr_reader :repo, :env
|
6
6
|
|
7
7
|
def self.from(repo)
|
8
|
-
env = new(repo).tap(&:call)
|
8
|
+
env = new(repo).tap(&:call)
|
9
9
|
yield env if block_given?
|
10
10
|
env
|
11
11
|
end
|
@@ -33,6 +33,20 @@ module Afterlife
|
|
33
33
|
@env_hash ||= repo.conf.dig(:deploy, :env)
|
34
34
|
end
|
35
35
|
|
36
|
+
# soft set, do not override existent ENVs
|
37
|
+
def set(arg)
|
38
|
+
arg.each do |k, v|
|
39
|
+
@env[k] ||= ENV.fetch(k, v)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# forces to be exactly dthe value
|
44
|
+
def set!(arg)
|
45
|
+
arg.each do |k, v|
|
46
|
+
@env[k] = v
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
36
50
|
private
|
37
51
|
|
38
52
|
def from_flat_envs
|
data/lib/afterlife/exec.rb
CHANGED
@@ -26,18 +26,22 @@ module Afterlife
|
|
26
26
|
def run
|
27
27
|
parsed_commands.each do |command|
|
28
28
|
Afterlife.cli.log_info(command) if Afterlife.cli.options['verbose']
|
29
|
-
system(
|
29
|
+
system(env_hash, command.squish, exception: true) unless Afterlife.cli.options['dry-run']
|
30
30
|
end
|
31
31
|
rescue RuntimeError => e
|
32
32
|
raise Error, e
|
33
33
|
end
|
34
34
|
|
35
35
|
def parsed_commands
|
36
|
-
Exec.parse(commands,
|
36
|
+
Exec.parse(commands, env_hash)
|
37
37
|
end
|
38
38
|
|
39
39
|
def repo
|
40
40
|
Afterlife.current_repo
|
41
41
|
end
|
42
|
+
|
43
|
+
def env_hash
|
44
|
+
repo.env.env
|
45
|
+
end
|
42
46
|
end
|
43
47
|
end
|
data/lib/afterlife/repo.rb
CHANGED
data/lib/afterlife/stage.rb
CHANGED
@@ -7,5 +7,14 @@ module Afterlife
|
|
7
7
|
:region,
|
8
8
|
:cdn_url,
|
9
9
|
keyword_init: true,
|
10
|
-
)
|
10
|
+
) do
|
11
|
+
def self.build(name = nil)
|
12
|
+
Stage.new(
|
13
|
+
name: ENV.fetch('AFTERLIFE_STAGE', name),
|
14
|
+
bucket: ENV.fetch('AWS_BUCKET', nil),
|
15
|
+
region: ENV.fetch('AWS_REGION'),
|
16
|
+
cdn_url: ENV.fetch('AWS_BUCKET', nil),
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
11
20
|
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.3.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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|