shopify-cli 2.6.2 → 2.6.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +15 -4
  3. data/.github/workflows/shopify.yml +3 -6
  4. data/CHANGELOG.md +89 -99
  5. data/CONTRIBUTING.md +9 -1
  6. data/Dockerfile +22 -4
  7. data/Gemfile +2 -0
  8. data/Gemfile.lock +7 -3
  9. data/RELEASING.md +17 -30
  10. data/Rakefile +0 -5
  11. data/lib/project_types/extension/cli.rb +1 -0
  12. data/lib/project_types/extension/commands/create.rb +1 -0
  13. data/lib/project_types/extension/features/argo.rb +9 -10
  14. data/lib/project_types/extension/features/argo_serve.rb +1 -1
  15. data/lib/project_types/extension/forms/create.rb +1 -1
  16. data/lib/project_types/extension/forms/questions/ask_template.rb +2 -1
  17. data/lib/project_types/extension/messages/messages.rb +1 -0
  18. data/lib/project_types/extension/models/server_config/extension.rb +2 -0
  19. data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +1 -1
  20. data/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +1 -1
  21. data/lib/project_types/extension/tasks/converters/server_config_converter.rb +4 -5
  22. data/lib/project_types/extension/tasks/find_package_from_json.rb +37 -0
  23. data/lib/project_types/extension/tasks/load_server_config.rb +6 -1
  24. data/lib/project_types/node/commands/serve.rb +7 -16
  25. data/lib/project_types/node/messages/messages.rb +0 -5
  26. data/lib/project_types/php/commands/serve.rb +6 -9
  27. data/lib/project_types/php/messages/messages.rb +1 -4
  28. data/lib/project_types/rails/commands/create.rb +45 -16
  29. data/lib/project_types/rails/commands/serve.rb +7 -8
  30. data/lib/project_types/rails/forms/create.rb +0 -1
  31. data/lib/project_types/rails/messages/messages.rb +1 -4
  32. data/lib/project_types/script/commands/create.rb +4 -5
  33. data/lib/project_types/script/config/extension_points.yml +10 -0
  34. data/lib/project_types/script/errors.rb +0 -18
  35. data/lib/project_types/script/graphql/app_script_set.graphql +2 -0
  36. data/lib/project_types/script/layers/application/build_script.rb +2 -1
  37. data/lib/project_types/script/layers/application/create_script.rb +2 -2
  38. data/lib/project_types/script/layers/application/push_script.rb +15 -1
  39. data/lib/project_types/script/layers/domain/push_package.rb +5 -2
  40. data/lib/project_types/script/layers/domain/script_json.rb +1 -1
  41. data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +0 -4
  42. data/lib/project_types/script/layers/infrastructure/errors.rb +17 -2
  43. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +29 -13
  44. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +29 -13
  45. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +4 -2
  46. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +3 -4
  47. data/lib/project_types/script/layers/infrastructure/script_service.rb +7 -2
  48. data/lib/project_types/script/messages/messages.rb +9 -22
  49. data/lib/project_types/script/ui/error_handler.rb +16 -26
  50. data/lib/project_types/theme/commands/serve.rb +2 -0
  51. data/lib/project_types/theme/messages/messages.rb +6 -0
  52. data/lib/shopify_cli/app_type_detector.rb +32 -0
  53. data/lib/shopify_cli/command.rb +6 -1
  54. data/lib/shopify_cli/command_options/command_serve_options.rb +43 -0
  55. data/lib/shopify_cli/command_options.rb +7 -0
  56. data/lib/shopify_cli/commands/login.rb +3 -3
  57. data/lib/shopify_cli/commands/reporting.rb +38 -0
  58. data/lib/shopify_cli/commands/switch.rb +1 -1
  59. data/lib/shopify_cli/commands.rb +1 -0
  60. data/lib/shopify_cli/constants.rb +7 -3
  61. data/lib/shopify_cli/core/monorail.rb +9 -20
  62. data/lib/shopify_cli/environment.rb +15 -1
  63. data/lib/shopify_cli/exception_reporter.rb +29 -15
  64. data/lib/shopify_cli/messages/messages.rb +48 -19
  65. data/lib/shopify_cli/migrator/migration.rb +1 -1
  66. data/lib/shopify_cli/migrator/migrations/1631709766_noop.rb +1 -1
  67. data/lib/shopify_cli/migrator/migrations/1633691650_merge_reporting_configuration.rb +41 -0
  68. data/lib/shopify_cli/migrator.rb +9 -11
  69. data/lib/shopify_cli/reporting_configuration_controller.rb +64 -0
  70. data/lib/shopify_cli/services/base_service.rb +13 -0
  71. data/lib/shopify_cli/services/reporting_service.rb +16 -0
  72. data/lib/shopify_cli/services.rb +6 -0
  73. data/lib/shopify_cli/theme/dev_server/watcher.rb +2 -2
  74. data/lib/shopify_cli/theme/dev_server.rb +3 -2
  75. data/lib/shopify_cli/version.rb +1 -1
  76. data/lib/shopify_cli.rb +4 -0
  77. data/shopify-cli.gemspec +2 -13
  78. data/utilities/docker/container.rb +97 -0
  79. data/utilities/docker.rb +45 -3
  80. metadata +18 -10
  81. data/ext/shopify-cli/extconf.rb +0 -60
  82. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +0 -0
  83. data/lib/shopify_cli/exception_reporter/permission_controller.rb +0 -54
