captive-release 0.13.2 → 0.14.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8b6fb2c222824add2e6fe62b462240609b233535e610ef7bd70513bf6ff5f931
|
|
4
|
+
data.tar.gz: ffb5b3704f4a4a4a94cb31c6d2275683077a3437d0b8b841ac727a893d32ff2f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4045d5e368e362b1307a2f27ce16df74ff0c7f0fc1ae021b9d62af6673441deb0b7a66c8d9623a27ae10a46662f8b51d7214c2b8d32cd1878d5c490acf56e7cc
|
|
7
|
+
data.tar.gz: 6a3f85ea5c5da1e82a3131c10f4b6f0e0dd59ec744b8134b2d470b5c47b11b4dcfe37f227d1f74285e03cdfc41fdcaa7ac9d98e39a798c6e23f6a82886fe41b5
|
|
@@ -3,9 +3,23 @@
|
|
|
3
3
|
module CaptiveRelease
|
|
4
4
|
# Quels fichiers d'un dépôt portent une version, et sous quel format.
|
|
5
5
|
class VersionDetector
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
GRADLE_PATH = %w[android app build.gradle].freeze
|
|
7
|
+
CLAUDE_PLUGIN_PATH = %w[.claude-plugin plugin.json].freeze
|
|
8
|
+
|
|
9
|
+
# Où chercher, quel format y lire, et ce que le fichier doit contenir pour en être un.
|
|
10
|
+
RULES = [
|
|
11
|
+
[ %w[** package.json], "package_json" ],
|
|
12
|
+
[ %w[** app.config.js], "app_config_js" ],
|
|
13
|
+
[ %w[** app.json], "app_json", /"expo"\s*:.*"version"\s*:/m ],
|
|
14
|
+
[ %w[lib ** version.rb], "ruby_version", /VERSION\s*=\s*["'].+?["']/ ],
|
|
15
|
+
[ %w[** VERSION], "plain" ],
|
|
16
|
+
# Chemin fixe : un glob remonterait les build.gradle des modules Android embarqués, qui ne
|
|
17
|
+
# portent pas la version de l'app.
|
|
18
|
+
[ GRADLE_PATH, "android_gradle", /versionName\s+['"]/ ],
|
|
19
|
+
# Un dépôt publie un seul plugin : son manifeste est à la racine.
|
|
20
|
+
[ CLAUDE_PLUGIN_PATH, "claude_plugin", /"version"/ ],
|
|
21
|
+
[ %w[ios ** Info.plist], "ios_plist", /CFBundleShortVersionString/ ],
|
|
22
|
+
].freeze
|
|
9
23
|
|
|
10
24
|
def self.scan(root = ".")
|
|
11
25
|
new(root).scan
|
|
@@ -16,33 +30,15 @@ module CaptiveRelease
|
|
|
16
30
|
end
|
|
17
31
|
|
|
18
32
|
def scan
|
|
19
|
-
|
|
20
|
-
by_name("app.config.js", "app_config_js") +
|
|
21
|
-
by_content(%w[** app.json], "app_json", EXPO_APP_JSON_PATTERN) +
|
|
22
|
-
by_content(%w[lib ** version.rb], "ruby_version", RUBY_VERSION_PATTERN) +
|
|
23
|
-
by_name("VERSION", "plain") +
|
|
24
|
-
android_gradle +
|
|
25
|
-
by_content(%w[ios ** Info.plist], "ios_plist", /CFBundleShortVersionString/)
|
|
33
|
+
RULES.flat_map { |segments, type, pattern| detect(segments, type, pattern) }
|
|
26
34
|
end
|
|
27
35
|
|
|
28
36
|
private
|
|
29
37
|
|
|
30
|
-
def
|
|
31
|
-
@files.glob("**", filename).map { |chemin| version_file(chemin, type) }
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def by_content(segments, type, pattern)
|
|
38
|
+
def detect(segments, type, pattern)
|
|
35
39
|
@files.glob(*segments)
|
|
36
|
-
.select { |chemin| contient?(chemin, pattern) }
|
|
37
|
-
.map { |chemin|
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# Le build.gradle est à un chemin fixe : le chercher par glob remonterait ceux des
|
|
41
|
-
# modules Android embarqués, qui ne portent pas la version de l'app.
|
|
42
|
-
def android_gradle
|
|
43
|
-
return [] unless contient?(@files.path(*GRADLE_PATH), /versionName\s+['"]/)
|
|
44
|
-
|
|
45
|
-
[ VersionFile.new(GRADLE_PATH.join("/"), "android_gradle") ]
|
|
40
|
+
.select { |chemin| pattern.nil? || contient?(chemin, pattern) }
|
|
41
|
+
.map { |chemin| VersionFile.new(@files.relative(chemin), type) }
|
|
46
42
|
end
|
|
47
43
|
|
|
48
44
|
def contient?(chemin, pattern)
|
|
@@ -50,7 +46,5 @@ module CaptiveRelease
|
|
|
50
46
|
rescue StandardError
|
|
51
47
|
false
|
|
52
48
|
end
|
|
53
|
-
|
|
54
|
-
def version_file(chemin, type) = VersionFile.new(@files.relative(chemin), type)
|
|
55
49
|
end
|
|
56
50
|
end
|
|
@@ -52,16 +52,19 @@ module CaptiveRelease
|
|
|
52
52
|
|
|
53
53
|
PLIST_VALUE = %r{(?<=<string>).+?(?=</string>)}
|
|
54
54
|
|
|
55
|
+
PACKAGE_JSON = new(read: ->(content) { JSON.parse(content)["version"] },
|
|
56
|
+
write: lambda { |content, old, nouvelle|
|
|
57
|
+
content.gsub(/"version": "#{Regexp.escape(old)}"/, %("version": "#{nouvelle}"))
|
|
58
|
+
},
|
|
59
|
+
expected: %("version": "x.y.z"))
|
|
60
|
+
|
|
55
61
|
FORMATS = {
|
|
56
62
|
"plain" => new(read: ->(content) { content.strip },
|
|
57
63
|
write: ->(_content, _old, nouvelle) { "#{nouvelle}\n" },
|
|
58
64
|
expected: "x.y.z"),
|
|
59
|
-
"package_json"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
%("version": "#{nouvelle}"))
|
|
63
|
-
},
|
|
64
|
-
expected: %("version": "x.y.z")),
|
|
65
|
+
"package_json" => PACKAGE_JSON,
|
|
66
|
+
# Le manifeste d'un plugin Claude porte sa version comme un package.json.
|
|
67
|
+
"claude_plugin" => PACKAGE_JSON,
|
|
65
68
|
|
|
66
69
|
"ruby_version" => RubyGemsVersion.new(
|
|
67
70
|
by_pattern(/VERSION\s*=\s*["'](.+?)["']/, %(VERSION = "x.y.z")) { |occurrence, nouvelle|
|