Sha256: d4f9f7b5f2064656f76659d462a88a90de04fff2ce30c8de4c21c3b27ece34e6

Contents?: true

Size: 976 Bytes

Versions: 2

Compression:

Stored size: 976 Bytes

Contents

# frozen_string_literal: true

module SewingKit
  class InstallGenerator < Rails::Generators::Base
    source_root File.expand_path('templates', __dir__)

    desc "This generator creates a sewing-kit config file."

    def initialize(args, *options)
      @application_name = Rails.application.class.module_parent.to_s.underscore
      super(args, *options)
    end

    def create_package_json
      package_json_path = "package.json"

      copy_file(package_json_path)
      gsub_file(package_json_path, "\${application_name}", @application_name)
    end

    def create_sk_config
      sk_config_path = "config/sewing-kit.config.ts"

      copy_file("sewing-kit.config.ts", sk_config_path)
      gsub_file(sk_config_path, "\${application_name}", @application_name)
    end

    def create_config_files
      copy_file("editorconfig", ".editorconfig")
      copy_file("eslintignore", ".eslintignore")
      copy_file("prettierignore", ".prettierignore")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sewing_kit-0.124.0 lib/generators/sewing_kit/install_generator.rb
sewing_kit-0.123.0 lib/generators/sewing_kit/install_generator.rb