xing-root 0.0.4 → 0.0.5
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 +4 -4
- data/lib/xing/edicts/launch-browser.rb +1 -1
- data/lib/xing/edicts/structure-checker.rb +4 -19
- data/lib/xing/managers/child.rb +0 -11
- data/lib/xing/managers/tmux.rb +2 -2
- data/lib/xing/tasks/develop.rb +26 -23
- data/lib/xing/tasks/spec.rb +3 -3
- data/lib/xing/tasks/tasklib.rb +1 -1
- data/lib/xing/tasks.rb +0 -3
- data/lib/xing/utils/import_checker.rb +76 -0
- data/spec/utils/import_checker_spec.rb +120 -0
- metadata +6 -4
- /data/spec/{tasks → edicts}/structure_checker_spec.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ec46b808ae2a32a6d8349f4eced8e10202f6f64b
|
|
4
|
+
data.tar.gz: 30e0847a924137bbd017b09226b4456b49354b87
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 656cc7df65075d545847d99b134a66384122f3e000c1843a80a90a45d5acecb30eb70eb5939755a0863beef62b6eafc0b200446f73414a500692942e3bf57c20
|
|
7
|
+
data.tar.gz: 361b16409ea0c7ad4b7aaa40a8d65f7ae79fec931cdae2c939b444fcea5f8d4e7ecef78864610b972a2b9b30a607ea6a72eaae39e1a61c054b4da7d04e25df96
|
|
@@ -63,7 +63,7 @@ module Xing::Edicts
|
|
|
63
63
|
raise "Can't find any executable to launch a browser with."
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
run_command(
|
|
66
|
+
run_command(cmd(browser_command, "http://localhost:#{static_server_port}/")).must_succeed!
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def subprocess_action
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'xing-root'
|
|
2
2
|
require 'find'
|
|
3
3
|
require 'edict'
|
|
4
|
+
require 'xing/utils/import_checker'
|
|
4
5
|
|
|
5
6
|
module Xing::Edicts
|
|
6
7
|
class StructureChecker < Edict::Rule
|
|
@@ -74,25 +75,9 @@ module Xing::Edicts
|
|
|
74
75
|
end
|
|
75
76
|
|
|
76
77
|
def check_imports(path, context)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
problem "doesn't seem to have a 'from' clause...", import_line, lineno, path
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
if /\.\./ =~ md[:from]
|
|
84
|
-
if /\A\.\./ !~ md[:from]
|
|
85
|
-
problem "from includes .. not at pos 0", import_line, lineno, path
|
|
86
|
-
end
|
|
87
|
-
if /\w.*\.\./ =~ md[:from]
|
|
88
|
-
problem "from includes .. after words", import_line, lineno, path
|
|
89
|
-
end
|
|
90
|
-
if !(violation = %r{(?<dir>\w+)/\w}.match md[:from]).nil?
|
|
91
|
-
unless %r{\.\./(#{context.escape_clause_list.join("|")})} =~ md[:from]
|
|
92
|
-
problem "Imports Rule: 'from' includes ../ and then #{violation[:dir].inspect} not in #{context.escape_clause_list.inspect}", import_line, lineno, path
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
78
|
+
checker = Xing::Utils::ImportChecker.new(path, context)
|
|
79
|
+
checker.check do |message, line, lineno|
|
|
80
|
+
problem message, line, lineno, path
|
|
96
81
|
end
|
|
97
82
|
end
|
|
98
83
|
end
|
data/lib/xing/managers/child.rb
CHANGED
|
@@ -41,17 +41,6 @@ class ChildManager
|
|
|
41
41
|
return false
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
def wait_until_dead(pilimit)
|
|
45
|
-
start = Time.now
|
|
46
|
-
while Time.now - start < limit
|
|
47
|
-
Process.waitpid(-1, Process::WNOHANG | Process::WUNTRACED)
|
|
48
|
-
sleep(0.1)
|
|
49
|
-
end
|
|
50
|
-
return false
|
|
51
|
-
rescue SystemCallError # = no children
|
|
52
|
-
return true
|
|
53
|
-
end
|
|
54
|
-
|
|
55
44
|
def wait_all
|
|
56
45
|
Process.waitall
|
|
57
46
|
end
|
data/lib/xing/managers/tmux.rb
CHANGED
|
@@ -62,7 +62,7 @@ module Xing
|
|
|
62
62
|
|
|
63
63
|
def wait_all
|
|
64
64
|
path = File.expand_path(@extra_config_path)
|
|
65
|
-
if File.
|
|
65
|
+
if File.exist?(path)
|
|
66
66
|
puts "Loading #{path}"
|
|
67
67
|
tmux "source-file #{path}"
|
|
68
68
|
else
|
|
@@ -145,7 +145,7 @@ module Xing
|
|
|
145
145
|
end
|
|
146
146
|
end
|
|
147
147
|
|
|
148
|
-
def open_additional_window(
|
|
148
|
+
def open_additional_window(_name, task)
|
|
149
149
|
tmux "select-layout -t '#@window_name' #{layout}"
|
|
150
150
|
@window_count = @window_count + 1
|
|
151
151
|
@window_name = "Dev Servers #{@window_count}"
|
data/lib/xing/tasks/develop.rb
CHANGED
|
@@ -19,33 +19,36 @@ module Xing
|
|
|
19
19
|
setting :manager
|
|
20
20
|
setting :config_dir, "../frontend"
|
|
21
21
|
|
|
22
|
-
def
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
ENV['PORT_OFFSET'].to_i.tap do |offset|
|
|
27
|
-
puts "Shifting server ports by #{offset}"
|
|
28
|
-
end
|
|
29
|
-
else
|
|
30
|
-
0
|
|
31
|
-
end
|
|
22
|
+
def get_port_offset
|
|
23
|
+
if !ENV['PORT_OFFSET'].nil?
|
|
24
|
+
ENV['PORT_OFFSET'].to_i.tap do |offset|
|
|
25
|
+
puts "Shifting server ports by #{offset}"
|
|
32
26
|
end
|
|
27
|
+
else
|
|
28
|
+
0
|
|
29
|
+
end
|
|
30
|
+
end
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
end
|
|
32
|
+
def choose_output_manager
|
|
33
|
+
begin
|
|
34
|
+
require 'xing/managers/child'
|
|
35
|
+
require 'xing/managers/tmux'
|
|
36
|
+
if Managers::Tmux.available?
|
|
37
|
+
Managers::TmuxPane.new
|
|
38
|
+
else
|
|
39
|
+
ChildManager.new.tap do |mngr|
|
|
40
|
+
at_exit{ mngr.kill_all }
|
|
44
41
|
end
|
|
45
|
-
end.tap do |mgr|
|
|
46
|
-
puts "Using #{mgr.class.name}"
|
|
47
42
|
end
|
|
48
|
-
|
|
43
|
+
end.tap do |mgr|
|
|
44
|
+
puts "Using #{mgr.class.name}"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def default_configuration
|
|
49
|
+
@port_offset ||= get_port_offset
|
|
50
|
+
@manager ||= choose_output_manager
|
|
51
|
+
super
|
|
49
52
|
end
|
|
50
53
|
|
|
51
54
|
def resolve_configuration
|
data/lib/xing/tasks/spec.rb
CHANGED
|
@@ -34,7 +34,7 @@ module Xing
|
|
|
34
34
|
eddie.dir = "backend"
|
|
35
35
|
eddie.shell_cmd = %w{bundle exec rspec}
|
|
36
36
|
end
|
|
37
|
-
task :full, [:spec_files] => [:check_dependencies, 'frontend:code_structure', :grunt_ci_test, 'backend:setup', :prepare_db] do |
|
|
37
|
+
task :full, [:spec_files] => [:check_dependencies, 'frontend:code_structure', :grunt_ci_test, 'backend:setup', :prepare_db] do |_task, args|
|
|
38
38
|
if args[:spec_files]
|
|
39
39
|
full_spec_edict.shell_cmd.push(args[:spec_files])
|
|
40
40
|
end
|
|
@@ -46,7 +46,7 @@ module Xing
|
|
|
46
46
|
copy_settings_to(eddie)
|
|
47
47
|
eddie.dir = "backend"
|
|
48
48
|
end
|
|
49
|
-
task :responsivity, [:spec_files] => ['backend:setup', :prepare_db] do |
|
|
49
|
+
task :responsivity, [:spec_files] => ['backend:setup', :prepare_db] do |_task, args|
|
|
50
50
|
%w{mobile small medium desktop}.each do |size|
|
|
51
51
|
responsivity_edict.shell_cmd = ["bundle", "exec", "rspec", "-o", "tmp/rspec_#{size}.txt"]
|
|
52
52
|
responsivity_edict.env_hash = {'BROWSER_SIZE' => size}
|
|
@@ -64,7 +64,7 @@ module Xing
|
|
|
64
64
|
eddie.dir = "backend"
|
|
65
65
|
eddie.shell_cmd = %w{bundle exec rspec}
|
|
66
66
|
end
|
|
67
|
-
task :fast, [:spec_files] => ['backend:setup', :prepare_db] do |
|
|
67
|
+
task :fast, [:spec_files] => ['backend:setup', :prepare_db] do |_task, args|
|
|
68
68
|
if args[:spec_files]
|
|
69
69
|
fast_edict.shell_cmd.push(args[:spec_files])
|
|
70
70
|
else
|
data/lib/xing/tasks/tasklib.rb
CHANGED
data/lib/xing/tasks.rb
CHANGED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module Xing::Utils
|
|
2
|
+
class ImportChecker
|
|
3
|
+
|
|
4
|
+
def initialize(path, context)
|
|
5
|
+
@path = path
|
|
6
|
+
@context = context
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
attr_reader :path, :context
|
|
10
|
+
|
|
11
|
+
def read_next
|
|
12
|
+
@import_line = @lines[@lineno]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def is_import_line
|
|
16
|
+
/\s*import/.match(@import_line)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def skip_to_end_of_import
|
|
20
|
+
# for a multi-line import, we need to skip past multiple lines of import
|
|
21
|
+
begin_check = /.*(?<begin>\{).*/.match(@import_line)
|
|
22
|
+
end_check = /.*(?<end>\}).*/.match(@import_line)
|
|
23
|
+
if begin_check and !end_check
|
|
24
|
+
until end_check
|
|
25
|
+
@lineno += 1
|
|
26
|
+
read_next
|
|
27
|
+
end_check = /.*(?<end>\}).*/.match(@import_line)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def match_line
|
|
33
|
+
@md = /.*from (?<quote>['"])(?<from>.*)\k<quote>/.match(@import_line)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def check_empty_match
|
|
37
|
+
problem "doesn't seem to have a 'from' clause..." if @md.nil?
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def check_structure
|
|
41
|
+
if /\.\./ =~ @md[:from]
|
|
42
|
+
problem "from includes .. not at pos 0" if /\A\.\./ !~ @md[:from]
|
|
43
|
+
problem "from includes .. after words" if /\w.*\.\./ =~ @md[:from]
|
|
44
|
+
unless (violation = %r{(?<dir>\w+)/\w}.match @md[:from]).nil?
|
|
45
|
+
unless %r{\.\./(#{context.escape_clause_list.join("|")})} =~ @md[:from]
|
|
46
|
+
problem "Imports Rule: 'from' includes ../ and then #{violation[:dir].inspect} not in #{context.escape_clause_list.inspect}"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def problem(message)
|
|
53
|
+
@error_block.call(message, @import_line, @lineno)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def initialize_check(error_block)
|
|
57
|
+
@error_block = error_block
|
|
58
|
+
@lines = File.read(path).lines
|
|
59
|
+
@lineno = 0
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def check(&error_block)
|
|
63
|
+
initialize_check(error_block)
|
|
64
|
+
while @lineno < @lines.length
|
|
65
|
+
read_next
|
|
66
|
+
if is_import_line
|
|
67
|
+
skip_to_end_of_import
|
|
68
|
+
match_line
|
|
69
|
+
check_empty_match
|
|
70
|
+
check_structure
|
|
71
|
+
end
|
|
72
|
+
@lineno += 1
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
require 'xing/utils/import_checker'
|
|
2
|
+
require 'support/file-sandbox'
|
|
3
|
+
require 'stringio'
|
|
4
|
+
|
|
5
|
+
describe Xing::Utils::ImportChecker do
|
|
6
|
+
include FileSandbox
|
|
7
|
+
|
|
8
|
+
let :stdout do
|
|
9
|
+
StringIO.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
let :errors do
|
|
13
|
+
[]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
let :context do
|
|
17
|
+
double("context", :escape_clause_list => ['common', 'framework'])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
subject :checker do
|
|
21
|
+
Xing::Utils::ImportChecker.new("test-dir/problem.js", context)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe "with a problem file" do
|
|
25
|
+
|
|
26
|
+
before :each do
|
|
27
|
+
@sandbox.new :file => "test-dir/problem.js", :with_content => "import Thing from '../../../somewhere/bad.js';"
|
|
28
|
+
checker.check do |message, import_line, lineno|
|
|
29
|
+
errors << [message, import_line, lineno]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should report errors" do
|
|
34
|
+
expect(errors).to_not be_empty
|
|
35
|
+
expect(errors[0][0]).to match(%r{'from' includes ../})
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe "with a good file" do
|
|
40
|
+
before :each do
|
|
41
|
+
@sandbox.new :file => "test-dir/problem.js", :with_content => "import Thing from 'somewhere/okay.js';"
|
|
42
|
+
checker.check do |message, import_line, lineno|
|
|
43
|
+
errors << [message, import_line, lineno]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should not report errors" do
|
|
48
|
+
expect(errors).to be_empty
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe "single line with brackets" do
|
|
53
|
+
describe "with a problem file" do
|
|
54
|
+
|
|
55
|
+
before :each do
|
|
56
|
+
@sandbox.new :file => "test-dir/problem.js", :with_content => "import { Thing } from '../../../somewhere/bad.js';"
|
|
57
|
+
checker.check do |message, import_line, lineno|
|
|
58
|
+
errors << [message, import_line, lineno]
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should report errors" do
|
|
63
|
+
expect(errors).to_not be_empty
|
|
64
|
+
expect(errors[0][0]).to match(%r{'from' includes ../})
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe "with a good file" do
|
|
69
|
+
before :each do
|
|
70
|
+
@sandbox.new :file => "test-dir/problem.js", :with_content => "import { Thing } from 'somewhere/okay.js';"
|
|
71
|
+
checker.check do |message, import_line, lineno|
|
|
72
|
+
errors << [message, import_line, lineno]
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "should not report errors" do
|
|
77
|
+
expect(errors).to be_empty
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
describe "multi-line import" do
|
|
83
|
+
describe "with a problem file" do
|
|
84
|
+
before :each do
|
|
85
|
+
@sandbox.new :file => "test-dir/problem.js", :with_content => <<-eos
|
|
86
|
+
import {
|
|
87
|
+
Thing,
|
|
88
|
+
OtherThing
|
|
89
|
+
} from '../../../somewhere/bad.js';"
|
|
90
|
+
eos
|
|
91
|
+
checker.check do |message, import_line, lineno|
|
|
92
|
+
errors << [message, import_line, lineno]
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "should report errors" do
|
|
97
|
+
expect(errors).to_not be_empty
|
|
98
|
+
expect(errors[0][0]).to match(%r{'from' includes ../})
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
describe "with a good file" do
|
|
103
|
+
before :each do
|
|
104
|
+
@sandbox.new :file => "test-dir/problem.js", :with_content => <<-eos
|
|
105
|
+
import {
|
|
106
|
+
Thing,
|
|
107
|
+
OtherThing
|
|
108
|
+
} from 'somewhere/okay.js';"
|
|
109
|
+
eos
|
|
110
|
+
checker.check do |message, import_line, lineno|
|
|
111
|
+
errors << [message, import_line, lineno]
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it "should not report errors" do
|
|
116
|
+
expect(errors).to be_empty
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: xing-root
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Judson Lester
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2015-
|
|
12
|
+
date: 2015-12-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: edict
|
|
@@ -78,15 +78,17 @@ files:
|
|
|
78
78
|
- lib/xing/tasks/frontend.rb
|
|
79
79
|
- lib/xing/tasks/spec.rb
|
|
80
80
|
- lib/xing/tasks/tasklib.rb
|
|
81
|
+
- lib/xing/utils/import_checker.rb
|
|
81
82
|
- spec/edicts/clean_rake_spec.rb
|
|
82
83
|
- spec/edicts/clean_run_spec.rb
|
|
83
84
|
- spec/edicts/launch-browser_spec.rb
|
|
84
85
|
- spec/edicts/start-child_spec.rb
|
|
86
|
+
- spec/edicts/structure_checker_spec.rb
|
|
85
87
|
- spec/managers/tmux_spec.rb
|
|
86
88
|
- spec/support/file-sandbox.rb
|
|
87
89
|
- spec/tasks/develop_spec.rb
|
|
88
90
|
- spec/tasks/frontend_spec.rb
|
|
89
|
-
- spec/
|
|
91
|
+
- spec/utils/import_checker_spec.rb
|
|
90
92
|
homepage: ''
|
|
91
93
|
licenses:
|
|
92
94
|
- MIT
|
|
@@ -97,7 +99,7 @@ rdoc_options:
|
|
|
97
99
|
- "--main"
|
|
98
100
|
- doc/README
|
|
99
101
|
- "--title"
|
|
100
|
-
- xing-root-0.0.
|
|
102
|
+
- xing-root-0.0.5 Documentation
|
|
101
103
|
require_paths:
|
|
102
104
|
- lib/
|
|
103
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
File without changes
|