way_of_working 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/CODE_OF_CONDUCT.md +2 -2
  4. data/README.md +53 -55
  5. data/exe/way_of_working +1 -1
  6. data/lib/tasks/audit_gems.rake +2 -2
  7. data/lib/way_of_working/cli.rb +11 -115
  8. data/lib/way_of_working/configuration.rb +18 -0
  9. data/lib/way_of_working/git/repo_reader.rb +1 -3
  10. data/lib/way_of_working/paths.rb +5 -2
  11. data/lib/way_of_working/readme_badge/generators/init.rb +54 -0
  12. data/lib/way_of_working/readme_badge/github_audit_rule.rb +27 -0
  13. data/lib/way_of_working/readme_badge/paths.rb +18 -0
  14. data/lib/way_of_working/readme_badge/templates/README.md +3 -0
  15. data/lib/way_of_working/readme_badge/templates/docs/way_of_working/readme-badges.md.tt +24 -0
  16. data/lib/way_of_working/readme_badge.rb +31 -0
  17. data/lib/way_of_working/sub_commands/base.rb +20 -0
  18. data/lib/way_of_working/sub_commands/exec.rb +11 -0
  19. data/lib/way_of_working/sub_commands/init.rb +17 -0
  20. data/lib/way_of_working/sub_commands/new.rb +11 -0
  21. data/lib/way_of_working/tasks.rb +1 -1
  22. data/lib/way_of_working/version.rb +1 -1
  23. data/lib/way_of_working.rb +18 -4
  24. data/way_of_working.gemspec +4 -1
  25. metadata +60 -23
  26. data/lib/way_of_working/generators/changelog/init.rb +0 -110
  27. data/lib/way_of_working/generators/code_of_conduct/init.rb +0 -32
  28. data/lib/way_of_working/generators/decision_record/init.rb +0 -29
  29. data/lib/way_of_working/generators/decision_record/new.rb +0 -67
  30. data/lib/way_of_working/generators/linter/exec.rb +0 -77
  31. data/lib/way_of_working/generators/linter/init.rb +0 -60
  32. data/lib/way_of_working/generators/rake_tasks/init.rb +0 -47
  33. data/lib/way_of_working/sub_command_base.rb +0 -16
  34. data/lib/way_of_working/templates/.github/linters/.markdown-link-check.json +0 -13
  35. data/lib/way_of_working/templates/.github/linters/rubocop_defaults.yml +0 -55
  36. data/lib/way_of_working/templates/.github/workflows/mega-linter.yml +0 -82
  37. data/lib/way_of_working/templates/.mega-linter.yml +0 -129
  38. data/lib/way_of_working/templates/.rubocop +0 -1
  39. data/lib/way_of_working/templates/CODE_OF_CONDUCT.md.tt +0 -134
  40. data/lib/way_of_working/templates/docs/decisions/README.md +0 -7
  41. data/lib/way_of_working/templates/docs/decisions/adr-template.md.tt +0 -79
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8af659ec8270a7df5b2333d631565faf9c7aa836be80dcfe704981d2d8f7336
4
- data.tar.gz: 3490bf4f4ee2735b710a555edc6a8759c8390227c2c8a6ea8b5395a54dfd9122
3
+ metadata.gz: fcf87e5f8b8338ec91dc10bb579a9c8e9fa3e977745ba61cf8ae106cfb27201c
4
+ data.tar.gz: 3be69c82e3d055cefe8353bf440f085eb84f420427a131dbb4a5f888f12d67f6
5
5
  SHA512:
