shopify-cli 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8765adff2578420b0bbaaf7aa30e7e3f6b28b20363671f9e64a419f8b97fe647
4
- data.tar.gz: 17e00973e6c881c58c1e0ade838a98e93a17a39f7d960261a36f9cdc74a87940
3
+ metadata.gz: cff1487d9bbf811bd4640cb9d67ea439ad198794e409355477757dac56052d65
4
+ data.tar.gz: 396f98fe6702a8c37cd58c906d843bc92888a7943375f99d723e7269d2dcda04
5
5
  SHA512:
6
- metadata.gz: '08b07fe290962b6ba6416214165dde7d9c78d01c7eade8662917ec530af18af1a773b08957c58be5b6c10c733bd4be8e2c40a24c2241153d575a158d3988bb84'
7
- data.tar.gz: 171f11dd5a4e740cb91345ed51e10485f9499e328bc6dec0ab3027c415b35fd312b616c451137639c224c07862d8651836074ef5bbb85563229ca93d85aa944a
6
+ metadata.gz: 93ad0fa7d1f935f07bc0549acaf7fdc4041dd7b00c1e097a13dcd591cec4e0a76f380c9fef0a69d33eb114703aebee8a57b6ad81fdac8f3b4c7463a22048af81
7
+ data.tar.gz: d326315732e87f9343a71bbf5719c46f9a951974b31c5e927437cb8e1bb64373c312aaef2fda2ddd904bb79f36fd25309fadd3cea21b6c0482d3abd6d1e7a1ea
@@ -4,7 +4,7 @@ Shopify App CLI is an open source project. We want to make it as easy and transp
4
4
 
5
5
  ## Code of conduct
6
6
 
7
- We expect all participants to read our [code of conduct](https://github.com/Shopify/shopify-app-cli/.github/CODE_OF_CONDUCT.md) to understand which actions are and aren’t tolerated.
7
+ We expect all participants to read our [code of conduct](https://github.com/Shopify/shopify-app-cli/blob/master/.github/CODE_OF_CONDUCT.md) to understand which actions are and aren’t tolerated.
8
8
 
9
9
  ## Open development
10
10
 
@@ -1,3 +1,7 @@
1
+ Version 1.1.2
2
+ ------
3
+ * Fix various minor bugs (check dir before creating Rails project, catch stderr from failed git command)
4
+
1
5
  Version 1.1.1
2
6
  ------
3
7
  * Fix a bug where usernames with spaces caused issues on Windows
@@ -20,12 +20,12 @@ module Node
20
20
  url: url,
21
21
  callback_url: "/auth/callback",
22
22
  )
23
- if @ctx.mac? && project.env.shop
24
- @ctx.puts(@ctx.message('node.serve.open_info', project.env.shop))
25
- @ctx.on_siginfo do
26
- @ctx.open_url!("#{project.env.host}/auth?shop=#{project.env.shop}")
27
- end
23
+
24
+ if project.env.shop
25
+ project_url = "#{project.env.host}/auth?shop=#{project.env.shop}"
26
+ @ctx.puts("\n" + @ctx.message('node.serve.open_info', project_url) + "\n")
28
27
  end
28
+
29
29
  CLI::UI::Frame.open(@ctx.message('node.serve.running_server')) do
30
30
  env = project.env.to_h
31
31
  env['PORT'] = ShopifyCli::Tunnel::PORT.to_s
@@ -202,7 +202,10 @@ module Node
202
202
  host_must_be_https: "HOST must be a HTTPS url.",
203
203
  },
204
204
 
205
- open_info: "{{*}} Press {{yellow: Control-T}} to open this project in {{green:%s}} ",
205
+ open_info: <<~MESSAGE,
206
+ {{*}} To install and start using your app, open this URL in your browser:
207
+ {{green:%s}}
208
+ MESSAGE
206
209
  running_server: "Running server...",
207
210
  },
208
211
 
@@ -114,6 +114,9 @@ module Rails
114
114
  @ctx.abort(@ctx.message('rails.create.error.install_failure', 'bundler ~>2.0')) unless
115
115
  install_gem('bundler', '~>2.0')
116
116
 
