@shopify/cli-kit 3.45.0 → 3.46.0-pre.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/assets/cli-ruby/Gemfile +0 -1
  2. package/assets/cli-ruby/Rakefile +0 -76
  3. package/assets/cli-ruby/lib/project_types/extension/cli.rb +5 -86
  4. package/assets/cli-ruby/lib/shopify_cli/admin_api.rb +0 -3
  5. package/assets/cli-ruby/lib/shopify_cli/command/sub_command.rb +1 -2
  6. package/assets/cli-ruby/lib/shopify_cli/command.rb +0 -7
  7. package/assets/cli-ruby/lib/shopify_cli/commands.rb +0 -15
  8. package/assets/cli-ruby/lib/shopify_cli/core.rb +0 -1
  9. package/assets/cli-ruby/lib/shopify_cli/identity_auth.rb +0 -1
  10. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/proxy.rb +9 -1
  11. package/assets/cli-ruby/lib/shopify_cli.rb +1 -10
  12. package/assets/cli-ruby/test/test_helpers.rb +0 -2
  13. package/dist/public/common/version.d.ts +1 -1
  14. package/dist/public/common/version.js +1 -1
  15. package/dist/public/common/version.js.map +1 -1
  16. package/dist/tsconfig.tsbuildinfo +1 -1
  17. package/package.json +1 -1
  18. package/assets/cli-ruby/lib/project_types/extension/commands/build.rb +0 -51
  19. package/assets/cli-ruby/lib/project_types/extension/commands/check.rb +0 -51
  20. package/assets/cli-ruby/lib/project_types/extension/commands/connect.rb +0 -35
  21. package/assets/cli-ruby/lib/project_types/extension/commands/create.rb +0 -100
  22. package/assets/cli-ruby/lib/project_types/extension/commands/info.rb +0 -86
  23. package/assets/cli-ruby/lib/project_types/extension/commands/push.rb +0 -112
  24. package/assets/cli-ruby/lib/project_types/extension/commands/register.rb +0 -67
  25. package/assets/cli-ruby/lib/project_types/extension/commands/tunnel.rb +0 -73
  26. package/assets/cli-ruby/lib/project_types/extension/forms/connect.rb +0 -42
  27. package/assets/cli-ruby/lib/project_types/extension/forms/create.rb +0 -49
  28. package/assets/cli-ruby/lib/project_types/extension/forms/questions/ask_app.rb +0 -53
  29. package/assets/cli-ruby/lib/project_types/extension/forms/questions/ask_name.rb +0 -48
  30. package/assets/cli-ruby/lib/project_types/extension/forms/questions/ask_registration.rb +0 -55
  31. package/assets/cli-ruby/lib/project_types/extension/forms/questions/ask_template.rb +0 -37
  32. package/assets/cli-ruby/lib/project_types/extension/forms/questions/ask_type.rb +0 -47
  33. package/assets/cli-ruby/lib/project_types/extension/models/development_server.rb +0 -77
  34. package/assets/cli-ruby/lib/project_types/extension/models/development_server_requirements.rb +0 -56
  35. package/assets/cli-ruby/lib/project_types/extension/models/npm_package.rb +0 -44
  36. package/assets/cli-ruby/lib/project_types/extension/models/product.rb +0 -12
  37. package/assets/cli-ruby/lib/project_types/extension/models/registration.rb +0 -20
  38. package/assets/cli-ruby/lib/project_types/extension/models/server_config/app.rb +0 -13
  39. package/assets/cli-ruby/lib/project_types/extension/models/server_config/base.rb +0 -31
  40. package/assets/cli-ruby/lib/project_types/extension/models/server_config/capabilities.rb +0 -11
  41. package/assets/cli-ruby/lib/project_types/extension/models/server_config/development.rb +0 -33
  42. package/assets/cli-ruby/lib/project_types/extension/models/server_config/development_entries.rb +0 -38
  43. package/assets/cli-ruby/lib/project_types/extension/models/server_config/development_renderer.rb +0 -38
  44. package/assets/cli-ruby/lib/project_types/extension/models/server_config/development_resource.rb +0 -13
  45. package/assets/cli-ruby/lib/project_types/extension/models/server_config/extension.rb +0 -46
  46. package/assets/cli-ruby/lib/project_types/extension/models/server_config/root.rb +0 -21
  47. package/assets/cli-ruby/lib/project_types/extension/models/server_config/user.rb +0 -10
  48. package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +0 -29
  49. package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +0 -170
  50. package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/web_pixel_extension.rb +0 -58
  51. package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/web_pixel_extension_utils/script_config.rb +0 -33
  52. package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/web_pixel_extension_utils/script_config_repository.rb +0 -75
  53. package/assets/cli-ruby/lib/project_types/extension/tasks/choose_next_available_port.rb +0 -36
  54. package/assets/cli-ruby/lib/project_types/extension/tasks/convert_server_config.rb +0 -85
  55. package/assets/cli-ruby/lib/project_types/extension/tasks/converters/app_converter.rb +0 -27
  56. package/assets/cli-ruby/lib/project_types/extension/tasks/converters/product_converter.rb +0 -21
  57. package/assets/cli-ruby/lib/project_types/extension/tasks/converters/registration_converter.rb +0 -28
  58. package/assets/cli-ruby/lib/project_types/extension/tasks/create_extension.rb +0 -31
  59. package/assets/cli-ruby/lib/project_types/extension/tasks/ensure_resource_url.rb +0 -39
  60. package/assets/cli-ruby/lib/project_types/extension/tasks/execute_commands/base.rb +0 -15
  61. package/assets/cli-ruby/lib/project_types/extension/tasks/execute_commands/build.rb +0 -30
  62. package/assets/cli-ruby/lib/project_types/extension/tasks/execute_commands/create.rb +0 -30
  63. package/assets/cli-ruby/lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb +0 -57
  64. package/assets/cli-ruby/lib/project_types/extension/tasks/execute_commands/serve.rb +0 -36
  65. package/assets/cli-ruby/lib/project_types/extension/tasks/find_npm_packages.rb +0 -106
  66. package/assets/cli-ruby/lib/project_types/extension/tasks/find_package_from_json.rb +0 -37
  67. package/assets/cli-ruby/lib/project_types/extension/tasks/get_app.rb +0 -22
  68. package/assets/cli-ruby/lib/project_types/extension/tasks/get_apps.rb +0 -26
  69. package/assets/cli-ruby/lib/project_types/extension/tasks/get_extensions.rb +0 -33
  70. package/assets/cli-ruby/lib/project_types/extension/tasks/get_product.rb +0 -22
  71. package/assets/cli-ruby/lib/project_types/extension/tasks/merge_server_config.rb +0 -47
  72. package/assets/cli-ruby/lib/project_types/extension/tasks/update_draft.rb +0 -29
  73. package/assets/cli-ruby/lib/project_types/extension/tasks/user_errors.rb +0 -45
  74. package/assets/cli-ruby/lib/shopify_cli/admin_api/populate_resource_command.rb +0 -166
  75. package/assets/cli-ruby/lib/shopify_cli/admin_api/schema.rb +0 -35
  76. package/assets/cli-ruby/lib/shopify_cli/app_type_detector.rb +0 -36
  77. package/assets/cli-ruby/lib/shopify_cli/assets/post_auth_page/index.html.erb +0 -34
  78. package/assets/cli-ruby/lib/shopify_cli/assets/post_auth_page/style.css +0 -58
  79. package/assets/cli-ruby/lib/shopify_cli/changelog.rb +0 -148
  80. package/assets/cli-ruby/lib/shopify_cli/command/app_sub_command.rb +0 -26
  81. package/assets/cli-ruby/lib/shopify_cli/command_options/command_serve_options.rb +0 -53
  82. package/assets/cli-ruby/lib/shopify_cli/command_options.rb +0 -7
  83. package/assets/cli-ruby/lib/shopify_cli/commands/app/connect.rb +0 -22
  84. package/assets/cli-ruby/lib/shopify_cli/commands/app/create/node.rb +0 -40
  85. package/assets/cli-ruby/lib/shopify_cli/commands/app/create/php.rb +0 -37
  86. package/assets/cli-ruby/lib/shopify_cli/commands/app/create/rails.rb +0 -42
  87. package/assets/cli-ruby/lib/shopify_cli/commands/app/create.rb +0 -28
  88. package/assets/cli-ruby/lib/shopify_cli/commands/app/deploy.rb +0 -51
  89. package/assets/cli-ruby/lib/shopify_cli/commands/app/open.rb +0 -19
  90. package/assets/cli-ruby/lib/shopify_cli/commands/app/serve.rb +0 -51
  91. package/assets/cli-ruby/lib/shopify_cli/commands/app/tunnel.rb +0 -43
  92. package/assets/cli-ruby/lib/shopify_cli/commands/app.rb +0 -29
  93. package/assets/cli-ruby/lib/shopify_cli/commands/config.rb +0 -76
  94. package/assets/cli-ruby/lib/shopify_cli/commands/help.rb +0 -52
  95. package/assets/cli-ruby/lib/shopify_cli/commands/login.rb +0 -98
  96. package/assets/cli-ruby/lib/shopify_cli/commands/logout.rb +0 -50
  97. package/assets/cli-ruby/lib/shopify_cli/commands/populate/customer.rb +0 -25
  98. package/assets/cli-ruby/lib/shopify_cli/commands/populate/draft_order.rb +0 -28
  99. package/assets/cli-ruby/lib/shopify_cli/commands/populate/product.rb +0 -24
  100. package/assets/cli-ruby/lib/shopify_cli/commands/populate.rb +0 -23
  101. package/assets/cli-ruby/lib/shopify_cli/commands/reporting.rb +0 -38
  102. package/assets/cli-ruby/lib/shopify_cli/commands/store.rb +0 -15
  103. package/assets/cli-ruby/lib/shopify_cli/commands/switch.rb +0 -39
  104. package/assets/cli-ruby/lib/shopify_cli/commands/system.rb +0 -165
  105. package/assets/cli-ruby/lib/shopify_cli/commands/version.rb +0 -15
  106. package/assets/cli-ruby/lib/shopify_cli/commands/whoami.rb +0 -28
  107. package/assets/cli-ruby/lib/shopify_cli/connect.rb +0 -32
  108. package/assets/cli-ruby/lib/shopify_cli/core/help_resolver.rb +0 -20
  109. package/assets/cli-ruby/lib/shopify_cli/heroku.rb +0 -140
  110. package/assets/cli-ruby/lib/shopify_cli/identity_auth/servlet.rb +0 -44
  111. package/assets/cli-ruby/lib/shopify_cli/js_deps.rb +0 -110
  112. package/assets/cli-ruby/lib/shopify_cli/packager.rb +0 -108
  113. package/assets/cli-ruby/lib/shopify_cli/php_deps.rb +0 -102
  114. package/assets/cli-ruby/lib/shopify_cli/process_supervision.rb +0 -228
  115. package/assets/cli-ruby/lib/shopify_cli/project_commands.rb +0 -16
  116. package/assets/cli-ruby/lib/shopify_cli/release.rb +0 -197
  117. package/assets/cli-ruby/lib/shopify_cli/sed.rb +0 -19
  118. package/assets/cli-ruby/lib/shopify_cli/services/app/connect_service.rb +0 -25
  119. package/assets/cli-ruby/lib/shopify_cli/services/app/create/node_service.rb +0 -143
  120. package/assets/cli-ruby/lib/shopify_cli/services/app/create/php_service.rb +0 -147
  121. package/assets/cli-ruby/lib/shopify_cli/services/app/create/rails_service.rb +0 -239
  122. package/assets/cli-ruby/lib/shopify_cli/services/app/deploy/heroku/node_service.rb +0 -101
  123. package/assets/cli-ruby/lib/shopify_cli/services/app/deploy/heroku/php_service.rb +0 -135
  124. package/assets/cli-ruby/lib/shopify_cli/services/app/deploy/heroku/rails_service.rb +0 -120
  125. package/assets/cli-ruby/lib/shopify_cli/services/app/open_service.rb +0 -19
  126. package/assets/cli-ruby/lib/shopify_cli/services/app/serve/node_service.rb +0 -19
  127. package/assets/cli-ruby/lib/shopify_cli/services/app/serve/php_service.rb +0 -23
  128. package/assets/cli-ruby/lib/shopify_cli/services/app/serve/rails_service.rb +0 -28
  129. package/assets/cli-ruby/lib/shopify_cli/services/app/serve/serve_service.rb +0 -57
  130. package/assets/cli-ruby/lib/shopify_cli/services/app/tunnel/auth_service.rb +0 -21
  131. package/assets/cli-ruby/lib/shopify_cli/services/app/tunnel/start_service.rb +0 -20
  132. package/assets/cli-ruby/lib/shopify_cli/services/app/tunnel/stop_service.rb +0 -20
  133. package/assets/cli-ruby/lib/shopify_cli/services/base_service.rb +0 -13
  134. package/assets/cli-ruby/lib/shopify_cli/services/reporting_service.rb +0 -16
  135. package/assets/cli-ruby/lib/shopify_cli/services.rb +0 -38
  136. package/assets/cli-ruby/lib/shopify_cli/tunnel.rb +0 -255
