way_of_working 2.0.0 → 2.1.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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -1
  3. data/CONTRIBUTING.md +62 -0
  4. data/README.md +187 -14
  5. data/lib/way_of_working/audit/github/auditor.rb +44 -0
  6. data/lib/way_of_working/audit/github/generators/exec.rb +163 -0
  7. data/lib/way_of_working/audit/github/rules/base.rb +91 -0
  8. data/lib/way_of_working/audit/github/rules/registry.rb +36 -0
  9. data/lib/way_of_working/audit/github/rules/unknown.rb +19 -0
  10. data/lib/way_of_working/audit/github.rb +25 -0
  11. data/lib/way_of_working/changelog/keepachangelog/generators/init.rb +118 -0
  12. data/lib/way_of_working/changelog/keepachangelog/github_audit_rule.rb +32 -0
  13. data/lib/way_of_working/changelog/keepachangelog/templates/docs/way_of_working/changelog.md +73 -0
  14. data/lib/way_of_working/changelog/keepachangelog.rb +35 -0
  15. data/lib/way_of_working/code_of_conduct/contributor_covenant/generators/init.rb +39 -0
  16. data/lib/way_of_working/code_of_conduct/contributor_covenant/github_audit_rule.rb +32 -0
  17. data/lib/way_of_working/code_of_conduct/contributor_covenant/templates/CODE_OF_CONDUCT.md.tt +133 -0
  18. data/lib/way_of_working/code_of_conduct/contributor_covenant/templates/docs/way_of_working/code-of-conduct.md +78 -0
  19. data/lib/way_of_working/code_of_conduct/contributor_covenant.rb +36 -0
  20. data/lib/way_of_working/decision_record/madr/generators/init.rb +41 -0
  21. data/lib/way_of_working/decision_record/madr/generators/new.rb +69 -0
  22. data/lib/way_of_working/decision_record/madr/github_audit_rule.rb +50 -0
  23. data/lib/way_of_working/decision_record/madr/templates/.github/ISSUE_TEMPLATE/decision-record.md +26 -0
  24. data/lib/way_of_working/decision_record/madr/templates/docs/decisions/0000-use-markdown-any-decision-records.md +30 -0
  25. data/lib/way_of_working/decision_record/madr/templates/docs/decisions/README.md +7 -0
  26. data/lib/way_of_working/decision_record/madr/templates/docs/decisions/adr-template.md.tt +82 -0
  27. data/lib/way_of_working/decision_record/madr/templates/docs/decisions/index.md +48 -0
  28. data/lib/way_of_working/decision_record/madr/templates/docs/way_of_working/decision-records.md +195 -0
  29. data/lib/way_of_working/decision_record/madr.rb +53 -0
  30. data/lib/way_of_working/git/repo_reader.rb +2 -2
  31. data/lib/way_of_working/inclusive_language/alex/generators/exec.rb +51 -0
  32. data/lib/way_of_working/inclusive_language/alex/generators/init.rb +34 -0
  33. data/lib/way_of_working/inclusive_language/alex/github_audit_rule.rb +35 -0
  34. data/lib/way_of_working/inclusive_language/alex/templates/.alexignore +2 -0
  35. data/lib/way_of_working/inclusive_language/alex/templates/.alexrc +3 -0
  36. data/lib/way_of_working/inclusive_language/alex/templates/.github/workflows/inclusive-language.yml +16 -0
  37. data/lib/way_of_working/inclusive_language/alex/templates/docs/way_of_working/inclusive-language.md +28 -0
  38. data/lib/way_of_working/inclusive_language/alex.rb +48 -0
  39. data/lib/way_of_working/pull_request_template/hdi/generators/init.rb +26 -0
  40. data/lib/way_of_working/pull_request_template/hdi/github_audit_rule.rb +32 -0
  41. data/lib/way_of_working/pull_request_template/hdi/templates/.github/pull_request_template.md +51 -0
  42. data/lib/way_of_working/pull_request_template/hdi/templates/docs/way_of_working/pull-request-template-and-guidelines.md +50 -0
  43. data/lib/way_of_working/pull_request_template/hdi.rb +35 -0
  44. data/lib/way_of_working/readme_badge/github_audit_rule.rb +1 -3
  45. data/lib/way_of_working/readme_badge/paths.rb +5 -2
  46. data/lib/way_of_working/readme_badge.rb +5 -7
  47. data/lib/way_of_working/version.rb +1 -1
  48. data/lib/way_of_working/versioning/semver/generators/init.rb +20 -0
  49. data/lib/way_of_working/versioning/semver/github_audit_rule.rb +49 -0
  50. data/lib/way_of_working/versioning/semver/templates/docs/way_of_working/versioning.md +71 -0
  51. data/lib/way_of_working/versioning/semver.rb +35 -0
  52. data/lib/way_of_working.rb +15 -0
  53. data/way_of_working.gemspec +4 -1
  54. metadata +89 -4
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'unknown'
4
+
5
+ module WayOfWorking
6
+ module Audit
7
+ module Github
8
+ module Rules
9
+ # This provides the GitHub audit rule factory
10
+ module Registry
11
+ class << self
12
+ attr_accessor :rules
13
+
14
+ def register(klass, rule_name)
15
+ @rules ||= {}
16
+
17
+ @rules[rule_name] = klass
18
+ end
19
+
20
+ def unregister(*rule_names)
21
+ rule_names.each do |rule_name|
22
+ @rules.delete(rule_name)
23
+ end
24
+ end
25
+
26
+ def rule(rule_name, client, repo)
27
+ klass = Registry.rules.fetch(rule_name, Unknown)
28
+
29
+ klass.new(client, repo)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base'
4
+
5
+ module WayOfWorking
6
+ module Audit
7
+ module Github
8
+ module Rules
9
+ # This is a stub handler for rules that aren't in the registry.
10
+ class Unknown < Base
11
+ def initialize(client, name, repo, rulesets, fix = false)
12
+ super
13
+ raise 'Error: Unknown client'
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'github/generators/exec'
4
+
5
+ module WayOfWorking
6
+ module Audit
7
+ module Github
8
+ class Error < StandardError; end
9
+ end
10
+ end
11
+
12
+ module SubCommands
13
+ # This reopens the "way_of_working exec" sub command
14
+ class Exec
15
+ register(Audit::Github::Generators::Exec, 'audit_github', 'audit_github',
16
+ <<~LONGDESC)
17
+ Description:
18
+ This runs the GitHub audit
19
+
20
+ Example:
21
+ way_of_working exec audit_github
22
+ LONGDESC
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,118 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'way_of_working/git/repo_reader'
4
+
5
+ module WayOfWorking
6
+ module Changelog
7
+ module Keepachangelog
8
+ module Generators
9
+ # This class generates the CHANGELOG.md file, generating sections based on
10
+ # git tags and commit messages (where possible).
11
+ class Init < Thor::Group
12
+ include Thor::Actions
13
+
14
+ source_root WayOfWorking.root.join('lib', 'way_of_working', 'changelog', 'keepachangelog', 'templates')
15
+
16
+ HEADER_TEXT = <<~TEXT
17
+ # Changelog
18
+
19
+ All notable changes to this project will be documented in this file.
20
+
21
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
22
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
23
+
24
+ TEXT
25
+
26
+ def add_changelog_to_project
27
+ create_file 'CHANGELOG.md' do
28
+ HEADER_TEXT + releases + footer
29
+ end
30
+ end
31
+
32
+ def copy_way_of_working_documentation
33
+ copy_file 'docs/way_of_working/changelog.md'
34
+ end
35
+
36
+ private
37
+
38
+ def releases
39
+ text = "## [Unreleased]\n\n"
40
+ text += added_change_text(:minor)
41
+ text += deprecated_removed_fixed_security_text(:minor)
42
+
43
+ summary_tags.each do |summary_tag|
44
+ text += "## [#{summary_tag.version}] - " \
45
+ "#{summary_tag.commit_date.strftime('%Y-%m-%d')}\n\n"
46
+
47
+ text += added_change_text(summary_tag.change_type)
48
+ text += deprecated_removed_fixed_security_text(summary_tag.change_type)
49
+ end
50
+
51
+ text
52
+ end
53
+
54
+ def added_change_text(tag_change_type)
55
+ return '' if tag_change_type == :patch
56
+
57
+ change_text('Added', 'Detail new feature(s) here', true) +
58
+ change_text('Change', 'Detail change(s) in existing functionality here',
59
+ tag_change_type == :major)
60
+ end
61
+
62
+ def deprecated_removed_fixed_security_text(tag_change_type)
63
+ change_text('Deprecated', 'Detail soon-to-be removed features here') +
64
+ change_text('Removed', 'Detail removed features here', tag_change_type == :major) +
65
+ change_text('Fixed', 'Detail any bug fixes here', true) +
66
+ change_text('Security', 'Detail fixes to vulnerabilities here')
67
+ end
68
+
69
+ # This method adds all of the reference style markdown links
70
+ def footer
71
+ return '' if summary_tags.empty?
72
+
73
+ previous_tag = nil
74
+ footer_text = ''
75
+ summary_tags.each do |summary_tag|
76
+ footer_text += if previous_tag
77
+ release_link(summary_tag.name, previous_tag.name, previous_tag.version)
78
+ else
79
+ release_link(summary_tag.name, 'HEAD', 'Unreleased')
80
+ end
81
+
82
+ previous_tag = summary_tag
83
+ end
84
+
85
+ footer_text += "[#{previous_tag.version}]: #{url}/releases/tag/#{previous_tag.name}\n"
86
+
87
+ footer_text
88
+ end
89
+
90
+ def release_link(start_tag, end_tag, version)
91
+ "[#{version}]: #{url}/compare/#{start_tag}...#{end_tag}\n"
92
+ end
93
+
94
+ def change_text(type, description, likely = false)
95
+ text = "### #{type}\n\n- TODO: #{description}"
96
+ text += ' (if any)' unless likely
97
+ text += "\n\n"
98
+ text
99
+ end
100
+
101
+ def repo_reader
102
+ @repo_reader ||= ::WayOfWorking::Git::RepoReader.new(::Git.open('.'))
103
+ end
104
+
105
+ def summary_tags
106
+ @summary_tags ||= repo_reader.summary_tags.reverse
107
+ rescue ArgumentError
108
+ []
109
+ end
110
+
111
+ def url
112
+ @url ||= repo_reader.likely_upstream_remote_url
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'way_of_working/audit/github/rules/base'
4
+
5
+ module WayOfWorking
6
+ module Changelog
7
+ # The namespace for this plugin
8
+ module Keepachangelog
9
+ # This rule checks for the Pull Request template.
10
+ class GithubAuditRule < ::WayOfWorking::Audit::Github::Rules::Base
11
+ def validate
12
+ @errors << 'No Keep a Changelog CHANGELOG.md found' unless keep_a_changelog_found?
13
+ end
14
+
15
+ private
16
+
17
+ def keep_a_changelog_found?
18
+ response = @client.contents(@repo_name, path: 'CHANGELOG.md')
19
+ decoded_content = Base64.decode64(response.content)
20
+
21
+ decoded_content.include?('Keep a Changelog')
22
+ rescue Octokit::NotFound
23
+ false
24
+ end
25
+ end
26
+
27
+ ::WayOfWorking::Audit::Github::Rules::Registry.register(
28
+ GithubAuditRule, 'Keep a Changelog CHANGELOG.md'
29
+ )
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,73 @@
1
+ ---
2
+ layout: page
3
+ status: REQUIRED
4
+ enforcement: manual
5
+ ---
6
+
7
+ # Changelog
8
+
9
+ ![Keep a Changelog v1.1.0 badge][changelog-badge]
10
+
11
+ ## Purpose
12
+
13
+ Maintain a human-readable project history that documents all notable changes between versions in plain English.
14
+
15
+ ## Scope
16
+
17
+ All projects must maintain a changelog using [Keep a Changelog v1.1.0][keep-a-changelog] format.
18
+
19
+ ## Requirements
20
+
21
+ - Human-written plain English summaries (not commit log dumps)
22
+ - Entry for every version
23
+ - Latest version listed first
24
+ - Release date displayed for each version
25
+ - Changes grouped by type: `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`, `Security`
26
+ - Versions and sections must be linkable
27
+ - Follow [Semantic Versioning][semver]
28
+ - Update changelog within Pull Requests, not at release time
29
+
30
+ ## Setup
31
+
32
+ Initialise a changelog for your project:
33
+
34
+ ```bash
35
+ way_of_working init changelog
36
+ ```
37
+
38
+ For git-based projects with existing releases, this scaffolds sections based on semantic version tags.
39
+
40
+ ## Usage
41
+
42
+ 1. Update the `Unreleased` section in each Pull Request
43
+ 2. Group changes under appropriate headings
44
+ 3. Write clear, user-focused descriptions
45
+ 4. Move `Unreleased` changes to a version section at release
46
+ 5. Use scaffolded commit links to document historical changes
47
+
48
+ ## Enforcement
49
+
50
+ - Changelog updates required in Pull Request reviews
51
+ - No automatic commit log dumps permitted
52
+
53
+ ## Examples
54
+
55
+ ```markdown
56
+ ## [1.2.0] - 2025-10-22
57
+
58
+ ### Added
59
+ - User authentication via OAuth2
60
+ - Export data to CSV functionality
61
+
62
+ ### Fixed
63
+ - Memory leak in background job processor
64
+ ```
65
+
66
+ ## Resources
67
+
68
+ - [Keep a Changelog][keep-a-changelog]
69
+ - [Semantic Versioning][semver]
70
+
71
+ [changelog-badge]: https://img.shields.io/badge/changelog-Keep%20a%20Changelog%20v1.1.0-%23E05735
72
+ [keep-a-changelog]: https://keepachangelog.com/en/1.1.0/
73
+ [semver]: https://semver.org
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'keepachangelog/generators/init'
4
+
5
+ # If way_of_working-audit-github is used we can add a rule
6
+ begin
7
+ require 'way_of_working/audit/github/rules/registry'
8
+ require_relative 'keepachangelog/github_audit_rule'
9
+ rescue LoadError # rubocop:disable Lint/SuppressedException
10
+ end
11
+
12
+ module WayOfWorking
13
+ module Changelog
14
+ module Keepachangelog
15
+ class Error < StandardError; end
16
+ end
17
+ end
18
+
19
+ module SubCommands
20
+ # This reopens the "way_of_working init" sub command
21
+ class Init
22
+ register(Changelog::Keepachangelog::Generators::Init, 'changelog', 'changelog',
23
+ <<~LONGDESC)
24
+ Description:
25
+ This adds the Keep a Changelog v1.1 changelog to the project
26
+
27
+ Example:
28
+ way_of_working init changelog
29
+
30
+ This will create:
31
+ CHANGELOG.md
32
+ LONGDESC
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'way_of_working/paths'
4
+
5
+ module WayOfWorking
6
+ module CodeOfConduct
7
+ module ContributorCovenant
8
+ module Generators
9
+ # This class fetches the CODE_OF_CONDUCT.md and inserts the contact method
10
+ class Init < Thor::Group
11
+ include Thor::Actions
12
+
13
+ source_root WayOfWorking.root.join('lib', 'way_of_working', 'code_of_conduct', 'contributor_covenant',
14
+ 'templates')
15
+
16
+ class_option :contact_method, required: true
17
+
18
+ # Use this method to update the cached template when required
19
+ # def download_and_save_code_of_conduct_template
20
+ # code_of_conduct_file = 'lib/way_of_working/templates/CODE_OF_CONDUCT.md.tt'
21
+
22
+ # get 'https://www.contributor-covenant.org/version/2/1/code_of_conduct/code_of_conduct.md',
23
+ # code_of_conduct_file
24
+ # gsub_file code_of_conduct_file, '[INSERT CONTACT METHOD]',
25
+ # "<<%= options['contact_method'] %>>"
26
+ # end
27
+
28
+ def add_code_of_conduct_to_project
29
+ template 'CODE_OF_CONDUCT.md'
30
+ end
31
+
32
+ def add_way_of_working_documentation
33
+ copy_file 'docs/way_of_working/code-of-conduct.md'
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'way_of_working/audit/github/rules/base'
4
+
5
+ module WayOfWorking
6
+ module CodeOfConduct
7
+ # The namespace for this plugin
8
+ module ContributorCovenant
9
+ # This rule checks for the MegaLinter workflow action and README badge.
10
+ class GithubAuditRule < ::WayOfWorking::Audit::Github::Rules::Base
11
+ def validate
12
+ @errors << 'No Contributor Covenant code of conduct found' unless code_of_conduct?
13
+ end
14
+
15
+ private
16
+
17
+ def code_of_conduct?
18
+ response = @client.contents(@repo_name, path: 'CODE_OF_CONDUCT.md')
19
+ decoded_content = Base64.decode64(response.content)
20
+
21
+ decoded_content.include?('# Contributor Covenant Code of Conduct')
22
+ rescue Octokit::NotFound
23
+ false
24
+ end
25
+ end
26
+
27
+ ::WayOfWorking::Audit::Github::Rules::Registry.register(
28
+ GithubAuditRule, 'Contributor Covenant Code Of Conduct'
29
+ )
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,133 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not only for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ <<%= options['contact_method'] %>>.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
133
+
@@ -0,0 +1,78 @@
1
+ ---
2
+ layout: page
3
+ status: REQUIRED
4
+ enforcement: manual
5
+ ---
6
+ # Code of Conduct
7
+
8
+ ## Purpose
9
+
10
+ We adopt the [Contributor Covenant v2.1][covenant] to establish clear behavioural expectations, create safe inclusive environments, prevent discrimination/harassment, and reduce conflicts.
11
+
12
+ {: .important }
13
+ Adoption requires more than adding `CODE_OF_CONDUCT.md`. Please read the [enforcement guidelines][enforcement] and discuss with your team.
14
+
15
+ ## Scope
16
+
17
+ Applies to all project spaces and community interactions.
18
+
19
+ **Promotes:** Respectful communication, collaboration, inclusive language, professional conduct
20
+
21
+ **Prevents:** Discrimination, harassment, unprofessional behaviour
22
+
23
+ ## Requirements
24
+
25
+ 1. Contact method for reports (email address)
26
+ 2. Enforcement responsibilities and process
27
+ 3. Consequences framework
28
+
29
+ {: .note }
30
+ Use HDI Code of Conduct email address as contact method.
31
+
32
+ ## Setup
33
+
34
+ ```bash
35
+ way_of_working init code_of_conduct --contact-method [CONTACT METHOD]
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ Command creates `CODE_OF_CONDUCT.md` in repository root.
41
+
42
+ **Post-setup:**
43
+
44
+ 1. Review enforcement guidelines with team
45
+ 2. Assign enforcement responsibilities
46
+ 3. Communicate adoption to contributors
47
+ 4. Link from README and CONTRIBUTING
48
+
49
+ **Enforcement process:**
50
+ Report → Review → Investigate → Apply consequence → Document
51
+
52
+ ## Enforcement
53
+
54
+ **Consequences:**
55
+
56
+ - **Warning:** First offense, minor issue
57
+ - **Temporary ban:** Sustained inappropriate behavior
58
+ - **Permanent ban:** Severe violations or repeat offenses
59
+
60
+ **Requirements:**
61
+
62
+ - Consistent enforcement by leadership
63
+ - Confidential handling, 5-day response
64
+ - Document incidents, annual review
65
+
66
+ ## Examples
67
+
68
+ **Acceptable:** Welcoming language, respect differing views, accept criticism, focus on community benefit
69
+
70
+ **Unacceptable:** Sexualized content, trolling/insults, harassment, publishing private info, unprofessional conduct
71
+
72
+ ## Resources
73
+
74
+ - [Contributor Covenant v2.1][covenant]
75
+ - [Enforcement Guidelines][enforcement]
76
+
77
+ [covenant]: https://www.contributor-covenant.org/version/2/1/code_of_conduct/
78
+ [enforcement]: https://www.contributor-covenant.org/version/2/1/code_of_conduct/#enforcement-guidelines
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'contributor_covenant/generators/init'
4
+
5
+ # If way_of_working-audit-github is used we can add a rule
6
+ begin
7
+ require 'way_of_working/audit/github/rules/registry'
8
+ require_relative 'contributor_covenant/github_audit_rule'
9
+ rescue LoadError # rubocop:disable Lint/SuppressedException
10
+ end
11
+
12
+ module WayOfWorking
13
+ module CodeOfConduct
14
+ module ContributorCovenant
15
+ class Error < StandardError; end
16
+ end
17
+ end
18
+
19
+ module SubCommands
20
+ # This reopens the "way_of_working init" sub command
21
+ class Init
22
+ register(CodeOfConduct::ContributorCovenant::Generators::Init, 'code_of_conduct',
23
+ 'code_of_conduct --contact-method [CONTACT METHOD]',
24
+ <<~LONGDESC)
25
+ Description:
26
+ This adds the Contributor Covenant v2.1 code of conduct to the project
27
+
28
+ Example:
29
+ way_of_working init code_of_conduct --contact-method "foo@bar.com"
30
+
31
+ This will create:
32
+ CODE_OF_CONDUCT.md
33
+ LONGDESC
34
+ end
35
+ end
36
+ end