shopify-cli 2.2.0 → 2.4.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.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -0
  3. data/.github/ISSUE_TEMPLATE.md +0 -4
  4. data/.github/workflows/shopify.yml +106 -0
  5. data/.gitignore +2 -0
  6. data/CHANGELOG.md +23 -0
  7. data/CONTRIBUTING.md +23 -0
  8. data/Dockerfile +19 -0
  9. data/Gemfile +1 -0
  10. data/Gemfile.lock +50 -13
  11. data/Rakefile +66 -0
  12. data/dev.yml +11 -1
  13. data/ext/shopify-extensions/extconf.rb +21 -0
  14. data/ext/shopify-extensions/shopify_extensions.rb +152 -0
  15. data/ext/shopify-extensions/version +1 -0
  16. data/lib/project_types/extension/cli.rb +14 -0
  17. data/lib/project_types/extension/commands/build.rb +30 -2
  18. data/lib/project_types/extension/commands/create.rb +25 -0
  19. data/lib/project_types/extension/commands/push.rb +0 -1
  20. data/lib/project_types/extension/features/argo.rb +1 -11
  21. data/lib/project_types/extension/forms/create.rb +4 -1
  22. data/lib/project_types/extension/forms/questions/ask_template.rb +44 -0
  23. data/lib/project_types/extension/messages/messages.rb +3 -0
  24. data/lib/project_types/extension/models/development_server.rb +35 -0
  25. data/lib/project_types/extension/models/development_server_requirements.rb +17 -0
  26. data/lib/project_types/extension/models/server_config/base.rb +31 -0
  27. data/lib/project_types/extension/models/server_config/development.rb +23 -0
  28. data/lib/project_types/extension/models/server_config/development_entries.rb +38 -0
  29. data/lib/project_types/extension/models/server_config/development_renderer.rb +30 -0
  30. data/lib/project_types/extension/models/server_config/extension.rb +35 -0
  31. data/lib/project_types/extension/models/server_config/root.rb +18 -0
  32. data/lib/project_types/extension/models/server_config/user.rb +10 -0
  33. data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +10 -0
  34. data/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +1 -1
  35. data/lib/project_types/extension/tasks/choose_next_available_port.rb +1 -1
  36. data/lib/project_types/extension/tasks/run_extension_command.rb +58 -0
  37. data/lib/project_types/node/commands/create.rb +1 -5
  38. data/lib/project_types/rails/commands/create.rb +1 -5
  39. data/lib/project_types/script/cli.rb +2 -0
  40. data/lib/project_types/script/graphql/app_script_set.graphql +40 -0
  41. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +0 -44
  42. data/lib/project_types/script/graphql/module_upload_url_generate.graphql +9 -0
  43. data/lib/project_types/script/layers/application/push_script.rb +10 -1
  44. data/lib/project_types/script/layers/domain/push_package.rb +1 -14
  45. data/lib/project_types/script/layers/infrastructure/api_clients.rb +89 -0
  46. data/lib/project_types/script/layers/infrastructure/errors.rb +2 -0
  47. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +1 -1
  48. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +0 -1
  49. data/lib/project_types/script/layers/infrastructure/script_service.rb +29 -94
  50. data/lib/project_types/script/layers/infrastructure/script_uploader.rb +27 -0
  51. data/lib/project_types/script/messages/messages.rb +3 -0
  52. data/lib/project_types/script/tasks/ensure_env.rb +2 -2
  53. data/lib/project_types/script/ui/error_handler.rb +6 -1
  54. data/lib/project_types/theme/commands/pull.rb +6 -0
  55. data/lib/project_types/theme/commands/push.rb +6 -0
  56. data/lib/shopify-cli/constants.rb +26 -0
  57. data/lib/shopify-cli/environment.rb +60 -0
  58. data/lib/shopify-cli/git.rb +2 -2
  59. data/lib/shopify-cli/identity_auth.rb +16 -23
  60. data/lib/shopify-cli/partners_api.rb +3 -27
  61. data/lib/shopify-cli/process_supervision.rb +14 -14
  62. data/lib/shopify-cli/theme/dev_server/header_hash.rb +4 -0
  63. data/lib/shopify-cli/theme/dev_server/hot_reload.rb +4 -5
  64. data/lib/shopify-cli/theme/dev_server/proxy.rb +13 -1
  65. data/lib/shopify-cli/theme/development_theme.rb +16 -2
  66. data/lib/shopify-cli/theme/file.rb +11 -3
  67. data/lib/shopify-cli/theme/ignore_filter.rb +7 -0
  68. data/lib/shopify-cli/theme/syncer.rb +1 -1
  69. data/lib/shopify-cli/version.rb +1 -1
  70. data/lib/shopify_cli.rb +4 -2
  71. data/shopify-cli.gemspec +3 -3
  72. metadata +31 -9
  73. data/.github/workflows/build.yml +0 -28
