pray-cli 1.26.3 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/pray/format_serialize.rb +9 -1
- data/lib/pray/manifest_parser_helpers.rb +30 -5
- data/lib/pray/resolve.rb +15 -9
- data/lib/pray/resolve_context.rb +3 -2
- data/lib/pray/resolve_host_sources.rb +41 -0
- data/lib/pray/source_root_locator/cargo_packages.rb +48 -0
- data/lib/pray/source_root_locator.rb +151 -0
- data/lib/pray/upstream.rb +2 -1
- data/lib/pray/upstream_drift.rb +2 -1
- data/lib/pray/upstream_latest.rb +6 -2
- data/lib/pray/upstream_plan.rb +4 -3
- data/lib/pray/upstream_refresh.rb +16 -10
- data/lib/pray/version.rb +2 -2
- data/lib/pray.rb +2 -0
- data/pray-cli.gemspec +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2150c637eae1a409a7004342084cd394cb528b59daed1faa1247ae05aecad82e
|
|
4
|
+
data.tar.gz: e5d65887f4799841bdebbf0dd2a61f12bdf7c74e4ee79cc07707ee4f7614180c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ead87229f277e8baa9f180e7527c57ad849baf19e6582c8e36e49a448a5f4a8fd4fa7eb577d607c711c9c6f9a3793d3566cb925c4d1092c5cda8501a45d970ce
|
|
7
|
+
data.tar.gz: 073b2f311d410ed0dbaeffa524145012767394a213d385a6a1a15a0644899ab8910e4faeeaf5338801600531f88b23fc157e163b3d2874c3cccb44b4a2d655b2
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 1.27.0 (2026-12-02)
|
|
6
|
+
|
|
7
|
+
- Let `pray install` use prayers from installed RubyGems, npm, Cargo, Hex, and PyPI packages declared in Prayfile (RFC 0122, experimental).
|
|
8
|
+
|
|
5
9
|
## 1.26.3 (2026-11-12)
|
|
6
10
|
|
|
7
11
|
- Allow `pray install` to refresh the lock when a managed span already matches the fresh render but the lock ideal is stale. Keep failing when the on-disk body matches neither, and name move-aside recovery instead of a force flag.
|
|
@@ -105,10 +105,18 @@ module Pray
|
|
|
105
105
|
when "git"
|
|
106
106
|
url = source.url.delete_prefix("git+")
|
|
107
107
|
parts << %(git: "#{url}")
|
|
108
|
+
when *SourceRootLocator::HOST_SOURCE_KINDS
|
|
109
|
+
parts << %(#{source.kind}: "#{source.url}")
|
|
108
110
|
else
|
|
109
111
|
parts << %("#{source.url}")
|
|
110
112
|
end
|
|
111
|
-
|
|
113
|
+
if source.subdir
|
|
114
|
+
parts << if SourceRootLocator.host_source_kind?(source.kind)
|
|
115
|
+
%(subdir: "#{source.subdir}")
|
|
116
|
+
else
|
|
117
|
+
%(distribution: "#{source.subdir}")
|
|
118
|
+
end
|
|
119
|
+
end
|
|
112
120
|
parts << %(tag: "#{source.tag}") if source.tag
|
|
113
121
|
parts << %(rev: "#{source.rev}") if source.rev
|
|
114
122
|
parts.join(", ")
|
|
@@ -51,22 +51,37 @@ module Pray
|
|
|
51
51
|
def parse_source(rest)
|
|
52
52
|
values, keywords = parse_call(rest)
|
|
53
53
|
raise Error.parse("manifest", "source requires a name") if values.empty?
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
host_keyword = SourceRootLocator.host_manager_keywords.find { |keyword| keywords.key?(keyword) }
|
|
55
|
+
if values.length < 2 && !keywords.key?("path") && !keywords.key?("git") && host_keyword.nil?
|
|
56
|
+
raise Error.parse(
|
|
57
|
+
"manifest",
|
|
58
|
+
"source requires a name and url, path:, git:, or a host package keyword"
|
|
59
|
+
)
|
|
56
60
|
end
|
|
57
61
|
|
|
58
|
-
kind, url = source_kind_and_url(values, keywords)
|
|
62
|
+
kind, url = source_kind_and_url(values, keywords, host_keyword)
|
|
63
|
+
subdir = keyword_string(keywords, "subdir") || keyword_string(keywords, "distribution")
|
|
64
|
+
SourceRootLocator.validate_host_subdir!(subdir) if subdir && SourceRootLocator.host_source_kind?(kind)
|
|
59
65
|
ManifestSource.new(
|
|
60
66
|
name: string_from_value(values.first),
|
|
61
67
|
kind: kind,
|
|
62
68
|
url: url,
|
|
63
|
-
subdir:
|
|
69
|
+
subdir: subdir,
|
|
64
70
|
rev: keyword_string(keywords, "rev"),
|
|
65
71
|
tag: keyword_string(keywords, "tag")
|
|
66
72
|
)
|
|
67
73
|
end
|
|
68
74
|
|
|
69
|
-
def source_kind_and_url(values, keywords)
|
|
75
|
+
def source_kind_and_url(values, keywords, host_keyword)
|
|
76
|
+
if host_keyword
|
|
77
|
+
reject_combined_host_keywords!(values, keywords, host_keyword)
|
|
78
|
+
value = keywords.fetch(host_keyword)
|
|
79
|
+
unless value.kind == :string
|
|
80
|
+
raise Error.parse("manifest", "#{host_keyword}: requires a package name string")
|
|
81
|
+
end
|
|
82
|
+
SourceRootLocator.validate_host_package_name!(host_keyword, value.as_string)
|
|
83
|
+
return [host_keyword, value.as_string]
|
|
84
|
+
end
|
|
70
85
|
if keywords["path"]
|
|
71
86
|
return ["path", string_from_value(keywords["path"])]
|
|
72
87
|
end
|
|
@@ -80,6 +95,16 @@ module Pray
|
|
|
80
95
|
[infer_source_kind(url), url]
|
|
81
96
|
end
|
|
82
97
|
|
|
98
|
+
def reject_combined_host_keywords!(values, keywords, manager)
|
|
99
|
+
if values.length > 1 || keywords.key?("path") || keywords.key?("git")
|
|
100
|
+
raise Error.parse("manifest", "#{manager}: cannot combine with a URL, path:, or git:")
|
|
101
|
+
end
|
|
102
|
+
others = SourceRootLocator.host_manager_keywords.count do |keyword|
|
|
103
|
+
keyword != manager && keywords.key?(keyword)
|
|
104
|
+
end
|
|
105
|
+
raise Error.parse("manifest", "source accepts only one host package keyword") if others.positive?
|
|
106
|
+
end
|
|
107
|
+
|
|
83
108
|
def infer_source_kind(url)
|
|
84
109
|
return "git" if url.start_with?("git+")
|
|
85
110
|
return "pray_ssh" if url.start_with?("pray+ssh://", "ssh+pray://")
|
data/lib/pray/resolve.rb
CHANGED
|
@@ -62,6 +62,7 @@ module Pray
|
|
|
62
62
|
refresh: options.refresh || options.refresh_source_revisions,
|
|
63
63
|
offline: options.offline
|
|
64
64
|
)
|
|
65
|
+
host_sources = HostSourceSet.new(project_root, options)
|
|
65
66
|
source_host_keys = Trust.prepare_source_host_keys(manifest.sources)
|
|
66
67
|
|
|
67
68
|
packages = []
|
|
@@ -72,6 +73,7 @@ module Pray
|
|
|
72
73
|
project_root,
|
|
73
74
|
sources,
|
|
74
75
|
git_sources,
|
|
76
|
+
host_sources,
|
|
75
77
|
user_config,
|
|
76
78
|
declaration,
|
|
77
79
|
lockfile_hints,
|
|
@@ -101,7 +103,7 @@ module Pray
|
|
|
101
103
|
|
|
102
104
|
ResolveDeps.reject_dependency_cycles(packages)
|
|
103
105
|
ResolveDeps.validate_optional_referrals(packages)
|
|
104
|
-
source_revisions = git_sources.revisions
|
|
106
|
+
source_revisions = git_sources.revisions.merge(host_sources.versions)
|
|
105
107
|
|
|
106
108
|
ResolvedProject.new(
|
|
107
109
|
manifest_path: manifest_path,
|
|
@@ -149,10 +151,10 @@ module Pray
|
|
|
149
151
|
GitRefresh.resolution_may_benefit_from_git_source_refresh?(error)
|
|
150
152
|
end
|
|
151
153
|
|
|
152
|
-
def resolve_package(project_root, sources, git_sources, user_config, declaration, lockfile, offline: false, options: nil)
|
|
154
|
+
def resolve_package(project_root, sources, git_sources, host_sources, user_config, declaration, lockfile, offline: false, options: nil)
|
|
153
155
|
options ||= ResolveOptions.new(offline: offline)
|
|
154
|
-
root, registry_latest_version = resolve_package_root_with_metadata(
|
|
155
|
-
project_root, sources, git_sources, user_config, declaration, lockfile, options
|
|
156
|
+
root, registry_latest_version, artifact = resolve_package_root_with_metadata(
|
|
157
|
+
project_root, sources, git_sources, host_sources, user_config, declaration, lockfile, options
|
|
156
158
|
)
|
|
157
159
|
spec_path = find_prayspec_file(root)
|
|
158
160
|
spec_text = SourcePath.read(root, File.basename(spec_path), "package specification").force_encoding(Encoding::UTF_8)
|
|
@@ -176,7 +178,7 @@ module Pray
|
|
|
176
178
|
spec: spec,
|
|
177
179
|
tree_hash: tree_hash,
|
|
178
180
|
artifact_hash: tree_hash,
|
|
179
|
-
artifact: "path:#{File.dirname(spec_path)}",
|
|
181
|
+
artifact: artifact || "path:#{File.dirname(spec_path)}",
|
|
180
182
|
selected_exports: selected_exports,
|
|
181
183
|
source_checksum: tree_hash,
|
|
182
184
|
export_bodies: export_bodies,
|
|
@@ -184,13 +186,13 @@ module Pray
|
|
|
184
186
|
signer_fingerprint: nil,
|
|
185
187
|
registry_latest_version: registry_latest_version,
|
|
186
188
|
upstream: Upstream.lock_path(
|
|
187
|
-
project_root, sources, git_sources, user_config, declaration, spec, lockfile, options
|
|
189
|
+
project_root, sources, git_sources, host_sources, user_config, declaration, spec, lockfile, options
|
|
188
190
|
)
|
|
189
191
|
)
|
|
190
192
|
end
|
|
191
193
|
|
|
192
194
|
def resolve_package_root_with_metadata(
|
|
193
|
-
project_root, sources, git_sources, user_config, declaration, lockfile, options = nil
|
|
195
|
+
project_root, sources, git_sources, host_sources, user_config, declaration, lockfile, options = nil
|
|
194
196
|
)
|
|
195
197
|
options ||= ResolveOptions.new
|
|
196
198
|
offline = options.offline
|
|
@@ -225,6 +227,8 @@ module Pray
|
|
|
225
227
|
directory = LocalPrayer.path_source_package_directory(source_name, declaration.name)
|
|
226
228
|
relative = File.join(source.url, directory)
|
|
227
229
|
return [SourcePath.declared_directory(project_root, relative, "package directory"), nil]
|
|
230
|
+
when *SourceRootLocator::HOST_SOURCE_KINDS
|
|
231
|
+
return host_sources.package_root(source, declaration.name)
|
|
228
232
|
when "registry", "static index"
|
|
229
233
|
resolved = Registry.resolve_registry_package_root(
|
|
230
234
|
project_root,
|
|
@@ -272,8 +276,10 @@ module Pray
|
|
|
272
276
|
[SourcePath.declared_directory(project_root, slug, "package directory"), nil]
|
|
273
277
|
end
|
|
274
278
|
|
|
275
|
-
def resolve_package_root(project_root, sources, git_sources, user_config, declaration, lockfile = nil)
|
|
276
|
-
resolve_package_root_with_metadata(
|
|
279
|
+
def resolve_package_root(project_root, sources, git_sources, host_sources, user_config, declaration, lockfile = nil)
|
|
280
|
+
resolve_package_root_with_metadata(
|
|
281
|
+
project_root, sources, git_sources, host_sources, user_config, declaration, lockfile
|
|
282
|
+
).first
|
|
277
283
|
end
|
|
278
284
|
|
|
279
285
|
def find_prayspec_file(root)
|
data/lib/pray/resolve_context.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Pray
|
|
4
4
|
ResolveOptions = Struct.new(
|
|
5
5
|
:offline, :refresh, :unlocked_packages, :refresh_source_revisions,
|
|
6
|
-
:ignore_locked_versions, :environment
|
|
6
|
+
:ignore_locked_versions, :environment, :host_packages
|
|
7
7
|
) do
|
|
8
8
|
def initialize(
|
|
9
9
|
offline: false,
|
|
@@ -11,7 +11,8 @@ module Pray
|
|
|
11
11
|
unlocked_packages: Set.new,
|
|
12
12
|
refresh_source_revisions: false,
|
|
13
13
|
ignore_locked_versions: false,
|
|
14
|
-
environment: nil
|
|
14
|
+
environment: nil,
|
|
15
|
+
host_packages: {}
|
|
15
16
|
)
|
|
16
17
|
super
|
|
17
18
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pray
|
|
4
|
+
class HostSourceSet
|
|
5
|
+
def initialize(project_root, options)
|
|
6
|
+
@project_root = project_root
|
|
7
|
+
@options = options
|
|
8
|
+
@cargo_packages = SourceRootLocator::CargoPackages.new
|
|
9
|
+
@locations = {}
|
|
10
|
+
@prayers_roots = {}
|
|
11
|
+
@versions = {}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def package_root(source, package_name)
|
|
15
|
+
directory = LocalPrayer.path_source_package_directory(source.name, package_name)
|
|
16
|
+
if directory == "." || !SourceRootLocator.host_relative_path?(directory)
|
|
17
|
+
raise Error.resolution("invalid host prayer package name")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
subdir = source.subdir || SourceRootLocator::DEFAULT_HOST_PRAYERS_SUBDIR
|
|
21
|
+
artifact = "host:#{source.kind}:#{source.url}/#{subdir}/#{directory}"
|
|
22
|
+
[SourcePath.declared_directory(prayers_root(source), directory, "package directory"), nil, artifact]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def versions
|
|
26
|
+
@versions.dup
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def prayers_root(source)
|
|
32
|
+
@prayers_roots[source.name] ||= begin
|
|
33
|
+
key = [source.kind, source.url]
|
|
34
|
+
location = @locations[key] ||= SourceRootLocator.locate_host_package(@project_root, *key, @options, @cargo_packages)
|
|
35
|
+
root = SourceRootLocator.host_prayers_directory(location, *key, source.subdir)
|
|
36
|
+
@versions[source.name] = location.version if location.version
|
|
37
|
+
root
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pray
|
|
4
|
+
module SourceRootLocator
|
|
5
|
+
class CargoPackages
|
|
6
|
+
def locate(project_root, name)
|
|
7
|
+
packages = @packages ||= read_packages(project_root)
|
|
8
|
+
return packages[name] if packages[name]
|
|
9
|
+
if packages.key?(name)
|
|
10
|
+
raise Error.resolution("crate package #{name} has multiple entries in the project install tree")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
raise SourceRootLocator.missing_host_package("crate", name)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def read_packages(project_root)
|
|
19
|
+
stdout, _stderr, status = Open3.capture3(
|
|
20
|
+
"cargo", "metadata", "--format-version", "1", "--frozen", chdir: project_root
|
|
21
|
+
)
|
|
22
|
+
return {} unless status.success?
|
|
23
|
+
|
|
24
|
+
metadata = JSON.parse(stdout)
|
|
25
|
+
return {} unless metadata.is_a?(Hash) && metadata["packages"].is_a?(Array)
|
|
26
|
+
|
|
27
|
+
metadata["packages"].each_with_object({}) do |entry, packages|
|
|
28
|
+
next unless entry.is_a?(Hash) && entry["name"].is_a?(String)
|
|
29
|
+
|
|
30
|
+
manifest = entry["manifest_path"]
|
|
31
|
+
next unless manifest.is_a?(String) && Pathname.new(manifest).absolute?
|
|
32
|
+
|
|
33
|
+
name = entry["name"]
|
|
34
|
+
packages[name] = if packages.key?(name)
|
|
35
|
+
nil
|
|
36
|
+
else
|
|
37
|
+
HostPackageLocation.new(
|
|
38
|
+
install_root: File.dirname(manifest),
|
|
39
|
+
version: entry["version"].is_a?(String) ? entry["version"] : nil
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
rescue Errno::ENOENT, JSON::ParserError
|
|
44
|
+
{}
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require "open3"
|
|
5
|
+
require "pathname"
|
|
6
|
+
|
|
7
|
+
module Pray
|
|
8
|
+
module SourceRootLocator
|
|
9
|
+
DEFAULT_HOST_PRAYERS_SUBDIR = "prayers"
|
|
10
|
+
HOST_SOURCE_KINDS = %w[gem npm crate hex pypi].freeze
|
|
11
|
+
|
|
12
|
+
HostPackageLocation = Struct.new(:install_root, :version, keyword_init: true)
|
|
13
|
+
|
|
14
|
+
module_function
|
|
15
|
+
|
|
16
|
+
def host_source_kind?(kind)
|
|
17
|
+
HOST_SOURCE_KINDS.include?(kind)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def host_manager_keywords
|
|
21
|
+
HOST_SOURCE_KINDS
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def validate_host_package_name!(kind, name)
|
|
25
|
+
pattern = if kind == "npm" && name.start_with?("@")
|
|
26
|
+
/\A@[a-z0-9_][\w.-]*\/[a-z0-9_][\w.-]*\z/i
|
|
27
|
+
else
|
|
28
|
+
/\A[a-z0-9_][\w.-]*\z/i
|
|
29
|
+
end
|
|
30
|
+
return if pattern.match?(name) && !name.include?("./") && !name.end_with?(".")
|
|
31
|
+
|
|
32
|
+
raise Error.parse("manifest", "#{kind}: invalid package name")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def host_relative_path?(path)
|
|
36
|
+
!path.strip.empty? && !path.start_with?("/") && !path.match?(/[\\:"<>|?*]/) &&
|
|
37
|
+
path.bytes.none? { |byte| byte < 32 } && path.split("/").none? { |part| part != "." && part.end_with?(".", " ") }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def validate_host_subdir!(subdir)
|
|
41
|
+
return if host_relative_path?(subdir)
|
|
42
|
+
|
|
43
|
+
raise Error.parse("manifest", "subdir must be a portable relative path")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def locate_host_package(project_root, kind, package_name, options, cargo_packages)
|
|
47
|
+
validate_host_package_name!(kind, package_name)
|
|
48
|
+
key = [kind, package_name]
|
|
49
|
+
override = options.host_packages[key]
|
|
50
|
+
return override if override
|
|
51
|
+
|
|
52
|
+
case kind
|
|
53
|
+
when "gem" then probe_gem(project_root, package_name)
|
|
54
|
+
when "npm" then probe_npm(project_root, package_name)
|
|
55
|
+
when "crate" then cargo_packages.locate(project_root, package_name)
|
|
56
|
+
when "hex" then probe_hex(project_root, package_name)
|
|
57
|
+
when "pypi" then probe_pypi(project_root, package_name)
|
|
58
|
+
else
|
|
59
|
+
raise Error.unsupported("source kind #{kind} is not a host package locator")
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def host_prayers_directory(location, kind, package_name, subdir)
|
|
64
|
+
relative = subdir || DEFAULT_HOST_PRAYERS_SUBDIR
|
|
65
|
+
validate_host_subdir!(relative)
|
|
66
|
+
label = "#{kind} package #{package_name} prayers directory"
|
|
67
|
+
directory = SourcePath.declared_directory(location.install_root, relative, label)
|
|
68
|
+
raise Error.resolution("#{label} was not found: #{relative}") unless File.directory?(directory)
|
|
69
|
+
|
|
70
|
+
directory
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def probe_gem(project_root, package_name)
|
|
74
|
+
gemfile = project_gemfile(project_root)
|
|
75
|
+
raise missing_host_package("gem", package_name) unless gemfile
|
|
76
|
+
|
|
77
|
+
env = defined?(Bundler) ? Bundler.unbundled_env : ENV.to_h
|
|
78
|
+
env["BUNDLE_FROZEN"] = "true"
|
|
79
|
+
env["BUNDLE_GEMFILE"] = gemfile.to_s
|
|
80
|
+
stdout = probe_metadata(
|
|
81
|
+
"gem", package_name, project_root, "bundle", "info", package_name,
|
|
82
|
+
env: env, unsetenv_others: true
|
|
83
|
+
)
|
|
84
|
+
install_root = stdout.lines.reverse_each.find { |line| line.start_with?("\tPath: ") }&.delete_prefix("\tPath: ")&.chomp
|
|
85
|
+
unless install_root && Pathname.new(install_root).absolute? && File.directory?(install_root)
|
|
86
|
+
raise missing_host_package("gem", package_name)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
heading = "* #{package_name} ("
|
|
90
|
+
version = stdout.each_line.map(&:strip).find { |line| line.start_with?(heading) && line.end_with?(")") }
|
|
91
|
+
HostPackageLocation.new(install_root: install_root, version: version&.delete_prefix(heading)&.delete_suffix(")")&.split&.first)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def project_gemfile(project_root)
|
|
95
|
+
Pathname.new(project_root).ascend.lazy.flat_map { |directory|
|
|
96
|
+
[directory.join("Gemfile"), directory.join("gems.rb")]
|
|
97
|
+
}.find(&:file?)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def probe_npm(project_root, package_name)
|
|
101
|
+
candidate = File.join(project_root, "node_modules", package_name)
|
|
102
|
+
raise missing_host_package("npm", package_name) unless File.directory?(candidate)
|
|
103
|
+
|
|
104
|
+
version = begin
|
|
105
|
+
metadata = JSON.parse(File.read(File.join(candidate, "package.json")))
|
|
106
|
+
metadata["version"] if metadata.is_a?(Hash) && metadata["version"].is_a?(String)
|
|
107
|
+
rescue SystemCallError, JSON::ParserError
|
|
108
|
+
nil
|
|
109
|
+
end
|
|
110
|
+
HostPackageLocation.new(install_root: candidate, version: version)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def probe_hex(project_root, package_name)
|
|
114
|
+
candidate = File.join(project_root, "deps", package_name)
|
|
115
|
+
raise missing_host_package("hex", package_name) unless File.directory?(candidate)
|
|
116
|
+
|
|
117
|
+
HostPackageLocation.new(install_root: candidate, version: nil)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def probe_pypi(project_root, package_name)
|
|
121
|
+
stdout = probe_metadata("pypi", package_name, project_root, "pip", "show", package_name)
|
|
122
|
+
location = metadata_field(stdout, "Location:")
|
|
123
|
+
raise missing_host_package("pypi", package_name) unless location && Pathname.new(location).absolute?
|
|
124
|
+
|
|
125
|
+
module_name = package_name.downcase.split(/[-_.]+/).reject(&:empty?).join("_")
|
|
126
|
+
install_root = File.join(location, module_name)
|
|
127
|
+
raise missing_host_package("pypi", package_name) unless File.directory?(install_root)
|
|
128
|
+
|
|
129
|
+
HostPackageLocation.new(install_root: install_root, version: metadata_field(stdout, "Version:"))
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def metadata_field(text, label)
|
|
133
|
+
text.each_line.map(&:lstrip).find { |line| line.start_with?(label) }&.delete_prefix(label)&.strip
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def probe_metadata(kind, name, project_root, *command, env: {}, unsetenv_others: false)
|
|
137
|
+
stdout, _stderr, status = Open3.capture3(env, *command, chdir: project_root, unsetenv_others: unsetenv_others)
|
|
138
|
+
raise missing_host_package(kind, name) unless status.success?
|
|
139
|
+
|
|
140
|
+
stdout
|
|
141
|
+
rescue Errno::ENOENT
|
|
142
|
+
raise missing_host_package(kind, name)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def missing_host_package(kind, package_name)
|
|
146
|
+
Error.resolution("#{kind} package #{package_name} was not found in the project install tree")
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
require_relative "source_root_locator/cargo_packages"
|
data/lib/pray/upstream.rb
CHANGED
|
@@ -27,7 +27,7 @@ module Pray
|
|
|
27
27
|
)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
def lock_path(project_root, sources, git_sources, user_config, declaration, spec, lockfile, options)
|
|
30
|
+
def lock_path(project_root, sources, git_sources, host_sources, user_config, declaration, spec, lockfile, options)
|
|
31
31
|
return nil unless spec.upstream
|
|
32
32
|
if spec.name == spec.upstream.name
|
|
33
33
|
raise Error.resolution("package #{spec.name} cannot use itself as upstream")
|
|
@@ -41,6 +41,7 @@ module Pray
|
|
|
41
41
|
project_root,
|
|
42
42
|
sources,
|
|
43
43
|
git_sources,
|
|
44
|
+
host_sources,
|
|
44
45
|
user_config,
|
|
45
46
|
ManifestPackage.new(
|
|
46
47
|
name: name,
|
data/lib/pray/upstream_drift.rb
CHANGED
|
@@ -13,6 +13,7 @@ module Pray
|
|
|
13
13
|
refresh: options.refresh || options.refresh_source_revisions,
|
|
14
14
|
offline: options.offline
|
|
15
15
|
)
|
|
16
|
+
host_sources = HostSourceSet.new(project.project_root, options)
|
|
16
17
|
sources = Resolve.source_map(project.manifest.sources)
|
|
17
18
|
lines = []
|
|
18
19
|
project.packages.each do |package|
|
|
@@ -21,7 +22,7 @@ module Pray
|
|
|
21
22
|
|
|
22
23
|
upstream = package.upstream
|
|
23
24
|
resolved = resolve_named(
|
|
24
|
-
project.project_root, sources, git_sources, user_config, previous, options,
|
|
25
|
+
project.project_root, sources, git_sources, host_sources, user_config, previous, options,
|
|
25
26
|
upstream.name, "= #{upstream.version}", upstream.source
|
|
26
27
|
)
|
|
27
28
|
upstream_content = content_file_bytes(resolved.root, resolved.spec)
|
data/lib/pray/upstream_latest.rb
CHANGED
|
@@ -18,12 +18,15 @@ module Pray
|
|
|
18
18
|
refresh: options.refresh || options.refresh_source_revisions,
|
|
19
19
|
offline: options.offline
|
|
20
20
|
)
|
|
21
|
+
host_sources = HostSourceSet.new(project.project_root, options)
|
|
21
22
|
sources = Resolve.source_map(project.manifest.sources)
|
|
22
23
|
plans = []
|
|
23
24
|
project.packages.each do |package|
|
|
24
25
|
next if selected && package.declaration.name != selected
|
|
25
26
|
|
|
26
|
-
plan = plan_one_path_upstream(
|
|
27
|
+
plan = plan_one_path_upstream(
|
|
28
|
+
project, package, sources, git_sources, host_sources, user_config, previous, options
|
|
29
|
+
)
|
|
27
30
|
plans << plan if plan
|
|
28
31
|
end
|
|
29
32
|
plans
|
|
@@ -52,7 +55,7 @@ module Pray
|
|
|
52
55
|
derived
|
|
53
56
|
end
|
|
54
57
|
|
|
55
|
-
def plan_one_path_upstream(project, package, sources, git_sources, user_config, lockfile, options)
|
|
58
|
+
def plan_one_path_upstream(project, package, sources, git_sources, host_sources, user_config, lockfile, options)
|
|
56
59
|
upstream = package.spec.upstream
|
|
57
60
|
return unless upstream && package.declaration.path
|
|
58
61
|
|
|
@@ -61,6 +64,7 @@ module Pray
|
|
|
61
64
|
project.project_root,
|
|
62
65
|
sources,
|
|
63
66
|
git_sources,
|
|
67
|
+
host_sources,
|
|
64
68
|
user_config,
|
|
65
69
|
ManifestPackage.new(name: upstream.name, constraint: "*", source: source),
|
|
66
70
|
lockfile,
|
data/lib/pray/upstream_plan.rb
CHANGED
|
@@ -22,13 +22,14 @@ module Pray
|
|
|
22
22
|
refresh: options.refresh || options.refresh_source_revisions,
|
|
23
23
|
offline: options.offline
|
|
24
24
|
)
|
|
25
|
+
host_sources = HostSourceSet.new(project.project_root, options)
|
|
25
26
|
sources = Resolve.source_map(project.manifest.sources)
|
|
26
27
|
conflicts = []
|
|
27
28
|
project.packages.each do |package|
|
|
28
29
|
next if selected && package.declaration.name != selected
|
|
29
30
|
|
|
30
31
|
conflict = plan_one_path_upstream_conflict(
|
|
31
|
-
project, package, previous, sources, git_sources, user_config, options
|
|
32
|
+
project, package, previous, sources, git_sources, host_sources, user_config, options
|
|
32
33
|
)
|
|
33
34
|
conflicts << conflict if conflict
|
|
34
35
|
end
|
|
@@ -52,7 +53,7 @@ module Pray
|
|
|
52
53
|
raise Error.resolution(messages.join("\n"))
|
|
53
54
|
end
|
|
54
55
|
|
|
55
|
-
def plan_one_path_upstream_conflict(project, package, previous, sources, git_sources, user_config, options)
|
|
56
|
+
def plan_one_path_upstream_conflict(project, package, previous, sources, git_sources, host_sources, user_config, options)
|
|
56
57
|
new_upstream = package.upstream
|
|
57
58
|
return nil unless new_upstream && package.declaration.path
|
|
58
59
|
|
|
@@ -64,7 +65,7 @@ module Pray
|
|
|
64
65
|
return nil if old_upstream.version == new_upstream.version && old_upstream.tree_hash == new_upstream.tree_hash
|
|
65
66
|
|
|
66
67
|
old_package, new_package = resolve_upstream_pair(
|
|
67
|
-
project, previous, sources, git_sources, user_config, options, old_upstream, new_upstream
|
|
68
|
+
project, previous, sources, git_sources, host_sources, user_config, options, old_upstream, new_upstream
|
|
68
69
|
)
|
|
69
70
|
old_content = content_file_bytes(old_package.root, old_package.spec)
|
|
70
71
|
new_content = content_file_bytes(new_package.root, new_package.spec)
|
|
@@ -13,24 +13,29 @@ module Pray
|
|
|
13
13
|
refresh: options.refresh || options.refresh_source_revisions,
|
|
14
14
|
offline: options.offline
|
|
15
15
|
)
|
|
16
|
+
host_sources = HostSourceSet.new(project.project_root, options)
|
|
16
17
|
sources = Resolve.source_map(project.manifest.sources)
|
|
17
18
|
changed = false
|
|
18
19
|
project.packages.each do |package|
|
|
19
20
|
next if selected && package.declaration.name != selected
|
|
20
|
-
next unless apply_one_path_upstream(
|
|
21
|
+
next unless apply_one_path_upstream(
|
|
22
|
+
project, package, previous, sources, git_sources, host_sources, user_config, options
|
|
23
|
+
)
|
|
21
24
|
|
|
22
25
|
changed = true
|
|
23
26
|
end
|
|
24
27
|
changed
|
|
25
28
|
end
|
|
26
29
|
|
|
27
|
-
def apply_one_path_upstream(project, package, previous, sources, git_sources, user_config, options)
|
|
30
|
+
def apply_one_path_upstream(project, package, previous, sources, git_sources, host_sources, user_config, options)
|
|
28
31
|
new_upstream = package.upstream
|
|
29
32
|
return false unless new_upstream && package.declaration.path
|
|
30
33
|
|
|
31
34
|
local_content = local_content_for_refresh(package.root, package.spec)
|
|
32
35
|
if local_content.empty?
|
|
33
|
-
return materialize_empty_path_fork(
|
|
36
|
+
return materialize_empty_path_fork(
|
|
37
|
+
project, package, previous, sources, git_sources, host_sources, user_config, options, new_upstream
|
|
38
|
+
)
|
|
34
39
|
end
|
|
35
40
|
|
|
36
41
|
old_upstream = previous&.package&.find { |entry| entry.name == package.declaration.name }&.upstream
|
|
@@ -38,7 +43,7 @@ module Pray
|
|
|
38
43
|
return false if old_upstream.version == new_upstream.version && old_upstream.tree_hash == new_upstream.tree_hash
|
|
39
44
|
|
|
40
45
|
old_package, new_package = resolve_upstream_pair(
|
|
41
|
-
project, previous, sources, git_sources, user_config, options, old_upstream, new_upstream
|
|
46
|
+
project, previous, sources, git_sources, host_sources, user_config, options, old_upstream, new_upstream
|
|
42
47
|
)
|
|
43
48
|
old_content, local_content, merged = merge_fork_content(package, old_upstream, new_upstream, old_package, new_package)
|
|
44
49
|
write_content_files(package.root, old_content, merged)
|
|
@@ -46,9 +51,9 @@ module Pray
|
|
|
46
51
|
true
|
|
47
52
|
end
|
|
48
53
|
|
|
49
|
-
def materialize_empty_path_fork(project, package, previous, sources, git_sources, user_config, options, new_upstream)
|
|
54
|
+
def materialize_empty_path_fork(project, package, previous, sources, git_sources, host_sources, user_config, options, new_upstream)
|
|
50
55
|
new_package = resolve_named(
|
|
51
|
-
project.project_root, sources, git_sources, user_config, previous, options,
|
|
56
|
+
project.project_root, sources, git_sources, host_sources, user_config, previous, options,
|
|
52
57
|
new_upstream.name, "= #{new_upstream.version}", new_upstream.source
|
|
53
58
|
)
|
|
54
59
|
new_content = content_file_bytes(new_package.root, new_package.spec)
|
|
@@ -67,9 +72,9 @@ module Pray
|
|
|
67
72
|
content_file_bytes(root, spec)
|
|
68
73
|
end
|
|
69
74
|
|
|
70
|
-
def resolve_upstream_pair(project, previous, sources, git_sources, user_config, options, old_upstream, new_upstream)
|
|
75
|
+
def resolve_upstream_pair(project, previous, sources, git_sources, host_sources, user_config, options, old_upstream, new_upstream)
|
|
71
76
|
old_package = resolve_named(
|
|
72
|
-
project.project_root, sources, git_sources, user_config, previous, options,
|
|
77
|
+
project.project_root, sources, git_sources, host_sources, user_config, previous, options,
|
|
73
78
|
old_upstream.name, "= #{old_upstream.version}", old_upstream.source
|
|
74
79
|
)
|
|
75
80
|
resolved_old = LockedUpstream.new(
|
|
@@ -81,7 +86,7 @@ module Pray
|
|
|
81
86
|
)
|
|
82
87
|
ensure_locked_match!(old_upstream, resolved_old)
|
|
83
88
|
new_package = resolve_named(
|
|
84
|
-
project.project_root, sources, git_sources, user_config, previous, options,
|
|
89
|
+
project.project_root, sources, git_sources, host_sources, user_config, previous, options,
|
|
85
90
|
new_upstream.name, "= #{new_upstream.version}", new_upstream.source
|
|
86
91
|
)
|
|
87
92
|
[old_package, new_package]
|
|
@@ -113,11 +118,12 @@ module Pray
|
|
|
113
118
|
Transaction.write_file(spec_path, PackageSpecRender.render_package_spec(updated))
|
|
114
119
|
end
|
|
115
120
|
|
|
116
|
-
def resolve_named(project_root, sources, git_sources, user_config, lockfile, options, name, constraint, source)
|
|
121
|
+
def resolve_named(project_root, sources, git_sources, host_sources, user_config, lockfile, options, name, constraint, source)
|
|
117
122
|
Resolve.resolve_package(
|
|
118
123
|
project_root,
|
|
119
124
|
sources,
|
|
120
125
|
git_sources,
|
|
126
|
+
host_sources,
|
|
121
127
|
user_config,
|
|
122
128
|
ManifestPackage.new(name: name, constraint: constraint, source: source),
|
|
123
129
|
lockfile,
|
data/lib/pray/version.rb
CHANGED
data/lib/pray.rb
CHANGED
|
@@ -32,6 +32,8 @@ require_relative "pray/project_context"
|
|
|
32
32
|
require_relative "pray/environment"
|
|
33
33
|
require_relative "pray/resolve_context"
|
|
34
34
|
require_relative "pray/source_path"
|
|
35
|
+
require_relative "pray/source_root_locator"
|
|
36
|
+
require_relative "pray/resolve_host_sources"
|
|
35
37
|
require_relative "pray/resolve_source"
|
|
36
38
|
require_relative "pray/resolve_exports"
|
|
37
39
|
require_relative "pray/dependency_graph"
|
data/pray-cli.gemspec
CHANGED
|
@@ -43,6 +43,6 @@ Gem::Specification.new do |spec|
|
|
|
43
43
|
spec.add_dependency "base64", "~> 0.2"
|
|
44
44
|
|
|
45
45
|
spec.add_development_dependency "rspec", "~> 3.13"
|
|
46
|
-
spec.add_development_dependency "polyrun", "~>
|
|
46
|
+
spec.add_development_dependency "polyrun", "~> 3.1"
|
|
47
47
|
spec.add_development_dependency "rbs", "~> 4.0"
|
|
48
48
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pray-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.27.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrei Makarov
|
|
@@ -63,14 +63,14 @@ dependencies:
|
|
|
63
63
|
requirements:
|
|
64
64
|
- - "~>"
|
|
65
65
|
- !ruby/object:Gem::Version
|
|
66
|
-
version: '
|
|
66
|
+
version: '3.1'
|
|
67
67
|
type: :development
|
|
68
68
|
prerelease: false
|
|
69
69
|
version_requirements: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements:
|
|
71
71
|
- - "~>"
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
|
-
version: '
|
|
73
|
+
version: '3.1'
|
|
74
74
|
- !ruby/object:Gem::Dependency
|
|
75
75
|
name: rbs
|
|
76
76
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -192,6 +192,7 @@ files:
|
|
|
192
192
|
- lib/pray/resolve_context.rb
|
|
193
193
|
- lib/pray/resolve_deps.rb
|
|
194
194
|
- lib/pray/resolve_exports.rb
|
|
195
|
+
- lib/pray/resolve_host_sources.rb
|
|
195
196
|
- lib/pray/resolve_local.rb
|
|
196
197
|
- lib/pray/resolve_source.rb
|
|
197
198
|
- lib/pray/resolve_tarball.rb
|
|
@@ -201,6 +202,8 @@ files:
|
|
|
201
202
|
- lib/pray/serve_range.rb
|
|
202
203
|
- lib/pray/session.rb
|
|
203
204
|
- lib/pray/source_path.rb
|
|
205
|
+
- lib/pray/source_root_locator.rb
|
|
206
|
+
- lib/pray/source_root_locator/cargo_packages.rb
|
|
204
207
|
- lib/pray/ssh_agent.rb
|
|
205
208
|
- lib/pray/statement_surface.rb
|
|
206
209
|
- lib/pray/substitute.rb
|