6
- metadata.gz: d6cd047c825b78be49b8460c98d65da9259d014aa2888767705c6601190d6630e9c0446e255abb67b903ac5201196b27a218b2f514889fb2eef33b78aad66773
7
- data.tar.gz: 631e4b3b9c62bd4c8daeaddc8617ddb3454ed2b33ddf08c29dc1219a8efd0a3b4948f9c36141bc579ee1c96be74d4a7671c7cced635004c53cffec3c02f476b4
6
+ metadata.gz: 70c5587a836fd9d530647f01e96fd725ac91ac418415e0d002613da943dfc502d6460d454bf81e9ea2c5f05ccfd78ef94b2b75adf8ca16261fa28c327c490a22
7
+ data.tar.gz: feb65211f0f6c7904c00a16dccdb1b8dde8de7ca3880282d7fe926543dae1de30fed6a1e722843f5bbcfb4dd2735b87dd0c5c6c4b9c9cbb72bf03a0a5a220a02
data/CHANGELOG.md CHANGED
@@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - Added a panel for README badges and a Way of Working badge
13
+ - Added a plugin system for new functionality
14
+
15
+ ### Removed
16
+
17
+ - Moved MADR Decision Records to a separate plugin
18
+ - Moved Contributor Covenant Code of Conduct to a separate plugin
19
+ - Moved MegaLinter to a separate plugin
20
+ - Moved Keep a Changelog to a separate plugin
21
+ - Removed GitHub Pages
22
+
23
+ ### Security
24
+
25
+ - Addressed known dependabot vulnerabilities
26
+
27
+ ### Fixed
28
+
29
+ - A Changelog can now be created in project that hasn't been initialised as a git repository
30
+ - Fixed the way active_support is used in this (non-rails) project
31
+
10
32
  ## [1.0.0] - 2023-02-17
11
33
 
12
34
  ### Added
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,4 +1,4 @@
1
-
1
+ <!--alex disable sex sexual-->
2
2
  # Contributor Covenant Code of Conduct
3
3
 
4
4
  ## Our Pledge
@@ -23,7 +23,7 @@ community include:
23
23
  * Giving and gracefully accepting constructive feedback
24
24
  * Accepting responsibility and apologizing to those affected by our mistakes,
25
25
  and learning from the experience
26
- * Focusing on what is best not just for us as individuals, but for the overall
26
+ * Focusing on what is best not only for us as individuals, but for the overall
27
27
  community
28
28
 
29
29
  Examples of unacceptable behavior include:
