locomotivecms_wagon 3.0.0.rc0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +1 -1
  4. data/Gemfile +2 -2
  5. data/README.md +4 -4
  6. data/generators/blank/Gemfile.tt +0 -6
  7. data/generators/blank/app/assets/javascripts/sections/_manager.js +3 -2
  8. data/generators/blank/app/views/pages/layouts/default.liquid +1 -1
  9. data/generators/blank/config/metafields_schema.yml +5 -0
  10. data/generators/blank/package.json.tt +1 -1
  11. data/generators/blank/public/samples/images/default.svg +1 -0
  12. data/generators/content_type/app/content_types/%slug%.yml.tt +6 -0
  13. data/generators/section/%type%.js.tt +1 -1
  14. data/generators/section/template.liquid.tt +117 -142
  15. data/generators/site_metafields/schema.yml.tt +5 -0
  16. data/generators/webpack/app/assets/javascripts/sections/_manager.js +3 -2
  17. data/generators/webpack/package.json.tt +1 -1
  18. data/lib/locomotive/wagon/cli.rb +13 -23
  19. data/lib/locomotive/wagon/commands/concerns/api_concern.rb +1 -0
  20. data/lib/locomotive/wagon/commands/concerns/steam_concern.rb +1 -1
  21. data/lib/locomotive/wagon/commands/delete_command.rb +2 -2
  22. data/lib/locomotive/wagon/commands/generate_command.rb +6 -1
  23. data/lib/locomotive/wagon/commands/push_command.rb +30 -3
  24. data/lib/locomotive/wagon/commands/push_sub_commands/push_pages_command.rb +4 -0
  25. data/lib/locomotive/wagon/commands/push_sub_commands/push_site_command.rb +4 -3
  26. data/lib/locomotive/wagon/commands/serve_command.rb +35 -54
  27. data/lib/locomotive/wagon/commands/sync_sub_commands/sync_pages_command.rb +2 -0
  28. data/lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb +1 -1
  29. data/lib/locomotive/wagon/decorators/content_type_decorator.rb +10 -1
  30. data/lib/locomotive/wagon/decorators/site_decorator.rb +14 -4
  31. data/lib/locomotive/wagon/generators/section.rb +3 -3
  32. data/lib/locomotive/wagon/generators/site/base.rb +2 -4
  33. data/lib/locomotive/wagon/middlewares/error_page.rb +18 -4
  34. data/lib/locomotive/wagon/tools/listen.rb +6 -1
  35. data/lib/locomotive/wagon/version.rb +1 -1
  36. data/locomotivecms_wagon.gemspec +8 -8
  37. data/spec/fixtures/cassettes/authenticate.yml +42 -42
  38. data/spec/fixtures/cassettes/delete.yml +238 -238
  39. data/spec/fixtures/cassettes/push.yml +2006 -2027
  40. data/spec/fixtures/cassettes/sync.yml +2290 -2311
  41. data/spec/fixtures/default/icon.png +0 -0
  42. data/spec/integration/commands/push_command_spec.rb +39 -9
  43. data/spec/integration/commands/sync_command_spec.rb +7 -1
  44. data/spec/support/vcr.rb +13 -0
  45. data/spec/unit/decorators/site_decorator_spec.rb +4 -3
  46. metadata +23 -24
  47. data/TODO +0 -57
Binary file
@@ -25,27 +25,57 @@ describe Locomotive::Wagon::PushCommand do
25
25
  let(:env) { 'hosting' }
26
26
 
27
27
  before do
28
+ allow(command).to receive(:ask_for_performing).with('You are about to deploy a new site').and_return(true)
28
29
  allow(Netrc).to receive(:read).and_return(TEST_PLATFORM_ALT_URL => credentials)
30
+ allow(command).to receive(:ask_for_performing).with("Warning! You're about to deploy data which will alter the content of your site.").and_return(true)
29
31
  allow(shell).to receive(:ask).with("What is the URL of your platform? (default: https://station.locomotive.works)").and_return(TEST_PLATFORM_URL)
30
32
  allow(shell).to receive(:ask).with('What is the handle of your site? (default: a random one)').and_return('wagon-test')
