shopify-cli 1.12.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -1
  3. data/.github/CONTRIBUTING.md +7 -7
  4. data/.github/DESIGN.md +3 -3
  5. data/.github/PULL_REQUEST_TEMPLATE.md +1 -1
  6. data/.github/workflows/build.yml +1 -1
  7. data/.gitignore +3 -0
  8. data/.rubocop.yml +3 -1
  9. data/.ruby-version +1 -1
  10. data/CHANGELOG.md +52 -21
  11. data/Gemfile +4 -0
  12. data/Gemfile.lock +32 -0
  13. data/LICENSE +4 -1
  14. data/README.md +92 -26
  15. data/RELEASING.md +31 -7
  16. data/Rakefile +2 -2
  17. data/SECURITY.md +1 -1
  18. data/bin/load_shopify.rb +1 -1
  19. data/bin/shopify +3 -3
  20. data/dev.yml +1 -1
  21. data/docs/app/node/index.md +1 -1
  22. data/docs/app/rails/index.md +1 -1
  23. data/docs/core/index.md +1 -1
  24. data/docs/getting-started/index.md +1 -1
  25. data/docs/getting-started/install/index.md +1 -1
  26. data/docs/getting-started/migrate/index.md +1 -1
  27. data/docs/getting-started/uninstall/index.md +1 -1
  28. data/docs/getting-started/upgrade/index.md +1 -1
  29. data/docs/help/start-app/index.md +1 -1
  30. data/docs/index.md +1 -1
  31. data/ext/shopify-cli/extconf.rb +17 -5
  32. data/install.sh +1 -1
  33. data/lib/docgen/index_template.md.erb +2 -2
  34. data/lib/graphql/all_orgs_with_extensions.graphql +37 -0
  35. data/lib/graphql/find_organization.graphql +2 -1
  36. data/lib/project_types/extension/cli.rb +18 -15
  37. data/lib/project_types/extension/commands/build.rb +4 -5
  38. data/lib/project_types/extension/commands/connect.rb +35 -0
  39. data/lib/project_types/extension/commands/create.rb +12 -16
  40. data/lib/project_types/extension/commands/extension_command.rb +2 -2
  41. data/lib/project_types/extension/commands/info.rb +86 -0
  42. data/lib/project_types/extension/commands/push.rb +8 -7
  43. data/lib/project_types/extension/commands/register.rb +4 -5
  44. data/lib/project_types/extension/commands/serve.rb +5 -8
  45. data/lib/project_types/extension/commands/tunnel.rb +3 -1
  46. data/lib/project_types/extension/errors.rb +9 -0
  47. data/lib/project_types/extension/extension_project.rb +5 -0
  48. data/lib/project_types/extension/features/argo.rb +6 -6
  49. data/lib/project_types/extension/features/argo_runtime.rb +22 -59
  50. data/lib/project_types/extension/features/argo_serve.rb +25 -21
  51. data/lib/project_types/extension/forms/connect.rb +42 -0
  52. data/lib/project_types/extension/forms/questions/ask_name.rb +14 -6
  53. data/lib/project_types/extension/forms/questions/ask_registration.rb +51 -0
  54. data/lib/project_types/extension/messages/messages.rb +75 -11
  55. data/lib/project_types/extension/models/specification.rb +1 -0
  56. data/lib/project_types/extension/models/specification_handlers/{checkout_argo_extension.rb → checkout_ui_extension.rb} +3 -1
  57. data/lib/project_types/extension/models/specification_handlers/default.rb +13 -13
  58. data/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +89 -0
  59. data/lib/project_types/extension/models/specifications.rb +1 -0
  60. data/lib/project_types/extension/tasks/configure_features.rb +6 -7
  61. data/lib/project_types/extension/tasks/configure_options.rb +20 -0
  62. data/lib/project_types/extension/tasks/get_extensions.rb +32 -0
  63. data/lib/project_types/node/cli.rb +9 -21
  64. data/lib/project_types/node/commands/connect.rb +8 -2
  65. data/lib/project_types/node/commands/create.rb +9 -5
  66. data/lib/project_types/node/commands/deploy.rb +15 -5
  67. data/lib/project_types/node/commands/deploy/heroku.rb +29 -29
  68. data/lib/project_types/node/commands/generate.rb +4 -2
  69. data/lib/project_types/node/commands/open.rb +4 -2
  70. data/lib/project_types/node/commands/serve.rb +3 -2
  71. data/lib/project_types/node/commands/tunnel.rb +4 -2
  72. data/lib/project_types/node/messages/messages.rb +46 -89
  73. data/lib/project_types/rails/cli.rb +9 -21
  74. data/lib/project_types/rails/commands/connect.rb +8 -2
  75. data/lib/project_types/rails/commands/create.rb +10 -6
  76. data/lib/project_types/rails/commands/deploy.rb +15 -5
  77. data/lib/project_types/rails/commands/deploy/heroku.rb +84 -82
  78. data/lib/project_types/rails/commands/generate.rb +15 -5
  79. data/lib/project_types/rails/commands/generate/webhook.rb +28 -26
  80. data/lib/project_types/rails/commands/open.rb +4 -2
  81. data/lib/project_types/rails/commands/serve.rb +3 -2
  82. data/lib/project_types/rails/commands/tunnel.rb +4 -2
  83. data/lib/project_types/rails/messages/messages.rb +54 -101
  84. data/lib/project_types/script/cli.rb +18 -20
  85. data/lib/project_types/script/commands/create.rb +3 -1
  86. data/lib/project_types/script/commands/push.rb +12 -5
  87. data/lib/project_types/script/config/extension_points.yml +0 -3
  88. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +9 -3
  89. data/lib/project_types/script/layers/application/create_script.rb +6 -5
  90. data/lib/project_types/script/layers/application/push_script.rb +2 -1
  91. data/lib/project_types/script/layers/domain/errors.rb +6 -11
  92. data/lib/project_types/script/layers/domain/push_package.rb +4 -8
  93. data/lib/project_types/script/layers/domain/script_json.rb +32 -0
  94. data/lib/project_types/script/layers/domain/script_project.rb +1 -1
  95. data/lib/project_types/script/layers/infrastructure/errors.rb +14 -18
  96. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +105 -0
  97. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +103 -0
  98. data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +26 -0
  99. data/lib/project_types/script/layers/infrastructure/languages/rust_project_creator.rb +73 -0
  100. data/lib/project_types/script/layers/infrastructure/languages/rust_task_runner.rb +60 -0
  101. data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +21 -0
  102. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +2 -4
  103. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +45 -34
  104. data/lib/project_types/script/layers/infrastructure/script_service.rb +37 -16
  105. data/lib/project_types/script/messages/messages.rb +66 -55
  106. data/lib/project_types/script/tasks/ensure_env.rb +22 -1
  107. data/lib/project_types/script/ui/error_handler.rb +32 -32
  108. data/lib/project_types/theme/cli.rb +16 -27
  109. data/lib/project_types/theme/commands/check.rb +33 -0
  110. data/lib/project_types/theme/commands/delete.rb +64 -0
  111. data/lib/project_types/theme/commands/init.rb +42 -0
  112. data/lib/project_types/theme/commands/language_server.rb +16 -0
  113. data/lib/project_types/theme/commands/package.rb +55 -0
  114. data/lib/project_types/theme/commands/publish.rb +43 -0
  115. data/lib/project_types/theme/commands/pull.rb +51 -0
  116. data/lib/project_types/theme/commands/push.rb +58 -32
  117. data/lib/project_types/theme/commands/serve.rb +8 -16
  118. data/lib/project_types/theme/forms/confirm_store.rb +15 -0
  119. data/lib/project_types/theme/forms/select.rb +59 -0
  120. data/lib/project_types/theme/messages/messages.rb +117 -102
  121. data/lib/project_types/theme/ui/sync_progress_bar.rb +20 -0
  122. data/lib/shopify-cli/admin_api.rb +53 -35
  123. data/lib/shopify-cli/admin_api/populate_resource_command.rb +6 -14
  124. data/lib/shopify-cli/admin_api/schema.rb +1 -10
  125. data/lib/shopify-cli/api.rb +29 -14
  126. data/lib/shopify-cli/command.rb +15 -3
  127. data/lib/shopify-cli/commands.rb +7 -2
  128. data/lib/shopify-cli/commands/help.rb +2 -29
  129. data/lib/shopify-cli/commands/login.rb +95 -0
  130. data/lib/shopify-cli/commands/logout.rb +24 -8
  131. data/lib/shopify-cli/commands/populate.rb +23 -0
  132. data/lib/{project_types/node → shopify-cli}/commands/populate/customer.rb +2 -8
  133. data/lib/{project_types/node → shopify-cli}/commands/populate/draft_order.rb +2 -2
  134. data/lib/{project_types/node → shopify-cli}/commands/populate/product.rb +2 -8
  135. data/lib/shopify-cli/commands/store.rb +15 -0
  136. data/lib/shopify-cli/commands/switch.rb +39 -0
  137. data/lib/shopify-cli/commands/system.rb +12 -0
  138. data/lib/shopify-cli/commands/whoami.rb +28 -0
  139. data/lib/shopify-cli/connect.rb +32 -0
  140. data/lib/shopify-cli/context.rb +65 -4
  141. data/lib/shopify-cli/core/entry_point.rb +3 -22
  142. data/lib/shopify-cli/db.rb +4 -4
  143. data/lib/shopify-cli/http_request.rb +16 -0
  144. data/lib/shopify-cli/identity_auth.rb +282 -0
  145. data/lib/shopify-cli/{oauth → identity_auth}/servlet.rb +11 -12
  146. data/lib/shopify-cli/messages/messages.rb +133 -39
  147. data/lib/shopify-cli/partners_api.rb +21 -41
  148. data/lib/shopify-cli/partners_api/organizations.rb +8 -0
  149. data/lib/shopify-cli/project_commands.rb +16 -0
  150. data/lib/shopify-cli/project_type.rb +0 -31
  151. data/lib/shopify-cli/resources/env_file.rb +1 -1
  152. data/lib/shopify-cli/shopifolk.rb +8 -11
  153. data/lib/shopify-cli/sub_command.rb +1 -0
  154. data/lib/shopify-cli/tasks.rb +3 -0
  155. data/lib/shopify-cli/tasks/confirm_store.rb +18 -0
  156. data/lib/shopify-cli/tasks/create_api_client.rb +2 -2
  157. data/lib/shopify-cli/tasks/ensure_authenticated.rb +13 -0
  158. data/lib/shopify-cli/tasks/ensure_loopback_url.rb +1 -1
  159. data/lib/shopify-cli/tasks/ensure_project_type.rb +12 -0
  160. data/lib/shopify-cli/tasks/select_org_and_shop.rb +0 -3
  161. data/lib/shopify-cli/theme/dev_server.rb +98 -0
  162. data/lib/shopify-cli/theme/dev_server/certificate_manager.rb +79 -0
  163. data/lib/shopify-cli/theme/dev_server/header_hash.rb +94 -0
  164. data/lib/shopify-cli/theme/dev_server/hot-reload.js +93 -0
  165. data/lib/shopify-cli/theme/dev_server/hot_reload.rb +76 -0
  166. data/lib/shopify-cli/theme/dev_server/local_assets.rb +87 -0
  167. data/lib/shopify-cli/theme/dev_server/proxy.rb +205 -0
  168. data/lib/shopify-cli/theme/dev_server/sse.rb +75 -0
  169. data/lib/shopify-cli/theme/dev_server/watcher.rb +59 -0
  170. data/lib/shopify-cli/theme/dev_server/web_server.rb +140 -0
  171. data/lib/shopify-cli/theme/development_theme.rb +69 -0
  172. data/lib/shopify-cli/theme/file.rb +112 -0
  173. data/lib/shopify-cli/theme/ignore_filter.rb +109 -0
  174. data/lib/shopify-cli/theme/mime_type.rb +34 -0
  175. data/lib/shopify-cli/theme/syncer.rb +328 -0
  176. data/lib/shopify-cli/theme/theme.rb +204 -0
  177. data/lib/shopify-cli/version.rb +1 -1
  178. data/lib/shopify_cli.rb +18 -11
  179. data/shopify-cli.gemspec +12 -5
  180. data/shopify.fish +1 -1
  181. data/shopify.sh +1 -1
  182. metadata +96 -41
  183. data/.github/workflows/release.yml +0 -61
  184. data/lib/project_types/extension/features/argo_serve_options.rb +0 -41
  185. data/lib/project_types/node/commands/populate.rb +0 -23
  186. data/lib/project_types/rails/commands/populate.rb +0 -23
  187. data/lib/project_types/rails/commands/populate/customer.rb +0 -31
  188. data/lib/project_types/rails/commands/populate/draft_order.rb +0 -28
  189. data/lib/project_types/rails/commands/populate/product.rb +0 -30
  190. data/lib/project_types/script/layers/domain/config_ui.rb +0 -16
  191. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +0 -95
  192. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +0 -101
  193. data/lib/project_types/script/layers/infrastructure/project_creator.rb +0 -24
  194. data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +0 -71
  195. data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +0 -58
  196. data/lib/project_types/script/layers/infrastructure/task_runner.rb +0 -19
  197. data/lib/project_types/theme/commands/connect.rb +0 -54
  198. data/lib/project_types/theme/commands/create.rb +0 -48
  199. data/lib/project_types/theme/commands/deploy.rb +0 -38
  200. data/lib/project_types/theme/commands/generate.rb +0 -20
  201. data/lib/project_types/theme/commands/generate/env.rb +0 -79
  202. data/lib/project_types/theme/forms/connect.rb +0 -34
  203. data/lib/project_types/theme/forms/create.rb +0 -22
  204. data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +0 -78
  205. data/lib/project_types/theme/themekit.rb +0 -113
  206. data/lib/shopify-cli/commands/connect.rb +0 -64
  207. data/lib/shopify-cli/commands/create.rb +0 -50
  208. data/lib/shopify-cli/oauth.rb +0 -198