@@ -12,6 +12,34 @@ module Extension
12
12
  NPM_BUILD_COMMAND = %w(run-script build)
13
13
 
14
14
  def call(_args, _command_name)
15
+ project = ExtensionProject.current(force_reload: true)
16
+ return run_new_flow(project) if supports_development_server?(project.specification_identifier)
17
+ run_legacy_flow
18
+ end
19
+
20
+ def self.help
21
+ ShopifyCli::Context.new.message("build.help", ShopifyCli::TOOL_NAME)
22
+ end
23
+
24
+ private
25
+
26
+ def run_new_flow(project)
27
+ Tasks::RunExtensionCommand.new(
28
+ type: project.specification_identifier.downcase,
29
+ command: "build"
30
+ ).call
31
+
32
+ @ctx.puts(@ctx.message("build.build_success_message"))
33
+ rescue => error
34
+ if error.message.include?("no such file or directory")
35
+ @ctx.abort(@ctx.message("build.directory_not_found"))
36
+ else
37
+ @ctx.debug(error)
38
+ @ctx.abort(@ctx.message("build.build_failure_message"))
39
+ end
40
+ end
41
+
42
+ def run_legacy_flow
15
43
  system = ShopifyCli::JsSystem.new(ctx: @ctx)
16
44
 
17
45
  CLI::UI::Frame.open(@ctx.message("build.frame_title", system.package_manager)) do
@@ -20,8 +48,8 @@ module Extension
20
48
  end
21
49
  end
22
50
 
23
- def self.help
24
- ShopifyCli::Context.new.message("build.help", ShopifyCli::TOOL_NAME)
51
+ def supports_development_server?(type)
52
+ Models::DevelopmentServerRequirements.supported?(type)
25
53
  end
26
54
  end
27
55
  end
@@ -3,6 +3,10 @@
3
3
  module Extension
4
4
  class Command
5
5
  class Create < ShopifyCli::SubCommand
6
+ DEVELOPMENT_SERVER_SUPPORTED_TYPES = [
7
+ "checkout_ui_extension",
8
+ ]
9
+
6
10
  prerequisite_task :ensure_authenticated
7
11
 
8
12
  options do |parser, flags|
@@ -18,6 +22,8 @@ module Extension
18
22
  @ctx.abort(message_for_extension["create.errors.directory_exists", form.directory_name])
19
23
  end
20
24
 
25
+ return use_new_create_flow(form, message_for_extension) if supports_development_server?(form.type)
26
+
21
27
  if form.type.create(form.directory_name, @ctx, getting_started: options.flags[:getting_started])
22
28
  ExtensionProject.write_cli_file(context: @ctx, type: form.type.identifier)
23
29
  ExtensionProject.write_env_file(
@@ -47,6 +53,25 @@ module Extension
47
53
 
48
54
  yield form, form.type.method(:message_for_extension)
49
55
  end
56
+
57
+ def supports_development_server?(type)
58
+ Models::DevelopmentServerRequirements.supported?(type.identifier)
59
+ end
60
+
61
+ def use_new_create_flow(form, msg)
62
+ Tasks::RunExtensionCommand.new(
63
+ root_dir: form.directory_name,
64
+ template: form.template,
65
+ type: form.type.identifier.downcase,
66
+ command: "create"
67
+ ).call
68
+
69
+ @ctx.puts(msg["create.ready_to_start", form.directory_name, form.name])
70
+ @ctx.puts(msg["create.learn_more", form.type.name])
71
+ rescue => error
72
+ @ctx.debug(error)
73
+ @ctx.puts(msg["create.try_again"])
74
+ end
50
75
  end
51
76
  end
52
77
  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)
