marketplace-kit 0.1.4 → 0.2.0

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
  SHA1:
3
- metadata.gz: 14be8b29844b60d5be3f94fa6619599e0a2ac0bc
4
- data.tar.gz: 647598d7ec8a66a5f1d103aada297534c6fa2f11
3
+ metadata.gz: 8b630bebf9a893b0a57f93311ac7216fc8311f59
4
+ data.tar.gz: f708c27fa61ce7333c346836ef2c3afac9379a60
5
5
  SHA512:
6
- metadata.gz: 52ecc290e1efbf67389c2bda3999c2228e681f841fc6eaef60c33d04848a638661b2d10fb1ea28193cbefd15dbaea6fe76a88e443e3bb73c2e4adbce0053fdff
7
- data.tar.gz: cf7ca768ea907ac894dabf65a642c0367e6a46aa383d8653ff32056ac89353b61012ab926f04389e3548eb465be49be1fa3b131ede89b6c53d1c1482e681dd99
6
+ metadata.gz: fe9c3698a774033d0f64e8f8207ff80d300b350ae95296954d3dfaa38964bfdf6f8d488679175de9549319dd152030575e5d76f07e9ac1d04be12eb706eb5ba5
7
+ data.tar.gz: f5fb46f4e5951dff722b94d5cf78e55f7446427c06441aad4c05b4639076acb39e9030dacdf286531c3c08ed412d248bed57404bc49fc15938ab7c06ce555fb9
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /marketplace-kit-*
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
3
+ - 2.1.0
4
+ - 2.3.4
4
5
  - 2.4.1
5
6
  env:
6
7
  script:
@@ -0,0 +1,21 @@
1
+ # MarketplaceKit contribute guide
2
+ How to develop, test and release new version of the gem
3
+
4
+ When setting new version to release, please read [SemVer](http://semver.org/).
5
+
6
+ ## Test
7
+
8
+ rake spec
9
+
10
+ ## Test locally
11
+
12
+ 1. Change code
13
+ 2. `gem build marketplace_kit.gemspec`
14
+ 3. `gem install marketplace-kit-x.x.x.gem`
15
+ 4. Run `marketplace-kit`
16
+
17
+ ## Release
18
+
19
+ 1. `gem build marketplace_kit.gemspec`
20
+ 2. `gem push marketplace-kit-x.x.x.gem`
21
+ 3. Create git tag `git tag vx.x.x; git push origin --tags`
data/README.md CHANGED
@@ -47,4 +47,8 @@ All commands should be run in the marketplace directory (ie. `marketplace-nearme
47
47
 
48
48
  ## Contributing
49
49
 
50
- Bug reports and pull requests are welcome on GitHub at https://github.com/mdyd-dev/marketplace-kit.
50
+ [Contributing quick start](https://github.com/mdyd-dev/marketplace-kit/blob/master/CONTRIBUTE_README.md)
51
+
52
+ [Bug reports, feature requests](https://github.com/mdyd-dev/marketplace-kit/issues)
53
+
54
+ [Pull requests](https://github.com/mdyd-dev/marketplace-kit/pulls)
@@ -22,11 +22,21 @@ module MarketplaceKit
22
22
 
23
23
  def zip_marketplace_builder_directory
24
24
  system "rm #{Dir.getwd}/tmp/marketplace_builder.zip"
25
- system "cd #{MarketplaceKit::MARKETPLACE_BUILDER_FOLDER}; zip -r #{Dir.getwd}/tmp/marketplace_builder.zip ."
25
+ force_mode? ? zip_all_files : zip_files_without_old_assets
26
+ end
27
+
28
+ def zip_files_without_old_assets
29
+ files_path = changed_files.map { |path| path.gsub(%r{^\/}, '') }
30
+ File.open('tmp/files_to_zip.txt', 'w+') { |file| file.puts files_path }
31
+ system "cd #{MarketplaceKit::MARKETPLACE_BUILDER_FOLDER}; zip #{root}/tmp/marketplace_builder.zip -@ < #{root}/tmp/files_to_zip.txt"
32
+ end
33
+
34
+ def zip_all_files
35
+ system "cd #{MarketplaceKit::MARKETPLACE_BUILDER_FOLDER}; zip -r #{root}/tmp/marketplace_builder.zip ."
26
36
  end
27
37
 
28
38
  def send_zip_to_server
29
- gateway.deploy("#{Dir.getwd}/tmp/marketplace_builder.zip", force: is_force_mode)
39
+ gateway.deploy("#{root}/tmp/marketplace_builder.zip", force: force_mode?, manifest: manifest)
30
40
  end
31
41
 
32
42
  def wait_for_deploy(deploy_id)
@@ -54,9 +64,45 @@ module MarketplaceKit
54
64
  end
55
65
  end
56
66
 
57
- def is_force_mode
67
+ def force_mode?
58
68
  (@command_args & ['--force', '-f']).any?
59
69
  end
70
+
71
+ def manifest
72
+ Dir.glob("marketplace_builder/**/*")
73
+ .select { |path| File.file?(path) }
74
+ .map { |path| [path.gsub('marketplace_builder', ''), { 'md5' => Digest::MD5.hexdigest(File.read(path)) }] }
75
+ .to_h
76
+ end
77
+
78
+ def root
79
+ Dir.getwd
80
+ end
81
+
82
+ def changed_files
83
+ ListChangedFiles.new(manifest, gateway.settings.body).call.keys
84
+ end
85
+
86
+ class ListChangedFiles
87
+ def initialize(manifest, settings)
88
+ @manifest = manifest
89
+ @settings = settings
90
+ end
91
+
92
+ def call
93
+ @manifest.reject do |path, meta|
94
+ path.start_with?('/custom_themes/') &&
95
+ manifest_on_server[path] &&
96
+ manifest_on_server[path]['md5'] == meta['md5']
97
+ end
98
+ end
99
+
100
+ private
101
+
102
+ def manifest_on_server
103
+ @manifest_on_server ||= @settings['manifest']
104
+ end
105
+ end
60
106
  end
61
107
  end
62
108
  end
@@ -2,39 +2,54 @@ module MarketplaceKit
2
2
  module Services
3
3
  class ApiGateway
4
4
  def login(email, password)
5
- response = send(:post, 'sessions', email: email, password: password)
5
+ response = send_request(:post, 'sessions', email: email, password: password)
6
6
  raise Errors::MarketplaceError.new('Error: Invalid email or password!') if response.status == 401
7
7
 
8
8
  response.body['token']
9
9
  end
10
10
 
11
11
  def login_required?
12
- response = send(:get, "sessions?temporary_token=#{MarketplaceKit.config.token}")
12
+ response = send_request(:get, "sessions?temporary_token=#{MarketplaceKit.config.token}")
13
13
  raise Errors::MarketplaceError.new('Login failed.') unless response.success?
14
14
 
15
15
  response.body['login_required']
16
16
  end
17
17
 
18
18
  def send_file_change(file_path, file_content)
19
- send(:put, 'marketplace_releases/sync', path: file_path, marketplace_builder_file_body: file_content)
19
+ send_request(:put, 'marketplace_releases/sync', path: file_path, marketplace_builder_file_body: file_content)
20
20
  end
21
21
 
22
22
  def get_deploy(deploy_id)
23
- send(:get, "marketplace_releases/#{deploy_id}")
23
+ send_request(:get, "marketplace_releases/#{deploy_id}")
24
24
  end
25
25
 
26
- def deploy(zip_file_path, deploy_options)
26
+ def deploy(zip_file_path, force:, manifest:)
27
27
  upload_file = Faraday::UploadIO.new(zip_file_path, 'application/zip')
28
- send(:post, 'marketplace_releases', { marketplace_builder: { zip_file: upload_file, force_mode: deploy_options[:force] } }, multipart: true)
28
+ send_request(
29
+ :post,
30
+ 'marketplace_releases',
31
+ {
32
+ marketplace_builder: {
33
+ zip_file: upload_file,
34
+ force_mode: force,
35
+ manifest: manifest
36
+ }
37
+ },
38
+ multipart: true
39
+ )
29
40
  end
30
41
 
31
42
  def backup
32
- send(:post, 'marketplace_releases/backup', {})
43
+ send_request(:post, 'marketplace_releases/backup', {})
44
+ end
45
+
46
+ def settings
47
+ send_request(:get, 'settings')
33
48
  end
34
49
 
35
50
  private
36
51
 
37
- def send(request_type, url, body = {}, options = {})
52
+ def send_request(request_type, url, body = {}, options = {})
38
53
  ApiDriver.new(request_type, url, body, options).send_request
39
54
  end
40
55
  end
@@ -1,3 +1,3 @@
1
1
  module MarketplaceKit
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marketplace-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Janeczek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-12 00:00:00.000000000 Z
11
+ date: 2017-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -189,6 +189,7 @@ files:
189
189
  - ".gitignore"
190
190
  - ".rspec"
191
191
  - ".travis.yml"
192
+ - CONTRIBUTE_README.md
192
193
  - Gemfile
193
194
  - README.md
194
195
  - Rakefile
@@ -213,7 +214,10 @@ files:
213
214
  - lib/marketplace_kit/version.rb
214
215
  - marketplace_builder/.builder
215
216
  - marketplace_builder/.builder-autogenerated
217
+ - marketplace_builder/custom_themes/default_custom_theme/foo.txt
218
+ - marketplace_builder/custom_themes/default_custom_theme/foo_unchanged.txt
216
219
  - marketplace_builder/liquid_views/index.liquid
220
+ - marketplace_builder/liquid_views/unchanged_file.liquid
217
221
  - marketplace_kit.gemspec
218
222
  homepage: https://marketplaceplatform.com
219
223
  licenses: []
@@ -235,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
239
  version: '0'
236
240
  requirements: []
237
241
  rubyforge_project:
238
- rubygems_version: 2.6.10
242
+ rubygems_version: 2.6.14
239
243
  signing_key:
240
244
  specification_version: 4
241
245
  summary: Marketplace Kit