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: 423b36a49572d388825d68a5128239d40977d95642dbb88e9e430c12a2c828e1
4
- data.tar.gz: 743a871e6213ac1c663ecc75bfeff8cecfeba16925bf95fa3b743d6186c0826c
3
+ metadata.gz: 8b6fb2c222824add2e6fe62b462240609b233535e610ef7bd70513bf6ff5f931
4
+ data.tar.gz: ffb5b3704f4a4a4a94cb31c6d2275683077a3437d0b8b841ac727a893d32ff2f
5
5
  SHA512:
6
- metadata.gz: ab946e3effe06248e0633c40936cc572a9cf2b875e61b4dda50f26d915698cc8f5bceab19a5b1f39f7649d024a3b3dd46080a4046a7f12185a54d8e77f5474de
7
- data.tar.gz: 5ce64635bc166ef4aacdb3cc468e07fda810941a8a0c73a3b085f466529aaf579e15240baf8e2e7ad37a18edd0a2a096a50183143c55d3784d127ebba7fcef6e
6
+ metadata.gz: 4045d5e368e362b1307a2f27ce16df74ff0c7f0fc1ae021b9d62af6673441deb0b7a66c8d9623a27ae10a46662f8b51d7214c2b8d32cd1878d5c490acf56e7cc
7
+ data.tar.gz: 6a3f85ea5c5da1e82a3131c10f4b6f0e0dd59ec744b8134b2d470b5c47b11b4dcfe37f227d1f74285e03cdfc41fdcaa7ac9d98e39a798c6e23f6a82886fe41b5
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CaptiveRelease
4
- VERSION = "0.13.2"
4
+ VERSION = "0.14.0"
5
5
  end
@@ -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
- RUBY_VERSION_PATTERN = /VERSION\s*=\s*["'].+?["']/
7
- EXPO_APP_JSON_PATTERN = /"expo"\s*:.*"version"\s*:/m
8
- GRADLE_PATH = %w[android app build.gradle].freeze
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
- by_name("package.json", "package_json") +
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 by_name(filename, type)
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| version_file(chemin, type) }
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
@@ -15,6 +15,8 @@ module CaptiveRelease
15
15
  end
16
16
 
17
17
  def self.type_deduit(chemin)
18
+ return "claude_plugin" if chemin == VersionDetector::CLAUDE_PLUGIN_PATH.join("/")
19
+
18
20
  File.basename(chemin) == "package.json" ? "package_json" : "plain"
19
21
  end
20
22
  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" => new(read: ->(content) { JSON.parse(content)["version"] },
60
- write: lambda { |content, old, nouvelle|
61
- content.gsub(/"version": "#{Regexp.escape(old)}"/,
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|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: captive-release
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.2
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Captive Studio