dsu 3.0.0.beta.0 → 3.0.0.beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +1 -0
- data/Gemfile +5 -5
- data/Gemfile.lock +4 -1
- data/lib/dsu/migration/base_service.rb +118 -0
- data/lib/dsu/migration/migrator.rb +24 -0
- data/lib/dsu/migration/raw_helpers/color_theme_hash.rb +13 -0
- data/lib/dsu/migration/raw_helpers/configuration_hash.rb +15 -0
- data/lib/dsu/migration/raw_helpers/entry_group_hash.rb +13 -0
- data/lib/dsu/migration/raw_json_file.rb +15 -0
- data/lib/dsu/migration/raw_json_files.rb +56 -0
- data/lib/dsu/migration/v20230613121411/service.rb +94 -0
- data/lib/dsu/migration/v20240210161248/service.rb +148 -0
- data/lib/dsu/models/color_theme.rb +2 -0
- data/lib/dsu/models/project.rb +2 -2
- data/lib/dsu/support/fileable.rb +11 -7
- data/lib/dsu/version.rb +1 -1
- data/lib/dsu/views/project/list.rb +4 -4
- data/lib/dsu.rb +8 -15
- data/lib/locales/en/miscellaneous.yml +1 -2
- data/lib/locales/en/subcommands.yml +5 -5
- data/lib/seed_data/20230613121411/dsu/migration_version.json +3 -0
- data/lib/seed_data/20240210161248/dsu/current_project.json +4 -0
- data/lib/seed_data/20240210161248/dsu/migration_version.json +3 -0
- data/lib/seed_data/20240210161248/dsu/projects/default/project.json +5 -0
- data/lib/seed_data/20240210161248/dsu/themes/cherry.json +79 -0
- data/lib/seed_data/20240210161248/dsu/themes/christmas.json +79 -0
- data/lib/seed_data/20240210161248/dsu/themes/default.json +79 -0
- data/lib/seed_data/20240210161248/dsu/themes/lemon.json +79 -0
- data/lib/seed_data/20240210161248/dsu/themes/light.json +79 -0
- data/lib/seed_data/20240210161248/dsu/themes/matrix.json +79 -0
- data/lib/seed_data/20240210161248/dsu/themes/whiteout.json +79 -0
- metadata +31 -12
- data/lib/dsu/migration/factory.rb +0 -26
- data/lib/dsu/migration/service.rb +0 -196
- data/lib/dsu/migration/service_20240210161248.rb +0 -172
- /data/lib/seed_data/{themes → 20230613121411/dsu/themes}/cherry.json +0 -0
- /data/lib/seed_data/{themes → 20230613121411/dsu/themes}/christmas.json +0 -0
- /data/lib/seed_data/{themes → 20230613121411/dsu/themes}/default.json +0 -0
- /data/lib/seed_data/{themes → 20230613121411/dsu/themes}/lemon.json +0 -0
- /data/lib/seed_data/{themes → 20230613121411/dsu/themes}/light.json +0 -0
- /data/lib/seed_data/{themes → 20230613121411/dsu/themes}/matrix.json +0 -0
- /data/lib/seed_data/{themes → 20230613121411/dsu/themes}/whiteout.json +0 -0
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: dsu
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 3.0.0.beta. | 
| 4 | 
            +
              version: 3.0.0.beta.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Gene M. Angelo, Jr.
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024-02- | 
| 11 | 
            +
            date: 2024-02-17 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         | 
| @@ -169,9 +169,15 @@ files: | |
| 169 169 | 
             
            - lib/dsu/command_services/add_entry_service.rb
         | 
| 170 170 | 
             
            - lib/dsu/crud/json_file.rb
         | 
| 171 171 | 
             
            - lib/dsu/env.rb
         | 
| 172 | 
            -
            - lib/dsu/migration/ | 
| 173 | 
            -
            - lib/dsu/migration/ | 
