Skip to content

Commit

Permalink
Updates for Crystal 1.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gdotdesign committed Jan 22, 2025
1 parent b82561a commit 61c1550
Show file tree
Hide file tree
Showing 88 changed files with 179 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
crystal 1.14.0
crystal 1.15.0
mint 0.20.0
nodejs 20.10.0
yarn 1.22.19
2 changes: 1 addition & 1 deletion shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ shards:

ameba:
git: https://github.com/crystal-ameba/ameba.git
version: 1.6.1
version: 1.6.4

ansi-escapes:
git: https://github.com/gtramontina/ansi-escapes.cr.git
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies:
development_dependencies:
ameba:
github: crystal-ameba/ameba
version: ~> 1.6.1
version: ~> 1.6.4

targets:
mint:
Expand Down
2 changes: 1 addition & 1 deletion src/ast.cr
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module Mint
*,
column : Int64,
path : String,
line : Int64
line : Int64,
) : Array(Ast::Node)
nodes_at_path(path).select!(&.contains?(line, column))
end
Expand Down
2 changes: 1 addition & 1 deletion src/ast/directives/file_based.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module Mint
@from : Parser::Location,
@to : Parser::Location,
@file : Parser::File,
@path : String
@path : String,
)
end

Expand Down
26 changes: 13 additions & 13 deletions src/bundler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module Mint

# Compile the CSS.
files[path_for_asset("index.css")] =
->do
-> do
Logger.log "Generating index.css" do
compiler.style_builder.compile
end
Expand Down Expand Up @@ -299,7 +299,7 @@ module Mint
renderer.render(compiler.js.statements(items, line_count: 2)) + ";"
end

files[path] = ->{ js }
files[path] = -> { js }

{renderer, path, js}
end
Expand All @@ -313,16 +313,16 @@ module Mint
source_map =
SourceMapGenerator.new(renderer.mappings, js).generate

files[path] = ->{ "#{js}\n//# sourceMappingURL=#{File.basename(source_map_path)}" }
files[source_map_path] = ->{ source_map }
files[path] = -> { "#{js}\n//# sourceMappingURL=#{File.basename(source_map_path)}" }
files[source_map_path] = -> { source_map }
end
end
end
end
end

def generate_index_html
files["/index.html"] = ->do
files["/index.html"] = -> do
HtmlBuilder.build(optimize: config.optimize) do
html do
head do
Expand Down Expand Up @@ -393,7 +393,7 @@ module Mint
end

def generate_manifest
files["/manifest.webmanifest"] = ->do
files["/manifest.webmanifest"] = -> do
icons =
if generate_icons?
ICON_SIZES.map do |size|
Expand Down Expand Up @@ -430,7 +430,7 @@ module Mint

ICON_SIZES.each do |size|
files[path_for_asset("icon-#{size}x#{size}.png")] =
->{ IconGenerator.convert(json.application.icon, size) }
-> { IconGenerator.convert(json.application.icon, size) }
end
end

Expand All @@ -443,7 +443,7 @@ module Mint
path =
path_for_asset(asset.filename(build: config.hash_assets))

files[path] = ->{ asset.file_contents }
files[path] = -> { asset.file_contents }
end

if Dir.exists?(PUBLIC_DIR)
Expand All @@ -453,23 +453,23 @@ module Mint
parts =
Path[path].parts.tap(&.shift)

files["/#{parts.join("/")}"] = ->{ File.read(path) }
files["/#{parts.join("/")}"] = -> { File.read(path) }
end
end

files[path_for_asset("runtime.js")] =
if runtime_path = config.runtime_path
# TODO: Raise if runtime not found
->{ File.read(runtime_path) }
-> { File.read(runtime_path) }
elsif config.test
->{ Assets.read("runtime_test.js") }
-> { Assets.read("runtime_test.js") }
else
->{ Assets.read("runtime.js") }
-> { Assets.read("runtime.js") }
end

if config.live_reload
files[path_for_asset("live-reload.js")] =
->{ Assets.read("live-reload.js") }
-> { Assets.read("live-reload.js") }
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/commands/build.cr
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module Mint
content.bytesize

proc =
->{ File.write_p(Path[DIST_DIR, chopped], content) }
-> { File.write_p(Path[DIST_DIR, chopped], content) }

bundle_size +=
size
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/js.cr
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ module Mint
# Renders an initializer.
def new(
name : Item | Compiled,
items : Array(Compiled) = [] of Compiled
items : Array(Compiled) = [] of Compiled,
) : Compiled
["new "] + call(name, items)
end
Expand Down Expand Up @@ -156,7 +156,7 @@ module Mint
def tenary(
condition : Compiled,
truthy : Compiled,
falsy : Compiled
falsy : Compiled,
) : Compiled
["("] +
condition +
Expand Down Expand Up @@ -198,7 +198,7 @@ module Mint
private def list(
arguments : Array(Compiled),
*,
multiline : Bool = false
multiline : Bool = false,
) : Compiled
if multiline
join(arguments, ",\n")
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/renderer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module Mint
@asset_path,
@bundles,
@pool,
@base
@base,
)
end

Expand Down
2 changes: 1 addition & 1 deletion src/compilers/case.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Mint
class Compiler
def compile(
node : Ast::Case,
block : Proc(String, String)? = nil
block : Proc(String, String)? = nil,
) : Compiled
compile node do
condition =
Expand Down
2 changes: 1 addition & 1 deletion src/compilers/case_branch.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Mint
class Compiler
def compile(
node : Ast::CaseBranch,
block : Proc(String, String)? = nil
block : Proc(String, String)? = nil,
) : Compiled
compile node do
expression =
Expand Down
4 changes: 2 additions & 2 deletions src/compilers/destructuring.cr
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module Mint

def destructuring(
node : Ast::TypeDestructuring,
variables : Array(Compiled)
variables : Array(Compiled),
) : Compiled
case item = lookups[node][0]
when Ast::TypeVariant
Expand All @@ -51,7 +51,7 @@ module Mint

def match(
condition : Ast::Node,
branches : Array(Tuple(Ast::Node?, Compiled))
branches : Array(Tuple(Ast::Node?, Compiled)),
) : Compiled
items =
branches.map do |(pattern, expression)|
Expand Down
2 changes: 1 addition & 1 deletion src/compilers/function.cr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Mint
node : Ast::Function, *,
contents : Compiled | Nil = nil,
args : Array(Compiled) | Nil = nil,
skip_const : Bool = false
skip_const : Bool = false,
) : Compiled
items =
[] of Compiled
Expand Down
2 changes: 1 addition & 1 deletion src/compilers/html_attribute.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Mint
class Compiler
def resolve(
node : Ast::HtmlAttribute, *,
is_element = true
is_element = true,
) : Hash(Item, Compiled)
value =
compile node.value
Expand Down
4 changes: 2 additions & 2 deletions src/compilers/if.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Mint
class Compiler
def compile(
items : Array(Ast::CssDefinition),
block : Proc(String, String)?
block : Proc(String, String)?,
) : Compiled
compiled =
items.each_with_object({} of String => Compiled) do |definition, memo|
Expand All @@ -24,7 +24,7 @@ module Mint

