omgcnb 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +64 -0
- data/LICENSE.txt +21 -0
- data/README.md +98 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/exe/omgcnb +73 -0
- data/lib/omgcnb/bit_of_buildpack.rb +38 -0
- data/lib/omgcnb/resolve_dependencies.rb +34 -0
- data/lib/omgcnb/scan_buildpack_toml.rb +34 -0
- data/lib/omgcnb/unreleased_markdown.rb +51 -0
- data/lib/omgcnb/version.rb +5 -0
- data/lib/omgcnb.rb +53 -0
- data/omgcnb.gemspec +40 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 54a6bbcb0235cf1b619b05dfbc625bc306aa456009bfb0074e0898a39081701b
|
4
|
+
data.tar.gz: 8903cf409775866351a5f61c0d245a5f67384b96a2b931a10b8a47ddba88755c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1363d4cd8b59fbf6b180b2246c5e28025d1c401ab08fa25c3260928cfbce1a03d8d33b3679cede77cb48712106145ccd6dec48a6b2b8157ec110a498a6172256
|
7
|
+
data.tar.gz: 34dd52430b27fc2a3a4f7ff1ebf1847b9979b815a9e5a009cf67a8e434ea2a57ec02ca8e2db7de4380111d1d534e628ec82f6262624f007e1283424f6c474942
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at richard.scheeman+foo@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omgcnb (0.1.0)
|
5
|
+
kramdown (>= 1.0)
|
6
|
+
nokogiri (>= 1.0)
|
7
|
+
tomlrb (>= 1.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
ast (2.4.2)
|
13
|
+
diff-lcs (1.4.4)
|
14
|
+
kramdown (2.3.1)
|
15
|
+
rexml
|
16
|
+
nokogiri (1.12.5-x86_64-darwin)
|
17
|
+
racc (~> 1.4)
|
18
|
+
parallel (1.21.0)
|
19
|
+
parser (3.0.2.0)
|
20
|
+
ast (~> 2.4.1)
|
21
|
+
racc (1.5.2)
|
22
|
+
rainbow (3.0.0)
|
23
|
+
rake (13.0.6)
|
24
|
+
regexp_parser (2.1.1)
|
25
|
+
rexml (3.2.5)
|
26
|
+
rspec (3.10.0)
|
27
|
+
rspec-core (~> 3.10.0)
|
28
|
+
rspec-expectations (~> 3.10.0)
|
29
|
+
rspec-mocks (~> 3.10.0)
|
30
|
+
rspec-core (3.10.1)
|
31
|
+
rspec-support (~> 3.10.0)
|
32
|
+
rspec-expectations (3.10.1)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.10.0)
|
35
|
+
rspec-mocks (3.10.2)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.10.0)
|
38
|
+
rspec-support (3.10.2)
|
39
|
+
rubocop (1.22.0)
|
40
|
+
parallel (~> 1.10)
|
41
|
+
parser (>= 3.0.0.0)
|
42
|
+
rainbow (>= 2.2.2, < 4.0)
|
43
|
+
regexp_parser (>= 1.8, < 3.0)
|
44
|
+
rexml
|
45
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
46
|
+
ruby-progressbar (~> 1.7)
|
47
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
48
|
+
rubocop-ast (1.12.0)
|
49
|
+
parser (>= 3.0.1.1)
|
50
|
+
ruby-progressbar (1.11.0)
|
51
|
+
tomlrb (2.0.1)
|
52
|
+
unicode-display_width (2.1.0)
|
53
|
+
|
54
|
+
PLATFORMS
|
55
|
+
x86_64-darwin-20
|
56
|
+
|
57
|
+
DEPENDENCIES
|
58
|
+
omgcnb!
|
59
|
+
rake (~> 13.0)
|
60
|
+
rspec (~> 3.0)
|
61
|
+
rubocop (~> 1.7)
|
62
|
+
|
63
|
+
BUNDLED WITH
|
64
|
+
2.2.27
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 schneems
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# Omgcnb
|
2
|
+
|
3
|
+
A fun little utility for interacting with cloud native buildpacks
|
4
|
+
|
5
|
+
## What
|
6
|
+
|
7
|
+
Cloud Native Buildpacks are awesome. You can compose your buildpack into many smaller pieces that can be reused. This utility scans a given project for `buildpack.toml` files and `CHANGELOG.md` to show you how the pieces depend on one another. As a bonus it can also check for sub-buildpacks that are unreleased and resolve the correct buildpack release order.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Or install it yourself as:
|
12
|
+
|
13
|
+
$ gem install omgcnb
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Scan a directory for buildpacks that need to be released:
|
18
|
+
|
19
|
+
```
|
20
|
+
$ omgcnb scan .
|
21
|
+
|
22
|
+
## Needs Release
|
23
|
+
|
24
|
+
1) heroku/nodejs-function-invoker
|
25
|
+
- Update sf-fx-runtime-nodejs to 0.8.0
|
26
|
+
|
27
|
+
## All Buildpacks
|
28
|
+
|
29
|
+
- heroku/nodejs
|
30
|
+
- heroku/nodejs-engine
|
31
|
+
- heroku/nodejs-yarn
|
32
|
+
- heroku/nodejs-typescript
|
33
|
+
- heroku/procfile
|
34
|
+
- heroku/nodejs-engine
|
35
|
+
- heroku/nodejs-npm
|
36
|
+
- heroku/nodejs-typescript
|
37
|
+
- heroku/procfile
|
38
|
+
- heroku/nodejs-function
|
39
|
+
- heroku/nodejs-engine
|
40
|
+
- heroku/nodejs-npm
|
41
|
+
- heroku/nodejs-typescript
|
42
|
+
- heroku/nodejs-function-invoker
|
43
|
+
- heroku/nodejs-typescript
|
44
|
+
- (no deps)
|
45
|
+
- heroku/nodejs-engine
|
46
|
+
- (no deps)
|
47
|
+
- heroku/nodejs-yarn
|
48
|
+
- (no deps)
|
49
|
+
- heroku/nodejs-function-invoker
|
50
|
+
- (no deps)
|
51
|
+
- heroku/nodejs-npm
|
52
|
+
- (no deps)
|
53
|
+
```
|
54
|
+
|
55
|
+
Run the command with `--help` for more info.
|
56
|
+
|
57
|
+
If you have more than one buildpack that has been modified the command will show the correct order that the buildpacks must be released:
|
58
|
+
|
59
|
+
```
|
60
|
+
$ omgcnb scan .
|
61
|
+
|
62
|
+
## Needs Release
|
63
|
+
|
64
|
+
1) heroku/nodejs-function-invoker
|
65
|
+
- Update sf-fx-runtime-nodejs to 0.8.0
|
66
|
+
2) heroku/nodejs-function
|
67
|
+
- Fix spelling in the readme
|
68
|
+
|
69
|
+
## All Buildpacks
|
70
|
+
|
71
|
+
# ...
|
72
|
+
```
|
73
|
+
|
74
|
+
In this example the output is indicating that `heroku/nodejs-function-invoker` needs to be deployed first, then after that `heroku/nodejs-function` buildpack needs deploy. The contents under each "needs release" show the changelog contents.
|
75
|
+
|
76
|
+
Optional dependant buildpacks are ignored by default, this tool does not yet support depending on buildpacks outside of the repo.
|
77
|
+
|
78
|
+
## How
|
79
|
+
|
80
|
+
For resolution order: dependencies are derived directly from `buildpack.toml` files. For knowing what needs to be released: The `CHANGELOG.md` files are parsed for contents in the `## Unreleased` section.
|
81
|
+
|
82
|
+
## Development
|
83
|
+
|
84
|
+
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.
|
85
|
+
|
86
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
87
|
+
|
88
|
+
## Contributing
|
89
|
+
|
90
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/omgcnb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/omgcnb/blob/main/CODE_OF_CONDUCT.md).
|
91
|
+
|
92
|
+
## License
|
93
|
+
|
94
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
95
|
+
|
96
|
+
## Code of Conduct
|
97
|
+
|
98
|
+
Everyone interacting in the Omgcnb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/omgcnb/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "omgcnb"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/omgcnb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
require "optparse"
|
5
|
+
require_relative "../lib/omgcnb.rb"
|
6
|
+
|
7
|
+
options = {}
|
8
|
+
parser = OptionParser.new do |opts|
|
9
|
+
opts.banner = <<~EOM
|
10
|
+
Usage: omgcnb [argument] [options]
|
11
|
+
|
12
|
+
Commands:
|
13
|
+
- scan <dir>: Outpusts buildpacks and their dependencies for a given path
|
14
|
+
|
15
|
+
Options:
|
16
|
+
EOM
|
17
|
+
|
18
|
+
opts.on("--exclude <dir>", "") do |v|
|
19
|
+
options[:exclude] = v
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on("--allow-test", "") do
|
23
|
+
options[:allow_test] = true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
parser.parse!
|
27
|
+
|
28
|
+
|
29
|
+
command = ARGV[0]
|
30
|
+
directory = ARGV[1]
|
31
|
+
|
32
|
+
case command
|
33
|
+
when 'scan'
|
34
|
+
directory = Pathname(directory).expand_path
|
35
|
+
exclude = if options[:exclude]
|
36
|
+
[Pathname(options[:exclude]).expand_path]
|
37
|
+
else
|
38
|
+
[]
|
39
|
+
end
|
40
|
+
if !options[:allow_test]
|
41
|
+
exclude << directory.join("test")
|
42
|
+
exclude << directory.join("spec")
|
43
|
+
end
|
44
|
+
|
45
|
+
buildpacks = Omgcnb::BuildpacksFromDir.new(
|
46
|
+
dir: directory,
|
47
|
+
exclude: exclude
|
48
|
+
).buildpacks
|
49
|
+
|
50
|
+
needs_release = Omgcnb::ResolveDependencies.new(buildpacks).solution
|
51
|
+
puts
|
52
|
+
puts "## Needs Release"
|
53
|
+
puts
|
54
|
+
needs_release.each_with_index do |buildpack, i|
|
55
|
+
puts "#{i.next}) #{buildpack.name}"
|
56
|
+
buildpack.changed_list.each do |line|
|
57
|
+
puts " #{line}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
puts
|
61
|
+
puts "## All Buildpacks"
|
62
|
+
puts
|
63
|
+
buildpacks.each do |b|
|
64
|
+
Omgcnb::DisplayAllDeps.new(b).call
|
65
|
+
end
|
66
|
+
when nil
|
67
|
+
puts parser.help
|
68
|
+
exit(1)
|
69
|
+
else
|
70
|
+
puts "no such command #{command}"
|
71
|
+
puts parser.help
|
72
|
+
exit(1)
|
73
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Omgcnb
|
4
|
+
class BitOfBuildpack
|
5
|
+
attr_reader :name
|
6
|
+
def initialize(toml_contents: , changelog_contents: )
|
7
|
+
@toml = Tomlrb.parse(toml_contents, symbolize_keys: true)
|
8
|
+
@name = toml.fetch(:buildpack).fetch(:id)
|
9
|
+
|
10
|
+
@unreleased_markdown = UnreleasedMarkdown.new(changelog_contents)
|
11
|
+
end
|
12
|
+
|
13
|
+
def needs_release?
|
14
|
+
@unreleased_markdown.needs_release?
|
15
|
+
end
|
16
|
+
|
17
|
+
def changed_list
|
18
|
+
@unreleased_markdown.changed_list
|
19
|
+
end
|
20
|
+
|
21
|
+
def toml
|
22
|
+
@toml
|
23
|
+
end
|
24
|
+
|
25
|
+
def depends_on(show_optional: false)
|
26
|
+
@depends_on = toml&.[](:order)
|
27
|
+
&.map { |group_array| group_array[:group] }
|
28
|
+
&.flatten
|
29
|
+
&.map {|group|
|
30
|
+
if show_optional || !group[:optional]
|
31
|
+
group[:id]
|
32
|
+
else
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
}&.compact || []
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Omgcnb
|
4
|
+
class ResolveDependencies
|
5
|
+
def initialize(buildpacks)
|
6
|
+
@order = []
|
7
|
+
@unsolved = buildpacks.select(&:needs_release?)
|
8
|
+
@solved = buildpacks - @unsolved
|
9
|
+
@buildpacks = buildpacks
|
10
|
+
|
11
|
+
given_buildpacks = buildpacks.flat_map {|b| b.name }
|
12
|
+
@buildpacks.each do |buildpack|
|
13
|
+
depends_diff = buildpack.depends_on - given_buildpacks
|
14
|
+
raise "Cannot satisfy '#{buildpack.name}' missing: #{depends_diff}" unless depends_diff.empty?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def call
|
19
|
+
while @unsolved.any?
|
20
|
+
found = @unsolved.select { |buildpack|
|
21
|
+
(buildpack.depends_on - @solved.map(&:name)).empty?
|
22
|
+
}
|
23
|
+
@order.concat(found)
|
24
|
+
@solved.concat(found)
|
25
|
+
@unsolved -=found
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def solution
|
30
|
+
call
|
31
|
+
@order
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
|
4
|
+
module Omgcnb
|
5
|
+
class ScanBuildpackToml
|
6
|
+
def initialize(dir: , exclude: [])
|
7
|
+
@dir = Pathname(dir)
|
8
|
+
@exclude = exclude.map {|p| Pathname(p) }
|
9
|
+
|
10
|
+
@buildpack_toml_files = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
scan_dir(@dir)
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def files
|
19
|
+
@buildpack_toml_files
|
20
|
+
end
|
21
|
+
|
22
|
+
private def scan_dir(dir)
|
23
|
+
return if @exclude.include?(dir)
|
24
|
+
|
25
|
+
dir.join("buildpack.toml").tap do |file|
|
26
|
+
@buildpack_toml_files << file if file.exist?
|
27
|
+
end
|
28
|
+
|
29
|
+
dir.children.each do |d|
|
30
|
+
scan_dir(d) if d.directory?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Omgcnb
|
4
|
+
class UnreleasedMarkdown
|
5
|
+
def initialize(markdown_text)
|
6
|
+
@markdown_text = markdown_text
|
7
|
+
end
|
8
|
+
|
9
|
+
def needs_release?
|
10
|
+
unreleased_ul
|
11
|
+
end
|
12
|
+
|
13
|
+
def html
|
14
|
+
@html ||= Kramdown::Document.new(@markdown_text).to_html
|
15
|
+
end
|
16
|
+
|
17
|
+
def nokogiri
|
18
|
+
@nokogiri ||= Nokogiri::HTML(html)
|
19
|
+
end
|
20
|
+
|
21
|
+
def changed_list
|
22
|
+
return [] unless unreleased_ul
|
23
|
+
unreleased_ul.xpath("li").map {|li| "- #{li.content}" }
|
24
|
+
end
|
25
|
+
|
26
|
+
def unreleased_ul
|
27
|
+
return @unreleased_ul if defined?(@unreleased_ul)
|
28
|
+
@unreleased_ul = search_ul
|
29
|
+
end
|
30
|
+
|
31
|
+
def search_ul
|
32
|
+
# Find h2 header with "unreleased"
|
33
|
+
# search to see if the next element is an "h2" (no unreleased changes)
|
34
|
+
# or it is "ul" (has unreleased changes)
|
35
|
+
node = unreleased_h2&.next_sibling
|
36
|
+
while node
|
37
|
+
node = node.next_sibling
|
38
|
+
case node&.name
|
39
|
+
when "h2"
|
40
|
+
return nil
|
41
|
+
when "ul"
|
42
|
+
return node
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def unreleased_h2
|
48
|
+
nokogiri.xpath("//h2[@id='unreleased']").first
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/omgcnb.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
require 'kramdown'
|
5
|
+
require 'nokogiri'
|
6
|
+
require 'tomlrb'
|
7
|
+
require_relative "omgcnb/version"
|
8
|
+
|
9
|
+
module Omgcnb
|
10
|
+
class Error < StandardError; end
|
11
|
+
|
12
|
+
class BuildpacksFromDir
|
13
|
+
def initialize(dir: , exclude: [])
|
14
|
+
@dir = dir
|
15
|
+
@exclude = exclude
|
16
|
+
end
|
17
|
+
|
18
|
+
def buildpacks
|
19
|
+
@buildpacks ||= ScanBuildpackToml.new(dir: @dir, exclude: @exclude).call.files.map do |file|
|
20
|
+
changelog = file.parent.join("CHANGELOG.md")
|
21
|
+
|
22
|
+
raise "Expected #{changelog} to exist but it does not" unless changelog.exist?
|
23
|
+
BitOfBuildpack.new(
|
24
|
+
toml_contents: file.read,
|
25
|
+
changelog_contents: changelog.read
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class DisplayAllDeps
|
32
|
+
attr_reader :io, :buildpack
|
33
|
+
|
34
|
+
def initialize(buildpack, io: STDOUT)
|
35
|
+
@buildpack = buildpack
|
36
|
+
@io = io
|
37
|
+
end
|
38
|
+
|
39
|
+
def call
|
40
|
+
io.puts "- #{buildpack.name}"
|
41
|
+
if buildpack.depends_on.any?
|
42
|
+
io.puts "#{buildpack.depends_on(show_optional: true).map {|s| " - #{s}" }.join("\n")}"
|
43
|
+
else
|
44
|
+
io.puts " - (no deps)"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
require_relative 'omgcnb/resolve_dependencies'
|
51
|
+
require_relative 'omgcnb/unreleased_markdown'
|
52
|
+
require_relative 'omgcnb/bit_of_buildpack'
|
53
|
+
require_relative 'omgcnb/scan_buildpack_toml'
|
data/omgcnb.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/omgcnb/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "omgcnb"
|
7
|
+
spec.version = Omgcnb::VERSION
|
8
|
+
spec.authors = ["schneems"]
|
9
|
+
spec.email = ["richard.scheeman+foo@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "OMG CNB"
|
12
|
+
spec.description = "OMG CNB"
|
13
|
+
spec.homepage = "https://example.com"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.4.0"
|
16
|
+
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = "https://example.com"
|
20
|
+
spec.metadata["changelog_uri"] = "https://example.com"
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
27
|
+
end
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
# Uncomment to register a new dependency of your gem
|
34
|
+
spec.add_dependency "kramdown", ">= 1.0"
|
35
|
+
spec.add_dependency "tomlrb", ">= 1.0"
|
36
|
+
spec.add_dependency "nokogiri", ">= 1.0"
|
37
|
+
|
38
|
+
# For more information and examples about making a new gem, checkout our
|
39
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omgcnb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- schneems
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-10-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: kramdown
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tomlrb
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
description: OMG CNB
|
56
|
+
email:
|
57
|
+
- richard.scheeman+foo@gmail.com
|
58
|
+
executables:
|
59
|
+
- omgcnb
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".rspec"
|
64
|
+
- ".rubocop.yml"
|
65
|
+
- CHANGELOG.md
|
66
|
+
- CODE_OF_CONDUCT.md
|
67
|
+
- Gemfile
|
68
|
+
- Gemfile.lock
|
69
|
+
- LICENSE.txt
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/console
|
73
|
+
- bin/setup
|
74
|
+
- exe/omgcnb
|
75
|
+
- lib/omgcnb.rb
|
76
|
+
- lib/omgcnb/bit_of_buildpack.rb
|
77
|
+
- lib/omgcnb/resolve_dependencies.rb
|
78
|
+
- lib/omgcnb/scan_buildpack_toml.rb
|
79
|
+
- lib/omgcnb/unreleased_markdown.rb
|
80
|
+
- lib/omgcnb/version.rb
|
81
|
+
- omgcnb.gemspec
|
82
|
+
homepage: https://example.com
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata:
|
86
|
+
homepage_uri: https://example.com
|
87
|
+
source_code_uri: https://example.com
|
88
|
+
changelog_uri: https://example.com
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 2.4.0
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubygems_version: 3.2.22
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: OMG CNB
|
108
|
+
test_files: []
|