31
33
  end
32
34
 
33
35
  after { restore_deploy_file(default_site_path) }
34
36
 
35
- it 'creates a site and push the site' do
36
- resources = []
37
- ActiveSupport::Notifications.subscribe('wagon.push') do |name, start, finish, id, payload|
38
- resources << payload[:name]
37
+ context 'answer yes to the deployment of the data' do
38
+
39
+ before do
40
+ allow(shell).to receive(:yes?).with("Are you sure you want to perform this action? (answer yes or no)").and_return(true)
41
+ end
42
+
43
+ it 'creates a site and push the site' do
44
+ resources = []
45
+ ActiveSupport::Notifications.subscribe('wagon.push') do |name, start, finish, id, payload|
46
+ resources << payload[:name]
47
+ end
48
+ is_expected.not_to eq nil
49
+ expect(resources).to eq %w(site content_types content_entries pages snippets sections theme_assets translations)
39
50
  end
40
- is_expected.not_to eq nil
41
- expect(resources).to eq %w(site content_types content_entries pages snippets sections theme_assets translations)
51
+
52
+ context 'no previous authentication' do
53
+
54
+ let(:credentials) { nil }
55
+
56
+ it 'stops the deployment' do
57
+ expect(shell).to receive(:say).with("Sorry, we were unable to find the credentials for this platform.\nPlease first login using the \"bundle exec wagon auth\"", :yellow)
58
+ is_expected.to eq nil
59
+ end
60
+
61
+ end
62
+
42
63
  end
43
64
 
44
- context 'no previous authentication' do
65
+ context 'answer no to the deployment of the data' do
45
66
 
46
- let(:credentials) { nil }
67
+ before do
68
+ allow(command).to receive(:ask_for_performing).with("Warning! You're about to deploy data which will alter the content of your site.").and_return(nil)
69
+ end
47
70
 
48
- it { expect { subject }.to raise_error('You need to run `wagon auth` before going further') }
71
+ it "doesn't push the site" do
72
+ resources = []
73
+ ActiveSupport::Notifications.subscribe('wagon.push') do |name, start, finish, id, payload|
74
+ resources << payload[:name]
75
+ end
76
+ is_expected.to eq nil
77
+ expect(resources).to eq([])
78
+ end
49
79
 
50
80
  end
51
81
 
@@ -1,6 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.dirname(__FILE__) + '/../integration_helper'
4
+ require 'locomotive/steam'
5
+ require 'locomotive/steam/adapters/filesystem'
4
6
  require 'locomotive/wagon/commands/push_command'
5
7
  require 'locomotive/wagon/commands/sync_command'
6
8
  require 'thor'
@@ -44,11 +46,15 @@ describe Locomotive::Wagon::SyncCommand do
44
46
  end
45
47
 
46
48
  def create_site
49
+ _command = Locomotive::Wagon::PushCommand.new(env, path, { data: true, verbose: false }, shell)
47
50
  credentials = instance_double('Credentials', login: TEST_API_EMAIL, password: TEST_API_KEY)
48
51
  allow(Netrc).to receive(:read).and_return(TEST_PLATFORM_ALT_URL => credentials)
52
+ allow(_command).to receive(:ask_for_performing).with('You are about to deploy a new site').and_return(true)
53
+ allow(_command).to receive(:ask_for_performing).with("Warning! You're about to deploy data which will alter the content of your site.").and_return(true)
49
54
  expect(shell).to receive(:ask).with("What is the URL of your platform? (default: https://station.locomotive.works)").and_return(TEST_PLATFORM_URL)
50
55
  expect(shell).to receive(:ask).with('What is the handle of your site? (default: a random one)').and_return('wagon-test-sync')
51
- Locomotive::Wagon::PushCommand.push(env, path, { data: true, verbose: false }, shell)
56
+ _command.push
57
+ # Locomotive::Wagon::PushCommand.push(env, path, { data: true, verbose: false }, shell)
52
58
  end
53
59
 
54
60
  end
data/spec/support/vcr.rb CHANGED
@@ -1,12 +1,25 @@
1
1
  require 'vcr'
2
2
  require 'faraday'
