shopify-cli 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/CODEOWNERS +1 -0
- data/.github/CODE_OF_CONDUCT.md +73 -0
- data/.github/CONTRIBUTING.md +51 -0
- data/.github/DESIGN.md +153 -0
- data/.github/ISSUE_TEMPLATE.md +38 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +22 -0
- data/.github/probots.yml +3 -0
- data/.gitignore +19 -0
- data/.rubocop.yml +47 -0
- data/.ruby-version +1 -0
- data/.travis.yml +12 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +77 -0
- data/LICENSE.md +7 -0
- data/README.md +13 -0
- data/Rakefile +101 -0
- data/SECURITY.md +59 -0
- data/Vagrantfile +17 -0
- data/bin/load_shopify.rb +20 -0
- data/bin/shopify +32 -0
- data/dev.yml +17 -0
- data/docs/Gemfile +5 -0
- data/docs/Gemfile.lock +248 -0
- data/docs/_config.yml +16 -0
- data/docs/_data/nav.yml +26 -0
- data/docs/_includes/footer.html +15 -0
- data/docs/_includes/head.html +19 -0
- data/docs/_includes/sidebar_nav.html +22 -0
- data/docs/_includes/toc.html +112 -0
- data/docs/_layouts/default.html +79 -0
- data/docs/app/node/commands/index.md +82 -0
- data/docs/app/node/index.md +35 -0
- data/docs/app/rails/commands/index.md +80 -0
- data/docs/app/rails/index.md +36 -0
- data/docs/core/index.md +70 -0
- data/docs/css/docs.css +157 -0
- data/docs/getting-started/index.md +61 -0
- data/docs/help/start-app/index.md +6 -0
- data/docs/images/header.png +0 -0
- data/docs/index.md +27 -0
- data/docs/installing-ruby.md +28 -0
- data/ext/shopify-cli/extconf.rb +27 -0
- data/install.sh +7 -0
- data/lib/docgen/class_template.md.erb +81 -0
- data/lib/docgen/index_template.md.erb +5 -0
- data/lib/docgen/markdown.rb +101 -0
- data/lib/graphql/admin_introspection.graphql +87 -0
- data/lib/graphql/all_organizations.graphql +19 -0
- data/lib/graphql/all_orgs_with_apps.graphql +30 -0
- data/lib/graphql/api_versions.graphql +6 -0
- data/lib/graphql/convert_dev_to_test_store.graphql +10 -0
- data/lib/graphql/create_app.graphql +20 -0
- data/lib/graphql/create_customer.graphql +9 -0
- data/lib/graphql/create_draft_order.graphql +8 -0
- data/lib/graphql/create_product.graphql +9 -0
- data/lib/graphql/extension_create.graphql +21 -0
- data/lib/graphql/extension_update_draft.graphql +18 -0
- data/lib/graphql/find_organization.graphql +17 -0
- data/lib/graphql/get_app_urls.graphql +6 -0
- data/lib/graphql/update_dashboard_urls.graphql +8 -0
- data/lib/project_types/extension/cli.rb +71 -0
- data/lib/project_types/extension/commands/build.rb +29 -0
- data/lib/project_types/extension/commands/create.rb +49 -0
- data/lib/project_types/extension/commands/extension_command.rb +22 -0
- data/lib/project_types/extension/commands/push.rb +69 -0
- data/lib/project_types/extension/commands/register.rb +78 -0
- data/lib/project_types/extension/commands/serve.rb +24 -0
- data/lib/project_types/extension/commands/tunnel.rb +69 -0
- data/lib/project_types/extension/extension_project.rb +85 -0
- data/lib/project_types/extension/extension_project_keys.rb +10 -0
- data/lib/project_types/extension/features/argo.rb +48 -0
- data/lib/project_types/extension/features/argo_dependencies.rb +28 -0
- data/lib/project_types/extension/features/argo_setup.rb +54 -0
- data/lib/project_types/extension/features/argo_setup_step.rb +31 -0
- data/lib/project_types/extension/features/argo_setup_steps.rb +53 -0
- data/lib/project_types/extension/features/tunnel_url.rb +20 -0
- data/lib/project_types/extension/forms/create.rb +52 -0
- data/lib/project_types/extension/forms/register.rb +48 -0
- data/lib/project_types/extension/messages/message_loading.rb +37 -0
- data/lib/project_types/extension/messages/messages.rb +126 -0
- data/lib/project_types/extension/models/app.rb +14 -0
- data/lib/project_types/extension/models/registration.rb +19 -0
- data/lib/project_types/extension/models/type.rb +76 -0
- data/lib/project_types/extension/models/types/checkout_post_purchase.rb +20 -0
- data/lib/project_types/extension/models/types/subscription_management.rb +20 -0
- data/lib/project_types/extension/models/validation_error.rb +17 -0
- data/lib/project_types/extension/models/version.rb +15 -0
- data/lib/project_types/extension/tasks/converters/registration_converter.rb +26 -0
- data/lib/project_types/extension/tasks/converters/validation_error_converter.rb +25 -0
- data/lib/project_types/extension/tasks/converters/version_converter.rb +28 -0
- data/lib/project_types/extension/tasks/create_extension.rb +31 -0
- data/lib/project_types/extension/tasks/get_apps.rb +34 -0
- data/lib/project_types/extension/tasks/update_draft.rb +29 -0
- data/lib/project_types/extension/tasks/user_errors.rb +45 -0
- data/lib/project_types/node/cli.rb +37 -0
- data/lib/project_types/node/commands/create.rb +117 -0
- data/lib/project_types/node/commands/deploy.rb +22 -0
- data/lib/project_types/node/commands/deploy/heroku.rb +91 -0
- data/lib/project_types/node/commands/generate.rb +51 -0
- data/lib/project_types/node/commands/generate/billing.rb +37 -0
- data/lib/project_types/node/commands/generate/page.rb +55 -0
- data/lib/project_types/node/commands/generate/webhook.rb +33 -0
- data/lib/project_types/node/commands/open.rb +16 -0
- data/lib/project_types/node/commands/populate.rb +23 -0
- data/lib/project_types/node/commands/populate/customer.rb +31 -0
- data/lib/project_types/node/commands/populate/draft_order.rb +28 -0
- data/lib/project_types/node/commands/populate/product.rb +30 -0
- data/lib/project_types/node/commands/serve.rb +45 -0
- data/lib/project_types/node/commands/tunnel.rb +39 -0
- data/lib/project_types/node/forms/create.rb +87 -0
- data/lib/project_types/node/messages/messages.rb +260 -0
- data/lib/project_types/rails/cli.rb +41 -0
- data/lib/project_types/rails/commands/create.rb +126 -0
- data/lib/project_types/rails/commands/deploy.rb +22 -0
- data/lib/project_types/rails/commands/deploy/heroku.rb +113 -0
- data/lib/project_types/rails/commands/generate.rb +49 -0
- data/lib/project_types/rails/commands/generate/webhook.rb +39 -0
- data/lib/project_types/rails/commands/open.rb +16 -0
- data/lib/project_types/rails/commands/populate.rb +23 -0
- data/lib/project_types/rails/commands/populate/customer.rb +31 -0
- data/lib/project_types/rails/commands/populate/draft_order.rb +28 -0
- data/lib/project_types/rails/commands/populate/product.rb +30 -0
- data/lib/project_types/rails/commands/serve.rb +47 -0
- data/lib/project_types/rails/commands/tunnel.rb +39 -0
- data/lib/project_types/rails/forms/create.rb +116 -0
- data/lib/project_types/rails/gem.rb +56 -0
- data/lib/project_types/rails/messages/messages.rb +283 -0
- data/lib/project_types/rails/ruby.rb +17 -0
- data/lib/project_types/script/cli.rb +76 -0
- data/lib/project_types/script/commands/create.rb +45 -0
- data/lib/project_types/script/commands/disable.rb +36 -0
- data/lib/project_types/script/commands/enable.rb +46 -0
- data/lib/project_types/script/commands/push.rb +39 -0
- data/lib/project_types/script/config/extension_points.yml +18 -0
- data/lib/project_types/script/errors.rb +16 -0
- data/lib/project_types/script/forms/create.rb +29 -0
- data/lib/project_types/script/forms/enable.rb +24 -0
- data/lib/project_types/script/forms/push.rb +19 -0
- data/lib/project_types/script/forms/script_form.rb +66 -0
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +27 -0
- data/lib/project_types/script/graphql/script_service_proxy.graphql +8 -0
- data/lib/project_types/script/graphql/shop_script_delete.graphql +14 -0
- data/lib/project_types/script/graphql/shop_script_update_or_create.graphql +28 -0
- data/lib/project_types/script/layers/application/build_script.rb +43 -0
- data/lib/project_types/script/layers/application/create_script.rb +47 -0
- data/lib/project_types/script/layers/application/disable_script.rb +19 -0
- data/lib/project_types/script/layers/application/enable_script.rb +21 -0
- data/lib/project_types/script/layers/application/extension_points.rb +17 -0
- data/lib/project_types/script/layers/application/project_dependencies.rb +34 -0
- data/lib/project_types/script/layers/application/push_script.rb +30 -0
- data/lib/project_types/script/layers/domain/errors.rb +25 -0
- data/lib/project_types/script/layers/domain/extension_point.rb +29 -0
- data/lib/project_types/script/layers/domain/push_package.rb +29 -0
- data/lib/project_types/script/layers/domain/script.rb +18 -0
- data/lib/project_types/script/layers/infrastructure/assemblyscript_dependency_manager.rb +73 -0
- data/lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb +38 -0
- data/lib/project_types/script/layers/infrastructure/assemblyscript_wasm_builder.rb +39 -0
- data/lib/project_types/script/layers/infrastructure/dependency_manager.rb +36 -0
- data/lib/project_types/script/layers/infrastructure/errors.rb +38 -0
- data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +31 -0
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +47 -0
- data/lib/project_types/script/layers/infrastructure/script_builder.rb +34 -0
- data/lib/project_types/script/layers/infrastructure/script_repository.rb +89 -0
- data/lib/project_types/script/layers/infrastructure/script_service.rb +165 -0
- data/lib/project_types/script/layers/infrastructure/test_suite_repository.rb +59 -0
- data/lib/project_types/script/messages/messages.rb +204 -0
- data/lib/project_types/script/script_project.rb +37 -0
- data/lib/project_types/script/templates/ts/as-pect.config.js +21 -0
- data/lib/project_types/script/ui/error_handler.rb +136 -0
- data/lib/project_types/script/ui/strict_spinner.rb +22 -0
- data/lib/rubygems_plugin.rb +18 -0
- data/lib/shopify-cli/admin_api.rb +99 -0
- data/lib/shopify-cli/admin_api/populate_resource_command.rb +165 -0
- data/lib/shopify-cli/admin_api/schema.rb +32 -0
- data/lib/shopify-cli/api.rb +104 -0
- data/lib/shopify-cli/command.rb +67 -0
- data/lib/shopify-cli/commands.rb +28 -0
- data/lib/shopify-cli/commands/connect.rb +108 -0
- data/lib/shopify-cli/commands/create.rb +50 -0
- data/lib/shopify-cli/commands/help.rb +79 -0
- data/lib/shopify-cli/commands/logout.rb +23 -0
- data/lib/shopify-cli/commands/system.rb +135 -0
- data/lib/shopify-cli/commands/version.rb +15 -0
- data/lib/shopify-cli/context.rb +372 -0
- data/lib/shopify-cli/core.rb +9 -0
- data/lib/shopify-cli/core/entry_point.rb +40 -0
- data/lib/shopify-cli/core/executor.rb +21 -0
- data/lib/shopify-cli/core/help_resolver.rb +20 -0
- data/lib/shopify-cli/core/monorail.rb +118 -0
- data/lib/shopify-cli/db.rb +114 -0
- data/lib/shopify-cli/form.rb +40 -0
- data/lib/shopify-cli/git.rb +141 -0
- data/lib/shopify-cli/helpers.rb +5 -0
- data/lib/shopify-cli/helpers/haikunator.rb +92 -0
- data/lib/shopify-cli/heroku.rb +97 -0
- data/lib/shopify-cli/js_deps.rb +110 -0
- data/lib/shopify-cli/js_system.rb +98 -0
- data/lib/shopify-cli/messages/messages.rb +287 -0
- data/lib/shopify-cli/oauth.rb +192 -0
- data/lib/shopify-cli/oauth/servlet.rb +61 -0
- data/lib/shopify-cli/options.rb +40 -0
- data/lib/shopify-cli/packager.rb +116 -0
- data/lib/shopify-cli/partners_api.rb +114 -0
- data/lib/shopify-cli/partners_api/organizations.rb +32 -0
- data/lib/shopify-cli/process_supervision.rb +187 -0
- data/lib/shopify-cli/project.rb +191 -0
- data/lib/shopify-cli/project_type.rb +83 -0
- data/lib/shopify-cli/resources.rb +5 -0
- data/lib/shopify-cli/resources/env_file.rb +96 -0
- data/lib/shopify-cli/sub_command.rb +15 -0
- data/lib/shopify-cli/task.rb +10 -0
- data/lib/shopify-cli/tasks.rb +32 -0
- data/lib/shopify-cli/tasks/create_api_client.rb +29 -0
- data/lib/shopify-cli/tasks/ensure_dev_store.rb +41 -0
- data/lib/shopify-cli/tasks/ensure_env.rb +31 -0
- data/lib/shopify-cli/tasks/ensure_loopback_url.rb +20 -0
- data/lib/shopify-cli/tasks/update_dashboard_urls.rb +44 -0
- data/lib/shopify-cli/tunnel.rb +154 -0
- data/lib/shopify-cli/version.rb +3 -0
- data/lib/shopify_cli.rb +132 -0
- data/shopify-cli.gemspec +40 -0
- data/shopify.fish +12 -0
- data/shopify.sh +11 -0
- data/vendor/deps/cli-kit/REVISION +1 -0
- data/vendor/deps/cli-kit/lib/cli/kit.rb +60 -0
- data/vendor/deps/cli-kit/lib/cli/kit/autocall.rb +21 -0
- data/vendor/deps/cli-kit/lib/cli/kit/base_command.rb +49 -0
- data/vendor/deps/cli-kit/lib/cli/kit/command_registry.rb +94 -0
- data/vendor/deps/cli-kit/lib/cli/kit/config.rb +133 -0
- data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +115 -0
- data/vendor/deps/cli-kit/lib/cli/kit/executor.rb +81 -0
- data/vendor/deps/cli-kit/lib/cli/kit/ini.rb +102 -0
- data/vendor/deps/cli-kit/lib/cli/kit/levenshtein.rb +82 -0
- data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +76 -0
- data/vendor/deps/cli-kit/lib/cli/kit/resolver.rb +60 -0
- data/vendor/deps/cli-kit/lib/cli/kit/ruby_backports/enumerable.rb +6 -0
- data/vendor/deps/cli-kit/lib/cli/kit/support.rb +9 -0
- data/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +244 -0
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +207 -0
- data/vendor/deps/cli-kit/lib/cli/kit/util.rb +189 -0
- data/vendor/deps/cli-kit/lib/cli/kit/version.rb +5 -0
- data/vendor/deps/cli-ui/REVISION +1 -0
- data/vendor/deps/cli-ui/lib/cli/ui.rb +187 -0
- data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +153 -0
- data/vendor/deps/cli-ui/lib/cli/ui/box.rb +15 -0
- data/vendor/deps/cli-ui/lib/cli/ui/color.rb +79 -0
- data/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +179 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +310 -0
- data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +78 -0
- data/vendor/deps/cli-ui/lib/cli/ui/progress.rb +88 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +248 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +472 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +24 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +48 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/async.rb +40 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +241 -0
- data/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +227 -0
- data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +36 -0
- data/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +102 -0
- data/vendor/deps/cli-ui/lib/cli/ui/version.rb +5 -0
- data/vendor/deps/smart_properties/REVISION +1 -0
- data/vendor/deps/smart_properties/lib/smart_properties.rb +174 -0
- data/vendor/deps/smart_properties/lib/smart_properties/errors.rb +114 -0
- data/vendor/deps/smart_properties/lib/smart_properties/property.rb +162 -0
- data/vendor/deps/smart_properties/lib/smart_properties/property_collection.rb +83 -0
- data/vendor/deps/smart_properties/lib/smart_properties/validations.rb +8 -0
- data/vendor/deps/smart_properties/lib/smart_properties/validations/ancestor.rb +27 -0
- data/vendor/deps/smart_properties/lib/smart_properties/version.rb +3 -0
- data/vendor/lib/semantic/LICENSE +20 -0
- data/vendor/lib/semantic/semantic.rb +4 -0
- data/vendor/lib/semantic/version.rb +180 -0
- metadata +374 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Extension
|
4
|
+
module Models
|
5
|
+
class App
|
6
|
+
include SmartProperties
|
7
|
+
|
8
|
+
property! :api_key, accepts: String
|
9
|
+
property! :secret, accepts: String
|
10
|
+
property :title, accepts: String
|
11
|
+
property :business_name, accepts: String
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Extension
|
4
|
+
module Models
|
5
|
+
class Registration
|
6
|
+
MAX_TITLE_LENGTH = 50
|
7
|
+
include SmartProperties
|
8
|
+
|
9
|
+
property! :id, accepts: Integer
|
10
|
+
property! :type, accepts: String
|
11
|
+
property! :title, accepts: String
|
12
|
+
property! :draft_version, accepts: Extension::Models::Version
|
13
|
+
|
14
|
+
def self.valid_title?(title)
|
15
|
+
!title.nil? && !title.strip.empty? && title.length <= MAX_TITLE_LENGTH
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Extension
|
4
|
+
module Models
|
5
|
+
class Type
|
6
|
+
TYPES_PATH = %w(lib project_types extension models types *.rb)
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def load_all
|
10
|
+
return unless @all_extension_types.nil? || @all_extension_types.empty?
|
11
|
+
Dir.glob(File.join(ShopifyCli::ROOT, TYPES_PATH)).map { |file_path| load(file_path) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def inherited(klass)
|
15
|
+
@all_extension_types ||= []
|
16
|
+
@all_extension_types << klass
|
17
|
+
end
|
18
|
+
|
19
|
+
def valid?(identifier)
|
20
|
+
repository.key?(identifier)
|
21
|
+
end
|
22
|
+
|
23
|
+
def repository
|
24
|
+
load_all if @all_extension_types.empty?
|
25
|
+
|
26
|
+
@repository ||= @all_extension_types.map(&:new).each_with_object({}) do |type, hash|
|
27
|
+
hash[type.identifier] = type
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def load_type(identifier)
|
32
|
+
repository[identifier]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def identifier
|
37
|
+
self.class::IDENTIFIER
|
38
|
+
end
|
39
|
+
|
40
|
+
def name
|
41
|
+
message('name')
|
42
|
+
end
|
43
|
+
|
44
|
+
def tagline
|
45
|
+
message('tagline') || ""
|
46
|
+
end
|
47
|
+
|
48
|
+
def config(_context)
|
49
|
+
raise NotImplementedError, "'#{__method__}' must be implemented for #{self.class}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def create(_directory_name, _context)
|
53
|
+
raise NotImplementedError, "'#{__method__}' must be implemented for #{self.class}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def extension_context(_context)
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def valid_extension_contexts
|
61
|
+
[]
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def message(key, *params)
|
67
|
+
return unless messages.key?(key.to_sym)
|
68
|
+
messages[key.to_sym] % params
|
69
|
+
end
|
70
|
+
|
71
|
+
def messages
|
72
|
+
@messages ||= Messages::TYPES[identifier.downcase.to_sym] || {}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Models
|
6
|
+
module Types
|
7
|
+
class CheckoutPostPurchase < Models::Type
|
8
|
+
IDENTIFIER = 'CHECKOUT_POST_PURCHASE'
|
9
|
+
|
10
|
+
def create(directory_name, context)
|
11
|
+
Features::Argo.checkout.create(directory_name, IDENTIFIER, context)
|
12
|
+
end
|
13
|
+
|
14
|
+
def config(context)
|
15
|
+
Features::Argo.checkout.config(context)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Models
|
6
|
+
module Types
|
7
|
+
class SubscriptionManagement < Models::Type
|
8
|
+
IDENTIFIER = 'SUBSCRIPTION_MANAGEMENT'
|
9
|
+
|
10
|
+
def create(directory_name, context)
|
11
|
+
Features::Argo.admin.create(directory_name, IDENTIFIER, context)
|
12
|
+
end
|
13
|
+
|
14
|
+
def config(context)
|
15
|
+
Features::Argo.admin.config(context)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Extension
|
4
|
+
module Models
|
5
|
+
class ValidationError
|
6
|
+
include SmartProperties
|
7
|
+
|
8
|
+
IS_VALIDATION_ERROR_LIST = -> (errors) do
|
9
|
+
errors.is_a?(Array) && errors.all? { |error| IS_VALIDATION_ERROR.call(error) }
|
10
|
+
end
|
11
|
+
IS_VALIDATION_ERROR = -> (error) { error.is_a?(ValidationError) }
|
12
|
+
|
13
|
+
property! :field, accepts: -> (fields) { fields.all? { |field| field.is_a?(String) } }
|
14
|
+
property! :message, accepts: String
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Extension
|
4
|
+
module Models
|
5
|
+
class Version
|
6
|
+
include SmartProperties
|
7
|
+
|
8
|
+
property! :registration_id, accepts: Integer
|
9
|
+
property! :last_user_interaction_at, accepts: Time
|
10
|
+
property :context, accepts: String
|
11
|
+
property :location, accepts: String
|
12
|
+
property :validation_errors, accepts: Models::ValidationError::IS_VALIDATION_ERROR_LIST, default: []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'shopify_cli'
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Tasks
|
6
|
+
module Converters
|
7
|
+
module RegistrationConverter
|
8
|
+
ID_FIELD = 'id'
|
9
|
+
TYPE_FIELD = 'type'
|
10
|
+
TITLE_FIELD = 'title'
|
11
|
+
DRAFT_VERSION_FIELD = 'draftVersion'
|
12
|
+
|
13
|
+
def self.from_hash(context, hash)
|
14
|
+
context.abort(context.message('tasks.errors.parse_error')) if hash.nil?
|
15
|
+
|
16
|
+
Models::Registration.new(
|
17
|
+
id: hash[ID_FIELD].to_i,
|
18
|
+
type: hash[TYPE_FIELD],
|
19
|
+
title: hash[TITLE_FIELD],
|
20
|
+
draft_version: VersionConverter.from_hash(context, hash[DRAFT_VERSION_FIELD])
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'shopify_cli'
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Tasks
|
6
|
+
module Converters
|
7
|
+
module ValidationErrorConverter
|
8
|
+
FIELD_FIELD = 'field'
|
9
|
+
MESSAGE_FIELD = 'message'
|
10
|
+
|
11
|
+
def self.from_array(context, errors)
|
12
|
+
return [] if errors.nil?
|
13
|
+
context.abort(context.message('tasks.errors.parse_error')) unless errors.is_a?(Array)
|
14
|
+
|
15
|
+
errors.map do |error|
|
16
|
+
Models::ValidationError.new(
|
17
|
+
field: error[FIELD_FIELD],
|
18
|
+
message: error[MESSAGE_FIELD]
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'shopify_cli'
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Tasks
|
6
|
+
module Converters
|
7
|
+
module VersionConverter
|
8
|
+
REGISTRATION_ID_FIELD = 'registrationId'
|
9
|
+
CONTEXT_FIELD = 'context'
|
10
|
+
LAST_USER_INTERACTION_AT_FIELD = 'lastUserInteractionAt'
|
11
|
+
LOCATION_FIELD = 'location'
|
12
|
+
VALIDATION_ERRORS_FIELD = 'validationErrors'
|
13
|
+
|
14
|
+
def self.from_hash(context, hash)
|
15
|
+
context.abort(context.message('tasks.errors.parse_error')) if hash.nil?
|
16
|
+
|
17
|
+
Models::Version.new(
|
18
|
+
registration_id: hash[REGISTRATION_ID_FIELD].to_i,
|
19
|
+
context: hash[CONTEXT_FIELD],
|
20
|
+
last_user_interaction_at: Time.parse(hash[LAST_USER_INTERACTION_AT_FIELD]),
|
21
|
+
location: hash[LOCATION_FIELD],
|
22
|
+
validation_errors: Converters::ValidationErrorConverter.from_array(context, hash[VALIDATION_ERRORS_FIELD])
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'shopify_cli'
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Tasks
|
6
|
+
class CreateExtension < ShopifyCli::Task
|
7
|
+
include UserErrors
|
8
|
+
|
9
|
+
GRAPHQL_FILE = 'extension_create'
|
10
|
+
|
11
|
+
RESPONSE_FIELD = %w(data extensionCreate)
|
12
|
+
REGISTRATION_FIELD = 'extensionRegistration'
|
13
|
+
|
14
|
+
def call(context:, api_key:, type:, title:, config:, extension_context: nil)
|
15
|
+
input = {
|
16
|
+
api_key: api_key,
|
17
|
+
type: type,
|
18
|
+
title: title,
|
19
|
+
config: JSON.generate(config),
|
20
|
+
extension_context: extension_context,
|
21
|
+
}
|
22
|
+
|
23
|
+
response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, input).dig(*RESPONSE_FIELD)
|
24
|
+
context.abort(context.message('tasks.errors.parse_error')) if response.nil?
|
25
|
+
|
26
|
+
abort_if_user_errors(context, response)
|
27
|
+
Converters::RegistrationConverter.from_hash(context, response.dig(REGISTRATION_FIELD))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'shopify_cli'
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Tasks
|
6
|
+
class GetApps < ShopifyCli::Task
|
7
|
+
def call(context:)
|
8
|
+
organizations = ShopifyCli::PartnersAPI::Organizations.fetch_with_app(context)
|
9
|
+
apps_from_organizations(organizations)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def apps_from_organizations(organizations)
|
15
|
+
organizations.flat_map do |organization|
|
16
|
+
apps_owned_by_organization(organization)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def apps_owned_by_organization(organization)
|
21
|
+
return [] unless organization.key?('apps') && organization['apps'].any?
|
22
|
+
|
23
|
+
organization['apps'].map do |app|
|
24
|
+
Models::App.new(
|
25
|
+
api_key: app['apiKey'],
|
26
|
+
secret: app["apiSecretKeys"].first["secret"],
|
27
|
+
title: app['title'],
|
28
|
+
business_name: organization['businessName']
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'shopify_cli'
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Tasks
|
6
|
+
class UpdateDraft < ShopifyCli::Task
|
7
|
+
include UserErrors
|
8
|
+
|
9
|
+
GRAPHQL_FILE = 'extension_update_draft'
|
10
|
+
|
11
|
+
RESPONSE_FIELD = %w(data extensionUpdateDraft)
|
12
|
+
VERSION_FIELD = 'extensionVersion'
|
13
|
+
|
14
|
+
def call(context:, api_key:, registration_id:, config:, extension_context:)
|
15
|
+
input = {
|
16
|
+
api_key: api_key,
|
17
|
+
registration_id: registration_id,
|
18
|
+
config: JSON.generate(config),
|
19
|
+
extension_context: extension_context,
|
20
|
+
}
|
21
|
+
response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, input).dig(*RESPONSE_FIELD)
|
22
|
+
context.abort(context.message('tasks.errors.parse_error')) if response.nil?
|
23
|
+
|
24
|
+
abort_if_user_errors(context, response)
|
25
|
+
Converters::VersionConverter.from_hash(context, response.dig(VERSION_FIELD))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'shopify_cli'
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Tasks
|
6
|
+
module UserErrors
|
7
|
+
USER_ERRORS_FIELD = 'userErrors'
|
8
|
+
MESSAGE_FIELD = 'message'
|
9
|
+
USER_ERRORS_PARSE_ERROR = 'Unable to parse errors from server.'
|
10
|
+
|
11
|
+
def abort_if_user_errors(context, response)
|
12
|
+
return if response.nil?
|
13
|
+
|
14
|
+
user_errors = response.dig(USER_ERRORS_FIELD)
|
15
|
+
output_all_user_errors(context, user_errors)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def output_all_user_errors(context, user_errors)
|
21
|
+
return if user_errors.nil? || user_errors.empty?
|
22
|
+
last_user_error = user_errors.pop
|
23
|
+
|
24
|
+
user_errors.each { |user_error| puts_user_error(context, user_error) }
|
25
|
+
abort_user_error(context, last_user_error)
|
26
|
+
end
|
27
|
+
|
28
|
+
def puts_user_error(context, user_error)
|
29
|
+
output_user_error(context, user_error) { |message| context.puts("{{x}} #{message}") }
|
30
|
+
end
|
31
|
+
|
32
|
+
def abort_user_error(context, user_error)
|
33
|
+
output_user_error(context, user_error) { |message| context.abort(message) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def output_user_error(context, user_error)
|
37
|
+
if user_error.key?(MESSAGE_FIELD)
|
38
|
+
yield(user_error[MESSAGE_FIELD])
|
39
|
+
else
|
40
|
+
context.abort(USER_ERRORS_PARSE_ERROR)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Node
|
3
|
+
class Project < ShopifyCli::ProjectType
|
4
|
+
creator 'Node.js App', 'Node::Commands::Create'
|
5
|
+
|
6
|
+
register_command('Node::Commands::Deploy', "deploy")
|
7
|
+
register_command('Node::Commands::Generate', "generate")
|
8
|
+
register_command('Node::Commands::Open', "open")
|
9
|
+
register_command('Node::Commands::Populate', "populate")
|
10
|
+
register_command('Node::Commands::Serve', "serve")
|
11
|
+
register_command('Node::Commands::Tunnel', "tunnel")
|
12
|
+
# register_task('Node::Tasks::NodeTask', 'node_task')
|
13
|
+
|
14
|
+
require Project.project_filepath('messages/messages')
|
15
|
+
register_messages(Node::Messages::MESSAGES)
|
16
|
+
end
|
17
|
+
|
18
|
+
# define/autoload project specific Commands
|
19
|
+
module Commands
|
20
|
+
autoload :Create, Project.project_filepath('commands/create')
|
21
|
+
autoload :Deploy, Project.project_filepath('commands/deploy')
|
22
|
+
autoload :Generate, Project.project_filepath('commands/generate')
|
23
|
+
autoload :Open, Project.project_filepath('commands/open')
|
24
|
+
autoload :Populate, Project.project_filepath('commands/populate')
|
25
|
+
autoload :Serve, Project.project_filepath('commands/serve')
|
26
|
+
autoload :Tunnel, Project.project_filepath('commands/tunnel')
|
27
|
+
end
|
28
|
+
|
29
|
+
# define/autoload project specific Tasks
|
30
|
+
module Tasks
|
31
|
+
end
|
32
|
+
|
33
|
+
# define/autoload project specific Forms
|
34
|
+
module Forms
|
35
|
+
autoload :Create, Project.project_filepath('forms/create')
|
36
|
+
end
|
37
|
+
end
|