@@ -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(
@@ -3,7 +3,7 @@
3
3
  module Extension
4
4
  module Forms
5
5
  class Create < ShopifyCli::Form
6
- flag_arguments :name, :type, :api_key
6
+ flag_arguments :name, :type, :api_key, :template
7
7
 
8
8
  attr_reader :app
9
9
 
@@ -13,6 +13,7 @@ module Extension
13
13
  property :app, accepts: Models::App
14
14
  property :name, accepts: String
15
15
  property :type, accepts: Models::SpecificationHandlers::Default
16
+ property :template, accepts: String
16
17
 
17
18
  def complete?
18
19
  !!(app && name && type)
@@ -23,6 +24,7 @@ module Extension
23
24
  ShopifyCli::Result.wrap(ExtensionProjectDetails.new)
24
25
  .then(&Questions::AskApp.new(ctx: ctx, api_key: api_key))
25
26
  .then(&Questions::AskType.new(ctx: ctx, type: type))
27
+ .then(&Questions::AskTemplate.new(ctx: ctx))
26
28
  .then(&Questions::AskName.new(ctx: ctx, name: name))
27
29
  .unwrap { |e| raise e }
28
30
  .tap do |project_details|
@@ -30,6 +32,7 @@ module Extension
30
32
 
31
33
  self.app = project_details.app
32
34
  self.type = project_details.type
35
+ self.template = project_details.template
33
36
  self.name = project_details.name
34
37
  end
35
38
  end
@@ -0,0 +1,44 @@
1
+ module Extension
2
+ module Forms
3
+ module Questions
4
+ class AskTemplate
5
+ include ShopifyCli::MethodObject
6
+
7
+ TEMPLATE_REQUIRED_TYPES = [
8
+ "checkout_ui_extension",
9
+ ]
10
+
11
+ property! :ctx
12
+ property :prompt,
13
+ accepts: ->(prompt) { prompt.respond_to?(:call) },
14
+ default: -> { CLI::UI::Prompt.method(:ask) }
15
+
16
+ def call(project_details)
17
+ return project_details unless template_required?(project_details)
18
+ project_details.template = choose_interactively
19
+ project_details
20
+ end
21
+
22
+ private
23
+
24
+ def template_required?(project_details)
25
+ return false unless extension_server_beta?
26
+ type = project_details&.type&.identifier
27
+ TEMPLATE_REQUIRED_TYPES.include?(type.downcase)
28
+ end
29
+
30
+ def extension_server_beta?
31
+ ShopifyCli::Shopifolk.check && ShopifyCli::Feature.enabled?(:extension_server_beta)
32
+ end
33
+
34
+ def choose_interactively
35
+ prompt.call(ctx.message("create.ask_template")) do |handler|
36
+ Models::ServerConfig::Development::VALID_TEMPLATES.each do |template|
37
+ handler.option(template) { template }
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -45,6 +45,7 @@ module Extension
45
45
  "or try creating a new app using {{command:shopify [node|rails] create}}.",
46
46
  loading_apps: "Loading your apps…",
47
47
  no_available_extensions: "{{x}} There are no available extensions for this app.",
48
+ ask_template: "Select a template to use for your extension",
48
49
  },
49
50
  connect: {
50
51
  connected: "Project now connected to {{green:%s: %s}}",
@@ -67,6 +68,8 @@ module Extension
67
68
  HELP
68
69
  frame_title: "Building extension with: %s…",
69
70
  build_failure_message: "Failed to build extension code.",
71
+ build_success_message: "Build was successful!",
72
+ directory_not_found: "Build directory not found.",
70
73
  },
