summaryrefslogtreecommitdiff
path: root/danger/vue_shared_documentation/Dangerfile
blob: 103ef3591af31201fcbe25fd4df00a9d41ef3fd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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/') &&
      !has_matching_story?(file)
  end
end

vue_shared_candidates = get_vue_shared_files(helper.all_changed_files)

return if vue_shared_candidates.empty?

documentation_url = 'https://docs.gitlab.com/ce/development/fe_guide/storybook'
file_list = "- #{vue_shared_candidates.map { |path| "`#{path}`" }.join("\n- ")}"

warn "This merge request changed undocumented Vue components in `vue_shared/`. Please consider [creating Stories](#{documentation_url}) for these components:\n#{file_list}"