3
3
 
4
+ # Custom VCR matchers
5
+ custom_body_matcher = lambda do |request_1, request_2|
6
+ if request_1.body.encoding.name == 'ASCII-8BIT'
7
+ # when uploading a file, we noticed that VCR or Faraday added 2 extra characters
8
+ # at the end of the body: \r\n.
9
+ request_1.body == request_2.body ||
10
+ request_1.body == request_2.body.gsub(/\r\n$/, '')
11
+ else
12
+ request_1.body == request_2.body
13
+ end
14
+ end
15
+
4
16
  # VCR config
5
17
  VCR.configure do |c|
6
18
  c.cassette_library_dir = 'spec/fixtures/cassettes'
7
19
  c.hook_into :faraday
8
20
  c.ignore_hosts 'codeclimate.com'
9
21
  c.configure_rspec_metadata!
22
+ c.register_request_matcher :custom_body, &custom_body_matcher
10
23
  end
11
24
 
12
25
  # Without this, VCR is unable to match a POST request with uploaded files
@@ -5,6 +5,7 @@ require 'ostruct'
5
5
 
6
6
  require 'locomotive/wagon/decorators/concerns/to_hash_concern'
7
7
  require 'locomotive/wagon/decorators/concerns/persist_assets_concern'
8
+ require 'locomotive/steam/decorators/i18n_decorator'
8
9
  require 'locomotive/wagon/decorators/site_decorator'
9
10
 
10
11
  describe Locomotive::Wagon::SiteDecorator do
@@ -14,7 +15,7 @@ describe Locomotive::Wagon::SiteDecorator do
14
15
 
15
16
  describe '#domains' do
16
17
 
17
- let(:attributes) { { domains: ['acme.com', 'localhost'] } }
18
+ let(:attributes) { { domains: ['acme.com', 'localhost'], default_locale: 'en', localized_attributes: [] } }
18
19
 
19
20
  subject { decorator.domains }
20
21
 
@@ -25,7 +26,7 @@ describe Locomotive::Wagon::SiteDecorator do
25
26
  describe '#to_hash' do
26
27
 
27
28
  let(:seo_title) { instance_double('I18nField', translations: { en: 'Hi', fr: 'Bonjour' }) }
28
- let(:attributes) { { name: 'Acme', handle: nil, seo_title: seo_title, locales: nil } }
29
+ let(:attributes) { { name: 'Acme', handle: nil, seo_title: seo_title, locales: nil, default_locale: 'en', localized_attributes: [] } }
29
30
  let(:site) { OpenStruct.new(attributes) }
30
31
 
31
32
  subject { decorator.to_hash }
@@ -36,7 +37,7 @@ describe Locomotive::Wagon::SiteDecorator do
36
37
 
37
38
  let(:metafields) { { some: 'Acme', img: '/samples/42.png', img2: '/samples/bar.png' } }
38
39
  let(:schema) { { some: { label: 'Some', type: 'string' }, img: { label: 'img', type: 'image' }, img2: { label: 'img2', type: 'image' } } }
39
- let(:attributes) { { name: 'Acme', handle: nil, seo_title: seo_title, locales: nil, metafields: metafields, metafields_schema: schema } }
40
+ let(:attributes) { { name: 'Acme', handle: nil, seo_title: seo_title, locales: nil, metafields: metafields, metafields_schema: schema, default_locale: 'en', localized_attributes: [] } }
40
41
  let(:asset_pusher) { SimpleAssetPusher.new }
41
42
 