71
74
  register: {
72
75
  help: <<~HELP,
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Extension
4
+ module Models
5
+ class DevelopmentServer
6
+ class DevelopmentServerError < StandardError; end
7
+
8
+ include SmartProperties
9
+
10
+ EXECUTABLE_PATH = "../../../../../ext/shopify-cli/shopify-extensions/shopify-extensions"
11
+
12
+ property! :executable, converts: :to_s, default: File.expand_path(EXECUTABLE_PATH, __FILE__)
13
+
14
+ def create(server_config)
15
+ CLI::Kit::System.capture3(executable, "create", "-", stdin_data: server_config.to_yaml)
16
+ rescue StandardError => error
17
+ raise error
18
+ end
19
+
20
+ def build(server_config)
21
+ _, error, pid = CLI::Kit::System.capture3(executable, "build", "-", stdin_data: server_config.to_yaml)
22
+ return if pid.success?
23
+ raise DevelopmentServerError, error
24
+ end
25
+
26
+ def serve
27
+ raise NotImplementedError
28
+ end
29
+
30
+ def version
31
+ raise NotImplementedError
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ require "shopify_cli"
3
+
4
+ module Extension
5
+ module Models
6
+ class DevelopmentServerRequirements
7
+ SUPPORTED_EXTENSION_TYPES = [
8
+ "checkout_ui_extension",
9
+ ]
10
+
11
+ def self.supported?(type)
12
+ return false unless SUPPORTED_EXTENSION_TYPES.include?(type.downcase)
13
+ ShopifyCli::Shopifolk.check && ShopifyCli::Feature.enabled?(:extension_server_beta)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Extension
4
+ module Models
5
+ module ServerConfig
6
+ class Base
7
+ def to_h
8
+ to_hash
9
+ end
10
+
11
+ def to_hash
12
+ is_hashable = ->(obj) { obj.respond_to?(:to_hash) }
13
+ is_collection_of_hashables = ->(obj) { obj.is_a?(Enumerable) && obj.all?(&is_hashable) }
14
+
15
+ self.class.properties.each.reduce({}) do |data, (_, property)|
16
+ data.merge(property.name.to_s => send(property.reader).yield_self do |value|
17
+ case value
18
+ when is_collection_of_hashables
19
+ value.map { |element| element.to_hash.transform_keys(&:to_s) }
20
+ when is_hashable
21
+ value.to_hash.transform_keys(&:to_s)
22
+ else
23
+ value
24
+ end
25
+ end)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,23 @@
1
+ module Extension
2
+ module Models
3
+ module ServerConfig
4
+ class Development < Base
5
+ include SmartProperties
6
+ VALID_TEMPLATES = [
7
+ "javascript",
8
+ "javascript-react",
9
+ "typescript",
10
+ "typescript-react",
11
+ ]
12
+
13
+ CURRENT_DIRECTORY = "."
14
+
15
+ property :root_dir, accepts: String, default: CURRENT_DIRECTORY
16
+ property! :build_dir, accepts: String, default: "build"
17
+ property :template, accepts: VALID_TEMPLATES
18
+ property :renderer, accepts: ServerConfig::DevelopmentRenderer
19
+ property :entries, accepts: ServerConfig::DevelopmentEntries
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Extension
4
+ module Models
5
+ module ServerConfig
6
+ class DevelopmentEntries < Base
7
+ include SmartProperties
8
+
9
+ JAVASCRIPT = "javascript"
10
+ JAVASCRIPT_REACT = "javascript-react"
11
+ TYPESCRIPT = "typescript"
12
+ TYPESCRIPT_REACT = "typescript-react"
13
+
14
+ VALID_ENTRY_POINTS = [
15
+ "src/index.js",
16
+ "src/index.jsx",
17
+ "src/index.ts",
18
+ "src/index.tsx",
19
+ ]
20
+
21
+ property! :main, accepts: VALID_ENTRY_POINTS
22
+
23
+ def self.find(template)
24
+ case template
25
+ when JAVASCRIPT
26
+ new(main: "src/index.js")
27
+ when JAVASCRIPT_REACT
28
+ new(main: "src/index.jsx")
29
+ when TYPESCRIPT
30
+ new(main: "src/index.ts")
31
+ when TYPESCRIPT_REACT
32
+ new(main: "src/index.tsx")
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Extension
4
+ module Models
5
+ module ServerConfig
6
+ class DevelopmentRenderer < Base
7
+ include SmartProperties
8
+
9
+ VALID_RENDERERS = [
10
+ "@shopify/admin-ui-extensions",
11
+ "@shopify/post-purchase-ui-extensions",
12
+ "@shopify/checkout-ui-extensions",
13
+ ]
14
+
15
+ property! :name, accepts: VALID_RENDERERS
16
+
17
+ def self.find(type)
18
+ case type.downcase
19
+ when "admin_ui_extension"
20
+ new(name: "@shopify/admin-ui-extensions")
21
+ when "checkout_ui_extension"
22
+ new(name: "@shopify/checkout-ui-extensions")
23
+ when "checkout_post_purchase"
24
+ new(name: "@shopify/post-purchase-ui-extensions")
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,35 @@
1
+ require "securerandom"
2
+
3
+ module Extension
4
+ module Models
5
+ module ServerConfig
6
+ class Extension < Base
7
+ include SmartProperties
8
+ property! :uuid, accepts: String
9
+ property! :type, accepts: String
10
+ property! :user, accepts: ServerConfig::User
11
+ property! :development, accepts: ServerConfig::Development
12
+
13
+ def self.build(uuid: "", template:, type:, root_dir:)
14
+ renderer = ServerConfig::DevelopmentRenderer.find(type)
15
+ entry = ServerConfig::DevelopmentEntries.find(template)
16
+ new(
17
+ uuid: uuid.empty? ? generate_dev_uuid : uuid,
18
+ type: type.downcase,
19
+ user: ServerConfig::User.new,
20
+ development: ServerConfig::Development.new(
21
+ root_dir: root_dir,
22
+ template: template,
23
+ renderer: renderer,
24
+ entries: entry
25
+ )
26
+ )
27
+ end
28
+
29
+ def self.generate_dev_uuid
30
+ "dev-#{SecureRandom.uuid}"
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Extension
4
+ module Models
5
+ module ServerConfig
6
+ class Root < Base
7
+ include SmartProperties
8
+
9
+ property! :port, accepts: Integer, default: 39351
10
+ property! :extensions, accepts: Array, default: -> { [] }
11
+
12
+ def to_yaml
13
+ to_h.to_yaml.gsub("---\n", "")
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ module Extension
2
+ module Models
3
+ module ServerConfig
4
+ class User < Base
5
+ include SmartProperties
6
+ property! :metafields, accepts: Array, default: -> { [] }
7
+ end
8
+ end
9
+ end
10
+ end
@@ -6,6 +6,7 @@ module Extension
6
6
  module SpecificationHandlers
7
7
  class CheckoutPostPurchase < Default
8
8
  PERMITTED_CONFIG_KEYS = [:metafields]
9
+ RENDERER_PACKAGE_NAME = "@shopify/post-purchase-ui-extensions"
9
10
 
10
11
  def config(context)
11
12
  {
@@ -13,6 +14,15 @@ module Extension
13
14
  **argo.config(context),
14
15
  }
15
16
  end
17
+
18
+ protected
19
+
20
+ def argo
21
+ Features::Argo.new(
22
+ git_template: specification.features.argo.git_template,
23
+ renderer_package_name: RENDERER_PACKAGE_NAME
24
+ )
25
+ end
16
26
  end
17
27
  end
18
28
  end
@@ -4,7 +4,7 @@ module Extension
4
4
  module Models
5
5
  module SpecificationHandlers
6
6
  class CheckoutUiExtension < Default
7
- PERMITTED_CONFIG_KEYS = [:metafields, :extension_points]
7
+ PERMITTED_CONFIG_KEYS = [:extension_points, :metafields, :name]
8
8
 
9
9
  def config(context)
10
10
  {
@@ -9,7 +9,7 @@ module Extension
9
9
 
10
10
  property! :from
11
11
  property! :to, default: -> { from + 10 }
12
- property! :host, default: "localhost"
12
+ property! :host, default: "127.0.0.1"
13
13
 
14
14
  def call
15
15
  available_port = port_range(from: from, to: to).find { |p| available?(host, p) }
@@ -0,0 +1,58 @@
1
+
2
+ # frozen_string_literal: true
3
+ require "shopify_cli"
4
+
5
+ module Extension
6
+ module Tasks
7
+ class RunExtensionCommand < ShopifyCli::Task
8
+ include SmartProperties
9
+
10
+ SUPPORTED_EXTENSION_TYPES = [
11
+ "checkout_ui_extension",
12
+ ]
13
+
14
+ SUPPORTED_COMMANDS = [
15
+ "create",
16
+ "build",
17
+ ]
18
+
19
+ property :root_dir, accepts: String
20
+ property :template, accepts: Models::ServerConfig::Development::VALID_TEMPLATES
21
+ property! :type, accepts: SUPPORTED_EXTENSION_TYPES
22
+ property! :command, accepts: SUPPORTED_COMMANDS
23
+
24
+ def call
25
+ ShopifyCli::Result
26
+ .call(&method(:build_extension))
27
+ .then(&method(:build_server_config))
28
+ .then(&method(:run_command))
29
+ .unwrap do |error|
30
+ raise error unless error.nil?
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def build_extension
37
+ Models::ServerConfig::Extension.build(
38
+ template: template,
39
+ type: type,
40
+ root_dir: root_dir,
41
+ )
42
+ end
43
+
44
+ def build_server_config(extension)
45
+ Models::ServerConfig::Root.new(extensions: [extension])
46
+ end
47
+
48
+ def run_command(server_config)
49
+ case command
50
+ when "create"
51
+ Models::DevelopmentServer.new.create(server_config)
52
+ when "build"
53
+ Models::DevelopmentServer.new.build(server_config)
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -46,7 +46,7 @@ module Node
46
46
  scopes: "write_products,write_customers,write_draft_orders",
47
47
  ).write(@ctx)
48
48
 
49
- partners_url = ShopifyCli::PartnersAPI.partners_url_for(form.organization_id, api_client["id"], local_debug?)
49
+ partners_url = ShopifyCli::PartnersAPI.partners_url_for(form.organization_id, api_client["id"])
50
50
 
51
51
  @ctx.puts(@ctx.message("apps.create.info.created", form.title, partners_url))
52
52
  @ctx.puts(@ctx.message("apps.create.info.serve", form.name, ShopifyCli::TOOL_NAME, "node"))
@@ -120,10 +120,6 @@ module Node
120
120
  @ctx.debug(e)
121
121
  end
122
122
  end
123
-
124
- def local_debug?
125
- @ctx.getenv(ShopifyCli::PartnersAPI::LOCAL_DEBUG)
126
- end
127
123
  end
128
124
  end
129
125
  end
@@ -63,7 +63,7 @@ module Rails
63
63
  scopes: "write_products,write_customers,write_draft_orders",
64
64
  ).write(@ctx)