| 174 | 
            -
            - lib/dsu/migration/ | 
| 172 | 
            +
            - lib/dsu/migration/base_service.rb
         | 
| 173 | 
            +
            - lib/dsu/migration/migrator.rb
         | 
| 174 | 
            +
            - lib/dsu/migration/raw_helpers/color_theme_hash.rb
         | 
| 175 | 
            +
            - lib/dsu/migration/raw_helpers/configuration_hash.rb
         | 
| 176 | 
            +
            - lib/dsu/migration/raw_helpers/entry_group_hash.rb
         | 
| 177 | 
            +
            - lib/dsu/migration/raw_json_file.rb
         | 
| 178 | 
            +
            - lib/dsu/migration/raw_json_files.rb
         | 
| 179 | 
            +
            - lib/dsu/migration/v20230613121411/service.rb
         | 
| 180 | 
            +
            - lib/dsu/migration/v20240210161248/service.rb
         | 
| 175 181 | 
             
            - lib/dsu/migration/version.rb
         | 
| 176 182 | 
             
            - lib/dsu/models/color_theme.rb
         | 
| 177 183 | 
             
            - lib/dsu/models/configuration.rb
         | 
| @@ -293,13 +299,24 @@ files: | |
| 293 299 | 
             
            - lib/locales/en/presenters.yml
         | 
| 294 300 | 
             
            - lib/locales/en/services.yml
         | 
| 295 301 | 
             
            - lib/locales/en/subcommands.yml
         | 
| 296 | 
            -
            - lib/seed_data/ | 
| 297 | 
            -
            - lib/seed_data/themes/ | 
| 298 | 
            -
            - lib/seed_data/themes/ | 
| 299 | 
            -
            - lib/seed_data/themes/ | 
| 300 | 
            -
            - lib/seed_data/themes/ | 
| 301 | 
            -
            - lib/seed_data/themes/ | 
| 302 | 
            -
            - lib/seed_data/themes/ | 
| 302 | 
            +
            - lib/seed_data/20230613121411/dsu/migration_version.json
         | 
| 303 | 
            +
            - lib/seed_data/20230613121411/dsu/themes/cherry.json
         | 
| 304 | 
            +
            - lib/seed_data/20230613121411/dsu/themes/christmas.json
         | 
| 305 | 
            +
            - lib/seed_data/20230613121411/dsu/themes/default.json
         | 
| 306 | 
            +
            - lib/seed_data/20230613121411/dsu/themes/lemon.json
         | 
| 307 | 
            +
            - lib/seed_data/20230613121411/dsu/themes/light.json
         | 
| 308 | 
            +
            - lib/seed_data/20230613121411/dsu/themes/matrix.json
         | 
| 309 | 
            +
            - lib/seed_data/20230613121411/dsu/themes/whiteout.json
         | 
| 310 | 
            +
            - lib/seed_data/20240210161248/dsu/current_project.json
         | 
| 311 | 
            +
            - lib/seed_data/20240210161248/dsu/migration_version.json
         | 
| 312 | 
            +
            - lib/seed_data/20240210161248/dsu/projects/default/project.json
         | 
| 313 | 
            +
            - lib/seed_data/20240210161248/dsu/themes/cherry.json
         | 
| 314 | 
            +
            - lib/seed_data/20240210161248/dsu/themes/christmas.json
         | 
| 315 | 
            +
            - lib/seed_data/20240210161248/dsu/themes/default.json
         | 
| 316 | 
            +
            - lib/seed_data/20240210161248/dsu/themes/lemon.json
         | 
| 317 | 
            +
            - lib/seed_data/20240210161248/dsu/themes/light.json
         | 
| 318 | 
            +
            - lib/seed_data/20240210161248/dsu/themes/matrix.json
         | 
| 319 | 
            +
            - lib/seed_data/20240210161248/dsu/themes/whiteout.json
         | 
| 303 320 | 
             
            - project.bak
         | 
| 304 321 | 
             
            - sig/dsu.rbs
         | 
| 305 322 | 
             
            homepage: https://github.com/gangelo/dsu
         | 
| @@ -341,6 +358,8 @@ post_install_message: | | |
| 341 358 | 
             
              Thank you!
         | 
| 342 359 |  | 
| 343 360 | 
             
              <3 Gene
         | 
| 361 | 
            +
             | 
| 362 | 
            +
              dsu now uses "Projects"! Run `dsu help project` to get started.
         | 
| 344 363 | 
             
            rdoc_options: []
         | 
| 345 364 | 
             
            require_paths:
         | 
| 346 365 | 
             
            - lib
         | 
| @@ -1,26 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require_relative '../models/migration_version'
         | 
| 4 | 
            -
            require_relative 'service_20240210161248'
         | 
| 5 | 
            -
            require_relative 'version'
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            module Dsu
         | 
| 8 | 
            -
              module Migration
         | 
| 9 | 
            -
                class Factory
         | 
| 10 | 
            -
                  class << self
         | 
| 11 | 
            -
                    def migrate_if!(options: {})
         | 
| 12 | 
            -
                      version = options.fetch(:version, migration_version)
         | 
| 13 | 
            -
                      if version == 20230613121411 # rubocop:disable Style/NumericLiterals
         | 
| 14 | 
            -
                        Service20240210161248.new(options: options).migrate!
         | 
| 15 | 
            -
                      end
         | 
| 16 | 
            -
                    end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                    private
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                    def migration_version
         | 
| 21 | 
            -
                      Models::MigrationVersion.new.version
         | 
| 22 | 
            -
                    end
         | 
| 23 | 
            -
                  end
         | 
| 24 | 
            -
                end
         | 
| 25 | 
            -
              end
         | 
| 26 | 
            -
            end
         | 
| @@ -1,196 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'fileutils'
         | 
| 4 | 
            -
            require 'json'
         | 
| 5 | 
            -
            require_relative '../migration/version'
         | 
| 6 | 
            -
            require_relative '../models/configuration'
         | 
| 7 | 
            -
            require_relative '../models/migration_version'
         | 
| 8 | 
            -
            require_relative '../support/fileable'
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            module Dsu
         | 
| 11 | 
            -
              module Migration
         | 
| 12 | 
            -
                MIGRATION_VERSION_REGEX = /(\A\d+)/
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                class Service
         | 
| 15 | 
            -
                  include Support::Fileable
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                  def initialize(options: {})
         | 
| 18 | 
            -
                    @options = options || {}
         | 
| 19 | 
            -
                    @migration_version = Models::MigrationVersion.new(options: options)
         | 
| 20 | 
            -
                    @start_migration_version = @migration_version.version
         | 
| 21 | 
            -
                  end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                  def call
         | 
| 24 | 
            -
                    unless self.class.run_migrations?
         | 
| 25 | 
            -
                      puts 'Nothing to do.'
         | 
| 26 | 
            -
                      return
         | 
| 27 | 
            -
                    end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                    run_migrations!
         | 
| 30 | 
            -
                  end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                  class << self
         | 
| 33 | 
            -
                    def run_migrations?
         | 
| 34 | 
            -
                      Models::MigrationVersion.new.version < 20230613121411 # rubocop:disable Style/NumericLiterals
         | 
| 35 | 
            -
                    end
         | 
| 36 | 
            -
                  end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                  private
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                  attr_reader :migration_version, :options, :start_migration_version
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                  def run_migrations!
         | 
| 43 | 
            -
                    puts "dsu version: #{Dsu::VERSION}"
         | 
| 44 | 
            -
                    puts
         | 
| 45 | 
            -
             | 
| 46 | 
            -
                    puts 'Running migrations...'
         | 
| 47 | 
            -
                    puts
         | 
