shopify-cli 1.8.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +1 -0
  3. data/.github/workflows/build.yml +28 -0
  4. data/.rubocop_todo.yml +15 -2
  5. data/CHANGELOG.md +24 -1
  6. data/Gemfile.lock +4 -4
  7. data/README.md +2 -1
  8. data/dev.yml +3 -0
  9. data/lib/graphql/extension_create.graphql +17 -2
  10. data/lib/project_types/extension/cli.rb +8 -0
  11. data/lib/project_types/extension/commands/extension_command.rb +4 -4
  12. data/lib/project_types/extension/commands/push.rb +2 -2
  13. data/lib/project_types/extension/commands/register.rb +4 -3
  14. data/lib/project_types/extension/commands/serve.rb +62 -28
  15. data/lib/project_types/extension/commands/tunnel.rb +3 -1
  16. data/lib/project_types/extension/extension_project.rb +16 -4
  17. data/lib/project_types/extension/extension_project_keys.rb +2 -1
  18. data/lib/project_types/extension/features/argo.rb +19 -44
  19. data/lib/project_types/extension/features/argo_runtime.rb +84 -0
  20. data/lib/project_types/extension/features/argo_serve.rb +80 -0
  21. data/lib/project_types/extension/features/argo_serve_options.rb +41 -0
  22. data/lib/project_types/extension/features/argo_setup.rb +1 -1
  23. data/lib/project_types/extension/messages/message_loading.rb +3 -1
  24. data/lib/project_types/extension/messages/messages.rb +5 -4
  25. data/lib/project_types/extension/models/npm_package.rb +14 -0
  26. data/lib/project_types/extension/models/registration.rb +1 -0
  27. data/lib/project_types/extension/models/specification.rb +3 -0
  28. data/lib/project_types/extension/models/specification_handlers/checkout_argo_extension.rb +18 -0
  29. data/lib/project_types/extension/models/specification_handlers/default.rb +49 -1
  30. data/lib/project_types/extension/models/version.rb +1 -1
  31. data/lib/project_types/extension/tasks/choose_next_available_port.rb +36 -0
  32. data/lib/project_types/extension/tasks/configure_features.rb +4 -0
  33. data/lib/project_types/extension/tasks/converters/registration_converter.rb +2 -0
  34. data/lib/project_types/extension/tasks/find_npm_packages.rb +106 -0
  35. data/lib/project_types/node/commands/generate.rb +0 -22
  36. data/lib/project_types/node/messages/messages.rb +4 -4
  37. data/lib/project_types/rails/messages/messages.rb +4 -4
  38. data/lib/project_types/script/cli.rb +7 -8
  39. data/lib/project_types/script/commands/create.rb +0 -7
  40. data/lib/project_types/script/commands/push.rb +3 -3
  41. data/lib/project_types/script/config/extension_points.yml +4 -0
  42. data/lib/project_types/script/errors.rb +0 -19
  43. data/lib/project_types/script/forms/create.rb +3 -14
  44. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +5 -5
  45. data/lib/project_types/script/graphql/get_app_scripts.graphql +6 -0
  46. data/lib/project_types/script/graphql/script_service_proxy.graphql +1 -2
  47. data/lib/project_types/script/layers/application/build_script.rb +1 -2
  48. data/lib/project_types/script/layers/application/create_script.rb +30 -51
  49. data/lib/project_types/script/layers/application/extension_points.rb +3 -2
  50. data/lib/project_types/script/layers/application/push_script.rb +5 -5
  51. data/lib/project_types/script/layers/domain/errors.rb +0 -2
  52. data/lib/project_types/script/layers/domain/extension_point.rb +56 -46
  53. data/lib/project_types/script/layers/domain/metadata.rb +18 -25
  54. data/lib/project_types/script/layers/domain/push_package.rb +4 -4
  55. data/lib/project_types/script/layers/domain/script_project.rb +54 -0
  56. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +15 -16
  57. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +13 -7
  58. data/lib/project_types/script/layers/infrastructure/command_runner.rb +19 -0
  59. data/lib/project_types/script/layers/infrastructure/errors.rb +40 -11
  60. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +12 -13
  61. data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +9 -10
  62. data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +6 -7
  63. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +172 -0
  64. data/lib/project_types/script/layers/infrastructure/script_service.rb +21 -72
  65. data/lib/project_types/script/messages/messages.rb +20 -50
  66. data/lib/project_types/script/tasks/ensure_env.rb +85 -0
  67. data/lib/project_types/script/ui/error_handler.rb +32 -30
  68. data/lib/shopify-cli/context.rb +28 -0
  69. data/lib/shopify-cli/js_system.rb +2 -2
  70. data/lib/shopify-cli/messages/messages.rb +50 -45
  71. data/lib/shopify-cli/method_object.rb +4 -4
  72. data/lib/shopify-cli/oauth.rb +9 -3
  73. data/lib/shopify-cli/packager.rb +1 -1
  74. data/lib/shopify-cli/partners_api/organizations.rb +3 -3
  75. data/lib/shopify-cli/resolve_constant.rb +1 -1
  76. data/lib/shopify-cli/resources/env_file.rb +1 -1
  77. data/lib/shopify-cli/shopifolk.rb +1 -1
  78. data/lib/shopify-cli/tasks/select_org_and_shop.rb +6 -4
  79. data/lib/shopify-cli/transform_data_structure.rb +1 -1
  80. data/lib/shopify-cli/tunnel.rb +22 -1
  81. data/lib/shopify-cli/version.rb +1 -1
  82. data/lib/shopify_cli.rb +0 -1
  83. data/vendor/deps/smart_properties/REVISION +1 -1
  84. data/vendor/deps/smart_properties/lib/smart_properties/property.rb +7 -1
  85. data/vendor/deps/smart_properties/lib/smart_properties/version.rb +1 -1
  86. metadata +16 -12
  87. data/.travis.yml +0 -14
  88. data/lib/project_types/script/commands/disable.rb +0 -25
  89. data/lib/project_types/script/commands/enable.rb +0 -80
  90. data/lib/project_types/script/graphql/shop_script_delete.graphql +0 -14
  91. data/lib/project_types/script/graphql/shop_script_update_or_create.graphql +0 -28
  92. data/lib/project_types/script/layers/application/disable_script.rb +0 -21
  93. data/lib/project_types/script/layers/application/enable_script.rb +0 -23
  94. data/lib/project_types/script/layers/infrastructure/config_ui_repository.rb +0 -46
  95. data/lib/project_types/script/script_project.rb +0 -64
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30e766112b0e09d6de0e907ecf7e002377fe8a0ecb6776bf0975ec1677a5858a
4
- data.tar.gz: 3fbcc004481a0b06c8ccfcd0fb5890d7ab4bf6ee778a6b4dc43c773508376a05
3
+ metadata.gz: 45acefe059ce1e83e77f20be8ee3b7815c5be28f834ef7697dd9000175884c4f
4
+ data.tar.gz: a1abb2765725c6a1d593f869c323f179429b7c21d25de9bfa8649e5817dc9d6e
5
5
  SHA512:
6
- metadata.gz: d3b9f2da8984619e58cb73a5a066bd67b7b0e3f050a82f794b36079d3f0850d8c57e4e346e7f6ae0c0ea01601d07e26d54359cced3e132d23246ad88bbed314f
7
- data.tar.gz: 1ec7d262e39e6b112cf25a35b85788faeb77fce56febdeb46e0f8630608ca19ec0eb032b668302515e23fbfa0831ad25492439cc8cb35e5fb376c6e2277e4596
6
+ metadata.gz: 5f73366ea4f16f7d5615fe6ae62edd58692f85288b7f6056be61a4cbcbf72c94a1979cc806255fe55c82504f42433c1264ca9b479203639dbaf209273189cccc
7
+ data.tar.gz: 556ef6bdc6338c156d1ef6c9f9971e37d687cd7c1c8c93f6dc609a053f2303cde7d03b968e2e0e2336e59bc5b89539e8fb3a12f38e3427bbddb29bf448d7f130
@@ -29,3 +29,4 @@ Fixes #0000 <!-- link to issue if one exists -->
29
29
  -->
30
30
  - [ ] I've added a CHANGELOG entry for this PR (if the change is public-facing)
31
31
  - [ ] I've considered possible cross-platform impacts (Mac, Linux, Windows).