65
65
 
66
- partners_url = ShopifyCli::PartnersAPI.partners_url_for(form.organization_id, api_client["id"], local_debug?)
66
+ partners_url = ShopifyCli::PartnersAPI.partners_url_for(form.organization_id, api_client["id"])
67
67
 
68
68
  @ctx.puts(@ctx.message("apps.create.info.created", form.title, partners_url))
69
69
  @ctx.puts(@ctx.message("apps.create.info.serve", form.name, ShopifyCli::TOOL_NAME, "rails"))
@@ -178,10 +178,6 @@ module Rails
178
178
  def install_gem(name, version = nil)
179
179
  Gem.install(@ctx, name, version)
180
180
  end
181
-
182
- def local_debug?
183
- @ctx.getenv(ShopifyCli::PartnersAPI::LOCAL_DEBUG)
184
- end
185
181
  end
186
182
  end
187
183
  end
@@ -45,12 +45,14 @@ module Script
45
45
  end
46
46
 
47
47
  module Infrastructure
48
+ autoload :ApiClients, Project.project_filepath("layers/infrastructure/api_clients")
48
49
  autoload :Errors, Project.project_filepath("layers/infrastructure/errors")
49
50
  autoload :CommandRunner, Project.project_filepath("layers/infrastructure/command_runner")
