baltix 0.1.1 → 0.2
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/Gemfile +4 -2
- data/README.md +136 -10
- data/Rakefile +8 -3
- data/baltix.gemspec +47 -29
- data/bin/console +4 -3
- data/data/alt-licenses/README.md +26 -0
- data/data/alt-licenses/licenses.json +2991 -0
- data/data/alt-rpm/README.md +21 -0
- data/data/alt-rpm/architectures.json +613 -0
- data/data/spdx/README.md +22 -0
- data/data/spdx/licenses.json +9287 -0
- data/docs/action-flow.md +42 -0
- data/docs/actor-integration.md +71 -0
- data/docs/alt-architectures.md +27 -0
- data/docs/cleanup-actors.md +14 -0
- data/docs/dependency-actions.md +22 -0
- data/docs/installation-actors.md +35 -0
- data/docs/pkglist.md +56 -0
- data/docs/plans/revision-003.md +328 -0
- data/docs/plans/revision-004.md +416 -0
- data/docs/plans/revision-005.md +431 -0
- data/docs/plans/revision-006.md +439 -0
- data/docs/plans/revision-007.md +441 -0
- data/docs/plans/revision-008.md +445 -0
- data/docs/plans/revision-009.md +450 -0
- data/docs/plans/revision-010.md +486 -0
- data/docs/plans/revision-011.md +500 -0
- data/docs/plans/revision-012.md +501 -0
- data/docs/plans/revision-013.md +501 -0
- data/docs/plans/revision-014.md +501 -0
- data/docs/plans/revision-015.md +502 -0
- data/docs/plans/revision-016.md +503 -0
- data/docs/plans/revision-017.md +504 -0
- data/docs/plans/revision-018.md +505 -0
- data/docs/plans/revision-019.md +510 -0
- data/docs/plans/revision-020.md +524 -0
- data/docs/plans/revision-021.md +542 -0
- data/docs/plans/revision-022.md +542 -0
- data/docs/plans/revision-023.md +545 -0
- data/docs/plans/revision-024.md +567 -0
- data/docs/plans/revision-025.md +583 -0
- data/docs/plans/revision-026.md +241 -0
- data/docs/plans/revision-027.md +305 -0
- data/docs/plans/revision-028.md +298 -0
- data/docs/plans/revision-029.md +288 -0
- data/docs/rpm-action-macros.md +52 -0
- data/docs/rpm-parts.md +53 -0
- data/docs/ruby-dependencies.md +217 -0
- data/docs/ruby-policy-2.1.md +28 -0
- data/docs/ruby-versioning.md +61 -0
- data/docs/space-format.md +58 -0
- data/exe/baltix +1 -0
- data/lib/baltix/action_flow/files.rb +49 -0
- data/lib/baltix/action_flow/inputs.rb +60 -0
- data/lib/baltix/action_flow/journal.rb +60 -0
- data/lib/baltix/action_flow/options.rb +60 -0
- data/lib/baltix/action_flow.rb +65 -0
- data/lib/baltix/actor/build/collect.rb +72 -0
- data/lib/baltix/actor/build/compile.rb +25 -0
- data/lib/baltix/actor/build/extconf.rb +14 -0
- data/lib/baltix/actor/build/make.rb +18 -0
- data/lib/baltix/actor/build/postprocess.rb +14 -0
- data/lib/baltix/actor/build/rake.rb +18 -0
- data/lib/baltix/actor/build/ronn.rb +55 -0
- data/lib/baltix/actor/build.rb +87 -0
- data/lib/baltix/actor/clean/remove.rb +45 -0
- data/lib/baltix/actor/clean.rb +37 -0
- data/lib/baltix/actor/config.rb +12 -0
- data/lib/baltix/actor/copy.rb +22 -7
- data/lib/baltix/actor/distclean.rb +20 -0
- data/lib/baltix/actor/doc/collect.rb +39 -0
- data/lib/baltix/actor/doc/generate.rb +47 -0
- data/lib/baltix/actor/doc/inputs.rb +25 -0
- data/lib/baltix/actor/doc.rb +70 -0
- data/lib/baltix/actor/gen.rb +19 -0
- data/lib/baltix/actor/install/data.rb +18 -0
- data/lib/baltix/actor/install/documentation.rb +48 -0
- data/lib/baltix/actor/install/executable.rb +27 -0
- data/lib/baltix/actor/install/extension.rb +44 -0
- data/lib/baltix/actor/install/headers.rb +10 -0
- data/lib/baltix/actor/install/library.rb +13 -0
- data/lib/baltix/actor/install/metadata.rb +21 -0
- data/lib/baltix/actor/install/paths.rb +73 -0
- data/lib/baltix/actor/install/plugin.rb +25 -0
- data/lib/baltix/actor/install/record.rb +48 -0
- data/lib/baltix/actor/install/shebang.rb +29 -0
- data/lib/baltix/actor/install/transfer.rb +64 -0
- data/lib/baltix/actor/install/trees.rb +34 -0
- data/lib/baltix/actor/install.rb +71 -0
- data/lib/baltix/actor/link.rb +15 -6
- data/lib/baltix/actor/make.rb +14 -0
- data/lib/baltix/actor/predeps/write.rb +51 -0
- data/lib/baltix/actor/predeps.rb +41 -0
- data/lib/baltix/actor/provides.rb +12 -0
- data/lib/baltix/actor/requires.rb +12 -0
- data/lib/baltix/actor/show.rb +26 -0
- data/lib/baltix/actor/spec.rb +6 -3
- data/lib/baltix/actor/test/record.rb +8 -0
- data/lib/baltix/actor/test/run.rb +30 -0
- data/lib/baltix/actor/test/select.rb +16 -0
- data/lib/baltix/actor/test.rb +41 -0
- data/lib/baltix/actor/touch.rb +14 -5
- data/lib/baltix/actor.rb +43 -26
- data/lib/baltix/cli/dependency_options.rb +63 -0
- data/lib/baltix/cli/options/action.rb +32 -0
- data/lib/baltix/cli/options.rb +280 -0
- data/lib/baltix/cli/output_options.rb +56 -0
- data/lib/baltix/cli/rake_tasks.rb +59 -0
- data/lib/baltix/cli/source_options.rb +52 -0
- data/lib/baltix/cli.rb +130 -116
- data/lib/baltix/concerns/command.rb +52 -0
- data/lib/baltix/concerns/configuration.rb +39 -0
- data/lib/baltix/concerns/dependency_output.rb +21 -0
- data/lib/baltix/concerns/extension_metadata.rb +44 -0
- data/lib/baltix/concerns/file_destination.rb +14 -0
- data/lib/baltix/concerns/inspection.rb +27 -0
- data/lib/baltix/concerns/parts.rb +16 -0
- data/lib/baltix/concerns/target_paths.rb +57 -0
- data/lib/baltix/concerns.rb +11 -0
- data/lib/baltix/core_extensions/gem_dependency.rb +24 -0
- data/lib/baltix/core_extensions/gem_requirement.rb +45 -0
- data/lib/baltix/core_extensions/open_struct_merge.rb +62 -0
- data/lib/baltix/deps/executables.rb +30 -0
- data/lib/baltix/deps/packages.rb +32 -0
- data/lib/baltix/deps.rb +103 -194
- data/lib/baltix/dsl/dependency_groups.rb +77 -0
- data/lib/baltix/dsl/dependency_sources.rb +100 -0
- data/lib/baltix/dsl/filtering.rb +26 -0
- data/lib/baltix/dsl/loading.rb +72 -0
- data/lib/baltix/dsl/merging.rb +74 -0
- data/lib/baltix/dsl/rendering.rb +54 -0
- data/lib/baltix/dsl/requirements.rb +77 -0
- data/lib/baltix/dsl/temporary_files.rb +36 -0
- data/lib/baltix/dsl.rb +66 -273
- data/lib/baltix/executable_dependencies/features.rb +53 -0
- data/lib/baltix/executable_dependencies/library.rb +21 -0
- data/lib/baltix/executable_dependencies/library_features.rb +34 -0
- data/lib/baltix/executable_dependencies/syntax.rb +102 -0
- data/lib/baltix/executable_dependencies.rb +102 -0
- data/lib/baltix/extensions/bones.rb +173 -0
- data/lib/baltix/extensions/echoe.rb +143 -0
- data/lib/baltix/extensions/hoe/metadata.rb +89 -0
- data/lib/baltix/extensions/hoe/options.rb +84 -0
- data/lib/baltix/extensions/hoe/readme.rb +29 -0
- data/lib/baltix/extensions/hoe.rb +146 -0
- data/lib/baltix/extensions/jeweler.rb +95 -0
- data/lib/baltix/extensions/levitate.rb +74 -0
- data/lib/baltix/extensions/olddoc.rb +42 -0
- data/lib/baltix/extensions.rb +340 -419
- data/lib/baltix/i18n.rb +22 -19
- data/lib/baltix/license/catalog/capture.rb +58 -0
- data/lib/baltix/license/catalog.rb +75 -0
- data/lib/baltix/license.rb +76 -0
- data/lib/baltix/loader/capture.rb +91 -0
- data/lib/baltix/loader/cmake.rb +6 -3
- data/lib/baltix/loader/evaluation.rb +49 -0
- data/lib/baltix/loader/extconf.rb +27 -0
- data/lib/baltix/loader/feature_loading.rb +54 -0
- data/lib/baltix/loader/git-version-gen.rb +36 -21
- data/lib/baltix/loader/mast/properties.rb +58 -0
- data/lib/baltix/loader/mast.rb +97 -109
- data/lib/baltix/loader/object_capture.rb +27 -0
- data/lib/baltix/loader/olddoc.gemspec.erb +31 -0
- data/lib/baltix/loader/pom.rb +36 -16
- data/lib/baltix/loader/rookbook.rb +19 -14
- data/lib/baltix/loader/yaml.rb +9 -5
- data/lib/baltix/loader.rb +85 -132
- data/lib/baltix/log.rb +26 -27
- data/lib/baltix/rake/metadata_adapter.rb +30 -0
- data/lib/baltix/rake/task_context.rb +59 -0
- data/lib/baltix/rake/task_libraries.rb +73 -0
- data/lib/baltix/rake.rb +62 -12
- data/lib/baltix/source/base/dependencies.rb +81 -0
- data/lib/baltix/source/base/file_queries.rb +67 -0
- data/lib/baltix/source/base/file_tree.rb +70 -0
- data/lib/baltix/source/base/metadata.rb +140 -0
- data/lib/baltix/source/base/options.rb +71 -0
- data/lib/baltix/source/base/roots.rb +53 -0
- data/lib/baltix/source/base.rb +95 -377
- data/lib/baltix/source/fake.rb +89 -5
- data/lib/baltix/source/gem/delegation.rb +32 -0
- data/lib/baltix/source/gem/dependencies.rb +69 -0
- data/lib/baltix/source/gem/discovery.rb +72 -0
- data/lib/baltix/source/gem/file_trees.rb +114 -0
- data/lib/baltix/source/gem/forwarding.rb +12 -0
- data/lib/baltix/source/gem/metadata.rb +104 -0
- data/lib/baltix/source/gem/specification.rb +65 -0
- data/lib/baltix/source/gem.rb +65 -312
- data/lib/baltix/source/gemfile.rb +55 -5
- data/lib/baltix/source/rakefile.rb +12 -5
- data/lib/baltix/source.rb +36 -24
- data/lib/baltix/space/configuration.rb +54 -0
- data/lib/baltix/space/data/collections.rb +33 -0
- data/lib/baltix/space/data/gem_metadata.rb +79 -0
- data/lib/baltix/space/data/models.rb +20 -0
- data/lib/baltix/space/data/values.rb +72 -0
- data/lib/baltix/space/data.rb +53 -0
- data/lib/baltix/space/dependencies.rb +53 -0
- data/lib/baltix/space/filters.rb +96 -0
- data/lib/baltix/space/initialization.rb +124 -0
- data/lib/baltix/space/metadata.rb +130 -0
- data/lib/baltix/space/source_order.rb +43 -0
- data/lib/baltix/space/source_selection.rb +136 -0
- data/lib/baltix/space/source_status.rb +114 -0
- data/lib/baltix/space/spec.rb +3 -0
- data/lib/baltix/space.rb +87 -367
- data/lib/baltix/spec/rpm/aliases.rb +79 -0
- data/lib/baltix/spec/rpm/arch.rb +119 -0
- data/lib/baltix/spec/rpm/available_overrides.rb +106 -0
- data/lib/baltix/spec/rpm/build_dependencies.rb +132 -0
- data/lib/baltix/spec/rpm/build_queries.rb +61 -0
- data/lib/baltix/spec/rpm/changelog.rb +115 -0
- data/lib/baltix/spec/rpm/dependency_overrides.rb +83 -0
- data/lib/baltix/spec/rpm/dependency_policy.rb +69 -0
- data/lib/baltix/spec/rpm/deps.rb +113 -0
- data/lib/baltix/spec/rpm/env/requirements.rb +20 -0
- data/lib/baltix/spec/rpm/env.rb +76 -0
- data/lib/baltix/spec/rpm/executable_packages.rb +49 -0
- data/lib/baltix/spec/rpm/file_manifest.rb +72 -0
- data/lib/baltix/spec/rpm/guard_compilation.rb +95 -0
- data/lib/baltix/spec/rpm/imported_secondaries.rb +26 -0
- data/lib/baltix/spec/rpm/layout.rb +14 -0
- data/lib/baltix/spec/rpm/manpages.rb +71 -0
- data/lib/baltix/spec/rpm/metadata.rb +78 -0
- data/lib/baltix/spec/rpm/name/equality.rb +68 -0
- data/lib/baltix/spec/rpm/name/formatting.rb +33 -0
- data/lib/baltix/spec/rpm/name/parsing.rb +58 -0
- data/lib/baltix/spec/rpm/name.rb +77 -108
- data/lib/baltix/spec/rpm/packaged_versions.rb +107 -0
- data/lib/baltix/spec/rpm/parser/comments.rb +35 -0
- data/lib/baltix/spec/rpm/parser/context.rb +50 -0
- data/lib/baltix/spec/rpm/parser/dependencies.rb +91 -0
- data/lib/baltix/spec/rpm/parser/file_sections.rb +68 -0
- data/lib/baltix/spec/rpm/parser/flow.rb +84 -0
- data/lib/baltix/spec/rpm/parser/header_dependencies.rb +36 -0
- data/lib/baltix/spec/rpm/parser/macros.rb +43 -0
- data/lib/baltix/spec/rpm/parser/metadata.rb +106 -0
- data/lib/baltix/spec/rpm/parser/sections.rb +88 -0
- data/lib/baltix/spec/rpm/parser/values.rb +85 -0
- data/lib/baltix/spec/rpm/parser.rb +124 -269
- data/lib/baltix/spec/rpm/part_files.rb +64 -0
- data/lib/baltix/spec/rpm/part_prelude.rb +43 -0
- data/lib/baltix/spec/rpm/part_scripts.rb +52 -0
- data/lib/baltix/spec/rpm/part_switches.rb +65 -0
- data/lib/baltix/spec/rpm/pkglist/header.rb +73 -0
- data/lib/baltix/spec/rpm/pkglist/provides.rb +57 -0
- data/lib/baltix/spec/rpm/pkglist.rb +116 -0
- data/lib/baltix/spec/rpm/preparation.rb +73 -0
- data/lib/baltix/spec/rpm/rendering.rb +66 -0
- data/lib/baltix/spec/rpm/repository_application.rb +33 -0
- data/lib/baltix/spec/rpm/revision.rb +58 -0
- data/lib/baltix/spec/rpm/root_source.rb +48 -0
- data/lib/baltix/spec/rpm/scripts.rb +85 -0
- data/lib/baltix/spec/rpm/secondaries.rb +82 -0
- data/lib/baltix/spec/rpm/secondary.rb +117 -64
- data/lib/baltix/spec/rpm/secondary_parts.rb +84 -0
- data/lib/baltix/spec/rpm/section_document.rb +84 -0
- data/lib/baltix/spec/rpm/section_guards.rb +116 -0
- data/lib/baltix/spec/rpm/source_selection.rb +82 -0
- data/lib/baltix/spec/rpm/spec_core/architecture.rb +28 -0
- data/lib/baltix/spec/rpm/spec_core/attributes.rb +89 -0
- data/lib/baltix/spec/rpm/spec_core/availability.rb +60 -0
- data/lib/baltix/spec/rpm/spec_core/dependency_rendering.rb +83 -0
- data/lib/baltix/spec/rpm/spec_core/descriptions.rb +77 -0
- data/lib/baltix/spec/rpm/spec_core/documentation.rb +48 -0
- data/lib/baltix/spec/rpm/spec_core/executable_names.rb +37 -0
- data/lib/baltix/spec/rpm/spec_core/host_names.rb +60 -0
- data/lib/baltix/spec/rpm/spec_core/interpreters.rb +103 -0
- data/lib/baltix/spec/rpm/spec_core/names.rb +80 -0
- data/lib/baltix/spec/rpm/spec_core/obsoletes.rb +38 -0
- data/lib/baltix/spec/rpm/spec_core/package_dependencies.rb +74 -0
- data/lib/baltix/spec/rpm/spec_core/plain_dependencies.rb +60 -0
- data/lib/baltix/spec/rpm/spec_core/pre_name.rb +23 -0
- data/lib/baltix/spec/rpm/spec_core/provides.rb +104 -0
- data/lib/baltix/spec/rpm/spec_core/readme.rb +78 -0
- data/lib/baltix/spec/rpm/spec_core/registration.rb +18 -0
- data/lib/baltix/spec/rpm/spec_core/runtime_dependencies.rb +81 -0
- data/lib/baltix/spec/rpm/spec_core/summaries.rb +64 -0
- data/lib/baltix/spec/rpm/spec_core/text_wrapping.rb +36 -0
- data/lib/baltix/spec/rpm/spec_core/versioning.rb +75 -0
- data/lib/baltix/spec/rpm/spec_core/versions.rb +94 -0
- data/lib/baltix/spec/rpm/spec_core.rb +75 -527
- data/lib/baltix/spec/{rpm.erb → rpm/template.erb} +131 -31
- data/lib/baltix/spec/rpm.rb +253 -644
- data/lib/baltix/spec.rb +16 -14
- data/lib/baltix/target/gem.rb +61 -0
- data/lib/baltix/target/site.rb +40 -0
- data/lib/baltix/target.rb +16 -0
- data/lib/baltix/version.rb +3 -1
- data/lib/baltix.rb +77 -5
- data/locale/en_US.UTF-8.yaml +4 -1
- data/locale/ru_RU.UTF-8.yaml +7 -1
- data/rpm/baltix.env +4 -0
- data/rpm/baltix.prov +8 -0
- data/rpm/baltix.prov.files +6 -0
- data/rpm/baltix.req +8 -0
- data/rpm/baltix.req.files +6 -0
- data/rpm/macros.baltix +24 -0
- data/utils/rubocop/compact_block_braces.rb +39 -0
- data/utils/rubocop/spacing.rb +96 -0
- data/utils/update_alt_architectures.rb +57 -0
- data/utils/update_alt_licenses.rb +19 -0
- data/utils/update_spdx_licenses.rb +21 -0
- metadata +526 -17
- data/.github/workflows/ci.yml +0 -44
- data/.gitignore +0 -10
- data/TODO +0 -84
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Applies explicit skip, replace and append settings to original dependency declarations.
|
|
4
|
+
class Baltix::DSL
|
|
5
|
+
protected
|
|
6
|
+
|
|
7
|
+
def deps_but dependencies
|
|
8
|
+
dependencies.filter_map do |dependency|
|
|
9
|
+
next if skip_list.include?(dependency.name)
|
|
10
|
+
|
|
11
|
+
requirement = replacement_requirement(dependency)
|
|
12
|
+
|
|
13
|
+
requirement ? replace_dependency_requirement(dependency, requirement) : dependency
|
|
14
|
+
end | append_list
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def replacement_requirement dependency
|
|
18
|
+
replace_list.reduce(nil) {|result, (name, requirement)| result || name == dependency.name && requirement }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def replace_dependency_requirement dependency, requirement
|
|
22
|
+
dependency.dup.tap do |replacement|
|
|
23
|
+
replacement.instance_variable_set(:@requirement, Gem::Requirement.new([requirement]))
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Loads source Gemfiles and their Bundler DSL while preserving original source locations.
|
|
4
|
+
class Baltix::DSL
|
|
5
|
+
def gemfiles
|
|
6
|
+
return @gemfiles if @gemfiles
|
|
7
|
+
|
|
8
|
+
gemfiles = dsl.instance_variable_get(:@gemfiles) || []
|
|
9
|
+
|
|
10
|
+
@gemfiles = gemfiles.map {|g| g.is_a?(Pathname) && g || Pathname.new(g) }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def gemfile
|
|
14
|
+
gemfiles.first || original_gemfile || fake_gemfile_path
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def original_gemfile
|
|
18
|
+
@original_gemfile ||= is_source_gemfile && Pathname.new(source_file) || find_gemfile
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def find_gemfile
|
|
22
|
+
gemfile = source_file && Dir[File.join(File.dirname(source_file), '{Gemfile,gemfile}')].first
|
|
23
|
+
|
|
24
|
+
gemfile && Pathname.new(gemfile) || nil
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def source_file_dsl
|
|
28
|
+
dsl =
|
|
29
|
+
Dir.chdir(File.dirname(source_file)) do
|
|
30
|
+
dsl = Bundler::Dsl.new
|
|
31
|
+
|
|
32
|
+
dsl.eval_gemfile(original_gemfile)
|
|
33
|
+
dsl
|
|
34
|
+
end
|
|
35
|
+
rescue StandardError, ScriptError, SystemExit => error
|
|
36
|
+
unless DSL_CONT_EXCEPTIONS.find {|ec| ec == error.class.to_s }
|
|
37
|
+
debug("dsl error: #{error.class} #{error.message}")
|
|
38
|
+
|
|
39
|
+
raise(error)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def dsl
|
|
44
|
+
@dsl ||= source_file_dsl || default_dsl
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def edsl
|
|
48
|
+
@edsl ||=
|
|
49
|
+
begin
|
|
50
|
+
edsl = dsl.dup
|
|
51
|
+
edsl.dependencies = deps_but(self.class.merge_dependencies(dsl.dependencies,
|
|
52
|
+
additional_dependencies))
|
|
53
|
+
|
|
54
|
+
edsl
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def definition
|
|
59
|
+
@definition ||=
|
|
60
|
+
Dir.mktmpdir do |directory|
|
|
61
|
+
lockfile = File.join(directory, 'Gemfile.lock')
|
|
62
|
+
|
|
63
|
+
FileUtils.touch(lockfile)
|
|
64
|
+
|
|
65
|
+
edsl.to_definition(lockfile, {})
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def valid?
|
|
70
|
+
gemfiles.any? {|g| g.eql?(original_gemfile) }
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Merges source constraints without dropping their dependency groups.
|
|
4
|
+
class Baltix::DSL
|
|
5
|
+
# Checks a dependency's actual groups against requested package kinds.
|
|
6
|
+
# @param dep [Bundler::Dependency] the dependency whose groups are classified
|
|
7
|
+
# @param kinds_in [Array<Symbol, Array<Symbol>>] runtime, development or other kinds
|
|
8
|
+
# @return [Boolean] whether any group maps to a requested kind
|
|
9
|
+
# Custom groups use GROUP_MAPPING's default development/test kinds.
|
|
10
|
+
def self.match_kind_dep dep, *kinds_in
|
|
11
|
+
kinds = kinds_in.flatten
|
|
12
|
+
|
|
13
|
+
dep.groups.any? {|group| (GROUP_MAPPING[group] & kinds).any? }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.defined_groups_for *kinds_in
|
|
17
|
+
groups =
|
|
18
|
+
kinds_in.flatten.map! do |kind|
|
|
19
|
+
GROUP_MAPPING.filter_map do |group, mapped|
|
|
20
|
+
[mapped].flatten.include?(kind) && group || nil
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
groups.flatten!
|
|
25
|
+
|
|
26
|
+
groups.grep(Symbol)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.retype type_in
|
|
30
|
+
if %i[development runtime].include?(type_in)
|
|
31
|
+
type_in
|
|
32
|
+
else
|
|
33
|
+
:development
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Excludes declarations explicitly disabled by the platform policy before merging.
|
|
38
|
+
# @param dependency [Gem::Dependency, Bundler::Dependency] declaration to check
|
|
39
|
+
# @return [Boolean] whether an unrestricted or supported-platform declaration is usable
|
|
40
|
+
# Missing platform metadata is unrestricted. If platforms are declared, at
|
|
41
|
+
# least one must not be disabled in PLATFORMS. Other declarations, including
|
|
42
|
+
# MRI-specific platforms, remain available; no second platform list is created.
|
|
43
|
+
def self.platform_allowed? dependency
|
|
44
|
+
platforms = dependency.respond_to?(:platforms) ? Array(dependency.platforms) : []
|
|
45
|
+
|
|
46
|
+
platforms.empty? || platforms.any? {|platform| PLATFORMS.fetch(platform.to_sym, true) }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.merge_dependencies *lists
|
|
50
|
+
lists.reduce({}) {|result, dependencies| merge_dependency_list(result, dependencies) }.values
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.merge_dependency_list previous, dependencies
|
|
54
|
+
return previous if dependencies.nil?
|
|
55
|
+
|
|
56
|
+
dependencies.reduce(previous.dup) do |result, dependency|
|
|
57
|
+
existing = result[dependency.name]
|
|
58
|
+
result[dependency.name] = existing ? merge_dependency(existing, dependency) : dependency
|
|
59
|
+
|
|
60
|
+
result
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def self.merge_dependency existing, incoming
|
|
65
|
+
requirement = existing.requirement.merge(incoming.requirement)
|
|
66
|
+
groups = (incoming.groups || []) | (existing.groups || [])
|
|
67
|
+
|
|
68
|
+
Bundler::Dependency.new(incoming.name, requirement, 'type' => retype(existing.type), 'group' => groups)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def self.filter_dependencies type, *depses
|
|
72
|
+
depses.map {|deps| deps.select {|x| x.type == type }}
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Renders retained dependency declarations as Ruby gemspec and Gemfile source.
|
|
4
|
+
class Baltix::DSL
|
|
5
|
+
def to_ruby
|
|
6
|
+
spec = self.spec.dup
|
|
7
|
+
deps_in = deps_but(extracted_gemspec_deps)
|
|
8
|
+
deps = spec.dependencies.filter_map {|x| deps_in.find {|a| a.name == x.name }}
|
|
9
|
+
|
|
10
|
+
spec.dependencies.replace(deps)
|
|
11
|
+
|
|
12
|
+
spec.to_ruby
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_gemfile
|
|
16
|
+
render_gemfile(deps_but(original_deps))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def to_installed_gemfile
|
|
20
|
+
render_gemfile(deps_but(all_dependencies))
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def render_gemfile dependencies
|
|
24
|
+
dependencies.group_by(&:name).map do |name, dependencies|
|
|
25
|
+
gemfile_declaration(name, dependencies)
|
|
26
|
+
end.join("\n")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def gemfile_declaration name, dependencies
|
|
30
|
+
requirements = dependencies.map {|dependency| gemfile_requirements(dependency) }.join(', ')
|
|
31
|
+
dependency = dependencies.first
|
|
32
|
+
|
|
33
|
+
["gem '#{name}'", requirements, gemfile_autorequire(dependency), gemfile_groups(dependency)].compact.join(', ')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def gemfile_requirements dependency
|
|
37
|
+
dependency.requirement.requirements.map {|operator, version| "'#{operator} #{version}'" }.join(', ')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def gemfile_autorequire dependency
|
|
41
|
+
return unless dependency.respond_to?(:autorequire) && dependency.autorequire
|
|
42
|
+
|
|
43
|
+
paths = dependency.autorequire
|
|
44
|
+
value = paths.any? ? "[#{paths.map(&:inspect).join(', ')}]" : 'false'
|
|
45
|
+
|
|
46
|
+
"require: #{value}"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def gemfile_groups dependency
|
|
50
|
+
groups = dependency.respond_to?(:groups) && dependency.groups || []
|
|
51
|
+
|
|
52
|
+
"group: %i(#{groups.join("\n")})" if (groups - [:default]).any?
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Retains the complete Ruby engine, language and RubyGems version requirements.
|
|
4
|
+
class Baltix::DSL
|
|
5
|
+
# Reads every declared version bound for a Gemfile's interpreter engine.
|
|
6
|
+
# @param dsl_ruby [Bundler::RubyVersion, Object] the Gemfile Ruby declaration
|
|
7
|
+
# @return [Gem::Requirement] the complete interpreter version requirement
|
|
8
|
+
# Bundler declarations may contain several bounds; legacy declarations already
|
|
9
|
+
# expose a requirement object and are returned unchanged.
|
|
10
|
+
def engine_version dsl_ruby
|
|
11
|
+
if dsl_ruby.is_a?(Bundler::RubyVersion)
|
|
12
|
+
Gem::Requirement.new(dsl_ruby.engine_versions)
|
|
13
|
+
else
|
|
14
|
+
dsl_ruby.engine_version
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Intersects Ruby language and engine constraints from the gemspec and Gemfile.
|
|
19
|
+
# @return [Hash<String, Gem::Requirement>] requirements keyed by interpreter name
|
|
20
|
+
# If both sources constrain Ruby, all bounds are retained by the shared merger.
|
|
21
|
+
# An alternate engine keeps its own bounds alongside the Ruby language bounds.
|
|
22
|
+
# Missing declarations contribute no additional constraints.
|
|
23
|
+
def required_rubies
|
|
24
|
+
return @required_rubies if @required_rubies
|
|
25
|
+
|
|
26
|
+
rubies = {}
|
|
27
|
+
|
|
28
|
+
rubies['ruby'] = spec.required_ruby_version if spec
|
|
29
|
+
|
|
30
|
+
declared = gemfile_rubies(dsl.instance_variable_get(:@ruby_version))
|
|
31
|
+
|
|
32
|
+
@required_rubies = rubies.merge(declared) {|_name, existing, incoming| existing.merge(incoming) }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def gemfile_rubies declared
|
|
36
|
+
return {} unless declared
|
|
37
|
+
|
|
38
|
+
result = { declared.engine.to_s => engine_version(declared) }
|
|
39
|
+
|
|
40
|
+
result['ruby'] = Gem::Requirement.new(declared.versions) if declared.is_a?(Bundler::RubyVersion)
|
|
41
|
+
|
|
42
|
+
result
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def required_rubygems
|
|
46
|
+
return @required_rubygems if @required_rubygems
|
|
47
|
+
|
|
48
|
+
rubygems = spec.required_rubygems_version if spec
|
|
49
|
+
|
|
50
|
+
dsl_rubygems = dsl.instance_variable_get(:@rubygems_version)
|
|
51
|
+
|
|
52
|
+
rubygems = rubygems ? rubygems.merge(dsl_rubygems) : dsl_rubygems if dsl_rubygems
|
|
53
|
+
|
|
54
|
+
@required_rubygems = rubygems || Gem::Requirement.new(['>= 0'])
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def ruby
|
|
58
|
+
{ type: required_ruby, version: required_ruby_version }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def rubygems
|
|
62
|
+
{ version: required_rubygems_version }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def required_rubygems_version
|
|
66
|
+
'>= 0'
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def required_ruby_version
|
|
70
|
+
@required_ruby_version ||=
|
|
71
|
+
Gem::Requirement.new(dsl.instance_variable_get(:@ruby_version)&.engine_versions || '>= 0')
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def required_ruby
|
|
75
|
+
@required_ruby ||= dsl.instance_variable_get(:@ruby_version)&.engine || 'ruby'
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Creates temporary Bundler inputs without confusing them with upstream Gemfiles.
|
|
4
|
+
class Baltix::DSL
|
|
5
|
+
def fake_gemfile_path
|
|
6
|
+
if !@fake_gemfile && @fake_gemfile ||= Tempfile.create('Gemfile')
|
|
7
|
+
@fake_gemfile_path = @fake_gemfile.path
|
|
8
|
+
|
|
9
|
+
@fake_gemfile.close
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
@fake_gemfile_path
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def fake_gemlock_path
|
|
16
|
+
if !@fake_gemlock && @fake_gemlock ||= Tempfile.create('Gemfile.lock')
|
|
17
|
+
@fake_gemlock_path = @fake_gemlock.path
|
|
18
|
+
|
|
19
|
+
@fake_gemlock.close
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
@fake_gemlock_path
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def default_dsl
|
|
26
|
+
Bundler.with_unbundled_env do
|
|
27
|
+
ENV['BUNDLE_GEMFILE'] = fake_gemfile_path
|
|
28
|
+
dsl = Bundler::Dsl.new
|
|
29
|
+
|
|
30
|
+
dsl.instance_variable_set(:@gemfiles, [Pathname.new(fake_gemfile_path)])
|
|
31
|
+
dsl.to_definition(fake_gemlock_path, {})
|
|
32
|
+
|
|
33
|
+
dsl
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|