@@ -1,102 +0,0 @@
1
- require "shopify_cli"
2
-
3
- module ShopifyCLI
4
- ##
5
- # ShopifyCLI::PHPDeps ensures that all PHP dependencies are installed for projects.
6
- #
7
- class PHPDeps
8
- include SmartProperties
9
-
10
- property! :ctx, accepts: ShopifyCLI::Context
11
-
12
- ##
13
- # Proxy to instance method ShopifyCLI::PHPDeps.new.install.
14
- #
15
- # #### Parameters
16
- # - `ctx`: running context from your command
17
- # - `verbose`: whether to run the installation tools in verbose mode
18
- #
19
- # #### Example
20
- #
21
- # ShopifyCLI::PHPDeps.install(ctx)
22
- #
23
- def self.install(ctx, verbose = false)
24
- new(ctx: ctx).install(verbose)
25
- end
26
-
27
- ##
28
- # Installs all of a project's PHP dependencies using Composer.
29
- #
30
- # #### Parameters
31
- # - `verbose`: whether to run the installation tools in verbose mode
32
- #
33
- # #### Example
34
- #
35
- # # context is the running context for the command
36
- # ShopifyCLI::PHPDeps.new(context).install(true)
37
- #
38
- def install(verbose = false)
39
- title = ctx.message("core.php_deps.installing")
40
- success = ctx.message("core.php_deps.installed")
41
- failure = ctx.message("core.php_deps.error.install_error")
42
-
43
- CLI::UI::Frame.open(title, success_text: success, failure_text: failure) do
44
- composer(verbose)
45
- end
46
- end
47
-
48
- private
49
-
50
- def composer(verbose = false)
51
- cmd = %w(composer install)
52
- cmd << "--quiet" unless verbose
53
-
54
- run_install_command(cmd)
55
- end
56
-
57
- def run_install_command(cmd)
58
- deps = parse_dependencies
59
- errors = nil
60
-
61
- spinner_title = ctx.message("core.php_deps.installing")
62
- success = CLI::UI::Spinner.spin(spinner_title, auto_debrief: false) do |spinner|
63
- _out, errors, status = CLI::Kit::System.capture3(*cmd, env: @ctx.env, chdir: ctx.root)
64
- update_spinner_title_and_status(spinner, status, deps)
65
- end
66
-
67
- errors.lines.each { |e| ctx.puts e } unless success || errors.nil?
68
-
69
- ctx.abort(ctx.message("core.php_deps.error.install", "Composer")) unless success
70
- success
71
- end
72
-
73
- def update_spinner_title_and_status(spinner, status, deps)
74
- if status.success?
75
- spinner.update_title(ctx.message("core.php_deps.installed_count", deps.size))
76
- else
77
- spinner.update_title(ctx.message("core.php_deps.error.install_spinner_error", deps.size))
78
- CLI::UI::Spinner::TASK_FAILED
79
- end
80
- end
81
-
82
- def parse_dependencies
83
- composer_json = File.join(ctx.root, "composer.json")
84
- pkg =
85
- begin
86
- JSON.parse(File.read(composer_json))
87
- rescue Errno::ENOENT, Errno::ENOTDIR
88
- ctx.abort(ctx.message("core.php_deps.error.missing_package", composer_json))
89
- end
90
-
91
- %w(require require-dev).map do |key|
92
- pkg.fetch(key, []).keys
93
- end.flatten
94
- rescue JSON::ParserError
95
- ctx.puts(
96
- ctx.message("core.php_deps.error.invalid_package", File.read(File.join(path, "composer.json"))),
97
- error: true
98
- )
99
- raise ShopifyCLI::AbortSilent
100
- end
101
- end
102
- end
@@ -1,228 +0,0 @@
1
- require "fileutils"
2
-
3
- module ShopifyCLI
4
- ##
5
- # ProcessSupervision wraps a running process spawned by `exec` and keeps track
6
- # if its `pid` and keeps a log file for it as well
7
- class ProcessSupervision
8
- # a string or a symbol to identify this process by
9
- attr_reader :identifier
10
- # process ID for the running process
11
- attr_accessor :pid
12
- # starttime of the process
13
- attr_reader :time
14
- # filepath to the pidfile for this process
15
- attr_reader :pid_path
16
- # filepath to the logfile for this process
17
- attr_reader :log_path
18
-
19
- class << self
20
- def run_dir
21
- # is the directory where the pid and logfile are kept
22
- File.join(ShopifyCLI.cache_dir, "sv")
23
- end
24
-
25
- ##
26
- # Will find and create a new instance of ProcessSupervision for a running process
27
- # if it is currently running. It will return nil if the process is not running.
28
- #
29
- # #### Parameters
30
- #
31
- # * `identifier` - a string or a symbol that a process was started with
32
- #
33
- # #### Returns
34
- #
35
- # * `process` - ProcessSupervision instance if the process is running this
36
- # will be nil if the process is not running.
37
- #
38
- def for_ident(identifier)
39
- pid, time = File.read(File.join(ShopifyCLI::ProcessSupervision.run_dir, "#{identifier}.pid")).split(":")
40
- new(identifier, pid: Integer(pid), time: time)
41
- rescue Errno::ENOENT
42
- nil
43
- end
44
-
45
- ##
46
- # will fork and spawn a new process that is separate from the current process.
47
- # This process will keep running beyond the command running so be careful!
48
- #
49
- # #### Parameters
50
- #
51
- # * `identifier` - a string or symbol to identify the new process by.
52
- # * `args` - a command to run, either a string or array of strings
53
- # * `force_spawn` - whether we want the child process to be a spawn and not a fork, so it is terminated along with
54
- # the parent
55
- #
56
- # #### Returns
57
- #
58
- # * `process` - ProcessSupervision instance if the process is running, this
59
- # will be nil if the process did not start.
60
- #
61
- def start(identifier, args, force_spawn: false)
62
- return for_ident(identifier) if running?(identifier)
63
-
64
- # Some systems don't support forking process without extra gems, so we resort to spawning a new child process -
65
- # that means that it dies along with the original process if it is interrupted. If possible, we fork the process
66
- # so that it doesn't have to be restarted on every run.
67
- if Process.respond_to?(:fork) && !force_spawn
68
- fork do
69
- pid_file = new(identifier, pid: Process.pid)
70
- pid_file.write
71
- STDOUT.reopen(pid_file.log_path, "w")
72
- STDERR.reopen(pid_file.log_path, "w")
73
- STDIN.reopen("/dev/null", "r")
74
- Process.setsid
75
- exec(*args)
76
- end
77
- else
78
- pid_file = new(identifier)
79
-
80
- # Make sure the file exists and is empty, otherwise Windows fails
81
- File.open(pid_file.log_path, "w") {}
82
- pid = Process.spawn(
83
- *args,
84
- out: pid_file.log_path,
85
- err: pid_file.log_path,
86
- in: Context.new.windows? ? "nul" : "/dev/null",
87
- )
88
- pid_file.pid = pid
89
- pid_file.write
90
-
91
- Process.detach(pid)
92
- end
93
-
94
- sleep(0.1)
95
- for_ident(identifier)
96
- end
97
-
98
- ##
99
- # will attempt to shutdown a running process
100
- #
101
- # #### Parameters
102
- #
103
- # * `identifier` - a string or symbol to identify the new process by.
104
- #
105
- # #### Returns
106
- #
107
- # * `stopped` - [true, false]
108
- #
109
- def stop(identifier)
110
- process = for_ident(identifier)
111
- return false unless process
112
- process.stop
113
- end
114
-
115
- ##
116
- # will help identify if your process is still running in the background.
117
- #
118
- # #### Parameters
119
- #
120
- # * `identifier` - a string or symbol to identify the new process by.
121
- #
122
- # #### Returns
123
- #
124
- # * `running` - [true, false]
125
- #
126
- def running?(identifier)
127
- process = for_ident(identifier)
128
- return false unless process
129
- process.alive?
130
- end
131
- end
132
-
133
- def initialize(identifier, pid: nil, time: Time.now.strftime("%s")) # :nodoc:
134
- @identifier = identifier
135
- @pid = pid
136
- @time = time
137
- FileUtils.mkdir_p(ShopifyCLI::ProcessSupervision.run_dir)
138
- @pid_path = File.join(ShopifyCLI::ProcessSupervision.run_dir, "#{identifier}.pid")
139
- @log_path = File.join(ShopifyCLI::ProcessSupervision.run_dir, "#{identifier}.log")
140
- end
141
-
142
- ##
143
- # will attempt to shutdown a running process
144
- #
145
- # #### Parameters
146
- #
147
- # * `ctx` - the context of this command
148
- #
149
- # #### Returns
150
- #
151
- # * `stopped` - [true, false]
152
- #
153
- def stop
154
- kill_proc
155
- unlink
156
- true
157
- rescue
158
- false
159
- end
160
-
161
- ##
162
- # will help identify if your process is still running in the background.
163
- #
164
- # #### Returns
165
- #
166
- # * `alive` - [true, false]
167
- #
168
- def alive?
169
- stat(pid)
170
- end
171
-
172
- ##
173
- # persists the pidfile
174
- #
175
- def write
176
- FileUtils.mkdir_p(File.dirname(pid_path))
177
- File.write(pid_path, "#{pid}:#{time}")
178
- end
179
-
180
- private
181
-
182
- def unlink
183
- File.unlink(pid_path)
184
- File.unlink(log_path)
185
- nil
186
- rescue Errno::ENOENT
187
- nil
188
- end
189
-
190
- def kill_proc
191
- if Context.new.windows?
192
- kill(pid)
193
- else
194
- kill(-pid) # process group
195
- end
196
- rescue Errno::ESRCH
197
- begin
198
- kill(pid)
199
- rescue Errno::ESRCH # The process group does not exist, try the pid itself
200
- # Race condition, process died in the middle
201
- end
202
- end
203
-
204
- def kill(id)
205
- ctx = Context.new
206
-
207
- # Windows does not handle SIGTERM, go straight to SIGKILL
208
- unless ctx.windows?
209
- Process.kill("TERM", id)
210
- 50.times do
211
- sleep(0.1)
212
- break unless stat(id)
213
- end
214
- end
215
- Process.kill("KILL", id) if stat(id)
216
- sleep(0.1) if ctx.windows? # Give Windows a second to actually close the process
217
- end
218
-
219
- def stat(id)
220
- Process.kill(0, id) # signal 0 checks if pid is alive
221
- true
222
- rescue Errno::EPERM
223
- true
224
- rescue Errno::ESRCH
225
- false
226
- end
227
- end
228
- end
@@ -1,16 +0,0 @@
1
- module ShopifyCLI
2
- class ProjectCommand < Command
3
- def call(*)
4
- @ctx.puts(self.class.help)
5
- end
6
-
7
- def self.help
8
- project_type = name.split("::")[0].downcase
9
- ShopifyCLI::Context.message(
10
- "#{project_type}.help",
11
- ShopifyCLI::TOOL_NAME,
12
- subcommand_registry.command_names.join(" | ")
13
- )
14
- end
15
- end
16
- end
@@ -1,197 +0,0 @@
1
- require "net/http"
2
- require "fileutils"
3
- require "shopify_cli/sed"
4
- require "shopify_cli/changelog"
5
- require "octokit"
6
-
7
- module ShopifyCLI
8
- class Release
9
- def initialize(new_version, github_access_token)
10
- @new_version = new_version
11
- @github = Octokit::Client.new(access_token: github_access_token)
12
- end
13
-
14
- def prepare!
15
- ensure_updated_main
16
- create_release_branch
17
- update_changelog
18
- update_versions_in_files
19
- commit_packaging
20
- pr = create_pr
21
- system("open #{pr["html_url"]}")
22
- end
23
-
24
- def package!
25
- ensure_updated_main
26
- ensure_correct_gem_version
27
- Rake::Task["package"].invoke
28
- update_homebrew
29
- create_github_release
30
- end
31
-
32
- private
33
-
34
- attr_reader :new_version, :github
35
-
36
- def ensure_updated_main
37
- # We can't be sure what is the correct action to take if changes have been
38
- # made but not committed. Ensure the user handles the situation before
39
- # moving on.
40
- unless %x(git status --porcelain).empty?
41
- raise <<~MESSAGE
42
- Uncommitted changes have been made to the repository.
43
- Please make sure `git status` does not show any changes before continuing.
44
- MESSAGE
45
- end
46
- system_or_fail("git checkout main", "check out main branch")
47
- unless system("git pull")
48
- raise "git pull failed, cannot be sure there aren't new commits!"
49
- end
50
- end
51
-
52
- def create_release_branch
53
- puts "Checking out release branch"
54
- system_or_fail("git checkout -b #{release_branch_name}", "check out release branch")
55
- end
56
-
57
- def update_changelog
58
- if release_notes("Unreleased").empty?
59
- puts "No unreleased CHANGELOG updates found!"
60
- else
61
- puts "Updating CHANGELOG"
62
- changelog.update_version!(new_version)
63
- end
64
- end
65
-
66
- def update_versions_in_files
67
- version_file = File.join(ShopifyCLI::ROOT, "lib/shopify_cli/version.rb")
68
- puts "Updating version.rb"
69
- ShopifyCLI::Sed.new.replace_inline(version_file, ShopifyCLI::VERSION, new_version)
70
- gemfile_lock = File.join(ShopifyCLI::ROOT, "Gemfile.lock")
71
- puts "Updating Gemfile.lock"
72
- ShopifyCLI::Sed.new.replace_inline(
73
- gemfile_lock,
74
- "shopify-cli (#{ShopifyCLI::VERSION})",
75
- "shopify-cli (#{new_version})",
76
- )
77
- end
78
-
79
- def commit_packaging
80
- puts "Committing"
81
- system_or_fail("git commit -am 'Packaging for release v#{new_version}'", "commit")
82
- system_or_fail("git push -u origin #{release_branch_name}", "push branch")
83
- end
84
-
85
- def create_pr
86
- repo = "Shopify/shopify-cli"
87
- github.create_pull_request(
88
- repo,
89
- "main",
90
- release_branch_name,
91
- "Packaging for release v#{new_version}",
92
- release_notes(new_version)
93
- ).tap { |results| puts "Created #{repo} PR ##{results["number"]}" }
94
- end
95
-
96
- def ensure_correct_gem_version
97
- response = Net::HTTP.get(URI("https://rubygems.org/api/v1/versions/shopify-cli/latest.json"))
98
- latest_version = JSON.parse(response)["version"]
99
- unless latest_version == new_version
100
- raise "Attempted to update to #{new_version}, but latest on RubyGems is #{latest_version}"
101
- end
102
- end
103
-
104
- def update_homebrew
105
- ensure_updated_homebrew_repo
106
- update_homebrew_repo
107
- pr = create_homebrew_pr
108
- system("open #{pr["html_url"]}")
109
- end
110
-
111
- def ensure_updated_homebrew_repo
112
- unless File.exist?(homebrew_path)
113
- system_or_fail("/opt/dev/bin/dev clone homebrew-shopify", "clone homebrew-shopify repo")
114
- end
115
-
116
- Dir.chdir(homebrew_path) do
117
- system_or_fail("git checkout master && git pull", "pull latest homebrew-shopify")
118
- system_or_fail("git checkout -b #{homebrew_release_branch}", "check out homebrew branch")
119
- end
120
- end
121
-
122
- def update_homebrew_repo
123
- source_file = File.join(package_dir, "shopify-cli@2.rb")
124
- FileUtils.copy(source_file, homebrew_path)
125
- Dir.chdir(homebrew_path) do
126
- system_or_fail("git commit -am '#{homebrew_update_message}'", "commit homebrew update")
127
- system_or_fail("git push -u origin #{homebrew_release_branch}", "push homebrew branch")
128
- end
129
- end
130
-
131
- def create_homebrew_pr
132
- repo = "Shopify/homebrew-shopify"
133
- github.create_pull_request(
134
- repo,
135
- "master",
136
- homebrew_release_branch,
137
- homebrew_update_message,
138
- homebrew_release_notes
139
- ).tap { |results| puts "Created #{repo} PR ##{results["number"]}" }
140
- end
141
-
142
- def create_github_release
143
- release = github.create_release(
144
- "Shopify/shopify-cli",
145
- "v#{new_version}",
146
- {
147
- name: "Version #{new_version}",
148
- body: release_notes(new_version),
149
- }
150
- )
151
- %w(.deb -1.noarch.rpm).each do |suffix|
152
- github.upload_asset(
153
- release["url"],
154
- File.join(package_dir, "shopify-cli-#{new_version}#{suffix}")
155
- )
156
- end
157
- system("open #{release["html_url"]}")
158
- end
159
-
160
- def homebrew_path
161
- @homebrew_path ||= %x(/opt/dev/bin/dev project-path homebrew-shopify).chomp
162
- end
163
-
164
- def homebrew_update_message
165
- @homebrew_update_message ||= "Update Shopify CLI to #{new_version}"
166
- end
167
-
168
- def package_dir
169
- @package_dir ||= File.join(ShopifyCLI::ROOT, "packaging", "builds", new_version)
170
- end
171
-
172
- def homebrew_release_branch
173
- "release_#{new_version.split(".").join("_")}_of_shopify-cli"
174
- end
175
-
176
- def homebrew_release_notes
177
- "I'm releasing a new version of the Shopify CLI, " \
178
- "[#{new_version}](https://github.com/Shopify/shopify-cli/releases/tag/v#{new_version})"
179
- end
180
-
181
- def release_branch_name
182
- @release_branch_name ||= "release_#{new_version.split(".").join("_")}"
183
- end
184
-
185
- def release_notes(version)
186
- changelog.release_notes(version)
187
- end
188
-
189
- def system_or_fail(command, action)
190
- raise "Failed to #{action}!" unless system(command)
191
- end
192
-
193
- def changelog
194
- @changelog ||= ShopifyCLI::Changelog.new
195
- end
196
- end
197
- end
@@ -1,19 +0,0 @@
1
- module ShopifyCLI
2
- class Sed
3
- class SedError < StandardError; end
4
-
5
- def replace_inline(filename, pattern, output)
6
- command =
7
- case CLI::Kit::System.os
8
- when :mac
9
- "sed -i ''"
10
- when :linux
11
- "sed -i"
12
- else
13
- raise "Unrecognized system!"
14
- end
15
- success = system("#{command} 's/#{pattern}/#{output}/' #{filename}")
16
- raise SedError unless success
17
- end
18
- end
19
- end
@@ -1,25 +0,0 @@
1
- module ShopifyCLI
2
- module Services
3
- module App
4
- class ConnectService < BaseService
5
- attr_reader :app_type, :project, :context
6
-
7
- def initialize(app_type:, project:, context:)
8
- @app_type = app_type
9
- @project = project
10
- @context = context
11
- super()
12
- end
13
-
14
- def call
15
- unless project&.env.nil?
16
- context.puts(context.message("core.app.connect.production_warning"))
17
- end
18
-
19
- app = ShopifyCLI::Connect.new(context).default_connect(app_type.to_s)
20
- context.done(context.message("core.app.connect.connected", app))
21
- end
22
- end
23
- end
24
- end
25
- end