117
+ full_path = File.join(@ctx.root, name)
118
+ @ctx.abort(@ctx.message('rails.create.error.dir_exists', name)) if Dir.exist?(full_path)
119
+
117
120
  CLI::UI::Frame.open(@ctx.message('rails.create.generating_app', name)) do
118
121
  new_command = %w(rails new)
119
122
  new_command += DEFAULT_RAILS_FLAGS
@@ -124,7 +127,7 @@ module Rails
124
127
  syscall(new_command)
125
128
  end
126
129
 
127
- @ctx.root = File.join(@ctx.root, name)
130
+ @ctx.root = full_path
128
131
 
129
132
  File.open(File.join(@ctx.root, '.gitignore'), 'a') { |f| f.write('.env') }
130
133
 
@@ -20,12 +20,12 @@ module Rails
20
20
  url: url,
21
21
  callback_url: "/auth/shopify/callback",
22
22
  )
23
- if @ctx.mac? && project.env.shop
24
- @ctx.puts(@ctx.message('rails.serve.open_info', project.env.shop))
25
- @ctx.on_siginfo do
26
- @ctx.open_url!("#{project.env.host}/login?shop=#{project.env.shop}")
27
- end
23
+
24
+ if project.env.shop
25
+ project_url = "#{project.env.host}/login?shop=#{project.env.shop}"
26
+ @ctx.puts("\n" + @ctx.message('rails.serve.open_info', project_url) + "\n")
28
27
  end
28
+
29
29
  CLI::UI::Frame.open(@ctx.message('rails.serve.running_server')) do
30
30
  env = ShopifyCli::Project.current.env.to_h
31
31
  env.delete('HOST')
@@ -36,6 +36,7 @@ module Rails
36
36
  See {{underline:https://github.com/Shopify/shopify-app-cli/blob/master/docs/installing-ruby.md}}
37
37
  for our recommended method of installing ruby.
38
38
  MSG
39
+ dir_exists: "Project directory %s already exists. Please use a different name.",
39
40
  install_failure: "Error installing %s gem",
40
41
  node_required: "node is required to create a rails project. Download at https://nodejs.org/en/download.",
41
42
  node_version_failure: "Failed to get the current node version. Please make sure it is installed as " \
@@ -219,7 +220,10 @@ module Rails
219
220
  host_must_be_https: "{{red:HOST must be a HTTPS url.}}",
220
221
  },
221
222
 
222
- open_info: "{{*}} Press {{yellow: Control-T}} to open this project in {{green:%s}} ",
223
+ open_info: <<~MESSAGE,
224
+ {{*}} To install and start using your app, open this URL in your browser:
225
+ {{green:%s}}
226
+ MESSAGE
223
227
  running_server: "Running server...",
224
228
  },
225
229
 
@@ -29,7 +29,7 @@ module Script
29
29
  no_existing_orgs_cause: "You don't have any partner organizations.",
30
30
  no_existing_orgs_help: "Please visit https://partners.shopify.com/ to create a partners account.",
31
31
 
32
- no_existing_stores_cause: "You don't have any development stores.",
32
+ no_existing_stores_cause: "You don't have any stores.",
33
33
  no_existing_stores_help: "Visit https://partners.shopify.com/%{organization_id}/stores/ to create one.",
34
34
 
35
35
  project_exists_cause: "Directory with the same name as the script already exists.",
@@ -43,7 +43,7 @@ module Script
43
43
 
44
44
  script_not_found_cause: "Couldn't find script %s for extension point %s",
45
45
 
46
- app_not_installed_cause: "App not installed on development store.",
46
+ app_not_installed_cause: "App not installed on store.",
47
47
 
48
48
  app_script_not_pushed_help: "Push the script and then try this command again.",
49
49
 
@@ -70,7 +70,7 @@ module Script
70
70
  "on this extension point.",
71
71
  shop_script_conflict_help: "Disable that script or uninstall that app and try again.",
72
72
 
73
- shop_script_undefined_cause: "Script is already turned off in development store.",
73
+ shop_script_undefined_cause: "Script is already turned off in store.",
74
74
  },
75
75
 
