avo_upgrade 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/avo_upgrade/upgrade29to30.rb +20 -3
- data/lib/avo_upgrade/upgrade_tool.rb +52 -0
- data/lib/avo_upgrade/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b377cc79f062c3f76ce66868c226c3ff5edf958d541a92cc2a1eaac5dfb712b
|
4
|
+
data.tar.gz: d40703c343bf2fae90d0c77551c2d651e921a141f191e70b46f1a18ec5b52fae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7a7d66ae9641d85962aa9799471e8a73b622f1967dfdb2b173ad1d49415c22d079c009c1591676376dc632654b67d6642fea4d77fa7efd9c987a1b55be121e4
|
7
|
+
data.tar.gz: 97489621617368df35a57d370672075ae9dcf71667e9af212df61ec97bc6ca1f5434b3d9f9f27317ab81cbd20854be4008f14bc56c391c1dec1e9294d536a49b
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# AvoUpgrade
|
2
|
-
|
2
|
+
|
3
|
+
Tiny upgrade helper for https://github.com/avo-hq/avo
|
3
4
|
|
4
5
|
## Usage
|
5
|
-
|
6
|
+
For now, check out [this guide](https://docs.avohq.io/3.0/upgrade.html#use-the-automatic-upgrade-tool).
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
Add this line to your application's Gemfile:
|
@@ -5,7 +5,19 @@ module AvoUpgrade
|
|
5
5
|
replace_in_filename "_resource", "", path: resources_path
|
6
6
|
|
7
7
|
# Replace all "Avo::Dashboards::" with "AvoDashboards::" in all files
|
8
|
-
replace_text_on(avo_global_files, { "Avo::Dashboards::" => "
|
8
|
+
# replace_text_on(avo_global_files, { "Avo::Dashboards::" => "Avo::Dashboards::" }, exact_match: false)
|
9
|
+
|
10
|
+
replace_text_on(
|
11
|
+
avo_global_files,
|
12
|
+
{
|
13
|
+
"Avo::Dashboards::BaseCard" => "Avo::Cards::BaseCard",
|
14
|
+
"Avo::Dashboards::BaseDivider" => "Avo::Cards::BaseDivider",
|
15
|
+
"Avo::Dashboards::ChartkickCard" => "Avo::Cards::ChartkickCard",
|
16
|
+
"Avo::Dashboards::MetricCard" => "Avo::Cards::MetricCard",
|
17
|
+
"Avo::Dashboards::PartialCard" => "Avo::Cards::PartialCard",
|
18
|
+
},
|
19
|
+
exact_match: false
|
20
|
+
)
|
9
21
|
|
10
22
|
# Create a hash with old class names as keys and new class names as values
|
11
23
|
# Example: { "Avo::Resources::UserResource" => "Avo::Resources::User" }
|
@@ -41,9 +53,12 @@ module AvoUpgrade
|
|
41
53
|
"|model, resource|",
|
42
54
|
"|model, resource, view|",
|
43
55
|
"|model, resource, view, field|",
|
56
|
+
"(model:, resource:, view:, field:)",
|
44
57
|
"|model, &args|"
|
45
58
|
]
|
46
|
-
|
59
|
+
remove_block_arg_on(files_from(resources_path) + files_from(actions_path) + files_from(filters_path), remove_text)
|
60
|
+
|
61
|
+
remove_config("config.tabs_style")
|
47
62
|
|
48
63
|
print "\n\nUpgrade to Avo 3.0 completed! 🚀\n\n"
|
49
64
|
end
|
@@ -60,18 +75,20 @@ module AvoUpgrade
|
|
60
75
|
# Print a summary of the upgrade process
|
61
76
|
puts "\n\nSummary of changes:\n" +
|
62
77
|
"---------------------\n" +
|
63
|
-
"Renaming Avo::Dashboards:: to AvoDashboards::\n" +
|
78
|
+
# "Renaming Avo::Dashboards:: to AvoDashboards::\n" +
|
64
79
|
"Renaming resources naming from ClassNameResource to Avo::Resources::ClassName\n" +
|
65
80
|
"Renaming actions naming from ClassName to Avo::Actions::ClassName\n" +
|
66
81
|
"Renaming filters naming from ClassName to Avo::Filters::ClassName\n" +
|
67
82
|
"Renaming resource tools naming from ClassName to Avo::ResourceTools::ClassName\n" +
|
68
83
|
"Renaming dashboards naming from ClassName to Avo::Dashboards::ClassName\n" +
|
69
84
|
"Renaming cards naming from ClassName to Avo::Cards::ClassName\n" +
|
85
|
+
"Changing cards namespace from Dashboards to Cards\n" +
|
70
86
|
"Renaming 'resolve_query_scope' method in resource files to 'index_query'\n" +
|
71
87
|
"Removing unused arguments from blocks in resource, action and filter files\n" +
|
72
88
|
"Updating resource and action files to use 'record' instead of 'model'\n" +
|
73
89
|
"Updating resource files to use 'query' instead of 'model_class' and 'scope'\n" +
|
74
90
|
"Renaming resource files to remove the '_resource' suffix\n" +
|
91
|
+
"Removing the `config.tabs_style` from the avo initializer\n" +
|
75
92
|
"\n" +
|
76
93
|
" - There are 2 ways of renaming the resource files:\n" +
|
77
94
|
" 1. Using `git mv` command, that automaticly stage the changes and makes the commit review process easier.\n" +
|
@@ -66,6 +66,17 @@ module AvoUpgrade
|
|
66
66
|
replace_text_on(files, text_array.map { |text| [text, ""] }.to_h, exact_match: false)
|
67
67
|
end
|
68
68
|
|
69
|
+
def remove_block_arg_on(files, text_array)
|
70
|
+
match_array = text_array.map do |text|
|
71
|
+
if proc_arg?(text)
|
72
|
+
proc_arg_match_params(text)
|
73
|
+
else
|
74
|
+
lambda_arg_match_params(text)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
replace_text_on(files, match_array.to_h, exact_match: false)
|
78
|
+
end
|
79
|
+
|
69
80
|
def replace_in_filename(old_text, new_text, path:)
|
70
81
|
Dir.glob("#{path}/*.rb").each do |file_path|
|
71
82
|
`#{@mv_cmd == "1" ? "git mv" : "mv"} #{file_path} #{file_path.gsub(/#{old_text}/, new_text)}`
|
@@ -76,5 +87,46 @@ module AvoUpgrade
|
|
76
87
|
print "\nPress ENTER to continue."
|
77
88
|
gets.chomp
|
78
89
|
end
|
90
|
+
|
91
|
+
# Receives the code at the beginning of a line and deletes the line.
|
92
|
+
def remove_config(config)
|
93
|
+
avo_config_path = File.join Rails.root.join("config", "initializers", "avo.rb")
|
94
|
+
|
95
|
+
# Read the content of the file into an array of lines
|
96
|
+
lines = File.readlines(avo_config_path)
|
97
|
+
|
98
|
+
# Open the file for writing
|
99
|
+
File.open(avo_config_path, "w") do |file|
|
100
|
+
lines.each do |line|
|
101
|
+
# Check if the line starts with the given config code
|
102
|
+
if line.strip.start_with?(config)
|
103
|
+
# Do nothing, skip the line
|
104
|
+
else
|
105
|
+
# Write the line to the file
|
106
|
+
file.puts(line)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
private
|
113
|
+
|
114
|
+
def proc_arg?(text)
|
115
|
+
/\|/.match?(text)
|
116
|
+
end
|
117
|
+
|
118
|
+
def lambda_arg_match_params(proc_arg_text)
|
119
|
+
[
|
120
|
+
/->\s*#{Regexp.escape(proc_arg_text)}/,
|
121
|
+
'->'
|
122
|
+
]
|
123
|
+
end
|
124
|
+
|
125
|
+
def proc_arg_match_params(lambda_arg_text)
|
126
|
+
[
|
127
|
+
/\b#{Regexp.escape(lambda_arg_text)}\b/,
|
128
|
+
''
|
129
|
+
]
|
130
|
+
end
|
79
131
|
end
|
80
132
|
end
|
data/lib/avo_upgrade/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avo_upgrade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Marin
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -61,7 +61,7 @@ metadata:
|
|
61
61
|
homepage_uri: https://avohq.io
|
62
62
|
source_code_uri: https://github.com/avo-hq/avo_upgrade
|
63
63
|
changelog_uri: https://github.com/avo-hq/avo_upgrade
|
64
|
-
post_install_message:
|
64
|
+
post_install_message:
|
65
65
|
rdoc_options: []
|
66
66
|
require_paths:
|
67
67
|
- lib
|
@@ -76,8 +76,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
|
-
rubygems_version: 3.
|
80
|
-
signing_key:
|
79
|
+
rubygems_version: 3.3.3
|
80
|
+
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: The friendly upgrade helper for Avo.
|
83
83
|
test_files: []
|