data/utilities/docker.rb CHANGED
@@ -1,10 +1,43 @@
1
1
  require "open3"
2
+ require "securerandom"
2
3
 
3
4
  module Utilities
4
5
  module Docker
6
+ autoload :Container, "docker/container"
7
+
5
8
  Error = Class.new(StandardError)
6
9
 
7
10
  class << self
11
+ def create_container(env: {})
12
+ id = SecureRandom.hex
13
+ cwd = "/tmp/#{SecureRandom.hex}"
14
+
15
+ build_image_if_needed
16
+
17
+ _, stderr, stat = Open3.capture3(
18
+ "docker", "run",
19
+ "-t", "-d",
20
+ "--name", id,
21
+ "--volume", "#{Shellwords.escape(root_dir)}:/usr/src/app",
22
+ image_tag,
23
+ "tail", "-f", "/dev/null"
24
+ )
25
+ raise Error, stderr unless stat.success?
26
+
27
+ _, stderr, stat = Open3.capture3(
28
+ "docker", "exec",
29
+ id,
30
+ "mkdir", "-p", cwd
31
+ )
32
+ raise Error, stderr unless stat.success?
33
+
34
+ Container.new(
35
+ id: id,
36
+ cwd: cwd,
37
+ env: env
38
+ )
39
+ end
40
+
8
41
  def run_and_rm_container(*args)
9
42
  build_image_if_needed