@@ -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,71 +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 command_runner
31
- @command_runner ||= CommandRunner.new(ctx: ctx)
32
- end
33
-
34
- def git_init
35
- command_runner.call("git init")
36
- end
37
-
38
- def setup_remote
39
- repo = extension_point.sdks.rust.package
40
- command_runner.call("git remote add -f origin #{repo}")
41
- end
42
-
43
- def setup_sparse_checkout
44
- type = extension_point.type
45
- command_runner.call("git config core.sparsecheckout true")
46
- command_runner.call("echo #{type}/#{SAMPLE_PATH} >> .git/info/sparse-checkout")
47
- end
48
-
49
- def pull
50
- command_runner.call("git pull origin #{ORIGIN_BRANCH}")
51
- end
52
-
53
- def clean
54
- type = extension_point.type
55
- ctx.rm_rf(".git")
56
- source = File.join(path_to_project, File.join(type, SAMPLE_PATH))
57
- FileUtils.copy_entry(source, path_to_project)
58
- ctx.rm_rf(type)
59
- end
60
-
61
- def set_script_name
62
- config_file = "Cargo.toml"
63
- upstream_name = "#{extension_point.type.gsub("_", "-")}-default"
64
- contents = File.read(config_file)
65
- new_contents = contents.sub(upstream_name, script_name)
66
- File.write(config_file, new_contents)
67
- end
68
- end
69
- end
70
- end
71
- end
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
- module Script
3
- module Layers
4
- module Infrastructure
5
- class RustTaskRunner
6
- attr_reader :ctx
7
-
8
- BUILD_TARGET = "wasm32-unknown-unknown"
9
- METADATA_FILE = "build/metadata.json"
10
- CARGO_BUILD_CMD = "cargo build --target=#{BUILD_TARGET} --release"
11
-
12
- def initialize(ctx, _)
13
- @ctx = ctx
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
- CommandRunner.new(ctx: ctx).call(CARGO_BUILD_CMD)
46
- end
47
-
48
- def bytecode
49
- binary_name = "script.wasm"
50
- binary_path = "target/#{BUILD_TARGET}/release/#{binary_name}"
51
- raise Errors::WebAssemblyBinaryNotFoundError unless ctx.file_exist?(binary_path)
52
-
53
- ctx.binread(binary_path)
54
- end
55
- end
56
- end
57
- end
58
- 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
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
- module Theme
3
- module Commands
4
- class Connect < ShopifyCli::SubCommand
5
- prerequisite_task :ensure_themekit_installed
6
-
7
- options do |parser, flags|
8
- parser.on("--store=STORE") { |url| flags[:store] = url }
9
- parser.on("--password=PASSWORD") { |p| flags[:password] = p }
10
- parser.on("--themeid=THEME_ID") { |id| flags[:themeid] = id }
11
- parser.on("--env=ENV") { |env| flags[:env] = env }
12
- end
13
-
14
- def call(args, _name)
15
- if ShopifyCli::Project.has_current?
16
- @ctx.abort(@ctx.message("theme.connect.inside_project"))
17
- end
18
-
19
- form = Forms::Connect.ask(@ctx, args, options.flags)
20
- return @ctx.puts(self.class.help) if form.nil?
21
-
22
- build(form.store, form.password, form.themeid, form.name, form.env)
23
- ShopifyCli::Project.write(@ctx,
24
- project_type: "theme",
25
- organization_id: nil)
26
-
27
- @ctx.done(@ctx.message("theme.connect.connected", form.name, form.store, @ctx.root))
28
- end
29
-
30
- def self.help
31
- ShopifyCli::Context.message("theme.connect.help", ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
32
- end
33
-
34
- private
35
-
36
- def build(store, password, themeid, name, env)
37
- if @ctx.dir_exist?(name)
38
- @ctx.abort(@ctx.message("theme.connect.duplicate"))
39
- end
40
-
41
- @ctx.mkdir_p(name)
42
- @ctx.chdir(name)
43
-
44
- CLI::UI::Frame.open(@ctx.message("theme.connect.connect")) do
45
- unless Themekit.connect(@ctx, store: store, password: password, themeid: themeid, env: env)
46
- @ctx.chdir("..")
47
- @ctx.rm_rf(name)
48
- @ctx.abort(@ctx.message("theme.connect.failed"))
49
- end
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
- module Theme
3
- module Commands
4
- class Create < ShopifyCli::SubCommand
5
- prerequisite_task :ensure_themekit_installed
6
-
7
- options do |parser, flags|
8
- parser.on("--name=NAME") { |t| flags[:title] = t }
9
- parser.on("--password=PASSWORD") { |p| flags[:password] = p }
10
- parser.on("--store=STORE") { |url| flags[:store] = url }
11
- parser.on("--env=ENV") { |env| flags[:env] = env }
12
- end
13
-
14
- def call(args, _name)
15
- form = Forms::Create.ask(@ctx, args, options.flags)
16
- return @ctx.puts(self.class.help) if form.nil?
17
-
18
- build(form.name, form.password, form.store, form.env)
19
- ShopifyCli::Project.write(@ctx,
20
- project_type: "theme",
21
- organization_id: nil) # private apps are different
22
-
23
- @ctx.done(@ctx.message("theme.create.info.created", form.name, form.store, @ctx.root))
24
- end
25
-
26
- def self.help
27
- ShopifyCli::Context.message("theme.create.help", ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
28
- end
29
-
30
- private
31
-
32
- def build(name, password, store, env)
33
- @ctx.abort(@ctx.message("theme.create.duplicate_theme")) if @ctx.dir_exist?(name)
34
-
35
- @ctx.mkdir_p(name)
36
- @ctx.chdir(name)
37
-
38
- CLI::UI::Frame.open(@ctx.message("theme.create.creating_theme", name)) do
39
- unless Themekit.create(@ctx, name: name, password: password, store: store, env: env)
40
- @ctx.chdir("..")
41
- @ctx.rm_rf(name)
42
- @ctx.abort(@ctx.message("theme.create.failed"))
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
- module Theme
3
- module Commands
4
- class Deploy < ShopifyCli::Command
5
- prerequisite_task :ensure_themekit_installed
6
-
7
- options do |parser, flags|
8
- parser.on("--env=ENV") { |env| flags[:env] = env }
9
- parser.on("--allow-live") { flags["allow_live"] = true }
10
- end
11
-
12
- def call(*)
13
- CLI::UI::Frame.open(@ctx.message("theme.deploy.deploying")) do
14
- unless CLI::UI::Prompt.confirm(@ctx.message("theme.deploy.confirmation"))
15
- @ctx.abort(@ctx.message("theme.deploy.abort"))
16
- end
17
-
18
- if options.flags[:env]
19
- env = options.flags[:env]
20
- options.flags.delete(:env)
21
- end
22
-
23
- flags = Themekit.add_flags(options.flags)
24
-
25
- unless Themekit.deploy(@ctx, flags: flags, env: env)
26
- @ctx.abort(@ctx.message("theme.deploy.error"))
27
- end
28
- end
29
-
30
- @ctx.done(@ctx.message("theme.deploy.info.deployed"))
31
- end
32
-
33
- def self.help
34
- ShopifyCli::Context.message("theme.deploy.help", ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
35
- end
36
- end
37
- end
38
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
- require "shopify_cli"
3
-
4
- module Theme
5
- module Commands
6
- class Generate < ShopifyCli::Command
7
- prerequisite_task :ensure_themekit_installed
8
-
9
- subcommand :Env, "env", Project.project_filepath("commands/generate/env")
10
-
11
- def call(*)
12
- @ctx.puts(self.class.help)
13
- end
14
-
15
- def self.help
16
- ShopifyCli::Context.message("theme.generate.help", ShopifyCli::TOOL_NAME)
17
- end
18
- end
19
- end
20
- end
@@ -1,79 +0,0 @@
1
- module Theme
2
- module Commands
3
- class Generate
4
- class Env < ShopifyCli::SubCommand
5
- options do |parser, flags|
6
- parser.on("--store=STORE") { |url| flags[:store] = url }
7
- parser.on("--password=PASSWORD") { |p| flags[:password] = p }
8
- parser.on("--themeid=THEME_ID") { |id| flags[:themeid] = id }
9
- parser.on("--env=ENV") { |env| flags[:env] = env }
10
- end
11
-
12
- def call(*)
13
- default_store, default_password = fetch_credentials
14
- store = ask_store(default_store) || default_store
15
- password = ask_password(default_password) || default_password
16
- themeid = ask_theme(store: store, password: password)
17
- env = options.flags[:env]
18
-
19
- Themekit.generate_env(@ctx, store: store, password: password, themeid: themeid, env: env)
20
- end
21
-
22
- def self.help
23
- ShopifyCli::Context.message("theme.generate.env.help", ShopifyCli::TOOL_NAME)
24
- end
25
-
26
- private
27
-
28
- def fetch_credentials
29
- unless File.exist?("config.yml")
30
- return nil
31
- end
32
-
33
- config = YAML.load_file("config.yml")
34
- store = config["development"]["store"]
35
- password = config["development"]["password"]
36
-
37
- [store, password]
38
- end
39
-
40
- def ask_store(default)
41
- store = options.flags[:store] ||
42
- if default
43
- CLI::UI::Prompt.ask(@ctx.message("theme.generate.env.ask_store_default", default))
44
- else
45
- CLI::UI::Prompt.ask(@ctx.message("theme.generate.env.ask_store"), allow_empty: false)
46
- end
47
- return nil if store.empty?
48
- store
49
- end
50
-
51
- def ask_password(default)
52
- password = options.flags[:password] ||
53
- if default
54
- CLI::UI::Prompt.ask(@ctx.message("theme.generate.env.ask_password_default", default))
55
- else
56
- CLI::UI::Prompt.ask(@ctx.message("theme.generate.env.ask_password"), allow_empty: false)
57
- end
58
- return nil if password.empty?
59
- password
60
- end
61
-
62
- def ask_theme(store:, password:)
63
- theme = options.flags[:themeid]
64
- return theme if theme
65
-
66
- themes = Themekit.query_themes(@ctx, store: store, password: password)
67
-
68
- @ctx.abort(@ctx.message("theme.generate.env.no_themes", ShopifyCli::TOOL_NAME)) if themes.empty?
69
-
70
- CLI::UI::Prompt.ask(@ctx.message("theme.generate.env.ask_theme")) do |handler|
71
- themes.each do |name, id|
72
- handler.option(name) { id }
73
- end
74
- end
75
- end
76
- end
77
- end
78
- end
79
- end
@@ -1,34 +0,0 @@
1
- module Theme
2
- module Forms
3
- class Connect < ShopifyCli::Form
4
- attr_accessor :name
5
- flag_arguments :themeid, :password, :store, :env
6
-
7
- def ask
8
- self.store ||= CLI::UI::Prompt.ask(ctx.message("theme.forms.ask_store"), allow_empty: false)
9
- ctx.puts(ctx.message("theme.forms.connect.private_app", store))
10
- self.password ||= CLI::UI::Prompt.ask(ctx.message("theme.forms.ask_password"), allow_empty: false)
11
-
12
- errors = []
13
- errors << "store" if store.strip.empty?
14
- errors << "password" if password.strip.empty?
15
- ctx.abort(ctx.message("theme.forms.errors", errors.join(", ").capitalize)) unless errors.empty?
16
-
17
- self.themeid, self.name = ask_theme(store: store, password: password, themeid: themeid)
18
- end
19
-
20
- private
21
-
22
- def ask_theme(store:, password:, themeid:)
23
- themes = Themekit.query_themes(@ctx, store: store, password: password)
24
-
25
- themeid ||= CLI::UI::Prompt.ask("Select theme") do |handler|
26
- themes.each do |name, id|
27
- handler.option(name) { id }
28
- end
29
- end
30
- [themeid, themes.key(themeid.to_i)]
31
- end
32
- end
33
- end
34
- end