Sha256: a7a1ef12c0b5b17c80cfad567134a5e68e61f1ca42c17b26d4383de7da703473
Contents?: true
Size: 1.98 KB
Versions: 20
Compression:
Stored size: 1.98 KB
Contents
# frozen_string_literal: true require 'shopify_cli' module Extension class ExtensionProject < ShopifyCli::Project class << self def write_cli_file(context:, type:) ShopifyCli::Project.write( context, project_type: :extension, organization_id: nil, "#{ExtensionProjectKeys::EXTENSION_TYPE_KEY}": type ) end def write_env_file(context:, title:, api_key: '', api_secret: '', registration_id: nil) ShopifyCli::Resources::EnvFile.new( api_key: api_key, secret: api_secret, extra: { ExtensionProjectKeys::TITLE_KEY => title, ExtensionProjectKeys::REGISTRATION_ID_KEY => registration_id, }.compact ).write(context) current.reload unless project_empty? end private def project_empty? directory(Dir.pwd).nil? end end def app Models::App.new(api_key: env['api_key'], secret: env['secret']) end def registered? property_present?('api_key') && property_present?('secret') && registration_id? end def title get_extra_field(ExtensionProjectKeys::TITLE_KEY) end def extension_type_identifier config[ExtensionProjectKeys::EXTENSION_TYPE_KEY] end def registration_id? extra_property_present?(ExtensionProjectKeys::REGISTRATION_ID_KEY) && integer?(get_extra_field(ExtensionProjectKeys::REGISTRATION_ID_KEY)) && registration_id > 0 end def registration_id get_extra_field(ExtensionProjectKeys::REGISTRATION_ID_KEY).to_i end def reload @env = nil end private def get_extra_field(key) extra = env[:extra] || {} extra[key] end def extra_property_present?(key) env[:extra].key?(key) && !get_extra_field(key).nil? end def property_present?(key) !env[key].nil? && !env[key].strip.empty? end def integer?(value) value.to_i.to_s == value.to_s end end end
Version data entries
20 entries across 20 versions & 1 rubygems