76
76
  create: {
@@ -100,7 +100,7 @@ module Script
100
100
  HELP
101
101
 
102
102
  error: {
103
- operation_failed: "Script not pushed.",
103
+ operation_failed: "Couldn't push script to app.",
104
104
  },
105
105
 
106
106
  script_pushed: "{{v}} Script pushed to app (API key: %{api_key}).",
@@ -108,21 +108,20 @@ module Script
108
108
 
109
109
  disable: {
110
110
  help: <<~HELP,
111
- Turn off script in development store.
111
+ Turn off script in store.
112
112
  Usage: {{command:%s disable}}
113
113
  HELP
114
114
 
115
115
  error: {
116
116
  operation_failed: "Can't disable script.",
117
- not_pushed_to_app: "Can't disable the script because it hasn't been pushed to the app.",
118
117
  },
119
118
 
120
- script_disabled: "{{v}} Script disabled. Script is turned off in development store.",
119
+ script_disabled: "{{v}} Script disabled. Script is turned off in store.",
121
120
  },
122
121
 
123
122
  enable: {
124
123
  help: <<~HELP,
125
- Turn on script in development store.
124
+ Turn on script in store.
126
125
  Usage: {{command:%s enable}}
127
126
  Options:
128
127
  {{command:--config_props='name1:value1, name2:value2'}} Optional. Define the configuration of your script by passing individual name and value pairs. If used with --config_file, then matching values in --config_props will override those set in the file.
@@ -135,11 +134,10 @@ module Script
135
134
 
136
135
  error: {
137
136
  operation_failed: "Can't enable script.",
138
- not_pushed_to_app: "Can't enable the script because it hasn't been pushed to the app.",
139
137
  },
140
138
 
141
139
  script_enabled: "{{v}} Script enabled. %{type} script %{title} in app (API key: %{api_key}) "\
142
- "is turned on in development store {{green:%{shop_domain}}}",
140
+ "is turned on in store {{green:%{shop_domain}}}",
143
141
  },
144
142
 
145
143
  project_deps: {
@@ -149,35 +147,11 @@ module Script
149
147
  installed: "Missing dependencies installed",
150
148
  },
151
149
 
152
- test: {
153
- help: <<~HELP,
154
- Runs unit tests on your script.
155
- Usage: {{command:%s test}}
156
- HELP
157
-
158
- error: {
159
- operation_failed: "Tests didn't run or they ran with failures.",
160
- },
161
-
162
- running: "Running tests",
163
- success: "{{v}} Tests finished.",
164
- },
165
-
166
150
  forms: {
167
151
  create: {
168
152
  select_extension_point: "Which extension point do you want to use?",
169
153
  script_name: "Script Name",
170
154
  },
171
- script_form: {
172
- ask_app_api_key_default: "Which app do you want this script to belong to?",
173
- ask_shop_domain_default: "Select a development store",
174
- fetching_organizations: "Fetching partner organizations",
175
- fetched_organizations: "Fetched partner organizations",
176
- select_organization: "Select partner organization.",
177
- using_app: "Using app {{green:%{title} (%{api_key})}}.",
178
- using_development_store: "Using development store {{green:%{domain}}}",
179
- using_organization: "Partner organization {{green:%s}}.",
180
- },
181
155
  },
182
156
 
183
157
  application: {
@@ -2,6 +2,8 @@
2
2
  require 'shopify_cli'
3
3
  require 'fileutils'
4
4
  require 'rbconfig'
5
+ require 'net/http'
6
+ require 'json'
5
7
 
6
8
  module ShopifyCli
7
9
  ##
@@ -11,6 +13,11 @@ module ShopifyCli
11
13
  # resoures.
12
14
  #
13
15
  class Context
16
+ GEM_LATEST_URI = URI.parse('https://rubygems.org/api/v1/versions/shopify-cli/latest.json')
17
+ VERSION_CHECK_SECTION = 'versioncheck'
18
+ LAST_CHECKED_AT_FIELD = 'last_checked_at'
19
+ VERSION_CHECK_INTERVAL = 86400
20
+
14
21
  class << self
15
22
  attr_reader :messages
16
23
 
@@ -446,6 +453,23 @@ module ShopifyCli
446
453
  nil
447
454
  end
448
455
 
456
+ # Checks if there's a newer version of the CLI available and returns version string if
457
+ # this should be conveyed to the user (i.e., if it's been over 24 hours since last check)
458
+ #
459
+ # #### Parameters
460
+ #
461
+ # #### Returns
462
+ # - `version`: string of newer version available, IFF new version is available AND it's time to inform user,
463
+ # : nil otherwise
464
+ #
465
+ def new_version
466
+ if (time_of_last_check + VERSION_CHECK_INTERVAL) < (now = Time.now.to_i)
467
+ update_time_of_last_check(now)
468
+ latest_version = retrieve_latest_gem_version
469
+ latest_version unless latest_version == ShopifyCli::VERSION
470
+ end
471
+ end
472
+
449
473
  private
450
474
 
451
475
  def ctx_path(fname)
@@ -456,5 +480,21 @@ module ShopifyCli
456
480
  File.join(root, fname)
457
481
  end
458
482
  end
483
+
484
+ def retrieve_latest_gem_version
485
+ response = Net::HTTP.get_response(GEM_LATEST_URI)
486
+ latest = JSON.parse(response.body)
487
+ latest["version"]
488
+ rescue
489
+ nil
490
+ end
491
+
492
+ def time_of_last_check
493
+ (val = ShopifyCli::Config.get(VERSION_CHECK_SECTION, LAST_CHECKED_AT_FIELD)) ? val.to_i : 0
494
+ end
495
+
496
+ def update_time_of_last_check(time)
497
+ ShopifyCli::Config.set(VERSION_CHECK_SECTION, LAST_CHECKED_AT_FIELD, time)
498
+ end
459
499
  end
460
500
  end
@@ -28,6 +28,9 @@ module ShopifyCli
28
28
  ctx.puts(
29
29
  ctx.message('core.warning.development_version', File.join(ShopifyCli::ROOT, 'bin', ShopifyCli::TOOL_NAME))
30
30
  )
31
+ else
32
+ new_version = ctx.new_version
33
+ ctx.puts(ctx.message('core.warning.new_version', ShopifyCli::VERSION, new_version)) unless new_version.nil?
31
34
  end
32
35
 
33
36
  ProjectType.load_type(Project.current_project_type)
@@ -125,13 +125,13 @@ module ShopifyCli
125
125
 
126
126
  success = Open3.popen3('git', *git_command, '--progress') do |_stdin, _stdout, stderr, thread|
127
127
  while (line = stderr.gets)
128
+ msg << line.chomp
128
129
  next unless line.strip.start_with?('Receiving objects:')
129
130
  percent = (line.match(/Receiving objects:\s+(\d+)/)[1].to_f / 100).round(2)
130
131
  bar.tick(set_percent: percent)
131
132
  next
132
133
  end
133
134
 
134
- msg << stderr
135
135
  thread.value
136
136
  end.success?
137
137
 
@@ -317,7 +317,7 @@ module ShopifyCli
317
317
  warning: {
318
318
  development_version: <<~DEVELOPMENT,
319
319
  {{*}} {{yellow:You are running a development version of the CLI at:}}
320
- {{yellow:%s}}
320
+ {{yellow:%s}}
321
321
 
322
322
  DEVELOPMENT
323
323
 
@@ -328,6 +328,14 @@ module ShopifyCli
328
328
  {{underline:https://shopify.github.io/shopify-app-cli/migrate/}}
329
329
 
330
330
  MESSAGE
331
+
332
+ new_version: <<~MESSAGE,
333
+ {{*}} {{yellow:A new version of the Shopify App CLI is available! You have version %s and the latest version is %s.
334
+
335
+ To upgrade, follow the instructions for the package manager you’re using:
336
+ {{underline:https://shopify.github.io/shopify-app-cli/getting-started/upgrade/}}}}
337
+
338
+ MESSAGE
331
339
  },
332
340
  },
333
341
  }.freeze
@@ -1,3 +1,3 @@
1
1
  module ShopifyCli
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
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: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-27 00:00:00.000000000 Z
11
+ date: 2020-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler