From 8ff57b3180215c086a9acdb75ff7a8aa378e575d Mon Sep 17 00:00:00 2001 From: gangelo Date: Sun, 8 Sep 2024 16:47:37 -0400 Subject: [PATCH] Update ruby gems and bug fix --- CHANGELOG.md | 8 + Gemfile.lock | 43 ++-- lib/dsu/migration/base_service.rb | 13 +- lib/dsu/migration/v20240210161248/service.rb | 7 +- lib/dsu/version.rb | 2 +- ...e_to_version_two_dot_zero_dot_zero_spec.rb | 243 ------------------ 6 files changed, 46 insertions(+), 270 deletions(-) delete mode 100644 spec/migrate/upgrade_to_version_two_dot_zero_dot_zero_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d519471..c84f919c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. +## [3.0.4] - 2024-09-08 + +### Changes +[x] Update ruby gems. + +### Bug Fixes +[x] Fix bug that fails to install dsu for first time users. + ## [3.0.3] - 2024-08-03 ### Changes diff --git a/Gemfile.lock b/Gemfile.lock index ab962164..14be81e5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - dsu (3.0.3) + dsu (3.0.4) activemodel (>= 7.0.8, < 8.0) activesupport (>= 7.0.8, < 8.0) colorize (>= 1.1, < 2.0) @@ -13,9 +13,9 @@ PATH GEM remote: https://rubygems.org/ specs: - activemodel (7.1.3.4) - activesupport (= 7.1.3.4) - activesupport (7.1.3.4) + activemodel (7.1.4) + activesupport (= 7.1.4) + activesupport (7.1.4) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -31,7 +31,7 @@ GEM byebug (11.1.3) coderay (1.1.3) colorize (1.1.0) - concurrent-ruby (1.3.3) + concurrent-ruby (1.3.4) connection_pool (2.4.1) diff-lcs (1.5.1) docile (1.4.1) @@ -64,7 +64,7 @@ GEM dry-inflector (~> 1.0) dry-logic (~> 1.4) zeitwerk (~> 2.6) - factory_bot (6.4.6) + factory_bot (6.5.0) activesupport (>= 5.0.0) ffaker (2.23.0) i18n (1.14.5) @@ -72,11 +72,11 @@ GEM json (2.7.2) language_server-protocol (3.17.0.3) method_source (1.1.0) - minitest (5.24.1) + minitest (5.25.1) mutex_m (0.2.0) os (1.1.4) - parallel (1.25.1) - parser (3.3.4.0) + parallel (1.26.3) + parser (3.3.5.0) ast (~> 2.4.1) racc pry (0.14.2) @@ -94,33 +94,31 @@ GEM rainbow (>= 2.0, < 4.0) rexml (~> 3.1) regexp_parser (2.9.2) - rexml (3.3.4) - strscan + rexml (3.3.7) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) + rspec-core (3.13.1) rspec-support (~> 3.13.0) - rspec-expectations (3.13.1) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.1) - rubocop (1.65.1) + rubocop (1.66.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.4, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.31.1, < 2.0) + rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.3) + rubocop-ast (1.32.3) parser (>= 3.3.1.0) rubocop-factory_bot (2.26.1) rubocop (~> 1.61) @@ -129,24 +127,23 @@ GEM rubocop-ast (>= 1.31.1, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (3.0.3) + rubocop-rspec (3.0.5) rubocop (~> 1.61) ruby-progressbar (1.13.0) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) + simplecov-html (0.13.0) simplecov_json_formatter (0.1.4) - strscan (3.1.0) - thor (1.3.1) + thor (1.3.2) thor_nested_subcommand (1.0.9) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - tzinfo-data (1.2024.1) + tzinfo-data (1.2024.2) tzinfo (>= 1.0.0) unicode-display_width (2.5.0) - zeitwerk (2.6.17) + zeitwerk (2.6.18) PLATFORMS arm64-darwin-22 diff --git a/lib/dsu/migration/base_service.rb b/lib/dsu/migration/base_service.rb index b9828b08..738e535d 100644 --- a/lib/dsu/migration/base_service.rb +++ b/lib/dsu/migration/base_service.rb @@ -82,8 +82,17 @@ def create_backup return puts "\tSkipping: backup already exists." if backup_exist? - FileUtils.cp_r(dsu_folder, backup_folder) - FileUtils.cp(config_path, backup_folder) + if Dir.exist?(dsu_folder) + FileUtils.cp_r(dsu_folder, backup_folder) + else + puts "\tSkipping: dsu folder \"#{dsu_folder}\" does not exists." + end + + if File.exist?(config_path) + FileUtils.cp(config_path, backup_folder) + else + puts "\tSkipping: config path \"#{config_path}\" does not exists." + end end def backup_exist? diff --git a/lib/dsu/migration/v20240210161248/service.rb b/lib/dsu/migration/v20240210161248/service.rb index 96565816..76766a9a 100644 --- a/lib/dsu/migration/v20240210161248/service.rb +++ b/lib/dsu/migration/v20240210161248/service.rb @@ -106,7 +106,12 @@ def update_entry_groups puts "\tCopying entries to default project \"#{default_project_name}\"..." entries_folder_to = File.join(dsu_folder, 'projects', default_project_name, 'entries') - FileUtils.cp_r(File.join(entries_folder_from, '.'), entries_folder_to) + if Dir.exist?(entries_folder_from) + FileUtils.cp_r(File.join(entries_folder_from, '.'), entries_folder_to) + else + puts "\tSkipping: entries folder \"#{entries_folder_from}\" does not exists." + FileUtils.mkdir_p(entries_folder_to) + end puts "\tUpdating entry group version..." diff --git a/lib/dsu/version.rb b/lib/dsu/version.rb index e7202efc..e13bfacc 100644 --- a/lib/dsu/version.rb +++ b/lib/dsu/version.rb @@ -2,5 +2,5 @@ module Dsu VERSION_REGEX = /\A\d+\.\d+\.\d+(\.(alpha|beta|rc)\.\d+)?\z/ - VERSION = '3.0.3' + VERSION = '3.0.4' end diff --git a/spec/migrate/upgrade_to_version_two_dot_zero_dot_zero_spec.rb b/spec/migrate/upgrade_to_version_two_dot_zero_dot_zero_spec.rb deleted file mode 100644 index ad0289a3..00000000 --- a/spec/migrate/upgrade_to_version_two_dot_zero_dot_zero_spec.rb +++ /dev/null @@ -1,243 +0,0 @@ -# frozen_string_literal: true - -# All this preprocessing does is make the old entries folder "unsafe" to manipulate -# by moving the entry group files to the '/tmp/dsu/entries' folder. The configuration -# file is also updated to point to the 'unsafe' entries folder so that the migration -# process knows where to find the entry group files. -def setup_unsafe_entries_folder(unsafe_entries_folder:) - config_path = Dsu::Support::Fileable.config_path - config_hash = read_configuration_version0!(config_path: config_path) - entries_folder = unsafe_entries_folder - FileUtils.mkdir_p(entries_folder) - config_hash[:entries_folder] = entries_folder - update_configuration_version0!(config_hash: config_hash, config_path: config_path) - from_folder = Dsu::Support::Fileable.entries_folder - move_entry_group_files(from_folder: from_folder, to_folder: entries_folder) -end - -def move_entry_group_files(from_folder:, to_folder:) - if File.basename(from_folder) == File.basename(to_folder) - FileUtils.mv(Dir.glob("#{from_folder}/*"), to_folder) - else - FileUtils.mv(from_folder, to_folder) - end - config_path = Dsu::Support::Fileable.config_path - config_hash = { entries_folder: File.join(destination_folder, File.basename(to_folder)) } - update_configuration_version0!(config_hash: config_hash, config_path: config_path) -end - -def rename_entry_group_files(entries_folder:, file_strftime: '%m-%d-%Y.json') - puts "Renaming entry group files using format \"#{file_strftime}\"..." - Dir.glob("#{entries_folder}/*").each do |file_path| - time = Time.parse(File.basename(file_path, '.*')) - new_file_path = File.join(entries_folder, time.strftime(file_strftime)) - puts "From: #{file_path}" \ - "\n to: #{new_file_path}" - FileUtils.mv(file_path, new_file_path) - - # We have to update the configuration to recognize the entries folder and new - # file name format. - config_path = Dsu::Support::Fileable.config_path - config_hash = { - entries_file_name: file_strftime, - entries_folder: File.dirname(new_file_path) - } - update_configuration_version0!(config_hash: config_hash, config_path: config_path) - end -end - -# RSpec.describe Dsu::Migrate::UpgradeToVersionTwoDotZeroDotZero do -# subject(:migration) { described_class.new } - -# include_context 'with migrations' - -# let(:version) { 20230613121411 } - -# shared_examples 'the migration version file is updated to the latest migration version' do -# it 'updates the migration file version' do -# subject.call -# expect(migration.current_migration_version).to eq(end_migration_version) -# end -# end - -# shared_examples 'the color theme files are created' do -# it 'creates the default color theme files' do -# subject.call -# expected_color_theme_names = %w[default cherry cloudy fozzy lemon matrix] -# expect(Dsu::Models::ColorTheme.all.map(&:theme_name)).to match_array expected_color_theme_names -# end -# end - -# shared_examples 'the entry group files exist in the right folder' do -# it 'creates the expected entry group files' do -# subject.call -# expected_entry_group_times = %w[2023-06-15 2023-06-16 2023-06-17] -# expect(Dsu::Models::EntryGroup.all&.map(&:time_yyyy_mm_dd)).to match_array(expected_entry_group_times) -# end -# end - -# shared_examples 'the old entry group files are renamed and exist in the right folder' do -# it 'renames the old entry group files' do -# subject.call -# expected_entry_group_times = %w[06-15-2023.json.old 06-16-2023.json.old 06-17-2023.json.old] -# expect(expected_entry_group_times.all? do |old_file| -# File.exist?(File.join(Dsu::Support::Fileable.entries_folder, old_file)) -# end).to be true -# end -# end - -# shared_examples 'no entry group files are created' do -# it 'does not create any entry group files' do -# subject.call -# expect(Dsu::Models::EntryGroup.any?).to be false -# end -# end - -# shared_examples 'the entry group files are updated' do -# it 'updates the entry group files' do -# subject.call -# expected_entry_group_times.each do |time| -# entry_group_time = Time.parse(time) -# entry_group = Dsu::Models::EntryGroup.find(time: entry_group_time) -# expect(entry_group.version).to eq end_migration_version -# expect(entry_group.time_equal?(other_time: entry_group_time)).to be true -# expect(entry_group.entries.count).to eq 2 -# formatted_entry_group_time = entry_group_time.strftime(Dsu::Support::TimeComparable::TIME_COMPARABLE_FORMAT_SPECIFIER) -# expect(entry_group.entries[0].description).to eq "#{formatted_entry_group_time} description 0" -# expect(entry_group.entries[1].description).to eq "#{formatted_entry_group_time} description 1" -# end -# end -# end - -# describe '#call' do -# let(:start_migration_version) { 0 } -# let(:end_migration_version) { 20230613121411 } - -# context 'when the configuration file does not exist' do -# before do -# File.delete(Dsu::Support::Fileable.config_path) -# end - -# it_behaves_like 'the color theme files are created' -# it_behaves_like 'the migration version file is updated to the latest migration version' - -# it 'creates a default configuration file' do -# migration.call -# expect(Dsu::Models::Configuration.exist?).to be(true) -# end -# end - -# context 'when the configuration file exists' do -# before do -# File.write(Dsu::Support::Fileable.config_path, ConfigurationHelpers::CONFIGURATION_HASHES[start_migration_version.to_s].to_yaml) -# end - -# let(:configuration) { Dsu::Models::Versions::Configuration[version].read } - -# it_behaves_like 'the color theme files are created' -# it_behaves_like 'the migration version file is updated to the latest migration version' - -# it 'creates the configuration file and carries over the values from the old configuration file' do -# migration.call -# expect(configuration[:version]).to eq(end_migration_version) -# expect(configuration[:editor]).to eq('vim') -# expect(configuration[:entries_display_order]).to eq('asc') -# expect(configuration[:carry_over_entries_to_today]).to be(true) -# expect(configuration[:include_all]).to be(true) -# expect(configuration[:theme_name]).to eq('default') -# end -# end - -# context 'when the migration version file does not exist' do -# let(:with_migration_version_file) { false } -# let(:expected_entry_group_times) { %w[2023-06-15 2023-06-16 2023-06-17] } - -# it_behaves_like 'the color theme files are created' -# it_behaves_like 'the entry group files exist in the right folder' -# it_behaves_like 'the entry group files are updated' -# it_behaves_like 'the migration version file is updated to the latest migration version' -# end - -# context 'when the migration version file exists' do -# context 'when the migration version file version is greater than the migration version' do -# subject(:migration) { described_class.new.call } - -# let(:migration_version_file_version) { end_migration_version } -# let(:expected_error) { /is not < the current migration version/ } - -# it_behaves_like 'an error is raised' -# end - -# context 'when the migration version file version is less than the migration version' do -# subject(:migration) { described_class.new.call } - -# let(:migration_version_file_version) { 0 } - -# it_behaves_like 'no error is raised' -# end -# end - -# context 'when there are entry group files' do -# let(:expected_entry_group_times) { %w[2023-06-15 2023-06-16 2023-06-17] } - -# context 'when the entry group files need to be moved to the new entries folder' do -# context 'when the old entries folder is not "safe" to manipulate' do -# before do -# setup_unsafe_entries_folder(unsafe_entries_folder: unsafe_entries_folder) -# end - -# let(:destination_folder) { '/tmp/dsu' } -# let(:unsafe_entries_folder) { File.join(destination_folder, 'entries') } -# let(:expected_console_output) do -# /.*Old entries folder "#{unsafe_entries_folder}".*This folder along with its old entry files may be deleted at your discretion.*/m -# end - -# it 'displays a message to the user that the old entries folder and entry files are safe to delete' do -# expect { migration.call }.to output(expected_console_output).to_stdout -# end - -# it_behaves_like 'the entry group files exist in the right folder' -# it_behaves_like 'the entry group files are updated' -# it_behaves_like 'the migration version file is updated to the latest migration version' -# end - -# context 'when the old entries folder is "safe" to manipulate' do -# before do -# from_folder = File.join(destination_folder, 'entries') -# to_folder = File.join(destination_folder, 'old_entries') -# move_entry_group_files(from_folder: from_folder, to_folder: to_folder) -# end - -# it_behaves_like 'the entry group files exist in the right folder' -# it_behaves_like 'the entry group files are updated' -# it_behaves_like 'the migration version file is updated to the latest migration version' -# end -# end - -# context 'when the entry group files DO NOT need to be moved to the new entries folder' do -# it_behaves_like 'the entry group files exist in the right folder' -# it_behaves_like 'the entry group files are updated' -# it_behaves_like 'the migration version file is updated to the latest migration version' -# end - -# context 'when the entry group files need to be renamed' do -# before do -# entries_folder = File.join(destination_folder, File.basename(Dsu::Support::Fileable.entries_folder)) -# rename_entry_group_files(entries_folder: entries_folder) -# end - -# it_behaves_like 'the entry group files exist in the right folder' -# it_behaves_like 'the old entry group files are renamed and exist in the right folder' -# it_behaves_like 'the entry group files are updated' -# it_behaves_like 'the migration version file is updated to the latest migration version' -# end -# end - -# context 'when there are no entry group files' do -# let(:with_entries) { false } - -# it_behaves_like 'no entry group files are created' -# it_behaves_like 'the migration version file is updated to the latest migration version' -# end -# end -# end