shopify-cli 1.14.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) 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/workflows/build.yml +1 -1
  6. data/.gitignore +3 -0
  7. data/.rubocop.yml +3 -1
  8. data/.ruby-version +1 -1
  9. data/CHANGELOG.md +35 -29
  10. data/Gemfile +4 -0
  11. data/Gemfile.lock +32 -0
  12. data/LICENSE +4 -1
  13. data/README.md +92 -26
  14. data/RELEASING.md +29 -7
  15. data/Rakefile +2 -2
  16. data/SECURITY.md +1 -1
  17. data/bin/load_shopify.rb +1 -1
  18. data/bin/shopify +3 -3
  19. data/dev.yml +1 -1
  20. data/docs/app/node/index.md +1 -1
  21. data/docs/app/rails/index.md +1 -1
  22. data/docs/core/index.md +1 -1
  23. data/docs/getting-started/index.md +1 -1
  24. data/docs/getting-started/install/index.md +1 -1
  25. data/docs/getting-started/migrate/index.md +1 -1
  26. data/docs/getting-started/uninstall/index.md +1 -1
  27. data/docs/getting-started/upgrade/index.md +1 -1
  28. data/docs/help/start-app/index.md +1 -1
  29. data/docs/index.md +1 -1
  30. data/ext/shopify-cli/extconf.rb +17 -5
  31. data/install.sh +1 -1
  32. data/lib/docgen/index_template.md.erb +2 -2
  33. data/lib/graphql/all_orgs_with_extensions.graphql +37 -0
  34. data/lib/graphql/find_organization.graphql +2 -1
  35. data/lib/project_types/extension/cli.rb +18 -15
  36. data/lib/project_types/extension/commands/build.rb +4 -5
  37. data/lib/project_types/extension/commands/connect.rb +35 -0
  38. data/lib/project_types/extension/commands/create.rb +12 -16
  39. data/lib/project_types/extension/commands/extension_command.rb +2 -2
  40. data/lib/project_types/extension/commands/info.rb +86 -0
  41. data/lib/project_types/extension/commands/push.rb +8 -7
  42. data/lib/project_types/extension/commands/register.rb +4 -5
  43. data/lib/project_types/extension/commands/serve.rb +5 -8
  44. data/lib/project_types/extension/commands/tunnel.rb +3 -1
  45. data/lib/project_types/extension/errors.rb +9 -0
  46. data/lib/project_types/extension/extension_project.rb +5 -0
  47. data/lib/project_types/extension/features/argo.rb +6 -6
  48. data/lib/project_types/extension/features/argo_runtime.rb +22 -66
  49. data/lib/project_types/extension/features/argo_serve.rb +25 -18
  50. data/lib/project_types/extension/forms/connect.rb +42 -0
  51. data/lib/project_types/extension/forms/questions/ask_name.rb +14 -6
  52. data/lib/project_types/extension/forms/questions/ask_registration.rb +51 -0
  53. data/lib/project_types/extension/messages/messages.rb +75 -11
  54. data/lib/project_types/extension/models/specification.rb +1 -0
  55. data/lib/project_types/extension/models/specification_handlers/{checkout_argo_extension.rb → checkout_ui_extension.rb} +3 -1
  56. data/lib/project_types/extension/models/specification_handlers/default.rb +13 -3
  57. data/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +86 -0
  58. data/lib/project_types/extension/models/specifications.rb +1 -0
  59. data/lib/project_types/extension/tasks/configure_features.rb +6 -7
  60. data/lib/project_types/extension/tasks/configure_options.rb +20 -0
  61. data/lib/project_types/extension/tasks/get_extensions.rb +32 -0
  62. data/lib/project_types/node/cli.rb +9 -21
  63. data/lib/project_types/node/commands/connect.rb +8 -2
  64. data/lib/project_types/node/commands/create.rb +9 -5
  65. data/lib/project_types/node/commands/deploy.rb +15 -5
  66. data/lib/project_types/node/commands/deploy/heroku.rb +29 -29
  67. data/lib/project_types/node/commands/generate.rb +4 -2
  68. data/lib/project_types/node/commands/open.rb +4 -2
  69. data/lib/project_types/node/commands/serve.rb +3 -2
  70. data/lib/project_types/node/commands/tunnel.rb +4 -2
  71. data/lib/project_types/node/messages/messages.rb +46 -89
  72. data/lib/project_types/rails/cli.rb +9 -21
  73. data/lib/project_types/rails/commands/connect.rb +8 -2
  74. data/lib/project_types/rails/commands/create.rb +10 -6
  75. data/lib/project_types/rails/commands/deploy.rb +15 -5
  76. data/lib/project_types/rails/commands/deploy/heroku.rb +84 -82
  77. data/lib/project_types/rails/commands/generate.rb +15 -5
  78. data/lib/project_types/rails/commands/generate/webhook.rb +28 -26
  79. data/lib/project_types/rails/commands/open.rb +4 -2
  80. data/lib/project_types/rails/commands/serve.rb +3 -2
  81. data/lib/project_types/rails/commands/tunnel.rb +4 -2
  82. data/lib/project_types/rails/messages/messages.rb +54 -101
  83. data/lib/project_types/script/cli.rb +5 -7
  84. data/lib/project_types/script/commands/create.rb +3 -1
  85. data/lib/project_types/script/commands/push.rb +4 -2
  86. data/lib/project_types/script/messages/messages.rb +52 -45
  87. data/lib/project_types/script/ui/error_handler.rb +2 -2
  88. data/lib/project_types/theme/cli.rb +15 -27
  89. data/lib/project_types/theme/commands/check.rb +33 -0
  90. data/lib/project_types/theme/commands/delete.rb +64 -0
  91. data/lib/project_types/theme/commands/language_server.rb +16 -0
  92. data/lib/project_types/theme/commands/package.rb +55 -0
  93. data/lib/project_types/theme/commands/publish.rb +43 -0
  94. data/lib/project_types/theme/commands/pull.rb +51 -0
  95. data/lib/project_types/theme/commands/push.rb +58 -32
  96. data/lib/project_types/theme/commands/serve.rb +7 -17
  97. data/lib/project_types/theme/forms/confirm_store.rb +15 -0
  98. data/lib/project_types/theme/forms/select.rb +59 -0
  99. data/lib/project_types/theme/messages/messages.rb +110 -106
  100. data/lib/project_types/theme/ui/sync_progress_bar.rb +20 -0
  101. data/lib/shopify-cli/admin_api.rb +53 -38
  102. data/lib/shopify-cli/admin_api/populate_resource_command.rb +6 -14
  103. data/lib/shopify-cli/admin_api/schema.rb +1 -10
  104. data/lib/shopify-cli/api.rb +29 -14
  105. data/lib/shopify-cli/command.rb +15 -3
  106. data/lib/shopify-cli/commands.rb +7 -2
  107. data/lib/shopify-cli/commands/help.rb +2 -29
  108. data/lib/shopify-cli/commands/login.rb +95 -0
  109. data/lib/shopify-cli/commands/logout.rb +24 -8
  110. data/lib/shopify-cli/commands/populate.rb +23 -0
  111. data/lib/{project_types/node → shopify-cli}/commands/populate/customer.rb +2 -8
  112. data/lib/{project_types/node → shopify-cli}/commands/populate/draft_order.rb +2 -2
  113. data/lib/{project_types/node → shopify-cli}/commands/populate/product.rb +2 -8
  114. data/lib/shopify-cli/commands/store.rb +15 -0
  115. data/lib/shopify-cli/commands/switch.rb +39 -0
  116. data/lib/shopify-cli/commands/system.rb +12 -0
  117. data/lib/shopify-cli/commands/whoami.rb +28 -0
  118. data/lib/shopify-cli/connect.rb +32 -0
  119. data/lib/shopify-cli/context.rb +52 -4
  120. data/lib/shopify-cli/core/entry_point.rb +3 -22
  121. data/lib/shopify-cli/db.rb +4 -4
  122. data/lib/shopify-cli/http_request.rb +10 -0
  123. data/lib/shopify-cli/identity_auth.rb +282 -0
  124. data/lib/shopify-cli/{oauth → identity_auth}/servlet.rb +11 -12
  125. data/lib/shopify-cli/messages/messages.rb +132 -39
  126. data/lib/shopify-cli/partners_api.rb +21 -44
  127. data/lib/shopify-cli/partners_api/organizations.rb +8 -0
  128. data/lib/shopify-cli/project_commands.rb +16 -0
  129. data/lib/shopify-cli/project_type.rb +0 -31
  130. data/lib/shopify-cli/shopifolk.rb +8 -11
  131. data/lib/shopify-cli/sub_command.rb +1 -0
  132. data/lib/shopify-cli/tasks.rb +3 -0
  133. data/lib/shopify-cli/tasks/confirm_store.rb +18 -0
  134. data/lib/shopify-cli/tasks/create_api_client.rb +2 -2
  135. data/lib/shopify-cli/tasks/ensure_authenticated.rb +13 -0
  136. data/lib/shopify-cli/tasks/ensure_loopback_url.rb +1 -1
  137. data/lib/shopify-cli/tasks/ensure_project_type.rb +12 -0
  138. data/lib/shopify-cli/tasks/select_org_and_shop.rb +0 -3
  139. data/lib/shopify-cli/theme/dev_server.rb +98 -0
  140. data/lib/shopify-cli/theme/dev_server/certificate_manager.rb +79 -0
  141. data/lib/shopify-cli/theme/dev_server/header_hash.rb +94 -0
  142. data/lib/shopify-cli/theme/dev_server/hot-reload.js +93 -0
  143. data/lib/shopify-cli/theme/dev_server/hot_reload.rb +76 -0
  144. data/lib/shopify-cli/theme/dev_server/local_assets.rb +87 -0
  145. data/lib/shopify-cli/theme/dev_server/proxy.rb +205 -0
  146. data/lib/shopify-cli/theme/dev_server/sse.rb +75 -0
  147. data/lib/shopify-cli/theme/dev_server/watcher.rb +59 -0
  148. data/lib/shopify-cli/theme/dev_server/web_server.rb +140 -0
  149. data/lib/shopify-cli/theme/development_theme.rb +69 -0
  150. data/lib/shopify-cli/theme/file.rb +112 -0
  151. data/lib/shopify-cli/theme/ignore_filter.rb +109 -0
  152. data/lib/shopify-cli/theme/mime_type.rb +34 -0
  153. data/lib/shopify-cli/theme/syncer.rb +328 -0
  154. data/lib/shopify-cli/theme/theme.rb +204 -0
  155. data/lib/shopify-cli/version.rb +1 -1
  156. data/lib/shopify_cli.rb +18 -11
  157. data/shopify-cli.gemspec +12 -5
  158. data/shopify.fish +1 -1
  159. data/shopify.sh +1 -1
  160. metadata +88 -34
  161. data/.github/workflows/release.yml +0 -59
  162. data/lib/project_types/extension/features/argo_serve_options.rb +0 -42
  163. data/lib/project_types/node/commands/populate.rb +0 -23
  164. data/lib/project_types/rails/commands/populate.rb +0 -23
  165. data/lib/project_types/rails/commands/populate/customer.rb +0 -31
  166. data/lib/project_types/rails/commands/populate/draft_order.rb +0 -28
  167. data/lib/project_types/rails/commands/populate/product.rb +0 -30
  168. data/lib/project_types/theme/commands/connect.rb +0 -54
  169. data/lib/project_types/theme/commands/create.rb +0 -48
  170. data/lib/project_types/theme/commands/deploy.rb +0 -38
  171. data/lib/project_types/theme/commands/generate.rb +0 -20
  172. data/lib/project_types/theme/commands/generate/env.rb +0 -79
  173. data/lib/project_types/theme/forms/connect.rb +0 -34
  174. data/lib/project_types/theme/forms/create.rb +0 -22
  175. data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +0 -78
  176. data/lib/project_types/theme/themekit.rb +0 -113
  177. data/lib/shopify-cli/commands/connect.rb +0 -64
  178. data/lib/shopify-cli/commands/create.rb +0 -50
  179. data/lib/shopify-cli/oauth.rb +0 -198