data/README.md CHANGED
@@ -1,90 +1,78 @@
1
- # HDI Engineering Way of Working
2
- [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
1
+ # Way of Working
2
+
3
+ <!-- Way of Working: Main Badge Holder Start -->
4
+ ![Way of Working Badge](https://img.shields.io/badge/Way_of_Working-v2.0.0-%238169e3?labelColor=black)
5
+ <!-- Way of Working: Additional Badge Holder Start -->
6
+ <!-- Way of Working: Badge Holder End -->
7
+
8
+ [![Gem Version](https://badge.fury.io/rb/way_of_working.svg)](https://badge.fury.io/rb/way_of_working)
9
+ <br />
3
10
  [![MegaLinter](https://github.com/HealthDataInsight/way_of_working/workflows/MegaLinter/badge.svg?branch=main)](https://github.com/HealthDataInsight/way_of_working/actions?query=workflow%3AMegaLinter+branch%3Amain)
4
- [![Keep a Changelog v1.1.0 badge][changelog-badge]][changelog]
11
+ [![Inclusive Language](https://github.com/HealthDataInsight/way_of_working/actions/workflows/inclusive-language.yml/badge.svg)](https://github.com/HealthDataInsight/way_of_working/actions/workflows/inclusive-language.yml)
5
12
 
6
13
  ## Introduction
7
14
 
8
- This framework will describe a consistent, high-quality approach to Software Engineering at HDI.
15
+ This tool underpins the Way of Working framework, used to describe a consistent, high-quality approach to Software Engineering. It is intended as an opinionated approach supporting rapid development, across numerous projects, by a fungible workforce who can swap between assignments with the minimum friction.
9
16
 
10
- It is an opinionated approach intending to support rapid development, across numerous projects, by a fungible workforce who can swap between assignments with the minimum friction.
17
+ It consists command line tool that uses a modular, plugin-based system to gain functionality, allowing for organisations to pick and choose different solutions for the same feature.
18
+ Organisations can create their own gem which defines the specific plugin dependencies which form their way of working. See the [Way of Working for HDI](https://github.com/HealthDataInsight/way_of_working-for-hdi) as an example.
11
19
 
12
- It builds on the [twelve-factor app](https://12factor.net) methodology and is intended to be compatible with the [NHS Digital Software Engineering Quality Framework](https://github.com/NHSDigital/software-engineering-quality-framework) and other frameworks like [the GDS Way](https://gds-way.cloudapps.digital).
20
+ There are subcommands that plugins hook into which enable them to add GitHub actions, configuration and other files to a project and GitHub pages outlining the tooling choice and thinking behind it.
13
21
 
14
- The most significant difference here is that we will be opinionated and make technological and process choices. Of course, users are encouraged to discuss and submit Pull Requests (PRs) if they want changes to the choices made, but by making those choices, we can automate many tedious background tasks that are currently manual.
22
+ Below is a list of plugins that have been implemented so far:
15
23
 
16
- ## Installation
24
+ | Feature | Plugin | Description |
25
+ | --------------------- | -------------------------------------- | ------------------------------------------------------------------------------ |
26
+ | Changelog | [changelog-keepachangelog] | Implements [keepachangelog v1.1] |
27
+ | Code Linting | [code_linting-hdi] | Implements a combination of [MegaLinter] and [RuboCop] built on NDRS standards |
28
+ | Code of Conduct | [code_of_conduct-contributor_covenant] | Implements [Contributor Covenant v2.1] |
29
+ | Decision Records | [decision_record-madr] | Implements [MADR v3] |
30
+ | Inclusive Language | [inclusive_language-alex] | Implements [alex] |
31
+ | Pull Request Template | [pull_request_template-hdi] | Implements a bespoke PR template |
17
32
 
18
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
33
+ ## Installation
19
34
 
20
35
  Install the gem and add to the application's Gemfile by executing:
21
36
 
22
- bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
37
+ ```bash
38
+ bundle add way_of_working
39
+ ```
23
40
 
24
41
  If bundler is not being used to manage dependencies, install the gem by executing:
25
42
 
26
- gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
43
+ ```bash
44
+ gem install way_of_working
45
+ ```
27
46
 
28
47
  ## Usage
29
48
 
30
- ### Changelog
31
-
32
- To add a [keep a changelog v1.1.0](https://keepachangelog.com/en/1.1.0/) changelog to your project, use the following at the command line:
33
-
34
- way_of_working init changelog
35
-
36
- ### Code Of Conduct
37
-
38
- To add a [Contributor Covenant](https://www.contributor-covenant.org/version/2/1/code_of_conduct/) Code of Conduct v2.1 to your project, use the following at the command line:
39
-
40
- way_of_working init code_of_conduct --contact-method [CONTACT METHOD]
41
-
42
- You will need to enter a contact method, usually an email address. Please thoroughly read the [enforcement guidelines](https://www.contributor-covenant.org/version/2/1/code_of_conduct/#enforcement-guidelines) section of the code and discuss the implications of adopting the code of conduct.
43
-
44
- ### Decision Records
45
-
46
- To add the [Markdown Any Decision Records (MADR)](https://adr.github.io/madr/) v3.0.0 framework to your project, run the following at the command line:
47
-
48
- way_of_working init decision_record
49
-
50
- To create a new decision record, run:
51
-
52
- way_of_working new decision_record [NAME]
53
-
54
- Where `[NAME]` is the title of your decision record, for example:
55
-
56
- way_of_working new decision_record "Use Markdown Any Decision Records"
57
-
58
- ### Linter
59
-
60
- To add [MegaLinter](https://megalinter.io/) to your project, run the following at the command line:
61
-
62
- way_of_working init linter
63
-
64
- to run MegaLinter in your project, run:
65
-
66
- way_of_working exec linter
67
-
68
49
  ### Initialise All Components
69
50
 
70
51
  To add all the Way of Working components to your project, run:
71
52
 
72
- way_of_working init all --contact-method [CONTACT METHOD]
53
+ ```bash
54
+ way_of_working init all --contact-method [CONTACT METHOD]
55
+ ```
73
56
 
74
- Providing the Code of Conduct `[CONTACT METHOD]` described above.
57
+ You will need to provide the Code of Conduct `[CONTACT METHOD]`, usually an email address, for community leaders to receive reports of unacceptable behavior.
75
58
 
76
59
  ### Help
77
60
 
78
61
  More help on using the command line tool is found by using:
79
62
 
80
- way_of_working help
63
+ ```bash
64
+ way_of_working help
65
+ ```
81
66
 
82
67
  ## Development
83
68
 
84
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. This RubyGem was created using `bundle gem --exe way_of_working`.
69
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
70
+ This RubyGem was created using `bundle gem --exe way_of_working`.
85
71
 
86
72
  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
73
 
74
+ When creating plugins, the convention is to create them within the WayOfWorking and feature namespaces. E.g.
75
+
88
76
  ## Contributing
89
77
 
90
78
  Bug reports and pull requests are welcome on GitHub at <https://github.com/HealthDataInsight/way_of_working>. 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/HealthDataInsight/way_of_working/blob/main/CODE_OF_CONDUCT.md).
@@ -97,5 +85,15 @@ The gem is available as open source under the terms of the [MIT License](https:/
97
85
 
98
86
  Everyone interacting in the WayOfWorking project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/HealthDataInsight/way_of_working/blob/main/CODE_OF_CONDUCT.md).
99
87
 
100
- [changelog]: ./CHANGELOG.md
101
- [changelog-badge]: https://img.shields.io/badge/changelog-Keep%20a%20Changelog%20v1.1.0-%23E05735
88
+ [alex]:https://alexjs.com
89
+ [Contributor Covenant v2.1]: https://www.contributor-covenant.org
90
+ [keepachangelog v1.1]: https://keepachangelog.com/en/1.1.0/
91
+ [MADR v3]: https://adr.github.io/madr/
92
+ [MegaLinter]: https://megalinter.io/
93
+ [RuboCop]: https://rubocop.org
94
+ [changelog-keepachangelog]: https://github.com/HealthDataInsight/way_of_working-changelog-keepachangelog
95
+ [code_linting-hdi]: https://github.com/HealthDataInsight/way_of_working-code_linting-hdi
96
+ [code_of_conduct-contributor_covenant]: https://github.com/HealthDataInsight/way_of_working-code_of_conduct-contributor_covenant
97
+ [decision_record-madr]: https://github.com/HealthDataInsight/way_of_working-decision_record-madr
98
+ [inclusive_language-alex]: https://github.com/HealthDataInsight/way_of_working-inclusive_language-alex
99
+ [pull_request_template-hdi]: https://github.com/HealthDataInsight/way_of_working-pull_request_template-hdi
data/exe/way_of_working CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require 'way_of_working'
4
4
 
5
- WayOfWorking::CLI.start(ARGV)
5
+ WayOfWorking::Cli.start(ARGV)
@@ -5,7 +5,7 @@ GEM_VERSION_PLATFORM_REGEXP = /
5
5
  (?:-(java|(?:aarch|arm|x)(?:86)?(?:_)?(?:64)?-(?:darwin|linux|mingw32|mingw-ucrt)))?
6
6
  \.gem
7
7
  \z
8
- /ix.freeze
8
+ /ix
9
9
 
10
10
  namespace :audit do
11
11
  desc 'This tasks audits vendored gems, comparing file digests with published ones'
@@ -21,7 +21,7 @@ namespace :audit do
21
21
  git_user_name = git_base.config('user.name')
22
22
  failed = false
23
23
 
24
- Dir['vendor/cache/*.gem'].sort.each do |path|
24
+ Dir['vendor/cache/*.gem'].each do |path|
25
25
  file_digest = Digest::SHA256.file(path).hexdigest
26
26
  file_name = File.basename(path)
27
27
  matchdata = GEM_VERSION_PLATFORM_REGEXP.match(file_name)
@@ -1,125 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'generators/changelog/init'
4
- require_relative 'generators/code_of_conduct/init'
5
- require_relative 'generators/decision_record/init'
6
- require_relative 'generators/decision_record/new'
7
- require_relative 'generators/linter/exec'
8
- require_relative 'generators/linter/init'
9
- require_relative 'generators/rake_tasks/init'
10
- require_relative 'sub_command_base'
3
+ require 'thor'
11
4
 
12
- module WayOfWorking
13
- # This class defines the exec (i.e. run) parent command
14
- class Exec < SubCommandBase
15
- register(Generators::Linter::Exec, 'linter', 'linter',
16
- <<~LONGDESC)
17
- Description:
18
- This runs the linter on this project
19
-
20
- Example:
21
- way_of_working exec linter
22
- LONGDESC
23
- end
24
-
25
- # This class defines the "init" parent command
26
- class Init < SubCommandBase
27
- desc 'all --contact-method [CONTACT METHOD]',
28
- 'This adds all of the available Way of Working components to this project'
29
- method_option :contact_method, required: true
30
- def all
31
- invoke_all
32
- end
33
-
34
- register(Generators::Changelog::Init, 'changelog', 'changelog',
35
- <<~LONGDESC)
36
- Description:
37
- This adds the Keep a Changelog v1.1 changelog to the project
38
-
39
- Example:
40
- way_of_working init changelog
41
-
42
- This will create:
43
- CHANGELOG.md
44
- LONGDESC
45
-
46
- register(Generators::CodeOfConduct::Init, 'code_of_conduct',
47
- 'code_of_conduct --contact-method [CONTACT METHOD]',
48
- <<~LONGDESC)
49
- Description:
50
- This adds the Contributor Covenant v2.1 code of conduct to the project
51
-
52
- Example:
53
- way_of_working init code_of_conduct --contact-method "foo@bar.com"
54
-
55
- This will create:
56
- CODE_OF_CONDUCT.md
57
- LONGDESC
58
-
59
- register(Generators::DecisionRecord::Init, 'decision_record', 'decision_record',
60
- <<~LONGDESC)
61
- Description:
62
- This generator adds Markdown Any Decision Records (MADR) to your project
63
-
64
- Example:
65
- way_of_working init decision_record
66
-
67
- This will create:
68
- docs/decisions/README.md
69
- docs/decisions/adr-template.md
70
- docs/decisions/0000-use-markdown-any-decision-records.md
71
- LONGDESC
72
-
73
- register(Generators::Linter::Init, 'linter', 'linter',
74
- <<~LONGDESC)
75
- Description:
76
- Installs MegaLinter config files into the project
77
-
78
- Example:
79
- way_of_working init linter
80
-
81
- This will create:
82
- .github/workflows/mega-linter.yml
83
- .mega-linter.yml
84
- LONGDESC
85
-
86
- register(Generators::RakeTasks::Init, 'rake_tasks', 'rake_tasks',
87
- <<~LONGDESC)
88
- Description:
89
- Installs Way of Working rake tasks into this project
90
-
91
- Example:
92
- way_of_working init rake_tasks
93
-
94
- This will amend or create:
95
- Rakefile
96
- LONGDESC
97
- end
98
-
99
- # This class defines the "new" parent command
100
- class New < SubCommandBase
101
- register(Generators::DecisionRecord::New, 'decision_record', 'decision_record [NAME]',
102
- <<~LONGDESC)
103
- Description:
104
- This generator adds a new decision record to your project
105
-
106
- Example:
107
- way_of_working new decision_record "Title of the decision"
108
-
109
- This will create:
110
- docs/decisions/NNNN-title-of-the-decision.md
111
- LONGDESC
112
- end
5
+ require_relative 'sub_commands/exec'
6
+ require_relative 'sub_commands/init'
7
+ require_relative 'sub_commands/new'
113
8
 
9
+ module WayOfWorking
114
10
  # This class defines the top level interface
115
- class CLI < Thor
11
+ class Cli < Thor
12
+ desc 'exec [COMPONENT]', 'Executes (runs) the specific component'
13
+ subcommand 'exec', ::WayOfWorking::SubCommands::Exec
14
+
116
15
  desc 'init [COMPONENT]', 'Initialises Way of Working components'
117
- subcommand 'init', Init
16
+ subcommand 'init', ::WayOfWorking::SubCommands::Init
118
17
 
119
18
  desc 'new [THING]', 'Creates new things'
120
- subcommand 'new', New
121
-
122
- desc 'exec [COMPONENT]', 'Executes (runs) the specific component'
123
- subcommand 'exec', Exec
19
+ subcommand 'new', ::WayOfWorking::SubCommands::New
124
20
  end
125
21
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WayOfWorking
4
+ # This class stores config information
5
+ class Configuration
6
+ class << self
7
+ attr_writer :organisation_abbreviation, :organisation_gem_version
8
+
9
+ def main_badge_name
10
+ [@organisation_abbreviation, 'Way of Working'].compact.join(' ')
11
+ end
12
+
13
+ def main_badge_version
14
+ @organisation_gem_version || WayOfWorking::VERSION
15
+ end
16
+ end
17
+ end
18
+ end
@@ -35,9 +35,7 @@ module WayOfWorking
35
35
  tags.each do |tag|
36
36
  next if tag.version.nil?
37
37
 
38
- if previous_version && tag.version <= previous_version
39
- raise 'Tag versions are not incremental over time'
40
- end
38
+ raise 'Tag versions are not incremental over time' if previous_version && tag.version <= previous_version
41
39
 
42
40
  previous_version = tag.version
43
41
  end
@@ -2,9 +2,10 @@
2
2
 
3
3
  require 'pathname'
4
4
 
5
- # Mixin that provides a couple of pathname convenience methods
5
+ # The Way of Working namespace
6
6
  module WayOfWorking
7
- class << self
7
+ # Mixin that provides a couple of pathname convenience methods
8
+ module Paths
8
9
  def root
9
10
  Pathname.new(File.expand_path('../..', __dir__))
10
11
  end
@@ -13,4 +14,6 @@ module WayOfWorking
13
14
  root.join('lib', 'way_of_working', 'templates')
14
15
  end
15
16
  end
17
+
18
+ extend Paths
16
19
  end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+ require 'way_of_working/readme_badge/paths'
5
+
6
+ module WayOfWorking
7
+ module ReadmeBadge
8
+ module Generators
9
+ HOLDER_END_TAG = "<!-- Way of Working: Badge Holder End -->\n"
10
+
11
+ # This generator adds the alexrc file
12
+ class Init < Thor::Group
13
+ include Thor::Actions
14
+
15
+ source_root ::WayOfWorking::ReadmeBadge.source_root
16
+
17
+ def create_template_readme_if_missing
18
+ template_if_missing 'README.md'
19
+ end
20
+
21
+ def insert_badge_holder_into_readme
22
+ content = <<~MARKDOWN + HOLDER_END_TAG
23
+
24
+ <!-- Way of Working: Main Badge Holder Start -->
25
+ #{main_badge}
26
+ <!-- Way of Working: Additional Badge Holder Start -->
27
+ MARKDOWN
28
+
29
+ insert_into_file 'README.md', content, after: /^#\s.*?\n/
30
+ end
31
+
32
+ def copy_way_of_working_documentation
33
+ template 'docs/way_of_working/readme-badges.md'
34
+ end
35
+
36
+ private
37
+
38
+ def main_badge
39
+ shield_url = 'https://img.shields.io/badge/' \
40
+ "#{WayOfWorking::Configuration.main_badge_name.gsub(' ', '_')}-" \
41
+ "v#{WayOfWorking::Configuration.main_badge_version}-%238169e3?labelColor=black"
42
+ "![#{WayOfWorking::Configuration.main_badge_name} Badge](#{shield_url})"
43
+ end
44
+
45
+ def template_if_missing(path)
46
+ destination_path = File.join(destination_root, path)
47
+ return if behavior == :revoke || File.exist?(destination_path)
48
+
49
+ template(path)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'way_of_working/audit/github/rules/base'
4
+
5
+ module WayOfWorking
6
+ # Namespace for the "internal" ReadmeBadge rule
7
+ module ReadmeBadge
8
+ # This rule checks for a README and Way of Working badge.
9
+ class GithubAuditRule < ::WayOfWorking::Audit::Github::Rules::Base
10
+ def valid?
11
+ @errors << 'No README' if readme_content.nil?
12
+ @errors << 'No Way of Working README Badge' unless readme_way_of_working_badge?
13
+
14
+ @errors.empty? ? :passed : :failed
15
+ end
16
+
17
+ private
18
+
19
+ def readme_way_of_working_badge?
20
+ readme_content.include?('Way of Working Badge](https://img.shields.io/badge/')
21
+ end
22
+ end
23
+
24
+ ::WayOfWorking::Audit::Github::Rules::Registry.register(GithubAuditRule,
25
+ 'Project README and Way of Working badge')
26
+ end
27
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+
5
+ module WayOfWorking
6
+ # Mixin that provides a couple of pathname convenience methods
7
+ module ReadmeBadge
8
+ class << self
9
+ def root
10
+ Pathname.new(File.expand_path('../../..', __dir__))
11
+ end
12
+
13
+ def source_root
14
+ root.join('lib', 'way_of_working', 'readme_badge', 'templates')
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ # {name of project}
2
+
3
+ Read the GitHub documentation to [learn more about READMEs](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-readmes).
@@ -0,0 +1,24 @@
1
+ ---
2
+ layout: page
3
+ ---
4
+ # README Badges
5
+
6
+ Badges at the top of a project's README file are a powerful tool for providing immediate, concise, and digestible information about a project.
7
+
8
+ They are an important feature, as they communicate crucial insights such as the build status, test coverage, package version, licensing information, or even the platform compatibility of the project, all at a glance. Badges allow developers to quickly gauge the project's health, and maintenance level, without delving into the project's codebase or documentation.
9
+
10
+ Moreover, badges can help foster a sense of openness and reliability within the open-source community, as they provide a transparent snapshot of the project's current state. This makes them essential to building trust and confidence in a project, which can facilitate broader adoption and community involvement.
11
+
12
+ Our badge "panel" is a set of predefined HTML comments that top and tail Way of Working badges in the README, so that other generators within the framework can automatically find the panel and add their badge(s) to it.
13
+
14
+ <%= main_badge %>
15
+
16
+ We have created a Way of Working badge to identify at a glance that a project has adopted the Way of Working.
17
+
18
+ ## Usage
19
+
20
+ To add the badge "panel" and Way of Working badge to your project, use the following at the command line:
21
+
22
+ ```bash
23
+ way_of_working init readme_badge
24
+ ```
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'readme_badge/generators/init'
4
+
5
+ # If way_of_working-audit-github is used we can add a rule
6
+ github_audit_used =
7
+ begin
8
+ require 'way_of_working/audit/github/rules/registry'
9
+ rescue LoadError
10
+ false
11
+ end
12
+ require_relative 'readme_badge/github_audit_rule' if github_audit_used
13
+
14
+ module WayOfWorking
15
+ module SubCommands
16
+ # This reopens the "way_of_working init" sub command
17
+ class Init
18
+ register(WayOfWorking::ReadmeBadge::Generators::Init, 'readme_badge', 'readme_badge',
19
+ <<~LONGDESC)
20
+ Description:
21
+ Installs Way of Working readme badge and badge holder into this project
22
+
23
+ Example:
24
+ way_of_working init readme_badge
25
+
26
+ This will amend or create:
27
+ README.md
28
+ LONGDESC
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+
5
+ module WayOfWorking
6
+ module SubCommands
7
+ # This base class enables subcommands to work correctly with help. See:
8
+ # https://github.com/rails/thor/wiki/Subcommands#subcommands-that-work-correctly-with-help
9
+ class Base < Thor
10
+ def self.banner(command, _namespace = nil, _subcommand = false)
11
+ "#{basename} #{subcommand_prefix} #{command.usage}"
12
+ end
13
+
14
+ def self.subcommand_prefix
15
+ name.gsub(/.*::/, '').gsub(/^[A-Z]/) { |match| match[0].downcase }.
16
+ gsub(/[A-Z]/) { |match| "-#{match[0].downcase}" }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base'
4
+
5
+ module WayOfWorking
6
+ module SubCommands
7
+ # This class defines the exec (i.e. run) parent command
8
+ class Exec < Base
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base'
4
+
5
+ module WayOfWorking
6
+ module SubCommands
7
+ # This class defines the "init" parent command
8
+ class Init < Base
9
+ desc 'all --contact-method [CONTACT METHOD]',
10
+ 'This adds all of the available Way of Working components to this project'
11
+ method_option :contact_method, required: true
12
+ def all
13
+ invoke_all
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base'
4
+
5
+ module WayOfWorking
6
+ module SubCommands
7
+ # This class defines the "way_of_working new ..." sub command
8
+ class New < Base
9
+ end
10
+ end
11
+ end