| 48 | 
            -
             | 
| 49 | 
            -
                    puts "Current migration version: #{start_migration_version}"
         | 
| 50 | 
            -
                    puts "Migrating to version: #{Dsu::Migration::VERSION}"
         | 
| 51 | 
            -
                    puts
         | 
| 52 | 
            -
             | 
| 53 | 
            -
                    backup!
         | 
| 54 | 
            -
                    cleanup!
         | 
| 55 | 
            -
                    migrate!
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                    new_migration_version = Models::MigrationVersion.new(version: Dsu::Migration::VERSION).tap(&:save!).version
         | 
| 58 | 
            -
             | 
| 59 | 
            -
                    puts "Migration version after migration is: #{new_migration_version}"
         | 
| 60 | 
            -
                    puts 'Migration completed successfully.'
         | 
| 61 | 
            -
                  rescue StandardError => e
         | 
| 62 | 
            -
                    warn "Migration completed with errors: #{e.message}"
         | 
| 63 | 
            -
                  end
         | 
| 64 | 
            -
             | 
| 65 | 
            -
                  def backup!
         | 
| 66 | 
            -
                    backup_config!
         | 
| 67 | 
            -
                    puts
         | 
| 68 | 
            -
             | 
| 69 | 
            -
                    backup_entry_groups!
         | 
| 70 | 
            -
                    puts
         | 
| 71 | 
            -
             | 
| 72 | 
            -
                    backup_themes!
         | 
| 73 | 
            -
                    puts
         | 
| 74 | 
            -
                  end
         | 
| 75 | 
            -
             | 
| 76 | 
            -
                  def backup_config!
         | 
| 77 | 
            -
                    puts 'Backing up config...'
         | 
| 78 | 
            -
                    if File.exist?(config_path)
         | 
| 79 | 
            -
                      backup_path = File.join(current_backup_folder, config_file_name)
         | 
| 80 | 
            -
                      puts "Backing up #{config_path} to #{backup_path}..."
         | 
| 81 | 
            -
                      FileUtils.cp(config_path, backup_path)
         | 
| 82 | 
            -
                    else
         | 
| 83 | 
            -
                      puts 'No config to backup.'
         | 
| 84 | 
            -
                    end
         | 
| 85 | 
            -
                  end
         | 
| 86 | 
            -
             | 
| 87 | 
            -
                  def backup_entry_groups!
         | 
| 88 | 
            -
                    puts 'Backing up entry groups...'
         | 
| 89 | 
            -
                    if Dir.exist?(entries_folder)
         | 
| 90 | 
            -
                      backup_folder = File.join(current_backup_folder, File.basename(entries_folder))
         | 
| 91 | 
            -
                      puts "Backing up #{entries_folder} to #{backup_folder}..."
         | 
| 92 | 
            -
                      FileUtils.mkdir_p(backup_folder)
         | 
| 93 | 
            -
                      FileUtils.cp_r("#{entries_folder}/.", backup_folder)
         | 
| 94 | 
            -
                    else
         | 
| 95 | 
            -
                      puts 'No entries to backup.'
         | 
| 96 | 
            -
                    end
         | 
| 97 | 
            -
                  end
         | 
| 98 | 
            -
             | 
| 99 | 
            -
                  def backup_themes!
         | 
| 100 | 
            -
                    puts 'Backing up themes...'
         | 
| 101 | 
            -
                    if Dir.exist?(themes_folder)
         | 
| 102 | 
            -
                      backup_folder = File.join(current_backup_folder, File.basename(themes_folder))
         | 
| 103 | 
            -
                      puts "Backing up #{themes_folder} to #{backup_folder}..."
         | 
| 104 | 
            -
                      FileUtils.mkdir_p(backup_folder)
         | 
| 105 | 
            -
                      FileUtils.cp_r("#{themes_folder}/.", backup_folder)
         | 
| 106 | 
            -
                    else
         | 
