shopify-cli 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +12 -12
- data/Rakefile +32 -30
- data/bin/load_shopify.rb +6 -6
- data/bin/shopify +2 -2
- data/ext/shopify-cli/extconf.rb +7 -7
- data/lib/docgen/markdown.rb +11 -11
- data/lib/{project_types/extension/graphql → graphql}/get_app_by_api_key.graphql +0 -0
- data/lib/project_types/extension/cli.rb +52 -45
- data/lib/project_types/extension/commands/build.rb +3 -3
- data/lib/project_types/extension/commands/create.rb +16 -9
- data/lib/project_types/extension/commands/extension_command.rb +8 -5
- data/lib/project_types/extension/commands/push.rb +8 -8
- data/lib/project_types/extension/commands/register.rb +19 -30
- data/lib/project_types/extension/commands/serve.rb +2 -2
- data/lib/project_types/extension/commands/tunnel.rb +12 -12
- data/lib/project_types/extension/extension_project.rb +4 -4
- data/lib/project_types/extension/extension_project_keys.rb +4 -4
- data/lib/project_types/extension/features/argo.rb +13 -13
- data/lib/project_types/extension/features/argo_config.rb +5 -5
- data/lib/project_types/extension/features/argo_dependencies.rb +5 -5
- data/lib/project_types/extension/features/argo_setup.rb +2 -2
- data/lib/project_types/extension/features/argo_setup_steps.rb +4 -4
- data/lib/project_types/extension/forms/create.rb +28 -34
- data/lib/project_types/extension/forms/questions/ask_app.rb +53 -0
- data/lib/project_types/extension/forms/questions/ask_name.rb +40 -0
- data/lib/project_types/extension/forms/questions/ask_type.rb +36 -0
- data/lib/project_types/extension/messages/messages.rb +53 -52
- data/lib/project_types/extension/models/lazy_specification_handler.rb +12 -0
- data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +1 -1
- data/lib/project_types/extension/models/specification_handlers/default.rb +2 -2
- data/lib/project_types/extension/models/specifications.rb +3 -3
- data/lib/project_types/extension/tasks/configure_features.rb +4 -4
- data/lib/project_types/extension/tasks/converters/app_converter.rb +6 -6
- data/lib/project_types/extension/tasks/converters/registration_converter.rb +6 -6
- data/lib/project_types/extension/tasks/converters/validation_error_converter.rb +4 -4
- data/lib/project_types/extension/tasks/converters/version_converter.rb +7 -7
- data/lib/project_types/extension/tasks/create_extension.rb +4 -4
- data/lib/project_types/extension/tasks/fetch_specifications.rb +4 -4
- data/lib/project_types/extension/tasks/get_app.rb +4 -4
- data/lib/project_types/extension/tasks/get_apps.rb +3 -3
- data/lib/project_types/extension/tasks/update_draft.rb +4 -4
- data/lib/project_types/extension/tasks/user_errors.rb +4 -4
- data/lib/project_types/node/cli.rb +19 -19
- data/lib/project_types/node/commands/connect.rb +3 -3
- data/lib/project_types/node/commands/create.rb +40 -38
- data/lib/project_types/node/commands/deploy.rb +4 -4
- data/lib/project_types/node/commands/deploy/heroku.rb +24 -24
- data/lib/project_types/node/commands/generate.rb +8 -8
- data/lib/project_types/node/commands/open.rb +2 -2
- data/lib/project_types/node/commands/populate.rb +6 -6
- data/lib/project_types/node/commands/populate/customer.rb +5 -5
- data/lib/project_types/node/commands/populate/draft_order.rb +5 -5
- data/lib/project_types/node/commands/populate/product.rb +5 -5
- data/lib/project_types/node/commands/serve.rb +9 -9
- data/lib/project_types/node/commands/tunnel.rb +7 -7
- data/lib/project_types/node/forms/create.rb +7 -7
- data/lib/project_types/node/messages/messages.rb +3 -3
- data/lib/project_types/rails/cli.rb +21 -21
- data/lib/project_types/rails/commands/connect.rb +3 -3
- data/lib/project_types/rails/commands/create.rb +51 -48
- data/lib/project_types/rails/commands/deploy.rb +4 -4
- data/lib/project_types/rails/commands/deploy/heroku.rb +30 -30
- data/lib/project_types/rails/commands/generate.rb +7 -7
- data/lib/project_types/rails/commands/generate/webhook.rb +6 -6
- data/lib/project_types/rails/commands/open.rb +2 -2
- data/lib/project_types/rails/commands/populate.rb +6 -6
- data/lib/project_types/rails/commands/populate/customer.rb +5 -5
- data/lib/project_types/rails/commands/populate/draft_order.rb +5 -5
- data/lib/project_types/rails/commands/populate/product.rb +5 -5
- data/lib/project_types/rails/commands/serve.rb +11 -11
- data/lib/project_types/rails/commands/tunnel.rb +7 -7
- data/lib/project_types/rails/forms/create.rb +23 -23
- data/lib/project_types/rails/gem.rb +23 -23
- data/lib/project_types/rails/messages/messages.rb +4 -4
- data/lib/project_types/rails/ruby.rb +2 -2
- data/lib/project_types/script/cli.rb +40 -40
- data/lib/project_types/script/commands/create.rb +9 -8
- data/lib/project_types/script/commands/disable.rb +3 -3
- data/lib/project_types/script/commands/enable.rb +9 -7
- data/lib/project_types/script/commands/push.rb +5 -4
- data/lib/project_types/script/errors.rb +17 -0
- data/lib/project_types/script/forms/create.rb +5 -5
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +2 -0
- data/lib/project_types/script/layers/application/build_script.rb +6 -8
- data/lib/project_types/script/layers/application/create_script.rb +2 -2
- data/lib/project_types/script/layers/application/disable_script.rb +2 -2
- data/lib/project_types/script/layers/application/enable_script.rb +2 -2
- data/lib/project_types/script/layers/application/project_dependencies.rb +4 -4
- data/lib/project_types/script/layers/application/push_script.rb +4 -12
- data/lib/project_types/script/layers/domain/push_package.rb +5 -1
- data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +3 -3
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +10 -10
- data/lib/project_types/script/layers/infrastructure/errors.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +2 -2
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +12 -17
- data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +4 -4
- data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/script_service.rb +18 -16
- data/lib/project_types/script/messages/messages.rb +14 -8
- data/lib/project_types/script/script_project.rb +27 -5
- data/lib/project_types/script/ui/error_handler.rb +80 -68
- data/lib/project_types/script/ui/printing_spinner.rb +1 -1
- data/lib/project_types/script/ui/strict_spinner.rb +1 -1
- data/lib/project_types/theme/cli.rb +19 -19
- data/lib/project_types/theme/commands/connect.rb +12 -12
- data/lib/project_types/theme/commands/create.rb +11 -11
- data/lib/project_types/theme/commands/deploy.rb +8 -8
- data/lib/project_types/theme/commands/generate.rb +3 -3
- data/lib/project_types/theme/commands/generate/env.rb +15 -15
- data/lib/project_types/theme/commands/push.rb +15 -15
- data/lib/project_types/theme/commands/serve.rb +5 -5
- data/lib/project_types/theme/forms/connect.rb +4 -4
- data/lib/project_types/theme/forms/create.rb +5 -5
- data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +22 -22
- data/lib/project_types/theme/themekit.rb +15 -15
- data/lib/rubygems_plugin.rb +3 -3
- data/lib/shopify-cli/admin_api.rb +11 -11
- data/lib/shopify-cli/admin_api/populate_resource_command.rb +17 -17
- data/lib/shopify-cli/admin_api/schema.rb +3 -3
- data/lib/shopify-cli/api.rb +10 -10
- data/lib/shopify-cli/command.rb +1 -1
- data/lib/shopify-cli/commands.rb +9 -9
- data/lib/shopify-cli/commands/config.rb +28 -52
- data/lib/shopify-cli/commands/connect.rb +10 -10
- data/lib/shopify-cli/commands/create.rb +5 -5
- data/lib/shopify-cli/commands/help.rb +6 -6
- data/lib/shopify-cli/commands/logout.rb +3 -3
- data/lib/shopify-cli/commands/system.rb +32 -32
- data/lib/shopify-cli/commands/version.rb +2 -2
- data/lib/shopify-cli/context.rb +23 -23
- data/lib/shopify-cli/core.rb +4 -4
- data/lib/shopify-cli/core/entry_point.rb +5 -5
- data/lib/shopify-cli/core/executor.rb +1 -1
- data/lib/shopify-cli/core/help_resolver.rb +2 -2
- data/lib/shopify-cli/core/monorail.rb +16 -16
- data/lib/shopify-cli/db.rb +2 -2
- data/lib/shopify-cli/feature.rb +1 -1
- data/lib/shopify-cli/form.rb +1 -1
- data/lib/shopify-cli/git.rb +17 -17
- data/lib/shopify-cli/helpers.rb +1 -1
- data/lib/shopify-cli/helpers/haikunator.rb +1 -1
- data/lib/shopify-cli/heroku.rb +28 -28
- data/lib/shopify-cli/http_request.rb +2 -2
- data/lib/shopify-cli/js_deps.rb +12 -12
- data/lib/shopify-cli/js_system.rb +5 -5
- data/lib/shopify-cli/lazy_delegator.rb +55 -0
- data/lib/shopify-cli/messages/messages.rb +4 -14
- data/lib/shopify-cli/oauth.rb +25 -25
- data/lib/shopify-cli/oauth/servlet.rb +9 -9
- data/lib/shopify-cli/options.rb +3 -3
- data/lib/shopify-cli/packager.rb +24 -24
- data/lib/shopify-cli/partners_api.rb +16 -16
- data/lib/shopify-cli/partners_api/organizations.rb +10 -10
- data/lib/shopify-cli/process_supervision.rb +7 -7
- data/lib/shopify-cli/project.rb +16 -16
- data/lib/shopify-cli/project_type.rb +3 -3
- data/lib/shopify-cli/resources.rb +1 -1
- data/lib/shopify-cli/resources/env_file.rb +9 -9
- data/lib/shopify-cli/result.rb +8 -8
- data/lib/shopify-cli/shopifolk.rb +6 -9
- data/lib/shopify-cli/sub_command.rb +1 -1
- data/lib/shopify-cli/task.rb +3 -3
- data/lib/shopify-cli/tasks.rb +7 -7
- data/lib/shopify-cli/tasks/create_api_client.rb +5 -5
- data/lib/shopify-cli/tasks/ensure_dev_store.rb +11 -11
- data/lib/shopify-cli/tasks/ensure_env.rb +15 -15
- data/lib/shopify-cli/tasks/ensure_loopback_url.rb +4 -4
- data/lib/shopify-cli/tasks/select_org_and_shop.rb +19 -19
- data/lib/shopify-cli/tasks/update_dashboard_urls.rb +10 -10
- data/lib/shopify-cli/transform_data_structure.rb +86 -0
- data/lib/shopify-cli/tunnel.rb +30 -30
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +56 -54
- data/shopify-cli.gemspec +6 -6
- data/vendor/gen/template/bin/update-deps +9 -9
- metadata +9 -4
- data/lib/project_types/extension/forms/register.rb +0 -47
@@ -0,0 +1,12 @@
|
|
1
|
+
module Extension
|
2
|
+
module Models
|
3
|
+
class LazySpecificationHandler < ShopifyCli::LazyDelegator
|
4
|
+
attr_reader :identifier
|
5
|
+
|
6
|
+
def initialize(identifier, &specification_handler_initializer)
|
7
|
+
super(&specification_handler_initializer)
|
8
|
+
@identifier = identifier
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -5,7 +5,7 @@ module Extension
|
|
5
5
|
|
6
6
|
property! :custom_handler_root,
|
7
7
|
accepts: ->(d) { File.directory?(d) },
|
8
|
-
default: -> { File.expand_path(
|
8
|
+
default: -> { File.expand_path("lib/project_types/extension/models/specification_handlers", ShopifyCli::ROOT) }
|
9
9
|
|
10
10
|
property! :custom_handler_namespace,
|
11
11
|
accepts: ->(m) { m.respond_to?(:const_get) },
|
@@ -64,8 +64,8 @@ module Extension
|
|
64
64
|
|
65
65
|
def ensure_legacy_compatibility(specification_attribute_sets)
|
66
66
|
specification_attribute_sets.each do |attributes|
|
67
|
-
next unless attributes.fetch(:identifier) ==
|
68
|
-
attributes[:graphql_identifier] =
|
67
|
+
next unless attributes.fetch(:identifier) == "product_subscription"
|
68
|
+
attributes[:graphql_identifier] = "SUBSCRIPTION_MANAGEMENT"
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -38,12 +38,12 @@ module Extension
|
|
38
38
|
def surface_area_configurations
|
39
39
|
{
|
40
40
|
admin: {
|
41
|
-
git_template:
|
42
|
-
renderer_package_name:
|
41
|
+
git_template: "https://github.com/Shopify/argo-admin-template.git",
|
42
|
+
renderer_package_name: "@shopify/argo-admin",
|
43
43
|
},
|
44
44
|
checkout: {
|
45
|
-
git_template:
|
46
|
-
renderer_package_name:
|
45
|
+
git_template: "https://github.com/Shopify/argo-checkout-template.git",
|
46
|
+
renderer_package_name: "@shopify/argo-checkout",
|
47
47
|
},
|
48
48
|
}
|
49
49
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "shopify_cli"
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
module Tasks
|
6
6
|
module Converters
|
7
7
|
module AppConverter
|
8
|
-
API_KEY_FIELD =
|
9
|
-
API_SECRET_KEYS_FIELD =
|
10
|
-
API_SECRET_FIELD =
|
11
|
-
TITLE_FIELD =
|
12
|
-
ORGANIZATION_NAME_FIELD =
|
8
|
+
API_KEY_FIELD = "apiKey"
|
9
|
+
API_SECRET_KEYS_FIELD = "apiSecretKeys"
|
10
|
+
API_SECRET_FIELD = "secret"
|
11
|
+
TITLE_FIELD = "title"
|
12
|
+
ORGANIZATION_NAME_FIELD = "businessName"
|
13
13
|
|
14
14
|
def self.from_hash(hash, organization = {})
|
15
15
|
return nil if hash.nil?
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "shopify_cli"
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
module Tasks
|
6
6
|
module Converters
|
7
7
|
module RegistrationConverter
|
8
|
-
ID_FIELD =
|
9
|
-
TYPE_FIELD =
|
10
|
-
TITLE_FIELD =
|
11
|
-
DRAFT_VERSION_FIELD =
|
8
|
+
ID_FIELD = "id"
|
9
|
+
TYPE_FIELD = "type"
|
10
|
+
TITLE_FIELD = "title"
|
11
|
+
DRAFT_VERSION_FIELD = "draftVersion"
|
12
12
|
|
13
13
|
def self.from_hash(context, hash)
|
14
|
-
context.abort(context.message(
|
14
|
+
context.abort(context.message("tasks.errors.parse_error")) if hash.nil?
|
15
15
|
|
16
16
|
Models::Registration.new(
|
17
17
|
id: hash[ID_FIELD].to_i,
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "shopify_cli"
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
module Tasks
|
6
6
|
module Converters
|
7
7
|
module ValidationErrorConverter
|
8
|
-
FIELD_FIELD =
|
9
|
-
MESSAGE_FIELD =
|
8
|
+
FIELD_FIELD = "field"
|
9
|
+
MESSAGE_FIELD = "message"
|
10
10
|
|
11
11
|
def self.from_array(context, errors)
|
12
12
|
return [] if errors.nil?
|
13
|
-
context.abort(context.message(
|
13
|
+
context.abort(context.message("tasks.errors.parse_error")) unless errors.is_a?(Array)
|
14
14
|
|
15
15
|
errors.map do |error|
|
16
16
|
Models::ValidationError.new(
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "shopify_cli"
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
module Tasks
|
6
6
|
module Converters
|
7
7
|
module VersionConverter
|
8
|
-
REGISTRATION_ID_FIELD =
|
9
|
-
CONTEXT_FIELD =
|
10
|
-
LAST_USER_INTERACTION_AT_FIELD =
|
11
|
-
LOCATION_FIELD =
|
12
|
-
VALIDATION_ERRORS_FIELD =
|
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
13
|
|
14
14
|
def self.from_hash(context, hash)
|
15
|
-
context.abort(context.message(
|
15
|
+
context.abort(context.message("tasks.errors.parse_error")) if hash.nil?
|
16
16
|
|
17
17
|
Models::Version.new(
|
18
18
|
registration_id: hash[REGISTRATION_ID_FIELD].to_i,
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "shopify_cli"
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
module Tasks
|
6
6
|
class CreateExtension < ShopifyCli::Task
|
7
7
|
include UserErrors
|
8
8
|
|
9
|
-
GRAPHQL_FILE =
|
9
|
+
GRAPHQL_FILE = "extension_create"
|
10
10
|
|
11
11
|
RESPONSE_FIELD = %w(data extensionCreate)
|
12
|
-
REGISTRATION_FIELD =
|
12
|
+
REGISTRATION_FIELD = "extensionRegistration"
|
13
13
|
|
14
14
|
def call(context:, api_key:, type:, title:, config:, extension_context: nil)
|
15
15
|
input = {
|
@@ -21,7 +21,7 @@ module Extension
|
|
21
21
|
}
|
22
22
|
|
23
23
|
response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
|
24
|
-
context.abort(context.message(
|
24
|
+
context.abort(context.message("tasks.errors.parse_error")) if response.nil?
|
25
25
|
|
26
26
|
abort_if_user_errors(context, response)
|
27
27
|
Converters::RegistrationConverter.from_hash(context, response.dig(REGISTRATION_FIELD))
|
@@ -14,10 +14,10 @@ module Extension
|
|
14
14
|
|
15
15
|
def product_subscription_specification
|
16
16
|
{
|
17
|
-
identifier:
|
17
|
+
identifier: "product_subscription",
|
18
18
|
features: {
|
19
19
|
argo: {
|
20
|
-
surface_area:
|
20
|
+
surface_area: "admin",
|
21
21
|
},
|
22
22
|
},
|
23
23
|
}
|
@@ -25,10 +25,10 @@ module Extension
|
|
25
25
|
|
26
26
|
def checkout_post_purchase_specification
|
27
27
|
{
|
28
|
-
identifier:
|
28
|
+
identifier: "checkout_post_purchase",
|
29
29
|
features: {
|
30
30
|
argo: {
|
31
|
-
surface_area:
|
31
|
+
surface_area: "checkout",
|
32
32
|
},
|
33
33
|
},
|
34
34
|
}
|
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "shopify_cli"
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
module Tasks
|
6
6
|
class GetApp < ShopifyCli::Task
|
7
|
-
GRAPHQL_FILE =
|
7
|
+
GRAPHQL_FILE = "get_app_by_api_key"
|
8
8
|
|
9
9
|
RESPONSE_FIELD = %w(data)
|
10
|
-
APP_FIELD =
|
10
|
+
APP_FIELD = "app"
|
11
11
|
|
12
12
|
def call(context:, api_key:)
|
13
13
|
input = { api_key: api_key }
|
14
14
|
|
15
15
|
response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
|
16
|
-
context.abort(context.message(
|
16
|
+
context.abort(context.message("tasks.errors.parse_error")) if response.nil?
|
17
17
|
|
18
18
|
Converters::AppConverter.from_hash(response.dig(APP_FIELD))
|
19
19
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "shopify_cli"
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
module Tasks
|
@@ -18,9 +18,9 @@ module Extension
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def apps_owned_by_organization(organization)
|
21
|
-
return [] unless organization.key?(
|
21
|
+
return [] unless organization.key?("apps") && organization["apps"].any?
|
22
22
|
|
23
|
-
organization[
|
23
|
+
organization["apps"].map do |app|
|
24
24
|
Converters::AppConverter.from_hash(app, organization)
|
25
25
|
end
|
26
26
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "shopify_cli"
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
module Tasks
|
6
6
|
class UpdateDraft < ShopifyCli::Task
|
7
7
|
include UserErrors
|
8
8
|
|
9
|
-
GRAPHQL_FILE =
|
9
|
+
GRAPHQL_FILE = "extension_update_draft"
|
10
10
|
|
11
11
|
RESPONSE_FIELD = %w(data extensionUpdateDraft)
|
12
|
-
VERSION_FIELD =
|
12
|
+
VERSION_FIELD = "extensionVersion"
|
13
13
|
|
14
14
|
def call(context:, api_key:, registration_id:, config:, extension_context:)
|
15
15
|
input = {
|
@@ -19,7 +19,7 @@ module Extension
|
|
19
19
|
extension_context: extension_context,
|
20
20
|
}
|
21
21
|
response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
|
22
|
-
context.abort(context.message(
|
22
|
+
context.abort(context.message("tasks.errors.parse_error")) if response.nil?
|
23
23
|
|
24
24
|
abort_if_user_errors(context, response)
|
25
25
|
Converters::VersionConverter.from_hash(context, response.dig(VERSION_FIELD))
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "shopify_cli"
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
module Tasks
|
6
6
|
module UserErrors
|
7
|
-
USER_ERRORS_FIELD =
|
8
|
-
MESSAGE_FIELD =
|
9
|
-
USER_ERRORS_PARSE_ERROR =
|
7
|
+
USER_ERRORS_FIELD = "userErrors"
|
8
|
+
MESSAGE_FIELD = "message"
|
9
|
+
USER_ERRORS_PARSE_ERROR = "Unable to parse errors from server."
|
10
10
|
|
11
11
|
def abort_if_user_errors(context, response)
|
12
12
|
return if response.nil?
|
@@ -1,32 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Node
|
3
3
|
class Project < ShopifyCli::ProjectType
|
4
|
-
title(
|
5
|
-
creator(
|
6
|
-
connector(
|
4
|
+
title("Node.js App")
|
5
|
+
creator("Node::Commands::Create")
|
6
|
+
connector("Node::Commands::Connect")
|
7
7
|
|
8
|
-
register_command(
|
9
|
-
register_command(
|
10
|
-
register_command(
|
11
|
-
register_command(
|
12
|
-
register_command(
|
13
|
-
register_command(
|
8
|
+
register_command("Node::Commands::Deploy", "deploy")
|
9
|
+
register_command("Node::Commands::Generate", "generate")
|
10
|
+
register_command("Node::Commands::Open", "open")
|
11
|
+
register_command("Node::Commands::Populate", "populate")
|
12
|
+
register_command("Node::Commands::Serve", "serve")
|
13
|
+
register_command("Node::Commands::Tunnel", "tunnel")
|
14
14
|
# register_task('Node::Tasks::NodeTask', 'node_task')
|
15
15
|
|
16
|
-
require Project.project_filepath(
|
16
|
+
require Project.project_filepath("messages/messages")
|
17
17
|
register_messages(Node::Messages::MESSAGES)
|
18
18
|
end
|
19
19
|
|
20
20
|
# define/autoload project specific Commands
|
21
21
|
module Commands
|
22
|
-
autoload :Connect, Project.project_filepath(
|
23
|
-
autoload :Create, Project.project_filepath(
|
24
|
-
autoload :Deploy, Project.project_filepath(
|
25
|
-
autoload :Generate, Project.project_filepath(
|
26
|
-
autoload :Open, Project.project_filepath(
|
27
|
-
autoload :Populate, Project.project_filepath(
|
28
|
-
autoload :Serve, Project.project_filepath(
|
29
|
-
autoload :Tunnel, Project.project_filepath(
|
22
|
+
autoload :Connect, Project.project_filepath("commands/connect")
|
23
|
+
autoload :Create, Project.project_filepath("commands/create")
|
24
|
+
autoload :Deploy, Project.project_filepath("commands/deploy")
|
25
|
+
autoload :Generate, Project.project_filepath("commands/generate")
|
26
|
+
autoload :Open, Project.project_filepath("commands/open")
|
27
|
+
autoload :Populate, Project.project_filepath("commands/populate")
|
28
|
+
autoload :Serve, Project.project_filepath("commands/serve")
|
29
|
+
autoload :Tunnel, Project.project_filepath("commands/tunnel")
|
30
30
|
end
|
31
31
|
|
32
32
|
# define/autoload project specific Tasks
|
@@ -35,6 +35,6 @@ module Node
|
|
35
35
|
|
36
36
|
# define/autoload project specific Forms
|
37
37
|
module Forms
|
38
|
-
autoload :Create, Project.project_filepath(
|
38
|
+
autoload :Create, Project.project_filepath("forms/create")
|
39
39
|
end
|
40
40
|
end
|
@@ -4,11 +4,11 @@ module Node
|
|
4
4
|
class Connect < ShopifyCli::SubCommand
|
5
5
|
def call(*)
|
6
6
|
if ShopifyCli::Project.has_current? && ShopifyCli::Project.current.env
|
7
|
-
@ctx.puts(@ctx.message(
|
7
|
+
@ctx.puts(@ctx.message("node.connect.production_warning"))
|
8
8
|
end
|
9
9
|
|
10
|
-
app = ShopifyCli::Commands::Connect.new.default_connect(
|
11
|
-
@ctx.done(@ctx.message(
|
10
|
+
app = ShopifyCli::Commands::Connect.new.default_connect("node")
|
11
|
+
@ctx.done(@ctx.message("node.connect.connected", app))
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -4,12 +4,14 @@ module Node
|
|
4
4
|
class Create < ShopifyCli::SubCommand
|
5
5
|
options do |parser, flags|
|
6
6
|
# backwards compatibility allow 'title' for now
|
7
|
-
parser.on(
|
8
|
-
parser.on(
|
9
|
-
parser.on(
|
10
|
-
parser.on(
|
11
|
-
parser.on(
|
12
|
-
parser.on(
|
7
|
+
parser.on("--title=TITLE") { |t| flags[:title] = t }
|
8
|
+
parser.on("--name=NAME") { |t| flags[:title] = t }
|
9
|
+
parser.on("--organization_id=ID") { |url| flags[:organization_id] = url }
|
10
|
+
parser.on("--organization-id=ID") { |url| flags[:organization_id] = url }
|
11
|
+
parser.on("--shop_domain=MYSHOPIFYDOMAIN") { |url| flags[:shop_domain] = url }
|
12
|
+
parser.on("--shop-domain=MYSHOPIFYDOMAIN") { |url| flags[:shop_domain] = url }
|
13
|
+
parser.on("--type=APPTYPE") { |url| flags[:type] = url }
|
14
|
+
parser.on("--verbose") { flags[:verbose] = true }
|
13
15
|
end
|
14
16
|
|
15
17
|
def call(args, _name)
|
@@ -22,7 +24,7 @@ module Node
|
|
22
24
|
|
23
25
|
ShopifyCli::Project.write(
|
24
26
|
@ctx,
|
25
|
-
project_type:
|
27
|
+
project_type: "node",
|
26
28
|
organization_id: form.organization_id,
|
27
29
|
)
|
28
30
|
|
@@ -37,65 +39,65 @@ module Node
|
|
37
39
|
api_key: api_client["apiKey"],
|
38
40
|
secret: api_client["apiSecretKeys"].first["secret"],
|
39
41
|
shop: form.shop_domain,
|
40
|
-
scopes:
|
42
|
+
scopes: "write_products,write_customers,write_draft_orders",
|
41
43
|
).write(@ctx)
|
42
44
|
|
43
|
-
partners_url = ShopifyCli::PartnersAPI.partners_url_for(form.organization_id, api_client[
|
45
|
+
partners_url = ShopifyCli::PartnersAPI.partners_url_for(form.organization_id, api_client["id"], local_debug?)
|
44
46
|
|
45
|
-
@ctx.puts(@ctx.message(
|
46
|
-
@ctx.puts(@ctx.message(
|
47
|
+
@ctx.puts(@ctx.message("apps.create.info.created", form.title, partners_url))
|
48
|
+
@ctx.puts(@ctx.message("apps.create.info.serve", form.name, ShopifyCli::TOOL_NAME))
|
47
49
|
unless ShopifyCli::Shopifolk.acting_as_shopify_organization?
|
48
|
-
@ctx.puts(@ctx.message(
|
50
|
+
@ctx.puts(@ctx.message("apps.create.info.install", partners_url, form.title))
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
52
54
|
def self.help
|
53
|
-
ShopifyCli::Context.message(
|
55
|
+
ShopifyCli::Context.message("node.create.help", ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
|
54
56
|
end
|
55
57
|
|
56
58
|
private
|
57
59
|
|
58
60
|
def check_node
|
59
|
-
cmd_path = @ctx.which(
|
60
|
-
@ctx.abort(@ctx.message(
|
61
|
+
cmd_path = @ctx.which("node")
|
62
|
+
@ctx.abort(@ctx.message("node.create.error.node_required")) if cmd_path.nil?
|
61
63
|
|
62
|
-
version, stat = @ctx.capture2e(
|
63
|
-
@ctx.abort(@ctx.message(
|
64
|
+
version, stat = @ctx.capture2e("node", "-v")
|
65
|
+
@ctx.abort(@ctx.message("node.create.error.node_version_failure")) unless stat.success?
|
64
66
|
|
65
|
-
@ctx.done(@ctx.message(
|
67
|
+
@ctx.done(@ctx.message("node.create.node_version", version))
|
66
68
|
end
|
67
69
|
|
68
70
|
def check_npm
|
69
|
-
cmd_path = @ctx.which(
|
70
|
-
@ctx.abort(@ctx.message(
|
71
|
+
cmd_path = @ctx.which("npm")
|
72
|
+
@ctx.abort(@ctx.message("node.create.error.npm_required")) if cmd_path.nil?
|
71
73
|
|
72
|
-
version, stat = @ctx.capture2e(
|
73
|
-
@ctx.abort(@ctx.message(
|
74
|
+
version, stat = @ctx.capture2e("npm", "-v")
|
75
|
+
@ctx.abort(@ctx.message("node.create.error.npm_version_failure")) unless stat.success?
|
74
76
|
|
75
|
-
@ctx.done(@ctx.message(
|
77
|
+
@ctx.done(@ctx.message("node.create.npm_version", version))
|
76
78
|
end
|
77
79
|
|
78
80
|
def set_npm_config
|
79
81
|
# check available npmrc (either user or system) for production registry
|
80
|
-
registry, _ = @ctx.capture2(
|
81
|
-
return if registry.include?(
|
82
|
+
registry, _ = @ctx.capture2("npm config get @shopify:registry")
|
83
|
+
return if registry.include?("https://registry.yarnpkg.com")
|
82
84
|
|
83
85
|
# available npmrc doesn't have production registry =>
|
84
86
|
# set a project-based .npmrc
|
85
87
|
@ctx.system(
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
88
|
+
"npm",
|
89
|
+
"--userconfig",
|
90
|
+
"./.npmrc",
|
91
|
+
"config",
|
92
|
+
"set",
|
93
|
+
"@shopify:registry",
|
94
|
+
"https://registry.yarnpkg.com",
|
93
95
|
chdir: @ctx.root
|
94
96
|
)
|
95
97
|
end
|
96
98
|
|
97
99
|
def build(name)
|
98
|
-
ShopifyCli::Git.clone(
|
100
|
+
ShopifyCli::Git.clone("https://github.com/Shopify/shopify-app-node.git", name)
|
99
101
|
|
100
102
|
@ctx.root = File.join(@ctx.root, name)
|
101
103
|
|
@@ -103,12 +105,12 @@ module Node
|
|
103
105
|
ShopifyCli::JsDeps.install(@ctx, !options.flags[:verbose].nil?)
|
104
106
|
|
105
107
|
begin
|
106
|
-
@ctx.rm_r(
|
107
|
-
@ctx.rm_r(
|
108
|
-
@ctx.rm(File.join(
|
108
|
+
@ctx.rm_r(".git")
|
109
|
+
@ctx.rm_r(".github")
|
110
|
+
@ctx.rm(File.join("server", "handlers", "client.js"))
|
109
111
|
@ctx.rename(
|
110
|
-
File.join(
|
111
|
-
File.join(
|
112
|
+
File.join("server", "handlers", "client.cli.js"),
|
113
|
+
File.join("server", "handlers", "client.js")
|
112
114
|
)
|
113
115
|
rescue Errno::ENOENT => e
|
114
116
|
@ctx.debug(e)
|