@@ -1,59 +0,0 @@
1
- name: Create Release
2
-
3
- on:
4
- push:
5
- tags:
6
- - 'v*'
7
-
8
- jobs:
9
- create-release:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - name: Extract tag name
13
- id: tag
14
- run: echo "::set-output name=value::${GITHUB_REF##*/}"
15
- - uses: actions/checkout@v2
16
-
17
- - name: Set up Ruby
18
- uses: ruby/setup-ruby@v1
19
- with:
20
- ruby-version: 2.6
21
- bundler-cache: true
22
-
23
- - name: Create package
24
- run: bundle exec rake package
25
-
26
- - name: Get Directory
27
- id: folder
28
- run: |
29
- cd packaging/builds
30
- echo ::set-output name=name::$(ls)
31
-
32
- - name: Get Packages
33
- id: binaries
34
- run: |
35
- cd packaging/builds/${{ steps.folder.outputs.name }}
36
- deb=$(find . -type f -name '*.deb')
37
- rpm=$(find . -type f -name "*.rpm")
38
- echo ::set-output name=deb_file::"${deb:2}"
39
- echo ::set-output name=rpm_file::"${rpm:2}"
40
-
41
- - uses: dawidd6/action-homebrew-bump-formula@v3
42
- with:
43
- token: ${{secrets.BREW_TOKEN}}
44
- tap: shopify/shopify
45
- formula: shopify-cli
46
- tag: ${{ steps.folder.outputs.name }}
47
-
48
- - name: Create Release # https://hub.github.com/hub-release.1.html
49
- env:
50
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51
- run: |
52
- cd packaging/builds/${{ steps.folder.outputs.name }}
53
- hub release create ${{ steps.tag.outputs.value }} \
54
- -a ${{ steps.binaries.outputs.deb_file }} \
55
- -a ${{ steps.binaries.outputs.rpm_file }} \
56
- -m "Version ${{ steps.folder.outputs.name }}
57
-
58
- Release of version ${{ steps.folder.outputs.name }} of the Shopify App CLI
59
- Please refer to [CHANGELOG](https://github.com/Shopify/shopify-app-cli/blob/master/CHANGELOG.md) for details."
@@ -1,42 +0,0 @@
1
- module Extension
2
- module Features
3
- class ArgoServeOptions
4
- include SmartProperties
5
-
6
- property! :argo_runtime, accepts: Features::ArgoRuntime
7
- property! :context, accepts: ShopifyCli::Context
8
- property :port, accepts: Integer, default: 39351
9
- property :public_url, accepts: String, default: ""
10
- property! :required_fields, accepts: Array, default: -> { [] }
11
- property! :renderer_package, accepts: Models::NpmPackage
12
-
13
- YARN_SERVE_COMMAND = %w(server)
14
- NPM_SERVE_COMMAND = %w(run-script server)
15
-
16
- def yarn_serve_command
17
- YARN_SERVE_COMMAND + options
18
- end
19
-
20
- def npm_serve_command
21
- NPM_SERVE_COMMAND + ["--"] + options
22
- end
23
-
24
- private
25
-
26
- def options
27
- project = ExtensionProject.current
28
- api_key = project.env.api_key
29
-
30
- @serve_options ||= [].tap do |options|
31
- options << "--port=#{port}" if argo_runtime.accepts_port?
32
- options << "--shop=#{project.env.shop}" if required_fields.include?(:shop) && argo_runtime.accepts_shop?
33
- options << "--apiKey=#{api_key}" if required_fields.include?(:api_key) && argo_runtime.accepts_api_key?
34
- options << "--argoVersion=#{renderer_package.version}" if argo_runtime.accepts_argo_version?
35
- options << "--uuid=#{project.registration_uuid}" if argo_runtime.accepts_uuid?
36
- options << "--publicUrl=#{public_url}" if argo_runtime.accepts_tunnel_url?
37
- options << "--name=#{project.title}" if argo_runtime.accepts_name?
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,23 +0,0 @@
1
- require "shopify_cli"
2
-
3
- module Node
4
- module Commands
5
- class Populate < ShopifyCli::Command
6
- subcommand :Customer, "customers", Project.project_filepath("commands/populate/customer")
7
- subcommand :DraftOrder, "draftorders", Project.project_filepath("commands/populate/draft_order")
8
- subcommand :Product, "products", Project.project_filepath("commands/populate/product")
9
-
10
- def call(_args, _name)
11
- @ctx.puts(self.class.help)
12
- end
13
-
14
- def self.help
15
- ShopifyCli::Context.message("node.populate.help", ShopifyCli::TOOL_NAME)
16
- end
17
-
18
- def self.extended_help
19
- ShopifyCli::Context.message("node.populate.extended_help", ShopifyCli::TOOL_NAME)
20
- end
21
- end
22
- end
23
- end
@@ -1,23 +0,0 @@
1
- require "shopify_cli"
2
-
3
- module Rails
4
- module Commands
5
- class Populate < ShopifyCli::Command
6
- subcommand :Product, "products", Project.project_filepath("commands/populate/product")
7
- subcommand :Customer, "customers", Project.project_filepath("commands/populate/customer")
8
- subcommand :DraftOrder, "draftorders", Project.project_filepath("commands/populate/draft_order")
9
-
10
- def call(_args, _name)
11
- @ctx.puts(self.class.help)
12
- end
13
-
14
- def self.help
15
- ShopifyCli::Context.message("rails.populate.help", ShopifyCli::TOOL_NAME)
16
- end
17
-
18
- def self.extended_help
19
- ShopifyCli::Context.message("rails.populate.extended_help", ShopifyCli::TOOL_NAME)
20
- end
21
- end
22
- end
23
- end
@@ -1,31 +0,0 @@
1
- require "shopify_cli"
2
-
3
- module Rails
4
- module Commands
5
- class Populate
6
- class Customer < ShopifyCli::AdminAPI::PopulateResourceCommand
7
- @input_type = :CustomerInput
8
-
9
- def defaults
10
- first_name, last_name = ShopifyCli::Helpers::Haikunator.name
11
- {
12
- firstName: first_name,
13
- lastName: last_name,
14
- }
15
- end
16
-
17
- def message(data)
18
- ret = data["customerCreate"]["customer"]
19
- id = ShopifyCli::API.gid_to_id(ret["id"])
20
- @ctx.message(
21
- "rails.populate.customer.added",
22
- ret["displayName"],
23
- ShopifyCli::Project.current.env.shop,
24
- admin_url,
25
- id
26
- )
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,28 +0,0 @@
1
- require "shopify_cli"
2
-
3
- module Rails
4
- module Commands
5
- class Populate
6
- class DraftOrder < ShopifyCli::AdminAPI::PopulateResourceCommand
7
- @input_type = :DraftOrderInput
8
-
9
- def defaults
10
- {
11
- lineItems: [{
12
- originalUnitPrice: price,
13
- quantity: 1,
14
- weight: { value: 10, unit: "GRAMS" },
15
- title: ShopifyCli::Helpers::Haikunator.title,
16
- }],
17
- }
18
- end
19
-
20
- def message(data)
21
- ret = data["draftOrderCreate"]["draftOrder"]
22
- id = ShopifyCli::API.gid_to_id(ret["id"])
23
- @ctx.message("rails.populate.draft_order.added", ShopifyCli::Project.current.env.shop, admin_url, id)
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,30 +0,0 @@
1
- require "shopify_cli"
2
-
3
- module Rails
4
- module Commands
5
- class Populate
6
- class Product < ShopifyCli::AdminAPI::PopulateResourceCommand
7
- @input_type = :ProductInput
8
-
9
- def defaults
10
- {
11
- title: ShopifyCli::Helpers::Haikunator.title,
12
- variants: [{ price: price }],
13
- }
14
- end
15
-
16
- def message(data)
17
- ret = data["productCreate"]["product"]
18
- id = ShopifyCli::API.gid_to_id(ret["id"])
19
- @ctx.message(
20
- "rails.populate.product.added",
21
- ret["title"],
22
- ShopifyCli::Project.current.env.shop,
23
- admin_url,
24
- id
25
- )
26
- end
27
- end
28
- end
29
- end
30
- 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