def compile(
node : Ast::If,
block : Proc(String, String)? = nil
block : Proc(String, String)? = nil,
) : Compiled
compile node do
truthy_item, falsy_item =
Expand Down
2 changes: 1 addition & 1 deletion src/compilers/string.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Mint
class Compiler
def compile(
value : Array(Ast::Node | String), *,
quote_string : Bool = false
quote_string : Bool = false,
) : Compiled
if value.any?(Ast::Node)
value.map do |part|
Expand Down
8 changes: 4 additions & 4 deletions src/documentation_generator.cr
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module Mint
*,
@value = nil,
@type = nil,
@name
@name,
)
end
end
Expand Down Expand Up @@ -90,7 +90,7 @@ module Mint
@type = nil,
@broken,
@name,
@kind
@kind,
)
end
end
Expand Down Expand Up @@ -127,7 +127,7 @@ module Mint
@flags = nil,
link = nil,
@name,
@kind
@kind,
)
@link = link || @name
end
Expand Down Expand Up @@ -325,7 +325,7 @@ module Mint
mapping : String? = nil,
type : Ast::Node? = nil,
name : String,
kind : Kind
kind : Kind,
)
formatted_value =
@@formatter.format!(value)
Expand Down
6 changes: 3 additions & 3 deletions src/error_message.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module Mint
files = {} of String => Proc(String)

files["/live-reload.js"] =
->{ Assets.read("live-reload.js") } if live_reload
-> { Assets.read("live-reload.js") } if live_reload

files["/index.html"] =
->do
-> do
HtmlBuilder.build(optimize: true) do
html do
head do
Expand All @@ -29,7 +29,7 @@ module Mint

Assets.files.each do |file|
next unless file.path.starts_with?("/error_message/")
files[file.path.lchop("/error_message")] = ->{ Assets.read(file.path) }
files[file.path.lchop("/error_message")] = -> { Assets.read(file.path) }
end

files
Expand Down
2 changes: 1 addition & 1 deletion src/errorable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ module Mint

def expected(
subject : TypeChecker::Checkable | String,
got : TypeChecker::Checkable
got : TypeChecker::Checkable,
)
snippet "I was expecting:", subject
snippet "Instead it is:", got
Expand Down
8 changes: 4 additions & 4 deletions src/exhaustiveness_checker.cr
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ module ExhaustivenessChecker
def add_missing_patterns(
node : Decision,
terms : Array(Term),
missing : Set(String)
missing : Set(String),
)
case node
in Success
Expand Down Expand Up @@ -513,7 +513,7 @@ module ExhaustivenessChecker
def compile_constructor_cases(
rows : Array(Row),
branch_var : Variable,
cases : Array(Tuple(Constructor, Array(Variable), Array(Row)))
cases : Array(Tuple(Constructor, Array(Variable), Array(Row))),
) : Array(Case)
rows.each do |row|
# This row had the branching variable.
Expand Down Expand Up @@ -584,7 +584,7 @@ module ExhaustivenessChecker
#
def compile_infinite_cases(
rows : Array(Row),
branch_var : Variable
branch_var : Variable,
) : Tuple(Array(Case), Decision)
raw_cases =
[] of Tuple(Constructor, Array(Variable), Array(Row))
Expand Down Expand Up @@ -654,7 +654,7 @@ module ExhaustivenessChecker
def compile_array_cases(
rows : Array(Row),
branch_var : Variable,
type : Checkable
type : Checkable,
) : Decision
rest_var =
new_variable(branch_var.type)
Expand Down
2 changes: 1 addition & 1 deletion src/formatter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ module Mint

def format_arguments(
nodes : Array(Ast::Node), *,
empty_parenthesis = true
empty_parenthesis = true,
) : Nodes
return empty_parenthesis ? ["()"] of Node : [] of Node if nodes.empty?

Expand Down
2 changes: 1 addition & 1 deletion src/formatters/html.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Mint
*,
node : Ast::HtmlElement | Ast::HtmlComponent,
prefix : Nodes,
tag : Nodes
tag : Nodes,
) : Nodes
child_nodes =
node.children + node.comments
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/list.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Mint
def list(
nodes : Array(Ast::Node),
separator : String? = nil,
comment : Nodes? = nil
comment : Nodes? = nil,
) : Nodes
[
List.new(
Expand Down
Loading

0 comments on commit 61c1550

Please sign in to comment.