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,27 @@
|
|
1
|
+
mutation AppScriptUpdateOrCreate(
|
2
|
+
$extensionPointName: ExtensionPointName!,
|
3
|
+
$title: String,
|
4
|
+
$sourceCode: String,
|
5
|
+
$language: String,
|
6
|
+
$force: Boolean
|
7
|
+
) {
|
8
|
+
appScriptUpdateOrCreate(
|
9
|
+
extensionPointName: $extensionPointName
|
10
|
+
title: $title
|
11
|
+
sourceCode: $sourceCode
|
12
|
+
language: $language
|
13
|
+
force: $force
|
14
|
+
) {
|
15
|
+
userErrors {
|
16
|
+
field
|
17
|
+
message
|
18
|
+
tag
|
19
|
+
}
|
20
|
+
appScript {
|
21
|
+
appKey
|
22
|
+
configSchema
|
23
|
+
extensionPointName
|
24
|
+
title
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
mutation ShopScriptUpdateOrCreate(
|
2
|
+
$extensionPointName: ExtensionPointName!,
|
3
|
+
$configuration: ConfigurationInput,
|
4
|
+
$title: String
|
5
|
+
) {
|
6
|
+
shopScriptUpdateOrCreate(
|
7
|
+
extensionPointName: $extensionPointName,
|
8
|
+
configuration: $configuration,
|
9
|
+
title: $title
|
10
|
+
) {
|
11
|
+
userErrors {
|
12
|
+
field
|
13
|
+
message
|
14
|
+
tag
|
15
|
+
}
|
16
|
+
shopScript {
|
17
|
+
extensionPointName
|
18
|
+
shopId
|
19
|
+
title
|
20
|
+
configuration {
|
21
|
+
entries {
|
22
|
+
key,
|
23
|
+
value
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Application
|
6
|
+
class BuildScript
|
7
|
+
class << self
|
8
|
+
def call(ctx:, script:)
|
9
|
+
return if CLI::UI::Frame.open(ctx.message('script.application.building')) do
|
10
|
+
begin
|
11
|
+
UI::StrictSpinner.spin(ctx.message('script.application.building_script')) do |spinner|
|
12
|
+
build(script)
|
13
|
+
spinner.update_title(ctx.message('script.application.built'))
|
14
|
+
end
|
15
|
+
true
|
16
|
+
rescue StandardError => e
|
17
|
+
CLI::UI::Frame.with_frame_color_override(:red) do
|
18
|
+
ctx.puts("\n{{red:#{e.message}}}")
|
19
|
+
end
|
20
|
+
false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
raise Infrastructure::Errors::BuildError
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def build(script)
|
29
|
+
script_repo = Infrastructure::ScriptRepository.new
|
30
|
+
script_builder = Infrastructure::ScriptBuilder.for(script)
|
31
|
+
compiled_type = script_builder.compiled_type
|
32
|
+
script_content = script_repo.with_temp_build_context do
|
33
|
+
script_builder.build
|
34
|
+
end
|
35
|
+
|
36
|
+
Infrastructure::PushPackageRepository.new
|
37
|
+
.create_push_package(script, script_content, compiled_type)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "shopify_cli"
|
4
|
+
|
5
|
+
module Script
|
6
|
+
module Layers
|
7
|
+
module Application
|
8
|
+
class CreateScript
|
9
|
+
class << self
|
10
|
+
def call(ctx:, language:, script_name:, extension_point_type:)
|
11
|
+
extension_point = ExtensionPoints.get(type: extension_point_type)
|
12
|
+
create_project(ctx, language, script_name, extension_point)
|
13
|
+
create_definition(ctx, language, extension_point, script_name)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def create_project(ctx, language, script_name, extension_point)
|
19
|
+
ScriptProject.create(script_name)
|
20
|
+
ctx.root = File.join(ctx.root, script_name)
|
21
|
+
ScriptProject.write(
|
22
|
+
ctx,
|
23
|
+
project_type: :script,
|
24
|
+
organization_id: nil, # TODO: can you provide this at creation
|
25
|
+
extension_point_type: extension_point.type,
|
26
|
+
script_name: script_name
|
27
|
+
)
|
28
|
+
ProjectDependencies
|
29
|
+
.bootstrap(ctx: ctx, language: language, extension_point: extension_point, script_name: script_name)
|
30
|
+
ProjectDependencies
|
31
|
+
.install(ctx: ctx, language: language, extension_point: extension_point, script_name: script_name)
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_definition(ctx, language, extension_point, script_name)
|
35
|
+
script = nil
|
36
|
+
UI::StrictSpinner.spin(ctx.message('script.create.creating')) do |spinner|
|
37
|
+
script = Infrastructure::ScriptRepository.new.create_script(language, extension_point, script_name)
|
38
|
+
Infrastructure::TestSuiteRepository.new.create_test_suite(script)
|
39
|
+
spinner.update_title(ctx.message('script.create.created'))
|
40
|
+
end
|
41
|
+
script
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Application
|
6
|
+
class DisableScript
|
7
|
+
def self.call(ctx:, api_key:, shop_domain:, extension_point_type:)
|
8
|
+
script_service = Infrastructure::ScriptService.new(ctx: ctx)
|
9
|
+
script_service.disable(
|
10
|
+
api_key: api_key,
|
11
|
+
shop_domain: shop_domain,
|
12
|
+
extension_point_type: extension_point_type,
|
13
|
+
)
|
14
|
+
ctx.puts(ctx.message('script.application.disabled'))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Application
|
6
|
+
class EnableScript
|
7
|
+
def self.call(ctx:, api_key:, shop_domain:, configuration:, extension_point_type:, title:)
|
8
|
+
script_service = Infrastructure::ScriptService.new(ctx: ctx)
|
9
|
+
script_service.enable(
|
10
|
+
api_key: api_key,
|
11
|
+
shop_domain: shop_domain,
|
12
|
+
configuration: configuration,
|
13
|
+
extension_point_type: extension_point_type,
|
14
|
+
title: title
|
15
|
+
)
|
16
|
+
ctx.puts(ctx.message('script.application.enabled'))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Application
|
6
|
+
class ExtensionPoints
|
7
|
+
def self.get(type:)
|
8
|
+
Infrastructure::ExtensionPointRepository.new.get_extension_point(type)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.types
|
12
|
+
Infrastructure::ExtensionPointRepository.new.extension_point_types
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Script
|
2
|
+
module Layers
|
3
|
+
module Application
|
4
|
+
class ProjectDependencies
|
5
|
+
def self.bootstrap(ctx:, language:, extension_point:, script_name:)
|
6
|
+
dep_manager = Infrastructure::DependencyManager.for(ctx, language, extension_point, script_name)
|
7
|
+
dep_manager.bootstrap
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.install(ctx:, language:, extension_point:, script_name:)
|
11
|
+
dep_manager = Infrastructure::DependencyManager.for(ctx, language, extension_point, script_name)
|
12
|
+
CLI::UI::Frame.open(ctx.message('script.project_deps.checking_with_npm')) do
|
13
|
+
begin
|
14
|
+
if dep_manager.installed?
|
15
|
+
ctx.puts(ctx.message('script.project_deps.none_required'))
|
16
|
+
else
|
17
|
+
UI::StrictSpinner.spin(ctx.message('script.project_deps.installing')) do |spinner|
|
18
|
+
dep_manager.install
|
19
|
+
spinner.update_title(ctx.message('script.project_deps.installed'))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
true
|
23
|
+
rescue Infrastructure::Errors::DependencyInstallError => e
|
24
|
+
CLI::UI::Frame.with_frame_color_override(:red) do
|
25
|
+
ctx.puts("\n#{e.message}")
|
26
|
+
end
|
27
|
+
raise e
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Application
|
6
|
+
class PushScript
|
7
|
+
class << self
|
8
|
+
def call(ctx:, language:, extension_point_type:, script_name:, api_key:, force:)
|
9
|
+
extension_point = ExtensionPoints.get(type: extension_point_type)
|
10
|
+
script = Infrastructure::ScriptRepository.new.get_script(language, extension_point_type, script_name)
|
11
|
+
ProjectDependencies
|
12
|
+
.install(ctx: ctx, language: language, extension_point: extension_point, script_name: script_name)
|
13
|
+
BuildScript.call(ctx: ctx, script: script)
|
14
|
+
push_script(ctx, script, api_key, force)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def push_script(ctx, script, api_key, force)
|
20
|
+
compiled_type = Infrastructure::ScriptBuilder.for(script).compiled_type
|
21
|
+
Infrastructure::PushPackageRepository.new
|
22
|
+
.get_push_package(script, compiled_type)
|
23
|
+
.push(Infrastructure::ScriptService.new(ctx: ctx), api_key, force)
|
24
|
+
ctx.puts(ctx.message('script.application.pushed'))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Domain
|
6
|
+
module Errors
|
7
|
+
class PushPackageNotFoundError < ScriptProjectError; end
|
8
|
+
class InvalidExtensionPointError < ScriptProjectError
|
9
|
+
attr_reader :type
|
10
|
+
def initialize(type)
|
11
|
+
@type = type
|
12
|
+
end
|
13
|
+
end
|
14
|
+
class ScriptNotFoundError < ScriptProjectError
|
15
|
+
attr_reader :script_name, :extension_point_type
|
16
|
+
def initialize(extension_point_type, script_name)
|
17
|
+
@script_name = script_name
|
18
|
+
@extension_point_type = extension_point_type
|
19
|
+
end
|
20
|
+
end
|
21
|
+
class ServiceFailureError < ScriptProjectError; end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Domain
|
6
|
+
class ExtensionPoint
|
7
|
+
attr_reader :type, :sdks
|
8
|
+
|
9
|
+
def initialize(type, config)
|
10
|
+
@type = type
|
11
|
+
@sdks = {
|
12
|
+
ts: ExtensionPointAssemblyScriptSDK.new(config["assemblyscript"]),
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class ExtensionPointAssemblyScriptSDK
|
18
|
+
attr_reader :package, :version, :sdk_version, :toolchain_version
|
19
|
+
|
20
|
+
def initialize(config)
|
21
|
+
@package = config["package"]
|
22
|
+
@version = config["version"]
|
23
|
+
@sdk_version = config["sdk-version"]
|
24
|
+
@toolchain_version = config["toolchain-version"]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Domain
|
6
|
+
class PushPackage
|
7
|
+
attr_reader :id, :script, :script_content, :compiled_type
|
8
|
+
|
9
|
+
def initialize(id, script, script_content, compiled_type)
|
10
|
+
@id = id
|
11
|
+
@script = script
|
12
|
+
@script_content = script_content
|
13
|
+
@compiled_type = compiled_type
|
14
|
+
end
|
15
|
+
|
16
|
+
def push(script_service, api_key, force)
|
17
|
+
script_service.push(
|
18
|
+
extension_point_type: @script.extension_point_type,
|
19
|
+
script_name: @script.name,
|
20
|
+
script_content: @script_content,
|
21
|
+
compiled_type: @compiled_type,
|
22
|
+
api_key: api_key,
|
23
|
+
force: force
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Domain
|
6
|
+
class Script
|
7
|
+
attr_reader :id, :name, :extension_point_type, :language
|
8
|
+
|
9
|
+
def initialize(id, name, extension_point_type, language)
|
10
|
+
@id = id
|
11
|
+
@name = name
|
12
|
+
@extension_point_type = extension_point_type
|
13
|
+
@language = language
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Infrastructure
|
6
|
+
class AssemblyScriptDependencyManager
|
7
|
+
def initialize(ctx, language, extension_point, script_name)
|
8
|
+
@ctx = ctx
|
9
|
+
@language = language
|
10
|
+
@script_name = script_name
|
11
|
+
@extension_point = extension_point
|
12
|
+
end
|
13
|
+
|
14
|
+
def bootstrap
|
15
|
+
write_npmrc
|
16
|
+
write_package_json
|
17
|
+
end
|
18
|
+
|
19
|
+
def installed?
|
20
|
+
# Assuming if node_modules folder exist at root of script folder, all deps are installed
|
21
|
+
Dir.exist?("node_modules")
|
22
|
+
end
|
23
|
+
|
24
|
+
def install
|
25
|
+
check_node_version!
|
26
|
+
|
27
|
+
output, status = @ctx.capture2e("npm", "install", "--no-audit", "--no-optional", "--loglevel error")
|
28
|
+
raise Errors::DependencyInstallError, output unless status.success?
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def check_node_version!
|
34
|
+
output, status = @ctx.capture2e("node", "--version")
|
35
|
+
raise Errors::DependencyInstallError, output unless status.success?
|
36
|
+
|
37
|
+
version = Semantic::Version.new(output[1..-1])
|
38
|
+
unless version >= Semantic::Version.new("12.16.0")
|
39
|
+
raise Errors::DependencyInstallError, "Node version must be >= v12.16.0 Current version: #{output}."
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def write_npmrc
|
44
|
+
@ctx.system(
|
45
|
+
'npm', '--userconfig', './.npmrc', 'config', 'set', '@shopify:registry', 'https://registry.npmjs.com'
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def write_package_json
|
50
|
+
package_json = <<~HERE
|
51
|
+
{
|
52
|
+
"name": "#{@script_name}",
|
53
|
+
"version": "1.0.0",
|
54
|
+
"devDependencies": {
|
55
|
+
"@shopify/scripts-sdk-as": "#{@extension_point.sdks[:ts].sdk_version}",
|
56
|
+
"@shopify/scripts-toolchain-as": "#{@extension_point.sdks[:ts].toolchain_version}",
|
57
|
+
"#{@extension_point.sdks[:ts].package}": "#{@extension_point.sdks[:ts].version}",
|
58
|
+
"@as-pect/cli": "4.0.0",
|
59
|
+
"as-wasi": "^0.0.1",
|
60
|
+
"assemblyscript": "^0.12.0"
|
61
|
+
},
|
62
|
+
"scripts": {
|
63
|
+
"test": "asp --config test/as-pect.config.js --summary --verbose"
|
64
|
+
}
|
65
|
+
}
|
66
|
+
HERE
|
67
|
+
|
68
|
+
File.write("package.json", package_json)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|