shopify-cli 2.10.0 → 2.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a580fc4c23a82fc147e126d1f2cc4b057e5194e75e9c3045e2fa26c97f3d88da
4
- data.tar.gz: 7cd7c21a2bac85a9f0bd3809acfb2ae7389f99be65e34e4411cb4fc4bc6235e8
3
+ metadata.gz: 39a23d6414281b45d36b3508a09f88b629300733e5a3177ce9923905ce26e0ee
4
+ data.tar.gz: 38483662a8c42d1463f1b157262a2cec3cf8c4fda0cb5ccfa74a207a3687be33
5
5
  SHA512:
6
- metadata.gz: 8ef4d2ddcb62c393d7ad69fca6cbdfd577926522fcafe6f172f3370cc4a55d8bf3db68f8fc154dbb6c483b38f718df7991e43c773801c27e1f7a055e3cd0ed1b
7
- data.tar.gz: 94d84b3588aeb62ee53f49593e486e268d58a112d73cdae15e2212dbb4a356ba736ff5e5adf31db4d979e83d7e1a8f56650911b0aab89837ef251f73ce6926b4
6
+ metadata.gz: 58b6b7aa28665cf1107c83ffa6f553eb4cca1661ff8d66d3ef47c9a4d9a3edb46a73e8f38bb5f0f6976699a4a94b58d408e11c2622718be1a554575048c844c3
7
+ data.tar.gz: e060cfe1fc4c2917f096b9c0c48f9562f441fb005b6669c1ad93ac8c0a6121ae8c2fac0759fd8f591f4700b0c717f993286b67911cfa133d5cab605a600d69c8
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@ 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.10.1
6
+ ### Fixed
7
+ * [#1985](https://github.com/Shopify/shopify-cli/pull/1985): Revert "Fix CORS (Cross-origin resource sharing) errors (#1952)"
8
+
5
9
  ## Version 2.10.0
6
10
  ### Fixed
7
11
  * [#1937](https://github.com/Shopify/shopify-cli/pull/1937): Fix `theme pull` to no longer add empty lines on Windows
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify-cli (2.10.0)
4
+ shopify-cli (2.10.1)
5
5
  bugsnag (~> 6.22)
6
6
  listen (~> 3.7.0)
7
7
  theme-check (~> 1.9.0)
@@ -11,6 +11,7 @@ mutation AppScriptSet(
11
11
  $configurationDefinition: String!,
12
12
  $moduleUploadUrl: String!,
13
13
  $library: LibraryInput,
14
+ $inputQuery: String,
14
15
  ) {
15
16
  appScriptSet(
16
17
  uuid: $uuid
@@ -25,6 +26,7 @@ mutation AppScriptSet(
25
26
  configurationDefinition: $configurationDefinition,
26
27
  moduleUploadUrl: $moduleUploadUrl,
27
28
  library: $library,
29
+ inputQuery: $inputQuery,
28
30
  ) {
29
31
  userErrors {
30
32
  field
@@ -12,7 +12,6 @@ module Script
12
12
  Infrastructure::PushPackageRepository.new(ctx: ctx).create_push_package(
13
13
  script_project: script_project,
14
14
  script_content: task_runner.build,
15
- compiled_type: task_runner.compiled_type,
16
15
  metadata: task_runner.metadata,
17
16
  library: library,
18
17
  )
@@ -30,7 +30,6 @@ module Script
30
30
  UI::PrintingSpinner.spin(ctx, ctx.message("script.application.pushing")) do |p_ctx, spinner|
31
31
  package = Infrastructure::PushPackageRepository.new(ctx: p_ctx).get_push_package(
32
32
  script_project: script_project,
33
- compiled_type: task_runner.compiled_type,
34
33
  metadata: task_runner.metadata,
35
34
  library: library,
36
35
  )
@@ -47,6 +46,7 @@ module Script
47
46
  script_config: package.script_config,
48
47
  module_upload_url: module_upload_url,
49
48
  library: package.library,
49
+ input_query: script_project.input_query,
50
50
  )
51
51
  if ShopifyCLI::Environment.interactive?
52
52
  script_project_repo.update_env(uuid: uuid)
@@ -9,7 +9,6 @@ module Script
9
9
  :extension_point_type,
10
10
  :script_config,
11
11
  :script_content,
12
- :compiled_type,
13
12
  :metadata,
14
13
  :library
15
14
 
@@ -18,7 +17,6 @@ module Script
18
17
  uuid:,
19
18
  extension_point_type:,
20
19
  script_content:,
21
- compiled_type: nil,
22
20
  metadata:,
23
21
  script_config:,
24
22
  library:
@@ -27,7 +25,6 @@ module Script
27
25
  @uuid = uuid
28
26
  @extension_point_type = extension_point_type
29
27
  @script_content = script_content
30
- @compiled_type = compiled_type
31
28
  @metadata = metadata
32
29
  @script_config = script_config
33
30
  @library = library
@@ -16,6 +16,7 @@ module Script
16
16
  property! :language, accepts: String
17
17
 
18
18
  property :script_config, accepts: ScriptConfig
19
+ property :input_query, accepts: String
19
20
 
20
21
  def initialize(*)
21
22
  super
@@ -21,10 +21,6 @@ module Script
21
21
  bytecode
22
22
  end
23
23
 
24
- def compiled_type
25
- "wasm"
26
- end
27
-
28
24
  def install_dependencies
29
25
  check_node_version!
30
26
 
@@ -22,10 +22,6 @@ module Script
22
22
  bytecode
23
23
  end
24
24
 
25
- def compiled_type
26
- "wasm"
27
- end
28
-
29
25
  def install_dependencies
30
26
  check_node_version!
31
27
 
@@ -7,8 +7,8 @@ module Script
7
7
  include SmartProperties
8
8
  property! :ctx, accepts: ShopifyCLI::Context
9
9
 
10
- def create_push_package(script_project:, script_content:, compiled_type:, metadata:, library:)
11
- build_file_path = file_path(script_project.id, compiled_type)
10
+ def create_push_package(script_project:, script_content:, metadata:, library:)
11
+ build_file_path = file_path(script_project.id)
12
12
  write_to_path(build_file_path, script_content)
13
13
 
14
14
  Domain::PushPackage.new(
@@ -16,15 +16,14 @@ module Script
16
16
  uuid: script_project.uuid,
17
17
  extension_point_type: script_project.extension_point_type,
18
18
  script_content: script_content,
19
- compiled_type: compiled_type,
20
19
  metadata: metadata,
21
20
  script_config: script_project.script_config,
22
21
  library: library
23
22
  )
24
23
  end
25
24
 
26
- def get_push_package(script_project:, compiled_type:, metadata:, library:)
27
- build_file_path = file_path(script_project.id, compiled_type)
25
+ def get_push_package(script_project:, metadata:, library:)
26
+ build_file_path = file_path(script_project.id)
28
27
  raise Domain::PushPackageNotFoundError unless ctx.file_exist?(build_file_path)
29
28
 
30
29
  script_content = ctx.binread(build_file_path)
@@ -46,8 +45,8 @@ module Script
46
45
  ctx.binwrite(path, content)
47
46
  end
48
47
 
49
- def file_path(path_to_script, compiled_type)
50
- "#{path_to_script}/build/script.#{compiled_type}"
48
+ def file_path(path_to_script)
49
+ "#{path_to_script}/build/script.wasm"
51
50
  end
52
51
  end
53
52
  end
@@ -10,6 +10,7 @@ module Script
10
10
  property :initial_directory, accepts: String
11
11
 
12
12
  MUTABLE_ENV_VALUES = %i(uuid)
13
+ INPUT_QUERY_PATH = "input.graphql"
13
14
 
14
15
  def create_project_directory
15
16
  raise Infrastructure::Errors::ScriptProjectAlreadyExistsError, directory if ctx.dir_exist?(directory)
@@ -38,13 +39,7 @@ module Script
38
39
  language: language
39
40
  )
40
41
 
41
- Domain::ScriptProject.new(
42
- id: ctx.root,
43
- env: project.env,
44
- script_name: script_name,
45
- extension_point_type: extension_point_type,
46
- language: language
47
- )
42
+ build_script_project(script_config: nil)
48
43
  end
49
44
 
50
45
  def get
@@ -56,7 +51,8 @@ module Script
56
51
  script_name: script_name,
57
52
  extension_point_type: extension_point_type,
58
53
  language: language,
59
- script_config: script_config_repository.get!
54
+ script_config: script_config_repository.get!,
55
+ input_query: read_input_query,
60
56
  )
61
57
  end
62
58
 
@@ -68,14 +64,7 @@ module Script
68
64
  end
69
65
  end
70
66
 
71
- Domain::ScriptProject.new(
72
- id: ctx.root,
73
- env: project.env,
74
- script_name: script_name,
75
- extension_point_type: extension_point_type,
76
- language: language,
77
- script_config: script_config_repository.get!,
78
- )
67
+ build_script_project
79
68
  end
80
69
 
81
70
  def create_env(api_key:, secret:, uuid:)
@@ -87,19 +76,19 @@ module Script
87
76
  }
88
77
  ).write(ctx)
89
78
 
90
- Domain::ScriptProject.new(
91
- id: ctx.root,
92
- env: project.env,
93
- script_name: script_name,
94
- extension_point_type: extension_point_type,
95
- language: language,
96
- script_config: script_config_repository.get!,
97
- )
79
+ build_script_project
98
80
  end
99
81
 
100
82
  def update_script_config(title:)
101
83
  script_config = script_config_repository.update!(title: title)
84
+ build_script_project(script_config: script_config)
85
+ end
86
+
87
+ private
102
88
 
89
+ def build_script_project(
90
+ script_config: script_config_repository.get!
91
+ )
103
92
  Domain::ScriptProject.new(
104
93
  id: ctx.root,
105
94
  env: project.env,
@@ -110,8 +99,6 @@ module Script
110
99
  )
111
100
  end
112
101
 
113
- private
114
-
115
102
  def change_directory(directory:)
116
103
  ctx.chdir(directory)
117
104
  end
@@ -173,6 +160,10 @@ module Script
173
160
  end
174
161
  end
175
162
 
163
+ def read_input_query
164
+ ctx.read(INPUT_QUERY_PATH) if ctx.file_exist?(INPUT_QUERY_PATH)
165
+ end
166
+
176
167
  class ScriptConfigRepository
177
168
  include SmartProperties
178
169
  property! :ctx, accepts: ShopifyCLI::Context
@@ -19,7 +19,8 @@ module Script
19
19
  metadata:,
20
20
  script_config:,
21
21
  module_upload_url:,
22
- library:
22
+ library:,
23
+ input_query: nil
23
24
  )
