lib/tasks/appbox.rake in dtc_rake-0.2.0 vs lib/tasks/appbox.rake in dtc_rake-1.0.0.pre.beta.1

- old
+ new

@@ -3,10 +3,12 @@ require "dtc_rake/config" require "dtc_rake/product" require "dtc_rake/ui" require "uu/os/security/session" +require "uu/os/uesuri" +require "uu/os/search" require "uu/os/artifact" require "uu/os/sheet" require "uu/os/rest/binary_value" include DtcRake::UI @@ -22,11 +24,11 @@ def create_appbox(attrs) config = DtcRake::Config.instance product = DtcRake::Product.instance credentials = attrs[:credentials] - version = attrs.fetch(:version, product.version) + version = attrs.fetch(:version, config.appbox_version) icon = attrs.fetch(:icon, %q(ues:#{system}:#{ues_v5.core_v1.codetable_v1.base_v1.CodeTable_Icons}:#{ART_364})) error("Specify appbox location code - set it in DtcRake.configure block (attribute appbox_location_code) in your Rakefile") unless config.appbox_location_code error("Specify appbox meta artifact code - set it in DtcRake.configure block (attribute appbox_meta_artifact_code) in your Rakefile") unless config.appbox_meta_artifact_code @@ -35,12 +37,19 @@ error("Specify login credentials") unless credentials UU::OS::Security::Session.login(credentials) config = DtcRake::Config.instance - art_name = "#{product.app_descriptor[:data][:name]} #{version}" - art_code = config.appbox_artifact_code || "#{product.app_descriptor[:data][:code]}_#{version}" + art_name = "#{config.product_name} #{version} AppBox" + art_code = config.appbox_artifact_code + + art_uri = UU::OS::UESURI.create(territory_code: config.appbox_territory_code, artifact_code: art_code) + if UU::OS::Search.exists(art_uri) + info "Appbox #{art_uri} already exists" + return + end + announce "Creating appbox #{art_code} in territory #{config.appbox_territory_code}" appbox_uri = UU::OS::Artifact.create(location, name: art_name, code: art_code, @@ -84,7 +93,7 @@ error("Specify password file in env variable DTC_RAKE_PASSWD, e.g. rake appbox DTC_RAKE_PASSWD=12-345-6") unless ENV["DTC_RAKE_PASSWD"] art_uri = create_appbox( credentials: ENV["DTC_RAKE_PASSWD"], version: ENV["VERSION"] || DtcRake::Product.instance.version ) - success "Appbox #{art_uri} created" + success "Appbox #{art_uri} created" unless art_uri.nil? end