| 107 | 
            -
                      puts 'No entries to backup.'
         | 
| 108 | 
            -
                    end
         | 
| 109 | 
            -
                  end
         | 
| 110 | 
            -
             | 
| 111 | 
            -
                  def before_migration_version
         | 
| 112 | 
            -
                    @before_migration_version ||= migration_version_instance.version
         | 
| 113 | 
            -
                  end
         | 
| 114 | 
            -
             | 
| 115 | 
            -
                  def cleanup!
         | 
| 116 | 
            -
                    puts 'Cleaning up old config file...'
         | 
| 117 | 
            -
                    File.delete(config_path) if File.file?(config_path)
         | 
| 118 | 
            -
                    puts 'Done.'
         | 
| 119 | 
            -
                    puts
         | 
| 120 | 
            -
             | 
| 121 | 
            -
                    puts 'Cleaning up old entries...'
         | 
| 122 | 
            -
                    entry_files = Dir.glob(File.join(entries_folder, '*'))
         | 
| 123 | 
            -
                    entry_files.each do |entry_file|
         | 
| 124 | 
            -
                      File.delete(entry_file) if File.file?(entry_file)
         | 
| 125 | 
            -
                    end
         | 
| 126 | 
            -
                    puts 'Done.'
         | 
| 127 | 
            -
                    puts
         | 
| 128 | 
            -
             | 
| 129 | 
            -
                    puts 'Cleaning up old themes...'
         | 
| 130 | 
            -
                    theme_files = Dir.glob(File.join(themes_folder, '*'))
         | 
| 131 | 
            -
                    theme_files.each do |theme_file|
         | 
| 132 | 
            -
                      File.delete(theme_file) if File.file?(theme_file)
         | 
| 133 | 
            -
                    end
         | 
| 134 | 
            -
                    puts 'Done.'
         | 
| 135 | 
            -
                    puts
         | 
| 136 | 
            -
                  end
         | 
| 137 | 
            -
             | 
| 138 | 
            -
                  def create_backup_folder!
         | 
| 139 | 
            -
                    FileUtils.mkdir_p(backup_folder(version: current_migration_version))
         | 
| 140 | 
            -
                  end
         | 
| 141 | 
            -
             | 
| 142 | 
            -
                  def current_backup_folder
         | 
| 143 | 
            -
                    @current_backup_folder ||= begin
         | 
| 144 | 
            -
                      create_backup_folder!
         | 
| 145 | 
            -
                      backup_folder(version: current_migration_version)
         | 
| 146 | 
            -
                    end
         | 
| 147 | 
            -
                  end
         | 
| 148 | 
            -
             | 
| 149 | 
            -
                  def current_migration_version
         | 
| 150 | 
            -
                    migration_version_instance.version
         | 
| 151 | 
            -
                  end
         | 
| 152 | 
            -
             | 
| 153 | 
            -
                  # Migrate
         | 
| 154 | 
            -
             | 
| 155 | 
            -
                  def migrate!
         | 
| 156 | 
            -
                    FileUtils.mkdir_p(dsu_folder)
         | 
| 157 | 
            -
                    FileUtils.mkdir_p(themes_folder)
         | 
| 158 | 
            -
                    FileUtils.mkdir_p(entries_folder)
         | 
| 159 | 
            -
             | 
| 160 | 
            -
                    migrate_themes!
         | 
| 161 | 
            -
                    migrate_config!
         | 
| 162 | 
            -
                    migrate_entry_groups!
         | 
| 163 | 
            -
                  end
         | 
| 164 | 
            -
             | 
| 165 | 
            -
                  def migrate_config!
         | 
| 166 | 
            -
                    puts 'Migrating config...'
         | 
| 167 | 
            -
                    Models::Configuration.new.save!
         | 
| 168 | 
            -
                    puts 'Done.'
         | 
| 169 | 
            -
                  end
         | 
