Make vue_shared danger message more concise

This commit is contained in:
Tom Quirk 2021-07-15 15:06:54 +09:30
parent c521bc976b
commit f612a60b79

View file

@ -1,10 +1,14 @@
# frozen_string_literal: true
def has_matching_story?(file)
File.file?(file.dup.sub!(/\.vue$/, '.stories.js'))
end
def get_vue_shared_files(files)
files.select do |file|
file.end_with?('.vue') &&
file.include?('vue_shared/') &&
!File.file?(file.dup.sub!(/\.vue$/, '.stories.js'))
!has_matching_story?(file)
end
end
@ -12,14 +16,7 @@ vue_shared_candidates = get_vue_shared_files(helper.all_changed_files)
return if vue_shared_candidates.empty?
warn 'This merge request changed undocumented Vue components in `vue_shared/`. Please consider [adding documention](https://docs.gitlab.com/ce/development/fe_guide/storybook).'
documentation_url = 'https://docs.gitlab.com/ce/development/fe_guide/storybook'
file_list = "- #{vue_shared_candidates.map { |path| "`#{path}`" }.join("\n- ")}"
if helper.ci?
markdown(<<~MARKDOWN)
## Undocumented Vue components
The following Vue components don't have associated stories. Please consider [creating them](https://docs.gitlab.com/ce/development/fe_guide/storybook):
* #{vue_shared_candidates.map { |path| "`#{path}`" }.join("\n* ")}
MARKDOWN
end
warn "This merge request changed undocumented Vue components in `vue_shared/`. Please consider [creating Stories](#{documentation_url}) for these components:\n#{file_list}"