lanes 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/Gemfile +2 -3
  4. data/client/lanes/boot.jsx +1 -1
  5. data/client/lanes/index.js +0 -11
  6. data/client/lanes/jest/matchers.js +14 -0
  7. data/{lib/js/jest/mocks.js → client/lanes/jest/mocks/fetch.js} +1 -1
  8. data/client/lanes/models/base.js +0 -32
  9. data/client/lanes/screens/definition.js +7 -8
  10. data/client/lanes/screens/index.js +24 -240
  11. data/client/lanes/workspace/menu.jsx +3 -34
  12. data/client/lanes/workspace/screen.jsx +3 -3
  13. data/config/routes.rb +2 -0
  14. data/config/screens.rb +2 -2
  15. data/lanes.gemspec +10 -7
  16. data/lib/lanes/access/authentication_provider.rb +4 -4
  17. data/lib/lanes/api.rb +1 -0
  18. data/lib/lanes/api/default_routes.rb +1 -1
  19. data/lib/lanes/api/handlers/screens.rb +26 -0
  20. data/lib/lanes/api/helper_methods.rb +5 -4
  21. data/lib/lanes/cli.rb +7 -0
  22. data/lib/lanes/command/app.rb +4 -6
  23. data/lib/lanes/command/client_config.rb +59 -0
  24. data/lib/lanes/command/generate_model.rb +4 -4
  25. data/lib/lanes/command/jest.rb +14 -29
  26. data/lib/lanes/command/model_attribute.rb +6 -1
  27. data/lib/lanes/command/named_command.rb +1 -0
  28. data/lib/lanes/command/puma.rb +56 -0
  29. data/lib/lanes/command/server.rb +21 -18
  30. data/lib/lanes/command/webpack.rb +54 -0
  31. data/lib/lanes/extension.rb +0 -7
  32. data/lib/lanes/guard_tasks.rb +21 -20
  33. data/lib/lanes/rake_tasks.rb +13 -0
  34. data/lib/lanes/reloadable_sinatra.rb +24 -0
  35. data/lib/lanes/screen.rb +15 -6
  36. data/lib/lanes/spec_helper.rb +70 -136
  37. data/lib/lanes/version.rb +1 -1
  38. data/package.json +1 -1
  39. data/spec/server/api/controller_base_spec.rb +61 -53
  40. data/spec/server/spec_helper.rb +37 -45
  41. data/templates/client/models/model.js +17 -0
  42. data/templates/config/database.yml +2 -1
  43. data/templates/config/jest.config.json +14 -0
  44. data/templates/config/jest/babel-transform.js +47 -0
  45. data/templates/config/routes.rb +3 -2
  46. data/templates/config/webpack.config.js +1 -1
  47. data/templates/js/jest.config.json +2 -10
  48. data/templates/spec/client/models/model.spec.js +10 -0
  49. data/templates/spec/client/setup.js +9 -0
  50. data/templates/spec/server/spec_helper.rb +3 -11
  51. metadata +40 -41
  52. data/lib/js/jest.config.json +0 -14
  53. data/lib/js/jest/fileMock.js +0 -1
  54. data/lib/js/jest/setup.js +0 -26
  55. data/lib/js/jest/stubs/screen-definitions.js +0 -0
  56. data/lib/js/jest/styleMock.js +0 -1
  57. data/lib/js/webpack.config.js +0 -93
  58. data/lib/lanes/hot_reload_plugin.rb +0 -47
  59. data/lib/lanes/webpack.rb +0 -73
  60. data/spec/server/api/coffeescript_processor_spec.rb +0 -116
  61. data/templates/client/models/Model.coffee +0 -17
  62. data/templates/spec/client/models/ModelSpec.coffee +0 -5