32
+ - [ ] I've left the version number as is (we'll handle incrmenting this when releasing).
@@ -0,0 +1,28 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ name: Ruby ${{ matrix.version }}
8
+ runs-on: macos-latest
9
+ strategy:
10
+ matrix:
11
+ version:
12
+ - 3.0.0
13
+ - 2.6.6
14
+ - 2.7.1
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+
18
+ - name: Set up Ruby ${{ matrix.version }}
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.version }}
22
+ bundler-cache: true
23
+
24
+ - name: Install Dependencies
25
+ run: bundle install
26
+
27
+ - name: Run Tests
28
+ run: bundle exec rake
data/.rubocop_todo.yml CHANGED
@@ -1,11 +1,24 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-12-01 16:33:09 UTC using RuboCop version 1.4.1.
3
+ # on 2021-04-08 18:25:36 UTC using RuboCop version 1.12.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 30
9
+ # Offense count: 35
10
10
  Minitest/MultipleAssertions:
11
11
  Max: 9
12
+
13
+ # Offense count: 1
14
+ # Cop supports --auto-correct.
15
+ Style/PerlBackrefs:
16
+ Exclude:
17
+ - 'lib/docgen/markdown.rb'
18
+
19
+ # Offense count: 2
20
+ # Cop supports --auto-correct.
21
+ Style/RedundantBegin:
22
+ Exclude:
23
+ - 'lib/shopify-cli/shopifolk.rb'
24
+ - 'test/shopify-cli/tunnel_test.rb'
data/CHANGELOG.md CHANGED
@@ -1,9 +1,32 @@
1
1
  Unreleased
2
2
  ------
3
3
 
