shopify-cli 2.11.2 → 2.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +5 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +1 -1
- data/.github/workflows/shopify.yml +2 -1
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +44 -1
- data/Gemfile.lock +18 -18
- data/Rakefile +16 -0
- data/bin/shopify +12 -8
- data/dev.yml +1 -1
- data/docs/users/installation.md +1 -44
- data/ext/javy/hashes/javy-arm-macos-v0.2.0.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-arm-macos-v0.2.1.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-linux-v0.2.0.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-linux-v0.2.1.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-macos-v0.2.0.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-macos-v0.2.1.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-windows-v0.2.0.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-windows-v0.2.1.gz.sha256 +1 -0
- data/ext/javy/version +1 -1
- data/lib/project_types/extension/features/argo_setup_steps.rb +4 -6
- data/lib/project_types/extension/models/npm_package.rb +19 -1
- data/lib/project_types/extension/models/server_config/development_renderer.rb +4 -3
- data/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +114 -0
- data/lib/project_types/extension/tasks/configure_features.rb +15 -2
- data/lib/project_types/extension/tasks/convert_server_config.rb +2 -1
- data/lib/project_types/script/cli.rb +2 -4
- data/lib/project_types/script/commands/create.rb +5 -5
- data/lib/project_types/script/commands/push.rb +4 -6
- data/lib/project_types/script/config/extension_points.yml +0 -10
- data/lib/project_types/script/errors.rb +1 -1
- data/lib/project_types/script/forms/create.rb +7 -20
- data/lib/project_types/script/layers/application/build_script.rb +9 -26
- data/lib/project_types/script/layers/application/connect_app.rb +3 -2
- data/lib/project_types/script/layers/application/create_script.rb +9 -10
- data/lib/project_types/script/layers/application/project_dependencies.rb +12 -14
- data/lib/project_types/script/layers/application/push_script.rb +14 -10
- data/lib/project_types/script/layers/domain/errors.rb +3 -3
- data/lib/project_types/script/layers/domain/push_package.rb +6 -0
- data/lib/project_types/script/layers/domain/script_config.rb +2 -4
- data/lib/project_types/script/layers/domain/script_project.rb +3 -2
- data/lib/project_types/script/layers/infrastructure/errors.rb +11 -0
- data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +0 -16
- data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +0 -1
- data/lib/project_types/script/layers/infrastructure/languages/tool_version_checker.rb +26 -0
- data/lib/project_types/script/layers/infrastructure/languages/typescript_project_creator.rb +22 -10
- data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +32 -29
- data/lib/project_types/script/layers/infrastructure/languages/wasm_project_creator.rb +0 -3
- data/lib/project_types/script/layers/infrastructure/languages/wasm_task_runner.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +3 -21
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +14 -26
- data/lib/project_types/script/layers/infrastructure/script_service.rb +4 -2
- data/lib/project_types/script/loaders/project.rb +8 -7
- data/lib/project_types/script/messages/messages.rb +22 -21
- data/lib/project_types/script/ui/error_handler.rb +17 -4
- data/lib/project_types/script/ui/strict_spinner.rb +4 -6
- data/lib/project_types/theme/cli.rb +2 -0
- data/lib/project_types/theme/commands/common/root_helper.rb +71 -0
- data/lib/project_types/theme/commands/init.rb +2 -0
- data/lib/project_types/theme/commands/list.rb +34 -0
- data/lib/project_types/theme/commands/open.rb +65 -0
- data/lib/project_types/theme/commands/package.rb +1 -0
- data/lib/project_types/theme/commands/pull.rb +18 -10
- data/lib/project_types/theme/commands/push.rb +17 -9
- data/lib/project_types/theme/commands/serve.rb +6 -2
- data/lib/project_types/theme/conversions/base_glob.rb +50 -0
- data/lib/project_types/theme/conversions/ignore_glob.rb +15 -0
- data/lib/project_types/theme/conversions/include_glob.rb +15 -0
- data/lib/project_types/theme/forms/select.rb +11 -39
- data/lib/project_types/theme/messages/messages.rb +38 -7
- data/lib/project_types/theme/presenters/theme_presenter.rb +48 -0
- data/lib/project_types/theme/presenters/themes_presenter.rb +32 -0
- data/lib/shopify_cli/api.rb +1 -1
- data/lib/shopify_cli/commands/app/create/node.rb +1 -0
- data/lib/shopify_cli/commands/app/create/php.rb +1 -0
- data/lib/shopify_cli/commands/app/create/rails.rb +1 -0
- data/lib/shopify_cli/commands/app/deploy.rb +1 -1
- data/lib/shopify_cli/constants.rb +2 -2
- data/lib/shopify_cli/context.rb +13 -15
- data/lib/shopify_cli/core/entry_point.rb +1 -1
- data/lib/shopify_cli/core/monorail.rb +14 -6
- data/lib/shopify_cli/environment.rb +6 -0
- data/lib/shopify_cli/exception_reporter.rb +2 -0
- data/lib/shopify_cli/git.rb +9 -1
- data/lib/shopify_cli/messages/messages.rb +21 -1
- data/lib/shopify_cli/packager.rb +1 -1
- data/lib/shopify_cli/result.rb +14 -0
- data/lib/shopify_cli/services/app/create/rails_service.rb +1 -1
- data/lib/shopify_cli/tasks/ensure_git_dependency.rb +14 -0
- data/lib/shopify_cli/tasks.rb +1 -0
- data/lib/shopify_cli/theme/dev_server/hot_reload/remote_file_reloader.rb +5 -5
- data/lib/shopify_cli/theme/dev_server/proxy.rb +14 -2
- data/lib/shopify_cli/theme/dev_server/watcher.rb +10 -2
- data/lib/shopify_cli/theme/development_theme.rb +2 -5
- data/lib/shopify_cli/theme/include_filter.rb +4 -2
- data/lib/shopify_cli/theme/syncer.rb +40 -36
- data/lib/shopify_cli/theme/theme.rb +16 -27
- data/lib/shopify_cli/theme/theme_admin_api.rb +71 -0
- data/lib/shopify_cli/transform_data_structure.rb +3 -2
- data/lib/shopify_cli/version.rb +1 -1
- data/shipit.yml +3 -0
- data/shopify-cli.gemspec +9 -2
- data/shopify-dev +9 -11
- metadata +26 -8
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +0 -25
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +0 -98
@@ -8,7 +8,7 @@ module Script
|
|
8
8
|
recommend_default_ruby_range
|
9
9
|
|
10
10
|
options do |parser, flags|
|
11
|
-
parser.on("--
|
11
|
+
parser.on("--title=TITLE") { |title| flags[:title] = title }
|
12
12
|
parser.on("--api=API_NAME") { |ep_name| flags[:extension_point] = ep_name }
|
13
13
|
parser.on("--language=LANGUAGE") { |language| flags[:language] = language }
|
14
14
|
parser.on("--branch=BRANCH") { |branch| flags[:branch] = branch }
|
@@ -18,18 +18,18 @@ module Script
|
|
18
18
|
form = Forms::Create.ask(@ctx, args, options.flags)
|
19
19
|
return @ctx.puts(self.class.help) if form.nil?
|
20
20
|
|
21
|
-
unless !form.
|
21
|
+
unless !form.title.empty? && form.extension_point
|
22
22
|
return @ctx.puts(self.class.help)
|
23
23
|
end
|
24
24
|
|
25
25
|
project = Layers::Application::CreateScript.call(
|
26
26
|
ctx: @ctx,
|
27
|
-
language:
|
27
|
+
language: options.flags[:language]&.downcase || "wasm",
|
28
28
|
sparse_checkout_branch: options.flags[:branch] || "master",
|
29
|
-
|
29
|
+
title: form.title,
|
30
30
|
extension_point_type: form.extension_point,
|
31
31
|
)
|
32
|
-
@ctx.puts(@ctx.message("script.create.change_directory_notice", project.
|
32
|
+
@ctx.puts(@ctx.message("script.create.change_directory_notice", project.title))
|
33
33
|
rescue StandardError => e
|
34
34
|
UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message("script.create.error.operation_failed"))
|
35
35
|
end
|
@@ -5,10 +5,6 @@ module Script
|
|
5
5
|
class Push < ShopifyCLI::Command::SubCommand
|
6
6
|
prerequisite_task ensure_project_type: :script
|
7
7
|
|
8
|
-
recommend_node(
|
9
|
-
from: ::Script::Layers::Infrastructure::Languages::TypeScriptProjectCreator::MIN_NODE_VERSION,
|
10
|
-
to: ShopifyCLI::Constants::SupportedVersions::Node::TO
|
11
|
-
)
|
12
8
|
recommend_default_ruby_range
|
13
9
|
|
14
10
|
options do |parser, flags|
|
@@ -26,7 +22,7 @@ module Script
|
|
26
22
|
push(project: project)
|
27
23
|
rescue StandardError => e
|
28
24
|
UI::ErrorHandler.pretty_print_and_raise(e,
|
29
|
-
failed_op: @ctx.message("script.push.error.
|
25
|
+
failed_op: @ctx.message("script.push.error.operation_failed"))
|
30
26
|
end
|
31
27
|
|
32
28
|
def push(project:)
|
@@ -38,7 +34,9 @@ module Script
|
|
38
34
|
Layers::Application::PushScript.call(ctx: @ctx, force: force, project: project)
|
39
35
|
@ctx.puts(@ctx.message("script.push.script_pushed", api_key: api_key))
|
40
36
|
else
|
41
|
-
|
37
|
+
message = @ctx.message("script.error.missing_push_options_ci", "--uuid")
|
38
|
+
message += @ctx.message("script.error.missing_push_options_ci_solution", ShopifyCLI::TOOL_NAME)
|
39
|
+
raise ShopifyCLI::Abort, message
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
@@ -1,28 +1,20 @@
|
|
1
1
|
payment_methods:
|
2
2
|
domain: 'checkout'
|
3
3
|
libraries:
|
4
|
-
assemblyscript:
|
5
|
-
repo: "https://github.com/Shopify/scripts-apis-examples"
|
6
|
-
package: "@shopify/scripts-checkout-apis"
|
7
4
|
typescript:
|
8
5
|
beta: true
|
9
6
|
package: "@shopify/scripts-checkout-apis"
|
10
7
|
repo: "https://github.com/Shopify/scripts-apis-examples"
|
11
8
|
wasm:
|
12
|
-
beta: true
|
13
9
|
repo: "https://github.com/Shopify/scripts-apis-examples"
|
14
10
|
shipping_methods:
|
15
11
|
domain: 'checkout'
|
16
12
|
libraries:
|
17
|
-
assemblyscript:
|
18
|
-
repo: "https://github.com/Shopify/scripts-apis-examples"
|
19
|
-
package: "@shopify/scripts-checkout-apis"
|
20
13
|
typescript:
|
21
14
|
beta: true
|
22
15
|
package: "@shopify/scripts-checkout-apis"
|
23
16
|
repo: "https://github.com/Shopify/scripts-apis-examples"
|
24
17
|
wasm:
|
25
|
-
beta: true
|
26
18
|
repo: "https://github.com/Shopify/scripts-apis-examples"
|
27
19
|
merchandise_discount_types:
|
28
20
|
beta: true
|
@@ -33,7 +25,6 @@ merchandise_discount_types:
|
|
33
25
|
package: "@shopify/scripts-discounts-apis"
|
34
26
|
repo: "https://github.com/Shopify/scripts-apis-examples"
|
35
27
|
wasm:
|
36
|
-
beta: true
|
37
28
|
repo: "https://github.com/Shopify/scripts-apis-examples"
|
38
29
|
delivery_discount_types:
|
39
30
|
beta: true
|
@@ -44,5 +35,4 @@ delivery_discount_types:
|
|
44
35
|
package: "@shopify/scripts-discounts-apis"
|
45
36
|
repo: "https://github.com/Shopify/scripts-apis-examples"
|
46
37
|
wasm:
|
47
|
-
beta: true
|
48
38
|
repo: "https://github.com/Shopify/scripts-apis-examples"
|
@@ -3,12 +3,11 @@
|
|
3
3
|
module Script
|
4
4
|
module Forms
|
5
5
|
class Create < ShopifyCLI::Form
|
6
|
-
flag_arguments :extension_point, :
|
6
|
+
flag_arguments :extension_point, :title
|
7
7
|
|
8
8
|
def ask
|
9
|
-
self.
|
9
|
+
self.title = valid_name
|
10
10
|
self.extension_point ||= ask_extension_point
|
11
|
-
self.language = ask_language
|
12
11
|
end
|
13
12
|
|
14
13
|
private
|
@@ -20,26 +19,14 @@ module Script
|
|
20
19
|
)
|
21
20
|
end
|
22
21
|
|
23
|
-
def
|
24
|
-
CLI::UI::Prompt.ask(@ctx.message("script.forms.create.
|
22
|
+
def ask_title
|
23
|
+
CLI::UI::Prompt.ask(@ctx.message("script.forms.create.script_title"))
|
25
24
|
end
|
26
25
|
|
27
26
|
def valid_name
|
28
|
-
|
29
|
-
return
|
30
|
-
raise Errors::
|
31
|
-
end
|
32
|
-
|
33
|
-
def ask_language
|
34
|
-
return language.downcase if language
|
35
|
-
|
36
|
-
all_languages = Layers::Application::ExtensionPoints.languages(type: extension_point)
|
37
|
-
return all_languages.first if all_languages.count == 1
|
38
|
-
|
39
|
-
CLI::UI::Prompt.ask(
|
40
|
-
ctx.message("script.forms.create.select_language"),
|
41
|
-
options: all_languages
|
42
|
-
)
|
27
|
+
normalized_title = (title || ask_title).downcase.gsub(" ", "_")
|
28
|
+
return normalized_title if normalized_title.match?(/^[0-9A-Za-z_-]*$/)
|
29
|
+
raise Errors::InvalidScriptTitleError
|
43
30
|
end
|
44
31
|
end
|
45
32
|
end
|
@@ -5,34 +5,17 @@ module Script
|
|
5
5
|
module Application
|
6
6
|
class BuildScript
|
7
7
|
class << self
|
8
|
-
def call(ctx:, task_runner
|
8
|
+
def call(ctx:, task_runner:)
|
9
9
|
CLI::UI::Frame.open(ctx.message("script.application.building")) do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
script_project: script_project,
|
18
|
-
script_content: script_content,
|
19
|
-
metadata: metadata,
|
20
|
-
library: library,
|
21
|
-
)
|
22
|
-
spinner.update_title(ctx.message("script.application.built"))
|
23
|
-
end
|
24
|
-
rescue StandardError => e
|
25
|
-
CLI::UI::Frame.with_frame_color_override(:red) do
|
26
|
-
ctx.puts("\n{{red:#{e.message}}}")
|
27
|
-
end
|
28
|
-
errors = [
|
29
|
-
Infrastructure::Errors::BuildScriptNotFoundError,
|
30
|
-
Infrastructure::Errors::WebAssemblyBinaryNotFoundError,
|
31
|
-
]
|
32
|
-
|
33
|
-
raise Infrastructure::Errors::BuildError unless errors.any? { |err| e.is_a?(err) }
|
34
|
-
raise
|
10
|
+
UI::StrictSpinner.spin(ctx.message("script.application.building_script")) do |spinner|
|
11
|
+
task_runner.build
|
12
|
+
spinner.update_title(ctx.message("script.application.built"))
|
13
|
+
end
|
14
|
+
rescue Infrastructure::Errors::BuildError => e
|
15
|
+
CLI::UI::Frame.with_frame_color_override(:red) do
|
16
|
+
ctx.puts("\n{{red:#{e.message}}}")
|
35
17
|
end
|
18
|
+
raise
|
36
19
|
end
|
37
20
|
end
|
38
21
|
end
|
@@ -55,9 +55,10 @@ module Script
|
|
55
55
|
def handle_error(error, context:)
|
56
56
|
properties_hash = { api_key: "SHOPIFY_API_KEY", secret: "SHOPIFY_API_SECRET" }
|
57
57
|
missing_env_variables = error.properties.map { |p| properties_hash[p.name] }.compact.join(", ")
|
58
|
+
message = context.message("script.error.missing_env_file_variables", missing_env_variables)
|
59
|
+
message += context.message("script.error.missing_env_file_variables_solution", ShopifyCLI::TOOL_NAME)
|
58
60
|
raise ShopifyCLI::Abort,
|
59
|
-
|
60
|
-
ShopifyCLI::TOOL_NAME)
|
61
|
+
message
|
61
62
|
end
|
62
63
|
|
63
64
|
private
|
@@ -7,17 +7,17 @@ module Script
|
|
7
7
|
module Application
|
8
8
|
class CreateScript
|
9
9
|
class << self
|
10
|
-
def call(ctx:, language:, sparse_checkout_branch:,
|
10
|
+
def call(ctx:, language:, sparse_checkout_branch:, title:, extension_point_type:)
|
11
11
|
script_project_repo = Infrastructure::ScriptProjectRepository.new(
|
12
12
|
ctx: ctx,
|
13
|
-
directory:
|
13
|
+
directory: title,
|
14
14
|
initial_directory: ctx.root
|
15
15
|
)
|
16
16
|
|
17
17
|
in_new_directory_context(script_project_repo) do
|
18
18
|
extension_point = ExtensionPoints.get(type: extension_point_type)
|
19
19
|
project = script_project_repo.create(
|
20
|
-
|
20
|
+
title: title,
|
21
21
|
extension_point_type: extension_point_type,
|
22
22
|
language: language
|
23
23
|
)
|
@@ -31,35 +31,34 @@ module Script
|
|
31
31
|
ctx: ctx,
|
32
32
|
language: language,
|
33
33
|
type: type,
|
34
|
-
project_name:
|
34
|
+
project_name: title,
|
35
35
|
path_to_project: project.id,
|
36
36
|
sparse_checkout_repo: sparse_checkout_repo,
|
37
37
|
sparse_checkout_branch: sparse_checkout_branch,
|
38
38
|
sparse_checkout_set_path: "#{domain}/#{language}/#{type}/default"
|
39
39
|
)
|
40
40
|
|
41
|
-
install_dependencies(ctx, language,
|
42
|
-
script_project_repo.update_script_config(title: script_name)
|
41
|
+
install_dependencies(ctx, language, title, project_creator)
|
43
42
|
project
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
46
|
private
|
48
47
|
|
49
|
-
def install_dependencies(ctx, language,
|
48
|
+
def install_dependencies(ctx, language, title, project_creator)
|
50
49
|
task_runner = Infrastructure::Languages::TaskRunner.for(ctx, language)
|
51
50
|
CLI::UI::Frame.open(ctx.message(
|
52
51
|
"core.git.pulling_from_to",
|
53
52
|
project_creator.sparse_checkout_repo,
|
54
|
-
|
53
|
+
title,
|
55
54
|
)) do
|
56
55
|
UI::StrictSpinner.spin(ctx.message(
|
57
56
|
"core.git.pulling",
|
58
57
|
project_creator.sparse_checkout_repo,
|
59
|
-
|
58
|
+
title,
|
60
59
|
)) do |spinner|
|
61
60
|
project_creator.setup_dependencies
|
62
|
-
spinner.update_title(ctx.message("core.git.pulled",
|
61
|
+
spinner.update_title(ctx.message("core.git.pulled", title))
|
63
62
|
end
|
64
63
|
end
|
65
64
|
ProjectDependencies.install(ctx: ctx, task_runner: task_runner)
|
@@ -4,22 +4,20 @@ module Script
|
|
4
4
|
class ProjectDependencies
|
5
5
|
def self.install(ctx:, task_runner:)
|
6
6
|
CLI::UI::Frame.open(ctx.message("script.project_deps.checking")) do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
spinner.update_title(ctx.message("script.project_deps.installed"))
|
14
|
-
end
|
7
|
+
if task_runner.dependencies_installed?
|
8
|
+
ctx.puts(ctx.message("script.project_deps.none_required"))
|
9
|
+
else
|
10
|
+
UI::StrictSpinner.spin(ctx.message("script.project_deps.installing")) do |spinner|
|
11
|
+
task_runner.install_dependencies
|
12
|
+
spinner.update_title(ctx.message("script.project_deps.installed"))
|
15
13
|
end
|
16
|
-
true
|
17
|
-
rescue Infrastructure::Errors::DependencyInstallError => e
|
18
|
-
CLI::UI::Frame.with_frame_color_override(:red) do
|
19
|
-
ctx.puts("\n#{e.message}")
|
20
|
-
end
|
21
|
-
raise e
|
22
14
|
end
|
15
|
+
true
|
16
|
+
rescue Infrastructure::Errors::DependencyInstallError => e
|
17
|
+
CLI::UI::Frame.with_frame_color_override(:red) do
|
18
|
+
ctx.puts("\n#{e.message}")
|
19
|
+
end
|
20
|
+
raise e
|
23
21
|
end
|
24
22
|
end
|
25
23
|
end
|
@@ -21,33 +21,37 @@ module Script
|
|
21
21
|
api: script_project.extension_point_type
|
22
22
|
) if library.nil? && (script_project.language != "wasm")
|
23
23
|
|
24
|
-
library_name = library&.package
|
25
|
-
library_data = {
|
26
|
-
language: script_project.language,
|
27
|
-
version: task_runner.library_version(library_name),
|
28
|
-
} if library_name
|
29
|
-
|
30
24
|
ProjectDependencies.install(ctx: ctx, task_runner: task_runner)
|
31
|
-
BuildScript.call(ctx: ctx, task_runner: task_runner
|
32
|
-
|
33
|
-
metadata_file_location = task_runner.metadata_file_location
|
34
|
-
metadata = Infrastructure::MetadataRepository.new(ctx: ctx).get_metadata(metadata_file_location)
|
25
|
+
BuildScript.call(ctx: ctx, task_runner: task_runner)
|
35
26
|
|
36
27
|
CLI::UI::Frame.open(ctx.message("script.application.pushing")) do
|
37
28
|
UI::PrintingSpinner.spin(ctx, ctx.message("script.application.pushing_script")) do |p_ctx, spinner|
|
29
|
+
library_name = library&.package
|
30
|
+
library_data = {
|
31
|
+
language: script_project.language,
|
32
|
+
version: task_runner.library_version(library_name),
|
33
|
+
} if library_name
|
34
|
+
|
35
|
+
metadata_file_location = task_runner.metadata_file_location
|
36
|
+
metadata = Infrastructure::MetadataRepository.new(ctx: ctx).get_metadata(metadata_file_location)
|
37
|
+
|
38
38
|
package = Infrastructure::PushPackageRepository.new(ctx: p_ctx).get_push_package(
|
39
39
|
script_project: script_project,
|
40
40
|
metadata: metadata,
|
41
41
|
library: library_data,
|
42
42
|
)
|
43
|
+
|
43
44
|
script_service = Infrastructure::ServiceLocator.script_service(
|
44
45
|
ctx: p_ctx,
|
45
46
|
api_key: script_project.api_key
|
46
47
|
)
|
47
48
|
module_upload_url = Infrastructure::ScriptUploader.new(script_service).upload(package.script_content)
|
49
|
+
|
48
50
|
uuid = script_service.set_app_script(
|
49
51
|
uuid: package.uuid,
|
50
52
|
extension_point_type: package.extension_point_type,
|
53
|
+
title: package.title,
|
54
|
+
description: package.description,
|
51
55
|
force: force,
|
52
56
|
metadata: package.metadata,
|
53
57
|
script_config: package.script_config,
|
@@ -24,10 +24,10 @@ module Script
|
|
24
24
|
end
|
25
25
|
|
26
26
|
class ScriptNotFoundError < ScriptProjectError
|
27
|
-
attr_reader :
|
28
|
-
def initialize(extension_point_type,
|
27
|
+
attr_reader :title, :extension_point_type
|
28
|
+
def initialize(extension_point_type, title)
|
29
29
|
super()
|
30
|
-
@
|
30
|
+
@title = title
|
31
31
|
@extension_point_type = extension_point_type
|
32
32
|
end
|
33
33
|
end
|
@@ -7,6 +7,8 @@ module Script
|
|
7
7
|
attr_reader :id,
|
8
8
|
:uuid,
|
9
9
|
:extension_point_type,
|
10
|
+
:title,
|
11
|
+
:description,
|
10
12
|
:script_config,
|
11
13
|
:script_content,
|
12
14
|
:metadata,
|
@@ -16,6 +18,8 @@ module Script
|
|
16
18
|
id:,
|
17
19
|
uuid:,
|
18
20
|
extension_point_type:,
|
21
|
+
title:,
|
22
|
+
description:,
|
19
23
|
script_content:,
|
20
24
|
metadata:,
|
21
25
|
script_config:,
|
@@ -24,6 +28,8 @@ module Script
|
|
24
28
|
@id = id
|
25
29
|
@uuid = uuid
|
26
30
|
@extension_point_type = extension_point_type
|
31
|
+
@title = title
|
32
|
+
@description = description
|
27
33
|
@script_content = script_content
|
28
34
|
@metadata = metadata
|
29
35
|
@script_config = script_config
|
@@ -4,17 +4,15 @@ module Script
|
|
4
4
|
module Layers
|
5
5
|
module Domain
|
6
6
|
class ScriptConfig
|
7
|
-
attr_reader :content, :version, :
|
7
|
+
attr_reader :content, :version, :configuration_ui, :configuration, :filename
|
8
8
|
|
9
|
-
REQUIRED_FIELDS = %w(version
|
9
|
+
REQUIRED_FIELDS = %w(version)
|
10
10
|
|
11
11
|
def initialize(content:, filename:)
|
12
12
|
@filename = filename
|
13
13
|
validate_content!(content)
|
14
14
|
@content = content
|
15
15
|
@version = @content["version"].to_s
|
16
|
-
@title = @content["title"]
|
17
|
-
@description = @content["description"]
|
18
16
|
@configuration_ui = @content.fetch("configurationUi", true)
|
19
17
|
@configuration = @content["configuration"]
|
20
18
|
end
|
@@ -12,7 +12,8 @@ module Script
|
|
12
12
|
property :env, accepts: ShopifyCLI::Resources::EnvFile
|
13
13
|
|
14
14
|
property! :extension_point_type, accepts: String
|
15
|
-
property! :
|
15
|
+
property! :title, accepts: String
|
16
|
+
property :description, accepts: String
|
16
17
|
property! :language, accepts: String
|
17
18
|
|
18
19
|
property :script_config, accepts: ScriptConfig
|
@@ -22,7 +23,7 @@ module Script
|
|
22
23
|
super
|
23
24
|
|
24
25
|
ShopifyCLI::Core::Monorail.metadata = {
|
25
|
-
"script_name" =>
|
26
|
+
"script_name" => title,
|
26
27
|
"extension_point_type" => extension_point_type,
|
27
28
|
"language" => language,
|
28
29
|
}
|
@@ -105,6 +105,17 @@ module Script
|
|
105
105
|
|
106
106
|
class DependencyInstallError < ScriptProjectError; end
|
107
107
|
class EmptyResponseError < ScriptProjectError; end
|
108
|
+
|
109
|
+
class InvalidEnvironmentError < ScriptProjectError
|
110
|
+
attr_reader :tool, :env_version, :minimum_version
|
111
|
+
def initialize(tool, env_version, minimum_version)
|
112
|
+
super()
|
113
|
+
@tool = tool
|
114
|
+
@env_version = env_version
|
115
|
+
@minimum_version = minimum_version
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
108
119
|
class InvalidResponseError < ScriptProjectError; end
|
109
120
|
class ForbiddenError < ScriptProjectError; end
|
110
121
|
class InvalidContextError < ScriptProjectError; end
|
@@ -26,7 +26,6 @@ module Script
|
|
26
26
|
)
|
27
27
|
|
28
28
|
project_creators = {
|
29
|
-
"assemblyscript" => AssemblyScriptProjectCreator,
|
30
29
|
"typescript" => TypeScriptProjectCreator,
|
31
30
|
"wasm" => WasmProjectCreator,
|
32
31
|
}
|
@@ -43,15 +42,10 @@ module Script
|
|
43
42
|
)
|
44
43
|
end
|
45
44
|
|
46
|
-
def self.config_file
|
47
|
-
raise NotImplementedError
|
48
|
-
end
|
49
|
-
|
50
45
|
# the sparse checkout process is common to all script types
|
51
46
|
def setup_dependencies
|
52
47
|
setup_sparse_checkout
|
53
48
|
clean
|
54
|
-
update_project_name(File.join(path_to_project, self.class.config_file))
|
55
49
|
end
|
56
50
|
|
57
51
|
private
|
@@ -72,16 +66,6 @@ module Script
|
|
72
66
|
ctx.rm_rf(".git")
|
73
67
|
end
|
74
68
|
|
75
|
-
def update_project_name(config_file)
|
76
|
-
raise Errors::ProjectConfigNotFoundError unless File.exist?(config_file)
|
77
|
-
upstream_name = "#{type.gsub("_", "-")}-default"
|
78
|
-
contents = File.read(config_file)
|
79
|
-
|
80
|
-
raise Errors::InvalidProjectConfigError unless contents.include?(upstream_name)
|
81
|
-
new_contents = contents.gsub(upstream_name, project_name)
|
82
|
-
File.write(config_file, new_contents)
|
83
|
-
end
|
84
|
-
|
85
69
|
def command_runner
|
86
70
|
@command_runner ||= CommandRunner.new(ctx: ctx)
|
87
71
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Script
|
2
|
+
module Layers
|
3
|
+
module Infrastructure
|
4
|
+
module Languages
|
5
|
+
class ToolVersionChecker
|
6
|
+
class << self
|
7
|
+
def check_node(minimum_version:)
|
8
|
+
check_version("node", ShopifyCLI::Environment.node_version, minimum_version)
|
9
|
+
end
|
10
|
+
|
11
|
+
def check_npm(minimum_version:)
|
12
|
+
check_version("npm", ShopifyCLI::Environment.npm_version, minimum_version)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def check_version(tool, env_version, minimum_version)
|
18
|
+
return if env_version >= ::Semantic::Version.new(minimum_version)
|
19
|
+
raise Errors::InvalidEnvironmentError.new(tool, env_version, minimum_version)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -5,18 +5,11 @@ module Script
|
|
5
5
|
module Infrastructure
|
6
6
|
module Languages
|
7
7
|
class TypeScriptProjectCreator < ProjectCreator
|
8
|
-
MIN_NODE_VERSION = "14.15.0"
|
9
|
-
NPM_SET_REGISTRY_COMMAND = "npm --userconfig ./.npmrc config set @shopify:registry https://registry.npmjs.com"
|
10
|
-
NPM_SET_ENGINE_STRICT_COMMAND = "npm --userconfig ./.npmrc config set engine-strict true"
|
11
|
-
|
12
|
-
def self.config_file
|
13
|
-
"package.json"
|
14
|
-
end
|
15
|
-
|
16
8
|
def setup_dependencies
|
9
|
+
task_runner = Infrastructure::Languages::TypeScriptTaskRunner.new(ctx)
|
10
|
+
task_runner.set_npm_config
|
11
|
+
|
17
12
|
super
|
18
|
-
command_runner.call(NPM_SET_REGISTRY_COMMAND)
|
19
|
-
command_runner.call(NPM_SET_ENGINE_STRICT_COMMAND)
|
20
13
|
|
21
14
|
if ctx.file_exist?("yarn.lock")
|
22
15
|
ctx.rm("yarn.lock")
|
@@ -25,6 +18,25 @@ module Script
|
|
25
18
|
if ctx.file_exist?("package-lock.json")
|
26
19
|
ctx.rm("package-lock.json")
|
27
20
|
end
|
21
|
+
|
22
|
+
update_package_json_name
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def update_package_json_name
|
28
|
+
file_content = ctx.read("package.json")
|
29
|
+
hash = file_content_to_hash(file_content)
|
30
|
+
hash["name"] = project_name
|
31
|
+
ctx.write("package.json", hash_to_file_content(hash))
|
32
|
+
end
|
33
|
+
|
34
|
+
def file_content_to_hash(content)
|
35
|
+
JSON.parse(content)
|
36
|
+
end
|
37
|
+
|
38
|
+
def hash_to_file_content(hash)
|
39
|
+
JSON.pretty_generate(hash)
|
28
40
|
end
|
29
41
|
end
|
30
42
|
end
|