bootic_cli 0.4.5 → 0.4.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6ab030919ecb399f1cda0030a9573b1dc1cebd7
4
- data.tar.gz: 3f6079156d89e0c6c18909453e3e50566d461283
3
+ metadata.gz: d367fc55f094ab200cc69836ed66a79c153ce766
4
+ data.tar.gz: a3aeee896b866038b588991bab6bb742a1c7114b
5
5
  SHA512:
6
- metadata.gz: ff7ae4987db9ab03c59ad9628a12470a0ced9088e10372252b590ecd297a22eb8406fb663d574e24bacd817371fb9fa4b54a87c9486cdb519ea47f82f97a50b4
7
- data.tar.gz: 63feac3baa1a355bd88c14cc11ed82fb1968370b364bad4310ee9cd3b8d6f29669d0dad28535f6e4dd567a74558a85e3e6818e151262e8356b28e2a4296b2b42
6
+ metadata.gz: f057c66358b85c1ceb1d58e874922a5ceec891aca95e9039e7a784d36d7fdb97662345d633e868d56eac19f7e0b09e95654ba3fe2fc5602120a5c808320f8498
7
+ data.tar.gz: e5ff8006d9b702befaf184822258306c194a947841ad5af8e7b3fa923ba5d4b0c6ca98cfa5df92e7c03f67fe5ddf91e3c9383c66a5455344f9216d60fb492cb2
data/GUIA.md ADDED
@@ -0,0 +1,106 @@
1
+ # Guía para usar la línea de comandos de Bootic (Bootic CLI)
2
+
3
+ El CLI de Bootic es una herramienta para diseñadores y desarrolladores que
4
+ quieran realizan tareas con la API de Bootic en forma local, ya sea para ver
5
+ o modificar datos, o bien para realizar cambios en la plantilla de la tienda.
6
+
7
+ ## ¿Cómo se instala?
8
+
9
+ El CLI lo proveemos como una gema en `rubygems.org`, y requiere de
10
+ Ruby 2.2 o superior. Afortunadamente, en versiones recientes de macOS,
11
+ ya viene instalado Ruby 2.3 (esto lo puedes comprobar corriendo `ruby -v`
12
+ en un terminal).
13
+
14
+ $ ruby -v
15
+ ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]
16
+
17
+ Perfectirijillo. El paso siguiente es asegurarse que estén instaladas
18
+ las Developer Tools de Xcode:
19
+
20
+ $ xcode-select --install
21
+
22
+ Hecho eso, podemos instalar la gema:
23
+
24
+ $ sudo gem install bootic_cli
25
+
26
+ Lo cual debería escupir un montón de texto, y terminar con algo así como
27
+ "23 gems installed" si todo salió bien.
28
+
29
+ ## ¿Cómo configurarlo?
30
+
31
+ Antes de poder usarlo, el CLI necesita saber que tú eres tú para saber a
32
+ qué datos darte acceso. Para eso corremos:
33
+
34
+ $ bootic setup
35
+
36
+ Te va a hacer algunas preguntas, pero el resumen es que debes entrar a
37
+ https://auth.bootic.net/dev/cli, seguir los pasos, y luego copiar las
38
+ credenciales de acceso que veas ahí.
39
+
40
+ Esto sólo hay que hacerlo una vez, por si aca.
41
+
42
+ ## Primeros pasos y clonar plantilla
43
+
44
+ - En el terminal, para moverte entre carpetas se escribe `cd [nombreCarpeta]`,
45
+ por ejemplo `cd proyectos`. Si quieres subir un nivel, el comando es `cd ..`
46
+
47
+ - Siempre puedes correr el comando `pwd` para saber la ruta completa de la
48
+ carpeta en la que estás. el comando `ls` (con ELE) te muestra los archivos
49
+ y carpetas que hay en la ruta que estés.
50
+
51
+ - Una vez dentro de tu carpeta de trabajo (por ejemplo, `/Users/pedro/proyectos/supercliente`),
52
+ escribe `bootic themes clone`.
53
+
54
+ - Con esto se va a descargar una copia de la plantilla de tu tienda (la que
55
+ esté asociada a la cuenta con la que te logueaste antes).
56
+
57
+ - La plantilla se guardará en una carpeta con el mismo subdominio que la tienda.
58
+ deberías verla si corres `ls`.
59
+
60
+ ## Modificando el código
61
+
62
+ - Luego, una vez dentro de esa carpeta (cd subdominio), puedes correr los
63
+ siguientes comandos:
64
+
65
+ - `bootic themes compare` para comparar los cambios entre tu version local y
66
+ la versión que está arriba,
67
+ - `bootic themes pull` para bajar cualquier cambio que haya arriba,
68
+ - `bootic themes push` para subir cualquier cambio que hagas local,
69
+ - `bootic themes sync` para sincronizar los cambios de arriba con los tuyos
70
+ (gana el archivo más reciente en cada lado), y por último,
71
+ - `bootic themes watch` que se queda escuchando cualquier cambio local que
72
+ ocurra, y cuando crees o cambies o elimines un archivo lo sube automáticamente.
73
+
74
+ El sitio lo sigues viendo "a distancia", remotamente, pero usando `bootic themes watch`
75
+ es casi instantáneo.
76
+
77
+ Todos estos cambios los puedes hacer directamente sobre el sitio público,
78
+ o bien hacerlo sobre el sitio/plantilla de desarrollo, que puedes crear al
79
+ momento de correr el comando `clone`.
80
+
81
+ Si elijes crear una plantilla de desarrollo todos los cambios que hagas van
82
+ a ser sobre un sitio de desarrollo, en `https://url.del.sitio/preview/dev`.
83
+ Los sitios de desarrollo no tienen caché, así que cualquier cambio que hagas
84
+ deberías verlo ipso-facto y sin retrasos.
85
+
86
+ ## Publicando los cambios cambios
87
+
88
+ Y finalmente, cuando quieras subir los cambios de la plantilla de desarrollo
89
+ al sitio público, corres `bootic themes publish`. Esto obviamente no aplica
90
+ en caso de que estés trabajo directamente sobre la plantilla pública.
91
+
92
+ En caso de que inicialmente no hayas creado una plantilla de desarrollo y
93
+ luego quieras hacerlo, basta con que elimines la carpeta y corras el comando
94
+ `bootic clone` de nuevo.
95
+
96
+ ## ¿Cómo lo hago para bajar la plantilla de otra tienda?
97
+
98
+ En ese caso debes correr `bootic login` para loguearte usando las credenciales
99
+ asociadas a la otra tienda. El CLI te advertirá que ya estás logueado (en caso
100
+ de que ya lo estés), pero simplemente dile que sí, que quieres reemplazar las
101
+ credenciales actuales por otras.
102
+
103
+ ## Tengo más preguntas. ¿Qué hago?
104
+
105
+ Escríbenos a soporte@bootic.io o por el chat de soporte dentro del panel de
106
+ la tienda.
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Bootic CLI
2
2
 