| 170 | 
            -
             | 
| 171 | 
            -
                  def migrate_entry_groups!
         | 
| 172 | 
            -
                    puts 'Migrating entry groups...'
         | 
| 173 | 
            -
                    # source_folder = File.join(seed_data_folder, 'entries')
         | 
| 174 | 
            -
                    # puts "Copying entries from #{source_folder} to #{entries_folder}..."
         | 
| 175 | 
            -
                    # FileUtils.cp_r("#{source_folder}/.", entries_folder)
         | 
| 176 | 
            -
                    # puts 'Done.'
         | 
| 177 | 
            -
                    description = "Migrated DSU to version #{Dsu::Migration::VERSION}"
         | 
| 178 | 
            -
                    entry = Models::Entry.new(description: description)
         | 
| 179 | 
            -
                    Models::EntryGroup.new(time: Time.now, entries: [entry]).save!
         | 
| 180 | 
            -
                    puts 'Done.'
         | 
| 181 | 
            -
                  end
         | 
| 182 | 
            -
             | 
| 183 | 
            -
                  def migrate_themes!
         | 
| 184 | 
            -
                    puts 'Migrating themes...'
         | 
| 185 | 
            -
                    source_folder = File.join(seed_data_folder, 'themes')
         | 
| 186 | 
            -
                    puts "Copying themes from #{source_folder} to #{themes_folder}..."
         | 
| 187 | 
            -
                    FileUtils.cp_r("#{source_folder}/.", themes_folder)
         | 
| 188 | 
            -
                    puts 'Done.'
         | 
| 189 | 
            -
                  end
         | 
| 190 | 
            -
             | 
| 191 | 
            -
                  def migration_version_instance
         | 
| 192 | 
            -
                    @migration_version_instance ||= Models::MigrationVersion.new
         | 
| 193 | 
            -
                  end
         | 
| 194 | 
            -
                end
         | 
| 195 | 
            -
              end
         | 
| 196 | 
            -
            end
         | 
| @@ -1,172 +0,0 @@ | |
| 1 | 
            -
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require_relative '../support/fileable'
         | 
| 4 | 
            -
            require_relative 'version'
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            module Dsu
         | 
| 7 | 
            -
              module Migration
         | 
| 8 | 
            -
                class Service20240210161248
         | 
| 9 | 
            -
                  include Support::Fileable
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                  def initialize(options: {})
         | 
| 12 | 
            -
                    @options = options || {}
         | 
| 13 | 
            -
                  end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                  def migrate!
         | 
| 16 | 
            -
                    puts 'Running migrations...'
         | 
| 17 | 
            -
                    puts
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                    puts "options[:pretend] is true\n" if pretend?
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                    raise_wrong_migration_version_error_if!
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                    puts "Migrating from: #{target_migration_version} to version: #{Migration::VERSION}"
         | 
| 24 | 
            -
                    puts
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                    add_new_color_themes
         | 
| 27 | 
            -
                    create_backup
         | 
| 28 | 
            -
                    create_default_project
         | 
| 29 | 
            -
                    update_configuration
         | 
| 30 | 
            -
                    update_entry_groups
         | 
| 31 | 
            -
                    update_color_themes
         | 
| 32 | 
            -
                    update_migration_version
         | 
| 33 | 
            -
                    delete_old_entry_folder
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                    puts 'Migration completed successfully.'
         | 
| 36 | 
            -
                  end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                  private
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                  attr_reader :options
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                  def pretend?
         | 
| 43 | 
            -
                    options.fetch(:pretend, true)
         | 
| 44 | 
            -
                  end
         | 
| 45 | 
            -
             | 
| 46 | 
            -
                  def add_new_color_themes
         | 
| 47 | 
            -
                    puts 'Copying new color themes...'
         | 
| 48 | 
            -
                    puts
         | 
| 49 | 
            -
             | 
