Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a new rake task to support refreshing all generated types #17

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/tasks/generate.rake
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
namespace :typelizer do
desc "Generate TypeScript interfaces from serializers"
task generate: :environment do
benchmark do
Typelizer::Generator.call
end
end

desc "Removes all files in output folder and refreshs all generate TypeScript interfaces from serializers"
task "generate:refresh": :environment do
benchmark do
Typelizer::Generator.call(force: true)
end
end

def benchmark(&block)
require "benchmark"

ENV["TYPELIZER"] = "true"

puts "Generating TypeScript interfaces..."
serializers = []
time = Benchmark.realtime do
serializers = Typelizer::Generator.call
serializers = block.call
end

puts "Finished in #{time} seconds"
Expand Down
4 changes: 2 additions & 2 deletions lib/typelizer/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

module Typelizer
class Generator
def self.call
new.call
def self.call(**args)
new.call(**args)
end

def initialize(config = Typelizer::Config)
Expand Down
Loading