4
- Version 1.8.0
4
+ Version 1.12.0
5
+ --------------
6
+ * [1255](https://github.com/Shopify/shopify-app-cli/pull/1255): Fix beta flag checks when running `shopify serve`
7
+
8
+ Version 1.11.0
9
+ --------------
10
+ * [#1221](https://github.com/Shopify/shopify-app-cli/pull/1221): Prioritizes returning an HTTPS URL over HTTP from `shopify tunnel status`.
11
+ * [#1223](https://github.com/Shopify/shopify-app-cli/pull/1233): Running `shopify serve` in an extension project now automatically runs `shopify tunnel`.
12
+ * [#1225](https://github.com/Shopify/shopify-app-cli/pull/1225): Improved handling of "account not found" scenario, plus improvements to related tests and UX messaging
13
+ * [#1229](https://github.com/Shopify/shopify-app-cli/pull/1229): Allows Checkout Extensions to specify configuration attributes in their extension.config.yml file.
14
+ * [#1238](https://github.com/Shopify/shopify-app-cli/pull/1238): Auto Tunnel Support for Checkout Extension
15
+
16
+ Version 1.10.0
17
+ --------------
18
+ * Updating internal features in development
19
+
20
+ Version 1.9.1
5
21
  -------------
22
+ * [1201](https://github.com/Shopify/shopify-app-cli/pull/1201) Determine Argo Renderer Dynamically. This fixes `shopify serve` and `shopify push` for extensions.
6
23
 
24
+ Version 1.9.0
25
+ -------------
26
+ * [1181](https://github.com/Shopify/shopify-app-cli/pull/1181): Remove the subcommand references of the `generate` command for node apps (fixes [1176](https://github.com/Shopify/shopify-app-cli/issues/1176))
27
+
28
+ Version 1.8.0
29
+ -------------
7
30
  * [1119](https://github.com/Shopify/shopify-app-cli/pull/1119): Enable guest serialization for scripts
8
31
 
9
32
  Version 1.7.1
data/Gemfile.lock CHANGED
@@ -22,7 +22,7 @@ GEM
22
22
  ruby-progressbar
23
23
  mocha (1.11.2)
24
24
  parallel (1.20.1)
25
- parser (3.0.0.0)
25
+ parser (3.0.1.0)
26
26
  ast (~> 2.4.1)
27
27
  pry (0.13.1)
28
28
  coderay (~> 1.1)
@@ -34,8 +34,8 @@ GEM
34
34
  rainbow (3.0.0)
35
35
  rake (13.0.1)
36
36
  regexp_parser (2.1.1)
37
- rexml (3.2.4)
38
- rubocop (1.11.0)
37
+ rexml (3.2.5)
38
+ rubocop (1.12.1)
39
39
  parallel (~> 1.10)
40
40
  parser (>= 3.0.0.0)
41
41
  rainbow (>= 2.2.2, < 4.0)
@@ -76,4 +76,4 @@ DEPENDENCIES
76
76
  webmock
77
77
 
78
78
  BUNDLED WITH
79
- 1.17.3
79
+ 2.1.4
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # [Shopify App CLI](https://shopify.dev/tools/cli)
2
2
 
3
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md)[![Build Status](https://travis-ci.com/Shopify/shopify-app-cli.svg?token=qtPazgjyosjEEgxgq7VZ&branch=master)](https://travis-ci.com/Shopify/shopify-app-cli)
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md)
4
+ [![Build Status](https://github.com/Shopify/shopify-app-cli/workflows/CI/badge.svg)](https://github.com/Shopify/shopify-app-cli/actions)
4
5
 
5
6
  Shopify App CLI helps you build Shopify apps faster. It quickly generates Node.js and Ruby on Rails apps and automates many common development tasks.
6
7
 
data/dev.yml CHANGED
@@ -5,6 +5,9 @@ type:
5
5
  up:
6
6
  - ruby: 2.5.1
7
7
  - bundler
8
+ - node:
9
+ version: 14.9.0
10
+ yarn: true
8
11
 
9
12
  test:
10
13
  desc: 'Run tests.'
@@ -1,7 +1,22 @@
1
- mutation ExtensionCreate($api_key: String!, $type: ExtensionType!, $title: String!, $config: JSON!, $extension_context: String) {
2
- extensionCreate(input: {apiKey: $api_key, type: $type, title: $title, config: $config, context: $extension_context}) {
1
+ mutation ExtensionCreate(
2
+ $api_key: String!
3
+ $type: ExtensionType!
4
+ $title: String!
5
+ $config: JSON!
6
+ $extension_context: String
7
+ ) {
8
+ extensionCreate(
9
+ input: {
10
+ apiKey: $api_key
11
+ type: $type
12
+ title: $title
13
+ config: $config
14
+ context: $extension_context
15
+ }
16
+ ) {
3
17
  extensionRegistration {
4
18
  id
19
+ uuid
5
20
  type
6
21
  title
7
22
  draftVersion {
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Extension
4
+ class PackageResolutionFailed < RuntimeError; end
5
+
4
6
  class Project < ShopifyCli::ProjectType
5
7
  hidden_feature
6
8
  title("App Extension")
@@ -36,6 +38,8 @@ module Extension
36
38
  autoload :UpdateDraft, Project.project_filepath("tasks/update_draft")
37
39
  autoload :FetchSpecifications, Project.project_filepath("tasks/fetch_specifications")
38
40
  autoload :ConfigureFeatures, Project.project_filepath("tasks/configure_features")
41
+ autoload :ChooseNextAvailablePort, Project.project_filepath("tasks/choose_next_available_port")
42
+ autoload :FindNpmPackages, Project.project_filepath("tasks/find_npm_packages")
39
43
 
40
44
  module Converters
41
45
  autoload :RegistrationConverter, Project.project_filepath("tasks/converters/registration_converter")
@@ -57,11 +61,14 @@ module Extension
57
61
  end
58
62
 
59
63
  module Features
64
+ autoload :ArgoServe, Project.project_filepath("features/argo_serve")
65
+ autoload :ArgoServeOptions, Project.project_filepath("features/argo_serve_options")
60
66
  autoload :ArgoSetup, Project.project_filepath("features/argo_setup")
61
67
  autoload :ArgoSetupStep, Project.project_filepath("features/argo_setup_step")
62
68
  autoload :ArgoSetupSteps, Project.project_filepath("features/argo_setup_steps")
63
69
  autoload :ArgoDependencies, Project.project_filepath("features/argo_dependencies")
64
70
  autoload :ArgoConfig, Project.project_filepath("features/argo_config")
71
+ autoload :ArgoRuntime, Project.project_filepath("features/argo_runtime")
65
72
  autoload :Argo, Project.project_filepath("features/argo")
66
73
  end
67
74
 
@@ -77,6 +84,7 @@ module Extension
77
84
  autoload :Specification, Project.project_filepath("models/specification")
78
85
  autoload :Specifications, Project.project_filepath("models/specifications")
79
86
  autoload :LazySpecificationHandler, Project.project_filepath("models/lazy_specification_handler")
87
+ autoload :NpmPackage, Project.project_filepath("models/npm_package")
80
88
  end
81
89
 
82
90
  autoload :ExtensionProjectKeys, Project.project_filepath("extension_project_keys")
@@ -8,16 +8,16 @@ module Extension
8
8
  @project ||= ExtensionProject.current
9
9
  end
10
10
 
11
- def extension_type
12
- @extension_type ||= begin
13
- identifier = project.extension_type_identifier
11
+ def specification_handler
12
+ @specification_handler ||= begin
13
+ identifier = project.specification_identifier
14
14
  Models::LazySpecificationHandler.new(identifier) do
15
15
  specifications = Models::Specifications.new(
16
16
  fetch_specifications: Tasks::FetchSpecifications.new(api_key: project.app.api_key, context: @ctx)
17
17
  )
18
18
 
19
19
  unless specifications.valid?(identifier)
20
- @ctx.abort(@ctx.message("errors.unknown_type", project.extension_type_identifier))
20
+ @ctx.abort(@ctx.message("errors.unknown_type", project.specification_identifier))
21
21
  end
22
22
 
23
23
  specifications[identifier]
@@ -59,8 +59,8 @@ module Extension
59
59
  context: @ctx,
60
60
  api_key: project.app.api_key,
61
61
  registration_id: project.registration_id,
62
- config: extension_type.config(@ctx),
63
- extension_context: extension_type.extension_context(@ctx)
62
+ config: specification_handler.config(@ctx),
63
+ extension_context: specification_handler.extension_context(@ctx)
64
64
  )
65
65
  end
66
66
  end
@@ -27,7 +27,7 @@ module Extension
27
27
  private
28
28
 
29
29
  def confirm_registration
30
- @ctx.puts(@ctx.message("register.confirm_info", extension_type.name))
30
+ @ctx.puts(@ctx.message("register.confirm_info", specification_handler.name))
31
31
  CLI::UI::Prompt.confirm(@ctx.message("register.confirm_question"))
32
32
  end
33
33
 
@@ -37,10 +37,10 @@ module Extension
37
37
  Tasks::CreateExtension.call(
38
38
  context: @ctx,
39
39
  api_key: app.api_key,
40
- type: extension_type.graphql_identifier,
40
+ type: specification_handler.graphql_identifier,
41
41
  title: project.title,
42
42
  config: {},
43
- extension_context: extension_type.extension_context(@ctx)
43
+ extension_context: specification_handler.extension_context(@ctx)
44
44
  )
45
45
  end
46
46
 
@@ -50,6 +50,7 @@ module Extension
50
50
  api_key: app.api_key,
51
51
  api_secret: app.secret,
52
52
  registration_id: registration.id,
53
+ registration_uuid: registration.uuid,
53
54
  title: project.title
54
55
  )
55
56
  end
@@ -3,49 +3,83 @@
3
3
  module Extension
4
4
  module Commands
5
5
  class Serve < ExtensionCommand
6
- YARN_SERVE_COMMAND = %w(server)
7
- NPM_SERVE_COMMAND = %w(run-script server)
6
+ DEFAULT_PORT = 39351
7
+
8
+ options do |parser, flags|
9
+ parser.on("-t", "--[no-]tunnel", "Establish an ngrok tunnel") { |tunnel| flags[:tunnel] = tunnel }
10
+ end
11
+
12
+ class RuntimeConfiguration
13
+ include SmartProperties
14
+
15
+ property! :tunnel_url, accepts: String, default: ""
16
+ property! :tunnel_requested, accepts: [true, false], reader: :tunnel_requested?, default: true
17
+ property! :port, accepts: (1...(2**16)), default: DEFAULT_PORT
18
+ end
8
19
 
9
20
  def call(_args, _command_name)
10
- if argo_admin?
11
- ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop])
12
- ShopifyCli::Tasks::EnsureDevStore.call(@ctx)
13
- validate_env
14
- end
15
-
16
- CLI::UI::Frame.open(@ctx.message("serve.frame_title")) do
17
- yarn_serve_command = YARN_SERVE_COMMAND
18
- npm_serve_command = NPM_SERVE_COMMAND
19
- if argo_admin?
20
- serve_args = %W(--shop=#{project.env.shop} --apiKey=#{project.env.api_key})
21
- yarn_serve_command += serve_args
22
- npm_serve_command += %w(--) + serve_args
23
- end
24
- success = ShopifyCli::JsSystem.call(@ctx, yarn: yarn_serve_command, npm: npm_serve_command)
25
- @ctx.abort(@ctx.message("serve.serve_failure_message")) unless success
26
- end
21
+ config = RuntimeConfiguration.new(
22
+ tunnel_requested: tunnel_requested?
23
+ )
24
+
25
+ ShopifyCli::Result
26
+ .success(config)
27
+ .then(&method(:find_available_port))
28
+ .then(&method(:start_tunnel_if_required))
29
+ .then(&method(:serve))
30
+ .unwrap { |error| raise error }
27
31
  end
28
32
 
29
33
  def self.help
30
34
  <<~HELP
31
35
  Serve your extension in a local simulator for development.
32
36
  Usage: {{command:#{ShopifyCli::TOOL_NAME} serve}}
37
+ Options:
38
+ {{command:--tunnel=TUNNEL}} Establish an ngrok tunnel (default: false)
33
39
  HELP
34
40
  end
35
41
 
36
42
  private
37
43
 
38
- def argo_admin?
39
- ShopifyCli::Shopifolk.check &&
40
- ShopifyCli::Feature.enabled?(:argo_admin_beta) &&
41
- extension_type.specification.features&.argo&.surface == "admin"
44
+ def tunnel_requested?
45
+ tunnel = options.flags[:tunnel]
46
+ tunnel.nil? || !!tunnel
47
+ end
48
+
49
+ def find_available_port(runtime_configuration)
50
+ return runtime_configuration unless specification_handler.choose_port?(@ctx)
51
+
52
+ chosen_port = Tasks::ChooseNextAvailablePort
53
+ .call(from: runtime_configuration.port)
54
+ .unwrap { |_error| @ctx.abort(@ctx.message("serve.no_available_ports_found")) }
55
+ runtime_configuration.tap { |c| c.port = chosen_port }
56
+ end
57
+
58
+ def start_tunnel_if_required(runtime_configuration)
59
+ return runtime_configuration unless specification_handler.establish_tunnel?(@ctx)
60
+ return runtime_configuration unless runtime_configuration.tunnel_requested?
61
+
62
+ return start_tunnel(runtime_configuration) if can_start_tunnel?(runtime_configuration)
63
+ @ctx.abort(@ctx.message("serve.tunnel_already_running"))
64
+ end
65
+
66
+ def can_start_tunnel?(runtime_configuration)
67
+ return true if ShopifyCli::Tunnel.urls.empty?
68
+ ShopifyCli::Tunnel.running_on?(runtime_configuration.port)
69
+ end
70
+
71
+ def start_tunnel(runtime_configuration)
72
+ tunnel_url = ShopifyCli::Tunnel.start(@ctx, port: runtime_configuration.port)
73
+ runtime_configuration.tap { |c| c.tunnel_url = tunnel_url }
42
74
  end
43
75
 
44
- def validate_env
45
- ExtensionProject.reload
46
- @ctx.abort(@ctx.message("serve.serve_missing_information")) if
47
- project.env.shop.nil? || project.env.api_key.nil? ||
48
- project.env.shop.strip.empty? || project.env.api_key.strip.empty?
76
+ def serve(runtime_configuration)
77
+ specification_handler.serve(
78
+ context: @ctx,
79
+ tunnel_url: runtime_configuration.tunnel_url,
80
+ port: runtime_configuration.port
81
+ )
82
+ runtime_configuration
49
83
  end
50
84
  end
51
85
  end
@@ -37,7 +37,9 @@ module Extension
37
37
  private
38
38
 
39
39
  def status
40
- tunnel_url = ShopifyCli::Tunnel.urls.first
40
+ tunnel_urls = ShopifyCli::Tunnel.urls
41
+ tunnel_url = tunnel_urls.find { |url| url.start_with?("https://") }
42
+ tunnel_url = tunnel_urls.first if tunnel_url.nil?
41
43
 
42
44
  if tunnel_url.nil?
43
45
  @ctx.puts(@ctx.message("tunnel.no_tunnel_running"))
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  require "shopify_cli"
3
+ require "securerandom"
3
4
 
4
5
  module Extension
5
6
  class ExtensionProject < ShopifyCli::Project
@@ -9,17 +10,20 @@ module Extension
9
10
  context,
10
11
  project_type: :extension,
11
12
  organization_id: nil,
12
- "#{ExtensionProjectKeys::EXTENSION_TYPE_KEY}": type
13
+ "#{ExtensionProjectKeys::SPECIFICATION_IDENTIFIER_KEY}": type
13
14
  )
14
15
  end
15
16
 
16
- def write_env_file(context:, title:, api_key: "", api_secret: "", registration_id: nil)
17
+ def write_env_file(
18
+ context:, title:, api_key: "", api_secret: "", registration_id: nil, registration_uuid: nil
19
+ )
17
20
  ShopifyCli::Resources::EnvFile.new(
18
21
  api_key: api_key,
19
22
  secret: api_secret,
20
23
  extra: {
21
24
  ExtensionProjectKeys::TITLE_KEY => title,
22
25
  ExtensionProjectKeys::REGISTRATION_ID_KEY => registration_id,
26
+ ExtensionProjectKeys::REGISTRATION_UUID_KEY => registration_uuid || generate_temporary_uuid,
23
27
  }.compact
24
28
  ).write(context)
25
29
 
@@ -49,8 +53,8 @@ module Extension
49
53
  get_extra_field(ExtensionProjectKeys::TITLE_KEY)
50
54
  end
51
55
 
52
- def extension_type_identifier
53
- config[ExtensionProjectKeys::EXTENSION_TYPE_KEY]
56
+ def specification_identifier
57
+ config[ExtensionProjectKeys::SPECIFICATION_IDENTIFIER_KEY]
54
58
  end
55
59
 
56
60
  def registration_id?
@@ -63,10 +67,18 @@ module Extension
63
67
  get_extra_field(ExtensionProjectKeys::REGISTRATION_ID_KEY).to_i
64
68
  end
65
69
 
70
+ def registration_uuid
71
+ get_extra_field(ExtensionProjectKeys::REGISTRATION_UUID_KEY)
72
+ end
73
+
66
74
  def reload
67
75
  @env = nil
68
76
  end
69
77
 
78
+ def self.generate_temporary_uuid
79
+ "dev-#{SecureRandom.uuid}"
80
+ end
81
+
70
82
  private
71
83
 
72
84
  def get_extra_field(key)