Class: ShopifyCLI::Theme::DevelopmentTheme
- Inherits:
-
Theme
- Object
- Root
- Theme
- ShopifyCLI::Theme::DevelopmentTheme
show all
- Defined in:
- lib/shopify_cli/theme/development_theme.rb
Instance Attribute Summary
Attributes inherited from Theme
#root
Attributes inherited from Root
#ctx, #root
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Theme
all, #create, create_unpublished, #created_at_runtime?, #current_development?, #development?, #editor_url, find_by_identifier, #foreign_development?, #initialize, live, #live?, #preview_url, #publish, #shop, #theme_file?, #theme_files, #to_h
Methods inherited from Root
#[], #file?, #glob, #initialize, #json_files, #liquid_files, #static_asset_file?, #static_asset_files, #static_asset_paths
Class Method Details
.delete(ctx) ⇒ Object
61
62
63
|
# File 'lib/shopify_cli/theme/development_theme.rb', line 61
def self.delete(ctx)
new(ctx).delete
end
|
.find(ctx, root: nil) ⇒ Object
65
66
67
68
|
# File 'lib/shopify_cli/theme/development_theme.rb', line 65
def self.find(ctx, root: nil)
dev_theme = new(ctx, root: root)
dev_theme.exists? ? dev_theme : nil
end
|
.find_or_create!(ctx, root: nil) ⇒ Object
70
71
72
|
# File 'lib/shopify_cli/theme/development_theme.rb', line 70
def self.find_or_create!(ctx, root: nil)
new(ctx, root: root).ensure_exists!
end
|
Instance Method Details
#ensure_exists! ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/shopify_cli/theme/development_theme.rb', line 33
def ensure_exists!
if exists?
@ctx.debug("Using temporary development theme: ##{id} #{name}")
else
create
@ctx.debug("Created temporary development theme: #{@id}")
ShopifyCLI::DB.set(development_theme_id: @id)
end
self
end
|
#exists? ⇒ Boolean
45
46
47
48
49
50
51
52
53
|
# File 'lib/shopify_cli/theme/development_theme.rb', line 45
def exists?
return false unless id
api_client.get(
path: "themes/#{id}.json"
)
rescue ShopifyCLI::API::APIRequestNotFoundError
false
end
|
#id ⇒ Object
12
13
14
|
# File 'lib/shopify_cli/theme/development_theme.rb', line 12
def id
ShopifyCLI::DB.get(:development_theme_id)
end
|
#name ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/shopify_cli/theme/development_theme.rb', line 16
def name
existing_name = ShopifyCLI::DB.get(:development_theme_name)
if existing_name.nil? || existing_name.length > API_NAME_LIMIT
generate_theme_name
else
existing_name
end
end
|
#role ⇒ Object
29
30
31
|
# File 'lib/shopify_cli/theme/development_theme.rb', line 29
def role
"development"
end
|