| 50 | 
            -
                    %w[light.json christmas.json].each do |theme_file|
         | 
| 51 | 
            -
                      destination_theme_file_path = File.join(Dsu::Support::Fileable.themes_folder, theme_file)
         | 
| 52 | 
            -
                      # next if File.exist?(destination_theme_file_path)
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                      source_theme_file_path = File.join(Dsu::Support::Fileable.seed_data_folder, 'themes', theme_file)
         | 
| 55 | 
            -
                      FileUtils.cp(source_theme_file_path, destination_theme_file_path) unless pretend?
         | 
| 56 | 
            -
                      puts I18n.t('migrations.information.theme_copied',
         | 
| 57 | 
            -
                        from: source_theme_file_path, to: destination_theme_file_path)
         | 
| 58 | 
            -
                    end
         | 
| 59 | 
            -
                  end
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                  def create_backup
         | 
| 62 | 
            -
                    return if Dir.exist?(backup_folder)
         | 
| 63 | 
            -
             | 
| 64 | 
            -
                    puts 'Creating backup...'
         | 
| 65 | 
            -
                    puts
         | 
| 66 | 
            -
             | 
| 67 | 
            -
                    FileUtils.cp_r(dsu_folder, backup_folder) unless pretend?
         | 
| 68 | 
            -
                  end
         | 
| 69 | 
            -
             | 
| 70 | 
            -
                  def create_default_project
         | 
| 71 | 
            -
                    default_project = Models::Configuration::DEFAULT_CONFIGURATION[:default_project]
         | 
| 72 | 
            -
                    return if Models::Project.project_initialized?(project_name: default_project)
         | 
| 73 | 
            -
             | 
| 74 | 
            -
                    puts "Creating default project \"#{default_project}\"..."
         | 
| 75 | 
            -
                    puts
         | 
| 76 | 
            -
             | 
| 77 | 
            -
                    Models::Project.create(project_name: default_project, options: options) unless pretend?
         | 
| 78 | 
            -
                  end
         | 
| 79 | 
            -
             | 
| 80 | 
            -
                  def update_configuration
         | 
| 81 | 
            -
                    puts 'Updating configuration...'
         | 
| 82 | 
            -
                    puts
         | 
| 83 | 
            -
             | 
| 84 | 
            -
                    return if pretend?
         | 
| 85 | 
            -
             | 
| 86 | 
            -
                    Models::Configuration.new.tap do |configuration|
         | 
| 87 | 
            -
                      configuration.version = Dsu::Migration::VERSION
         | 
| 88 | 
            -
                      configuration.write!
         | 
| 89 | 
            -
                    end
         | 
| 90 | 
            -
                  end
         | 
| 91 | 
            -
             | 
| 92 | 
            -
                  def update_entry_groups
         | 
| 93 | 
            -
                    puts 'Updating entry groups...'
         | 
| 94 | 
            -
                    puts
         | 
| 95 | 
            -
             | 
| 96 | 
            -
                    return if pretend? || Dir.exist?(entries_folder)
         | 
| 97 | 
            -
             | 
| 98 | 
            -
                    puts 'Copying entries to default project...'
         | 
| 99 | 
            -
                    puts
         | 
| 100 | 
            -
             | 
| 101 | 
            -
                    FileUtils.mkdir_p(entries_folder)
         | 
| 102 | 
            -
                    FileUtils.cp_r(File.join(backup_folder, 'entries', '.'), entries_folder)
         | 
| 103 | 
            -
             | 
| 104 | 
            -
                    puts 'Updating entry group version...'
         | 
| 105 | 
            -
                    puts
         | 
| 106 | 
            -
             | 
| 107 | 
            -
                    Models::EntryGroup.all.each do |entry_group|
         | 
| 108 | 
            -
                      puts "Updating entry group version: #{entry_group.time_yyyy_mm_dd}..."
         | 
| 109 | 
            -
                      entry_group.version = Dsu::Migration::VERSION
         | 
