require "json" namespace :coco do desc "Run tests" task :test, [:files] do |task, args| puts "🥥 Running Ruby tests..." system "npm run build:dev" system "bundle exec rake test TEST=#{args.files || "test/**/*_test.rb"}" puts "✅ Ruby tests complete" end namespace :test do desc "Run tests in CI" task :ci do puts "🥥 Building assets..." Rake::Task["coco:assets:build"].execute puts "🥥 Running Ruby tests..." Rake::Task["test"].execute puts "✅ Ruby tests complete" end end task :lint do puts "🥥 Running standardrb..." Rake::Task["standard"].execute puts "✅ standardrb complete" puts "🥥 Running prettier..." system "npx prettier . --check --config ./package.json" puts "✅ prettier complete" end namespace :lint do desc "Lint & fix files" task :fix do puts "🥥 Running standardrb..." Rake::Task["standard:fix"].execute puts "✅ standardrb complete" puts "🥥 Running prettier..." system "npx prettier . --write --config ./package.json" puts "✅ prettier complete" end end namespace :assets do desc "Build assets" task :build do puts "🥥 Building assets..." system "npm run build" puts "✅ Asset build complete" end end namespace :gem do desc "Build and push to RubyGems" task :release, [:version] do |task, args| Rake::Task["coco:gem:build"].execute Rake::Task["coco:gem:push"].invoke(args.version) end desc "Bump gem version" task :bump_version, [:version] => :environment do |task, args| puts "🥥 Bumping version number to #{args.version}" new_version = args.version.sub("v", "").tr("-", ".") version_file = File.expand_path("#{File.dirname(__FILE__)}/../coco.rb") current_version = Coco::VERSION.to_s file = File.open(version_file) contents = file.read File.write(version_file, contents.gsub(current_version, new_version)) puts "✅ Version bump complete" end desc "Build gem" task :build do puts "🥥 Building Gem..." Rake::Task["build"].execute puts "✅ Gem build complete" end desc "Push gem to Rubygems" task :push, [:version] do |task, args| puts "🥥 Pushing to RubyGems..." version = args.version.sub("v", "").tr("-", ".") system "gem push pkg/coveragebook_components-#{version}.gem" puts "✅ Gem pushed to RubyGems" end end end