shopify-cli 2.34.0 → 2.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd29ef210f31fc605f44e4ecc7402157b79ab92091aa247a2025576a87e7159b
4
- data.tar.gz: bf8c1081b70e4c97d5dabd6ed54818b5e6fada2787ebc51cb5406791af9e5982
3
+ metadata.gz: ade7adf91cbeb9a2dd8a02b15189641ccefc1b936f6a7f1621018c6bbd9b6197
4
+ data.tar.gz: 2a260ea255710a59c3062189561a367a6a97738c4c29d8d2df4aae75d9a28ad0
5
5
  SHA512:
6
- metadata.gz: e941e27b0d6a5faf0bf210f21cb0fd8d86bcc1bfc142e4e57ba44f6918fdc44664c6d82d32f605a3a1aa047119242014e1c4b324031212fdc849c7361c0e29fa
7
- data.tar.gz: '09b978061cecd114d072d17df1667601f0275fb6a28f42219a3ba359b44cde4c7becb63d65a6ec6e686eeeedbdf54f29ca911cfb7eaf3b19d116d3a816740f78'
6
+ metadata.gz: 8472b9e1cf6c57b9f469d75c1df4f8aaf4b6942746a6cb20b20b67853d8a7f64775f236074251fbb344d20e7befaee54334f85ad69f30fd1d381cebab2da7986
7
+ data.tar.gz: 29cb2ad9e92906a3e0cec7903d2ed1a072b81133a0a623492c9210a9795257648a768221c6955b3eaa302b949ee44ecf61a37b24cfaed165aae7b654a1625788
data/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## Version 2.36.0 - 2023-05-03
6
+
7
+ ### Fixed
8
+ * [#2735](https://github.com/Shopify/shopify-cli/pull/2735): Remove theme directory confirmation during tests and make confirmation dialogue respect `SHOPIFY_CLI_TTY` (from cli#1369)
9
+ * [#2737](https://github.com/Shopify/shopify-cli/pull/2737): Do not inject hot-reload code into web-pixels-manager sandbox (from cli#1568)
10
+
11
+ ### Added
12
+ * [#2735](https://github.com/Shopify/shopify-cli/pull/2735): Pass development theme from CLI 3’s to CLI 2’s local storage (from cli#1410)
13
+
14
+ ## Version 2.35.0 - 2023-02-22
15
+
16
+ ### Fixed
17
+ * [#2721](https://github.com/Shopify/shopify-cli/pull/2721): Do not `replace_asset_urls` in font bodies
18
+ * [#2729](https://github.com/Shopify/shopify-cli/pull/2729): Do not inject hot-reload code into web-pixels-manager sandbox (from cli#1370)
19
+ * [#2731](https://github.com/Shopify/shopify-cli/pull/2731): The CLI should not report IO messages when the `--json` flag is passed
20
+
21
+ ### Added
22
+ * [#2724](https://github.com/Shopify/shopify-cli/pull/2724): Introduce hidden `--overwrite-json` flag
23
+ * [#2729](https://github.com/Shopify/shopify-cli/pull/2729): Introduce hidden `--generate_tmp_theme` flag (from cli#1264)
24
+
5
25
  ## Version 2.34.0 - 2023-01-11
6
26
 
7
27
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify-cli (2.34.0)
4
+ shopify-cli (2.36.0)
5
5
  bugsnag (~> 6.22)
6
6
  listen (~> 3.7.0)
7
7
  theme-check (~> 1.14.0)
@@ -165,7 +165,7 @@ PLATFORMS
165
165
  ruby
166
166
 
167
167
  DEPENDENCIES
168
- bundler (~> 2.3.11)
168
+ bundler (>= 2.3.11)
169
169
  byebug
170
170
  colorize (~> 0.8.1)
171
171
  cucumber (~> 7.0)
@@ -19,7 +19,6 @@ module Extension
19
19
  class Command < ShopifyCLI::Command::ProjectCommand
20
20
  autoload :ExtensionCommand, Project.project_filepath("commands/extension_command")
21
21
 
22
- subcommand :Create, "create", Project.project_filepath("commands/create")
23
22
  subcommand :Register, "register", Project.project_filepath("commands/register")
24
23
  subcommand :Info, "info", Project.project_filepath("commands/info")
25
24
  subcommand :Connect, "connect", Project.project_filepath("commands/connect")
@@ -20,6 +20,9 @@ module Extension
20
20
  parser.on("-T", "--theme=NAME_OR_ID", "Theme ID or name of the theme app extension host theme.") do |theme|
21
21
  flags[:theme] = theme
22
22
  end
23
+ parser.on("--generate-tmp-theme", "Populate host theme, created by CLI 3, with assets") do |generate_tmp_theme|
24
+ flags[:generate_tmp_theme] = generate_tmp_theme
25
+ end
23
26
  parser.on("--api-key=API_KEY", "Connect your extension and app by inserting your app's API key") do |api_key|
24
27
  flags[:api_key] = api_key.gsub('"', "")
25
28
  end
@@ -45,6 +48,7 @@ module Extension
45
48
  property! :tunnel_requested, accepts: [true, false], reader: :tunnel_requested?, default: true
46
49
  property :port, accepts: (1...(2**16))
47
50
  property :theme, accepts: String, default: nil
51
+ property :generate_tmp_theme, accepts: [true, false], reader: :generate_tmp_theme?, default: false
48
52
  property :api_key, accepts: String, default: nil
49
53
  property :api_secret, accepts: String, default: nil
50
54
  property :registration_id, accepts: String, default: nil
@@ -60,6 +64,7 @@ module Extension
60
64
  resource_url: options.flags[:resource_url],
61
65
  port: options.flags[:port],
62
66
  theme: options.flags[:theme],
67
+ generate_tmp_theme: generate_tmp_theme?,
63
68
  api_key: options.flags[:api_key],
64
69
  api_secret: options.flags[:api_secret],
65
70
  registration_id: options.flags[:registration_id],
@@ -103,6 +108,10 @@ module Extension
103
108
  tunnel.nil? || !!tunnel
104
109
  end
105
110
 
111
+ def generate_tmp_theme?
112
+ options.flags[:generate_tmp_theme] == true
113
+ end
114
+
106
115
  def find_available_port(runtime_configuration)
107
116
  return runtime_configuration unless runtime_configuration.port.nil?
108
117
  return runtime_configuration unless specification_handler.choose_port?(@ctx)
@@ -137,6 +146,7 @@ module Extension
137
146
  tunnel_url: runtime_configuration.tunnel_url,
138
147
  port: runtime_configuration.port,
139
148
  theme: runtime_configuration.theme,
149
+ generate_tmp_theme: runtime_configuration.generate_tmp_theme?,
140
150
  api_key: runtime_configuration.api_key,
141
151
  api_secret: runtime_configuration.api_secret,
142
152
  registration_id: runtime_configuration.registration_id,
@@ -78,7 +78,7 @@ module Extension
78
78
  root = options[:context]&.root
79
79
  project = options[:project]
80
80
  properties = options
81
- .slice(:port, :theme)
81
+ .slice(:port, :theme, :generate_tmp_theme)
82
82
  .compact
83
83
  .merge({
84
84
  project: project,
@@ -49,13 +49,14 @@ module Theme
49
49
  private
50
50
 
51
51
  def current_directory_confirmed?
52
- raise "Current theme directory can't be confirmed during tests" if @ctx.testing?
52
+ return true if options.flags[:force]
53
53
 
54
+ @ctx.warn(@ctx.message("theme.current_directory_is_not_theme_directory"))
54
55
  Forms::ConfirmStore.ask(
55
56
  @ctx,
56
57
  [],
57
58
  title: @ctx.message("theme.confirm_current_directory"),
58
- force: options.flags[:force],
59
+ force: !ShopifyCLI::Environment.interactive?,
59
60
  ).confirmed?
60
61
  end
61
62
 
@@ -35,12 +35,18 @@ module Theme
35
35
  flags[:ignores] |= pattern
36
36
  end
37
37
  parser.on("-f", "--force") { flags[:force] = true }
38
+ parser.on("--development-theme-id=DEVELOPMENT_THEME_ID") do |development_theme_id|
39
+ flags[:development_theme_id] = development_theme_id.to_i
40
+ end
38
41
  end
39
42
 
40
43
  def call(_args, name)
41
44
  root = root_value(options, name)
42
45
  return if exist_and_not_empty?(root) && !valid_theme_directory?(root)
43
46
 
47
+ development_theme_id = options.flags[:development_theme_id]
48
+ ShopifyCLI::DB.set(development_theme_id: development_theme_id) unless development_theme_id.nil?
49
+
44
50
  delete = !options.flags[:nodelete]
45
51
  theme = find_theme(root, **options.flags)
46
52
  return if theme.nil?
@@ -40,12 +40,18 @@ module Theme
40
40
  flags[:ignores] |= pattern
41
41
  end
42
42
  parser.on("-f", "--force") { flags[:force] = true }
43
+ parser.on("--development-theme-id=DEVELOPMENT_THEME_ID") do |development_theme_id|
44
+ flags[:development_theme_id] = development_theme_id.to_i
45
+ end
43
46
  end
44
47
 
45
48
  def call(_args, name)
46
49
  root = root_value(options, name)
47
50
  return unless valid_theme_directory?(root)
48
51
 
52
+ development_theme_id = options.flags[:development_theme_id]
53
+ ShopifyCLI::DB.set(development_theme_id: development_theme_id) unless development_theme_id.nil?
54
+
49
55
  delete = !options.flags[:nodelete]
50
56
  theme = find_theme(root, **options.flags)
51
57
  return if theme.nil?
@@ -67,6 +73,7 @@ module Theme
67
73
  begin
68
74
  syncer.start_threads
69
75
  if options.flags[:json]
76
+ syncer.standard_reporter.disable!
70
77
  syncer.upload_theme!(delete: delete)
71
78
  else
72
79
  CLI::UI::Frame.open(@ctx.message("theme.push.info.pushing", theme.name, theme.id, theme.shop)) do
@@ -35,6 +35,7 @@ module Theme
35
35
  flags[:ignores] |= pattern
36
36
  end
37
37
  parser.on("-f", "--force") { flags[:force] = true }
38
+ parser.on("--overwrite-json") { flags[:overwrite_json] = true }
38
39
  end
39
40
 
40
41
  def call(_args, name)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Theme
3
4
  module Messages
4
5
  MESSAGES = {
@@ -18,8 +19,9 @@ module Theme
18
19
  ENSURE_USER
19
20
  stable_flag_suggestion: "If the current command isn't working as expected," \
20
21
  " we suggest re-running the command with the {{command: --stable}} flag",
21
- confirm_current_directory: "It doesn’t seem like you’re running this command in a theme directory. " \
22
- "Are you sure you want to proceed?",
22
+ current_directory_is_not_theme_directory: "It doesn’t seem like you’re running this command" \
23
+ " in a theme directory.",
24
+ confirm_current_directory: "Are you sure you want to proceed?",
23
25
  init: {
24
26
  help: <<~HELP,
25
27
  {{command:%s theme init}}: Clones a Git repository to use as a starting point for building a new theme.
@@ -4,7 +4,6 @@ module ShopifyCLI
4
4
  module Commands
5
5
  class App < ShopifyCLI::Command
6
6
  subcommand :Connect, "connect", "shopify_cli/commands/app/connect"
7
- subcommand :Create, "create", "shopify_cli/commands/app/create"
8
7
  subcommand :Deploy, "deploy", "shopify_cli/commands/app/deploy"
9
8
  subcommand :Open, "open", "shopify_cli/commands/app/open"
10
9
  subcommand :Serve, "serve", "shopify_cli/commands/app/serve"
@@ -313,7 +313,7 @@ module ShopifyCLI
313
313
  },
314
314
  error_reporting: {
315
315
  unhandled_error: {
316
- message: "{{x}} {{red:An unexpected error occured.}}",
316
+ message: "{{x}} {{red:An unexpected error occurred.}}",
317
317
  issue_message: "{{red:\tTo \e]8;;%s\e\\submit an issue\e]8;;\e\\"\
318
318
  " include the stack trace.}}",
319
319
  stacktrace_message: "{{red:\tTo print the stack trace, add the environment variable %s.}}",
@@ -25,7 +25,7 @@ module ShopifyCLI
25
25
  "</script>",
26
26
  ].join("\n")
27
27
 
28
- body = body.join.gsub("</body>", "#{hot_reload_script}\n</body>")
28
+ body = body.join.sub("</body>", "#{hot_reload_script}\n</body>")
29
29
 
30
30
  [body]
31
31
  end
@@ -16,12 +16,15 @@ module ShopifyCLI
16
16
  end
17
17
 
18
18
  def call(env)
19
- if env["PATH_INFO"] == "/hot-reload"
19
+ path = env["PATH_INFO"]
20
+ if path == "/hot-reload"
20
21
  create_stream
21
22
  else
22
23
  status, headers, body = @app.call(env)
23
24
 
24
- body = inject_hot_reload_javascript(body) if request_is_html?(headers)
25
+ if request_is_html?(headers) && leads_to_injectable_body?(path)
26
+ body = inject_hot_reload_javascript(body)
27
+ end
25
28
 
26
29
  [status, headers, body]
27
30
  end
@@ -43,6 +46,10 @@ module ShopifyCLI
43
46
  headers["content-type"]&.start_with?("text/html")
44
47
  end
45
48
 
49
+ def leads_to_injectable_body?(path)
50
+ path !~ /.+\/sandbox/
51
+ end
52
+
46
53
  def inject_hot_reload_javascript(body)
47
54
  @script_injector&.inject(body: body, dir: __dir__, mode: @mode)
48
55
  end
@@ -29,13 +29,14 @@ module ShopifyCLI
29
29
  end
30
30
 
31
31
  def call(env)
32
- if env["PATH_INFO"].start_with?("/assets")
32
+ path_info = env["PATH_INFO"]
33
+ if path_info.start_with?("/assets")
33
34
  # Serve from disk
34
- serve_file(env["PATH_INFO"])
35
+ serve_file(path_info)
35
36
  else
36
37
  # Proxy the request, and replace the URLs in the response
37
38
  status, headers, body = @app.call(env)
38
- body = replace_asset_urls(body)
39
+ body = replace_asset_urls(body) unless path_info.start_with?("/fonts")
39
40
  [status, headers, body]
40
41
  end
41
42
  end
@@ -53,6 +54,10 @@ module ShopifyCLI
53
54
  end
54
55
 
55
56
  [replaced_body]
57
+ rescue ArgumentError => error
58
+ return [body.join] if error.message.include?("invalid byte sequence")
59
+
60
+ raise error
56
61
  end
57
62
 
58
63
  def serve_fail(status, body)
@@ -41,6 +41,7 @@ module ShopifyCLI
41
41
  port: 9292,
42
42
  poll: false,
43
43
  editor_sync: false,
44
+ overwrite_json: false,
44
45
  stable: false,
45
46
  mode: ReloadMode.default,
46
47
  includes: nil,
@@ -55,6 +56,7 @@ module ShopifyCLI
55
56
  port,
56
57
  poll,
57
58
  editor_sync,
59
+ overwrite_json,
58
60
  stable,
59
61
  mode,
60
62
  includes,
@@ -78,6 +80,7 @@ module ShopifyCLI
78
80
  port,
79
81
  poll,
80
82
  editor_sync,
83
+ overwrite_json,
81
84
  stable,
82
85
  mode,
83
86
  includes,
@@ -91,6 +94,7 @@ module ShopifyCLI
91
94
  @port = port
92
95
  @poll = poll
93
96
  @editor_sync = editor_sync
97
+ @overwrite_json = overwrite_json
94
98
  @stable = stable
95
99
  @mode = mode
96
100
  @includes = includes
@@ -199,7 +203,7 @@ module ShopifyCLI
199
203
  theme: theme,
200
204
  include_filter: include_filter,
201
205
  ignore_filter: ignore_filter,
202
- overwrite_json: !editor_sync,
206
+ overwrite_json: !editor_sync || @overwrite_json,
203
207
  stable: stable
204
208
  )
205
209
  end
@@ -26,12 +26,13 @@ module ShopifyCLI
26
26
  # Extensions
27
27
  ScriptInjector = ShopifyCLI::Theme::Extension::DevServer::HotReload::ScriptInjector
28
28
 
29
- attr_accessor :project, :specification_handler
29
+ attr_accessor :project, :specification_handler, :generate_tmp_theme
30
30
 
31
31
  class << self
32
- def start(ctx, root, port: 9292, theme: nil, project:, specification_handler:)
32
+ def start(ctx, root, port: 9292, theme: nil, generate_tmp_theme: false, project:, specification_handler:)
33
33
  instance.project = project
34
34
  instance.specification_handler = specification_handler
35
+ instance.generate_tmp_theme = generate_tmp_theme
35
36
 
36
37
  super(ctx, root, port: port, theme: theme)
37
38
  end
@@ -66,8 +67,10 @@ module ShopifyCLI
66
67
 
67
68
  def theme
68
69
  @theme ||= if theme_identifier
69
- theme = ShopifyCLI::Theme::Theme.find_by_identifier(ctx, identifier: theme_identifier)
70
- theme || ctx.abort(not_found_error_message)
70
+ theme = HostTheme.find_by_identifier(ctx, identifier: theme_identifier)
71
+ ctx.abort(not_found_error_message) unless theme
72
+ theme.generate_tmp_theme if generate_tmp_theme
73
+ theme
71
74
  else
72
75
  HostTheme.find_or_create!(ctx)
73
76
  end
@@ -61,20 +61,9 @@ module ShopifyCLI
61
61
  new(ctx, root: nil).ensure_exists!
62
62
  end
63
63
 
64
- private
65
-
66
- def generate_host_theme_name
67
- hostname = Socket.gethostname.split(".").shift
68
- hash = SecureRandom.hex(3)
69
-
70
- theme_name = "App Ext. Host ()"
71
- hostname_character_limit = API_NAME_LIMIT - theme_name.length - hash.length - 1
72
- identifier = encode_identifier("#{hash}-#{hostname[0, hostname_character_limit]}")
73
- theme_name = "App Ext. Host (#{identifier})"
74
-
75
- ShopifyCLI::DB.set(host_theme_name: theme_name)
76
-
77
- theme_name
64
+ def self.find_by_identifier(ctx, root: nil, identifier:)
65
+ ShopifyCLI::DB.set(host_theme_id: identifier)
66
+ find(ctx, root: root)
78
67
  end
79
68
 
80
69
  def generate_tmp_theme
@@ -98,6 +87,22 @@ module ShopifyCLI
98
87
  end
99
88
  end
100
89
  end
90
+
91
+ private
92
+
93
+ def generate_host_theme_name
94
+ hostname = Socket.gethostname.split(".").shift
95
+ hash = SecureRandom.hex(3)
96
+
97
+ theme_name = "App Ext. Host ()"
98
+ hostname_character_limit = API_NAME_LIMIT - theme_name.length - hash.length - 1
99
+ identifier = encode_identifier("#{hash}-#{hostname[0, hostname_character_limit]}")
100
+ theme_name = "App Ext. Host (#{identifier})"
101
+
102
+ ShopifyCLI::DB.set(host_theme_name: theme_name)
103
+
104
+ theme_name
105
+ end
101
106
  end
102
107
  end
103
108
  end
@@ -5,7 +5,7 @@ module ShopifyCLI
5
5
  class Syncer
6
6
  ##
7
7
  # ShopifyCLI::Theme::Syncer::StdReporter allows disabling/enabling
8
- # messages reported in the standard output (ShopifyCLI::Context#puts).
8
+ # messages reported in the standard error output (ShopifyCLI::Context#puts).
9
9
  #
10
10
  class StandardReporter
11
11
  attr_reader :ctx
@@ -24,7 +24,7 @@ module ShopifyCLI
24
24
  end
25
25
 
26
26
  def report(message)
27
- ctx.puts(message) if @enabled
27
+ ctx.error(message) if @enabled
28
28
  end
29
29
  end
30
30
  end
@@ -33,7 +33,7 @@ module ShopifyCLI
33
33
  :union_merge, # - Union merges the local file content with the remote file content
34
34
  ]
35
35
 
36
- attr_reader :ctx, :theme, :checksums, :error_checksums, :api_client, :pending
36
+ attr_reader :ctx, :theme, :checksums, :error_checksums, :api_client, :pending, :standard_reporter
37
37
  attr_accessor :include_filter, :ignore_filter
38
38
 
39
39
  def_delegators :@error_reporter, :has_any_error?
@@ -1,3 +1,3 @@
1
1
  module ShopifyCLI
2
- VERSION = "2.34.0"
2
+ VERSION = "2.36.0"
3
3
  end
data/shopify-cli.gemspec CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.require_paths = ["lib", "vendor"]
36
36
  spec.executables << "shopify"
37
37
 
38
- spec.add_development_dependency("bundler", "~> 2.3.11")
38
+ spec.add_development_dependency("bundler", ">= 2.3.11")
39
39
  spec.add_development_dependency("rake", "~> 12.3", ">= 12.3.3")
40
40
  spec.add_development_dependency("minitest", "~> 5.0")
41
41
 
@@ -157,7 +157,7 @@ module SmartProperties
157
157
  rescue NoMethodError => error
158
158
  # BasicObject does not respond to #nil? by default, so we need to double
159
159
  # check if somebody implemented it and it fails internally or if the
160
- # error occured because the method is actually not present. In the former
160
+ # error occurred because the method is actually not present. In the former
161
161
  # case, we want to raise the exception because there is something wrong
162
162
  # with the implementation of object#nil?. In the latter case we treat the
163
163
  # object as truthy because we don't know better.
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.34.0
4
+ version: 2.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-11 00:00:00.000000000 Z
11
+ date: 2023-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.3.11
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.3.11
27
27
  - !ruby/object:Gem::Dependency
@@ -690,7 +690,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
690
690
  - !ruby/object:Gem::Version
691
691
  version: '0'
692
692
  requirements: []
693
- rubygems_version: 3.3.3
693
+ rubygems_version: 3.4.12
694
694
  signing_key:
695
695
  specification_version: 4
696
696
  summary: Shopify CLI helps you build Shopify apps faster.