shopify-cli 1.9.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +1 -0
  3. data/.github/workflows/build.yml +28 -0
  4. data/.github/workflows/release.yml +2 -4
  5. data/CHANGELOG.md +27 -0
  6. data/Gemfile.lock +1 -1
  7. data/README.md +2 -1
  8. data/lib/project_types/extension/cli.rb +7 -1
  9. data/lib/project_types/extension/commands/serve.rb +69 -1
  10. data/lib/project_types/extension/commands/tunnel.rb +3 -1
  11. data/lib/project_types/extension/extension_project.rb +1 -0
  12. data/lib/project_types/extension/features/argo.rb +18 -49
  13. data/lib/project_types/extension/features/argo_runtime.rb +81 -0
  14. data/lib/project_types/extension/features/argo_serve.rb +35 -27
  15. data/lib/project_types/extension/features/argo_serve_options.rb +41 -0
  16. data/lib/project_types/extension/features/argo_setup.rb +1 -1
  17. data/lib/project_types/extension/messages/messages.rb +5 -4
  18. data/lib/project_types/extension/models/npm_package.rb +14 -0
  19. data/lib/project_types/extension/models/specification.rb +3 -2
  20. data/lib/project_types/extension/models/specification_handlers/checkout_argo_extension.rb +18 -0
  21. data/lib/project_types/extension/models/specification_handlers/default.rb +33 -3
  22. data/lib/project_types/extension/models/version.rb +1 -1
  23. data/lib/project_types/extension/tasks/choose_next_available_port.rb +36 -0
  24. data/lib/project_types/extension/tasks/configure_features.rb +2 -0
  25. data/lib/project_types/extension/tasks/find_npm_packages.rb +106 -0
  26. data/lib/project_types/node/messages/messages.rb +4 -4
  27. data/lib/project_types/rails/messages/messages.rb +4 -4
  28. data/lib/project_types/script/cli.rb +17 -12
  29. data/lib/project_types/script/commands/push.rb +1 -1
  30. data/lib/project_types/script/config/extension_points.yml +2 -3
  31. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +5 -2
  32. data/lib/project_types/script/graphql/get_app_scripts.graphql +6 -0
  33. data/lib/project_types/script/layers/application/create_script.rb +2 -2
  34. data/lib/project_types/script/layers/application/push_script.rb +6 -3
  35. data/lib/project_types/script/layers/domain/errors.rb +0 -2
  36. data/lib/project_types/script/layers/domain/push_package.rb +4 -0
  37. data/lib/project_types/script/layers/domain/script_project.rb +21 -1
  38. data/lib/project_types/script/layers/infrastructure/command_runner.rb +19 -0
  39. data/lib/project_types/script/layers/infrastructure/errors.rb +30 -3
  40. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +97 -0
  41. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +103 -0
  42. data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +26 -0
  43. data/lib/project_types/script/layers/infrastructure/languages/rust_project_creator.rb +73 -0
  44. data/lib/project_types/script/layers/infrastructure/languages/rust_task_runner.rb +60 -0
  45. data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +21 -0
  46. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +6 -5
  47. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +61 -34
  48. data/lib/project_types/script/layers/infrastructure/script_service.rb +14 -2
  49. data/lib/project_types/script/messages/messages.rb +20 -3
  50. data/lib/project_types/script/tasks/ensure_env.rb +85 -0
  51. data/lib/project_types/script/ui/error_handler.rb +25 -6
  52. data/lib/shopify-cli/admin_api.rb +7 -4
  53. data/lib/shopify-cli/js_system.rb +2 -2
  54. data/lib/shopify-cli/messages/messages.rb +51 -45
  55. data/lib/shopify-cli/method_object.rb +4 -4
  56. data/lib/shopify-cli/oauth.rb +9 -3
  57. data/lib/shopify-cli/packager.rb +1 -1
  58. data/lib/shopify-cli/partners_api.rb +7 -4
  59. data/lib/shopify-cli/partners_api/organizations.rb +3 -3
  60. data/lib/shopify-cli/resolve_constant.rb +1 -1
  61. data/lib/shopify-cli/resources/env_file.rb +2 -2
  62. data/lib/shopify-cli/shopifolk.rb +1 -1
  63. data/lib/shopify-cli/tasks/select_org_and_shop.rb +6 -4
  64. data/lib/shopify-cli/transform_data_structure.rb +1 -1
  65. data/lib/shopify-cli/tunnel.rb +22 -1
  66. data/lib/shopify-cli/version.rb +1 -1
  67. data/lib/shopify_cli.rb +0 -1
  68. data/vendor/deps/smart_properties/REVISION +1 -1
  69. data/vendor/deps/smart_properties/lib/smart_properties/property.rb +7 -1
  70. data/vendor/deps/smart_properties/lib/smart_properties/version.rb +1 -1
  71. metadata +19 -11
  72. data/.travis.yml +0 -14
  73. data/lib/project_types/extension/features/argo_renderer_package.rb +0 -32
  74. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +0 -100
  75. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +0 -95
  76. data/lib/project_types/script/layers/infrastructure/project_creator.rb +0 -24
  77. data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +0 -72
  78. data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +0 -59
  79. data/lib/project_types/script/layers/infrastructure/task_runner.rb +0 -19
