dapp 0.6.17 → 0.7.1
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/config/en/common.yml +2 -2
- data/config/en/net_status.yml +25 -23
- data/lib/dapp.rb +24 -16
- data/lib/dapp/artifact.rb +1 -1
- data/lib/dapp/build/stage/after_install_artifact.rb +2 -2
- data/lib/dapp/build/stage/after_setup_artifact.rb +4 -4
- data/lib/dapp/build/stage/artifact_base.rb +25 -25
- data/lib/dapp/build/stage/artifact_default.rb +16 -16
- data/lib/dapp/build/stage/base.rb +36 -31
- data/lib/dapp/build/stage/before_install.rb +8 -8
- data/lib/dapp/build/stage/before_install_artifact.rb +2 -2
- data/lib/dapp/build/stage/before_setup.rb +8 -8
- data/lib/dapp/build/stage/before_setup_artifact.rb +2 -2
- data/lib/dapp/build/stage/build_artifact.rb +10 -10
- data/lib/dapp/build/stage/docker_instructions.rb +3 -3
- data/lib/dapp/build/stage/from.rb +7 -3
- data/lib/dapp/build/stage/ga_archive.rb +2 -2
- data/lib/dapp/build/stage/ga_archive_dependencies.rb +3 -3
- data/lib/dapp/build/stage/ga_artifact_patch.rb +2 -2
- data/lib/dapp/build/stage/ga_base.rb +2 -2
- data/lib/dapp/build/stage/ga_dependencies_base.rb +2 -2
- data/lib/dapp/build/stage/ga_latest_patch.rb +3 -3
- data/lib/dapp/build/stage/import_artifact.rb +19 -19
- data/lib/dapp/build/stage/install/ga_post_install_patch.rb +2 -2
- data/lib/dapp/build/stage/install/ga_post_install_patch_dependencies.rb +2 -2
- data/lib/dapp/build/stage/install/ga_pre_install_patch.rb +2 -2
- data/lib/dapp/build/stage/install/ga_pre_install_patch_dependencies.rb +2 -2
- data/lib/dapp/build/stage/install/install.rb +9 -9
- data/lib/dapp/build/stage/mod/group.rb +2 -2
- data/lib/dapp/build/stage/mod/logging.rb +19 -19
- data/lib/dapp/build/stage/setup/chef_cookbooks.rb +4 -4
- data/lib/dapp/build/stage/setup/ga_post_setup_patch.rb +2 -2
- data/lib/dapp/build/stage/setup/ga_post_setup_patch_dependencies.rb +3 -3
- data/lib/dapp/build/stage/setup/ga_pre_setup_patch.rb +2 -2
- data/lib/dapp/build/stage/setup/ga_pre_setup_patch_dependencies.rb +2 -2
- data/lib/dapp/build/stage/setup/setup.rb +9 -9
- data/lib/dapp/builder/base.rb +4 -4
- data/lib/dapp/builder/chef.rb +65 -64
- data/lib/dapp/builder/none.rb +45 -0
- data/lib/dapp/builder/shell.rb +3 -3
- data/lib/dapp/cli.rb +9 -10
- data/lib/dapp/cli/base.rb +6 -1
- data/lib/dapp/cli/bp.rb +2 -2
- data/lib/dapp/cli/build.rb +2 -2
- data/lib/dapp/cli/cleanup.rb +2 -2
- data/lib/dapp/cli/list.rb +2 -2
- data/lib/dapp/cli/mrproper.rb +0 -4
- data/lib/dapp/cli/push.rb +3 -3
- data/lib/dapp/cli/run.rb +3 -3
- data/lib/dapp/cli/spush.rb +2 -2
- data/lib/dapp/cli/stage_image.rb +2 -2
- data/lib/dapp/cli/stages/cleanup_local.rb +3 -3
- data/lib/dapp/cli/stages/cleanup_repo.rb +3 -3
- data/lib/dapp/cli/stages/flush_local.rb +3 -3
- data/lib/dapp/cli/stages/flush_repo.rb +3 -3
- data/lib/dapp/cli/stages/pull.rb +3 -3
- data/lib/dapp/cli/stages/push.rb +3 -3
- data/lib/dapp/config/artifact_dimg.rb +18 -0
- data/lib/dapp/config/artifact_group.rb +54 -0
- data/lib/dapp/config/base.rb +19 -0
- data/lib/dapp/config/dimg.rb +23 -0
- data/lib/dapp/config/dimg/instance_methods.rb +179 -0
- data/lib/dapp/config/dimg/validation.rb +124 -0
- data/lib/dapp/config/dimg_group.rb +56 -0
- data/lib/dapp/config/dimg_group_base.rb +36 -0
- data/lib/dapp/config/dimg_group_main.rb +21 -0
- data/lib/dapp/config/directive/artifact.rb +29 -54
- data/lib/dapp/config/directive/artifact_base.rb +92 -0
- data/lib/dapp/config/directive/base.rb +22 -0
- data/lib/dapp/config/directive/chef.rb +23 -61
- data/lib/dapp/config/directive/docker/artifact.rb +3 -14
- data/lib/dapp/config/directive/docker/base.rb +3 -78
- data/lib/dapp/config/directive/docker/dimg.rb +81 -0
- data/lib/dapp/config/directive/git_artifact_local.rb +13 -0
- data/lib/dapp/config/directive/git_artifact_remote.rb +55 -0
- data/lib/dapp/config/directive/mount.rb +25 -0
- data/lib/dapp/config/directive/shell/artifact.rb +3 -24
- data/lib/dapp/config/directive/shell/dimg.rb +68 -0
- data/lib/dapp/{application.rb → dimg.rb} +12 -33
- data/lib/dapp/{application → dimg}/git_artifact.rb +3 -3
- data/lib/dapp/{application → dimg}/path.rb +9 -5
- data/lib/dapp/{application → dimg}/stages.rb +8 -8
- data/lib/dapp/{application → dimg}/tags.rb +6 -6
- data/lib/dapp/docker_registry.rb +11 -15
- data/lib/dapp/error/dimg.rb +6 -0
- data/lib/dapp/git_artifact.rb +19 -20
- data/lib/dapp/git_repo/base.rb +6 -6
- data/lib/dapp/git_repo/own.rb +4 -4
- data/lib/dapp/git_repo/remote.rb +5 -5
- data/lib/dapp/image/docker.rb +0 -15
- data/lib/dapp/image/stage.rb +12 -22
- data/lib/dapp/project.rb +14 -18
- data/lib/dapp/project/command/build.rb +2 -2
- data/lib/dapp/project/command/cleanup.rb +9 -11
- data/lib/dapp/project/command/common.rb +8 -20
- data/lib/dapp/project/command/list.rb +7 -1
- data/lib/dapp/project/command/mrproper.rb +12 -22
- data/lib/dapp/project/command/push.rb +3 -4
- data/lib/dapp/project/command/run.rb +2 -2
- data/lib/dapp/project/command/spush.rb +3 -4
- data/lib/dapp/project/command/stage_image.rb +2 -2
- data/lib/dapp/project/command/stages/cleanup_local.rb +20 -24
- data/lib/dapp/project/command/stages/cleanup_repo.rb +3 -3
- data/lib/dapp/project/command/stages/common.rb +2 -3
- data/lib/dapp/project/command/stages/flush_local.rb +5 -7
- data/lib/dapp/project/command/stages/flush_repo.rb +2 -2
- data/lib/dapp/project/command/stages/pull.rb +3 -4
- data/lib/dapp/project/command/stages/push.rb +3 -4
- data/lib/dapp/project/dappfile.rb +9 -26
- data/lib/dapp/project/logging/base.rb +14 -0
- data/lib/dapp/project/logging/process.rb +1 -1
- data/lib/dapp/project/shellout/system.rb +2 -4
- data/lib/dapp/version.rb +1 -1
- metadata +25 -17
- data/lib/dapp/cli/tag.rb +0 -24
- data/lib/dapp/config/application.rb +0 -288
- data/lib/dapp/config/artifact.rb +0 -20
- data/lib/dapp/config/directive/build_dir.rb +0 -9
- data/lib/dapp/config/directive/git_artifact.rb +0 -59
- data/lib/dapp/config/directive/shell/base.rb +0 -85
- data/lib/dapp/config/directive/tmp_dir.rb +0 -36
- data/lib/dapp/config/main.rb +0 -20
- data/lib/dapp/error/application.rb +0 -6
- data/lib/dapp/project/command/tag.rb +0 -18
@@ -7,16 +7,16 @@ module Dapp
|
|
7
7
|
module Common
|
8
8
|
protected
|
9
9
|
|
10
|
-
def project_images
|
11
|
-
shellout!(%(docker images --format="{{.Repository}}:{{.Tag}}" #{stage_cache
|
10
|
+
def project_images
|
11
|
+
shellout!(%(docker images --format="{{.Repository}}:{{.Tag}}" #{stage_cache})).stdout.strip
|
12
12
|
end
|
13
13
|
|
14
|
-
def project_containers_flush
|
15
|
-
remove_containers_by_query(%(docker ps -a -f "label=dapp" -f "name=#{
|
14
|
+
def project_containers_flush
|
15
|
+
remove_containers_by_query(%(docker ps -a -f "label=dapp" -f "name=#{container_name_prefix}" -q), force: true)
|
16
16
|
end
|
17
17
|
|
18
|
-
def project_dangling_images_flush
|
19
|
-
remove_images_by_query(%(docker images -f "dangling=true" -f "label=dapp=#{stage_dapp_label
|
18
|
+
def project_dangling_images_flush
|
19
|
+
remove_images_by_query(%(docker images -f "dangling=true" -f "label=dapp=#{stage_dapp_label}" -q), force: true)
|
20
20
|
end
|
21
21
|
|
22
22
|
def remove_images_by_query(images_query, force: false)
|
@@ -51,20 +51,8 @@ module Dapp
|
|
51
51
|
shellout!(cmd) unless dry_run?
|
52
52
|
end
|
53
53
|
|
54
|
-
def
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
def stage_dapp_label(basename)
|
59
|
-
stage_dapp_label_format % { application_name: basename }
|
60
|
-
end
|
61
|
-
|
62
|
-
def container_name(basename)
|
63
|
-
basename
|
64
|
-
end
|
65
|
-
|
66
|
-
def validate_repo_name(repo)
|
67
|
-
raise(Error::Project, code: :repo_name_incorrect, data: { name: repo }) unless DockerRegistry.repo_name?(repo)
|
54
|
+
def container_name_prefix
|
55
|
+
name
|
68
56
|
end
|
69
57
|
|
70
58
|
def proper_cache_version?
|
@@ -6,7 +6,13 @@ module Dapp
|
|
6
6
|
# List
|
7
7
|
module List
|
8
8
|
def list
|
9
|
-
build_configs.each
|
9
|
+
build_configs.each do |config|
|
10
|
+
if config._name.nil?
|
11
|
+
log_warning("Project '#{name}' with nameless dimg!")
|
12
|
+
else
|
13
|
+
puts config._name
|
14
|
+
end
|
15
|
+
end
|
10
16
|
end
|
11
17
|
end
|
12
18
|
end
|
@@ -8,13 +8,12 @@ module Dapp
|
|
8
8
|
def mrproper
|
9
9
|
log_step_with_indent(:mrproper) do
|
10
10
|
if proper_all?
|
11
|
-
|
12
|
-
|
13
|
-
flush_by_label('dapp-dev-mode')
|
11
|
+
log_step_with_indent(:containers) { dapp_containers_flush }
|
12
|
+
log_step_with_indent(:images) { dapp_images_flush }
|
14
13
|
elsif proper_cache_version?
|
15
14
|
log_proper_cache do
|
16
15
|
proper_cache_images = proper_cache_all_images
|
17
|
-
remove_images(
|
16
|
+
remove_images(dapp_images.lines.select { |id| !proper_cache_images.lines.include?(id) }.map(&:strip))
|
18
17
|
end
|
19
18
|
else
|
20
19
|
raise Error::Project, code: :mrproper_required_option
|
@@ -24,34 +23,25 @@ module Dapp
|
|
24
23
|
|
25
24
|
protected
|
26
25
|
|
27
|
-
def flush_by_label(label)
|
28
|
-
log_step_with_indent(:containers) { dapp_containers_flush_by_label(label) }
|
29
|
-
log_step_with_indent(:images) { dapp_images_flush_be_label(label) }
|
30
|
-
end
|
31
|
-
|
32
26
|
def proper_all?
|
33
27
|
!!cli_options[:proper_all]
|
34
28
|
end
|
35
29
|
|
36
|
-
def
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
def dapp_containers_flush_by_label(label)
|
41
|
-
remove_containers_by_query(%(docker ps -a -f "label=#{label}" -q), force: true)
|
30
|
+
def dapp_containers_flush
|
31
|
+
remove_containers_by_query('docker ps -a -f "label=dapp" -q', force: true)
|
42
32
|
end
|
43
33
|
|
44
|
-
def
|
45
|
-
remove_images_by_query(
|
34
|
+
def dapp_dangling_images_flush
|
35
|
+
remove_images_by_query('docker images -f "dangling=true" -f "label=dapp" -q', force: true)
|
46
36
|
end
|
47
37
|
|
48
|
-
def
|
49
|
-
|
50
|
-
remove_images(
|
38
|
+
def dapp_images_flush
|
39
|
+
dapp_dangling_images_flush
|
40
|
+
remove_images(dapp_images.lines.map(&:strip), force: true)
|
51
41
|
end
|
52
42
|
|
53
|
-
def
|
54
|
-
@dapp_images ||= shellout!(
|
43
|
+
def dapp_images
|
44
|
+
@dapp_images ||= shellout!('docker images -f "dangling=false" --format="{{.Repository}}:{{.Tag}}" -f "label=dapp"').stdout.strip
|
55
45
|
end
|
56
46
|
|
57
47
|
def proper_cache_all_images
|
@@ -6,12 +6,11 @@ module Dapp
|
|
6
6
|
# Push
|
7
7
|
module Push
|
8
8
|
def push(repo)
|
9
|
-
validate_repo_name(repo)
|
10
9
|
log_step_with_indent(:stages) { stages_push(repo) } if with_stages?
|
11
10
|
build_configs.each do |config|
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
log_dimg_name_with_indent(config) do
|
12
|
+
Dimg.new(config: config, project: self, ignore_git_fetch: true, should_be_built: true).tap do |dimg|
|
13
|
+
dimg.export!(repo, format: '%{repo}:%{dimg_name}-%{tag}')
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
@@ -6,8 +6,8 @@ module Dapp
|
|
6
6
|
# Run
|
7
7
|
module Run
|
8
8
|
def run(docker_options, command)
|
9
|
-
raise Error::Project, code: :
|
10
|
-
|
9
|
+
raise Error::Project, code: :command_unexpected_dimgs_number unless build_configs.one?
|
10
|
+
Dimg.new(config: build_configs.first, project: self, ignore_git_fetch: true, should_be_built: true).run(docker_options, command)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -6,10 +6,9 @@ module Dapp
|
|
6
6
|
# Spush
|
7
7
|
module Spush
|
8
8
|
def spush(repo)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
app.export!(repo, format: '%{repo}:%{tag}')
|
9
|
+
raise Error::Project, code: :spush_command_unexpected_dimgs_number unless build_configs.one?
|
10
|
+
Dimg.new(config: build_configs.first, project: self, ignore_git_fetch: true, should_be_built: true).tap do |dimg|
|
11
|
+
dimg.export!(repo, format: '%{repo}:%{tag}')
|
13
12
|
end
|
14
13
|
end
|
15
14
|
end
|
@@ -6,8 +6,8 @@ module Dapp
|
|
6
6
|
# StageImage
|
7
7
|
module StageImage
|
8
8
|
def stage_image
|
9
|
-
raise Error::Project, code: :
|
10
|
-
puts
|
9
|
+
raise Error::Project, code: :command_unexpected_dimgs_number unless build_configs.one?
|
10
|
+
puts Dimg.new(config: build_configs.first, project: self, ignore_git_fetch: true).stage_image_name(cli_options[:stage])
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -9,59 +9,55 @@ module Dapp
|
|
9
9
|
def stages_cleanup_local(repo)
|
10
10
|
lock_repo(repo, readonly: true) do
|
11
11
|
registry = registry(repo)
|
12
|
-
|
12
|
+
repo_dimgs = repo_dimgs_images(registry)
|
13
13
|
proper_cache if proper_cache_version?
|
14
|
-
|
15
|
-
cleanup_project(basename, repo_applications)
|
16
|
-
end
|
14
|
+
cleanup_project(repo_dimgs)
|
17
15
|
end
|
18
16
|
end
|
19
17
|
|
20
18
|
protected
|
21
19
|
|
22
|
-
def cleanup_project(
|
23
|
-
lock("#{
|
24
|
-
log_step_with_indent(
|
25
|
-
project_containers_flush
|
26
|
-
project_dangling_images_flush
|
27
|
-
|
28
|
-
|
20
|
+
def cleanup_project(repo_dimgs)
|
21
|
+
lock("#{name}.images") do
|
22
|
+
log_step_with_indent(name) do
|
23
|
+
project_containers_flush
|
24
|
+
project_dangling_images_flush
|
25
|
+
dimgs, stages = project_images_hash.partition { |_, image_id| repo_dimgs.values.include?(image_id) }
|
26
|
+
dimgs = dimgs.to_h
|
29
27
|
stages = stages.to_h
|
30
|
-
|
28
|
+
dimgs.each { |_, aiid| clear_stages(aiid, stages) }
|
31
29
|
remove_images(stages.keys)
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
35
33
|
|
36
|
-
def
|
34
|
+
def repo_dimgs_images(registry)
|
37
35
|
repo_images(registry).first
|
38
36
|
end
|
39
37
|
|
40
38
|
def proper_cache
|
41
39
|
log_proper_cache do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
remove_images(project_images(basename).lines.select { |id| !actual_cache_images.lines.include?(id) }.map(&:strip))
|
48
|
-
end
|
40
|
+
lock("#{name}.images") do
|
41
|
+
log_step_with_indent(name) do
|
42
|
+
project_containers_flush
|
43
|
+
actual_cache_images = actual_cache_images
|
44
|
+
remove_images(project_images.lines.select { |id| !actual_cache_images.lines.include?(id) }.map(&:strip))
|
49
45
|
end
|
50
46
|
end
|
51
47
|
end
|
52
48
|
end
|
53
49
|
|
54
|
-
def actual_cache_images
|
50
|
+
def actual_cache_images
|
55
51
|
shellout!([
|
56
52
|
'docker images',
|
57
53
|
'--format="{{.Repository}}:{{.Tag}}"',
|
58
54
|
%(-f "label=dapp-cache-version=#{Dapp::BUILD_CACHE_VERSION}"),
|
59
|
-
stage_cache
|
55
|
+
stage_cache
|
60
56
|
].join(' ')).stdout.strip
|
61
57
|
end
|
62
58
|
|
63
|
-
def project_images_hash
|
64
|
-
shellout!(%(docker images --format "{{.Repository}}:{{.Tag}};{{.ID}}" --no-trunc #{stage_cache
|
59
|
+
def project_images_hash
|
60
|
+
shellout!(%(docker images --format "{{.Repository}}:{{.Tag}};{{.ID}}" --no-trunc #{stage_cache})).stdout.lines.map do |line|
|
65
61
|
line.strip.split(';')
|
66
62
|
end.to_h
|
67
63
|
end
|
@@ -9,11 +9,11 @@ module Dapp
|
|
9
9
|
def stages_cleanup_repo(repo)
|
10
10
|
lock_repo(repo) do
|
11
11
|
registry = registry(repo)
|
12
|
-
|
13
|
-
repo_stages.delete_if { |_, siid|
|
12
|
+
repo_dimgs, repo_stages = repo_images(registry)
|
13
|
+
repo_stages.delete_if { |_, siid| repo_dimgs.values.include?(siid) } # ignoring stages with dimgs ids (v2)
|
14
14
|
proper_repo_cache(registry, repo_stages) if proper_cache_version?
|
15
15
|
log_step_with_indent(repo) do
|
16
|
-
|
16
|
+
repo_dimgs.each { |image_tag, image_id| clear_repo_stages(registry, repo_stages, image_tag, image_id) }
|
17
17
|
repo_stages.keys.each { |image_tag| delete_repo_image(registry, image_tag) }
|
18
18
|
end
|
19
19
|
end
|
@@ -9,7 +9,6 @@ module Dapp
|
|
9
9
|
protected
|
10
10
|
|
11
11
|
def registry(repo)
|
12
|
-
validate_repo_name(repo)
|
13
12
|
DockerRegistry.new(repo)
|
14
13
|
end
|
15
14
|
|
@@ -23,8 +22,8 @@ module Dapp
|
|
23
22
|
end
|
24
23
|
end.compact.to_h
|
25
24
|
end
|
26
|
-
|
27
|
-
[format.call(
|
25
|
+
dimgs, stages = registry.tags.partition { |tag| !tag.start_with?('dimgstage') }
|
26
|
+
[format.call(dimgs), format.call(stages)]
|
28
27
|
end
|
29
28
|
|
30
29
|
def registry_tags(registry)
|
@@ -7,13 +7,11 @@ module Dapp
|
|
7
7
|
# FlushLocal
|
8
8
|
module FlushLocal
|
9
9
|
def stages_flush_local
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
remove_images(project_images(basename).lines.map(&:strip))
|
16
|
-
end
|
10
|
+
lock("#{name}.images") do
|
11
|
+
log_step_with_indent(name) do
|
12
|
+
project_containers_flush
|
13
|
+
project_dangling_images_flush
|
14
|
+
remove_images(project_images.lines.map(&:strip))
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
@@ -10,8 +10,8 @@ module Dapp
|
|
10
10
|
lock_repo(repo) do
|
11
11
|
log_step_with_indent(repo) do
|
12
12
|
registry = registry(repo)
|
13
|
-
|
14
|
-
|
13
|
+
repo_dimgs, repo_stages = repo_images(registry)
|
14
|
+
repo_dimgs.merge(repo_stages).keys.each { |image_tag| delete_repo_image(registry, image_tag) }
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -7,11 +7,10 @@ module Dapp
|
|
7
7
|
# Pull
|
8
8
|
module Pull
|
9
9
|
def stages_pull(repo)
|
10
|
-
validate_repo_name(repo)
|
11
10
|
build_configs.each do |config|
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
log_dimg_name_with_indent(config) do
|
12
|
+
Dimg.new(config: config, project: self, ignore_git_fetch: true).tap do |dimg|
|
13
|
+
dimg.import_stages!(repo, format: '%{repo}:dimgstage-%{signature}')
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
@@ -7,11 +7,10 @@ module Dapp
|
|
7
7
|
# Push
|
8
8
|
module Push
|
9
9
|
def stages_push(repo)
|
10
|
-
validate_repo_name(repo)
|
11
10
|
build_configs.each do |config|
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
log_dimg_name_with_indent(config) do
|
12
|
+
Dimg.new(config: config, project: self, ignore_git_fetch: true, should_be_built: true).tap do |dimg|
|
13
|
+
dimg.export_stages!(repo, format: '%{repo}:dimgstage-%{signature}')
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
@@ -5,31 +5,15 @@ module Dapp
|
|
5
5
|
module Dappfile
|
6
6
|
def build_configs
|
7
7
|
@configs ||= begin
|
8
|
-
|
9
|
-
raise Error::Project, code: :
|
8
|
+
dimgs(dappfile_path).flatten.tap do |dimgs|
|
9
|
+
raise Error::Project, code: :no_such_dimg, data: { dimgs_patterns: dimgs_patterns.join(', ') } if dimgs.empty?
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
def dappfiles
|
15
|
-
if File.exist?(dappfile_path) then [dappfile_path]
|
16
|
-
elsif !dapps_dappfiles_pathes.empty? then dapps_dappfiles_pathes
|
17
|
-
elsif (dappfile_path = search_up('Dappfile')) then [dappfile_path]
|
18
|
-
else raise Error::Project, code: :dappfile_not_found
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
14
|
def dappfile_path
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
def dapps_dappfiles_pathes
|
27
|
-
path = []
|
28
|
-
path << cli_options[:dir]
|
29
|
-
path << '.dapps' unless File.basename(work_dir) == '.dapps'
|
30
|
-
path << '*'
|
31
|
-
path << 'Dappfile'
|
32
|
-
Dir.glob(File.join(path.compact))
|
15
|
+
raise Error::Project, code: :dappfile_not_found unless (dappfile_path = search_up('Dappfile'))
|
16
|
+
dappfile_path
|
33
17
|
end
|
34
18
|
|
35
19
|
def search_up(file)
|
@@ -52,19 +36,18 @@ module Dapp
|
|
52
36
|
path
|
53
37
|
end
|
54
38
|
|
55
|
-
def
|
56
|
-
|
39
|
+
def dimgs(dappfile_path)
|
40
|
+
Config::DimgGroupMain.new(project: self) do |conf|
|
57
41
|
begin
|
58
42
|
conf.instance_eval File.read(dappfile_path), dappfile_path
|
59
43
|
rescue SyntaxError, StandardError => e
|
60
44
|
backtrace = e.backtrace.find { |line| line.start_with?(dappfile_path) }
|
61
|
-
message = e.is_a?(
|
45
|
+
message = [NoMethodError, NameError].any? { |err| e.is_a?(err) } ? e.message[/.*(?= for)/] : e.message
|
62
46
|
message = "#{backtrace[/.*(?=:in)/]}: #{message}" if backtrace
|
63
47
|
raise Error::Dappfile, code: :incorrect, data: { error: e.class.name, message: message }
|
64
48
|
end
|
65
|
-
end
|
66
|
-
|
67
|
-
apps.each { |app| app.send(:validate!) }
|
49
|
+
end._dimg.select { |dimg| dimgs_patterns.any? { |pattern| dimg._name.nil? || File.fnmatch(pattern, dimg._name) } }.tap do |dimgs|
|
50
|
+
dimgs.each { |dimg| dimg.send(:validate!) }
|
68
51
|
end
|
69
52
|
end
|
70
53
|
end # Dappfile
|
@@ -17,6 +17,10 @@ module Dapp
|
|
17
17
|
cli_options[:log_verbose]
|
18
18
|
end
|
19
19
|
|
20
|
+
def ignore_config_warning?
|
21
|
+
cli_options[:ignore_config_warning]
|
22
|
+
end
|
23
|
+
|
20
24
|
def introspect_error?
|
21
25
|
cli_options[:introspect_error]
|
22
26
|
end
|
@@ -34,6 +38,11 @@ module Dapp
|
|
34
38
|
log(*args, **kwargs)
|
35
39
|
end
|
36
40
|
|
41
|
+
def log_dimg_name_with_indent(dimg, &blk)
|
42
|
+
return yield if dimg._name.nil?
|
43
|
+
log_step_with_indent(dimg._name, &blk)
|
44
|
+
end
|
45
|
+
|
37
46
|
def log_step_with_indent(step)
|
38
47
|
log_step(step)
|
39
48
|
with_log_indent do
|
@@ -58,6 +67,11 @@ module Dapp
|
|
58
67
|
log(*args, **kwargs)
|
59
68
|
end
|
60
69
|
|
70
|
+
def log_config_warning(*args, **kwargs)
|
71
|
+
return if ignore_config_warning?
|
72
|
+
log_warning(*args, **kwargs)
|
73
|
+
end
|
74
|
+
|
61
75
|
def log(message = '', desc: nil, inline: false, **kwargs)
|
62
76
|
return if log_quiet?
|
63
77
|
unless desc.nil?
|