10
43
  system(
@@ -24,18 +57,27 @@ module Utilities
24
57
 
25
58
  def build_image_if_needed
26
59
  unless image_exists?(image_tag)
27
- system("docker", "build", root_dir, "-t", image_tag) || abort
60
+ puts "Rebuilding the Docker image..."
61
+ _, err, stat = Open3.capture3(
62
+ "docker", "build", root_dir, "-t", image_tag
63
+ )
64
+ raise Error, err unless stat.success?
28
65
  end
29
66
  end
30
67
 
31
68
  def image_tag
32
69
  gemfile_lock_path = File.expand_path("./Gemfile.lock", root_dir)
33
- image_sha = Digest::SHA256.hexdigest(File.read(gemfile_lock_path))
70
+ dockerfile_path = File.expand_path("./Dockerfile", root_dir)
71
+ fingerprintable_strings = [
72
+ File.read(gemfile_lock_path),
73
+ File.read(dockerfile_path),
74
+ ]
75
+ image_sha = Digest::SHA256.hexdigest(fingerprintable_strings.join("-"))
34
76
  "shopify-cli-#{image_sha}"
35
77
  end
36
78
 
37
79
  def image_exists?(tag)
38
- _, stat = Open3.capture2(
80
+ _, stat = Open3.capture2e(
39
81
  "docker", "inspect",
40
82
  "--type=image",
41
83
  tag
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.2
4
+ version: 2.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-06 00:00:00.000000000 Z
11
+ date: 2021-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '1.7'
95
+ version: 1.7.2
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '1.7'
102
+ version: 1.7.2
103
103
  description: |
104
104
  Shopify CLI helps you build Shopify apps faster. It quickly scaffolds Node.js
105
105
  and Ruby on Rails embedded apps. It also automates many common tasks in the
@@ -107,9 +107,9 @@ description: |
107
107
  and webhooks.
108
108
  email:
109
109
  - dev-tools-education@shopify.com
110
- executables: []
111
- extensions:
112
- - ext/shopify-cli/extconf.rb
110
+ executables:
111
+ - shopify
112
+ extensions: []
113
113
  extra_rdoc_files: []
114
114
  files:
115
115
  - ".github/CODEOWNERS"
@@ -155,7 +155,6 @@ files:
155
155
  - docs/getting-started/upgrade/index.md
156
156
  - docs/help/start-app/index.md
157
157
  - docs/index.md
158
- - ext/shopify-cli/extconf.rb
159
158
  - ext/shopify-extensions/extconf.rb
160
159
  - ext/shopify-extensions/shopify_extensions.rb
161
160
  - ext/shopify-extensions/version
@@ -250,6 +249,7 @@ files:
250
249
  - lib/project_types/extension/tasks/create_extension.rb
251
250
  - lib/project_types/extension/tasks/fetch_specifications.rb
252
251
  - lib/project_types/extension/tasks/find_npm_packages.rb
252
+ - lib/project_types/extension/tasks/find_package_from_json.rb
253
253
  - lib/project_types/extension/tasks/get_app.rb
254
254
  - lib/project_types/extension/tasks/get_apps.rb
255
255
  - lib/project_types/extension/tasks/get_extensions.rb
@@ -300,7 +300,6 @@ files:
300
300
  - lib/project_types/script/errors.rb
301
301
  - lib/project_types/script/forms/create.rb
302
302
  - lib/project_types/script/graphql/app_script_set.graphql
303
- - lib/project_types/script/graphql/app_script_update_or_create.graphql
304
303
  - lib/project_types/script/graphql/get_app_scripts.graphql
305
304
  - lib/project_types/script/graphql/module_upload_url_generate.graphql
306
305
  - lib/project_types/script/graphql/script_service_proxy.graphql
@@ -356,8 +355,11 @@ files:
356
355
  - lib/shopify_cli/admin_api/populate_resource_command.rb
357
356
  - lib/shopify_cli/admin_api/schema.rb
358
357
  - lib/shopify_cli/api.rb
358
+ - lib/shopify_cli/app_type_detector.rb
359
359
  - lib/shopify_cli/command.rb
360
360
  - lib/shopify_cli/command/app_sub_command.rb
361
+ - lib/shopify_cli/command_options.rb
362
+ - lib/shopify_cli/command_options/command_serve_options.rb
361
363
  - lib/shopify_cli/commands.rb
362
364
  - lib/shopify_cli/commands/config.rb
363
365
  - lib/shopify_cli/commands/help.rb
@@ -367,6 +369,7 @@ files:
367
369
  - lib/shopify_cli/commands/populate/customer.rb
368
370
  - lib/shopify_cli/commands/populate/draft_order.rb
369
371
  - lib/shopify_cli/commands/populate/product.rb
372
+ - lib/shopify_cli/commands/reporting.rb
370
373
  - lib/shopify_cli/commands/store.rb
371
374
  - lib/shopify_cli/commands/switch.rb
372
375
  - lib/shopify_cli/commands/system.rb
@@ -384,7 +387,6 @@ files:
384
387
  - lib/shopify_cli/db.rb
385
388
  - lib/shopify_cli/environment.rb
386
389
  - lib/shopify_cli/exception_reporter.rb
387
- - lib/shopify_cli/exception_reporter/permission_controller.rb
388
390
  - lib/shopify_cli/feature.rb
389
391
  - lib/shopify_cli/form.rb
390
392
  - lib/shopify_cli/git.rb
@@ -402,6 +404,7 @@ files:
402
404
  - lib/shopify_cli/migrator.rb
403
405
  - lib/shopify_cli/migrator/migration.rb
404
406
  - lib/shopify_cli/migrator/migrations/1631709766_noop.rb
407
+ - lib/shopify_cli/migrator/migrations/1633691650_merge_reporting_configuration.rb
405
408
  - lib/shopify_cli/options.rb
406
409
  - lib/shopify_cli/packager.rb
407
410
  - lib/shopify_cli/partners_api.rb
@@ -411,10 +414,14 @@ files:
411
414
  - lib/shopify_cli/project.rb
412
415
  - lib/shopify_cli/project_commands.rb
413
416
  - lib/shopify_cli/project_type.rb
417
+ - lib/shopify_cli/reporting_configuration_controller.rb
414
418
  - lib/shopify_cli/resolve_constant.rb
415
419
  - lib/shopify_cli/resources.rb
416
420
  - lib/shopify_cli/resources/env_file.rb
417
421
  - lib/shopify_cli/result.rb
422
+ - lib/shopify_cli/services.rb
423
+ - lib/shopify_cli/services/base_service.rb
424
+ - lib/shopify_cli/services/reporting_service.rb
418
425
  - lib/shopify_cli/shopifolk.rb
419
426
  - lib/shopify_cli/sub_command.rb
420
427
  - lib/shopify_cli/task.rb
@@ -451,6 +458,7 @@ files:
451
458
  - shopify.fish
452
459
  - shopify.sh
453
460
  - utilities/docker.rb
461
+ - utilities/docker/container.rb
454
462
  - utilities/utilities.rb
455
463
  - vendor/deps/cli-kit/REVISION
456
464
  - vendor/deps/cli-kit/lib/cli/kit.rb
@@ -1,60 +0,0 @@
1
- require "rbconfig"
2
- require "fileutils"
3
- require "date"
4
-
5
- gem = File.expand_path("../../../", __FILE__)
6
- exe = File.join(gem, "bin", "shopify")
7
-
8
- # `--skip-cli-build` will be passed from the brew `shopify-cli.rb` formula, so
9
- # as to prevent this extension builder doing the script and sym-link creation;
10
- # the brew install process takes care of these itself - see
11
- # https://github.com/Shopify/homebrew-shopify/shopify-cli.rb
12
- if ARGV && ARGV[0]&.match(/skip-cli-build/)
13
- makefile_content = <<~MAKEFILE
14
- .PHONY: clean
15
-
16
- clean: ;
17
-
18
- install: ;
19
- MAKEFILE
20
- elsif RUBY_PLATFORM.match(/mswin|mingw|cygwin/)
21
- bat_path = File.dirname(RbConfig.ruby)
22
- bat = "#{bat_path}\\shopify.bat"
23
-
24
- script_content = "#{RbConfig.ruby} -I '#{gem}' '#{exe}' %*"
25
-
26
- FileUtils.mkdir_p(bat_path)
27
- makefile_content = <<~MAKEFILE
28
- .PHONY: clean install
29
-
30
- clean:
31
- \t rm -f "#{bat}"
32
-
33
- install: clean
34
- \t echo "@ECHO OFF"> "#{bat}"
35
- \t echo "#{script_content}">> "#{bat}"
36
- MAKEFILE
37
- else
38
- script = exe + ".sh"
39
- symlink = "/usr/local/bin/shopify"
40
-
41
- script_content = <<~SCRIPT
42
- #!/usr/bin/env bash
43
- #{RbConfig.ruby} -I #{gem} #{exe} $@
44
- SCRIPT
45
-
46
- File.write(script, script_content)
47
- FileUtils.chmod("+x", script)
48
-
49
- makefile_content = <<~MAKEFILE
50
- .PHONY: clean install
51
-
52
- clean:
53
- \t@sudo rm -f #{symlink}
54
-
55
- install: clean
56
- \t@sudo ln -s #{script} #{symlink}
57
- MAKEFILE
58
- end
59
-
60
- File.write("Makefile", makefile_content)
@@ -1,54 +0,0 @@
1
- module ShopifyCLI
2
- module ExceptionReporter
3
- module PermissionController
4
- def self.report_error?(context: ShopifyCLI::Context.new)
5
- CLI::UI::Prompt.ask(context.message("core.error_reporting.report_error.question")) do |handler|
6
- handler.option(context.message("core.error_reporting.report_error.yes")) { |_| true }
7
- handler.option(context.message("core.error_reporting.report_error.no")) { |_| false }
8
- end
9
- end
10
-
11
- def self.automatic_reporting_prompted?
12
- ShopifyCLI::Config.get_section(Constants::Config::Sections::ErrorTracking::NAME).key?(
13
- Constants::Config::Sections::ErrorTracking::Fields::AUTOMATIC_REPORTING
14
- )
15
- end
16
-
17
- def self.can_report_automatically?(context: ShopifyCLI::Context.new)
18
- # If the terminal is not interactive we can't prompt the user.
19
- return false unless ShopifyCLI::Environment.interactive?
20
-
21
- if automatic_reporting_prompted?
22
- automatic_reporting_enabled?
23
- else
24
- prompt_user(context: context)
25
- end
26
- end
27
-
28
- def self.prompt_user(context:)
29
- enable_automatic_tracking = CLI::UI::Prompt.ask(
30
- context.message("core.error_reporting.enable_automatic_reporting_prompt.question")
31
- ) do |handler|
32
- handler.option(context.message("core.error_reporting.enable_automatic_reporting_prompt.yes")) { |_| true }
33
- handler.option(context.message("core.error_reporting.enable_automatic_reporting_prompt.no")) { |_| false }
34
- end
35
-
36
- ShopifyCLI::Config.set(
37
- Constants::Config::Sections::ErrorTracking::NAME,
38
- Constants::Config::Sections::ErrorTracking::Fields::AUTOMATIC_REPORTING,
39
- enable_automatic_tracking
40
- )
41
-
42
- enable_automatic_tracking
43
- end
44
-
45
- def self.automatic_reporting_enabled?
46
- ShopifyCLI::Config.get_bool(
47
- Constants::Config::Sections::ErrorTracking::NAME,
48
- Constants::Config::Sections::ErrorTracking::Fields::AUTOMATIC_REPORTING,
49
- default: false
50
- )
51
- end
52
- end
53
- end
54
- end