@@ -1,95 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Script
4
- module Layers
5
- module Infrastructure
6
- class AssemblyScriptTaskRunner
7
- BYTECODE_FILE = "build/%{name}.wasm"
8
- METADATA_FILE = "build/metadata.json"
9
- SCRIPT_SDK_BUILD = "npm run build"
10
-
11
- attr_reader :ctx, :script_name
12
-
13
- def initialize(ctx, script_name)
14
- @ctx = ctx
15
- @script_name = script_name
16
- end
17
-
18
- def build
19
- compile
20
- bytecode
21
- end
22
-
23
- def compiled_type
24
- "wasm"
25
- end
26
-
27
- def install_dependencies
28
- check_node_version!
29
-
30
- output, status = ctx.capture2e("npm install --no-audit --no-optional --legacy-peer-deps --loglevel error")
31
- raise Errors::DependencyInstallError, output unless status.success?
32
- end
33
-
34
- def dependencies_installed?
35
- # Assuming if node_modules folder exist at root of script folder, all deps are installed
36
- ctx.dir_exist?("node_modules")
37
- end
38
-
39
- def metadata
40
- unless @ctx.file_exist?(METADATA_FILE)
41
- msg = @ctx.message("script.error.metadata_not_found_cause", METADATA_FILE)
42
- raise Domain::Errors::MetadataNotFoundError, msg
43
- end
44
-
45
- raw_contents = File.read(METADATA_FILE)
46
- Domain::Metadata.create_from_json(@ctx, raw_contents)
47
- end
48
-
49
- private
50
-
51
- def check_node_version!
52
- output, status = @ctx.capture2e("node", "--version")
53
- raise Errors::DependencyInstallError, output unless status.success?
54
-
55
- require "semantic/semantic"
56
- version = ::Semantic::Version.new(output[1..-1])
57
- unless version >= ::Semantic::Version.new(AssemblyScriptProjectCreator::MIN_NODE_VERSION)
58
- raise Errors::DependencyInstallError,
59
- "Node version must be >= v#{AssemblyScriptProjectCreator::MIN_NODE_VERSION}. "\
60
- "Current version: #{output.strip}."
61
- end
62
- end
63
-
64
- def compile
65
- check_compilation_dependencies!
66
-
67
- out, status = ctx.capture2e(SCRIPT_SDK_BUILD)
68
- raise Domain::Errors::ServiceFailureError, out unless status.success?
69
- end
70
-
71
- def check_compilation_dependencies!
72
- pkg = JSON.parse(File.read("package.json"))
73
- build_script = pkg.dig("scripts", "build")
74
-
75
- raise Errors::BuildScriptNotFoundError,
76
- "Build script not found" if build_script.nil?
77
-
78
- unless build_script.start_with?("shopify-scripts")
79
- raise Errors::InvalidBuildScriptError, "Invalid build script"
80
- end
81
- end
82
-
83
- def bytecode
84
- filename = format(BYTECODE_FILE, name: script_name)
85
- raise Errors::WebAssemblyBinaryNotFoundError unless ctx.file_exist?(filename)
86
-
87
- contents = ctx.binread(filename)
88
- ctx.rm(filename)
89
-
90
- contents
91
- end
92
- end
93
- end
94
- end
95
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Script
4
- module Layers
5
- module Infrastructure
6
- class ProjectCreator
7
- PROJECT_CREATORS = {
8
- "assemblyscript" => Infrastructure::AssemblyScriptProjectCreator,
9
- "rust" => Infrastructure::RustProjectCreator,
10
- }
11
-
12
- def self.for(ctx, language, extension_point, script_name, path_to_project)
13
- raise Errors::ProjectCreatorNotFoundError unless PROJECT_CREATORS[language]
14
- PROJECT_CREATORS[language].new(
15
- ctx: ctx,
16
- extension_point: extension_point,
17
- script_name: script_name,
18
- path_to_project: path_to_project
19
- )
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,72 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Script
4
- module Layers
5
- module Infrastructure
6
- class RustProjectCreator
7
- include SmartProperties
8
- property! :ctx, accepts: ShopifyCli::Context
9
- property! :extension_point, accepts: Domain::ExtensionPoint
10
- property! :script_name, accepts: String
11
- property! :path_to_project, accepts: String
12
-
13
- ORIGIN_BRANCH = "main"
14
- SAMPLE_PATH = "default"
15
-
16
- def setup_dependencies
17
- git_init
18
- setup_remote
19
- setup_sparse_checkout
20
- pull
21
- clean
22
- set_script_name
23
- end
24
-
25
- def bootstrap
26
- end
27
-
28
- private
29
-
30
- def git_init
31
- out, status = ctx.capture2e("git init")
32
- raise Domain::Errors::ServiceFailureError, out unless status.success?
33
- end
34
-
35
- def setup_remote
36
- repo = extension_point.sdks.rust.package
37
- out, status = ctx.capture2e("git remote add -f origin #{repo}")
38
- raise Domain::Errors::ServiceFailureError, out unless status.success?
39
- end
40
-
41
- def setup_sparse_checkout
42
- type = extension_point.type
43
- out, status = ctx.capture2e("git config core.sparsecheckout true")
44
- raise Domain::Errors::ServiceFailureError, out unless status.success?
45
- out, status = ctx.capture2e("echo #{type}/#{SAMPLE_PATH} >> .git/info/sparse-checkout")
46
- raise Domain::Errors::ServiceFailureError, out unless status.success?
47
- end
48
-
49
- def pull
50
- out, status = ctx.capture2e("git pull origin #{ORIGIN_BRANCH}")
51
- raise Domain::Errors::ServiceFailureError, out unless status.success?
52
- end
53
-
54
- def clean
55
- type = extension_point.type
56
- ctx.rm_rf(".git")
57
- source = File.join(path_to_project, File.join(type, SAMPLE_PATH))
58
- FileUtils.copy_entry(source, path_to_project)
59
- ctx.rm_rf(type)
60
- end
61
-
62
- def set_script_name
63
- config_file = "Cargo.toml"
64
- upstream_name = "#{extension_point.type.gsub("_", "-")}-default"
65
- contents = File.read(config_file)
66
- new_contents = contents.sub(upstream_name, script_name)
67
- File.write(config_file, new_contents)
68
- end
69
- end
70
- end
71
- end
72
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
- module Script
3
- module Layers
4
- module Infrastructure
5
- class RustTaskRunner
6
- attr_reader :ctx, :script_name
7
-
8
- BUILD_TARGET = "wasm32-unknown-unknown"
9
- METADATA_FILE = "build/metadata.json"
10
-
11
- def initialize(ctx, script_name)
12
- @ctx = ctx
13
- @script_name = script_name
14
- end
15
-
16
- def dependencies_installed?
17
- true
18
- end
19
-
20
- def install_dependencies
21
- end
22
-
23
- def build
24
- compile
25
- bytecode
26
- end
27
-
28
- def compiled_type
29
- "wasm"
30
- end
31
-
32
- def metadata
33
- unless @ctx.file_exist?(METADATA_FILE)
34
- msg = @ctx.message("script.error.metadata_not_found_cause", METADATA_FILE)
35
- raise Domain::Errors::MetadataNotFoundError, msg
36
- end
37
-
38
- raw_contents = File.read(METADATA_FILE)
39
- Domain::Metadata.create_from_json(@ctx, raw_contents)
40
- end
41
-
42
- private
43
-
44
- def compile
45
- out, status = ctx.capture2e("cargo build --target=#{BUILD_TARGET} --release")
46
- raise Domain::Errors::ServiceFailureError, out unless status.success?
47
- end
48
-
49
- def bytecode
50
- binary_name = "#{script_name}.wasm"
51
- binary_path = "target/#{BUILD_TARGET}/release/#{binary_name}"
52
- raise Errors::WebAssemblyBinaryNotFoundError unless ctx.file_exist?(binary_path)
53
-
54
- ctx.binread(binary_path)
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Script
4
- module Layers
5
- module Infrastructure
6
- class TaskRunner
7
- TASK_RUNNERS = {
8
- "assemblyscript" => Infrastructure::AssemblyScriptTaskRunner,
9
- "rust" => Infrastructure::RustTaskRunner,
10
- }
11
-
12
- def self.for(ctx, language, script_name)
13
- raise Errors::TaskRunnerNotFoundError unless TASK_RUNNERS[language]
14
- TASK_RUNNERS[language].new(ctx, script_name)
15
- end
16
- end
17
- end
18
- end
19
- end