3
- CLI to interact with the [Bootic.net API](https://developers.bootic.net/) and run custom API scripts.
3
+ CLI to interact with the [Bootic API](https://api.bootic.net/) and run custom API scripts. [Aquí hay una guía](https://github.com/bootic/bootic_cli/blob/master/GUIA.md) en castellano que explica cómo se instala y usa.
4
4
 
5
5
  ## Installation
6
6
 
7
- Install in your system.
7
+ Install via Rubygems:
8
8
 
9
9
  gem install bootic_cli
10
10
 
@@ -71,10 +71,10 @@ bootic runner list_products.rb
71
71
 
72
72
  ### Custom Thor commands
73
73
 
74
- More advanced scripts can be written as [Thor]() commands. Any scripts in `~/.bootic` will be loaded automatically.
74
+ More advanced scripts can be written as [Thor]() commands. Any scripts in `~/bootic` will be loaded automatically.
75
75
 
76
76
  ```ruby
77
- # ~/.bootic/list_products
77
+ # ~/.bootic/list_products.rb
78
78
  class ListProducts < BooticCli::Command
79
79
 
80
80
  desc "list", "list products by status"
@@ -84,7 +84,8 @@ class ListProducts < BooticCli::Command
84
84
  puts p.title
85
85
  end
86
86
  end
87
-
87
+
88
+ declare self, "list_products"
88
89
  end
89
90
  ```
90
91
 
@@ -13,7 +13,7 @@ module BooticCli
13
13
  # end
14
14
 
15
15
  desc 'clone [dir]', 'Clone remote theme into directory [dir]'
16
- option :shop, banner: '<shop_subdomain>', type: :string
16
+ option :shop, banner: '<shop_subdomain>', aliases: '-s', type: :string
17
17
  option :public, banner: '<true|false>', type: :boolean, aliases: '-p', desc: 'Clones public theme, even if dev theme exists'
18
18
  option :dev, banner: '<true|false>', type: :boolean, aliases: '-d', desc: 'Clones development theme, or creates one if missing'
19
19
  def clone(dir = nil)
@@ -7,6 +7,10 @@ module BooticCli
7
7
  def updated_on
8
8
  Time.parse(super)
9
9
  end
10
+
11
+ def ==(other)
12
+ self.updated_on == other.updated_on
13
+ end
10
14
  end
11
15
 
12
16
  class APIAsset < ItemWithTime
@@ -16,6 +20,11 @@ module BooticCli
16
20
  StringIO.new(data)
17
21
  )
18
22
  end
23
+
24
+ def ==(other)
25
+ return super if digest.to_s == '' || other.digest.to_s == ''
26
+ self.file_size == other.file_size && self.digest == other.digest
27
+ end
19
28
  end
20
29
 
21
30
  class APITheme
@@ -32,10 +41,9 @@ module BooticCli
32
41
  theme.can?(:publish_theme)
33
42
  end
34
43
 
35
- def publish(clone = false)
44
+ def publish
36
45
  if theme.can?(:publish_theme)
37
46
  @theme = theme.publish_theme
38
- @theme.create_dev_theme if clone
39
47
  reload!(false)
40
48
  end
41
49
  end
@@ -53,11 +61,11 @@ module BooticCli
53
61
  end
54
62
 
55
63
  def templates
56
- @templates ||= theme.templates.map{|t| ItemWithTime.new(t) }
64
+ @templates ||= theme.templates.map { |t| ItemWithTime.new(t) }
57
65
  end
58
66
 
59
67
  def assets
60
- @assets ||= theme.assets.map{|t| APIAsset.new(t) }
68
+ @assets ||= theme.assets.map { |t| APIAsset.new(t) }
61
69
  end
62
70
 
63
71
  def add_template(file_name, body)
@@ -1,11 +1,30 @@
1
1
  require 'fileutils'
2
2
  require 'yaml/store'
3
+ require 'digest/md5'
3
4
 
4
5
  module BooticCli
5
6
  module Themes
6
7
  class FSTheme
7
- Template = Struct.new(:file_name, :body, :updated_on)
8
- ThemeAsset = Struct.new(:file_name, :file, :updated_on)
8
+
9
+ Template = Struct.new(:file_name, :body, :updated_on) do
10
+ def ==(other)
11
+ self.updated_on == other.updated_on
12
+ end
13
+ end
14
+
15
+ ThemeAsset = Struct.new(:file_name, :file, :updated_on) do
16
+ def body; @body ||= file.read; end
17
+ def file_size; body.length; end
18
+ def digest; @digest ||= Digest::MD5.hexdigest(body); end
19
+
20
+ def ==(other)
21
+ if other.digest.to_s == '' # api theme asset without a digest set
22
+ return self.updated_on == other.updated_on
23
+ end
24
+
25
+ self.file_size == other.file_size && self.digest == other.digest
26
+ end
27
+ end
9
28
 
10
29
  ASSETS_DIR = 'assets'.freeze
11
30
  TEMPLATE_PATTERNS = ['*.liquid', '*.html', '*.css', '*.js', 'theme.yml'].freeze
@@ -19,11 +38,11 @@ module BooticCli
19
38
 
20
39
  def self.resolve_file(path)
21
40
  file = File.new(path)
22
- file_name = File.basename(path)
23
41
  type = resolve_type(path)
42
+ file_name = File.basename(path)
24
43
 
25
44
  item = if path =~ /assets\//
26
- ThemeAsset.new(file_name, file.read, file.mtime.utc)
45
+ ThemeAsset.new(file_name, file, file.mtime.utc)
27
46
  else
28
47
  Template.new(file_name, file.read, file.mtime.utc)
29
48
  end
@@ -41,7 +41,7 @@ module BooticCli
41
41
  attr_reader :source, :target, :force_update
42
42
 
43
43
  def should_update?(a, b)
44
- force_update || more_recent?(a, b)
44
+ force_update || (a != b && more_recent?(a, b))
45
45
  end
46
46
 
47
47
  def more_recent?(a, b)
@@ -110,12 +110,12 @@ module BooticCli
110
110
  # now, download missing files on local end
111
111
  notice 'Downloading missing local templates & assets...'
112
112
  copy_templates(diff.missing_in_source, local_theme, download_opts)
113
- copy_assets(diff.missing_in_source, local_theme, overwrite: true)
113
+ copy_assets(diff.missing_in_source, local_theme, download_opts)
114
114
 
115
115
  # now, upload missing files on remote
116
116
  notice 'Uploading missing remote templates & assets...'
117
117
  copy_templates(diff.missing_in_target, remote_theme, download_opts)
118
- copy_assets(diff.missing_in_target, remote_theme, overwrite: true)
118
+ copy_assets(diff.missing_in_target, remote_theme, download_opts)
119
119
 
120
120
  prompt.say "Synced! Preview this theme at #{remote_theme.path}", :cyan
121
121
  end
@@ -132,10 +132,14 @@ module BooticCli
132
132
  notice "Local <--- Remote"
133
133
 
134
134
  diff.updated_in_target.templates.each do |t|
135
- puts "Updated in remote: #{t.file_name} (updated at #{t.updated_on})"
135
+ puts "Updated template in remote: #{t.file_name} (updated at #{t.updated_on})"
136
136
  puts t.diff.to_s(:color)
137
137
  end
138
138
 
139
+ diff.updated_in_target.assets.each do |t|
140
+ puts "Updated asset in remote: #{t.file_name} (updated at #{t.updated_on})"
141
+ end
142
+
139
143
  diff.missing_in_source.templates.each do |t|
140
144
  puts "Remote template not in local dir: #{t.file_name}"
141
145
  end
@@ -151,6 +155,10 @@ module BooticCli
151
155
  puts t.diff.to_s(:color)
152
156
  end
153
157
 
158
+ diff.updated_in_source.assets.each do |t|
159
+ puts "Updated locally: #{t.file_name} (updated at #{t.updated_on})"
160
+ end
161
+
154
162
  diff.missing_in_target.templates.each do |f|
155
163
  puts "Local template not in remote: #{f.file_name}"
156
164
  end
@@ -213,7 +221,7 @@ module BooticCli
213
221
  end
214
222
 
215
223
  prompt.notice "Alrighty! Publishing your development theme..."
216
- remote_theme.publish(true) # syncs dev to public, without flipping them
224
+ remote_theme.publish # syncs dev to public, without flipping them
217
225
  prompt.notice "Yay! Your development theme has been made public. Take a look at #{remote_theme.path}"
218
226
  end
219
227
 
@@ -275,7 +283,7 @@ module BooticCli
275
283
  if opts[:overwrite]
276
284
  true
277
285
  else
278
- target_asset = to.assets.find{ |t| t.file_name == a.file_name }
286
+ target_asset = to.assets.find { |t| t.file_name == a.file_name }
279
287
  if target_asset
280
288
  opts[:interactive] && prompt.yes_or_no?("Asset exists: #{highlight(a.file_name)}. Overwrite?", false)
281
289
  else
@@ -1,3 +1,3 @@
1
1
  module BooticCli
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootic_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Celis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-25 00:00:00.000000000 Z
11
+ date: 2018-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -146,6 +146,7 @@ extra_rdoc_files: []
146
146
  files:
147
147
  - ".gitignore"
148
148
  - ".travis.yml"
149
+ - GUIA.md
149
150
  - Gemfile
150
151
  - LICENSE.txt
151
152
  - README.md