24
25
  query_name = "app_script_set"
25
26
  variables = {
@@ -38,6 +39,7 @@ module Script
38
39
  language: library[:language],
39
40
  version: library[:version],
40
41
  },
42
+ inputQuery: input_query,
41
43
  }
42
44
  resp_hash = make_request(query_name: query_name, variables: variables)
43
45
  user_errors = resp_hash["data"]["appScriptSet"]["userErrors"]
@@ -1,13 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "cdn/cdn_helper"
4
-
5
3
  module ShopifyCLI
6
4
  module Theme
7
5
  module DevServer
8
6
  class CdnFonts
9
- include Cdn::CdnHelper
10
-
11
7
  FONTS_PATH = "/fonts"
12
8
  FONTS_CDN = "https://fonts.shopifycdn.com"
13
9
  FONTS_REGEX = %r{#{FONTS_CDN}}
@@ -21,7 +17,7 @@ module ShopifyCLI
21
17
  path = env["PATH_INFO"]
22
18
 
23
19
  # Serve from fonts CDN
24
- return serve_font(env, path) if path.start_with?(FONTS_PATH)
20
+ return serve_font(env) if path.start_with?(FONTS_PATH)
25
21
 
26
22
  # Proxy the request, and replace the URLs in the response
27
23
  status, headers, body = @app.call(env)
@@ -31,11 +27,35 @@ module ShopifyCLI
31
27
 
32
28
  private
33
29
 
34
- def serve_font(env, path)
35
- query = env["QUERY_STRING"]
30
+ def serve_font(env)
31
+ parameters = %w(PATH_INFO QUERY_STRING REQUEST_METHOD rack.input)
32
+ path, query, method, body_stream = *env.slice(*parameters).values
33
+
36
34
  uri = fonts_cdn_uri(path, query)
37
35
 
38
- proxy_request(env, uri, @theme)
36
+ response = Net::HTTP.start(uri.host, 443, use_ssl: true) do |http|
37
+ req_class = Net::HTTP.const_get(method.capitalize)
38
+ req = req_class.new(uri)
39
+ req.initialize_http_header(fonts_cdn_headers)
40
+ req.body_stream = body_stream
41
+ http.request(req)
42
+ end
43
+
44
+ [
45
+ response.code.to_s,
46
+ {
47
+ "Content-Type" => response.content_type,
48
+ "Content-Length" => response.content_length.to_s,
49
+ },
50
+ [response.body],
51
+ ]
52
+ end
53
+
54
+ def fonts_cdn_headers
55
+ {
56
+ "Referer" => "https://#{@theme.shop}",
57
+ "Transfer-Encoding" => "chunked",
58
+ }
39
59
  end
40
60
 
41
61
  def fonts_cdn_uri(path, query)
@@ -11,10 +11,6 @@ module ShopifyCLI
11
11
  @path = path
12
12
  end
13
13
 
14
- def join
15
- @path.read
16
- end
17
-
18
14
  # Naive implementation. Only used in unit tests.
19
15
  def each
20
16
  yield @path.read
@@ -3,7 +3,6 @@ require_relative "development_theme"
3
3
  require_relative "ignore_filter"
4
4
  require_relative "syncer"
5
5
 
6
- require_relative "dev_server/cdn_assets"
7
6
  require_relative "dev_server/cdn_fonts"
8
7
  require_relative "dev_server/hot_reload"
9
8
  require_relative "dev_server/header_hash"
@@ -38,7 +37,6 @@ module ShopifyCLI
38
37
  @app = Proxy.new(ctx, theme: theme, syncer: @syncer)
39
38
  @app = CdnFonts.new(@app, theme: theme)
40
39
  @app = LocalAssets.new(ctx, @app, theme: theme)
41
- @app = CdnAssets.new(@app, theme: theme)
42
40
  @app = HotReload.new(ctx, @app, theme: theme, watcher: watcher, mode: mode, ignore_filter: ignore_filter)
43
41
  stopped = false
44
42
  address = "http://#{host}:#{port}"
@@ -1,3 +1,3 @@
1
1
  module ShopifyCLI
2
- VERSION = "2.10.0"
2
+ VERSION = "2.10.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.0
4
+ version: 2.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-25 00:00:00.000000000 Z
11
+ date: 2022-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -458,8 +458,6 @@ files:
458
458
  - lib/shopify_cli/tasks/select_org_and_shop.rb
459
459
  - lib/shopify_cli/tasks/update_dashboard_urls.rb
460
460
  - lib/shopify_cli/theme/dev_server.rb
461
- - lib/shopify_cli/theme/dev_server/cdn/cdn_helper.rb
462
- - lib/shopify_cli/theme/dev_server/cdn_assets.rb
463
461
  - lib/shopify_cli/theme/dev_server/cdn_fonts.rb
464
462
  - lib/shopify_cli/theme/dev_server/certificate_manager.rb
465
463
  - lib/shopify_cli/theme/dev_server/header_hash.rb
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ShopifyCLI
4
- module Theme
5
- module DevServer
6
- module Cdn
7
- module CdnHelper
8
- def proxy_request(env, uri, theme)
9
- response = Net::HTTP.start(uri.host, 443, use_ssl: true) do |http|
10
- req_class = Net::HTTP.const_get(method(env))
11
-
12
- req = req_class.new(uri)
13
- req.initialize_http_header(req_headers(theme))
14
- req.body_stream = req_body(env)
15
-
16
- http.request(req)
17
- end
18
-
19
- [
20
- response.code.to_s,
21
- {
22
- "Content-Type" => response.content_type,
23
- "Content-Length" => response.content_length.to_s,
24
- },
25
- [response.body],
26
- ]
27
- end
28
-
29
- private
30
-
31
- def method(env)
32
- env["REQUEST_METHOD"].capitalize
33
- end
34
-
35
- def req_body(env)
36
- env["rack.input"]
37
- end
38
-
39
- def req_headers(theme)
40
- {
41
- "Referer" => "https://#{theme.shop}",
42
- "Transfer-Encoding" => "chunked",
43
- }
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
@@ -1,69 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "cdn/cdn_helper"
4
- require_relative "local_assets"
5
-
6
- module ShopifyCLI
7
- module Theme
8
- module DevServer
9
- class CdnAssets
10
- include Cdn::CdnHelper
11
-
12
- ASSETS_PROXY_PATH = "/cdn_asset"
13
- ASSETS_CDN = "//cdn.shopify.com"
14
- ASSETS_CDN_REGEX = %r{(https?:)?#{ASSETS_CDN}}
15
- ASSETS_SOURCE_MAP_REGEX = /\/[\/|\*]# sourceMappingURL\=(\/.*)/
16
-
17
- def initialize(app, theme:)
18
- @app = app
19
- @theme = theme
20
- end
21
-
22
- def call(env)
23
- path = env["PATH_INFO"]
24
-
25
- # Serve assets from CDN
26
- return serve_asset(env, path) if path.start_with?(ASSETS_PROXY_PATH)
27
-
28
- # Proxy the request, and replace the URLs in the response
29
- status, headers, body = @app.call(env)
30
- body = replace_asset_urls(body)
31
- [status, headers, body]
32
- end
33
-
34
- private
35
-
36
- def serve_asset(env, path)
37
- path = path.gsub(%r{^#{ASSETS_PROXY_PATH}}, "")
38
- query = env["QUERY_STRING"]
39
- uri = asset_cdn_uri(path, query)
40
-
41
- status, headers, body = proxy_request(env, uri, @theme)
42
-
43
- [status, headers, replace_source_map_url(body)]
44
- end
45
-
46
- def asset_cdn_uri(path, query)
47
- uri = URI.join("https:#{ASSETS_CDN}", path)
48
- uri.query = query.split("&").last
49
- uri
50
- end
51
-
52
- def replace_asset_urls(body)
53
- [body.join.gsub(ASSETS_CDN_REGEX, ASSETS_PROXY_PATH)]
54
- end
55
-
56
- def replace_source_map_url(body)
57
- body_content = body.join
58
- map_regex_match = body_content.match(ASSETS_SOURCE_MAP_REGEX)
59
- return body if map_regex_match.nil?
60
-
61
- map_url = map_regex_match[1]
62
- return body if map_url.nil?
63
-
64
- [body_content.gsub(map_url, "#{ASSETS_PROXY_PATH}#{map_url}")]
65
- end
66
- end
67
- end
68
- end
69
- end