Skip to content

Commit

Permalink
Add icon pack version into its own module
Browse files Browse the repository at this point in the history
  • Loading branch information
AliOsm committed Sep 25, 2024
1 parent 8bffc65 commit cf5192e
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 8 deletions.
8 changes: 7 additions & 1 deletion generators/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

REPO_URL = 'https://github.com/twbs/icons.git'
REPO_NAME = 'twbs-icons'
ICONS_PACK_MODULE_PATH = 'lib/phlex/icons/bootstrap.rb'
ICONS_PACK_PATH = 'lib/phlex/icons/bootstrap'

TEMPLATE = ERB.new <<~TEMPLATE
Expand Down Expand Up @@ -39,7 +40,12 @@ def view_template
}.freeze

def main
run_generator { icon_file_paths.tqdm.each { create_icon_component(_1) } }
run_generator do
new_version = JSON.parse(File.read("generators/#{REPO_NAME}/package.json"))['version']
update_icon_path_version(new_version)

icon_file_paths.tqdm.each { create_icon_component(_1) }
end
end

def icon_file_paths
Expand Down
8 changes: 7 additions & 1 deletion generators/flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

REPO_URL = 'https://github.com/lipis/flag-icons.git'
REPO_NAME = 'lipis-flag-icons'
ICONS_PACK_MODULE_PATH = 'lib/phlex/icons/flag.rb'
ICONS_PACK_PATH = 'lib/phlex/icons/flag'

TEMPLATE = ERB.new <<~TEMPLATE
Expand All @@ -29,7 +30,12 @@ def rectangle
TEMPLATE

def main
run_generator { icon_file_names.tqdm.each { create_icon_component(_1) } }
run_generator do
new_version = JSON.parse(File.read("generators/#{REPO_NAME}/package.json"))['version']
update_icon_path_version(new_version)

icon_file_names.tqdm.each { create_icon_component(_1) }
end
end

def icon_file_names
Expand Down
6 changes: 6 additions & 0 deletions generators/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def prepare_phlex_icons_pack_directory(icons_pack_path)
puts "\e[2K\r🎉 '#{icons_pack_path}' directory prepared successfully!"
end

def update_icon_path_version(new_version)
content = File.read(ICONS_PACK_MODULE_PATH)
updated_content = content.sub(/VERSION = '.*'/, "VERSION = '#{new_version}'")
File.write(ICONS_PACK_MODULE_PATH, updated_content)
end

def component_file_name(icon_file_name, replacements = nil)
replacements ||= {}

Expand Down
8 changes: 7 additions & 1 deletion generators/hero.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

REPO_URL = 'https://github.com/tailwindlabs/heroicons.git'
REPO_NAME = 'tailwindlabs-heroicons'
ICONS_PACK_MODULE_PATH = 'lib/phlex/icons/hero.rb'
ICONS_PACK_PATH = 'lib/phlex/icons/hero'

TEMPLATE = ERB.new <<~TEMPLATE
Expand All @@ -29,7 +30,12 @@ def outline
TEMPLATE

def main
run_generator { icon_file_names.tqdm.each { create_icon_component(_1) } }
run_generator do
new_version = JSON.parse(File.read("generators/#{REPO_NAME}/package.json"))['version']
update_icon_path_version(new_version)

icon_file_names.tqdm.each { create_icon_component(_1) }
end
end

def icon_file_names
Expand Down
11 changes: 10 additions & 1 deletion generators/lucide.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

REPO_URL = 'https://github.com/lucide-icons/lucide.git'
REPO_NAME = 'lucide-icons-lucide'
ICONS_PACK_MODULE_PATH = 'lib/phlex/icons/lucide.rb'
ICONS_PACK_PATH = 'lib/phlex/icons/lucide'

TEMPLATE = ERB.new <<~TEMPLATE
Expand All @@ -25,7 +26,15 @@ def view_template
TEMPLATE

def main
run_generator { icon_file_paths.tqdm.each { create_icon_component(_1) } }
run_generator do
cd_command = "cd generators/#{REPO_NAME}"
safe_directory_command = "git config --global --add safe.directory '*'"
get_latest_tag_command = 'git describe --tags --abbrev=0'
new_version = `#{cd_command} && #{safe_directory_command} && #{get_latest_tag_command}`.strip
update_icon_path_version(new_version)

icon_file_paths.tqdm.each { create_icon_component(_1) }
end
end

def icon_file_paths
Expand Down
10 changes: 8 additions & 2 deletions generators/radix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

require_relative 'helper'