42
43
  before { allow(decorator).to receive(:__content_assets_pusher__).and_return(asset_pusher) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locomotivecms_wagon
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Didier Lafforgue
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-04-25 00:00:00.000000000 Z
12
+ date: 2019-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -17,42 +17,42 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 10.0.4
20
+ version: 13.0.1
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 10.0.4
27
+ version: 13.0.1
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: thor
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 0.19.4
34
+ version: 0.20.3
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 0.19.4
41
+ version: 0.20.3
42
42
  - !ruby/object:Gem::Dependency
43
- name: thin
43
+ name: puma
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 1.7.2
48
+ version: 4.3.0
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 1.7.2
55
+ version: 4.3.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: netrc
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -73,70 +73,70 @@ dependencies:
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: 3.7.11
76
+ version: 3.9.2
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: 3.7.11
83
+ version: 3.9.2
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: locomotivecms_common
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: 0.3.1
90
+ version: 0.4.0
91
91
  type: :runtime
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: 0.3.1
97
+ version: 0.4.0
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: locomotivecms_coal
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: 1.6.0.beta1
104
+ version: 1.6.0
105
105
  type: :runtime
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: 1.6.0.beta1
111
+ version: 1.6.0
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: locomotivecms_steam
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: 1.5.0.rc0
118
+ version: 1.5.0
119
119
  type: :runtime
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: 1.5.0.rc0
125
+ version: 1.5.0
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: haml
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: 4.0.7
132
+ version: 5.1.2
133
133
  type: :runtime
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: 4.0.7
139
+ version: 5.1.2
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: listen
142
142
  requirement: !ruby/object:Gem::Requirement
@@ -195,7 +195,6 @@ files:
195
195
  - MIT-LICENSE
196
196
  - README.md
197
197
  - Rakefile
198
- - TODO
199
198
  - bin/wagon
200
199
  - generators/blank/.gitignore
201
200
  - generators/blank/Gemfile.tt
@@ -225,6 +224,7 @@ files:
225
224
  - generators/blank/public/images/.empty_directory
226
225
  - generators/blank/public/javascripts/.empty_directory
227
226
  - generators/blank/public/samples/.empty_directory
227
+ - generators/blank/public/samples/images/default.svg
228
228
  - generators/blank/public/stylesheets/.empty_directory
229
229
  - generators/cloned/Gemfile.tt
230
230
  - generators/cloned/app/content_types/.empty_directory
@@ -463,12 +463,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
463
463
  version: '0'
464
464
  required_rubygems_version: !ruby/object:Gem::Requirement
465
465
  requirements:
466
- - - ">"
466
+ - - ">="
467
467
  - !ruby/object:Gem::Version
468
- version: 1.3.1
468
+ version: '0'
469
469
  requirements: []
470
- rubyforge_project:
471
- rubygems_version: 2.7.3
470
+ rubygems_version: 3.0.3
472
471
  signing_key:
473
472
  specification_version: 4
474
473
  summary: The LocomotiveCMS wagon is a site generator for the LocomotiveCMS engine
data/TODO DELETED
@@ -1,57 +0,0 @@
1
- *** REQUIREMENTS ***
2
-
3
- x templatized page
4
- x localized page
5
- x dragonfly
6
- - listen:
7
- x content types and content entries / site
8
- - make it work for other platforms (linux, windows)
9
- x post content entry
10
- x liquid assigns: sessions (rack)
11
- x I18n keys
12
- x fr/en
13
- x other locales
14
- x static js/css assets (non coffeescript or sass files) are not reloaded if got changed.
15
- x content types / liquid
16
- x group_contents_by
17
- x select_names
18
- x params to launch the thin server (port, address ?)
19
- - commands:
20
- ! create
21
- ! sites
22
- x blank
23
- x twitter bootstrap + HAML
24
- ? localized
25
- ? boilerplate
26
- ! copy Bundler / Gemfile (pending)
27
- x content types
28
- x definitions
29
- x data (Faker)
30
- x page
31
- x snippet
32
- - push:
33
- x option to select to push only some parts (pages, ...etc)
34
- x --force option
35
- - more tests
36
- - pull
37
- - translations (Rod)
38
- - version checkings:
39
- - wagon when running it
40
- - engine when pushing a site
41
- - nice error page (replace the default exception middleware) to display:
42
- - liquid errors
43
- - other exceptions
44
- - nice logs
45
-
46
- - tests (Rod/Did)
47
-
48
- - refactoring:
49
- x generators/sites -> generators/site
50
- x list is only for site generators
51
- x move the call to the CC generator directly in the wagon.rb file
52
-
53
- *** FEATURES ***
54
-
55
- - toolbar to:
56
- - push a whole site / page(s) / snippet(s) / ....
57
- - create / update a content type