aemcrxpkgmgr 0.1.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +5 -0
- data/.travis.yml +2 -2
- data/Gemfile.lock +16 -16
- data/README.md +2 -2
- data/aemcrxpkgmgr.gemspec +4 -4
- data/bin/setup +1 -0
- data/changelog.md +17 -10
- data/exe/aemcrxpkgmgr +26 -13
- data/lib/aemcrxpkgmgr/version.rb +1 -1
- data/lib/aemcrxpkgmgr.rb +36 -8
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a24f0915b9577e735d320619e2d23162465df08c79036d0404f04e334da152c0
|
4
|
+
data.tar.gz: 393a36ccdb60bcb7131523e86a746c3aa99c448647ed6fa68cc26cbc6907ca76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 439e17bfb6d3af0e74d0c624e3233c91e85894d715509197ef241e6f6774a793cf43d99682db8984f2acea9c6c1efdab47edadbdaa977819b5243260ce7e772f
|
7
|
+
data.tar.gz: 0e2af1b759fbbcfcfc37f8fe41a25d5b4d3c3fe132e3ba2eac89b2890845795df73659a0b252b28a64efaf853f5127fbf79d1fbe4bb9ae8155519a205e11d20b
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
aemcrxpkgmgr (0.
|
4
|
+
aemcrxpkgmgr (0.2.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
diff-lcs (1.3)
|
10
|
-
rake (
|
11
|
-
rspec (3.
|
12
|
-
rspec-core (~> 3.
|
13
|
-
rspec-expectations (~> 3.
|
14
|
-
rspec-mocks (~> 3.
|
15
|
-
rspec-core (3.
|
16
|
-
rspec-support (~> 3.
|
17
|
-
rspec-expectations (3.
|
10
|
+
rake (13.0.1)
|
11
|
+
rspec (3.8.0)
|
12
|
+
rspec-core (~> 3.8.0)
|
13
|
+
rspec-expectations (~> 3.8.0)
|
14
|
+
rspec-mocks (~> 3.8.0)
|
15
|
+
rspec-core (3.8.2)
|
16
|
+
rspec-support (~> 3.8.0)
|
17
|
+
rspec-expectations (3.8.4)
|
18
18
|
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.
|
20
|
-
rspec-mocks (3.
|
19
|
+
rspec-support (~> 3.8.0)
|
20
|
+
rspec-mocks (3.8.1)
|
21
21
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.
|
23
|
-
rspec-support (3.
|
22
|
+
rspec-support (~> 3.8.0)
|
23
|
+
rspec-support (3.8.2)
|
24
24
|
|
25
25
|
PLATFORMS
|
26
26
|
ruby
|
27
27
|
|
28
28
|
DEPENDENCIES
|
29
29
|
aemcrxpkgmgr!
|
30
|
-
bundler (~>
|
31
|
-
rake (~>
|
30
|
+
bundler (~> 2.0)
|
31
|
+
rake (~> 13.0)
|
32
32
|
rspec (~> 3.0)
|
33
33
|
|
34
34
|
BUNDLED WITH
|
35
|
-
|
35
|
+
2.2.27
|
data/README.md
CHANGED
@@ -26,10 +26,10 @@ TODO: Write usage instructions here
|
|
26
26
|
|
27
27
|
## Development
|
28
28
|
|
29
|
-
After checking out the repo, run
|
29
|
+
After checking out the repo, run `./bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `./bin/console` for an interactive prompt that will allow you to experiment.
|
30
30
|
|
31
31
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
32
|
|
33
33
|
## Contributing
|
34
34
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/vrtdev/aemcrxpkgmgr.
|
data/aemcrxpkgmgr.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'aemcrxpkgmgr/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'aemcrxpkgmgr'
|
8
8
|
spec.version = AemCrxPkgMgr::VERSION
|
9
|
-
spec.authors = ['Stefan - Zipkid - Goethals']
|
10
|
-
spec.email = ['stefan.goethals@vrt.be']
|
9
|
+
spec.authors = ['Stefan - Zipkid - Goethals', 'Wim Symons']
|
10
|
+
spec.email = ['stefan.goethals@vrt.be', 'wim.symons@vrt.be']
|
11
11
|
|
12
12
|
spec.summary = 'AEM CRX Package Manager script'
|
13
13
|
spec.description = 'AEM CRX Package Manager script'
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
30
|
spec.require_paths = ['lib']
|
31
31
|
|
32
|
-
spec.add_development_dependency 'bundler', '~>
|
33
|
-
spec.add_development_dependency 'rake', '~>
|
32
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
33
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
34
34
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
35
35
|
end
|
data/bin/setup
CHANGED
data/changelog.md
CHANGED
@@ -5,6 +5,23 @@ Version format based on http://semver.org/
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [0.2.2] - 2022-09-28
|
9
|
+
## Fixed
|
10
|
+
- `--debug` did not function properly, causing debug output to be printed on stdout by default, which breaks valid (json) output.
|
11
|
+
|
12
|
+
## [0.2.1] - 2021-12-15
|
13
|
+
## Fixed
|
14
|
+
- `filtergroup` and `filtername` paramters to pkg_query made optional. (the puppet fact does not pass them)
|
15
|
+
|
16
|
+
## [0.2.0] - 2021-09-03
|
17
|
+
## Added
|
18
|
+
- `--filtergroup` and `--filtername` options to provide extra filtering on queried packages as `--query` does not provide exact matches.
|
19
|
+
|
20
|
+
## [0.1.2] - 2019-07-05
|
21
|
+
## Changed
|
22
|
+
- immediately stop retries when the given address is not available
|
23
|
+
- added `max_retries` and `retry_timeout` options while keeping the current defaults
|
24
|
+
|
8
25
|
## [0.1.1] - 2018-01-30
|
9
26
|
## Added
|
10
27
|
- retry failed get
|
@@ -12,13 +29,3 @@ Version format based on http://semver.org/
|
|
12
29
|
## [0.1.0] - 2018-01-30
|
13
30
|
## Added
|
14
31
|
- First working version
|
15
|
-
|
16
|
-
## [0.0.0] - 2018-01-01
|
17
|
-
### Added
|
18
|
-
- ...
|
19
|
-
|
20
|
-
### Changed
|
21
|
-
- ...
|
22
|
-
|
23
|
-
### Removed
|
24
|
-
- ...
|
data/exe/aemcrxpkgmgr
CHANGED
@@ -23,9 +23,15 @@ def clidoc
|
|
23
23
|
-p --pass:
|
24
24
|
password
|
25
25
|
|
26
|
-
-q --query
|
26
|
+
-q --query:
|
27
27
|
query string
|
28
28
|
|
29
|
+
-g --filtergroup:
|
30
|
+
the exact package group name to filter on
|
31
|
+
|
32
|
+
-n --filtername:
|
33
|
+
the exact package name to filter on
|
34
|
+
|
29
35
|
-v --versions:
|
30
36
|
include other versions of package
|
31
37
|
|
@@ -41,7 +47,7 @@ def clidoc
|
|
41
47
|
ruby: native Array/Hash output
|
42
48
|
|
43
49
|
-d --debug:
|
44
|
-
debug
|
50
|
+
enable debug output on stderr
|
45
51
|
|
46
52
|
CLIDOC
|
47
53
|
end
|
@@ -53,21 +59,25 @@ opts = GetoptLong.new(
|
|
53
59
|
['--user', '-u', GetoptLong::REQUIRED_ARGUMENT],
|
54
60
|
['--pass', '-p', GetoptLong::REQUIRED_ARGUMENT],
|
55
61
|
['--query', '-q', GetoptLong::REQUIRED_ARGUMENT],
|
62
|
+
['--filtergroup', '-g', GetoptLong::OPTIONAL_ARGUMENT],
|
63
|
+
['--filtername', '-n', GetoptLong::OPTIONAL_ARGUMENT],
|
56
64
|
['--versions', '-v', GetoptLong::NO_ARGUMENT],
|
57
65
|
['--keys', '-k', GetoptLong::REQUIRED_ARGUMENT],
|
58
66
|
['--output', '-o', GetoptLong::REQUIRED_ARGUMENT],
|
59
|
-
['--debug', '-d', GetoptLong::
|
67
|
+
['--debug', '-d', GetoptLong::NO_ARGUMENT]
|
60
68
|
)
|
61
69
|
|
62
70
|
action = 'query'
|
63
71
|
host = 'http://localhost:4502'
|
64
72
|
user = 'admin'
|
65
73
|
pass = ENV['AEM_PASSWORD']
|
66
|
-
query =
|
74
|
+
query = nil
|
75
|
+
filtergroup = nil
|
76
|
+
filtername = nil
|
67
77
|
includeversions = false
|
68
78
|
keys_to_extract = %w[name description version group path]
|
69
79
|
output = 'yaml'
|
70
|
-
debug =
|
80
|
+
debug = false
|
71
81
|
|
72
82
|
# rubocop:disable Metrics/BlockLength
|
73
83
|
opts.each do |opt, arg|
|
@@ -85,6 +95,10 @@ opts.each do |opt, arg|
|
|
85
95
|
pass = arg
|
86
96
|
when '--query'
|
87
97
|
query = arg
|
98
|
+
when '--filtergroup'
|
99
|
+
filtergroup = arg
|
100
|
+
when '--filtername'
|
101
|
+
filtername = arg
|
88
102
|
when '--versions'
|
89
103
|
includeversions = true
|
90
104
|
when '--keys'
|
@@ -92,11 +106,10 @@ opts.each do |opt, arg|
|
|
92
106
|
when '--output'
|
93
107
|
output = arg
|
94
108
|
when '--debug'
|
95
|
-
debug =
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
end
|
109
|
+
debug = true
|
110
|
+
else
|
111
|
+
STDERR.puts "Unknown option #{opt}"
|
112
|
+
exit 1
|
100
113
|
end
|
101
114
|
end
|
102
115
|
# rubocop:enable Metrics/BlockLength
|
@@ -115,10 +128,10 @@ case action
|
|
115
128
|
when 'delete_crx_zip'
|
116
129
|
aemcrxpkgmgr.output = 'ruby'
|
117
130
|
aemcrxpkgmgr.keys_to_extract = ['path']
|
118
|
-
list = aemcrxpkgmgr.pkg_query
|
119
|
-
result = aemcrxpkgmgr.delete_crx_zip
|
131
|
+
list = aemcrxpkgmgr.pkg_query(query, filtergroup, filtername)
|
132
|
+
result = aemcrxpkgmgr.delete_crx_zip(list)
|
120
133
|
else
|
121
|
-
result = aemcrxpkgmgr.pkg_query
|
134
|
+
result = aemcrxpkgmgr.pkg_query(query, filtergroup, filtername)
|
122
135
|
end
|
123
136
|
|
124
137
|
puts result
|
data/lib/aemcrxpkgmgr/version.rb
CHANGED
data/lib/aemcrxpkgmgr.rb
CHANGED
@@ -9,19 +9,22 @@ require 'pp'
|
|
9
9
|
# AEM CRX Package Manager
|
10
10
|
class AemCrxPkgMgr
|
11
11
|
attr_accessor :includeversions, :keys_to_extract, :output
|
12
|
+
|
12
13
|
def initialize(options = {})
|
13
14
|
@host = options[:host] || 'http://localhost:4502'
|
14
15
|
@user = options[:user] || 'admin'
|
16
|
+
@max_retries = options[:max_retries] || 100
|
17
|
+
@retry_timeout = options[:retry_timeout] || 3
|
15
18
|
@pass = options[:pass]
|
16
19
|
@includeversions = options[:includeversions] || false
|
17
20
|
@keys_to_extract = options[:keys_to_extract]
|
18
21
|
@output = options[:output] || 'ruby'
|
19
|
-
@debug = options[:debug]
|
22
|
+
@debug = options[:debug] || false
|
23
|
+
STDERR.puts 'AemCrxPkgMgr Object initialised' if @debug
|
20
24
|
end
|
21
25
|
|
22
26
|
def get(uri)
|
23
|
-
retries ||=
|
24
|
-
retry_timeout = 3
|
27
|
+
retries ||= @max_retries
|
25
28
|
|
26
29
|
request = Net::HTTP::Get.new(uri)
|
27
30
|
request.basic_auth(@user, @pass)
|
@@ -30,26 +33,35 @@ class AemCrxPkgMgr
|
|
30
33
|
http.request(request)
|
31
34
|
end
|
32
35
|
raise "AemCrxPkgMgr.get Response '#{response.code}' is not a Net::HTTPSuccess" unless response.is_a?(Net::HTTPSuccess)
|
36
|
+
|
33
37
|
response
|
34
|
-
rescue Errno::EADDRNOTAVAIL
|
35
|
-
|
38
|
+
rescue Errno::EADDRNOTAVAIL
|
39
|
+
raise 'AemCrxPkgMgr.get AEM not available'
|
40
|
+
rescue RuntimeError => e
|
41
|
+
STDERR.puts "AemCrxPkgMgr.get : #{e.class} : #{e.message}"
|
36
42
|
will_retry = (retries -= 1) >= 0
|
37
43
|
if will_retry
|
38
|
-
sleep retry_timeout
|
44
|
+
sleep @retry_timeout
|
39
45
|
retry
|
40
46
|
end
|
41
47
|
raise
|
42
48
|
end
|
43
49
|
|
44
50
|
def pkg_query_uri(query)
|
51
|
+
STDERR.puts "pkg_query_uri Starting (#{query})" if @debug
|
45
52
|
uri = URI.parse(@host + '/crx/packmgr/list.jsp')
|
46
|
-
params = {
|
53
|
+
params = { includeVersions: @includeversions }
|
54
|
+
unless query.nil?
|
55
|
+
params['q'] = query
|
56
|
+
end
|
47
57
|
uri.query = URI.encode_www_form(params)
|
58
|
+
STDERR.puts "pkg_query_uri : discovered uri : #{uri}" if @debug
|
48
59
|
uri
|
49
60
|
end
|
50
61
|
|
51
62
|
def delete_crx_zip(list)
|
52
63
|
return unless list
|
64
|
+
|
53
65
|
@delete_crx_zip_ok = 0
|
54
66
|
@delete_crx_zip_status = []
|
55
67
|
list.each do |path|
|
@@ -74,21 +86,36 @@ class AemCrxPkgMgr
|
|
74
86
|
@delete_crx_zip_ok += 1 if response.is_a? Net::HTTPSuccess
|
75
87
|
end
|
76
88
|
|
77
|
-
def pkg_query(query)
|
89
|
+
def pkg_query(query, filtergroup=nil, filtername=nil)
|
90
|
+
STDERR.puts "pkg_query Starting (#{query}, #{filtergroup}, #{filtername})" if @debug
|
78
91
|
uri = pkg_query_uri(query)
|
79
92
|
response = get uri
|
93
|
+
STDERR.puts 'pkg_query : got response' if @debug
|
80
94
|
|
81
95
|
raise "HTTP response code : #{response.code}, message : #{response.message}" unless response.is_a? Net::HTTPSuccess
|
82
96
|
|
97
|
+
STDERR.puts "pkg_query : response.code : #{response.code}" if @debug
|
98
|
+
|
83
99
|
@query_data = JSON.parse(response.body)['results']
|
84
100
|
|
101
|
+
unless filtergroup.nil?
|
102
|
+
@query_data = @query_data.select { |item| item['group'] == filtergroup }
|
103
|
+
end
|
104
|
+
|
105
|
+
unless filtername.nil?
|
106
|
+
@query_data = @query_data.select { |item| item['name'] == filtername }
|
107
|
+
end
|
108
|
+
|
85
109
|
extract_keys
|
86
110
|
|
87
111
|
format_output @query_data unless @query_data.empty?
|
88
112
|
end
|
89
113
|
|
90
114
|
def extract_keys
|
115
|
+
STDERR.puts 'extract_keys : Starting' if @debug
|
91
116
|
return if @keys_to_extract.length.zero?
|
117
|
+
|
118
|
+
STDERR.puts "extract_keys : keys_to_extract : #{@keys_to_extract}" if @debug
|
92
119
|
@query_data.map! do |element|
|
93
120
|
if @keys_to_extract.length == 1
|
94
121
|
element[@keys_to_extract.first]
|
@@ -111,6 +138,7 @@ class AemCrxPkgMgr
|
|
111
138
|
|
112
139
|
def output_single(data)
|
113
140
|
raise 'Resultset contains more than 1 element and "single" was requested.' if data.length != 1
|
141
|
+
|
114
142
|
data.first
|
115
143
|
end
|
116
144
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aemcrxpkgmgr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan - Zipkid - Goethals
|
8
|
-
|
8
|
+
- Wim Symons
|
9
|
+
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2024-01-03 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
@@ -16,28 +17,28 @@ dependencies:
|
|
16
17
|
requirements:
|
17
18
|
- - "~>"
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
+
version: '2.0'
|
20
21
|
type: :development
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
25
|
- - "~>"
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
+
version: '2.0'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: rake
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
32
|
- - "~>"
|
32
33
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
+
version: '13.0'
|
34
35
|
type: :development
|
35
36
|
prerelease: false
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
39
|
- - "~>"
|
39
40
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
+
version: '13.0'
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
43
|
name: rspec
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -55,6 +56,7 @@ dependencies:
|
|
55
56
|
description: AEM CRX Package Manager script
|
56
57
|
email:
|
57
58
|
- stefan.goethals@vrt.be
|
59
|
+
- wim.symons@vrt.be
|
58
60
|
executables:
|
59
61
|
- aemcrxpkgmgr
|
60
62
|
extensions: []
|
@@ -79,7 +81,7 @@ homepage: http://github.com/vrtdev
|
|
79
81
|
licenses: []
|
80
82
|
metadata:
|
81
83
|
allowed_push_host: https://rubygems.org
|
82
|
-
post_install_message:
|
84
|
+
post_install_message:
|
83
85
|
rdoc_options: []
|
84
86
|
require_paths:
|
85
87
|
- lib
|
@@ -94,9 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
96
|
- !ruby/object:Gem::Version
|
95
97
|
version: '0'
|
96
98
|
requirements: []
|
97
|
-
|
98
|
-
|
99
|
-
signing_key:
|
99
|
+
rubygems_version: 3.4.21
|
100
|
+
signing_key:
|
100
101
|
specification_version: 4
|
101
102
|
summary: AEM CRX Package Manager script
|
102
103
|
test_files: []
|