Module: InlineFormsGemFiles

Defined in:
lib/inline_forms/gem_files.rb

Constant Summary collapse

INSTALLER_FILE_PREFIXES =
%w[
  bin/inline_forms
  lib/inline_forms_installer.rb
  lib/inline_forms_installer/
  lib/installer_templates/
  inline_forms_installer.gemspec
].freeze
SCHEMA_GUI_FILE_PREFIXES =

The schema-GUI gem lives in its own subdirectory with its own gemspec (inline_forms_schema_edit/inline_forms_schema_edit.gemspec) and packages its files itself; exclude the whole subtree from BOTH gems here.

%w[
  inline_forms_schema_edit/
].freeze
EXCLUDED_FILE_PREFIXES =

Scratch / local-notes dir. It holds working notes and, crucially, secrets such as stuff/forgejo-token (mode 0600, only used by CI pushes to forgejo). It must NEVER be packaged into a gem. Do not rely on git ignore for this: gem_files sweeps untracked files too, and the global excludes file that ignores stuff/ is per-machine (present here, absent on the release box), so the token leaked into gem build on the release machine. Exclude it hard, independent of any ignore configuration.

%w[
  stuff/
].freeze
REPO_ROOT =
File.expand_path("../..", __dir__)

Class Method Summary collapse

Class Method Details

.gem_files(include_installer:) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/inline_forms/gem_files.rb', line 34

def gem_files(include_installer:)
  files =
    if File.directory?(File.join(REPO_ROOT, ".git"))
      Dir.chdir(REPO_ROOT) do
        tracked = `git ls-files`.split("\n")
        untracked = `git ls-files --others --exclude-standard`.split("\n")
        (tracked + untracked).uniq
      end
    else
      Dir.chdir(REPO_ROOT) do
        Dir.glob("**/*", File::FNM_DOTMATCH).reject do |f|
          f.start_with?(".git/", ".bundle/", "pkg/") ||
            f == ".git" || f == ".bundle"
        end
      end
    end

  files.select! { |f| File.file?(File.join(REPO_ROOT, f)) }

  files.reject! do |f|
    EXCLUDED_FILE_PREFIXES.any? { |prefix| f == prefix || f.start_with?(prefix) }
  end

  files.reject! do |f|
    SCHEMA_GUI_FILE_PREFIXES.any? { |prefix| f == prefix || f.start_with?(prefix) }
  end

  files.reject do |f|
    installer_file = INSTALLER_FILE_PREFIXES.any? { |prefix| f == prefix || f.start_with?(prefix) }
    include_installer ? !installer_file : installer_file
  end
end