@@ -1,73 +0,0 @@
1
- require 'forwardable'
2
- require 'fileutils'
3
- require 'pathname'
4
- require 'erb'
5
-
6
- module Lanes
7
-
8
- class Webpack
9
-
10
- TMP = Pathname.new(Dir.pwd).join('tmp')
11
- TEMPLATES = Pathname.new(__FILE__).dirname.join('..', '..', 'templates', 'js')
12
-
13
- extend Forwardable
14
- def_delegators :@process, :port, :environment, :stop, :alive?, :start, :wait
15
- attr_reader :process
16
-
17
- def initialize
18
- controller = Command.load_current_extension(raise_on_fail: true)
19
-
20
- config = WebpackDriver::Configuration.new(
21
- controller.root_path.join('config', 'webpack.config.js'),
22
- cmd_line_flags: ['--hot', '--inline'],
23
- logger: Lanes.logger,
24
- directory: controller.root_path
25
- )
26
-
27
- generated_asset_dir = write_asset_files
28
-
29
- config.environment.merge!(
30
- EXTENSION_ID: controller.identifier,
31
- LANES_MODULES: modules(controller, generated_asset_dir).join(':'),
32
- ENTRY: 'show-maker/index.js',
33
- GENERATED_CONFIG_DIR: generated_asset_dir.to_s
34
- )
35
- @process = ::WebpackDriver::DevServer.new(config)
36
- end
37
-
38
-
39
- def api_host
40
- Lanes.env.production? ?
41
- '' : "http://localhost:#{API::Root.settings.port}"
42
- end
43
-
44
- def modules(controller, generated_asset_dir)
45
- Extensions.asset_paths(controller, generated_asset_dir.to_s)
46
- end
47
-
48
- def write_asset_files
49
- dir = Pathname.new(Dir.mktmpdir)
50
- dir.join('lanes').mkpath
51
-
52
- screens = ERB.new(TEMPLATES.join('screens.js').read)
53
- root_view = ERB.new(TEMPLATES.join('root-view.html').read)
54
- dir
55
- .join('lanes', 'screen-definitions.js')
56
- .write(screens.result(binding))
57
- template = dir.join('root-view.tmpl.html')
58
- template.write(root_view.result(binding))
59
- # set the mtime to the past, otherwise Webpack will build repeatedly for a second
60
- FileUtils.touch template.to_s, :mtime => Time.now - 1.minute
61
- return dir
62
- end
63
-
64
- def assets
65
- process.assets.keys.select{|a| a=~/.js$/ }.reverse
66
- end
67
-
68
- def port
69
- process.port
70
- end
71
- end
72
-
73
- end
@@ -1,116 +0,0 @@
1
- require "lanes/spec_helper"
2
-
3
- class CoffeeScriptProcessor < Lanes::TestCase
4
-
5
- SCRIPT = <<-EOS
6
- class NS.Baz
7
- constructor: ->
8
- alert("foo")
9
- alert: (msg)->
10
- alert(msg);
11
-
12
- class NS.Bar extends NS.Baz
13
- squawk:->
14
- this.alert("Hello World!")
15
-
16
- class Foo extends Bar
17
- constructor: ->
18
- this.called=true
19
- super
20
- aMethod: ->
21
- @squawk("howdy!")
22
-
23
- EOS
24
-
25
- CLEANED=<<-EOS
26
- class NS.Baz
27
- constructor: ->
28
- alert("foo")
29
- alert: (msg)->
30
- alert(msg);
31
-
32
- class NS.Bar
33
- FILE: FILE
34
- constructor: -> super
35
- squawk:->
36
- this.alert("Hello World!")
37
-
38
- NS.Baz.extend(NS.Bar)
39
-
40
- class Foo
41
- FILE: FILE
42
- constructor: ->
43
- this.called=true
44
- super
45
- aMethod: ->
46
- @squawk("howdy!")
47
-
48
- Bar.extend(Foo)
49
-
50
- EOS
51
-
52
- JS=<<-EOS
53
- (function(Lanes,Foo,_,LC,React,BS,FILE,window,undefined){
54
- var Foo;
55
-
56
- NS.Baz = (function() {
57
- function Baz() {
58
- alert("foo");
59
- }
60
-
61
- Baz.prototype.alert = function(msg) {
62
- return alert(msg);
63
- };
64
-
65
- return Baz;
66
-
67
- })();
68
-
69
- NS.Bar = (function() {
70
- Bar.prototype.FILE = FILE;
71
-
72
- function Bar() {
73
- Bar.__super__.constructor.apply(this, arguments);
74
- }
75
-
76
- Bar.prototype.squawk = function() {
77
- return this.alert("Hello World!");
78
- };
79
-
80
- return Bar;
81
-
82
- })();
83
-
84
- NS.Baz.extend(NS.Bar);
85
-
86
- Foo = (function() {
87
- Foo.prototype.FILE = FILE;
88
-
89
- function Foo() {
90
- this.called = true;
91
- Foo.__super__.constructor.apply(this, arguments);
92
- }
93
-
94
- Foo.prototype.aMethod = function() {
95
- return this.squawk("howdy!");
96
- };
97
-
98
- return Foo;
99
-
100
- })();
101
-
102
- Bar.extend(Foo);
103
-
104
- })((window.Lanes = (window.Lanes || {})),(window.Lanes ? window.Lanes['Foo'] : null),(window.Lanes.Vendor = (window.Lanes.Vendor || {})).ld,window.Lanes.Components,window.Lanes.Vendor.React,window.Lanes.Vendor.ReactBootstrap,{namespace:window.Lanes['Foo'],extension:{name:'Foo',identifier:'foo'},path:[\"foo\",\"bar\",\"baz\"]},window);
105
- EOS
106
-
107
- Scope = Struct.new(:logical_path)
108
-
109
- def test_coffeescript_generation
110
- template = API::CoffeeScriptProcessor.new{ |t| SCRIPT }
111
- assert_equal CLEANED, template.cleaned
112
-
113
-
114
- assert_equal JS.chomp, template.render(Scope.new("foo/bar/baz"))
115
- end
116
- end
@@ -1,17 +0,0 @@
1
- class <%= namespace %>.Models.<%= class_name %> extends <%= namespace %>.Models.Base
2
-
3
- props:
4
- <% fields.each do |field| -%>
5
- <% if field.reference? -%>
6
- <%= sprintf("%-#{max_field_length}s",field.name+'_id') %>: "<%= field.client_type %>"
7
- <% else -%>
8
- <%= sprintf("%-#{max_field_length}s",field.name) %>: "<%= field.client_type %>"
9
- <% end -%>
10
- <% end %>
11
- <% if reference_fields.any? -%>
12
-
13
- associations:
14
- <% reference_fields.each do |field| -%>
15
- <%= sprintf("%-#{max_field_length}s ",field.name) %>: { <%= field.belongs_to? ? 'model' : 'collection' -%>: "<%= namespace %>.<%= field.name.camelize %>" }
16
- <% end -%>
17
- <% end -%>
@@ -1,5 +0,0 @@
1
- describe "<%= namespace %>.Models.<%= class_name %>", ->
2
-
3
- it "can be instantiated", ->
4
- model = new <%= namespace %>.Models.<%= class_name %>()
5
- expect(model).toEqual(jasmine.any(<%= namespace %>.Models.<%= class_name %>))