50
51
  autoload :PushPackageRepository, Project.project_filepath("layers/infrastructure/push_package_repository")
51
52
  autoload :ExtensionPointRepository, Project.project_filepath("layers/infrastructure/extension_point_repository")
52
53
  autoload :ScriptProjectRepository, Project.project_filepath("layers/infrastructure/script_project_repository")
53
54
  autoload :ScriptService, Project.project_filepath("layers/infrastructure/script_service")
55
+ autoload :ScriptUploader, Project.project_filepath("layers/infrastructure/script_uploader")
54
56
 
55
57
  module Languages
56
58
  autoload :AssemblyScriptProjectCreator,
@@ -0,0 +1,40 @@
1
+ mutation AppScriptSet(
2
+ $uuid: String
3
+ $extensionPointName: ExtensionPointName!,
4
+ $title: String!,
5
+ $description: String,
6
+ $force: Boolean,
7
+ $schemaMajorVersion: String,
8
+ $schemaMinorVersion: String,
9
+ $scriptJsonVersion: String!,
10
+ $configurationUi: Boolean!,
11
+ $configurationDefinition: String!,
12
+ $moduleUploadUrl: String!,
13
+ ) {
14
+ appScriptSet(
15
+ uuid: $uuid
16
+ extensionPointName: $extensionPointName
17
+ title: $title
18
+ description: $description
19
+ force: $force
20
+ schemaMajorVersion: $schemaMajorVersion
21
+ schemaMinorVersion: $schemaMinorVersion,
22
+ scriptJsonVersion: $scriptJsonVersion,
23
+ configurationUi: $configurationUi,
24
+ configurationDefinition: $configurationDefinition,
25
+ moduleUploadUrl: $moduleUploadUrl,
26
+ ) {
27
+ userErrors {
28
+ field
29
+ message
30
+ tag
31
+ }
32
+ appScript {
33
+ uuid
34
+ appKey
35
+ configSchema
36
+ extensionPointName
37
+ title
38
+ }
39
+ }
40
+ }