| 110 | 
            -
                      entry_group.save! unless pretend?
         | 
| 111 | 
            -
                    end
         | 
| 112 | 
            -
                  end
         | 
| 113 | 
            -
             | 
| 114 | 
            -
                  def update_color_themes
         | 
| 115 | 
            -
                    puts 'Updating color themes...'
         | 
| 116 | 
            -
                    puts
         | 
| 117 | 
            -
             | 
| 118 | 
            -
                    puts 'Copying color themes...'
         | 
| 119 | 
            -
                    puts
         | 
| 120 | 
            -
             | 
| 121 | 
            -
                    unless pretend?
         | 
| 122 | 
            -
                      FileUtils.mkdir_p(themes_folder)
         | 
| 123 | 
            -
                      FileUtils.cp_r(File.join(backup_folder, 'themes', '.'), themes_folder)
         | 
| 124 | 
            -
                    end
         | 
| 125 | 
            -
             | 
| 126 | 
            -
                    puts 'Updating color theme version...'
         | 
| 127 | 
            -
                    puts
         | 
| 128 | 
            -
             | 
| 129 | 
            -
                    Models::ColorTheme.all.each do |color_theme|
         | 
| 130 | 
            -
                      puts "Updating color theme version: #{color_theme.theme_name}..."
         | 
| 131 | 
            -
                      color_theme.update_version!
         | 
| 132 | 
            -
                      color_theme.save! unless pretend?
         | 
| 133 | 
            -
                    end
         | 
| 134 | 
            -
                  end
         | 
| 135 | 
            -
             | 
| 136 | 
            -
                  def update_migration_version
         | 
| 137 | 
            -
                    puts 'Updating migration version...'
         | 
| 138 | 
            -
                    puts
         | 
| 139 | 
            -
             | 
| 140 | 
            -
                    return if pretend? || migration_version == Migration::VERSION
         | 
| 141 | 
            -
             | 
| 142 | 
            -
                    Models::MigrationVersion.new(version: Migration::VERSION).save!
         | 
| 143 | 
            -
                  end
         | 
| 144 | 
            -
             | 
| 145 | 
            -
                  def delete_old_entry_folder
         | 
| 146 | 
            -
                    puts 'Cleaning up old entries...'
         | 
| 147 | 
            -
                    puts
         | 
| 148 | 
            -
             | 
| 149 | 
            -
                    FileUtils.rm_rf(File.join(dsu_folder, 'entries')) unless pretend?
         | 
| 150 | 
            -
                  end
         | 
| 151 | 
            -
             | 
| 152 | 
            -
                  def backup_folder
         | 
| 153 | 
            -
                    @backup_folder ||= File.join(root_folder, "dsu-#{target_migration_version}-backup")
         | 
| 154 | 
            -
                  end
         | 
| 155 | 
            -
             | 
| 156 | 
            -
                  def target_migration_version
         | 
| 157 | 
            -
                    20230613121411 # rubocop:disable Style/NumericLiterals
         | 
| 158 | 
            -
                  end
         | 
| 159 | 
            -
             | 
| 160 | 
            -
                  def raise_wrong_migration_version_error_if!
         | 
| 161 | 
            -
                    return if migration_version == target_migration_version
         | 
| 162 | 
            -
             | 
| 163 | 
            -
                    raise "Actual migration version #{migration_version} " \
         | 
| 164 | 
            -
                          "is not the expected migration version #{target_migration_version}."
         | 
| 165 | 
            -
                  end
         | 
| 166 | 
            -
             | 
| 167 | 
            -
                  def migration_version
         | 
| 168 | 
            -
                    @migration_version ||= Models::MigrationVersion.new.version
         | 
| 169 | 
            -
                  end
         | 
| 170 | 
            -
                end
         | 
| 171 | 
            -
              end
         | 
| 172 | 
            -
            end
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         |