kettle-jem 7.1.42 → 7.1.43
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
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +67 -7
- data/README.md +27 -0
- data/lib/kettle/jem/ci/harden_macos_ca_bundle.sh +75 -0
- data/lib/kettle/jem/tasks/install_task.rb +2 -2
- data/lib/kettle/jem/templates/.duel.rb.example +10 -0
- data/lib/kettle/jem/templates/.git-hooks/commit-msg.example +6 -6
- data/lib/kettle/jem/templates/.git-hooks/commit-subjects-goalie.txt.example +7 -1
- data/lib/kettle/jem/templates/.github/workflows/current.yml.example +1 -1
- data/lib/kettle/jem/templates/.github/workflows/dependency-review.yml.example +1 -1
- data/lib/kettle/jem/templates/.github/workflows/discord-notifier.yml.example +1 -1
- data/lib/kettle/jem/templates/.github/workflows/perf-comment.yml.example +92 -0
- data/lib/kettle/jem/templates/.github/workflows/perf.yml.example +152 -69
- data/lib/kettle/jem/templates/.structuredmerge/kettle-jem.yml.example +2 -2
- data/lib/kettle/jem/templates/Appraisals.example +12 -0
- data/lib/kettle/jem/templates/CONTRIBUTING.md.example +5 -1
- data/lib/kettle/jem/templates/Gemfile.example +3 -1
- data/lib/kettle/jem/templates/gem.gemspec.example +10 -6
- data/lib/kettle/jem/templates/gemfiles/modular/debug.gemfile.example +1 -1
- data/lib/kettle/jem/templates/gemfiles/modular/documentation.gemfile.example +5 -5
- data/lib/kettle/jem/templates/gemfiles/modular/duel.gemfile.example +1 -1
- data/lib/kettle/jem/templates/gemfiles/modular/optional.gemfile.example +1 -1
- data/lib/kettle/jem/templates/gemfiles/modular/ostruct/r4/v0.6.gemfile.example +1 -1
- data/lib/kettle/jem/templates/gemfiles/modular/rspec.gemfile.example +12 -4
- data/lib/kettle/jem/templates/gemfiles/modular/rspec_junit_formatter/r2/v0.6.gemfile.example +7 -0
- data/lib/kettle/jem/templates/gemfiles/modular/rspec_junit_formatter/r3/v0.8.gemfile.example +2 -0
- data/lib/kettle/jem/templates/gemfiles/modular/rspec_junit_formatter/r3.2/v0.6.gemfile.example +7 -0
- data/lib/kettle/jem/templates/gemfiles/modular/rspec_junit_formatter/r4/v0.8.gemfile.example +2 -0
- data/lib/kettle/jem/templates/gemfiles/modular/style_local.gemfile.example +1 -1
- data/lib/kettle/jem/templates/gemfiles/modular/templating.gemfile.example +2 -1
- data/lib/kettle/jem/templates/gemfiles/modular/templating_local.gemfile.example +34 -18
- data/lib/kettle/jem/templates/gemfiles/modular/x_std_libs.gemfile.example +10 -2
- data/lib/kettle/jem/templates/readme/partials/configuration.md.example +3 -0
- data/lib/kettle/jem/templates/shim/Gemfile.example +1 -1
- data/lib/kettle/jem/templates/shim/gem.gemspec.example +3 -3
- data/lib/kettle/jem/version.rb +1 -1
- data/lib/kettle/jem.rb +725 -100
- data.tar.gz.sig +3 -2
- metadata +1188 -1037
- metadata.gz.sig +0 -0
data/lib/kettle/jem.rb
CHANGED
|
@@ -57,18 +57,18 @@ module Kettle
|
|
|
57
57
|
MANAGED_BLOCK_OPEN = "# <<kettle-jem:generated>> do not edit below this line"
|
|
58
58
|
MANAGED_BLOCK_CLOSE = "# <</kettle-jem:generated>>"
|
|
59
59
|
GEMSPEC_DEPENDENCY_MINIMUM_REQUIREMENTS = {
|
|
60
|
-
"rspec-stubbed_env" => ">= 1.0.
|
|
60
|
+
"rspec-stubbed_env" => ">= 1.0.19"
|
|
61
61
|
}.freeze
|
|
62
62
|
# Template dependency transitions are location-independent. Prepare finds
|
|
63
63
|
# declarations in the destination and reconciles their complete requirement
|
|
64
64
|
# set in place before Bundler is allowed to evaluate that destination.
|
|
65
65
|
TEMPLATE_MANAGED_DEPENDENCIES = [
|
|
66
66
|
{name: PACKAGE_NAME, requirements: ["~> 7.1", ">= 7.1.28"], bootstrap: false},
|
|
67
|
-
{name: "nomono", requirements: ["~> 1.1", ">= 1.1.
|
|
68
|
-
{name: "kettle-dev", requirements: ["~> 3.1", ">= 3.1.
|
|
67
|
+
{name: "nomono", requirements: ["~> 1.1", ">= 1.1.18"], bootstrap: true},
|
|
68
|
+
{name: "kettle-dev", requirements: ["~> 3.1", ">= 3.1.31"], bootstrap: true},
|
|
69
69
|
{
|
|
70
70
|
name: "kettle-changelog",
|
|
71
|
-
requirements: ["~> 1.0", ">= 1.0.
|
|
71
|
+
requirements: ["~> 1.0", ">= 1.0.20"],
|
|
72
72
|
bootstrap: true,
|
|
73
73
|
ruby_requirement: ">= 4.0.0"
|
|
74
74
|
}
|
|
@@ -88,12 +88,32 @@ module Kettle
|
|
|
88
88
|
codeql-analysis.yml
|
|
89
89
|
tests.yml
|
|
90
90
|
].freeze
|
|
91
|
+
# Versioned engine workflows for engine releases that are end-of-life.
|
|
92
|
+
# An engine release is EOL when the CRuby it implements is EOL (JRuby 9.x
|
|
93
|
+
# implement CRuby <= 3.1; TruffleRuby 33+ is numbered by Ruby version and
|
|
94
|
+
# older GraalVM-numbered releases target CRuby <= 3.3 and are unmaintained
|
|
95
|
+
# upstream). The upstream TruffleRuby maintainers have asked projects to
|
|
96
|
+
# stop testing old releases. They are neither generated nor kept by
|
|
97
|
+
# default; the README badge becomes the static no-CI variant, so support
|
|
98
|
+
# is still declared (via the equivalent MRI job and rubocop-lts rules).
|
|
99
|
+
# Opt back in per workflow with `workflows.legacy_engines`.
|
|
100
|
+
# Explicit list, not date-derived, so templating stays deterministic.
|
|
101
|
+
EOL_ENGINE_WORKFLOWS = %w[
|
|
102
|
+
jruby-9.1
|
|
103
|
+
jruby-9.2
|
|
104
|
+
jruby-9.3
|
|
105
|
+
jruby-9.4
|
|
106
|
+
truffleruby-22.3
|
|
107
|
+
truffleruby-23.1
|
|
108
|
+
truffleruby-24.2
|
|
109
|
+
truffleruby-25.0
|
|
110
|
+
].freeze
|
|
91
111
|
OPENCOLLECTIVE_DISABLED_FILES = %w[.opencollective.yml .github/workflows/opencollective.yml].freeze
|
|
92
112
|
OPT_IN_GITHUB_WORKFLOWS = %w[.github/workflows/discord-notifier.yml].freeze
|
|
93
113
|
# Templates that exist only for projects that set `workflows.duel: true`.
|
|
94
114
|
# While Duel is off, kettle-jem neither writes nor removes these paths, so a
|
|
95
115
|
# project's own files at them stay exactly as they are.
|
|
96
|
-
DUEL_TEMPLATE_PATHS = %w[.duel.rb .github/workflows/perf.yml gemfiles/modular/duel.gemfile].freeze
|
|
116
|
+
DUEL_TEMPLATE_PATHS = %w[.duel.rb .github/workflows/perf.yml .github/workflows/perf-comment.yml gemfiles/modular/duel.gemfile].freeze
|
|
97
117
|
DUEL_MAIN_GEMFILE_EVAL_PATH = "gemfiles/modular/duel.gemfile"
|
|
98
118
|
DUEL_APPRAISAL_NAME = "perf"
|
|
99
119
|
OBSOLETE_APPRAISAL_SPEC_EXEC_CMDS = [
|
|
@@ -149,7 +169,7 @@ module Kettle
|
|
|
149
169
|
ast-template bash-merge binary-merge citrus-toml-merge commonmarker-merge dotenv-merge
|
|
150
170
|
go-merge html-merge json-merge kettle-jem kramdown-merge markdown-merge markly-merge
|
|
151
171
|
parslet-toml-merge plain-merge prism-merge psych-merge rbs-merge ruby-merge rust-merge
|
|
152
|
-
smorg-rb toml-merge tree_haver typescript-merge yaml-merge zip-merge
|
|
172
|
+
smorg-rb structuredmerge-core toml-merge tree_haver typescript-merge yaml-merge zip-merge
|
|
153
173
|
].freeze
|
|
154
174
|
# Canonical resolutions for development-dependency gems whose handling is
|
|
155
175
|
# already known ahead of any specific destination project. Two
|
|
@@ -289,6 +309,7 @@ module Kettle
|
|
|
289
309
|
MONOREPO_SUBGEM_TEMPLATE_ENTRIES + [
|
|
290
310
|
"Gemfile",
|
|
291
311
|
"Rakefile",
|
|
312
|
+
".gitignore",
|
|
292
313
|
".rspec",
|
|
293
314
|
".simplecov",
|
|
294
315
|
".yard-lint.yml",
|
|
@@ -618,6 +639,7 @@ module Kettle
|
|
|
618
639
|
COPYRIGHT_NAME_RE = /\ACopyright \(c\) [\d,\s-]+ (.+)\z/
|
|
619
640
|
BOT_IDENTITY_PATTERN = /\[bot\]/i
|
|
620
641
|
DEFAULT_MACHINE_USERS = ["autobolt", "StepSecurity Bot", "dependabot[bot]", "depfu[bot]"].freeze
|
|
642
|
+
DEFAULT_AUTHOR_ALIASES = {"erik michaels-ober" => "Erik Berlin"}.freeze
|
|
621
643
|
NOT_COMMITTED_EMAIL = "not.committed.yet"
|
|
622
644
|
LOGOS_GALTZO_BASE_URL = "https://logos.galtzo.com/assets/images"
|
|
623
645
|
README_TOP_LOGO_DEFAULTS = %w[org project].freeze
|
|
@@ -982,17 +1004,36 @@ module Kettle
|
|
|
982
1004
|
workflow_references(content).each do |label, workflow_path|
|
|
983
1005
|
next if existing.include?(workflow_path)
|
|
984
1006
|
|
|
985
|
-
content =
|
|
1007
|
+
content = if EOL_ENGINE_WORKFLOWS.include?(File.basename(workflow_path, ".yml"))
|
|
1008
|
+
no_ci_badge(content, label)
|
|
1009
|
+
else
|
|
1010
|
+
remove_workflow_badge_occurrences(content, label)
|
|
1011
|
+
end
|
|
986
1012
|
end
|
|
987
1013
|
|
|
988
1014
|
content
|
|
989
1015
|
end
|
|
990
1016
|
|
|
1017
|
+
# Declares support without CI: drop the workflow link from the badge and
|
|
1018
|
+
# mark its image "(🚫CI)" in neutral grey, like Ruby 2.0-2.3.
|
|
1019
|
+
def no_ci_badge(content, workflow_label)
|
|
1020
|
+
match = workflow_label.match(/\A🚎(truby|jruby)-(\d+\.\d+)-wf\z/)
|
|
1021
|
+
return remove_workflow_badge_occurrences(content, workflow_label) unless match
|
|
1022
|
+
|
|
1023
|
+
image_label = "💎#{match[1]}-#{match[2]}i"
|
|
1024
|
+
processed = content.gsub(/\[(!\[[^\]]*\]\[#{Regexp.escape(image_label)}\])\]\[#{Regexp.escape(workflow_label)}\]/, '\1')
|
|
1025
|
+
processed.sub(/^(\[#{Regexp.escape(image_label)}\]: https:\/\/img\.shields\.io\/badge\/[^-\s]+-#{Regexp.escape(match[2])})-[0-9A-Fa-f]{6}(\?)/,
|
|
1026
|
+
'\1_(%F0%9F%9A%ABCI)-AABBCC\2')
|
|
1027
|
+
end
|
|
1028
|
+
|
|
991
1029
|
def workflow_references(content)
|
|
992
1030
|
markdown_structural_owners(content, :link_definitions).fetch(:link_definitions).each_with_object({}) do |owner, references|
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1031
|
+
path = URI(owner.url.to_s).path.to_s
|
|
1032
|
+
# Only real workflow links: badge image definitions (shields.io URLs)
|
|
1033
|
+
# are not workflow references.
|
|
1034
|
+
next unless path.include?("/actions/workflows/")
|
|
1035
|
+
|
|
1036
|
+
workflow = path.split("/actions/workflows/", 2).last.split("/", 2).first
|
|
996
1037
|
|
|
997
1038
|
references[owner.label.to_s] = ".github/workflows/#{workflow}"
|
|
998
1039
|
end
|
|
@@ -3025,6 +3066,7 @@ module Kettle
|
|
|
3025
3066
|
namespace,
|
|
3026
3067
|
entrypoint_path: entrypoint_path
|
|
3027
3068
|
)
|
|
3069
|
+
version_constant_path = existing_version_constant_path(project_root, version_path, namespace)
|
|
3028
3070
|
version_namespace_superclasses = existing_version_namespace_superclasses(
|
|
3029
3071
|
project_root,
|
|
3030
3072
|
version_path,
|
|
@@ -3107,6 +3149,7 @@ module Kettle
|
|
|
3107
3149
|
entrypoint_require: entrypoint_require,
|
|
3108
3150
|
namespace: namespace,
|
|
3109
3151
|
min_ruby: min_ruby,
|
|
3152
|
+
version_constant_path: (version_constant_path unless version_constant_path == "Version::VERSION"),
|
|
3110
3153
|
version_namespace_kinds: version_namespace_kinds,
|
|
3111
3154
|
version_namespace_superclasses: version_namespace_superclasses,
|
|
3112
3155
|
entrypoint_namespace_superclasses: entrypoint_namespace_superclasses,
|
|
@@ -3200,11 +3243,14 @@ module Kettle
|
|
|
3200
3243
|
include_patterns: template_selection[:include]
|
|
3201
3244
|
)
|
|
3202
3245
|
inactive_templates = inactive_packaged_template_cleanup_files(project_root, template_config)
|
|
3246
|
+
legacy_warnings = legacy_engine_warnings(kettle_config, inactive_workflows)
|
|
3247
|
+
facts[:warnings] = Array(facts[:warnings]) + legacy_warnings unless legacy_warnings.empty?
|
|
3203
3248
|
facts[:ci] = {
|
|
3204
3249
|
provider: "github_actions",
|
|
3205
3250
|
default_branch: "main",
|
|
3206
3251
|
exec_cmd: github_actions_exec_cmd(kettle_config, env),
|
|
3207
|
-
engine_exec_cmds:
|
|
3252
|
+
engine_exec_cmds: legacy_engine_exec_cmds(kettle_config, github_actions_exec_cmd(kettle_config, env))
|
|
3253
|
+
.merge(github_actions_engine_exec_cmds(kettle_config)),
|
|
3208
3254
|
platforms: ci_os_platforms_facts(kettle_config, project_root),
|
|
3209
3255
|
recording: project_recording_enabled?(project_root, kettle_config),
|
|
3210
3256
|
ruby_versions: github_actions_ruby_versions(project_runtime.fetch(:test_min_ruby)),
|
|
@@ -3212,6 +3258,9 @@ module Kettle
|
|
|
3212
3258
|
obsolete_workflows: github_actions_obsolete_workflows(project_root),
|
|
3213
3259
|
custom_workflows: github_actions_custom_workflows(project_root, template_config, opencollective_disabled: opencollective_disabled)
|
|
3214
3260
|
}
|
|
3261
|
+
# Only present when used, so projects without legacy engines keep identical facts.
|
|
3262
|
+
experimental_legacy_engines = legacy_engine_experimental_names(kettle_config)
|
|
3263
|
+
facts[:ci][:legacy_experimental_engines] = experimental_legacy_engines unless experimental_legacy_engines.empty?
|
|
3215
3264
|
standard_appraisal_gemfiles = github_actions_standard_appraisal_gemfiles(kettle_config)
|
|
3216
3265
|
facts[:ci][:duel] = true if template_config["resolved_duel"]
|
|
3217
3266
|
facts[:ci][:standard_appraisal_gemfiles] = standard_appraisal_gemfiles unless standard_appraisal_gemfiles.empty?
|
|
@@ -3431,7 +3480,16 @@ module Kettle
|
|
|
3431
3480
|
facts: %w[templates shim]
|
|
3432
3481
|
)
|
|
3433
3482
|
end
|
|
3434
|
-
|
|
3483
|
+
# Cleanup plans against the original file and would overwrite a merged
|
|
3484
|
+
# Rakefile when both recipes change it. The template merge owns that
|
|
3485
|
+
# file whenever it is selected; the merge path strips proven bundle-gem
|
|
3486
|
+
# scaffold content from the merge input instead (see
|
|
3487
|
+
# rakefile_merge_scaffold_source). Retain this recipe for standalone
|
|
3488
|
+
# runs where no Rakefile template application is selected.
|
|
3489
|
+
rakefile_template = recipes.any? do |recipe|
|
|
3490
|
+
TEMPLATE_SOURCE_APPLICATION_RECIPE.match?(recipe.fetch(:name)) && recipe.fetch(:target_path) == "Rakefile"
|
|
3491
|
+
end
|
|
3492
|
+
unless shim_template_profile?(facts) || rakefile_template
|
|
3435
3493
|
recipes << recipe_entry(
|
|
3436
3494
|
"rakefile_scaffold_cleanup",
|
|
3437
3495
|
"Rakefile",
|
|
@@ -3860,6 +3918,12 @@ module Kettle
|
|
|
3860
3918
|
if template_file_type_for_relative_path(report.fetch(:relative_path).to_s) == :appraisals
|
|
3861
3919
|
payload[:appraisals_template_policy_fingerprint_version] = APPRAISALS_TEMPLATE_POLICY_FINGERPRINT_VERSION
|
|
3862
3920
|
end
|
|
3921
|
+
if report.fetch(:relative_path).to_s == "Gemfile"
|
|
3922
|
+
runtime_context = report.dig(:request_envelope, :request, :runtime_context) || {}
|
|
3923
|
+
ci_context = runtime_context[:ci] || runtime_context["ci"] || {}
|
|
3924
|
+
default_test_bundle = ci_context[:default_test_bundle] || ci_context["default_test_bundle"] || {}
|
|
3925
|
+
payload[:default_test_bundle] = stringify_keys_for_json(default_test_bundle)
|
|
3926
|
+
end
|
|
3863
3927
|
if report.fetch(:relative_path).to_s.start_with?("gemfiles/modular/")
|
|
3864
3928
|
conflict_policy = modular_dependency_conflict_decisions(
|
|
3865
3929
|
kettle_jem_config(project_root)
|
|
@@ -3883,6 +3947,12 @@ module Kettle
|
|
|
3883
3947
|
{}
|
|
3884
3948
|
)
|
|
3885
3949
|
payload[:github_workflow_engine_exec_cmds] = engine_exec_cmds unless engine_exec_cmds.empty?
|
|
3950
|
+
# Changes the generated output, so it must change the fingerprint.
|
|
3951
|
+
experimental = Array(
|
|
3952
|
+
report.dig(:request_envelope, :request, :runtime_context, :ci, :legacy_experimental_engines) ||
|
|
3953
|
+
report.dig(:request_envelope, :request, :runtime_context, "ci", "legacy_experimental_engines")
|
|
3954
|
+
).map(&:to_s).sort
|
|
3955
|
+
payload[:github_workflow_legacy_experimental_engines] = experimental unless experimental.empty?
|
|
3886
3956
|
end
|
|
3887
3957
|
payload
|
|
3888
3958
|
end
|
|
@@ -5057,9 +5127,11 @@ module Kettle
|
|
|
5057
5127
|
strategy_index = ((rakefile_index + 1)...block_end).find do |index|
|
|
5058
5128
|
lines.fetch(index).start_with?(" strategy:")
|
|
5059
5129
|
end
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5130
|
+
# The monorepo-subgem profile seeds accept_template, but an explicit
|
|
5131
|
+
# per-file strategy is an operator override. In particular, preserve
|
|
5132
|
+
# merge so a generated destination Rakefile can keep its custom tasks
|
|
5133
|
+
# while receiving template-only nodes.
|
|
5134
|
+
unless strategy_index
|
|
5063
5135
|
lines.insert(rakefile_index + 1, " strategy: accept_template")
|
|
5064
5136
|
end
|
|
5065
5137
|
end
|
|
@@ -5152,15 +5224,15 @@ module Kettle
|
|
|
5152
5224
|
[
|
|
5153
5225
|
{name: "appraisal2", source: %(gem "appraisal2", "~> 3.2", ">= 3.2.6"\n)},
|
|
5154
5226
|
{name: "bundler-audit", source: %(gem "bundler-audit", "~> 0.9.3"\n)},
|
|
5155
|
-
{name: "kettle-dev", source: %(gem "kettle-dev", "~> 3.1", ">= 3.1.
|
|
5227
|
+
{name: "kettle-dev", source: %(gem "kettle-dev", "~> 3.1", ">= 3.1.31"\n)},
|
|
5156
5228
|
{name: "kettle-drift", source: %(gem "kettle-drift", "~> 1.0", ">= 1.0.19"\n)},
|
|
5157
|
-
{name: "kettle-family", source: %(gem "kettle-family", "~> 1.3", ">= 1.3.
|
|
5229
|
+
{name: "kettle-family", source: %(gem "kettle-family", "~> 1.3", ">= 1.3.48"\n)},
|
|
5158
5230
|
{name: PACKAGE_NAME, source: kettle_jem_dependency_source},
|
|
5159
|
-
{name: "kettle-test", source: %(gem "kettle-test", "~> 2.0", ">= 2.0.
|
|
5231
|
+
{name: "kettle-test", source: %(gem "kettle-test", "~> 2.0", ">= 2.0.30"\n)},
|
|
5160
5232
|
{name: "rake", source: %(gem "rake", "~> 13.0"\n)},
|
|
5161
5233
|
{name: "rspec", source: %(gem "rspec", "~> 3.0"\n)},
|
|
5162
|
-
{name: "stone_checksums", source: %(gem "stone_checksums", "~> 1.0", ">= 1.0.
|
|
5163
|
-
{name: "turbo_tests2", source: %(gem "turbo_tests2", "~> 4.0", ">= 4.0.
|
|
5234
|
+
{name: "stone_checksums", source: %(gem "stone_checksums", "~> 1.0", ">= 1.0.11"\n)},
|
|
5235
|
+
{name: "turbo_tests2", source: %(gem "turbo_tests2", "~> 4.0", ">= 4.0.2"\n)}
|
|
5164
5236
|
].freeze
|
|
5165
5237
|
end
|
|
5166
5238
|
|
|
@@ -6052,7 +6124,7 @@ module Kettle
|
|
|
6052
6124
|
"feature.appraisals" => File.file?(File.join(project_root, "Appraisals")),
|
|
6053
6125
|
"feature.rubyforum" => !rubyforum_facts(config, env, package_name: transfer_changelog_package_name(project_root)).empty?,
|
|
6054
6126
|
"feature.rubyforum_project_tag" => !normalize_rubyforum_tag(project_tag).empty?,
|
|
6055
|
-
"feature.corporate_sponsors" => sponsors.any
|
|
6127
|
+
"feature.corporate_sponsors" => sponsors.any? { |sponsor| readme_corporate_sponsor_active?(sponsor, Date.today) || readme_corporate_sponsor_past?(sponsor, Date.today) },
|
|
6056
6128
|
"feature.organization_logo" => readme_top_logo_options(config).any? || readme_h2_synopsis_logo_options(config).any?,
|
|
6057
6129
|
"feature.structuredmerge_driver" => config.fetch("git_drivers", "semantic-diff").to_s == "semantic-diff",
|
|
6058
6130
|
"feature.dedicated_version_gem" => version_gem_mode == "dedicated" || File.file?(File.join(project_root, "lib", entrypoint, "version_gem.rb")),
|
|
@@ -6283,25 +6355,6 @@ module Kettle
|
|
|
6283
6355
|
)
|
|
6284
6356
|
end
|
|
6285
6357
|
|
|
6286
|
-
def remove_excluded_changelog_transfer_entries(content, excluded_keys)
|
|
6287
|
-
excluded = Array(excluded_keys).map(&:to_s).reject(&:empty?).to_set
|
|
6288
|
-
return content if excluded.empty?
|
|
6289
|
-
|
|
6290
|
-
lines = markdown_source_lines(content)
|
|
6291
|
-
removals = changelog_existing_transfer_occurrences(content).filter_map do |occurrence|
|
|
6292
|
-
key = occurrence.fetch(:key).to_s
|
|
6293
|
-
next unless excluded.include?(key)
|
|
6294
|
-
|
|
6295
|
-
(occurrence.fetch(:start_line)..occurrence.fetch(:end_line))
|
|
6296
|
-
end
|
|
6297
|
-
return content if removals.empty?
|
|
6298
|
-
|
|
6299
|
-
lines.each_with_index.reject do |_line, index|
|
|
6300
|
-
line_number = index + 1
|
|
6301
|
-
removals.any? { |range| range.cover?(line_number) }
|
|
6302
|
-
end.map(&:first).join("\n").then { |text| ensure_trailing_newline(text.gsub(/\n{3,}/, "\n\n")) }
|
|
6303
|
-
end
|
|
6304
|
-
|
|
6305
6358
|
def changelog_existing_transfer_occurrences(content)
|
|
6306
6359
|
context = Ast::Crispr::Markdown::Markly.document_context(content: content, source_label: "CHANGELOG.md")
|
|
6307
6360
|
release_sections = context.structural_owners(owner_scope: :heading_sections)
|
|
@@ -6438,6 +6491,7 @@ module Kettle
|
|
|
6438
6491
|
relative_path = recipe.fetch(:target_path)
|
|
6439
6492
|
destination_existed = File.exist?(File.join(project_root, relative_path))
|
|
6440
6493
|
original = files.fetch(relative_path, "")
|
|
6494
|
+
merge_source = scaffold_cleaned_merge_source(recipe, original, facts)
|
|
6441
6495
|
deletion = rakefile_scaffold_cleanup_recipe?(recipe) ? rakefile_scaffold_cleanup(original, facts) : nil
|
|
6442
6496
|
readme_timings = []
|
|
6443
6497
|
final = with_readme_timing_context(relative_path, readme_timings) do
|
|
@@ -6481,7 +6535,7 @@ module Kettle
|
|
|
6481
6535
|
when TEMPLATE_SOURCE_PREFERENCE_RECIPE
|
|
6482
6536
|
original
|
|
6483
6537
|
when TEMPLATE_SOURCE_APPLICATION_RECIPE
|
|
6484
|
-
apply_template_source(project_root, recipe,
|
|
6538
|
+
apply_template_source(project_root, recipe, merge_source, facts: facts, env: env, template_contents: template_contents)
|
|
6485
6539
|
when "rakefile_scaffold_cleanup"
|
|
6486
6540
|
deletion.fetch(:content)
|
|
6487
6541
|
else
|
|
@@ -6552,10 +6606,148 @@ module Kettle
|
|
|
6552
6606
|
|
|
6553
6607
|
def rakefile_scaffold_cleanup(content, facts)
|
|
6554
6608
|
return {content: content.to_s, delete_selectors: []} if facts[:template_profile].to_s == MONOREPO_ROOT_TEMPLATE_PROFILE
|
|
6609
|
+
return {content: content.to_s, delete_selectors: []} unless rakefile_scaffold_provenance?(content)
|
|
6555
6610
|
|
|
6556
6611
|
delete_rakefile_scaffold(content)
|
|
6557
6612
|
end
|
|
6558
6613
|
|
|
6614
|
+
# The Rakefile merge preserves destination-only nodes, so a `bundle gem`
|
|
6615
|
+
# scaffolded Rakefile would keep its scaffold lines (including an eager
|
|
6616
|
+
# `require "rubocop/rake_task"`) forever, and its bare
|
|
6617
|
+
# `require "bundler/gem_tasks"` would win over the template's conditional
|
|
6618
|
+
# form under preference destination. When the destination shows bundle-gem
|
|
6619
|
+
# scaffold provenance, strip the scaffold from the merge INPUT so the
|
|
6620
|
+
# merge adds the template's conditional gem-tasks wiring cleanly. Keep
|
|
6621
|
+
# destination (keep_destination) and wholesale replacement
|
|
6622
|
+
# (accept_template) strategies need no cleaning: one preserves by
|
|
6623
|
+
# contract, the other discards the destination entirely. alef/native
|
|
6624
|
+
# Rakefiles lack the provenance markers and pass through untouched, as do
|
|
6625
|
+
# monorepo-root Rakefiles (matching the standalone cleanup exemption).
|
|
6626
|
+
def rakefile_merge_scaffold_source(recipe, original, facts)
|
|
6627
|
+
return original unless recipe.fetch(:target_path) == "Rakefile"
|
|
6628
|
+
return original unless TEMPLATE_SOURCE_APPLICATION_RECIPE.match?(recipe.fetch(:name))
|
|
6629
|
+
return original if facts[:template_profile].to_s == MONOREPO_ROOT_TEMPLATE_PROFILE
|
|
6630
|
+
|
|
6631
|
+
strategy = recipe.dig(:template_preference, :strategy).to_s
|
|
6632
|
+
return original unless strategy.empty? || strategy == "merge"
|
|
6633
|
+
return original unless rakefile_scaffold_provenance?(original)
|
|
6634
|
+
|
|
6635
|
+
delete_rakefile_scaffold(original).fetch(:content)
|
|
6636
|
+
end
|
|
6637
|
+
|
|
6638
|
+
# True when the content carries markers only a `bundle gem` scaffold
|
|
6639
|
+
# produces: a bare top-level `require "bundler/gem_tasks"` (the template's
|
|
6640
|
+
# own emission is a conditional modifier, which is not a bare top-level
|
|
6641
|
+
# call), a `RuboCop::RakeTask` (templated projects wire rubocop via
|
|
6642
|
+
# rubocop_gradual, never this class), or the scaffold's exact
|
|
6643
|
+
# `task default: %i[spec rubocop]` (alef uses `task default: :spec`).
|
|
6644
|
+
def rakefile_scaffold_provenance?(content)
|
|
6645
|
+
text = content.to_s
|
|
6646
|
+
return false if text.empty?
|
|
6647
|
+
|
|
6648
|
+
rakefile_require_records(text).any? { |record| record.fetch(:name) == "bundler/gem_tasks" } ||
|
|
6649
|
+
rakefile_task_class_records(text).any? { |record| record.fetch(:receiver) == "RuboCop::RakeTask" } ||
|
|
6650
|
+
rakefile_scaffold_default_task?(text)
|
|
6651
|
+
end
|
|
6652
|
+
|
|
6653
|
+
def rakefile_scaffold_default_task?(content)
|
|
6654
|
+
top_level_ruby_call_records(content, :task).any? do |call|
|
|
6655
|
+
argument = call.arguments&.arguments&.first
|
|
6656
|
+
next false unless argument.is_a?(::Prism::KeywordHashNode)
|
|
6657
|
+
|
|
6658
|
+
argument.elements.any? do |element|
|
|
6659
|
+
element.key.is_a?(::Prism::SymbolNode) && element.key.unescaped.to_s == "default" &&
|
|
6660
|
+
rakefile_scaffold_default_task_value?(element.value)
|
|
6661
|
+
end
|
|
6662
|
+
end
|
|
6663
|
+
end
|
|
6664
|
+
|
|
6665
|
+
def rakefile_scaffold_default_task_value?(value)
|
|
6666
|
+
return false unless value.is_a?(::Prism::ArrayNode)
|
|
6667
|
+
|
|
6668
|
+
value.elements.map { |element| element.is_a?(::Prism::SymbolNode) ? element.unescaped.to_s : nil } == %w[spec rubocop]
|
|
6669
|
+
end
|
|
6670
|
+
|
|
6671
|
+
# Dispatch merge-input scaffold cleaning by target. Each cleaner strips
|
|
6672
|
+
# `bundle gem` scaffold artifacts from the DESTINATION content before the
|
|
6673
|
+
# template merge, because the merge preserves destination-only nodes
|
|
6674
|
+
# forever (see rakefile_merge_scaffold_source). Files without a cleaner
|
|
6675
|
+
# pass through unchanged.
|
|
6676
|
+
def scaffold_cleaned_merge_source(recipe, original, facts)
|
|
6677
|
+
case recipe.fetch(:target_path)
|
|
6678
|
+
when "Rakefile"
|
|
6679
|
+
rakefile_merge_scaffold_source(recipe, original, facts)
|
|
6680
|
+
when "CODE_OF_CONDUCT.md"
|
|
6681
|
+
coc_scaffold_merge_source(recipe, original)
|
|
6682
|
+
else
|
|
6683
|
+
original
|
|
6684
|
+
end
|
|
6685
|
+
end
|
|
6686
|
+
|
|
6687
|
+
# Bundler's newgem CoC template renders the contact line with
|
|
6688
|
+
# config[:email].inspect, embedding literal quotes in the href
|
|
6689
|
+
# (mailto:"..."), which crashes yard-relative_markdown_links during the
|
|
6690
|
+
# release changelog yard step. The packaged CoC template covers contact
|
|
6691
|
+
# via the maintainer badge in the Enforcement section, so the scaffold
|
|
6692
|
+
# line is pure junk. Only merge strategies see cleaning: keep_destination
|
|
6693
|
+
# preserves by contract, accept_template discards the destination anyway.
|
|
6694
|
+
def coc_scaffold_merge_source(recipe, original)
|
|
6695
|
+
return original unless TEMPLATE_SOURCE_APPLICATION_RECIPE.match?(recipe.fetch(:name))
|
|
6696
|
+
|
|
6697
|
+
strategy = recipe.dig(:template_preference, :strategy).to_s
|
|
6698
|
+
return original unless strategy.empty? || strategy == "merge"
|
|
6699
|
+
|
|
6700
|
+
delete_quoted_mailto_scaffold_lines(original)
|
|
6701
|
+
end
|
|
6702
|
+
|
|
6703
|
+
# Delete every paragraph containing a quoted mailto link (the bundler
|
|
6704
|
+
# scaffold artifact). The malformation is the detector: `mailto:"` is
|
|
6705
|
+
# never legitimate, so valid contact links pass through. Node discovery
|
|
6706
|
+
# is AST-based via ast-crispr-markdown-markly; deletion is line-based
|
|
6707
|
+
# over the paragraph's source span, collapsing blank runs, so a wrapped
|
|
6708
|
+
# paragraph is removed whole. Accepted tradeoff: a paragraph mixing the
|
|
6709
|
+
# scaffold link with other sentences loses those sentences too — the
|
|
6710
|
+
# paragraph is definitionally broken (its link is an invalid URI).
|
|
6711
|
+
def delete_quoted_mailto_scaffold_lines(content)
|
|
6712
|
+
text = content.to_s
|
|
6713
|
+
ranges = quoted_mailto_scaffold_line_ranges(text)
|
|
6714
|
+
return text if ranges.empty?
|
|
6715
|
+
|
|
6716
|
+
selectors = ranges.map do |(start_line, end_line)|
|
|
6717
|
+
{
|
|
6718
|
+
selector_id: "coc_scaffold_quoted_mailto_paragraph",
|
|
6719
|
+
selector_family: "structural_owner_range",
|
|
6720
|
+
start_line: start_line,
|
|
6721
|
+
end_line: end_line,
|
|
6722
|
+
reason: "wrapper_selected_scaffold_contact"
|
|
6723
|
+
}
|
|
6724
|
+
end
|
|
6725
|
+
delete_line_ranges(text, selectors).sub(/\A(?:[ \t]*\n)+/, "")
|
|
6726
|
+
end
|
|
6727
|
+
|
|
6728
|
+
def quoted_mailto_scaffold_line_ranges(content)
|
|
6729
|
+
context = Ast::Crispr::Markdown::Markly.document_context(content: content, source_label: "CODE_OF_CONDUCT.md")
|
|
6730
|
+
ranges = []
|
|
6731
|
+
walk_markdown_nodes(context.ast.document) do |node|
|
|
6732
|
+
next unless node.type == "link"
|
|
6733
|
+
next unless node.url.to_s.start_with?(%(mailto:"))
|
|
6734
|
+
|
|
6735
|
+
paragraph = node.parent
|
|
6736
|
+
paragraph = paragraph.parent while paragraph && paragraph.type != "paragraph"
|
|
6737
|
+
next unless paragraph
|
|
6738
|
+
|
|
6739
|
+
ranges << [paragraph.start_line, paragraph.end_line]
|
|
6740
|
+
end
|
|
6741
|
+
ranges.uniq
|
|
6742
|
+
rescue Ast::Crispr::Error
|
|
6743
|
+
[]
|
|
6744
|
+
end
|
|
6745
|
+
|
|
6746
|
+
def walk_markdown_nodes(node, &block)
|
|
6747
|
+
yield node
|
|
6748
|
+
node.children.each { |child| walk_markdown_nodes(child, &block) }
|
|
6749
|
+
end
|
|
6750
|
+
|
|
6559
6751
|
def content_recipe_step(recipe)
|
|
6560
6752
|
step = {
|
|
6561
6753
|
step_id: recipe.fetch(:name),
|
|
@@ -6856,6 +7048,10 @@ module Kettle
|
|
|
6856
7048
|
end
|
|
6857
7049
|
|
|
6858
7050
|
def apply_template_source(project_root, recipe, original, facts: nil, env: ENV, template_contents: nil)
|
|
7051
|
+
if template_file_type(recipe) == :gemspec && recipe.dig(:template_preference, :preference).to_s == "destination"
|
|
7052
|
+
facts = deep_dup(facts || {})
|
|
7053
|
+
facts[:gemspec] = facts[:gemspec].to_h.merge(preference: "destination")
|
|
7054
|
+
end
|
|
6859
7055
|
strategy = recipe.dig(:template_preference, :strategy).to_s
|
|
6860
7056
|
return original if Ast::Template::Strategies.keep_destination?(strategy)
|
|
6861
7057
|
|
|
@@ -7774,6 +7970,12 @@ module Kettle
|
|
|
7774
7970
|
return merge_changelog_template_source(template_content, destination_content, facts: facts) if recipe.fetch(:target_path) == "CHANGELOG.md"
|
|
7775
7971
|
|
|
7776
7972
|
merge_result = Ast::Template::MergeDispatch.dispatch(:markdown, template_content, destination_content)
|
|
7973
|
+
# A successful structural merge can still produce no document (for
|
|
7974
|
+
# example, a license containing only unheaded prose). Never replace a
|
|
7975
|
+
# nonempty destination with that empty result.
|
|
7976
|
+
if merge_result[:ok] && merge_result.fetch(:output).strip.empty? && !destination_content.strip.empty?
|
|
7977
|
+
return destination_content
|
|
7978
|
+
end
|
|
7777
7979
|
when :dotenv
|
|
7778
7980
|
merge_result = merge_dotenv_template_source(template_content, destination_content, recipe)
|
|
7779
7981
|
when :rbs
|
|
@@ -7824,6 +8026,11 @@ module Kettle
|
|
|
7824
8026
|
target.include?(dependency.tr("-", "_"))
|
|
7825
8027
|
end
|
|
7826
8028
|
removable = [package_name, *(runtime_dependencies - named_fragment_dependencies)]
|
|
8029
|
+
# A modular Gemfile may repeat a runtime gem only to select its local
|
|
8030
|
+
# source. Keep explicit path overrides while pruning ordinary
|
|
8031
|
+
# duplicates. The package's own gem is never exempt: a self-reference
|
|
8032
|
+
# is a prohibited declaration, not a local source override.
|
|
8033
|
+
removable -= (gemfile_path_source_override_names(template_content) - [package_name])
|
|
7827
8034
|
output = remove_gemfile_dependency_blocks(content, removable)
|
|
7828
8035
|
output = remove_gemfile_percent_w_entries(output, removable)
|
|
7829
8036
|
end
|
|
@@ -9211,6 +9418,7 @@ module Kettle
|
|
|
9211
9418
|
|
|
9212
9419
|
def finalize_github_workflow_template(content, facts = nil)
|
|
9213
9420
|
output = apply_github_actions_engine_exec_cmd_overrides(content, facts)
|
|
9421
|
+
output = apply_legacy_engine_experimental(output, facts)
|
|
9214
9422
|
inject_framework_matrix_workflow_env(update_github_actions_pins(output), facts)
|
|
9215
9423
|
end
|
|
9216
9424
|
|
|
@@ -9236,6 +9444,28 @@ module Kettle
|
|
|
9236
9444
|
content
|
|
9237
9445
|
end
|
|
9238
9446
|
|
|
9447
|
+
# Adds `experimental: true` to the matrix entry of legacy engines configured
|
|
9448
|
+
# with mode: experimental (the job's continue-on-error already honours it).
|
|
9449
|
+
def apply_legacy_engine_experimental(content, facts)
|
|
9450
|
+
names = Array(facts.to_h.dig(:ci, :legacy_experimental_engines))
|
|
9451
|
+
return content if names.empty?
|
|
9452
|
+
|
|
9453
|
+
lines = content.to_s.lines
|
|
9454
|
+
yaml_mapping_nodes(content).sort_by { |mapping| -mapping.start_line }.each do |mapping|
|
|
9455
|
+
next unless names.include?(yaml_mapping_scalar_value(mapping, "ruby"))
|
|
9456
|
+
next if yaml_mapping_scalar_node(mapping, "experimental")
|
|
9457
|
+
|
|
9458
|
+
anchor = yaml_mapping_scalar_node(mapping, "exec_cmd")
|
|
9459
|
+
next unless anchor
|
|
9460
|
+
|
|
9461
|
+
indent = lines.fetch(anchor.start_line).to_s.match(/\A(\s*)/)[1]
|
|
9462
|
+
lines.insert(anchor.start_line + 1, "#{indent}experimental: true\n")
|
|
9463
|
+
end
|
|
9464
|
+
lines.join
|
|
9465
|
+
rescue Psych::Exception
|
|
9466
|
+
content
|
|
9467
|
+
end
|
|
9468
|
+
|
|
9239
9469
|
def inject_framework_matrix_workflow_env(content, facts)
|
|
9240
9470
|
env_by_appraisal = framework_matrix_appraisal_env_by_name(facts)
|
|
9241
9471
|
return content if env_by_appraisal.empty?
|
|
@@ -9410,7 +9640,7 @@ module Kettle
|
|
|
9410
9640
|
end
|
|
9411
9641
|
|
|
9412
9642
|
def merge_ruby_template_source(file_type, recipe, template_content, destination_content, facts: nil)
|
|
9413
|
-
return merge_prism_gemfile_template_source(template_content, destination_content) if file_type == :gemfile
|
|
9643
|
+
return merge_prism_gemfile_template_source(template_content, destination_content, recipe) if file_type == :gemfile
|
|
9414
9644
|
|
|
9415
9645
|
template_preference = recipe.fetch(:template_preference, {})
|
|
9416
9646
|
preference = (template_preference[:preference] || "destination").to_sym
|
|
@@ -9431,22 +9661,33 @@ module Kettle
|
|
|
9431
9661
|
)
|
|
9432
9662
|
end
|
|
9433
9663
|
|
|
9434
|
-
def merge_prism_gemfile_template_source(template_content, destination_content)
|
|
9664
|
+
def merge_prism_gemfile_template_source(template_content, destination_content, recipe)
|
|
9665
|
+
template_preference = recipe.fetch(:template_preference, {})
|
|
9666
|
+
add_template_only_nodes = DecisionPolicy.value_to_boolean(template_preference[:add_template_only_nodes])
|
|
9435
9667
|
Prism::Merge.merge_ruby(
|
|
9436
9668
|
template_content,
|
|
9437
9669
|
destination_content,
|
|
9438
9670
|
"ruby",
|
|
9439
|
-
preference: :template,
|
|
9440
|
-
add_template_only_nodes:
|
|
9441
|
-
signature_generator: Prism::Merge.ruby_dsl_signature_generator
|
|
9671
|
+
preference: (template_preference[:preference] || "template").to_sym,
|
|
9672
|
+
add_template_only_nodes: add_template_only_nodes.nil? || add_template_only_nodes,
|
|
9673
|
+
signature_generator: Prism::Merge.ruby_dsl_signature_generator,
|
|
9674
|
+
freeze_token: ruby_merge_freeze_token(recipe)
|
|
9442
9675
|
)
|
|
9443
9676
|
end
|
|
9444
9677
|
|
|
9678
|
+
# kettle-jem orchestrates every merge, so freeze blocks in templated files
|
|
9679
|
+
# are uniformly owned by kettle-jem regardless of the merge backend's own
|
|
9680
|
+
# default token (Prism::Merge defaults to "prism-merge").
|
|
9681
|
+
def ruby_merge_freeze_token(recipe)
|
|
9682
|
+
recipe.dig(:template_preference, :freeze_token) || "kettle-jem"
|
|
9683
|
+
end
|
|
9684
|
+
|
|
9445
9685
|
def prism_ruby_merge_options(recipe)
|
|
9446
9686
|
{
|
|
9447
9687
|
method_move_policy: ruby_method_move_policy(recipe),
|
|
9448
9688
|
merge_template_requires: true,
|
|
9449
|
-
template_only_placement: :after_anchor
|
|
9689
|
+
template_only_placement: :after_anchor,
|
|
9690
|
+
freeze_token: ruby_merge_freeze_token(recipe)
|
|
9450
9691
|
}
|
|
9451
9692
|
end
|
|
9452
9693
|
|
|
@@ -9468,6 +9709,12 @@ module Kettle
|
|
|
9468
9709
|
removable_gems = [*PROHIBITED_GEMFILE_DEPENDENCIES]
|
|
9469
9710
|
removable_gems << package_name unless package_name.to_s.empty?
|
|
9470
9711
|
removable_gems.concat(package_runtime_dependency_names(facts))
|
|
9712
|
+
# A Gemfile path declaration can override the source of a runtime gemspec
|
|
9713
|
+
# dependency. Keep those declarations so local development can resolve an
|
|
9714
|
+
# unpublished dependency without changing the runtime dependency graph.
|
|
9715
|
+
# The package's own gem is never exempt: a self-reference is a prohibited
|
|
9716
|
+
# declaration, not a local source override.
|
|
9717
|
+
removable_gems -= (gemfile_path_source_override_names(template_content.to_s) - [package_name])
|
|
9471
9718
|
removable_gems << "version_gem" unless version_gem_enabled?(facts)
|
|
9472
9719
|
pruned = remove_gemfile_dependency_blocks(content, removable_gems)
|
|
9473
9720
|
pruned = remove_gemfile_percent_w_entries(pruned, [package_name]) unless preserve_self_word_entries
|
|
@@ -9770,6 +10017,13 @@ module Kettle
|
|
|
9770
10017
|
end
|
|
9771
10018
|
end
|
|
9772
10019
|
|
|
10020
|
+
def gemfile_path_source_override_names(content)
|
|
10021
|
+
ruby_call_records(content, :gem).filter_map do |call|
|
|
10022
|
+
name = ruby_string_argument(call)
|
|
10023
|
+
name if name && ruby_keyword_argument_node(call, :path)
|
|
10024
|
+
end.uniq
|
|
10025
|
+
end
|
|
10026
|
+
|
|
9773
10027
|
# A dependency owned directly by the project must not also be introduced by
|
|
9774
10028
|
# a generated modular Gemfile. On first bootstrap, write a reviewable
|
|
9775
10029
|
# resolution list; later runs require an explicit removal operation.
|
|
@@ -9911,8 +10165,9 @@ module Kettle
|
|
|
9911
10165
|
direct_records = dependency_records_for(direct_path, content)
|
|
9912
10166
|
modular.flat_map do |modular_path, modular_content|
|
|
9913
10167
|
modular_records = dependency_records_for(modular_path, modular_content)
|
|
10168
|
+
source_overrides = gemfile_path_source_override_names(modular_content)
|
|
9914
10169
|
direct_records.flat_map do |direct_record|
|
|
9915
|
-
modular_records.select { |record| record.fetch(:name) == direct_record.fetch(:name) }.map do |modular_record|
|
|
10170
|
+
modular_records.select { |record| record.fetch(:name) == direct_record.fetch(:name) && !source_overrides.include?(record.fetch(:name)) }.map do |modular_record|
|
|
9916
10171
|
{
|
|
9917
10172
|
name: direct_record.fetch(:name),
|
|
9918
10173
|
direct: direct_path,
|
|
@@ -10609,6 +10864,8 @@ module Kettle
|
|
|
10609
10864
|
index + 2
|
|
10610
10865
|
end
|
|
10611
10866
|
|
|
10867
|
+
# Normalize paths for merging, without interpreting ranges; see
|
|
10868
|
+
# Kettle::Rb::RubySeriesBuckets for the complete-set bucket rules.
|
|
10612
10869
|
def normalize_eval_gemfile_ruby_bucket(path)
|
|
10613
10870
|
segments = path.to_s.split("/", -1)
|
|
10614
10871
|
bucket_index = segments.index { |segment| ruby_bucket_path_segment?(segment) }
|
|
@@ -10635,6 +10892,7 @@ module Kettle
|
|
|
10635
10892
|
with_standard_appraisal_gemfiles = inject_duel_appraisal(with_standard_appraisal_gemfiles, facts) if target_path.to_s == "Appraisals"
|
|
10636
10893
|
pruned = prune_appraisals_recording_entries(with_standard_appraisal_gemfiles, facts)
|
|
10637
10894
|
pruned = prune_appraisals_below_min_ruby(pruned, min_ruby)
|
|
10895
|
+
pruned = migrate_and_prune_appraisal_buckets(pruned, min_ruby)
|
|
10638
10896
|
pruned = remove_managed_stdlib_appraisal_gems(pruned)
|
|
10639
10897
|
pruned = remove_duplicate_runtime_heads_from_head_appraisal(pruned)
|
|
10640
10898
|
pruned = migrate_legacy_byebug_appraisal_dependencies(pruned)
|
|
@@ -10642,6 +10900,55 @@ module Kettle
|
|
|
10642
10900
|
remove_gemfile_percent_w_entries(pruned, [package_name])
|
|
10643
10901
|
end
|
|
10644
10902
|
|
|
10903
|
+
# Migrate the historically misnamed formatter path before pruning managed
|
|
10904
|
+
# bucket references. Ranges come from kettle-rb's RubySeriesBuckets: rN.M
|
|
10905
|
+
# is an upper bound and rN is the remaining range within major N.
|
|
10906
|
+
def migrate_and_prune_appraisal_buckets(content, min_ruby)
|
|
10907
|
+
parsed = appraisal_blocks(content)
|
|
10908
|
+
blocks = parsed.fetch(:order).map do |name|
|
|
10909
|
+
migrate_and_prune_appraisal_bucket_block(parsed.fetch(:blocks).fetch(name), min_ruby)
|
|
10910
|
+
end
|
|
10911
|
+
ensure_trailing_newline(([parsed.fetch(:prelude).to_s.rstrip] + blocks.map(&:rstrip)).reject(&:empty?).join("\n\n"))
|
|
10912
|
+
end
|
|
10913
|
+
|
|
10914
|
+
def migrate_and_prune_appraisal_bucket_block(block, min_ruby)
|
|
10915
|
+
lines = block.lines
|
|
10916
|
+
calls = ruby_call_records(block, :eval_gemfile)
|
|
10917
|
+
loader = "modular/rspec.gemfile"
|
|
10918
|
+
legacy = "modular/rspec_junit_formatter/r3.3/v0.8.gemfile"
|
|
10919
|
+
has_loader = calls.any? { |call| ruby_string_argument(call) == loader }
|
|
10920
|
+
calls.sort_by { |call| -call.location.start_line }.each do |call|
|
|
10921
|
+
path = ruby_string_argument(call)
|
|
10922
|
+
index = call.location.start_line - 1
|
|
10923
|
+
next unless call.location.start_line == ruby_node_source_end_line(call)
|
|
10924
|
+
next unless lines.fetch(index).strip == call.location.slice.strip
|
|
10925
|
+
|
|
10926
|
+
if path == legacy
|
|
10927
|
+
lines[index] = has_loader ? "" : %( eval_gemfile "#{loader}"\n)
|
|
10928
|
+
has_loader = true
|
|
10929
|
+
elsif obsolete_managed_appraisal_bucket?(path, min_ruby)
|
|
10930
|
+
lines[index] = ""
|
|
10931
|
+
end
|
|
10932
|
+
end
|
|
10933
|
+
lines.join
|
|
10934
|
+
end
|
|
10935
|
+
|
|
10936
|
+
# Only prune packaged variants; destination-owned paths are not ours to
|
|
10937
|
+
# reinterpret. The complete sibling bucket set determines each range.
|
|
10938
|
+
def obsolete_managed_appraisal_bucket?(path, min_ruby)
|
|
10939
|
+
return false if min_ruby.to_s.empty? || !path.to_s.start_with?("modular/")
|
|
10940
|
+
|
|
10941
|
+
parts = path.split("/")
|
|
10942
|
+
return false unless parts.length >= 4 && ruby_bucket_path_segment?(parts[2])
|
|
10943
|
+
|
|
10944
|
+
source = File.join(PACKAGED_TEMPLATE_ROOT, "gemfiles", "#{path}.example")
|
|
10945
|
+
return false unless File.file?(source)
|
|
10946
|
+
|
|
10947
|
+
root = File.join(PACKAGED_TEMPLATE_ROOT, "gemfiles", "modular", parts[1])
|
|
10948
|
+
buckets = Dir.children(root).select { |name| ruby_bucket_path_segment?(name) && File.directory?(File.join(root, name)) }
|
|
10949
|
+
!Kettle::Rb::RubySeriesBuckets.relevant_buckets(buckets, minimum: min_ruby).include?(parts[2])
|
|
10950
|
+
end
|
|
10951
|
+
|
|
10645
10952
|
# Each appraisal has an independent dependency set. Reuse the AST-based
|
|
10646
10953
|
# Gemfile migration per block so every legacy byebug/pry-byebug pair is
|
|
10647
10954
|
# replaced by one debug declaration in that same appraisal.
|
|
@@ -11089,9 +11396,11 @@ module Kettle
|
|
|
11089
11396
|
def merge_gemspec_template_source(template_content, destination_content, facts: nil, env: ENV)
|
|
11090
11397
|
template_receiver = gemspec_block_param(template_content) || "spec"
|
|
11091
11398
|
destination_receiver = gemspec_block_param(destination_content) || "spec"
|
|
11399
|
+
gemspec_preference = facts.to_h.dig(:gemspec, :preference).to_s
|
|
11092
11400
|
package_name = facts.dig(:package, :name).to_s if facts
|
|
11093
11401
|
replacements = gemspec_preserved_assignments(destination_content, receiver: destination_receiver)
|
|
11094
11402
|
.except(*env_overridden_gemspec_fields(env))
|
|
11403
|
+
replacements.delete("version") if gemspec_preference == "destination"
|
|
11095
11404
|
replacements = remove_stale_generated_gemspec_homepage_replacement(
|
|
11096
11405
|
replacements,
|
|
11097
11406
|
destination_content,
|
|
@@ -11110,8 +11419,10 @@ module Kettle
|
|
|
11110
11419
|
template_content: template_content,
|
|
11111
11420
|
destination_content: destination_content,
|
|
11112
11421
|
template_receiver: template_receiver,
|
|
11113
|
-
destination_receiver: destination_receiver
|
|
11422
|
+
destination_receiver: destination_receiver,
|
|
11423
|
+
preference: gemspec_preference
|
|
11114
11424
|
)
|
|
11425
|
+
merged = preserve_destination_gemspec_version(merged, destination_content, template_receiver: template_receiver, destination_receiver: destination_receiver) if gemspec_preference == "destination"
|
|
11115
11426
|
merged = insert_missing_gemspec_files_assignment(
|
|
11116
11427
|
merged,
|
|
11117
11428
|
template_content: template_content,
|
|
@@ -11160,6 +11471,14 @@ module Kettle
|
|
|
11160
11471
|
rewrite_gemspec_version_loader(merged, facts: facts)
|
|
11161
11472
|
end
|
|
11162
11473
|
|
|
11474
|
+
def preserve_destination_gemspec_version(content, destination_content, template_receiver:, destination_receiver:)
|
|
11475
|
+
destination = gemspec_assignment_records(destination_content, receiver: destination_receiver).find { |record| record.fetch(:field) == "version" }
|
|
11476
|
+
return content unless destination
|
|
11477
|
+
|
|
11478
|
+
replacement = normalize_gemspec_receiver(destination.fetch(:source).rstrip, from: destination_receiver, to: template_receiver)
|
|
11479
|
+
replace_gemspec_assignment_sources(content, {"version" => replacement}, receiver: template_receiver)
|
|
11480
|
+
end
|
|
11481
|
+
|
|
11163
11482
|
def normalize_gemspec_package_helper_assignments(content, template_content)
|
|
11164
11483
|
template_records = gemspec_package_helper_assignment_records(template_content).to_h do |record|
|
|
11165
11484
|
[record.fetch(:name), record.fetch(:source)]
|
|
@@ -11218,6 +11537,17 @@ module Kettle
|
|
|
11218
11537
|
def rewrite_gemspec_version_loader(content, facts:)
|
|
11219
11538
|
return content if shim_template_profile?(facts)
|
|
11220
11539
|
|
|
11540
|
+
if facts.to_h.dig(:gemspec, :preference).to_s == "destination"
|
|
11541
|
+
# Keep Alef's version expression, but normalize the generated file path
|
|
11542
|
+
# when its configured Ruby entrypoint does not follow the gem-name path.
|
|
11543
|
+
package_name = facts.to_h.dig(:package, :name).to_s
|
|
11544
|
+
entrypoint_require = facts.to_h.dig(:rubygems, :entrypoint_require).to_s
|
|
11545
|
+
default_path = package_name.tr("-", "/")
|
|
11546
|
+
return content if package_name.empty? || entrypoint_require.empty? || default_path == entrypoint_require
|
|
11547
|
+
|
|
11548
|
+
return content.gsub("lib/#{default_path}/version.rb", "lib/#{entrypoint_require}/version.rb")
|
|
11549
|
+
end
|
|
11550
|
+
|
|
11221
11551
|
min_ruby = gemspec_runtime_floor_token(facts)
|
|
11222
11552
|
return content if min_ruby.to_s.empty?
|
|
11223
11553
|
|
|
@@ -11229,7 +11559,9 @@ module Kettle
|
|
|
11229
11559
|
receiver = gemspec_block_param(content) || "spec"
|
|
11230
11560
|
min_ruby_version = Gem::Version.new(min_ruby)
|
|
11231
11561
|
modern = min_ruby_version >= MODERN_GEMSPEC_VERSION_LOADER_MIN_RUBY
|
|
11232
|
-
|
|
11562
|
+
version_constant_path = facts.to_h.dig(:rubygems, :version_constant_path).to_s
|
|
11563
|
+
version_constant_path = "Version::VERSION" if version_constant_path.empty?
|
|
11564
|
+
rhs = modern ? gemspec_modern_version_loader_expression(entrypoint_require: entrypoint_require, namespace: namespace, version_constant_path: version_constant_path) : "gem_version"
|
|
11233
11565
|
rewritten = replace_gemspec_version_assignment(content, receiver: receiver, rhs: rhs)
|
|
11234
11566
|
if modern
|
|
11235
11567
|
remove_gemspec_legacy_version_loader_preamble(rewritten)
|
|
@@ -11239,6 +11571,7 @@ module Kettle
|
|
|
11239
11571
|
entrypoint_require: entrypoint_require,
|
|
11240
11572
|
namespace: namespace,
|
|
11241
11573
|
min_ruby: min_ruby_version,
|
|
11574
|
+
version_constant_path: version_constant_path,
|
|
11242
11575
|
superclass_sensitive: gemspec_version_loader_superclass_sensitive?(facts),
|
|
11243
11576
|
fallback_version: facts.to_h.dig(:project_runtime, :version)
|
|
11244
11577
|
)
|
|
@@ -11258,16 +11591,17 @@ module Kettle
|
|
|
11258
11591
|
insert_lines_after(content, gemspec_new_call(content)&.location&.start_line || 1, " #{replacement}\n")
|
|
11259
11592
|
end
|
|
11260
11593
|
|
|
11261
|
-
def gemspec_modern_version_loader_expression(entrypoint_require:, namespace:)
|
|
11262
|
-
%(Module.new.tap { |mod| Kernel.load("\#{__dir__}/lib/#{entrypoint_require}/version.rb", mod) }::#{namespace}
|
|
11594
|
+
def gemspec_modern_version_loader_expression(entrypoint_require:, namespace:, version_constant_path: "Version::VERSION")
|
|
11595
|
+
%(Module.new.tap { |mod| Kernel.load("\#{__dir__}/lib/#{entrypoint_require}/version.rb", mod) }::#{namespace}::#{version_constant_path})
|
|
11263
11596
|
end
|
|
11264
11597
|
|
|
11265
|
-
def gemspec_legacy_version_loader_block(entrypoint_require:, namespace:, min_ruby:, superclass_sensitive: false, fallback_version: nil)
|
|
11598
|
+
def gemspec_legacy_version_loader_block(entrypoint_require:, namespace:, min_ruby:, version_constant_path: "Version::VERSION", superclass_sensitive: false, fallback_version: nil)
|
|
11266
11599
|
unless superclass_sensitive
|
|
11267
11600
|
return gemspec_standard_legacy_version_loader_block(
|
|
11268
11601
|
entrypoint_require: entrypoint_require,
|
|
11269
11602
|
namespace: namespace,
|
|
11270
|
-
min_ruby: min_ruby
|
|
11603
|
+
min_ruby: min_ruby,
|
|
11604
|
+
version_constant_path: version_constant_path
|
|
11271
11605
|
)
|
|
11272
11606
|
end
|
|
11273
11607
|
|
|
@@ -11275,7 +11609,7 @@ module Kettle
|
|
|
11275
11609
|
require "anonymous_loader"
|
|
11276
11610
|
path = File.expand_path("lib/#{entrypoint_require}/version.rb", __dir__)
|
|
11277
11611
|
anonymous_namespace = AnonymousLoader.load(files: path)
|
|
11278
|
-
anonymous_namespace::#{namespace}
|
|
11612
|
+
anonymous_namespace::#{namespace}::#{version_constant_path}
|
|
11279
11613
|
RUBY
|
|
11280
11614
|
anonymous_loader_lines = anonymous_loader.lines.map { |line| " #{line.chomp}" }
|
|
11281
11615
|
fallback = fallback_version.to_s
|
|
@@ -11286,7 +11620,7 @@ module Kettle
|
|
|
11286
11620
|
" # Loading Version into an anonymous module allows version.rb to get code coverage from SimpleCov!",
|
|
11287
11621
|
" # See: https://github.com/simplecov-ruby/simplecov/issues/557#issuecomment-2630782358",
|
|
11288
11622
|
" # See: https://github.com/panorama-ed/memo_wise/pull/397",
|
|
11289
|
-
" #{gemspec_modern_version_loader_expression(entrypoint_require: entrypoint_require, namespace: namespace)}"
|
|
11623
|
+
" #{gemspec_modern_version_loader_expression(entrypoint_require: entrypoint_require, namespace: namespace, version_constant_path: version_constant_path)}"
|
|
11290
11624
|
]
|
|
11291
11625
|
lines << " # The namesake namespace has a superclass. Directly requiring version.rb"
|
|
11292
11626
|
lines << " # on legacy Ruby could define that namespace with the wrong superclass."
|
|
@@ -11303,7 +11637,7 @@ module Kettle
|
|
|
11303
11637
|
"#{lines.join("\n")}\n"
|
|
11304
11638
|
end
|
|
11305
11639
|
|
|
11306
|
-
def gemspec_standard_legacy_version_loader_block(entrypoint_require:, namespace:, min_ruby:)
|
|
11640
|
+
def gemspec_standard_legacy_version_loader_block(entrypoint_require:, namespace:, min_ruby:, version_constant_path: "Version::VERSION")
|
|
11307
11641
|
legacy_else =
|
|
11308
11642
|
if min_ruby >= REQUIRE_RELATIVE_MIN_RUBY
|
|
11309
11643
|
<<~RUBY.chomp
|
|
@@ -11312,7 +11646,7 @@ module Kettle
|
|
|
11312
11646
|
# gemspec (e.g. by bundler/setup in a subprocess) must not define top-level constants,
|
|
11313
11647
|
# which isolated-loading specs assert on.
|
|
11314
11648
|
version_path = "\#{__dir__}/lib/#{entrypoint_require}/version.rb"
|
|
11315
|
-
Module.new.tap { |mod| mod.module_eval(File.read(version_path), version_path, 1) }::#{namespace}
|
|
11649
|
+
Module.new.tap { |mod| mod.module_eval(File.read(version_path), version_path, 1) }::#{namespace}::#{version_constant_path}
|
|
11316
11650
|
RUBY
|
|
11317
11651
|
else
|
|
11318
11652
|
<<~RUBY.chomp
|
|
@@ -11321,7 +11655,7 @@ module Kettle
|
|
|
11321
11655
|
lib = File.expand_path("lib", File.dirname(__FILE__))
|
|
11322
11656
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
11323
11657
|
require "#{entrypoint_require}/version"
|
|
11324
|
-
#{namespace}
|
|
11658
|
+
#{namespace}::#{version_constant_path}
|
|
11325
11659
|
RUBY
|
|
11326
11660
|
end
|
|
11327
11661
|
|
|
@@ -11331,7 +11665,7 @@ module Kettle
|
|
|
11331
11665
|
# Loading Version into an anonymous module allows version.rb to get code coverage from SimpleCov!
|
|
11332
11666
|
# See: https://github.com/simplecov-ruby/simplecov/issues/557#issuecomment-2630782358
|
|
11333
11667
|
# See: https://github.com/panorama-ed/memo_wise/pull/397
|
|
11334
|
-
#{gemspec_modern_version_loader_expression(entrypoint_require: entrypoint_require, namespace: namespace)}
|
|
11668
|
+
#{gemspec_modern_version_loader_expression(entrypoint_require: entrypoint_require, namespace: namespace, version_constant_path: version_constant_path)}
|
|
11335
11669
|
else
|
|
11336
11670
|
#{legacy_else.gsub("\n", "\n ")}
|
|
11337
11671
|
end
|
|
@@ -11378,8 +11712,8 @@ module Kettle
|
|
|
11378
11712
|
{start_line: start_index + 1, end_line: end_line}
|
|
11379
11713
|
end
|
|
11380
11714
|
|
|
11381
|
-
def ensure_gemspec_legacy_version_loader_preamble(content, entrypoint_require:, namespace:, min_ruby:, superclass_sensitive: false, fallback_version: nil)
|
|
11382
|
-
block = "#{gemspec_legacy_version_loader_block(entrypoint_require: entrypoint_require, namespace: namespace, min_ruby: min_ruby, superclass_sensitive: superclass_sensitive, fallback_version: fallback_version)}\n"
|
|
11715
|
+
def ensure_gemspec_legacy_version_loader_preamble(content, entrypoint_require:, namespace:, min_ruby:, version_constant_path: "Version::VERSION", superclass_sensitive: false, fallback_version: nil)
|
|
11716
|
+
block = "#{gemspec_legacy_version_loader_block(entrypoint_require: entrypoint_require, namespace: namespace, min_ruby: min_ruby, version_constant_path: version_constant_path, superclass_sensitive: superclass_sensitive, fallback_version: fallback_version)}\n"
|
|
11383
11717
|
node = gemspec_top_level_gem_version_node(content)
|
|
11384
11718
|
return replace_source_range_lines(content, node.location.start_line, expand_line_range_through_following_blanks(content, node.location.end_line), block) if node
|
|
11385
11719
|
|
|
@@ -11729,16 +12063,26 @@ module Kettle
|
|
|
11729
12063
|
licenses
|
|
11730
12064
|
required_ruby_version
|
|
11731
12065
|
executables
|
|
12066
|
+
extensions
|
|
11732
12067
|
]
|
|
11733
12068
|
end
|
|
11734
12069
|
|
|
11735
|
-
def merge_gemspec_files_assignment(content, template_content:, destination_content:, template_receiver:, destination_receiver:)
|
|
12070
|
+
def merge_gemspec_files_assignment(content, template_content:, destination_content:, template_receiver:, destination_receiver:, preference: nil)
|
|
11736
12071
|
merged_record = gemspec_assignment_records(content, receiver: template_receiver).find { |record| record.fetch(:field) == "files" }
|
|
11737
12072
|
template_record = gemspec_assignment_records(template_content, receiver: template_receiver).find { |record| record.fetch(:field) == "files" }
|
|
11738
12073
|
destination_record = gemspec_assignment_records(destination_content, receiver: destination_receiver).find { |record| record.fetch(:field) == "files" }
|
|
11739
12074
|
return content unless merged_record && template_record && destination_record
|
|
11740
12075
|
|
|
11741
|
-
|
|
12076
|
+
# The destination preference preserves the Alef manifest and filter,
|
|
12077
|
+
# while still adding files required by the template.
|
|
12078
|
+
replacement ||= merge_gemspec_files_assignment_with_destination_filter(
|
|
12079
|
+
template_record: template_record,
|
|
12080
|
+
destination_content: destination_content,
|
|
12081
|
+
destination_record: destination_record,
|
|
12082
|
+
template_receiver: template_receiver,
|
|
12083
|
+
destination_receiver: destination_receiver
|
|
12084
|
+
)
|
|
12085
|
+
replacement ||= merge_gemspec_files_assignment_source(
|
|
11742
12086
|
merged_record: merged_record,
|
|
11743
12087
|
template_record: template_record,
|
|
11744
12088
|
destination_record: destination_record
|
|
@@ -11755,6 +12099,59 @@ module Kettle
|
|
|
11755
12099
|
replace_source_range_lines(content, merged_record.fetch(:start_line), merged_record.fetch(:end_line), replacement)
|
|
11756
12100
|
end
|
|
11757
12101
|
|
|
12102
|
+
# Alef emits a named candidate_files list and applies a grep_v exclusion
|
|
12103
|
+
# after it. Keep both parts of that contract while adding the template's
|
|
12104
|
+
# package files before the exclusion runs. Inlining the candidate list is
|
|
12105
|
+
# necessary because the rest of the destination gemspec is template-owned.
|
|
12106
|
+
def merge_gemspec_files_assignment_with_destination_filter(template_record:, destination_content:, destination_record:, template_receiver:, destination_receiver:)
|
|
12107
|
+
template_parts = gemspec_files_collection_parts(template_record)
|
|
12108
|
+
return unless template_parts
|
|
12109
|
+
|
|
12110
|
+
assignment = destination_record.fetch(:value_node)
|
|
12111
|
+
return unless assignment.is_a?(::Prism::CallNode) && assignment.name == :grep_v && !assignment.block
|
|
12112
|
+
|
|
12113
|
+
arguments = Array(assignment.arguments&.arguments)
|
|
12114
|
+
variable = assignment.receiver
|
|
12115
|
+
if arguments.length == 1 && assignment.receiver.is_a?(::Prism::ParenthesesNode)
|
|
12116
|
+
existing_expression = assignment.receiver.body&.body&.first
|
|
12117
|
+
if existing_expression.is_a?(::Prism::CallNode) && existing_expression.name == :+
|
|
12118
|
+
existing_additions = Array(existing_expression.arguments&.arguments).first
|
|
12119
|
+
desired_groups = gemspec_files_normalize_dir_globs_for_array(template_parts.fetch(:groups), template_parts)
|
|
12120
|
+
if existing_additions.is_a?(::Prism::ArrayNode) &&
|
|
12121
|
+
desired_groups.map { |group| group.fetch(:node).slice }.all? { |source| existing_additions.elements.any? { |node| node.slice == source } }
|
|
12122
|
+
return normalize_gemspec_receiver(
|
|
12123
|
+
destination_record.fetch(:source).rstrip,
|
|
12124
|
+
from: destination_receiver,
|
|
12125
|
+
to: template_receiver
|
|
12126
|
+
) + "\n"
|
|
12127
|
+
end
|
|
12128
|
+
end
|
|
12129
|
+
end
|
|
12130
|
+
candidate_name = if variable.is_a?(::Prism::LocalVariableReadNode)
|
|
12131
|
+
variable.name
|
|
12132
|
+
elsif variable.is_a?(::Prism::CallNode) && variable.receiver.nil? && variable.arguments.nil? && variable.block.nil?
|
|
12133
|
+
variable.name
|
|
12134
|
+
end
|
|
12135
|
+
return unless arguments.length == 1 && candidate_name
|
|
12136
|
+
|
|
12137
|
+
candidate_assignment = prism_parse_success(destination_content)&.value&.breadth_first_search_all do |node|
|
|
12138
|
+
node.is_a?(::Prism::LocalVariableWriteNode) && node.name == candidate_name
|
|
12139
|
+
end&.first
|
|
12140
|
+
return unless candidate_assignment&.value
|
|
12141
|
+
|
|
12142
|
+
additions = gemspec_files_normalize_dir_globs_for_array(template_parts.fetch(:groups), template_parts)
|
|
12143
|
+
indent = destination_record.fetch(:source)[/\A\s*/].to_s
|
|
12144
|
+
addition_source = additions.map { |group| "#{indent} #{group.fetch(:node).slice}" }.join(",\n")
|
|
12145
|
+
candidate_source = candidate_assignment.value.slice
|
|
12146
|
+
filter_source = arguments.first.slice
|
|
12147
|
+
expression = "(#{candidate_source} + [\n#{addition_source}\n#{indent}]).grep_v(#{filter_source})"
|
|
12148
|
+
normalize_gemspec_receiver(
|
|
12149
|
+
destination_record.fetch(:source).sub(assignment.slice, expression).rstrip,
|
|
12150
|
+
from: destination_receiver,
|
|
12151
|
+
to: template_receiver
|
|
12152
|
+
) + "\n"
|
|
12153
|
+
end
|
|
12154
|
+
|
|
11758
12155
|
def insert_missing_gemspec_files_assignment(content, template_content:, template_receiver:)
|
|
11759
12156
|
return content if gemspec_assignment_records(content, receiver: template_receiver).any? { |record| record.fetch(:field) == "files" }
|
|
11760
12157
|
|
|
@@ -11955,6 +12352,9 @@ module Kettle
|
|
|
11955
12352
|
|
|
11956
12353
|
def gemspec_files_collection_parts(record)
|
|
11957
12354
|
value_node = record.fetch(:value_node)
|
|
12355
|
+
if value_node.is_a?(::Prism::CallNode) && value_node.name == :grep_v && !value_node.block
|
|
12356
|
+
return gemspec_files_collection_parts(record.merge(value_node: value_node.receiver))
|
|
12357
|
+
end
|
|
11958
12358
|
if gemspec_files_concat_call_node?(value_node)
|
|
11959
12359
|
return gemspec_files_concat_collection_parts(record, value_node)
|
|
11960
12360
|
end
|
|
@@ -13695,6 +14095,14 @@ module Kettle
|
|
|
13695
14095
|
" Rakefile:",
|
|
13696
14096
|
" strategy: accept_template"
|
|
13697
14097
|
]
|
|
14098
|
+
if normalize_template_profile(profile) == MONOREPO_SUBGEM_RELEASE_TEMPLATE_PROFILE
|
|
14099
|
+
override_lines.concat([
|
|
14100
|
+
" .gitignore:",
|
|
14101
|
+
" strategy: merge",
|
|
14102
|
+
" preference: destination",
|
|
14103
|
+
" add_template_only_nodes: true"
|
|
14104
|
+
])
|
|
14105
|
+
end
|
|
13698
14106
|
gemspec = gemspec_path.to_s.strip
|
|
13699
14107
|
unless gemspec.empty?
|
|
13700
14108
|
override_lines.concat([
|
|
@@ -14961,6 +15369,7 @@ module Kettle
|
|
|
14961
15369
|
"KJ|CI:EXEC_CMD" => facts.dig(:ci, :exec_cmd).to_s,
|
|
14962
15370
|
"KJ|CI:OS_MATRIX_ENTRIES" => github_actions_current_os_matrix_entries(facts),
|
|
14963
15371
|
"KJ|CI:OS_TEST_STEPS" => github_actions_current_os_test_steps(facts),
|
|
15372
|
+
"KJ|CI:MACOS_HARDENING_STEP" => github_actions_macos_hardening_step(facts),
|
|
14964
15373
|
"KJ|README:CURRENT_MRI_PLATFORMS" => readme_current_mri_platforms(facts),
|
|
14965
15374
|
"KJ|RAKE:TOP_LEVEL_DOCS_TASK" => rake_top_level_docs_task_token(facts).rstrip,
|
|
14966
15375
|
"KJ|GITHUB_ACTIONS:COVERAGE_UPLOAD_STEPS" => github_actions_coverage_steps(disabled_integrations: facts.dig(:integrations, :disabled))
|
|
@@ -15397,11 +15806,11 @@ module Kettle
|
|
|
15397
15806
|
token_config = token_config_values(config)
|
|
15398
15807
|
author_config = token_config["author"].is_a?(Hash) ? token_config["author"] : {}
|
|
15399
15808
|
aliases = author_aliases(config)
|
|
15400
|
-
|
|
15401
|
-
|
|
15402
|
-
end
|
|
15809
|
+
machine_users = copyright_machine_users(config)
|
|
15810
|
+
derived_name = author_names(gemspec_metadata, {}, nil, author_aliases: aliases, machine_users: machine_users).first
|
|
15403
15811
|
derived_email = Array(gemspec_metadata[:email]).map(&:to_s).find { |value| present_template_token_value?(value) }
|
|
15404
15812
|
name = preferred_template_token_value(derived_name, author_config["name"], env, "KJ_AUTHOR_NAME").to_s
|
|
15813
|
+
name = "" if copyright_bot_entry?(name: name) || copyright_machine_user_entry?({name: name}, machine_users, author_aliases: aliases)
|
|
15405
15814
|
email = preferred_template_token_value(derived_email, author_config["email"], env, "KJ_AUTHOR_EMAIL").to_s
|
|
15406
15815
|
given_names = preferred_template_token_value(author_given_names(name), author_config["given_names"], env, "KJ_AUTHOR_GIVEN_NAMES")
|
|
15407
15816
|
family_names = preferred_template_token_value(author_family_names(name), author_config["family_names"], env, "KJ_AUTHOR_FAMILY_NAMES")
|
|
@@ -15409,7 +15818,7 @@ module Kettle
|
|
|
15409
15818
|
orcid = preferred_template_token_value(nil, author_config["orcid"], env, "KJ_AUTHOR_ORCID")
|
|
15410
15819
|
compact_hash(
|
|
15411
15820
|
name: name,
|
|
15412
|
-
names: author_names(gemspec_metadata, copyright, name, author_aliases: aliases),
|
|
15821
|
+
names: author_names(gemspec_metadata, copyright, name, author_aliases: aliases, machine_users: machine_users),
|
|
15413
15822
|
given_names: given_names.to_s,
|
|
15414
15823
|
family_names: family_names.to_s,
|
|
15415
15824
|
email: email,
|
|
@@ -15444,13 +15853,13 @@ module Kettle
|
|
|
15444
15853
|
end
|
|
15445
15854
|
|
|
15446
15855
|
def author_aliases(config)
|
|
15447
|
-
|
|
15856
|
+
config = {} unless config.is_a?(Hash)
|
|
15448
15857
|
|
|
15449
15858
|
configured = config["author_aliases"]
|
|
15450
15859
|
configured = config.dig("copyright", "author_aliases") if configured.nil? && config["copyright"].is_a?(Hash)
|
|
15451
|
-
|
|
15860
|
+
configured = {} unless configured.is_a?(Hash)
|
|
15452
15861
|
|
|
15453
|
-
configured.each_with_object(
|
|
15862
|
+
configured.each_with_object(DEFAULT_AUTHOR_ALIASES.dup) do |(alias_name, canonical_name), aliases|
|
|
15454
15863
|
alias_key = alias_name.to_s.strip.downcase
|
|
15455
15864
|
canonical = canonical_name.to_s.strip
|
|
15456
15865
|
next if alias_key.empty? || canonical.empty?
|
|
@@ -15497,13 +15906,16 @@ module Kettle
|
|
|
15497
15906
|
}
|
|
15498
15907
|
end
|
|
15499
15908
|
|
|
15500
|
-
def author_names(gemspec_metadata, copyright, primary_name, author_aliases: {})
|
|
15909
|
+
def author_names(gemspec_metadata, copyright, primary_name, author_aliases: {}, machine_users: DEFAULT_MACHINE_USERS.map(&:downcase))
|
|
15501
15910
|
names = Array(gemspec_metadata[:authors]).map(&:to_s)
|
|
15502
15911
|
names += copyright_author_names(copyright)
|
|
15503
15912
|
names = names
|
|
15913
|
+
.reject { |name| copyright_bot_entry?(name: name) || copyright_machine_user_entry?({name: name}, machine_users, author_aliases: author_aliases) }
|
|
15504
15914
|
.map { |name| canonical_author_name(name, author_aliases) }
|
|
15915
|
+
.reject { |name| copyright_bot_entry?(name: name) || copyright_machine_user_entry?({name: name}, machine_users, author_aliases: author_aliases) }
|
|
15505
15916
|
.select { |name| present_template_token_value?(name) }
|
|
15506
|
-
|
|
15917
|
+
fallback = canonical_author_name(primary_name, author_aliases)
|
|
15918
|
+
names = [fallback] if names.empty? && !copyright_bot_entry?(name: fallback) && !copyright_machine_user_entry?({name: fallback}, machine_users, author_aliases: author_aliases)
|
|
15507
15919
|
names.map(&:strip).reject(&:empty?).uniq
|
|
15508
15920
|
end
|
|
15509
15921
|
|
|
@@ -16162,7 +16574,7 @@ module Kettle
|
|
|
16162
16574
|
def main_gemfile_kettle_family_gem(package_name)
|
|
16163
16575
|
return "" if package_name.to_s == "kettle-family"
|
|
16164
16576
|
|
|
16165
|
-
%(gem "kettle-family", "~> 1.3", ">= 1.3.
|
|
16577
|
+
%(gem "kettle-family", "~> 1.3", ">= 1.3.48"\n)
|
|
16166
16578
|
end
|
|
16167
16579
|
|
|
16168
16580
|
def main_gemfile_nomono_bootstrap(package_name)
|
|
@@ -16175,7 +16587,7 @@ module Kettle
|
|
|
16175
16587
|
end
|
|
16176
16588
|
|
|
16177
16589
|
def nomono_gemfile_declaration
|
|
16178
|
-
%(gem "nomono", "~> 1.1", ">= 1.1.
|
|
16590
|
+
%(gem "nomono", "~> 1.1", ">= 1.1.18", require: false # ruby >= 3.2.0)
|
|
16179
16591
|
end
|
|
16180
16592
|
|
|
16181
16593
|
def local_gemfile_nomono_bootstrap(_package_name)
|
|
@@ -17239,6 +17651,20 @@ module Kettle
|
|
|
17239
17651
|
end
|
|
17240
17652
|
end
|
|
17241
17653
|
|
|
17654
|
+
def existing_version_constant_path(project_root, relative_path, namespace)
|
|
17655
|
+
content = read_project_file(project_root, relative_path)
|
|
17656
|
+
return "Version::VERSION" unless content
|
|
17657
|
+
|
|
17658
|
+
nested_version = ruby_namespace_declaration_node(content, "#{namespace}::Version")
|
|
17659
|
+
return "Version::VERSION" if nested_version
|
|
17660
|
+
|
|
17661
|
+
namespace_node = ruby_namespace_declaration_node(content, namespace)
|
|
17662
|
+
direct_version = namespace_node&.body&.body&.any? do |node|
|
|
17663
|
+
node.is_a?(::Prism::ConstantWriteNode) && node.name == :VERSION
|
|
17664
|
+
end
|
|
17665
|
+
direct_version ? "VERSION" : "Version::VERSION"
|
|
17666
|
+
end
|
|
17667
|
+
|
|
17242
17668
|
def existing_version_namespace_superclasses(project_root, relative_path, namespace, entrypoint_path: nil)
|
|
17243
17669
|
contents = [read_project_file(project_root, relative_path)]
|
|
17244
17670
|
contents << read_project_file(project_root, entrypoint_path) if entrypoint_path
|
|
@@ -17715,10 +18141,39 @@ module Kettle
|
|
|
17715
18141
|
|
|
17716
18142
|
def readme_corporate_sponsors_facts(config, env)
|
|
17717
18143
|
sponsors = readme_corporate_sponsors(config, env)
|
|
18144
|
+
today = Date.today
|
|
18145
|
+
active = sponsors.select { |sponsor| readme_corporate_sponsor_active?(sponsor, today) }.map do |sponsor|
|
|
18146
|
+
next sponsor unless sponsor[:members]
|
|
18147
|
+
|
|
18148
|
+
sponsor.merge(members: sponsor[:members].select { |member| readme_corporate_sponsor_active?(member, today) })
|
|
18149
|
+
end
|
|
18150
|
+
past = sponsors.select { |sponsor| readme_corporate_sponsor_past?(sponsor, today) }
|
|
18151
|
+
past_links = past.map do |sponsor|
|
|
18152
|
+
link = "[#{sponsor.fetch(:name)}](#{sponsor.fetch(:url)})"
|
|
18153
|
+
members = Array(sponsor[:members]).select { |member| !member[:since] || member[:since] <= today }
|
|
18154
|
+
unless members.empty?
|
|
18155
|
+
links = members.map { |member| "[#{member.fetch(:name)}](#{member.fetch(:url)})" }.join(", ")
|
|
18156
|
+
link = "#{link} (backed by #{links})"
|
|
18157
|
+
end
|
|
18158
|
+
link
|
|
18159
|
+
end
|
|
18160
|
+
sponsors.each do |sponsor|
|
|
18161
|
+
next unless readme_corporate_sponsor_active?(sponsor, today)
|
|
18162
|
+
|
|
18163
|
+
members = Array(sponsor[:members]).select { |member| readme_corporate_sponsor_past?(member, today) }
|
|
18164
|
+
next if members.empty?
|
|
18165
|
+
|
|
18166
|
+
links = members.map { |member| "[#{member.fetch(:name)}](#{member.fetch(:url)})" }.join(", ")
|
|
18167
|
+
past_links << "#{links} (formerly backing [#{sponsor.fetch(:name)}](#{sponsor.fetch(:url)}))"
|
|
18168
|
+
end
|
|
18169
|
+
detail = readme_corporate_sponsors_detail(active)
|
|
18170
|
+
past_detail = past_links.empty? ? "" : "Past sponsors: #{past_links.join(", ")}"
|
|
17718
18171
|
compact_hash(
|
|
17719
|
-
entries:
|
|
17720
|
-
|
|
17721
|
-
|
|
18172
|
+
entries: active,
|
|
18173
|
+
past_entries: past,
|
|
18174
|
+
row: readme_corporate_sponsors_row(active),
|
|
18175
|
+
detail: [detail, past_detail].reject(&:empty?).join("\n\n"),
|
|
18176
|
+
past_detail: past_detail
|
|
17722
18177
|
)
|
|
17723
18178
|
end
|
|
17724
18179
|
|
|
@@ -17728,15 +18183,11 @@ module Kettle
|
|
|
17728
18183
|
readme_config["corporate_sponsors"] || readme_config["sponsors"]
|
|
17729
18184
|
)
|
|
17730
18185
|
inherited = normalize_readme_corporate_sponsors_json(env["KETTLE_JEM_CORPORATE_SPONSORS_JSON"])
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
sponsors
|
|
17734
|
-
.select { |sponsor| readme_corporate_sponsor_active?(sponsor, today) }
|
|
17735
|
-
.map do |sponsor|
|
|
17736
|
-
next sponsor unless sponsor[:members]
|
|
18186
|
+
deduplicate_readme_corporate_sponsors(configured + inherited)
|
|
18187
|
+
end
|
|
17737
18188
|
|
|
17738
|
-
|
|
17739
|
-
|
|
18189
|
+
def readme_corporate_sponsor_past?(sponsor, today)
|
|
18190
|
+
(!sponsor[:since] || sponsor[:since] <= today) && sponsor[:until] && sponsor[:until] < today
|
|
17740
18191
|
end
|
|
17741
18192
|
|
|
17742
18193
|
def readme_corporate_sponsor_active?(sponsor, today)
|
|
@@ -19040,11 +19491,11 @@ module Kettle
|
|
|
19040
19491
|
aliased_readme_destination_section(base, destination_lookup, preserve_config)
|
|
19041
19492
|
next unless destination_section
|
|
19042
19493
|
|
|
19043
|
-
"#{section.fetch(:heading)}\n#{destination_section
|
|
19494
|
+
"#{section.fetch(:heading)}\n#{readme_preserved_section_body(destination_section, destination_sections, template_bases)}"
|
|
19044
19495
|
else
|
|
19045
19496
|
lines[section.fetch(:start)..section.fetch(:end)].join("\n")
|
|
19046
19497
|
end
|
|
19047
|
-
replacement = ([replacement] + extra_sections.map { |extra| "#{extra.fetch(:heading)}\n#{extra
|
|
19498
|
+
replacement = ([replacement] + extra_sections.map { |extra| "#{extra.fetch(:heading)}\n#{readme_preserved_section_body(extra, destination_sections, template_bases)}" }).join("\n")
|
|
19048
19499
|
lines[section.fetch(:start)..section.fetch(:end)] = replacement
|
|
19049
19500
|
end
|
|
19050
19501
|
lines.join("\n")
|
|
@@ -19058,7 +19509,8 @@ module Kettle
|
|
|
19058
19509
|
next if readme_section_has_preserved_ancestor?(destination_sections, index, preserve_targets)
|
|
19059
19510
|
|
|
19060
19511
|
anchor = destination_sections[0...index].reverse.find do |candidate|
|
|
19061
|
-
template_bases.include?(candidate.fetch(:base))
|
|
19512
|
+
template_bases.include?(candidate.fetch(:base)) &&
|
|
19513
|
+
candidate.fetch(:level).to_i <= section.fetch(:level).to_i
|
|
19062
19514
|
end
|
|
19063
19515
|
next unless anchor
|
|
19064
19516
|
|
|
@@ -19067,6 +19519,27 @@ module Kettle
|
|
|
19067
19519
|
end
|
|
19068
19520
|
end
|
|
19069
19521
|
|
|
19522
|
+
# Body of a preserved destination section with any nested template-owned
|
|
19523
|
+
# subsections removed. A section's line range spans its nested children,
|
|
19524
|
+
# so without this the preserved body would re-inject sections the template
|
|
19525
|
+
# also renders, duplicating them on every merge.
|
|
19526
|
+
def readme_preserved_section_body(section, destination_sections, template_bases)
|
|
19527
|
+
nested = destination_sections.select do |candidate|
|
|
19528
|
+
candidate.fetch(:start) > section.fetch(:start) &&
|
|
19529
|
+
candidate.fetch(:end) <= section.fetch(:end) &&
|
|
19530
|
+
candidate.fetch(:level).to_i > section.fetch(:level).to_i &&
|
|
19531
|
+
template_bases.include?(candidate.fetch(:base))
|
|
19532
|
+
end
|
|
19533
|
+
return section.fetch(:body) if nested.empty?
|
|
19534
|
+
|
|
19535
|
+
offset = section.fetch(:start) + 1
|
|
19536
|
+
body_lines = section.fetch(:body).split("\n", -1)
|
|
19537
|
+
nested.reverse_each do |candidate|
|
|
19538
|
+
body_lines[(candidate.fetch(:start) - offset)..(candidate.fetch(:end) - offset)] = []
|
|
19539
|
+
end
|
|
19540
|
+
body_lines.join("\n").gsub(/\n{3,}/, "\n\n").rstrip
|
|
19541
|
+
end
|
|
19542
|
+
|
|
19070
19543
|
def readme_section_has_preserved_ancestor?(sections, index, preserve_targets)
|
|
19071
19544
|
section = sections.fetch(index)
|
|
19072
19545
|
section_level = section.fetch(:level).to_i
|
|
@@ -19383,6 +19856,8 @@ module Kettle
|
|
|
19383
19856
|
target.end_with?("/version.rb", "/version.rbs")
|
|
19384
19857
|
end
|
|
19385
19858
|
|
|
19859
|
+
# Cleanup uses the same canonical bucket relevance as template selection and
|
|
19860
|
+
# keeps references reachable from surviving loaders.
|
|
19386
19861
|
def inactive_packaged_template_cleanup_files(project_root, config = {})
|
|
19387
19862
|
gemfile_cleanups = Dir.glob(File.join(project_root, "gemfiles/**/*.gemfile")).filter_map do |path|
|
|
19388
19863
|
relative_path = path.delete_prefix("#{project_root}/")
|
|
@@ -19390,6 +19865,12 @@ module Kettle
|
|
|
19390
19865
|
|
|
19391
19866
|
{target_path: relative_path} if skip_packaged_gemfile_template?(relative_path, config)
|
|
19392
19867
|
end
|
|
19868
|
+
# The old formatter path used r3.3 as a lower bound. It is no longer a
|
|
19869
|
+
# canonical bucket; the reference guard protects existing loaders during migration.
|
|
19870
|
+
legacy_formatter = "gemfiles/modular/rspec_junit_formatter/r3.3/v0.8.gemfile"
|
|
19871
|
+
if File.file?(File.join(project_root, legacy_formatter))
|
|
19872
|
+
gemfile_cleanups << {target_path: legacy_formatter}
|
|
19873
|
+
end
|
|
19393
19874
|
gemfile_cleanups = reject_loader_referenced_gemfile_cleanups(project_root, gemfile_cleanups)
|
|
19394
19875
|
(gemfile_cleanups + disabled_integration_config_cleanups(project_root, config)).sort_by { |cleanup| cleanup.fetch(:target_path) }
|
|
19395
19876
|
end
|
|
@@ -19423,7 +19904,7 @@ module Kettle
|
|
|
19423
19904
|
# exactly the closure the committed loader needs.
|
|
19424
19905
|
def loader_referenced_gemfile_closure(project_root, deletable)
|
|
19425
19906
|
root = File.expand_path(project_root.to_s)
|
|
19426
|
-
raw_prefix = "#{project_root.to_s.chomp(
|
|
19907
|
+
raw_prefix = "#{project_root.to_s.chomp("/")}/"
|
|
19427
19908
|
queue = Dir.glob(File.join(root, "gemfiles/**/*.gemfile")).map { |path| path.delete_prefix("#{root}/").delete_prefix(raw_prefix) }
|
|
19428
19909
|
main_gemfile = File.join(root, "Gemfile")
|
|
19429
19910
|
queue << "Gemfile" if File.file?(main_gemfile)
|
|
@@ -19632,7 +20113,7 @@ module Kettle
|
|
|
19632
20113
|
end
|
|
19633
20114
|
|
|
19634
20115
|
def template_strategy_config(config, target_path)
|
|
19635
|
-
template_file_strategy_config(config, target_path) || template_pattern_strategy_config(config, target_path)
|
|
20116
|
+
template_file_strategy_config(config, target_path) || template_preference_only_file_config(config, target_path) || template_pattern_strategy_config(config, target_path)
|
|
19636
20117
|
end
|
|
19637
20118
|
|
|
19638
20119
|
def template_file_strategy_config(config, target_path)
|
|
@@ -19652,6 +20133,21 @@ module Kettle
|
|
|
19652
20133
|
template_strategy_entry(config, nil, current)
|
|
19653
20134
|
end
|
|
19654
20135
|
|
|
20136
|
+
def template_preference_only_file_config(config, target_path)
|
|
20137
|
+
files = config["files"]
|
|
20138
|
+
return unless files.is_a?(Hash)
|
|
20139
|
+
|
|
20140
|
+
current = target_path.to_s.delete_prefix("./").split("/").reduce(files) do |memo, part|
|
|
20141
|
+
if memo.is_a?(Hash) && memo.key?(part)
|
|
20142
|
+
memo[part]
|
|
20143
|
+
end
|
|
20144
|
+
end
|
|
20145
|
+
return unless current.is_a?(Hash) && !current.key?("strategy")
|
|
20146
|
+
return unless current.keys.any? { |key| %w[preference add_template_only_nodes file_type].include?(key) }
|
|
20147
|
+
|
|
20148
|
+
template_strategy_entry(config, nil, current.merge("strategy" => "merge"))
|
|
20149
|
+
end
|
|
20150
|
+
|
|
19655
20151
|
def template_pattern_strategy_config(config, target_path)
|
|
19656
20152
|
patterns = config["patterns"]
|
|
19657
20153
|
return unless patterns.is_a?(Array)
|
|
@@ -19667,6 +20163,7 @@ module Kettle
|
|
|
19667
20163
|
|
|
19668
20164
|
def template_strategy_entry(config, path, entry)
|
|
19669
20165
|
strategy = entry["strategy"].to_s.strip.downcase.to_sym
|
|
20166
|
+
strategy = :merge if strategy == :""
|
|
19670
20167
|
raise ArgumentError, "unknown kettle-jem template strategy: #{entry["strategy"]}" unless SUPPORTED_TEMPLATE_STRATEGIES.include?(strategy)
|
|
19671
20168
|
|
|
19672
20169
|
result = {strategy: strategy}
|
|
@@ -19774,6 +20271,8 @@ module Kettle
|
|
|
19774
20271
|
engine = Kettle::Rb::CompatMatrix.engine_workflow(basename)
|
|
19775
20272
|
return true if engine && !enabled_ruby_engines(config).include?(engine)
|
|
19776
20273
|
|
|
20274
|
+
return true if EOL_ENGINE_WORKFLOWS.include?(basename) && !legacy_engine_workflow_opted_in?(config, basename)
|
|
20275
|
+
|
|
19777
20276
|
version = basename[/\Aruby-(\d+\.\d+)\z/, 1]
|
|
19778
20277
|
return false unless version && min_ruby
|
|
19779
20278
|
Gem::Version.new(version) < min_ruby
|
|
@@ -19792,6 +20291,20 @@ module Kettle
|
|
|
19792
20291
|
return !relevant.include?(x_std_bucket)
|
|
19793
20292
|
end
|
|
19794
20293
|
|
|
20294
|
+
# A bucket's range depends on all sibling bucket names, not its name alone.
|
|
20295
|
+
# Kettle::Rb::RubySeriesBuckets is the canonical definition.
|
|
20296
|
+
path = target_path.to_s
|
|
20297
|
+
if (match = path.match(%r{\Agemfiles/modular/([^/]+)/(r\d+(?:\.\d+)?)/}))
|
|
20298
|
+
bucket_root = File.join(template_root_path.to_s, "gemfiles/modular", match[1])
|
|
20299
|
+
buckets = Dir.glob(File.join(bucket_root, "r*")).select { |entry| File.directory?(entry) }
|
|
20300
|
+
.map { |entry| File.basename(entry) }.select { |name| ruby_bucket_path_segment?(name) }
|
|
20301
|
+
if buckets.include?(match[2])
|
|
20302
|
+
minimum = config_test_min_ruby(config)
|
|
20303
|
+
return false unless minimum
|
|
20304
|
+
return !Kettle::Rb::RubySeriesBuckets.relevant_buckets(buckets, minimum: minimum).include?(match[2])
|
|
20305
|
+
end
|
|
20306
|
+
end
|
|
20307
|
+
|
|
19795
20308
|
version = packaged_gemfile_template_ruby_floor(target_path)
|
|
19796
20309
|
return false unless version
|
|
19797
20310
|
|
|
@@ -19801,6 +20314,8 @@ module Kettle
|
|
|
19801
20314
|
Gem::Version.new(version) < min_ruby
|
|
19802
20315
|
end
|
|
19803
20316
|
|
|
20317
|
+
# Inventory the complete x_std_lib bucket set for the canonical ranges in
|
|
20318
|
+
# Kettle::Rb::RubySeriesBuckets, including transitively loaded templates.
|
|
19804
20319
|
def packaged_x_std_lib_template_inventory(template_root_path)
|
|
19805
20320
|
root_key = File.expand_path(template_root_path.to_s)
|
|
19806
20321
|
if root_key == File.expand_path(PACKAGED_TEMPLATE_ROOT)
|
|
@@ -19876,7 +20391,7 @@ module Kettle
|
|
|
19876
20391
|
return "#{match[1]}.#{match[2]}"
|
|
19877
20392
|
end
|
|
19878
20393
|
|
|
19879
|
-
|
|
20394
|
+
nil
|
|
19880
20395
|
end
|
|
19881
20396
|
|
|
19882
20397
|
def enabled_ruby_engines(config)
|
|
@@ -20255,6 +20770,84 @@ module Kettle
|
|
|
20255
20770
|
# A generated workflow normally uses one command for every matrix entry.
|
|
20256
20771
|
# Legacy engines occasionally need a narrower command while retaining the
|
|
20257
20772
|
# rest of the generated workflow (setup, retries, cache keys, and pins).
|
|
20773
|
+
LEGACY_ENGINE_MODES = %w[parallel serial experimental].freeze
|
|
20774
|
+
SERIAL_TEST_RUNNER_ENV = "env KETTLE_TEST_RUNNER=rspec"
|
|
20775
|
+
|
|
20776
|
+
# `workflows.legacy_engines` opts EOL engine workflows back in. Either a
|
|
20777
|
+
# list of workflow names (`- truffleruby-24.2`) or a map keyed by them:
|
|
20778
|
+
#
|
|
20779
|
+
# legacy_engines:
|
|
20780
|
+
# truffleruby-24.2:
|
|
20781
|
+
# mode: experimental # parallel (default) | serial | experimental
|
|
20782
|
+
# tracking: https://github.com/org/repo/issues/1
|
|
20783
|
+
# revisit_by: 2027-03-01 # warn once this date has passed
|
|
20784
|
+
#
|
|
20785
|
+
# serial runs the engine's job with `KETTLE_TEST_RUNNER=rspec` (no parallel
|
|
20786
|
+
# worker pool); experimental adds `experimental: true` to its matrix entry
|
|
20787
|
+
# so a failure does not fail the workflow.
|
|
20788
|
+
def legacy_engine_settings(config)
|
|
20789
|
+
workflows = config["workflows"]
|
|
20790
|
+
return {} unless workflows.is_a?(Hash)
|
|
20791
|
+
|
|
20792
|
+
raw = workflows["legacy_engines"]
|
|
20793
|
+
entries = raw.is_a?(Hash) ? raw : Array(raw).to_h { |name| [name, {}] }
|
|
20794
|
+
entries.each_with_object({}) do |(name, value), settings|
|
|
20795
|
+
key = name.to_s.strip.delete_suffix(".yml")
|
|
20796
|
+
next if key.empty?
|
|
20797
|
+
|
|
20798
|
+
value = {} unless value.is_a?(Hash)
|
|
20799
|
+
mode = value["mode"].to_s.strip.downcase
|
|
20800
|
+
mode = "parallel" unless LEGACY_ENGINE_MODES.include?(mode)
|
|
20801
|
+
settings[key] = {
|
|
20802
|
+
mode: mode,
|
|
20803
|
+
tracking: value["tracking"].to_s.strip,
|
|
20804
|
+
revisit_by: value["revisit_by"].to_s.strip
|
|
20805
|
+
}
|
|
20806
|
+
end
|
|
20807
|
+
end
|
|
20808
|
+
|
|
20809
|
+
def legacy_engine_workflow_opted_in?(config, basename)
|
|
20810
|
+
legacy_engine_settings(config).key?(basename)
|
|
20811
|
+
end
|
|
20812
|
+
|
|
20813
|
+
# Serial legacy engines become exec_cmd overrides, unless the project set an
|
|
20814
|
+
# explicit `engine_exec_cmds` entry for the same matrix value.
|
|
20815
|
+
def legacy_engine_exec_cmds(config, base_exec_cmd)
|
|
20816
|
+
legacy_engine_settings(config).each_with_object({}) do |(name, setting), overrides|
|
|
20817
|
+
next unless setting.fetch(:mode) == "serial"
|
|
20818
|
+
|
|
20819
|
+
overrides[name] = "#{SERIAL_TEST_RUNNER_ENV} #{base_exec_cmd}".strip
|
|
20820
|
+
end
|
|
20821
|
+
end
|
|
20822
|
+
|
|
20823
|
+
def legacy_engine_experimental_names(config)
|
|
20824
|
+
legacy_engine_settings(config).select { |_name, setting| setting.fetch(:mode) == "experimental" }.keys
|
|
20825
|
+
end
|
|
20826
|
+
|
|
20827
|
+
# Template-run notes: workflows about to be deleted as EOL (so the change is
|
|
20828
|
+
# never silent), and opted-in engines whose revisit_by date has passed.
|
|
20829
|
+
def legacy_engine_warnings(config, removed_workflow_paths, today: Date.today)
|
|
20830
|
+
removed = Array(removed_workflow_paths).filter_map do |path|
|
|
20831
|
+
basename = File.basename(path.to_s, ".yml")
|
|
20832
|
+
next unless EOL_ENGINE_WORKFLOWS.include?(basename)
|
|
20833
|
+
|
|
20834
|
+
"EOL engine workflow #{basename} is no longer generated; #{path} is removed. " \
|
|
20835
|
+
"Keep it with `workflows.legacy_engines: [#{basename}]` if you still want it."
|
|
20836
|
+
end
|
|
20837
|
+
overdue = legacy_engine_settings(config).filter_map do |name, setting|
|
|
20838
|
+
date = begin
|
|
20839
|
+
Date.iso8601(setting.fetch(:revisit_by))
|
|
20840
|
+
rescue ArgumentError, TypeError
|
|
20841
|
+
nil
|
|
20842
|
+
end
|
|
20843
|
+
next unless date && date < today
|
|
20844
|
+
|
|
20845
|
+
tracking = setting.fetch(:tracking).empty? ? "" : " (#{setting.fetch(:tracking)})"
|
|
20846
|
+
"legacy engine #{name}: revisit_by #{date} has passed#{tracking}; drop it from workflows.legacy_engines or extend the date."
|
|
20847
|
+
end
|
|
20848
|
+
removed + overdue
|
|
20849
|
+
end
|
|
20850
|
+
|
|
20258
20851
|
def github_actions_engine_exec_cmds(config)
|
|
20259
20852
|
workflows = config["workflows"]
|
|
20260
20853
|
return {} unless workflows.is_a?(Hash)
|
|
@@ -20936,6 +21529,38 @@ module Kettle
|
|
|
20936
21529
|
end.join("\n")
|
|
20937
21530
|
end
|
|
20938
21531
|
|
|
21532
|
+
MACOS_CA_HARDENING_SCRIPT = File.expand_path("jem/ci/harden_macos_ca_bundle.sh", __dir__)
|
|
21533
|
+
private_constant :MACOS_CA_HARDENING_SCRIPT
|
|
21534
|
+
|
|
21535
|
+
# The first step of current.yml's test job when macos is a declared platform:
|
|
21536
|
+
# removes the eMudhra-related roots Apple still ships in /etc/ssl/cert.pem
|
|
21537
|
+
# (https://github.com/galadran/we-have-a-problem.com/issues/157). The script is
|
|
21538
|
+
# inlined, not fetched or run from the repo, because it has to run before the
|
|
21539
|
+
# first download, and actions/checkout runs git. Like the Windows guard, the
|
|
21540
|
+
# step exists only when its platform is declared, so no dead `if:` is emitted
|
|
21541
|
+
# for linux-only or linux+windows destinations. Returns the step plus a blank
|
|
21542
|
+
# line, or "" so the token vanishes without leaving a stray line behind. The
|
|
21543
|
+
# script is a copy of structuredmerge/structuredmerge
|
|
21544
|
+
# workspace-scripts/harden_macos_ca_bundle.sh (tested there against a bundle
|
|
21545
|
+
# containing an eMudhra root).
|
|
21546
|
+
def github_actions_macos_hardening_step(facts)
|
|
21547
|
+
platforms = facts.dig(:ci, :platforms)
|
|
21548
|
+
platforms = DEFAULT_PLATFORMS if platforms.nil? || platforms.empty?
|
|
21549
|
+
return "" unless platforms.include?("macos")
|
|
21550
|
+
|
|
21551
|
+
header = [
|
|
21552
|
+
" - name: Remove eMudhra roots from the macOS CA bundle",
|
|
21553
|
+
" if: runner.os == 'macOS'",
|
|
21554
|
+
" shell: bash",
|
|
21555
|
+
" run: |"
|
|
21556
|
+
]
|
|
21557
|
+
script = File.read(MACOS_CA_HARDENING_SCRIPT).rstrip.lines(chomp: true).map do |line|
|
|
21558
|
+
line.empty? ? "" : " #{line}"
|
|
21559
|
+
end
|
|
21560
|
+
|
|
21561
|
+
"#{(header + script).join("\n")}\n\n"
|
|
21562
|
+
end
|
|
21563
|
+
|
|
20939
21564
|
# The current.yml test steps, generated from the same platforms facts. The
|
|
20940
21565
|
# Windows-only guard and step exist only when windows is declared, so no
|
|
20941
21566
|
# tautological `if:` survives in a linux+macos destination (spec slice
|
|
@@ -21061,7 +21686,7 @@ module Kettle
|
|
|
21061
21686
|
steps << <<~YAML
|
|
21062
21687
|
- name: Upload coverage to QLTY
|
|
21063
21688
|
if: ${{ !env.ACT }}
|
|
21064
|
-
uses: qltysh/qlty-action/coverage@
|
|
21689
|
+
uses: qltysh/qlty-action/coverage@56bee2d751c94b7bd8de22f64c9b5f398048e13f # v2.8.1
|
|
21065
21690
|
with:
|
|
21066
21691
|
oidc: true
|
|
21067
21692
|
files: coverage/lcov.info
|
|
@@ -21356,22 +21981,22 @@ module Kettle
|
|
|
21356
21981
|
"actions/checkout" => "actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1",
|
|
21357
21982
|
"actions/cache" => "actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0",
|
|
21358
21983
|
"appraisal-rb/setup-ruby-flash" => "appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14",
|
|
21359
|
-
"ruby/setup-ruby" => "ruby/setup-ruby@
|
|
21984
|
+
"ruby/setup-ruby" => "ruby/setup-ruby@78c62f2208e480ce3d5ae4dfd9b9e181acf48b63 # v1.344.0",
|
|
21360
21985
|
"coverallsapp/github-action" => "coverallsapp/github-action@8d6379e14d29928660c4ba802d8e85393440b329 # v2.3.8",
|
|
21361
|
-
"qltysh/qlty-action/coverage" => "qltysh/qlty-action/coverage@
|
|
21986
|
+
"qltysh/qlty-action/coverage" => "qltysh/qlty-action/coverage@56bee2d751c94b7bd8de22f64c9b5f398048e13f # v2.8.1",
|
|
21362
21987
|
"codecov/codecov-action" => "codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1",
|
|
21363
21988
|
"irongut/CodeCoverageSummary" => "irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0",
|
|
21364
21989
|
"marocchino/sticky-pull-request-comment" => "marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5",
|
|
21365
21990
|
"actions/upload-artifact" => "actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2",
|
|
21366
21991
|
"actions/download-artifact" => "actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2",
|
|
21367
21992
|
"amancevice/setup-code-climate" => "amancevice/setup-code-climate@0daf2985a225e8ac15975b4d233010e94d65b76a # v2",
|
|
21368
|
-
"actions/dependency-review-action" => "actions/dependency-review-action@
|
|
21369
|
-
"github/codeql-action/init" => "github/codeql-action/init@
|
|
21370
|
-
"github/codeql-action/autobuild" => "github/codeql-action/autobuild@
|
|
21371
|
-
"github/codeql-action/analyze" => "github/codeql-action/analyze@
|
|
21993
|
+
"actions/dependency-review-action" => "actions/dependency-review-action@bbc44d14a204704ccc493733616cd1e93a0321ec # v5.0.1",
|
|
21994
|
+
"github/codeql-action/init" => "github/codeql-action/init@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5",
|
|
21995
|
+
"github/codeql-action/autobuild" => "github/codeql-action/autobuild@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5",
|
|
21996
|
+
"github/codeql-action/analyze" => "github/codeql-action/analyze@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5",
|
|
21372
21997
|
"pozil/auto-assign-issue" => "pozil/auto-assign-issue@d6e511896e5f1d2408e74db74416647d8ff80c8c # v4.1.0",
|
|
21373
21998
|
"apache/skywalking-eyes/dependency" => "apache/skywalking-eyes/dependency@a196742f472feaffafea537ce5a2a4c3c53a8de4 # v0.9.0",
|
|
21374
|
-
"sarisia/actions-status-discord" => "sarisia/actions-status-discord@
|
|
21999
|
+
"sarisia/actions-status-discord" => "sarisia/actions-status-discord@74e2ad0c4e57ca8b9ba6aee75d5a7841497bbb87 # v1.16.1"
|
|
21375
22000
|
}
|
|
21376
22001
|
end
|
|
21377
22002
|
|