REPO_URL = 'https://github.com/radix-ui/icons'
REPO_URL = 'https://github.com/radix-ui/icons.git'
REPO_NAME = 'radix-ui-icons'
ICONS_PACK_MODULE_PATH = 'lib/phlex/icons/radix.rb'
ICONS_PACK_PATH = 'lib/phlex/icons/radix'

TEMPLATE = ERB.new <<~TEMPLATE
Expand All @@ -25,7 +26,12 @@ def view_template
TEMPLATE

def main
run_generator { icon_file_paths.tqdm.each { create_icon_component(_1) } }
run_generator do
new_version = JSON.parse(File.read("generators/#{REPO_NAME}/packages/radix-icons/package.json"))['version']
update_icon_path_version(new_version)

icon_file_paths.tqdm.each { create_icon_component(_1) }
end
end

def icon_file_paths
Expand Down
8 changes: 7 additions & 1 deletion generators/remix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

REPO_URL = 'https://github.com/Remix-Design/RemixIcon.git'
REPO_NAME = 'remix-design-remixicon'
ICONS_PACK_MODULE_PATH = 'lib/phlex/icons/remix.rb'
ICONS_PACK_PATH = 'lib/phlex/icons/remix'

TEMPLATE = ERB.new <<~TEMPLATE
Expand All @@ -30,7 +31,12 @@ def view_template
}.freeze

def main
run_generator { icon_file_paths.tqdm.each { create_icon_component(_1) } }
run_generator do
new_version = JSON.parse(File.read("generators/#{REPO_NAME}/package.json"))['version']
update_icon_path_version(new_version)

icon_file_paths.tqdm.each { create_icon_component(_1) }
end
end

def icon_file_paths
Expand Down
8 changes: 7 additions & 1 deletion generators/tabler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

REPO_URL = 'https://github.com/tabler/tabler-icons.git'
REPO_NAME = 'tabler-tabler-icons'
ICONS_PACK_MODULE_PATH = 'lib/phlex/icons/tabler.rb'
ICONS_PACK_PATH = 'lib/phlex/icons/tabler'

TEMPLATE = ERB.new <<~TEMPLATE
Expand All @@ -29,7 +30,12 @@ def outline
TEMPLATE

def main
run_generator { icon_file_names.tqdm.each { create_icon_component(_1) } }
run_generator do
new_version = JSON.parse(File.read("generators/#{REPO_NAME}/package.json"))['version']
update_icon_path_version(new_version)

icon_file_names.tqdm.each { create_icon_component(_1) }
end
end

def icon_file_names
Expand Down
2 changes: 2 additions & 0 deletions lib/phlex/icons/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Phlex
module Icons
module Bootstrap # rubocop:disable Metrics/ModuleLength
VERSION = '1.11.3'

extend Phlex::Kit

require_relative 'bootstrap/base'
Expand Down
2 changes: 2 additions & 0 deletions lib/phlex/icons/flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Phlex
module Icons
module Flag # rubocop:disable Metrics/ModuleLength
VERSION = '7.2.3'

extend Phlex::Kit

require_relative 'flag/base'
Expand Down
2 changes: 2 additions & 0 deletions lib/phlex/icons/hero.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Phlex
module Icons
module Hero # rubocop:disable Metrics/ModuleLength
VERSION = '2.1.5'

extend Phlex::Kit

require_relative 'hero/base'
Expand Down
2 changes: 2 additions & 0 deletions lib/phlex/icons/lucide.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Phlex
module Icons
module Lucide # rubocop:disable Metrics/ModuleLength
VERSION = '0.446.0'

extend Phlex::Kit

require_relative 'lucide/base'
Expand Down
2 changes: 2 additions & 0 deletions lib/phlex/icons/radix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Phlex
module Icons
module Radix # rubocop:disable Metrics/ModuleLength
VERSION = '1.3.0'

extend Phlex::Kit

require_relative 'radix/base'
Expand Down
2 changes: 2 additions & 0 deletions lib/phlex/icons/remix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Phlex
module Icons
module Remix # rubocop:disable Metrics/ModuleLength
VERSION = '4.3.0'

extend Phlex::Kit

require_relative 'remix/base'
Expand Down
2 changes: 2 additions & 0 deletions lib/phlex/icons/tabler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Phlex
module Icons
module Tabler # rubocop:disable Metrics/ModuleLength
VERSION = '3.17.0'

extend Phlex::Kit

require_relative 'tabler/base'
Expand Down

0 comments on commit cf5192e

Please sign in to comment.