-
# frozen_string_literal: true
-
-
1
ruby file: ".ruby-version"
-
-
1
source "https://rubygems.org"
-
-
1
gemspec
-
-
1
group :quality do
-
1
gem "caliber", "~> 0.90"
-
1
gem "git-lint", "~> 11.0"
-
1
gem "reek", "~> 6.5", require: false
-
1
gem "simplecov", "~> 0.22", require: false
-
end
-
-
1
group :development do
-
1
gem "rake", "~> 13.4"
-
end
-
-
1
group :test do
-
1
gem "rspec", "~> 3.13"
-
1
gem "rubocop-sequel", "~> 0.4"
-
end
-
-
1
group :tools do
-
1
gem "amazing_print", "~> 2.0"
-
1
gem "debug", "~> 1.11"
-
1
gem "irb-kit", "~> 2.0"
-
1
gem "repl_type_completor", "~> 0.1"
-
end
-
# frozen_string_literal: true
-
-
1
require "rubysmith"
-
1
require "zeitwerk"
-
-
1
Zeitwerk::Loader.new.then do |loader|
-
1
loader.inflector.inflect "cli" => "CLI",
-
"ci" => "CI",
-
"circle_ci" => "CircleCI",
-
"htmx" => "HTMX",
-
"npm" => "NPM",
-
"pwa" => "PWA",
-
"rspec" => "RSpec",
-
"yjit" => "YJIT"
-
1
loader.tag = File.basename __FILE__, ".rb"
-
1
loader.push_dir __dir__
-
1
loader.setup
-
end
-
-
# Main namespace.
-
1
module Hanamismith
-
1
def self.loader registry = Zeitwerk::Registry
-
5
@loader ||= registry.loaders.each.find { |loader| loader.tag == File.basename(__FILE__, ".rb") }
-
end
-
end
-
# frozen_string_literal: true
-
-
1
Gem::Specification.new do |spec|
-
1
spec.name = "hanamismith"
-
1
spec.version = "3.1.0"
-
1
spec.authors = ["Brooke Kuhlmann"]
-
1
spec.email = ["brooke@alchemists.io"]
-
1
spec.homepage = "https://alchemists.io/projects/hanamismith"
-
1
spec.summary = "A command line interface for smithing Hanami projects."
-
1
spec.license = "Hippocratic-2.1"
-
-
1
spec.metadata = {
-
"bug_tracker_uri" => "https://github.com/bkuhlmann/hanamismith/issues",
-
"changelog_uri" => "https://alchemists.io/projects/hanamismith/versions",
-
"homepage_uri" => "https://alchemists.io/projects/hanamismith",
-
"funding_uri" => "https://github.com/sponsors/bkuhlmann",
-
"label" => "Hanamismith",
-
"rubygems_mfa_required" => "true",
-
"source_code_uri" => "https://github.com/bkuhlmann/hanamismith"
-
}
-
-
1
spec.signing_key = Gem.default_key_path
-
1
spec.cert_chain = [Gem.default_cert_path]
-
-
1
spec.required_ruby_version = ">= 4.0"
-
-
1
spec.add_dependency "cogger", "~> 2.3"
-
1
spec.add_dependency "containable", "~> 2.3"
-
1
spec.add_dependency "dry-monads", "~> 1.9"
-
1
spec.add_dependency "dry-schema", "~> 1.15"
-
1
spec.add_dependency "etcher", "~> 4.3"
-
1
spec.add_dependency "htmx", "~> 3.0"
-
1
spec.add_dependency "infusible", "~> 5.0"
-
1
spec.add_dependency "refinements", "~> 14.0"
-
1
spec.add_dependency "rubysmith", "~> 10.0"
-
1
spec.add_dependency "runcom", "~> 13.0"
-
1
spec.add_dependency "sod", "~> 2.0"
-
1
spec.add_dependency "spek", "~> 5.0"
-
1
spec.add_dependency "zeitwerk", "~> 2.8"
-
-
1
spec.bindir = "exe"
-
1
spec.executables << "hanamismith"
-
1
spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
-
1
spec.files = Dir.glob ["*.gemspec", "lib/**/*"], File::FNM_DOTMATCH
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds project skeleton for assets.
-
1
class Asset < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
6
path = "%project_name%/config/assets.js.erb"
-
6
builder.call(settings.with(template_path: path)).render
-
6
true
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds project skeleton binstub.
-
1
class Binstub < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
7
builder.call(settings.with(template_path: "%project_name%/bin/hanami.erb"))
-
.render
-
.permit 0o755
-
-
7
true
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds project skeleton with Gemfile configuration.
-
1
class Bundler < Rubysmith::Builders::Bundler
-
1
using Refinements::Struct
-
-
1
def call
-
7
super
-
-
7
%i[groups hanami main persistence quality devtest development test].each do |name|
-
56
__send__ :"insert_#{name}"
-
end
-
-
7
remove_zeitwerk
-
7
true
-
end
-
-
1
private
-
-
1
def insert_groups
-
7
else: 2
then: 5
return unless settings.build_minimum
-
-
2
with_template.append <<~CONTENT
-
group :development do
-
end
-
-
group :test do
-
end
-
CONTENT
-
end
-
-
1
def insert_hanami
-
7
with_template.insert_after "source", <<~CONTENT.strip
-
gem "hanami", "~> 3.0"
-
gem "hanami-action", "~> 3.0"
-
gem "hanami-assets", "~> 3.0"
-
gem "hanami-db", "~> 3.0"
-
gem "hanami-mailer", "~> 3.0"
-
gem "hanami-router", "~> 3.0"
-
gem "hanami-view", "~> 3.0"
-
CONTENT
-
end
-
-
1
def insert_main
-
7
with_template.insert_after "source", <<~CONTENT
-
gem "cogger", "~> 2.4"
-
gem "core", "~> 3.2"
-
gem "dry-schema", "~> 1.16"
-
gem "dry-types", "~> 1.9"
-
gem "dry-validation", "~> 1.11"
-
gem "htmx", "~> 3.2"
-
gem "i18n", "~> 1.15"
-
gem "puma", "~> 8.0"
-
gem "rack-attack", "~> 6.8"
-
CONTENT
-
end
-
-
1
def insert_persistence
-
7
with_template.insert_after "source", <<~CONTENT
-
-
gem "pg", "~> 1.6", force_ruby_platform: true
-
gem "rom", "~> 5.4"
-
gem "rom-sql", "~> 3.7"
-
gem "sequel", "~> 5.106"
-
CONTENT
-
end
-
-
1
def insert_quality
-
7
with_template.insert_after(/group :quality/, %( gem "rubocop-sequel", "~> 0.4"\n))
-
end
-
-
1
def insert_devtest
-
7
with_template.insert_before(/group :development/, <<~CONTENT)
-
-
group :development, :test do
-
gem "dotenv", "~> 3.2"
-
end
-
-
CONTENT
-
end
-
-
1
def insert_development
-
7
with_template.insert_after(/group :development do/, <<~CONTENT.gsub("gem", " gem"))
-
gem "hanami-webconsole", "~> 3.0"
-
gem "localhost", "~> 1.8"
-
CONTENT
-
end
-
-
1
def insert_test
-
7
with_template.insert_after(/group :test/, <<~CONTENT.gsub("gem", " gem"))
-
gem "capybara", "~> 3.40"
-
gem "capybara-validate_html5", "~> 2.1"
-
gem "cuprite", "~> 0.17"
-
gem "database_cleaner-sequel", "~> 2.0"
-
gem "launchy", "~> 3.1"
-
gem "rack-test", "~> 2.2"
-
gem "rom-factory", "~> 0.13"
-
CONTENT
-
end
-
-
1
def remove_zeitwerk = with_template.replace(/.+zeitwerk.+\n\n/, "\n")
-
-
1
def with_template
-
58
builder.call settings.with(template_path: "%project_name%/Gemfile.erb")
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds project skeleton with Caliber style support.
-
1
class Caliber < Rubysmith::Builders::Caliber
-
1
using Refinements::Struct
-
-
1
def call
-
8
else: 4
then: 4
return false unless settings.build_caliber
-
-
4
super
-
4
with_template.append "\nplugins: rubocop-sequel\n\n"
-
4
add_configuration
-
4
true
-
end
-
-
1
private
-
-
1
def add_configuration
-
4
with_template.append <<~CONTENT
-
Metrics/MethodLength:
-
Exclude:
-
- config/initializers/universal_logger_patch.rb
-
RSpec/SpecFilePathFormat:
-
CustomTransform:
-
#{settings.project_namespaced_class}: ""
-
CONTENT
-
end
-
-
1
def with_template
-
8
path = "%project_name%/.config/rubocop/config.yml.erb"
-
8
builder.call settings.with(template_path: path)
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
1
require "securerandom"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds project skeleton Circle CI configuration.
-
1
class CircleCI < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def initialize(generator: SecureRandom, **)
-
10
@generator = generator
-
10
super(**)
-
end
-
-
1
def call
-
10
else: 6
then: 4
return false unless settings.build_circle_ci
-
-
6
path = "%project_name%/.circleci/config.yml.erb"
-
-
6
builder.call(settings.with(template_path: path))
-
.render
-
.replace("<app_secret>", generator.hex(30))
-
.replace(/\n\n\Z/, "\n")
-
-
6
true
-
end
-
-
1
private
-
-
1
attr_reader :generator
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds project skeleton console for object inspection and exploration.
-
1
class Console < Rubysmith::Builders::Console
-
1
using Refinements::Struct
-
-
1
def call
-
8
else: 4
then: 4
return false unless settings.build_console
-
-
4
super
-
4
builder.call(settings.with(template_path: "%project_name%/bin/console.erb"))
-
.replace(/require Bundler.root.+/, %(require "hanami/prepare"))
-
-
4
add_irb_autocomplete
-
-
4
true
-
end
-
-
1
private
-
-
1
def add_irb_autocomplete
-
4
with_template.insert_before "IRB.start", <<~CODE
-
unless Hanami.env? :development, :test
-
ENV["IRB_USE_AUTOCOMPLETE"] ||= "false"
-
puts "IRB autocomplete disabled."
-
end
-
-
CODE
-
end
-
-
1
def with_template
-
4
builder.call settings.with(template_path: "%project_name%/bin/console.erb")
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds project skeleton foundation.
-
1
class Core < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
629
private_methods.grep(/\Aadd_/).sort.each { |method| __send__ method }
-
37
true
-
end
-
-
1
private
-
-
1
def add_db_relation
-
37
builder.call(settings.with(template_path: "%project_name%/app/db/relation.rb.erb")).render
-
end
-
-
1
def add_db_repository
-
37
builder.call(settings.with(template_path: "%project_name%/app/db/repository.rb.erb")).render
-
end
-
-
1
def add_db_struct
-
37
builder.call(settings.with(template_path: "%project_name%/app/db/struct.rb.erb")).render
-
end
-
-
1
def add_action
-
37
builder.call(settings.with(template_path: "%project_name%/app/action.rb.erb")).render
-
end
-
-
1
def add_contract
-
37
builder.call(settings.with(template_path: "%project_name%/app/contract.rb.erb")).render
-
end
-
-
1
def add_mailer
-
37
builder.call(settings.with(template_path: "%project_name%/app/mailer.rb.erb")).render
-
end
-
-
1
def add_view
-
37
builder.call(settings.with(template_path: "%project_name%/app/view.rb.erb")).render
-
end
-
-
1
def add_application_configuration
-
37
builder.call(settings.with(template_path: "%project_name%/config/app.rb.erb")).render
-
end
-
-
1
def add_routes_configuration
-
37
builder.call(settings.with(template_path: "%project_name%/config/routes.rb.erb")).render
-
end
-
-
1
def add_settings_configuration
-
37
builder.call(settings.with(template_path: "%project_name%/config/settings.rb.erb")).render
-
end
-
-
1
def add_types
-
37
path = "%project_name%/lib/%project_path%/types.rb.erb"
-
37
builder.call(settings.with(template_path: path)).render
-
end
-
-
1
def add_migrate_directory
-
37
builder.call(settings.with(template_path: "%project_name%/config/db/migrate")).make_path
-
end
-
-
1
def add_well_known_security_text
-
37
else: 26
then: 11
return unless settings.build_security
-
-
26
path = "%project_name%/public/.well-known/security.txt.erb"
-
26
builder.call(settings.with(template_path: path)).render
-
end
-
-
1
def add_public_http_errors
-
37
%w[404 500].each do |code|
-
74
path = "%project_name%/public/#{code}.html.erb"
-
74
builder.call(settings.with(template_path: path)).render
-
end
-
end
-
-
1
def add_log_directory
-
37
builder.call(settings.with(template_path: "%project_name%/log")).make_path
-
end
-
-
1
def add_temp_directory
-
37
builder.call(settings.with(template_path: "%project_name%/tmp")).make_path
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Docker
-
# Builds Docker compose configuration.
-
1
class Compose < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
8
else: 4
then: 4
return false unless settings.build_docker
-
-
4
builder.call(settings.with(template_path: "%project_name%/compose.yml.erb")).render
-
4
true
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Docker
-
# Builds Dockerfile configuration.
-
1
class File < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
15
else: 11
then: 4
return false unless settings.build_docker
-
-
11
builder.call(settings.with(template_path: "%project_name%/Dockerfile.erb")).render
-
11
true
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Documentation
-
# Builds project skeleton README documentation.
-
1
class Readme < Rubysmith::Builders::Documentation::Readme
-
1
using Refinements::Struct
-
-
1
def call
-
10
else: 6
then: 4
return false unless settings.build_readme
-
-
6
super
-
6
builder.call(settings.with(template_path: "%project_name%/README.#{kind}.erb"))
-
.replace("Rubysmith", "Hanamismith")
-
.replace("rubysmith", "hanamismith")
-
-
6
true
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
1
require "securerandom"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Environments
-
# Builds test environment skeleton.
-
1
class All < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def initialize(generator: SecureRandom, **)
-
6
@generator = generator
-
6
super(**)
-
end
-
-
1
def call
-
6
builder.call(settings.with(template_path: "%project_name%/env.erb"))
-
.render
-
.replace("<app_secret>", generator.hex(40))
-
.replace("<pg_password>", generator.hex(15))
-
.rename(".env")
-
-
6
true
-
end
-
-
1
private
-
-
1
attr_reader :generator
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Environments
-
# Builds development environment skeleton.
-
1
class Development < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
6
builder.call(settings.with(template_path: "%project_name%/env.development.erb"))
-
.render
-
.rename(".env.development")
-
-
6
true
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Environments
-
# Builds test environment skeleton.
-
1
class Test < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
6
builder.call(settings.with(template_path: "%project_name%/env.test.erb"))
-
.render
-
.rename(".env.test")
-
-
6
true
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Git
-
# Builds project skeleton initial Git commit message.
-
1
class Commit < Rubysmith::Builders::Git::Commit
-
1
include Dependencies[:specification]
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Git
-
# Builds project skeleton Git ignore.
-
1
class Ignore < Rubysmith::Builders::Git::Ignore
-
1
using Refinements::Struct
-
-
1
def call
-
8
else: 4
then: 4
return false unless settings.build_git
-
-
4
super
-
4
add_entries
-
4
true
-
end
-
-
1
private
-
-
1
def add_entries
-
4
builder.call(settings.with(template_path: "%project_name%/.gitignore.erb"))
-
.insert_before "tmp\n", <<~CONTENT
-
node_modules
-
public/*
-
!public/.well-known
-
!public/404.html
-
!public/500.html
-
CONTENT
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module GitHub
-
# Builds project skeleton GitHub CI configuration.
-
1
class CI < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
10
else: 6
then: 4
return false unless settings.build_git_hub_ci
-
-
6
path = "%project_name%/.github/workflows/ci.yml.erb"
-
6
builder.call(settings.with(template_path: path)).render.replace(/\n\n\Z/, "\n")
-
6
true
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds project skeleton SVG icon.
-
1
class Icon < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
6
path = "%project_name%/app/assets/images/icon.svg.erb"
-
6
builder.call(settings.with(template_path: path)).render
-
6
true
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds project skeleton javascript.
-
1
class Javascript < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
6
path = "%project_name%/app/assets/js/app.js.erb"
-
6
builder.call(settings.with(template_path: path)).render
-
6
true
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds app layout.
-
1
class Layout < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
7
path = "%project_name%/app/templates/layouts/app.html.erb.erb"
-
7
builder.call(settings.with(template_path: path))
-
.render
-
.replace("<!-- title -->", "<%= content_for :title %>")
-
.replace("<!-- favicon -->", favicon)
-
.replace("<!-- icon -->", icon)
-
.replace("<!-- apple_icon -->", apple_icon)
-
.replace("<!-- manifest -->", manifest)
-
.replace("<!-- stylesheet -->", stylesheet)
-
.replace("<!-- javascript -->", javascript)
-
.replace("<!-- yield -->", "<%= yield %>")
-
.replace("<!-- flash:alert -->", flash(:alert))
-
.replace("<!-- flash:notice -->", flash(:notice))
-
-
7
true
-
end
-
-
1
private
-
-
1
def favicon
-
7
uri = "https://alchemists.io/images/projects/hanamismith/icons/favicon.ico"
-
-
7
%(<%= tag.link title: "#{settings.project_label}: Favicon",\n) +
-
%( rel: :icon,\n) +
-
%( href: "#{uri}",\n) +
-
%( sizes: "32x32" %>)
-
end
-
-
1
def icon
-
7
%(<%= tag.link title: "#{settings.project_label}: Icon",\n) +
-
%( rel: :icon,\n) +
-
%( href: app_assets["icon.svg"],\n) +
-
%( type: "image/svg+xml" %>)
-
end
-
-
1
def apple_icon
-
7
uri = "https://alchemists.io/images/projects/hanamismith/icons/apple.png"
-
-
7
%(<%= tag.link title: "#{settings.project_label}: Apple Icon",\n) +
-
%( rel: "apple-touch-icon",\n) +
-
%( href: "#{uri}",\n) +
-
%( type: "image/png" %>)
-
end
-
-
# :reek:UtilityFunction
-
1
def flash kind
-
14
%(<% if flash[:#{kind}] %>\n) +
-
%( <div class="site-#{kind}">\n) +
-
%( <p><%= flash[:#{kind}] %></p>\n) +
-
%( </div>\n) +
-
%( <% end %>\n)
-
end
-
-
1
def manifest
-
7
%(<%= tag.link title: "#{settings.project_label}: Manifest",\n) +
-
%( rel: :manifest,\n) +
-
%( href: app_assets["manifest.webmanifest"] %>)
-
end
-
-
1
def stylesheet
-
7
%(<%= tag.link title: "#{settings.project_label}: Stylesheet", rel: :stylesheet, ) +
-
%(href: app_assets["app.css"] %>)
-
end
-
-
1
def javascript = %(<%= tag.script src: app_assets["app.js"], type: "text/javascript" %>)
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "dry/monads"
-
1
require "refinements/pathname"
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds project skeleton for Node.
-
1
class Node < Rubysmith::Builders::Abstract
-
1
include Dry::Monads[:result]
-
-
1
using Refinements::Struct
-
1
using Refinements::Pathname
-
-
1
def initialize(executor: Open3, **)
-
10
@executor = executor
-
10
super(**)
-
end
-
-
1
def call
-
10
build_version
-
10
builder.call(settings.with(template_path: "%project_name%/package.json.erb")).render
-
10
true
-
end
-
-
1
private
-
-
1
attr_reader :executor
-
-
1
def build_version
-
10
in: 7
case load_version
-
7
in: 2
in Success(text) then version_path.make_ancestors.write text.delete_prefix("v")
-
2
else: 1
in Failure(message) then log_error message
-
1
else log_error "Shell failure. Is your environment configured properly?"
-
end
-
end
-
-
1
def load_version
-
10
executor.capture3("node", "--version").then do |stdout, _stderr, status|
-
8
then: 7
else: 1
return Success stdout if status.success?
-
-
1
Failure "Unable to obtain version for #{version_path.inspect}."
-
end
-
rescue Errno::ENOENT
-
1
Failure "Unable to find Node. Is Node installed?"
-
end
-
-
1
def version_path = settings.project_root.join ".node-version"
-
-
4
def log_error(message) = logger.error { message }
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Providers
-
# Builds project skeleton for database provider.
-
1
class Database < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
6
path = "%project_name%/config/providers/db.rb.erb"
-
6
builder.call(settings.with(template_path: path)).render
-
6
true
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Providers
-
# Builds project skeleton for HTMX provider.
-
1
class HTMX < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
6
path = "%project_name%/config/providers/htmx.rb.erb"
-
6
builder.call(settings.with(template_path: path)).render
-
6
true
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Providers
-
# Builds project skeleton for logger provider.
-
1
class Logger < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
10
build_all
-
10
add_initializers
-
10
true
-
end
-
-
1
private
-
-
1
def build_all
-
10
%w[
-
%project_name%/app/providers/logger.rb.erb
-
%project_name%/spec/app/providers/logger_spec.rb.erb
-
%project_name%/config/providers/logger.rb.erb
-
%project_name%/config/initializers/universal_logger_patch.rb.erb
-
40
].each { build it }
-
end
-
-
1
def build(path) = builder.call(settings.with(template_path: path)).render
-
-
1
def add_initializers
-
10
builder.call(settings.with(template_path: "%project_name%/config/app.rb.erb"))
-
.insert_after(
-
/require/,
-
<<~REQUIRES
-
-
require_relative "initializers/universal_logger_patch"
-
REQUIRES
-
)
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Puma
-
# Builds project skeleton Puma configuration.
-
1
class Configuration < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
6
builder.call(settings.with(template_path: "%project_name%/config/puma.rb.erb")).render
-
-
6
true
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Puma
-
# Builds project skeleton Puma Procfile for production and development environments.
-
1
class Procfile < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
8
builder.call(settings.with(template_path: "%project_name%/Procfile.erb")).render
-
8
builder.call(settings.with(template_path: "%project_name%/Procfile.dev.erb")).render
-
8
true
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds project skeleton Progressive Web Application (PWA) manifest.
-
1
class PWA < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
6
path = "%project_name%/app/assets/pwa/manifest.webmanifest.erb"
-
6
builder.call(settings.with(template_path: path)).render
-
6
true
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Rack
-
# Builds project skeleton.
-
1
class Attack < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
11
add_configuration
-
11
add_middleware
-
11
true
-
end
-
-
1
private
-
-
1
def add_configuration
-
11
template_path = "%project_name%/config/initializers/rack_attack.rb.erb"
-
11
builder.call(settings.with(template_path:)).render
-
end
-
-
1
def add_middleware
-
11
builder.call(settings.with(template_path: "%project_name%/config/app.rb.erb"))
-
.insert_after(/require/, %(\nrequire_relative "initializers/rack_attack"\n))
-
.insert_after(
-
"rubocop:enable Layout/FirstArrayElementLineBreak\n",
-
"\n config.middleware.use Rack::Attack\n"
-
)
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Rack
-
# Builds project skeleton.
-
1
class Configuration < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
6
builder.call(settings.with(template_path: "%project_name%/config.ru.erb")).render
-
6
true
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Rack
-
# Builds project skeleton.
-
1
class Deflater < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
7
builder.call(settings.with(template_path: "%project_name%/config/app.rb.erb"))
-
.insert_after(
-
"rubocop:enable Layout/FirstArrayElementLineBreak\n",
-
"\n config.middleware.use Rack::Deflater\n"
-
)
-
7
true
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Rake
-
# Builds project skeleton Rake configuration file.
-
1
class Configuration < Rubysmith::Builders::Rake::Configuration
-
1
using Refinements::Struct
-
-
1
def call
-
8
else: 4
then: 4
return false unless settings.build_rake
-
-
4
super
-
4
process
-
4
true
-
end
-
-
1
private
-
-
1
def process
-
4
builder.call(settings.with(template_path: "%project_name%/Rakefile.erb"))
-
.render
-
.replace(
-
"Reek::Rake::Task.new",
-
%(Reek::Rake::Task.new { it.source_files = "{app,config,lib,slices}/**/*.rb" })
-
)
-
.insert_after(%r(bundler/setup), %(require "hanami/rake_tasks"))
-
.insert_after(/RuboCop::RakeTask/, %(\nRake.add_rakelib "lib/tasks"\n))
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds project skeleton Reek code quality support.
-
1
class Reek < Rubysmith::Builders::Reek
-
1
using Refinements::Struct
-
-
1
def call
-
7
else: 4
then: 3
return false unless settings.build_reek
-
-
4
super
-
4
add_duplicate_exclusion
-
4
add_too_many_statements_exclusion
-
4
true
-
end
-
-
1
def add_duplicate_exclusion
-
4
with_template.insert_before(
-
/LongParameterList:\n/,
-
<<~DETECTORS.gsub(/^/, " ")
-
DuplicateMethodCall:
-
exclude:
-
- UniversalLoggerPatch#_log_structured
-
DETECTORS
-
)
-
end
-
-
1
def add_too_many_statements_exclusion
-
4
with_template.insert_after(
-
/enabled:\sfalse\n/,
-
<<~DETECTORS.gsub(/^/, " ")
-
TooManyStatements:
-
exclude:
-
- UniversalLoggerPatch#_log_structured
-
DETECTORS
-
)
-
end
-
-
1
def with_template
-
8
builder.call settings.with(template_path: "%project_name%/.reek.yml.erb")
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds project skeleton foundation.
-
1
class Refinement < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
7
%w[
-
%project_name%/lib/%project_path%/refines/actions/response.rb.erb
-
%project_name%/spec/lib/%project_path%/refines/actions/response_spec.rb.erb
-
].each do |path|
-
14
builder.call(settings.with(template_path: path)).render
-
end
-
-
7
true
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module RSpec
-
# Builds project skeleton RSpec application shared context.
-
1
class ApplicationSharedContext < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
8
else: 4
then: 4
return false unless settings.build_rspec
-
-
4
path = "%project_name%/spec/support/shared_contexts/application_dependencies.rb.erb"
-
4
builder.call(settings.with(template_path: path)).render
-
-
4
true
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module RSpec
-
# Builds project skeleton RSpec helper.
-
1
class Hanami < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
8
else: 4
then: 4
return false unless settings.build_rspec
-
-
4
path = "%project_name%/spec/hanami_helper.rb.erb"
-
4
builder.call(settings.with(template_path: path)).render
-
-
4
true
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module RSpec
-
# Builds project skeleton RSpec helper.
-
1
class Helper < Rubysmith::Builders::RSpec::Helper
-
1
using Refinements::Struct
-
-
1
def initialize(...)
-
10
super
-
10
@template = builder.call settings.with(
-
template_path: "%project_name%/spec/spec_helper.rb.erb"
-
)
-
end
-
-
1
def call
-
10
else: 6
then: 4
return false unless settings.build_rspec
-
-
6
super
-
6
remove_project_requirement
-
6
disable_simple_cov_eval
-
6
true
-
end
-
-
1
private
-
-
1
attr_reader :template
-
-
1
def remove_project_requirement
-
6
template.replace(/require.+#{settings.project_name}.+\n/, "")
-
end
-
-
1
def disable_simple_cov_eval
-
6
template.replace(/\s{4}enable_coverage_for_eval\n/, "")
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds project skeleton setup script.
-
1
class Setup < Rubysmith::Builders::Setup
-
1
using Refinements::Struct
-
-
1
def call
-
10
else: 6
then: 4
return false unless settings.build_setup
-
-
6
super
-
6
append
-
6
true
-
end
-
-
1
private
-
-
1
def append
-
6
builder.call(settings.with(template_path: "%project_name%/bin/setup.erb"))
-
.insert_after(%(Runner.call "bundle install"\n), <<~CONTENT.gsub(/^(?=\w)/, " "))
-
-
puts "Installing packages..."
-
Runner.call "npm install"
-
-
puts "Configuring databases..."
-
Runner.call "hanami db prepare"
-
-
puts "Compiling assets..."
-
Runner.call "hanami assets compile"
-
CONTENT
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Slices
-
# Builds health slice skeleton.
-
1
class Health < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
117
private_methods.grep(/\Aadd_/).sort.each { |method| __send__ method }
-
13
true
-
end
-
-
1
private
-
-
1
def add_configuration
-
13
path = "%project_name%/config/slices/health.rb.erb"
-
13
builder.call(settings.with(template_path: path)).render
-
end
-
-
1
def add_action
-
13
path = "%project_name%/slices/health/action.rb.erb"
-
13
builder.call(settings.with(template_path: path)).render
-
end
-
-
1
def add_view
-
13
path = "%project_name%/slices/health/view.rb.erb"
-
13
builder.call(settings.with(template_path: path)).render
-
end
-
-
1
def add_show_template
-
13
path = "%project_name%/slices/health/templates/show.html.erb.erb"
-
-
13
builder.call(settings.with(template_path: path))
-
.render
-
.replace(
-
"<!-- title -->",
-
%(<% content_for :title, "Health | #{settings.project_label}" %>)
-
)
-
.replace("<!-- color -->", %(<%= color %>))
-
end
-
-
1
def add_context
-
13
path = "%project_name%/slices/health/views/context.rb.erb"
-
13
builder.call(settings.with(template_path: path)).render
-
end
-
-
1
def add_show_view
-
13
path = "%project_name%/slices/health/views/show.rb.erb"
-
13
builder.call(settings.with(template_path: path)).render
-
end
-
-
1
def add_show_action
-
13
path = "%project_name%/slices/health/actions/show.rb.erb"
-
13
builder.call(settings.with(template_path: path)).render
-
end
-
-
1
def add_show_action_spec
-
13
path = "%project_name%/spec/slices/health/actions/show_spec.rb.erb"
-
13
builder.call(settings.with(template_path: path)).render
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
1
module Slices
-
# Builds home slice skeleton.
-
1
class Home < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
150
private_methods.grep(/\Aadd_/).sort.each { |method| __send__ method }
-
15
true
-
end
-
-
1
private
-
-
1
def add_configuration
-
15
path = "%project_name%/config/slices/home.rb.erb"
-
15
builder.call(settings.with(template_path: path)).render
-
end
-
-
1
def add_action
-
15
path = "%project_name%/slices/home/action.rb.erb"
-
15
builder.call(settings.with(template_path: path)).render
-
end
-
-
1
def add_repository
-
15
path = "%project_name%/slices/home/repository.rb.erb"
-
15
builder.call(settings.with(template_path: path)).render
-
end
-
-
1
def add_view
-
15
path = "%project_name%/slices/home/view.rb.erb"
-
15
builder.call(settings.with(template_path: path)).render
-
end
-
-
1
def add_context
-
15
path = "%project_name%/slices/home/views/context.rb.erb"
-
15
builder.call(settings.with(template_path: path)).render
-
end
-
-
1
def add_show_template
-
15
path = "%project_name%/slices/home/templates/show.html.erb.erb"
-
-
15
builder.call(settings.with(template_path: path))
-
.render
-
.replace(
-
"<!-- title -->",
-
%(<% content_for :title, "#{settings.project_label}" %>)
-
)
-
.replace("<!-- ruby_version -->", "<%= ruby_version %>")
-
.replace("<!-- hanami_version -->", "<%= hanami_version %>")
-
end
-
-
1
def add_show_view
-
15
path = "%project_name%/slices/home/views/show.rb.erb"
-
15
builder.call(settings.with(template_path: path)).render
-
end
-
-
1
def add_show_action
-
15
path = "%project_name%/slices/home/actions/show.rb.erb"
-
15
builder.call(settings.with(template_path: path)).render
-
end
-
-
1
def add_request_spec
-
15
path = "%project_name%/spec/features/home_spec.rb.erb"
-
15
builder.call(settings.with(template_path: path)).render
-
end
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/struct"
-
-
1
module Hanamismith
-
1
module Builders
-
# Builds project skeleton stylesheet.
-
1
class Stylesheet < Rubysmith::Builders::Abstract
-
1
using Refinements::Struct
-
-
1
def call
-
10
%w[
-
%project_name%/app/assets/css/settings.css.erb
-
%project_name%/app/assets/css/colors.css.erb
-
%project_name%/app/assets/css/view_transitions.css.erb
-
%project_name%/app/assets/css/defaults.css.erb
-
%project_name%/app/assets/css/layout.css.erb
-
].each do |path|
-
50
builder.call(settings.with(template_path: path)).render
-
end
-
-
10
true
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "sod"
-
-
1
module Hanamismith
-
1
module CLI
-
1
module Commands
-
# Handles the build command.
-
1
class Build < Sod::Command
-
1
include Dependencies[:settings, :logger]
-
-
# Order matters.
-
BUILDERS = [
-
1
Rubysmith::Builders::Init,
-
Builders::Core,
-
Builders::Providers::Database,
-
Builders::Providers::HTMX,
-
Builders::Providers::Logger,
-
Builders::Refinement,
-
Builders::Icon,
-
Builders::Stylesheet,
-
Builders::Javascript,
-
Builders::PWA,
-
Builders::Layout,
-
Builders::Slices::Home,
-
Builders::Slices::Health,
-
Rubysmith::Builders::Version,
-
Builders::Documentation::Readme,
-
Rubysmith::Builders::Documentation::Citation,
-
Rubysmith::Builders::Documentation::License,
-
Rubysmith::Builders::Documentation::Version,
-
Rubysmith::Builders::Git::Setup,
-
Builders::Git::Ignore,
-
Rubysmith::Builders::Git::Safe,
-
Builders::Bundler,
-
Builders::Node,
-
Builders::Asset,
-
Rubysmith::Builders::Rake::Binstub,
-
Builders::Rake::Configuration,
-
Builders::Binstub,
-
Builders::Console,
-
Builders::CircleCI,
-
Rubysmith::Builders::GitHub::Template,
-
Rubysmith::Builders::GitHub::Funding,
-
Builders::GitHub::CI,
-
Builders::Setup,
-
Builders::Reek,
-
Rubysmith::Builders::RSpec::Binstub,
-
Rubysmith::Builders::RSpec::Context,
-
Builders::RSpec::ApplicationSharedContext,
-
Builders::RSpec::Helper,
-
Builders::RSpec::Hanami,
-
Builders::Rack::Configuration,
-
Builders::Rack::Attack,
-
Builders::Rack::Deflater,
-
Builders::Puma::Configuration,
-
Builders::Puma::Procfile,
-
Builders::Caliber,
-
Rubysmith::Builders::Docker::Build,
-
Rubysmith::Builders::Docker::Console,
-
Rubysmith::Builders::Docker::Entrypoint,
-
Builders::Docker::Compose,
-
Builders::Docker::File,
-
Rubysmith::Builders::Docker::Ignore,
-
Rubysmith::Extensions::Bundler,
-
Rubysmith::Extensions::Pragmater,
-
Rubysmith::Extensions::Tocer,
-
Rubysmith::Extensions::Rubocop,
-
Extensions::NPM,
-
Extensions::Asset,
-
Builders::Environments::All,
-
Builders::Environments::Development,
-
Builders::Environments::Test,
-
Builders::Git::Commit
-
].freeze
-
-
1
handle "build"
-
-
1
description "Build new project."
-
-
1
on Rubysmith::CLI::Actions::Name, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::AmazingPrint, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Bootsnap, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Caliber, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::CircleCI, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Citation, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Community, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Conduct, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Console, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Contributions, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::DCOO, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Debug, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Docker, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Funding, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Git, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::GitHub, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::GitHubCI, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::GitLint, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::IRBKit, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::License, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Maximum, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Minimum, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Monads, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Rake, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Readme, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Reek, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Refinements, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::RSpec, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::RTC, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Security, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Setup, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::SimpleCov, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Versions, settings: Container[:settings]
-
1
on Rubysmith::CLI::Actions::Zeitwerk, settings: Container[:settings]
-
-
1
def initialize(builders: BUILDERS, **)
-
9
super(**)
-
9
@builders = builders
-
end
-
-
1
def call
-
6
log_info "Building project skeleton: #{settings.project_name}..."
-
252
builders.each { |constant| constant.new(settings:, logger:).call }
-
6
log_info "Project skeleton complete!"
-
end
-
-
1
private
-
-
1
attr_reader :builders
-
-
13
def log_info(message) = logger.info { message }
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "sod"
-
-
1
module Hanamismith
-
1
module CLI
-
# The main Command Line Interface (CLI) object.
-
1
class Shell
-
1
include Dependencies[:defaults_path, :xdg_config, :specification]
-
-
1
def initialize(context: Sod::Context, dsl: Sod, **)
-
7
super(**)
-
7
@context = context
-
7
@dsl = dsl
-
end
-
-
1
def call(...) = cli.call(...)
-
-
1
private
-
-
1
attr_reader :context, :dsl
-
-
1
def cli
-
7
context = build_context
-
-
7
dsl.new :hanamismith, banner: specification.banner do
-
7
on(Sod::Prefabs::Commands::Config, context:)
-
7
on Commands::Build
-
7
on(Sod::Prefabs::Actions::Version, context:)
-
7
on Sod::Prefabs::Actions::Help, self
-
end
-
end
-
-
1
def build_context
-
7
context[defaults_path:, xdg_config:, version_label: specification.labeled_version]
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "cogger"
-
1
require "containable"
-
1
require "etcher"
-
1
require "runcom"
-
1
require "spek"
-
-
1
module Hanamismith
-
# Provides a global gem container for injection into other objects.
-
1
module Container
-
1
extend Containable
-
-
1
register :registry, as: :fresh do
-
188
contract = Rubysmith::Configuration::Contract
-
188
model = Rubysmith::Configuration::Model
-
-
188
Etcher::Registry.new(contract:, model:)
-
.add_loader(:yaml, self[:defaults_path])
-
.add_loader(:yaml, self[:xdg_config].active)
-
.add_transformer(Rubysmith::Configuration::Transformers::GitHubUser.new)
-
.add_transformer(Rubysmith::Configuration::Transformers::GitEmail.new)
-
.add_transformer(Rubysmith::Configuration::Transformers::GitUser.new)
-
.add_transformer(Rubysmith::Configuration::Transformers::TemplateRoot.new)
-
.add_transformer(
-
Rubysmith::Configuration::Transformers::TemplateRoot.new(
-
default: Pathname(__dir__).join("templates")
-
)
-
)
-
.add_transformer(:root, :target_root)
-
.add_transformer(:format, :author_uri)
-
.add_transformer(:format, :citation_affiliation)
-
.add_transformer(:format, :project_uri_community)
-
.add_transformer(:format, :project_uri_conduct)
-
.add_transformer(:format, :project_uri_contributions)
-
.add_transformer(:format, :project_uri_dcoo)
-
.add_transformer(:format, :project_uri_download, :project_name)
-
.add_transformer(:format, :project_uri_funding)
-
.add_transformer(:format, :project_uri_home, :project_name)
-
.add_transformer(:format, :project_uri_issues, :project_name)
-
.add_transformer(:format, :project_uri_license)
-
.add_transformer(:format, :project_uri_security)
-
.add_transformer(:format, :project_uri_source, :project_name)
-
.add_transformer(:format, :project_uri_versions, :project_name)
-
.add_transformer(:time, :loaded_at)
-
end
-
-
2
register(:settings) { Etcher.call(self[:registry]).dup }
-
8
register(:specification) { Spek::Loader.call "#{__dir__}/../../hanamismith.gemspec" }
-
2
register(:defaults_path) { Rubysmith::Container[:defaults_path] }
-
2
register(:xdg_config) { Runcom::Config.new "hanamismith/configuration.yml" }
-
1
register(:logger) { Cogger.new id: :hanamismith }
-
1
register :kernel, Kernel
-
1
register :io, STDOUT
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "infusible"
-
-
1
module Hanamismith
-
1
Dependencies = Infusible[Container]
-
end
-
# frozen_string_literal: true
-
-
1
module Hanamismith
-
1
module Extensions
-
# Ensures assets are compiled.
-
1
class Asset
-
1
include Dependencies[:settings, :kernel, :logger]
-
-
1
def call
-
8
else: 6
then: 1
logger.error { "Unable to compile assets. Try: `hanami assets compile`." } unless compile
-
7
true
-
end
-
-
1
private
-
-
1
def compile
-
7
kernel.system "node config/assets.js -- --path=app --dest=public/assets > /dev/null 2>&1",
-
chdir: settings.project_root
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require "refinements/io"
-
1
require "refinements/pathname"
-
-
1
module Hanamismith
-
1
module Extensions
-
# Ensures NPM packages are installed if NPM is available.
-
1
class NPM
-
1
include Dependencies[:settings, :kernel, :logger]
-
-
1
using Refinements::IO
-
1
using Refinements::Pathname
-
-
1
def call
-
8
else: 6
then: 1
logger.error { "Unable to detect NPM. Install NPM and run: `npm install`." } unless run
-
7
true
-
end
-
-
1
private
-
-
1
def run
-
7
success = false
-
-
7
settings.project_root.change_dir do
-
14
STDOUT.squelch { success = kernel.system "command -v npm && npm install" }
-
end
-
-
7
success
-
end
-
end
-
end
-
end