Class: Extension::ExtensionProject
- Inherits:
-
ShopifyCLI::Project
- Object
- ShopifyCLI::Project
- Extension::ExtensionProject
- Defined in:
- lib/project_types/extension/extension_project.rb
Class Method Summary collapse
- .generate_temporary_uuid ⇒ Object
- .reload ⇒ Object
- .update_env_file(context:, **updates) ⇒ Object
- .write_cli_file(context:, type:) ⇒ Object
- .write_env_file(context:, title:, api_key: "", api_secret: "", registration_id: nil, registration_uuid: nil, resource_url: nil, shop: nil) ⇒ Object
Instance Method Summary collapse
- #app ⇒ Object
- #registered? ⇒ Boolean
- #registration_id ⇒ Object
- #registration_id? ⇒ Boolean
- #registration_uuid ⇒ Object
- #reload ⇒ Object
- #resource_url ⇒ Object
- #specification_identifier ⇒ Object
- #title ⇒ Object
Methods inherited from ShopifyCLI::Project
at, clear, #config, current, current_project_type, #env, has_current?, project_name, write
Class Method Details
.generate_temporary_uuid ⇒ Object
117 118 119 |
# File 'lib/project_types/extension/extension_project.rb', line 117 def self.generate_temporary_uuid "dev-#{SecureRandom.uuid}" end |
.reload ⇒ Object
61 62 63 |
# File 'lib/project_types/extension/extension_project.rb', line 61 def reload current.reload unless project_empty? end |
.update_env_file(context:, **updates) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/project_types/extension/extension_project.rb', line 18 def update_env_file(context:, **updates) current_config = { title: current.title, shop: current.env.shop, api_key: current.app.api_key, api_secret: current.app.secret, registration_id: current.registration_id, registration_uuid: current.registration_uuid, resource_url: current.resource_url, } write_env_file( context: context, **current_config, **updates ) end |
.write_cli_file(context:, type:) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/project_types/extension/extension_project.rb', line 9 def write_cli_file(context:, type:) ShopifyCLI::Project.write( context, project_type: :extension, organization_id: nil, "#{ExtensionProjectKeys::SPECIFICATION_IDENTIFIER_KEY}": type ) end |
.write_env_file(context:, title:, api_key: "", api_secret: "", registration_id: nil, registration_uuid: nil, resource_url: nil, shop: nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/project_types/extension/extension_project.rb', line 36 def write_env_file( context:, title:, api_key: "", api_secret: "", registration_id: nil, registration_uuid: nil, resource_url: nil, shop: nil ) ShopifyCLI::Resources::EnvFile.new( api_key: api_key, secret: api_secret, shop: shop, extra: { ExtensionProjectKeys::TITLE_KEY => title, ExtensionProjectKeys::REGISTRATION_ID_KEY => registration_id, ExtensionProjectKeys::REGISTRATION_UUID_KEY => registration_uuid || generate_temporary_uuid, ExtensionProjectKeys::RESOURCE_URL_KEY => resource_url, }.compact ).write(context) reload end |
Instance Method Details
#app ⇒ Object
72 73 74 75 |
# File 'lib/project_types/extension/extension_project.rb', line 72 def app validate_env_present Models::App.new(api_key: env["api_key"], secret: env["secret"]) end |
#registered? ⇒ Boolean
77 78 79 |
# File 'lib/project_types/extension/extension_project.rb', line 77 def registered? registration_id? end |
#registration_id ⇒ Object
101 102 103 |
# File 'lib/project_types/extension/extension_project.rb', line 101 def registration_id get_extra_field(ExtensionProjectKeys::REGISTRATION_ID_KEY).to_i end |
#registration_id? ⇒ Boolean
95 96 97 98 99 |
# File 'lib/project_types/extension/extension_project.rb', line 95 def registration_id? extra_property_present?(ExtensionProjectKeys::REGISTRATION_ID_KEY) && integer?(get_extra_field(ExtensionProjectKeys::REGISTRATION_ID_KEY)) && registration_id > 0 end |
#registration_uuid ⇒ Object
105 106 107 |
# File 'lib/project_types/extension/extension_project.rb', line 105 def registration_uuid get_extra_field(ExtensionProjectKeys::REGISTRATION_UUID_KEY) end |
#reload ⇒ Object
113 114 115 |
# File 'lib/project_types/extension/extension_project.rb', line 113 def reload @env = nil end |
#resource_url ⇒ Object
109 110 111 |
# File 'lib/project_types/extension/extension_project.rb', line 109 def resource_url get_extra_field(ExtensionProjectKeys::RESOURCE_URL_KEY) end |
#specification_identifier ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'lib/project_types/extension/extension_project.rb', line 85 def specification_identifier key = ExtensionProjectKeys::SPECIFICATION_IDENTIFIER_KEY if ShopifyCLI::Environment.run_as_subprocess? get_extra_field(key) else config[key] end end |
#title ⇒ Object
81 82 83 |
# File 'lib/project_types/extension/extension_project.rb', line 81 def title get_extra_field(ExtensionProjectKeys::TITLE_KEY) end |