Skip to content

Commit

Permalink
Solara
Browse files Browse the repository at this point in the history
  • Loading branch information
IdeaS0ft committed Sep 10, 2024
1 parent 153e324 commit 1db6e8f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 3 deletions.
1 change: 1 addition & 0 deletions solara/lib/core/doctor/doctor_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def ensure_initialized!
brands = FilePath.brands
brands_list = FilePath.brands_list
platform = SolaraSettingsManager.instance.platform
puts "ensure_initialized! platform: #{platform}"
unless File.exist?(brands) && File.exist?(brands_list) && !platform.nil? && !platform.empty?
Solara.logger.error("Solara is not initialized here. Please run 'solara init' to initialize.")
exit 1
Expand Down
2 changes: 1 addition & 1 deletion solara/lib/core/doctor/schema/platform/ios/ios_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"description": "The marketing version of the product."
},
"BUNDLE_VERSION": {
"type": "string",
"type": "number",
"description": "The bundle version of the product."
}
},
Expand Down
4 changes: 4 additions & 0 deletions solara/lib/core/scripts/file_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ def self.solara_settings
File.join(dot_solara, 'solara_settings.json')
end

def self.solara_version
File.join(dot_solara, 'solara_version.json')
end

def self.solara_aliases_sh
File.join(ENV['HOME'], '.solara', 'aliases.sh')
end
Expand Down
42 changes: 42 additions & 0 deletions solara/lib/core/scripts/solara_version_manager.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'singleton'

require 'singleton'
require 'json'

class SolaraVersionManager
include Singleton

def sversion
json['solaraVersion']
end

def version=(value)
new_json = json
new_json['solaraVersion'] = value
save(new_json)
end

def value(key)
json[key]
end

def add(key, value)
new_json = json
new_json[key] = value
save(new_json)
end

private

def json
path = FilePath.solara_version
FileManager.create_file_if_not_exist(path)
JSON.parse(File.read(path))
rescue JSON::ParserError => e
{}
end

def save(json)
File.write(FilePath.solara_version, JSON.pretty_generate(json))
end
end
16 changes: 14 additions & 2 deletions solara/lib/solara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Dir['*.rb'].each { |file| require_relative file }
Dir.glob("#{__dir__}/core/scripts/*.rb").each { |file| require file }
require 'solara_manager'
require 'rubygems'

module Solara
ROOT = Pathname.new(File.expand_path('..', __FILE__))
Expand Down Expand Up @@ -35,8 +36,7 @@ class CLI < Thor

def initialize(*args)
super
Solara.logger.verbose = options[:verbose] || false
ensure_platform
setup
end

def self.exit_on_failure?
Expand Down Expand Up @@ -224,5 +224,17 @@ def validate_brand_name(brand_name)
end
brand_name
end


def setup
Solara.logger.verbose = options[:verbose] || false

ensure_platform

# Solara version is mandatory because the structure and logic may change in the future and need to migrate.
SolaraVersionManager.instance.version = Gem.loaded_specs['solara'].version.to_s
end

end

end

0 comments on commit 1db6e8f

Please sign in to comment.