shopify-cli 2.0.1 → 2.2.1

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -0
  3. data/Gemfile.lock +4 -4
  4. data/README.md +3 -1
  5. data/THEMEKIT_MIGRATION.md +18 -0
  6. data/lib/graphql/api_versions.graphql +1 -1
  7. data/lib/graphql/get_variant_id.graphql +16 -0
  8. data/lib/project_types/extension/cli.rb +10 -1
  9. data/lib/project_types/extension/commands/check.rb +44 -0
  10. data/lib/project_types/extension/commands/push.rb +0 -1
  11. data/lib/project_types/extension/commands/serve.rb +8 -2
  12. data/lib/project_types/extension/extension_project.rb +39 -1
  13. data/lib/project_types/extension/extension_project_keys.rb +1 -0
  14. data/lib/project_types/extension/features/argo.rb +1 -11
  15. data/lib/project_types/extension/features/argo_runtime.rb +6 -38
  16. data/lib/project_types/extension/features/argo_serve.rb +30 -1
  17. data/lib/project_types/extension/features/runtimes/admin.rb +29 -0
  18. data/lib/project_types/extension/features/runtimes/base.rb +19 -0
  19. data/lib/project_types/extension/features/runtimes/checkout_post_purchase.rb +23 -0
  20. data/lib/project_types/extension/features/runtimes/checkout_ui_extension.rb +29 -0
  21. data/lib/project_types/extension/messages/messages.rb +19 -6
  22. data/lib/project_types/extension/models/product.rb +12 -0
  23. data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +10 -0
  24. data/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +10 -2
  25. data/lib/project_types/extension/models/specification_handlers/default.rb +13 -4
  26. data/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +12 -0
  27. data/lib/project_types/extension/tasks/configure_features.rb +1 -0
  28. data/lib/project_types/extension/tasks/converters/product_converter.rb +21 -0
  29. data/lib/project_types/extension/tasks/get_product.rb +22 -0
  30. data/lib/project_types/node/messages/messages.rb +1 -1
  31. data/lib/project_types/rails/messages/messages.rb +18 -18
  32. data/lib/project_types/script/commands/create.rb +1 -1
  33. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +3 -3
  34. data/lib/project_types/theme/forms/select.rb +1 -1
  35. data/lib/project_types/theme/messages/messages.rb +3 -3
  36. data/lib/shopify-cli/admin_api.rb +6 -2
  37. data/lib/shopify-cli/api.rb +2 -2
  38. data/lib/shopify-cli/core/monorail.rb +8 -3
  39. data/lib/shopify-cli/messages/messages.rb +9 -8
  40. data/lib/shopify-cli/packager.rb +5 -5
  41. data/lib/shopify-cli/theme/dev_server.rb +1 -1
  42. data/lib/shopify-cli/theme/dev_server/local_assets.rb +1 -1
  43. data/lib/shopify-cli/theme/file.rb +2 -2
  44. data/lib/shopify-cli/theme/syncer.rb +9 -5
  45. data/lib/shopify-cli/theme/theme.rb +5 -5
  46. data/lib/shopify-cli/tunnel.rb +1 -1
  47. data/lib/shopify-cli/version.rb +1 -1
  48. data/shopify-cli.gemspec +1 -1
  49. metadata +14 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a3d1792a9f0fef3212722391bc41ac2cba899f60b65c61d75c624fb61aef1dc
4
- data.tar.gz: 4927100649c20fbedd270715ff5e34fe89138548c2355f8fdff68ed19bdc6ce4
3
+ metadata.gz: c0c4574b0b307dbe68a4cfe4d47e76a4825dbc2bb208b2fd891e0192e3158690
4
+ data.tar.gz: c365c04166d24b723c4b5d8e0612e722fec4e765f2efcc4a638d534ab60a645c
5
5
  SHA512:
6
- metadata.gz: 9cdddb7dc42cb7df1baa92baea6da019b180092aa54d40185a72a8f0552d1f894bf896fedc007ded724023bdce163a13fb16d7e8eb4f11554aafc19fbdedf318
7
- data.tar.gz: 61e74dc5788edc4653902bf2a42ddc8ca9da3535bc4b1779a0ed73b475940c423a61374e6f5eb18c5e635115ea86634b29c0ebf3f081bce28cb7fec2fd4071cd
6
+ metadata.gz: baecd34e68711439ab4986652a21d00dc7c8443ef92497cf516e535cb91b979280293a3d86936a5b4260984739b28adab3ece18fdedfa35087d8ed1ee7411f2c
7
+ data.tar.gz: c55111c54115aeb15b5c9cd29e48c1b42c2dbe89a79a509e74c3f2fdea0830ad693e9983ca00ad40468ed9c132c7202e0ca01681dc94866f191773c982811f14
data/CHANGELOG.md CHANGED
@@ -1,6 +1,33 @@
1
1
  Unreleased
2
2
  ------
3
3
 
4
+ Version 2.2.1
5
+ ------
6
+
7
+ * [1432](https://github.com/Shopify/shopify-cli/pull/1432) New method for determining renderer package name
8
+
9
+ Version 2.2.0
10
+ ------
11
+ * [#1424](https://github.com/Shopify/shopify-cli/pull/1424/): Add `--resourceUrl` flag to extension serve command
12
+ * [#1419](https://github.com/Shopify/shopify-cli/pull/1419): Remove analytics prompt when used in CI
13
+ * [#1418](https://github.com/Shopify/shopify-cli/pull/1418): Auto configure resource URL for Checkout Extensions
14
+ * [#1399](https://github.com/Shopify/shopify-cli/pull/1399): Fix error when running `shopify extension serve` in a theme app extension project
15
+
16
+ Version 2.1.0
17
+ -------------
18
+ * [#1357](https://github.com/Shopify/shopify-cli/pull/1357): Update Theme-Check to 1.1
19
+ * [#1352](https://github.com/Shopify/shopify-cli/pull/1352): Add `shopify extension check` for checking theme app extensions
20
+ * [#1304](https://github.com/Shopify/shopify-cli/pull/1304): Prompt user to run `shopify extension connect` if .env file is missing
21
+
22
+ Version 2.0.2
23
+ -------------
24
+ * [#1305](https://github.com/Shopify/shopify-cli/pull/1305): Fix `Uninitialized constant Net::WriteTimeout` error
25
+ * [#1319](https://github.com/Shopify/shopify-cli/pull/1319): Fix `theme pull` not pulling some files
26
+ * [#1321](https://github.com/Shopify/shopify-cli/pull/1321): Fix error when pulling images with `theme pull`
27
+ * [#1322](https://github.com/Shopify/shopify-cli/pull/1322): Fix error when running `shopify theme language-server --help`
28
+ * [#1324](https://github.com/Shopify/shopify-cli/pull/1324): Fix issue [#1308](https://github.com/Shopify/shopify-cli/issues/1308) where a non-English language on Partner Account breaks how CLI determines latest API version.
29
+ * [#1343](https://github.com/Shopify/shopify-cli/pull/1343): Fix inconsistent use of periods vs ellipsis in messages. This replaces periods with ellipsis.
30
+
4
31
  Version 2.0.1
5
32
  -------------
6
33
  * [#1295](https://github.com/Shopify/shopify-cli/pull/1295): Ignore files at the root of a theme app extension project
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify-cli (2.0.1)
4
+ shopify-cli (2.2.1)
5
5
  listen (~> 3.5)
6
- theme-check (~> 1.0)
6
+ theme-check (~> 1.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -76,7 +76,7 @@ GEM
76
76
  rubocop-shopify (2.0.1)
77
77
  rubocop (~> 1.11)
78
78
  ruby-progressbar (1.11.0)
79
- theme-check (1.0.0)
79
+ theme-check (1.1.0)
80
80
  liquid (>= 5.0.1)
81
81
  nokogumbo
82
82
  timecop (0.9.2)
@@ -108,4 +108,4 @@ DEPENDENCIES
108
108
  webmock
109
109
 
110
110
  BUNDLED WITH
111
- 2.1.4
111
+ 2.2.22
data/README.md CHANGED
@@ -101,9 +101,11 @@ Run:
101
101
 
102
102
  To start the server. The server includes hot reload for CSS & Sections.
103
103
 
104
+ **Note:** Shopify CLI is the recommended and officially supported tool for developing themes and creating CI/CD workflows. Please refer to the [Theme Kit Migration Guide](https://github.com/Shopify/shopify-cli/blob/main/THEMEKIT_MIGRATION.md) for details.
105
+
104
106
  ### Contributing
105
107
 
106
- Shopify CLI is an [open source tool](https://github.com/Shopify/shopify-cli/blob/main/.github/LICENSE.md) and everyone is welcome to help the community by [contributing](https://github.com/Shopify/shopify-cli/blob/main/.github/CONTRIBUTING.md) to the project.
108
+ Shopify CLI is an [open source tool](https://github.com/Shopify/shopify-cli/blob/main/LICENSE) and everyone is welcome to help the community by [contributing](https://github.com/Shopify/shopify-cli/blob/main/.github/CONTRIBUTING.md) to the project.
107
109
 
108
110
  ### Where to get help
109
111
 
@@ -0,0 +1,18 @@
1
+ # Theme Kit Migration
2
+
3
+ Shopify CLI is the recommended and officially supported tool for developing Themes and creating CI/CD workflows.
4
+
5
+ This guide shows how to achieve equivalent flows with the new version of the CLI.
6
+
7
+ ## Equivalent commands
8
+
9
+ | Theme Kit Command | Shopify CLI Equivalent | Objective |
10
+ |---|---|---|
11
+ |`theme deploy`|`shopify theme push`| Deploy a local (to the CLI) version of the Theme in the current working directory to a remote store.|
12
+ |`theme new`|`shopify theme init`| Scaffold a new theme. In the case of the CLI it clones Dawn to be used as a reference Theme. Alternatively, it's possible to simply clone Dawn `git clone git@github.com:Shopify/dawn.git` and use it with the CLI.
13
+ |`theme download`|`shopify theme pull`| Download your remote theme files.|
14
+ |`theme watch` & `theme open` | `shopify theme serve` | Start a theme server to locally preview changes with CSS & Section hot reload enabled|
15
+ |-| `shopify theme check`| Run the Theme Check linter on your theme codebase.|
16
+ |-|`shopify theme publish`| Set a remote theme as the live theme.|
17
+ |-|`shopify theme package`|Pack your Theme as a zip file ready for distribution and submission to the Theme Store.|
18
+ |`theme remove`| `shopify theme delete`| Theme kit removes files from the Theme whereas Shopify CLI will remotely destroy the specified theme.|
@@ -1,6 +1,6 @@
1
1
  query {
2
2
  publicApiVersions {
3
3
  handle
4
- displayName
4
+ supported
5
5
  }
6
6
  }
@@ -0,0 +1,16 @@
1
+ query {
2
+ products(first: 1) {
3
+ edges {
4
+ node {
5
+ id
6
+ variants(first: 1) {
7
+ edges {
8
+ node {
9
+ id
10
+ }
11
+ }
12
+ }
13
+ }
14
+ }
15
+ }
16
+ }
@@ -24,6 +24,7 @@ module Extension
24
24
  subcommand :Serve, "serve", Project.project_filepath("commands/serve")
25
25
  subcommand :Push, "push", Project.project_filepath("commands/push")
26
26
  subcommand :Tunnel, "tunnel", Project.project_filepath("commands/tunnel")
27
+ subcommand :Check, "check", Project.project_filepath("commands/check")
27
28
  end
28
29
  ShopifyCli::Commands.register("Extension::Command", "extension")
29
30
 
@@ -39,12 +40,14 @@ module Extension
39
40
  autoload :ChooseNextAvailablePort, Project.project_filepath("tasks/choose_next_available_port")
40
41
  autoload :FindNpmPackages, Project.project_filepath("tasks/find_npm_packages")
41
42
  autoload :GetExtensions, Project.project_filepath("tasks/get_extensions")
43
+ autoload :GetProduct, Project.project_filepath("tasks/get_product")
42
44
 
43
45
  module Converters
44
46
  autoload :RegistrationConverter, Project.project_filepath("tasks/converters/registration_converter")
45
47
  autoload :VersionConverter, Project.project_filepath("tasks/converters/version_converter")
46
48
  autoload :ValidationErrorConverter, Project.project_filepath("tasks/converters/validation_error_converter")
47
49
  autoload :AppConverter, Project.project_filepath("tasks/converters/app_converter")
50
+ autoload :ProductConverter, Project.project_filepath("tasks/converters/product_converter")
48
51
  end
49
52
  end
50
53
 
@@ -62,6 +65,12 @@ module Extension
62
65
  end
63
66
 
64
67
  module Features
68
+ module Runtimes
69
+ autoload :Admin, Project.project_filepath("features/runtimes/admin")
70
+ autoload :Base, Project.project_filepath("features/runtimes/base")
71
+ autoload :CheckoutPostPurchase, Project.project_filepath("features/runtimes/checkout_post_purchase")
72
+ autoload :CheckoutUiExtension, Project.project_filepath("features/runtimes/checkout_ui_extension")
73
+ end
65
74
  autoload :ArgoServe, Project.project_filepath("features/argo_serve")
66
75
  autoload :ArgoServeOptions, Project.project_filepath("features/argo_serve_options")
67
76
  autoload :ArgoSetup, Project.project_filepath("features/argo_setup")
@@ -76,7 +85,6 @@ module Extension
76
85
  module Models
77
86
  module SpecificationHandlers
78
87
  autoload :Default, Project.project_filepath("models/specification_handlers/default")
79
- autoload :CheckoutArgoExtension, Project.project_filepath("models/specification_handlers/checkout_ui_extension")
80
88
  end
81
89
 
82
90
  autoload :App, Project.project_filepath("models/app")
@@ -87,6 +95,7 @@ module Extension
87
95
  autoload :Specifications, Project.project_filepath("models/specifications")
88
96
  autoload :LazySpecificationHandler, Project.project_filepath("models/lazy_specification_handler")
89
97
  autoload :NpmPackage, Project.project_filepath("models/npm_package")
98
+ autoload :Product, Project.project_filepath("models/product")
90
99
  end
91
100
 
92
101
  autoload :ExtensionProjectKeys, Project.project_filepath("extension_project_keys")
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+ require "theme_check"
3
+
4
+ module Extension
5
+ class Command
6
+ class Check < ExtensionCommand
7
+ class CheckOptions < ShopifyCli::Options
8
+ def initialize(ctx, theme_check)
9
+ super()
10
+ @theme_check = theme_check
11
+ @ctx = ctx
12
+ end
13
+
14
+ def parse(_options_block, args)
15
+ # Check if .theme-check.yml exists, or if another -C has been passed on the command line
16
+ unless args.include?("-C") || @ctx.file_exist?(".theme-check.yml")
17
+ args += ["-C", ":theme_app_extension"]
18
+ end
19
+ @theme_check.parse(args)
20
+ end
21
+ end
22
+
23
+ def initialize(*)
24
+ super
25
+ if project.specification_identifier == "THEME_APP_EXTENSION"
26
+ @theme_check = ThemeCheck::Cli.new
27
+ self.options = CheckOptions.new(@ctx, @theme_check)
28
+ end
29
+ end
30
+
31
+ def call(*)
32
+ if project.specification_identifier == "THEME_APP_EXTENSION"
33
+ @theme_check.run
34
+ else
35
+ @ctx.abort(@ctx.message("check.unsupported", project.specification_identifier))
36
+ end
37
+ end
38
+
39
+ def self.help
40
+ ShopifyCli::Context.message("check.help", ShopifyCli::TOOL_NAME)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -11,7 +11,6 @@ module Extension
11
11
  def call(args, name)
12
12
  Command::Register.new(@ctx).call(args, name) unless project.registered?
13
13
  Command::Build.new(@ctx).call(args, name) unless specification_handler.specification.options[:skip_build]
14
-
15
14
  CLI::UI::Frame.open(@ctx.message("push.frame_title")) do
16
15
  updated_draft_version = update_draft
17
16
  show_message(updated_draft_version)
@@ -9,19 +9,24 @@ module Extension
9
9
 
10
10
  options do |parser, flags|
11
11
  parser.on("-t", "--[no-]tunnel", "Establish an ngrok tunnel") { |tunnel| flags[:tunnel] = tunnel }
12
+ parser.on("--resourceUrl=RESOURCE_URL", "Provide a resource URL") do |resource_url|
13
+ flags[:resource_url] = resource_url
14
+ end
12
15
  end
13
16
 
14
17
  class RuntimeConfiguration
15
18
  include SmartProperties
16
19
 
17
20
  property :tunnel_url, accepts: String, default: nil
21
+ property :resource_url, accepts: String, default: nil
18
22
  property! :tunnel_requested, accepts: [true, false], reader: :tunnel_requested?, default: true
19
23
  property! :port, accepts: (1...(2**16)), default: DEFAULT_PORT
20
24
  end
21
25
 
22
26
  def call(_args, _command_name)
23
27
  config = RuntimeConfiguration.new(
24
- tunnel_requested: tunnel_requested?
28
+ tunnel_requested: tunnel_requested?,
29
+ resource_url: options.flags[:resource_url]
25
30
  )
26
31
 
27
32
  ShopifyCli::Result
@@ -74,7 +79,8 @@ module Extension
74
79
  specification_handler.serve(
75
80
  context: @ctx,
76
81
  tunnel_url: runtime_configuration.tunnel_url,
77
- port: runtime_configuration.port
82
+ port: runtime_configuration.port,
83
+ resource_url: runtime_configuration.resource_url
78
84
  )
79
85
  runtime_configuration
80
86
  end
@@ -14,16 +14,43 @@ module Extension
14
14
  )
15
15
  end
16
16
 
17
+ def update_env_file(context:, **updates)
18
+ current_config = {
19
+ title: current.title,
20
+ shop: current.env.shop,
21
+ api_key: current.app.api_key,
22
+ api_secret: current.app.secret,
23
+ registration_id: current.registration_id,
24
+ registration_uuid: current.registration_uuid,
25
+ resource_url: current.resource_url,
26
+ }
27
+
28
+ write_env_file(
29
+ context: context,
30
+ **current_config,
31
+ **updates
32
+ )
33
+ end
34
+
17
35
  def write_env_file(
18
- context:, title:, api_key: "", api_secret: "", registration_id: nil, registration_uuid: nil
36
+ context:,
37
+ title:,
38
+ api_key: "",
39
+ api_secret: "",
40
+ registration_id: nil,
41
+ registration_uuid: nil,
42
+ resource_url: nil,
43
+ shop: nil
19
44
  )
20
45
  ShopifyCli::Resources::EnvFile.new(
21
46
  api_key: api_key,
22
47
  secret: api_secret,
48
+ shop: shop,
23
49
  extra: {
24
50
  ExtensionProjectKeys::TITLE_KEY => title,
25
51
  ExtensionProjectKeys::REGISTRATION_ID_KEY => registration_id,
26
52
  ExtensionProjectKeys::REGISTRATION_UUID_KEY => registration_uuid || generate_temporary_uuid,
53
+ ExtensionProjectKeys::RESOURCE_URL_KEY => resource_url,
27
54
  }.compact
28
55
  ).write(context)
29
56
 
@@ -42,6 +69,7 @@ module Extension
42
69
  end
43
70
 
44
71
  def app
72
+ validate_env_present
45
73
  Models::App.new(api_key: env["api_key"], secret: env["secret"])
46
74
  end
47
75
 
@@ -71,6 +99,10 @@ module Extension
71
99
  get_extra_field(ExtensionProjectKeys::REGISTRATION_UUID_KEY)
72
100
  end
73
101
 
102
+ def resource_url
103
+ get_extra_field(ExtensionProjectKeys::RESOURCE_URL_KEY)
104
+ end
105
+
74
106
  def reload
75
107
  @env = nil
76
108
  end
@@ -96,9 +128,15 @@ module Extension
96
128
  end
97
129
 
98
130
  def property_present?(key)
131
+ validate_env_present
99
132
  !env[key].nil? && !env[key].strip.empty?
100
133
  end
101
134
 
135
+ def validate_env_present
136
+ return if env
137
+ raise ShopifyCli::Abort, "Missing .env file. Run `shopify extension connect` to generate an .env file."
138
+ end
139
+
102
140
  def integer?(value)
103
141
  value.to_i.to_s == value.to_s
104
142
  end
@@ -7,5 +7,6 @@ module Extension
7
7
  REGISTRATION_UUID_KEY = "EXTENSION_UUID"
8
8
  SPECIFICATION_IDENTIFIER_KEY = "EXTENSION_TYPE"
9
9
  TITLE_KEY = "EXTENSION_TITLE"
10
+ RESOURCE_URL_KEY = "EXTENSION_RESOURCE_URL"
10
11
  end
11
12
  end
@@ -19,16 +19,6 @@ module Extension
19
19
  YARN_RUN_SCRIPT_NAME = %w(build).freeze
20
20
  private_constant :YARN_INSTALL_COMMAND, :YARN_INSTALL_PARAMETERS, :YARN_RUN_COMMAND, :YARN_RUN_SCRIPT_NAME
21
21
 
22
- UI_EXTENSIONS_CHECKOUT = "@shopify/checkout-ui-extensions"
23
- UI_EXTENSIONS_ADMIN = "@shopify/admin-ui-extensions"
24
- UI_EXTENSIONS_POST_PURCHASE = "@shopify/post-purchase-ui-extensions"
25
-
26
- PACKAGE_NAMES = [
27
- UI_EXTENSIONS_CHECKOUT,
28
- UI_EXTENSIONS_ADMIN,
29
- UI_EXTENSIONS_POST_PURCHASE,
30
- ].freeze
31
-
32
22
  def create(directory_name, identifier, context)
33
23
  Features::ArgoSetup.new(git_template: git_template).call(directory_name, identifier, context)
34
24
  end
@@ -54,7 +44,7 @@ module Extension
54
44
  def renderer_package(context)
55
45
  js_system = ShopifyCli::JsSystem.new(ctx: context)
56
46
  Tasks::FindNpmPackages
57
- .exactly_one_of(*PACKAGE_NAMES, js_system: js_system)
47
+ .exactly_one_of(renderer_package_name, js_system: js_system)
58
48
  .unwrap { |err| raise err }
59
49
  rescue Extension::PackageResolutionFailed
60
50
  context.abort(
@@ -1,46 +1,14 @@
1
1
  module Extension
2
2
  module Features
3
3
  class ArgoRuntime
4
- include SmartProperties
5
-
6
- UI_EXTENSIONS_CHECKOUT_RUN = "@shopify/checkout-ui-extensions-run"
7
- UI_EXTENSIONS_ADMIN_RUN = "@shopify/admin-ui-extensions-run"
8
-
9
- ADMIN_RUN_FLAGS = [
10
- :api_key,
11
- :name,
12
- :port,
13
- :public_url,
14
- :renderer_version,
15
- :shop,
16
- :uuid,
4
+ RUNTIMES = [
5
+ Runtimes::Admin.new,
6
+ Runtimes::CheckoutPostPurchase.new,
7
+ Runtimes::CheckoutUiExtension.new,
17
8
  ]
18
9
 
19
- CHECKOUT_RUN_FLAGS = [
20
- :port,
21
- :public_url,
22
- ]
23
-
24
- property! :renderer, accepts: Models::NpmPackage
25
- property! :cli, accepts: Models::NpmPackage
26
-
27
- def supports?(flag)
28
- case cli
29
- when admin?
30
- ADMIN_RUN_FLAGS.include?(flag.to_sym)
31
- when checkout?
32
- CHECKOUT_RUN_FLAGS.include?(flag.to_sym)
33
- end
34
- end
35
-
36
- private
37
-
38
- def admin?
39
- ->(cli) { cli.name == UI_EXTENSIONS_ADMIN_RUN }
40
- end
41
-
42
- def checkout?
43
- ->(cli) { cli.name == UI_EXTENSIONS_CHECKOUT_RUN }
10
+ def self.find(cli_package:, identifier:)
11
+ RUNTIMES.find { |runtime| runtime.active_runtime?(cli_package, identifier) }
44
12
  end
45
13
  end
46
14
  end
@@ -7,11 +7,12 @@ module Extension
7
7
  NPM_SERVE_COMMAND = %w(run-script server)
8
8
 
9
9
  property! :specification_handler, accepts: Extension::Models::SpecificationHandlers::Default
10
- property! :argo_runtime, accepts: Features::ArgoRuntime
10
+ property! :argo_runtime, accepts: -> (runtime) { runtime.class < Features::Runtimes::Base }
11
11
  property! :context, accepts: ShopifyCli::Context
12
12
  property! :port, accepts: Integer, default: 39351
13
13
  property :tunnel_url, accepts: String, default: nil
14
14
  property! :js_system, accepts: ->(jss) { jss.respond_to?(:call) }, default: ShopifyCli::JsSystem
15
+ property :resource_url, accepts: String, default: nil
15
16
 
16
17
  def call
17
18
  validate_env!
@@ -22,6 +23,10 @@ module Extension
22
23
  end
23
24
  end
24
25
 
26
+ def resource_url
27
+ super || ExtensionProject.current(force_reload: true).resource_url
28
+ end
29
+
25
30
  private
26
31
 
27
32
  def start_server
@@ -57,6 +62,7 @@ module Extension
57
62
  ShopifyCli::Tasks::EnsureDevStore.call(context) if required_fields.include?(:shop)
58
63
 
59
64
  project = ExtensionProject.current
65
+ ensure_resource_resource_url! if specification_handler.supplies_resource_url?
60
66
 
61
67
  return if required_fields.all? do |field|
62
68
  value = project.env.public_send(field)
@@ -77,8 +83,31 @@ module Extension
77
83
  options << "--uuid=#{project.registration_uuid}" if argo_runtime.supports?(:uuid)
78
84
  options << "--publicUrl=#{tunnel_url}" if !tunnel_url.nil? && argo_runtime.supports?(:public_url)
79
85
  options << "--name=#{project.title}" if argo_runtime.supports?(:name)
86
+ options << "--resourceUrl=#{resource_url}" if !resource_url.nil? && argo_runtime.supports?(:resource_url)
80
87
  end
81
88
  end
89
+
90
+ def ensure_resource_resource_url!
91
+ project = ExtensionProject.current(force_reload: true)
92
+
93
+ ShopifyCli::Result
94
+ .wrap(project.resource_url)
95
+ .rescue { specification_handler.build_resource_url(shop: project.env.shop, context: context) }
96
+ .then(&method(:persist_resource_url))
97
+ .unwrap do |nil_or_exception|
98
+ case nil_or_exception
99
+ when nil
100
+ context.warn(context.message("warnings.resource_url_auto_generation_failed", project.env.shop))
101
+ else
102
+ context.abort(nil_or_exception)
103
+ end
104
+ end
105
+ end
106
+
107
+ def persist_resource_url(resource_url)
108
+ ExtensionProject.update_env_file(context: context, resource_url: resource_url)
109
+ resource_url
110
+ end
82
111
  end
83
112
  end
84
113
  end