threat 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Dangerfile +5 -0
- data/README.md +1 -0
- data/lib/threat/plugins/pr_title.rb +25 -0
- data/lib/threat/plugins/todo.rb +19 -0
- data/lib/threat/version.rb +5 -0
- data/lib/threat.rb +11 -0
- metadata +77 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 37e589f3b6eac127b034369646f4a4974dec74deacbfa6fe534c72f0162c316a
|
4
|
+
data.tar.gz: e0ff6f20a2bebc6b2bb39a3328897f7b7165e8c251297b444f6d609af6755fc7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f20ac080e2f6a1ad188ece50d026e8e284982a9fa32fe9017cc6e94f0cd8add1008d241e7ab3a475fc17d57132d21526c8d8ecda34ea389cdfbf3f141f2bc6fd
|
7
|
+
data.tar.gz: 222a8a43c3bd6b8b47177bdf81f9e58eeda80a13b1ad275826413adf27c7fb35218e75d1d1a8eea4e5a5eaedc472fa00e604618d2cf22b91a244f0c5b3ec88b1
|
data/Dangerfile
ADDED
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Threat - Collection of useful Danger plugins
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This plugin validates that the PR title includes JIRA ticket number and a meaningful title
|
4
|
+
#
|
5
|
+
# Usage:
|
6
|
+
#
|
7
|
+
# Dangerfile
|
8
|
+
#
|
9
|
+
# ```ruby
|
10
|
+
# danger.import_dangerfile(gem: 'threat')
|
11
|
+
#
|
12
|
+
# pr_title.run!
|
13
|
+
# ```
|
14
|
+
#
|
15
|
+
class Threat::Plugins::PrTitle < Danger::Plugin
|
16
|
+
JIRA_TICKET_NUMBER_FORMAT = '[A-Z]+-\d+(?:, [A-Z]+-\d+)*' # [KEY-123]
|
17
|
+
PR_TITLE_REGEX = /\[#{JIRA_TICKET_NUMBER_FORMAT}\] [A-Z|0-9].*\S/ # [KEY-123] An amazing feature
|
18
|
+
|
19
|
+
def run!
|
20
|
+
# Danger does not define github object when running locally
|
21
|
+
return unless defined?(github)
|
22
|
+
|
23
|
+
failure('Invalid format of PR title') unless github.pr_title.strip.match?(PR_TITLE_REGEX)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Threat::Plugins::PrTitle < Danger::Plugin
|
4
|
+
SUPPORTED_COMMENTS = [
|
5
|
+
'#', # e.g Ruby/YAML/Dockerfile and so on
|
6
|
+
'//' # e.g JS
|
7
|
+
].freeze
|
8
|
+
TODO_COMMENENT_REGEX = /(^|\s)(#{SUPPORTED_COMMENTS.join('|')})\sTODO:\s/
|
9
|
+
|
10
|
+
def run!
|
11
|
+
(git.modified_files + git.added_files).each do |path|
|
12
|
+
File.foreach(path) do |line|
|
13
|
+
next unless line.match?(TODO_COMMENENT_REGEX)
|
14
|
+
|
15
|
+
warn('TODO detected! The whole team will be greatful if you may resolve it <3')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/threat.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'zeitwerk'
|
4
|
+
require 'danger'
|
5
|
+
|
6
|
+
loader = Zeitwerk::Loader.for_gem
|
7
|
+
loader.setup
|
8
|
+
loader.eager_load_namespace(Threat::Plugins) # This way we're autoloading all defined plugins for Danger to register
|
9
|
+
|
10
|
+
module Threat
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: threat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Egor Iskrenkov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-06-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: zeitwerk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: danger
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 9.4.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 9.4.3
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- egor@iskrenkov.me
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- Dangerfile
|
49
|
+
- README.md
|
50
|
+
- lib/threat.rb
|
51
|
+
- lib/threat/plugins/pr_title.rb
|
52
|
+
- lib/threat/plugins/todo.rb
|
53
|
+
- lib/threat/version.rb
|
54
|
+
homepage: https://github.com/eiskrenkov/threat
|
55
|
+
licenses: []
|
56
|
+
metadata:
|
57
|
+
source_code_uri: https://github.com/eiskrenkov/threat
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 3.0.0
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubygems_version: 3.5.3
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: Collection of useful Danger plugins
|
77
|
+
test_files: []
|