Sha256: 6a00507378b51dc473a02390fdd2e2296417916f0a9acbca128564c2153dfa7e

Contents?: true

Size: 1.74 KB

Versions: 4

Compression:

Stored size: 1.74 KB

Contents

# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'flatpickr/version'

RSpec::Core::RakeTask.new(:spec)

task default: :spec

namespace :flatpickr do
  namespace :assets do
    desc 'Update Flatpickr assets from source.'
    task update: :clean do
      version = ARGV[1] || "v#{Flatpickr::VERSION.sub(/.\d+$/, '')}"

      sh 'git clone git@github.com:flatpickr/flatpickr.git flatpickr_source'
      sh "cd flatpickr_source && git checkout tags/#{version}"
      sh 'cd flatpickr_source && npm install && npm run build:pre && npm run build:build'

      sh 'cp flatpickr_source/dist/flatpickr.js vendor/assets/javascripts/flatpickr.js'
      sh 'cp -R flatpickr_source/dist/plugins/ vendor/assets/javascripts/flatpickr/plugins/'
      sh 'cd vendor/assets/javascripts/flatpickr/plugins/ && find . -name "*.css" -type f -delete'
      sh 'cp -R flatpickr_source/dist/l10n/ vendor/assets/javascripts/flatpickr/l10n/'

      sh 'cp flatpickr_source/dist/flatpickr.css vendor/assets/stylesheets/flatpickr.css'
      sh 'cp -R flatpickr_source/dist/plugins/ vendor/assets/stylesheets/flatpickr/plugins/'
      sh 'cd vendor/assets/stylesheets/flatpickr/plugins/ && find . -name "*.js" -type f -delete'
      sh 'cp -R flatpickr_source/dist/themes/ vendor/assets/stylesheets/flatpickr/themes/'
      sh 'cp flatpickr_source/dist/ie.css vendor/assets/stylesheets/flatpickr/ie.css'

      puts "\n===============================\n"
      puts "ASSETS UPDATED to #{version}! ✨"
    end

    desc 'Remove previous Flatpickr assets.'
    task :clean do
      sh 'rm -rf vendor'
      sh 'rm -rf flatpickr_source'
      sh 'mkdir -p vendor/assets/stylesheets/flatpickr/'
      sh 'mkdir -p vendor/assets/javascripts/flatpickr/'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
flatpickr-4.6.3.0 Rakefile
flatpickr-4.5.7.0 Rakefile
flatpickr-4.5.2.1 Rakefile
flatpickr-4.5.2.0 Rakefile