shopify-cli 1.7.0 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +28 -0
  3. data/.rubocop_todo.yml +15 -2
  4. data/CHANGELOG.md +21 -0
  5. data/Gemfile.lock +14 -14
  6. data/README.md +2 -1
  7. data/dev.yml +3 -0
  8. data/lib/docgen/markdown.rb +1 -1
  9. data/lib/graphql/extension_create.graphql +17 -2
  10. data/lib/graphql/fetch_specifications.graphql +14 -0
  11. data/lib/project_types/extension/cli.rb +4 -10
  12. data/lib/project_types/extension/commands/create.rb +2 -2
  13. data/lib/project_types/extension/commands/extension_command.rb +10 -6
  14. data/lib/project_types/extension/commands/push.rb +2 -2
  15. data/lib/project_types/extension/commands/register.rb +6 -5
  16. data/lib/project_types/extension/commands/serve.rb +1 -7
  17. data/lib/project_types/extension/extension_project.rb +19 -4
  18. data/lib/project_types/extension/extension_project_keys.rb +2 -1
  19. data/lib/project_types/extension/features/argo.rb +18 -34
  20. data/lib/project_types/extension/features/argo_renderer_package.rb +47 -0
  21. data/lib/project_types/extension/features/argo_serve.rb +69 -0
  22. data/lib/project_types/extension/features/argo_setup.rb +1 -1
  23. data/lib/project_types/extension/forms/questions/ask_type.rb +16 -5
  24. data/lib/project_types/extension/messages/message_loading.rb +3 -1
  25. data/lib/project_types/extension/messages/messages.rb +6 -6
  26. data/lib/project_types/extension/models/registration.rb +1 -0
  27. data/lib/project_types/extension/models/specification.rb +6 -2
  28. data/lib/project_types/extension/models/specification_handlers/default.rb +9 -1
  29. data/lib/project_types/extension/models/specifications.rb +12 -1
  30. data/lib/project_types/extension/models/version.rb +1 -1
  31. data/lib/project_types/extension/tasks/configure_features.rb +3 -1
  32. data/lib/project_types/extension/tasks/converters/registration_converter.rb +2 -0
  33. data/lib/project_types/extension/tasks/fetch_specifications.rb +8 -28
  34. data/lib/project_types/node/commands/generate.rb +0 -22
  35. data/lib/project_types/node/forms/create.rb +10 -1
  36. data/lib/project_types/node/messages/messages.rb +5 -4
  37. data/lib/project_types/rails/forms/create.rb +11 -1
  38. data/lib/project_types/rails/messages/messages.rb +5 -4
  39. data/lib/project_types/script/cli.rb +7 -7
  40. data/lib/project_types/script/commands/create.rb +2 -7
  41. data/lib/project_types/script/commands/push.rb +3 -3
  42. data/lib/project_types/script/config/extension_points.yml +27 -10
  43. data/lib/project_types/script/errors.rb +0 -35
  44. data/lib/project_types/script/forms/create.rb +3 -14
  45. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +5 -5
  46. data/lib/project_types/script/graphql/get_app_scripts.graphql +6 -0
  47. data/lib/project_types/script/graphql/script_service_proxy.graphql +1 -2
  48. data/lib/project_types/script/layers/application/create_script.rb +32 -22
  49. data/lib/project_types/script/layers/application/extension_points.rb +3 -2
  50. data/lib/project_types/script/layers/application/push_script.rb +6 -3
  51. data/lib/project_types/script/layers/domain/config_ui.rb +16 -0
  52. data/lib/project_types/script/layers/domain/errors.rb +16 -0
  53. data/lib/project_types/script/layers/domain/extension_point.rb +60 -45
  54. data/lib/project_types/script/layers/domain/metadata.rb +18 -25
  55. data/lib/project_types/script/layers/domain/push_package.rb +4 -4
  56. data/lib/project_types/script/layers/domain/script_project.rb +54 -0
  57. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +37 -8
  58. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +5 -40
  59. data/lib/project_types/script/layers/infrastructure/errors.rb +50 -19
  60. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +8 -9
  61. data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +1 -1
  62. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +198 -0
  63. data/lib/project_types/script/layers/infrastructure/script_service.rb +27 -66
  64. data/lib/project_types/script/messages/messages.rb +28 -51
  65. data/lib/project_types/script/tasks/ensure_env.rb +77 -0
  66. data/lib/project_types/script/ui/error_handler.rb +63 -47
  67. data/lib/shopify-cli/context.rb +28 -0
  68. data/lib/shopify-cli/js_system.rb +2 -2
  69. data/lib/shopify-cli/messages/messages.rb +3 -2
  70. data/lib/shopify-cli/method_object.rb +1 -1
  71. data/lib/shopify-cli/oauth.rb +2 -2
  72. data/lib/shopify-cli/packager.rb +1 -1
  73. data/lib/shopify-cli/resolve_constant.rb +1 -1
  74. data/lib/shopify-cli/resources/env_file.rb +1 -1
  75. data/lib/shopify-cli/result.rb +3 -3
  76. data/lib/shopify-cli/tasks/ensure_dev_store.rb +1 -1
  77. data/lib/shopify-cli/transform_data_structure.rb +2 -2
  78. data/lib/shopify-cli/version.rb +1 -1
  79. data/lib/shopify_cli.rb +0 -1
  80. data/vendor/deps/smart_properties/REVISION +1 -1
  81. data/vendor/deps/smart_properties/lib/smart_properties/property.rb +7 -1
  82. data/vendor/deps/smart_properties/lib/smart_properties/version.rb +1 -1
  83. metadata +11 -10
  84. data/.travis.yml +0 -14
  85. data/lib/project_types/script/commands/disable.rb +0 -25
  86. data/lib/project_types/script/commands/enable.rb +0 -80
  87. data/lib/project_types/script/graphql/shop_script_delete.graphql +0 -14
  88. data/lib/project_types/script/graphql/shop_script_update_or_create.graphql +0 -28
  89. data/lib/project_types/script/layers/application/disable_script.rb +0 -21
  90. data/lib/project_types/script/layers/application/enable_script.rb +0 -23
  91. data/lib/project_types/script/script_project.rb +0 -85
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 718e73fd7541d075d7caf66c078dfe9ba3723299aa4fc668164dda9953c5dc7f
4
- data.tar.gz: 116ed7d69bca5345c7120b9ca5e53172afe3bebaceb0a0539a2d128ebab6235f
3
+ metadata.gz: ea41fa5cbfa0eb2bf575fe82111c6be56df6807ed7696e64acc741ef2fa2e6be
4
+ data.tar.gz: 899299251ed4b0a50b0c3a5c5ae55324ebd64e92fbb981da7d4a093df94d5596
5
5
  SHA512:
6
- metadata.gz: 11d8373057ed9d845c71863ba6443a47949a8c4e3c9d281b731638f0a1326be30076c94d38ee2d99a02a3779b4eaabd2a04b656306e4f1cd157888b483fe5946
7
- data.tar.gz: 866966d912d1d65731619afe68fe37c9679852fd41a1e7c0b1eecc80a6182d505e06f0c5608f98ff7b53b8dde52d136ce6ac5e3b037282f62458086df2fabb52
6
+ metadata.gz: 8b757bbf4ef686593f3fe8fdf82da6c83468f40d04bc312476e2bea614d5f75e3d63afe097c149f3de34b35631032c096799f0728b12732dfbbb5bd3e5141384
7
+ data.tar.gz: 2059062ef9aff95cad44d2b4bcad442e2cf82636d6733c065bb83544ac4d0b8cef2a5de3c438d5f252a251fa0cf813b03fc064db407940e3469b476a26c35e0d
@@ -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,8 +1,29 @@
1
1
  Unreleased
2
2
  ------
3
3
 
4
+ Version 1.10.0
5
+ -------------
6
+ * Updating internal features in development
7
+
8
+ Version 1.9.1
9
+ -------------
10
+ * [1201](https://github.com/Shopify/shopify-app-cli/pull/1201) Determine Argo Renderer Dynamically. This fixes `shopify serve` and `shopify push` for extensions.
11
+
12
+ Version 1.9.0
13
+ -------------
14
+ * [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))
15
+
16
+ Version 1.8.0
17
+ -------------
18
+ * [1119](https://github.com/Shopify/shopify-app-cli/pull/1119): Enable guest serialization for scripts
19
+
20
+ Version 1.7.1
21
+ ------
22
+ * Updating internal features in development
23
+
4
24
  Version 1.7.0
5
25
  -----
26
+ * [#1109](https://github.com/Shopify/shopify-app-cli/pull/1109): Abort app generation if name contains disallowed text.
6
27
  * [#1075](https://github.com/Shopify/shopify-app-cli/pull/1075): Add support for kebab-case flags
7
28
 
8
29
  Version 1.6.0
data/Gemfile.lock CHANGED
@@ -4,7 +4,7 @@ GEM
4
4
  addressable (2.7.0)
5
5
  public_suffix (>= 2.0.2, < 5.0)
6
6
  ansi (1.5.0)
7
- ast (2.4.1)
7
+ ast (2.4.2)
8
8
  builder (3.2.4)
9
9
  byebug (11.1.3)
10
10
  coderay (1.1.3)
@@ -22,7 +22,7 @@ GEM
22
22
  ruby-progressbar
23
23
  mocha (1.11.2)
24
24
  parallel (1.20.1)
25
- parser (2.7.2.0)
25
+ parser (3.0.1.0)
26
26
  ast (~> 2.4.1)
27
27
  pry (0.13.1)
28
28
  coderay (~> 1.1)
@@ -33,26 +33,26 @@ GEM
33
33
  public_suffix (4.0.6)
34
34
  rainbow (3.0.0)
35
35
  rake (13.0.1)
36
- regexp_parser (1.8.2)
37
- rexml (3.2.4)
38
- rubocop (1.4.1)
36
+ regexp_parser (2.1.1)
37
+ rexml (3.2.5)
38
+ rubocop (1.12.1)
39
39
  parallel (~> 1.10)
40
- parser (>= 2.7.1.5)
40
+ parser (>= 3.0.0.0)
41
41
  rainbow (>= 2.2.2, < 4.0)
42
- regexp_parser (>= 1.8)
42
+ regexp_parser (>= 1.8, < 3.0)
43
43
  rexml
44
- rubocop-ast (>= 1.1.1)
44
+ rubocop-ast (>= 1.2.0, < 2.0)
45
45
  ruby-progressbar (~> 1.7)
46
- unicode-display_width (>= 1.4.0, < 2.0)
47
- rubocop-ast (1.1.1)
46
+ unicode-display_width (>= 1.4.0, < 3.0)
47
+ rubocop-ast (1.4.1)
48
48
  parser (>= 2.7.1.5)
49
49
  rubocop-minitest (0.10.1)
50
50
  rubocop (>= 0.87)
51
- rubocop-shopify (1.0.7)
52
- rubocop (~> 1.4)
53
- ruby-progressbar (1.10.1)
51
+ rubocop-shopify (2.0.1)
52
+ rubocop (~> 1.11)
53
+ ruby-progressbar (1.11.0)
54
54
  timecop (0.9.2)
55
- unicode-display_width (1.7.0)
55
+ unicode-display_width (2.0.0)
56
56
  webmock (3.9.3)
57
57
  addressable (>= 2.3.6)
58
58
  crack (>= 0.3.2)
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.'
@@ -89,7 +89,7 @@ module RDoc
89
89
  lines.shift if src =~ /\A.*#\ *File/i # remove '# File' comment
90
90
  lines.each do |line|
91
91
  next unless line =~ /^ *(?=\S)/
92
- n = $&.length
92
+ n = Regexp.last_match(0).length
93
93
  indent = n if n < indent
94
94
  break if n == 0
95
95
  end
@@ -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 {
@@ -0,0 +1,14 @@
1
+ query fetchSpecifications($api_key: String!) {
2
+ extensionSpecifications(apiKey: $api_key) {
3
+ name
4
+ identifier
5
+ options {
6
+ managementExperience
7
+ }
8
+ features {
9
+ argo {
10
+ surface
11
+ }
12
+ }
13
+ }
14
+ }
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Extension
4
+ class PackageNotFound < RuntimeError; end
5
+
4
6
  class Project < ShopifyCli::ProjectType
5
7
  hidden_feature
6
8
  title("App Extension")
@@ -57,6 +59,8 @@ module Extension
57
59
  end
58
60
 
59
61
  module Features
62
+ autoload :ArgoRendererPackage, Project.project_filepath("features/argo_renderer_package")
63
+ autoload :ArgoServe, Project.project_filepath("features/argo_serve")
60
64
  autoload :ArgoSetup, Project.project_filepath("features/argo_setup")
61
65
  autoload :ArgoSetupStep, Project.project_filepath("features/argo_setup_step")
62
66
  autoload :ArgoSetupSteps, Project.project_filepath("features/argo_setup_steps")
@@ -81,14 +85,4 @@ module Extension
81
85
 
82
86
  autoload :ExtensionProjectKeys, Project.project_filepath("extension_project_keys")
83
87
  autoload :ExtensionProject, Project.project_filepath("extension_project")
84
-
85
- def self.specifications
86
- @specifications ||= Models::Specifications.new(
87
- fetch_specifications: Tasks::FetchSpecifications
88
- )
89
- end
90
-
91
- def self.specifications=(specifications)
92
- @specifications = specifications
93
- end
94
88
  end
@@ -38,8 +38,8 @@ module Extension
38
38
  Usage: {{command:#{ShopifyCli::TOOL_NAME} create extension}}
39
39
  Options:
40
40
  {{command:--type=TYPE}} The type of extension you would like to create.
41
- {{command:--name=NAME}} The name of your extension (50 characters).”
42
- {{command:--api-key=KEY}} The API key of your app.”
41
+ {{command:--name=NAME}} The name of your extension (50 characters).
42
+ {{command:--api-key=KEY}} The API key of your app.
43
43
  HELP
44
44
  end
45
45
 
@@ -8,15 +8,19 @@ 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
- unless Extension.specifications.valid?(identifier)
16
- @ctx.abort(@ctx.message("errors.unknown_type", project.extension_type_identifier))
15
+ specifications = Models::Specifications.new(
16
+ fetch_specifications: Tasks::FetchSpecifications.new(api_key: project.app.api_key, context: @ctx)
17
+ )
18
+
19
+ unless specifications.valid?(identifier)
20
+ @ctx.abort(@ctx.message("errors.unknown_type", project.specification_identifier))
17
21
  end
18
22
 
19
- Extension.specifications[identifier]
23
+ specifications[identifier]
20
24
  end
21
25
  end
22
26
  end
@@ -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
@@ -12,7 +12,7 @@ module Extension
12
12
 
13
13
  update_project_files(registration)
14
14
 
15
- @ctx.puts(@ctx.message("register.success", project.title, app.title))
15
+ @ctx.puts(@ctx.message("register.success", project.title))
16
16
  @ctx.puts(@ctx.message("register.success_info"))
17
17
  end
18
18
  end
@@ -27,8 +27,8 @@ module Extension
27
27
  private
28
28
 
29
29
  def confirm_registration
30
- @ctx.puts(@ctx.message("register.confirm_info", extension_type.name))
31
- CLI::UI::Prompt.confirm(@ctx.message("register.confirm_question", app.title))
30
+ @ctx.puts(@ctx.message("register.confirm_info", specification_handler.name))
31
+ CLI::UI::Prompt.confirm(@ctx.message("register.confirm_question"))
32
32
  end
33
33
 
34
34
  def register_extension
@@ -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,14 +3,8 @@
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)
8
-
9
6
  def call(_args, _command_name)
10
- CLI::UI::Frame.open(@ctx.message("serve.frame_title")) do
11
- success = ShopifyCli::JsSystem.call(@ctx, yarn: YARN_SERVE_COMMAND, npm: NPM_SERVE_COMMAND)
12
- @ctx.abort(@ctx.message("serve.serve_failure_message")) unless success
13
- end
7
+ specification_handler.serve(@ctx)
14
8
  end
15
9
 
16
10
  def self.help
@@ -9,20 +9,27 @@ module Extension
9
9
  context,
10
10
  project_type: :extension,
11
11
  organization_id: nil,
12
- "#{ExtensionProjectKeys::EXTENSION_TYPE_KEY}": type
12
+ "#{ExtensionProjectKeys::SPECIFICATION_IDENTIFIER_KEY}": type
13
13
  )
14
14
  end
15
15
 
16
- def write_env_file(context:, title:, api_key: "", api_secret: "", registration_id: nil)
16
+ def write_env_file(
17
+ context:, title:, api_key: "", api_secret: "", registration_id: nil, registration_uuid: nil
18
+ )
17
19
  ShopifyCli::Resources::EnvFile.new(
18
20
  api_key: api_key,
19
21
  secret: api_secret,
20
22
  extra: {
21
23
  ExtensionProjectKeys::TITLE_KEY => title,
22
24
  ExtensionProjectKeys::REGISTRATION_ID_KEY => registration_id,
25
+ ExtensionProjectKeys::REGISTRATION_UUID_KEY => registration_uuid || generate_temporary_uuid,
23
26
  }.compact
24
27
  ).write(context)
25
28
 
29
+ reload
30
+ end
31
+
32
+ def reload
26
33
  current.reload unless project_empty?
27
34
  end
28
35
 
@@ -45,8 +52,8 @@ module Extension
45
52
  get_extra_field(ExtensionProjectKeys::TITLE_KEY)
46
53
  end
47
54
 
48
- def extension_type_identifier
49
- config[ExtensionProjectKeys::EXTENSION_TYPE_KEY]
55
+ def specification_identifier
56
+ config[ExtensionProjectKeys::SPECIFICATION_IDENTIFIER_KEY]
50
57
  end
51
58
 
52
59
  def registration_id?
@@ -59,10 +66,18 @@ module Extension
59
66
  get_extra_field(ExtensionProjectKeys::REGISTRATION_ID_KEY).to_i
60
67
  end
61
68
 
69
+ def registration_uuid
70
+ get_extra_field(ExtensionProjectKeys::REGISTRATION_UUID_KEY)
71
+ end
72
+
62
73
  def reload
63
74
  @env = nil
64
75
  end
65
76
 
77
+ def self.generate_temporary_uuid
78
+ "dev-#{SecureRandom.uuid}"
79
+ end
80
+
66
81
  private
67
82
 
68
83
  def get_extra_field(key)
@@ -4,7 +4,8 @@ require "shopify_cli"
4
4
  module Extension
5
5
  module ExtensionProjectKeys
6
6
  REGISTRATION_ID_KEY = "EXTENSION_ID"
7
- EXTENSION_TYPE_KEY = "EXTENSION_TYPE"
7
+ REGISTRATION_UUID_KEY = "EXTENSION_UUID"
8
+ SPECIFICATION_IDENTIFIER_KEY = "EXTENSION_TYPE"
8
9
  TITLE_KEY = "EXTENSION_TITLE"
9
10
  end
10
11
  end
@@ -14,8 +14,8 @@ module Extension
14
14
  SCRIPT_PATH = %w(build main.js).freeze
15
15
 
16
16
  NPM_LIST_COMMAND = %w(list).freeze
17
- YARN_LIST_COMMAND = %w(list --pattern).freeze
18
- NPM_LIST_PARAMETERS = %w(--prod).freeze
17
+ YARN_LIST_COMMAND = %w(list).freeze
18
+ NPM_LIST_PARAMETERS = %w(--prod --depth=1).freeze
19
19
  YARN_LIST_PARAMETERS = %w(--production).freeze
20
20
  private_constant :NPM_LIST_COMMAND, :YARN_LIST_COMMAND, :NPM_LIST_PARAMETERS, :YARN_LIST_PARAMETERS
21
21
 
@@ -39,7 +39,7 @@ module Extension
39
39
  context.abort(context.message("features.argo.missing_file_error")) unless File.exist?(filepath)
40
40
  begin
41
41
  {
42
- renderer_version: extract_argo_renderer_version(context),
42
+ renderer_version: renderer_package(context).version,
43
43
  serialized_script: Base64.strict_encode64(File.read(filepath).chomp),
44
44
  }
45
45
  rescue StandardError
@@ -47,45 +47,29 @@ module Extension
47
47
  end
48
48
  end
49
49
 
50
- private
51
-
52
- def extract_argo_renderer_version(context)
53
- result = run_list_command(context)
54
- found_version = find_version_number(context, result)
55
- context.abort(
56
- context.message("features.argo.dependencies.argo_renderer_package_invalid_version_error")
57
- ) if found_version.nil?
58
- ::Semantic::Version.new(found_version).to_s
59
- rescue ArgumentError
50
+ def renderer_package(context)
51
+ Features::ArgoRendererPackage.from_package_manager(run_list_command(context))
52
+ rescue Extension::PackageNotFound
60
53
  context.abort(
61
- context.message("features.argo.dependencies.argo_renderer_package_invalid_version_error")
54
+ context.message("features.argo.dependencies.argo_missing_renderer_package_error")
62
55
  )
63
56
  end
64
57
 
65
- def find_version_number(context, result)
66
- packages = result.to_json.split('\n')
67
- found_package = packages.find do |package|
68
- package.match(/#{renderer_package_name}@/)
69
- end
70
- if found_package.nil?
71
- error = "'#{renderer_package_name}' not found."
72
- context.abort(
73
- context.message("features.argo.dependencies.argo_missing_renderer_package_error", error)
74
- )
75
- end
76
- found_package.split("@")[2]&.strip
77
- end
58
+ private
78
59
 
79
60
  def run_list_command(context)
80
- js_system = ShopifyCli::JsSystem.new(ctx: context)
81
- result, error, status = js_system.call(
82
- yarn: YARN_LIST_COMMAND + [renderer_package_name] + YARN_LIST_PARAMETERS,
83
- npm: NPM_LIST_COMMAND + [renderer_package_name] + NPM_LIST_PARAMETERS,
61
+ yarn_list = YARN_LIST_COMMAND + YARN_LIST_PARAMETERS
62
+ npm_list = NPM_LIST_COMMAND + NPM_LIST_PARAMETERS
63
+
64
+ result, _error, _status = ShopifyCli::JsSystem.call(
65
+ context,
66
+ yarn: yarn_list,
67
+ npm: npm_list,
84
68
  capture_response: true
85
69
  )
86
- context.abort(
87
- context.message("features.argo.dependencies.argo_missing_renderer_package_error", error)
88
- ) unless status.success?
70
+ # context.abort(
71
+ # context.message("features.argo.dependencies.argo_missing_renderer_package_error", error)
72
+ # ) unless status.success?
89
73
  result
90
74
  end
91
75