Sha256: 4f80676ccc9fbe7695593339d7f45328c8ba831701e40b91b2ced392d80ab9aa

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

namespace :static do
  task :dump do
    ENV["RAILS_ENV"] = "test"
    require File.expand_path("./../../demo/config/environment.rb", __dir__)
    require "primer/view_components"
    require "lookbook"
    # Loads all components for `.descendants` to work properly
    Dir["./app/components/primer/**/*.rb"].sort.each { |file| require file }

    Primer::ViewComponents.dump(:statuses)
    Primer::ViewComponents.dump(:constants)
    Primer::ViewComponents.dump(:audited_at)

    previews = Lookbook.previews.map do |preview|
      {
        name: preview.name,
        lookup_path: preview.lookup_path,
        examples: preview.examples.map { |example|
          {
            inspect_path: example.url_path,
            preview_path: example.url_path.sub("/inspect/", "/preview/"),
            name: example.name
          }
        }
      }
    end

    require "json"

    File.open(File.join(Primer::ViewComponents::DEFAULT_STATIC_PATH, "previews.json"), "w") do |f|
      f.write(JSON.pretty_generate(previews))
      f.write($INPUT_RECORD_SEPARATOR)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
primer_view_components-0.1.4 lib/tasks/static.rake
primer_view_components-0.1.3 lib/tasks/static.rake
primer_view_components-0.1.2 lib/tasks/static.rake
primer_view_components-0.1.1 lib/tasks/static.rake
primer_view_components-0.1.0 lib/tasks/static.rake
primer_view_components-0.0.123 lib/tasks/static.rake
primer_view_components-0.0.122 lib/tasks/static.rake
primer_view_components-0.0.121 lib/tasks/static.rake