puman 0.1.1 → 0.2.0
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 +5 -5
- data/README.md +10 -31
- data/lib/puman/app.rb +15 -5
- data/lib/puman/cli.rb +38 -8
- data/lib/puman/version.rb +1 -1
- data/puman.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5fb458fa1cb7c90b98c9edc679f13a9f3107562e9586056b868ad367ed46d1c4
|
4
|
+
data.tar.gz: adeed9435d312803c54b69d1f3f5d4d41f7389f4e4197cb77ae2c2f62bc1aa25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54f564df2cdf84c78e271adcc309dc5a939801b0d6fa34ce547a51135f27e365c3985e4b691a41ccdd7799e26c8f04c7b75e150e3ca16e1741fa6b5aff2924e6
|
7
|
+
data.tar.gz: 5628e1e2c782d8d7d21425cf2f01018442cc36643aae384e32ec118ae0d8217dd8414d8337ddf8af8aaa8d0fc22302faa627e3d95dddb496c19144950e830de4
|
data/README.md
CHANGED
@@ -1,41 +1,20 @@
|
|
1
1
|
# Puman
|
2
2
|
|
3
|
-
|
3
|
+
You can forget puma-dev proxy port numbers for your Rails apps!
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'puman'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install puman
|
5
|
+
`Puman` only supports macOS for now.
|
22
6
|
|
23
7
|
## Usage
|
24
8
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/puman.
|
36
|
-
|
9
|
+
```
|
10
|
+
Commands:
|
11
|
+
puman help [COMMAND] # Describe available commands or one specific com...
|
12
|
+
puman list # list all apps linked with puma-dev
|
13
|
+
puman server # run rails server
|
14
|
+
puman symlink DIR # create symlink into puma-dev directory.
|
15
|
+
puman version # version
|
16
|
+
```
|
37
17
|
|
38
18
|
## License
|
39
19
|
|
40
20
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
-
|
data/lib/puman/app.rb
CHANGED
@@ -47,11 +47,17 @@ module Puman
|
|
47
47
|
def server_command
|
48
48
|
name = File.basename(git_dir_or_current_dir)
|
49
49
|
apps = @proxy_apps.select{|app| app.name == name}
|
50
|
-
if apps.size
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
if apps.size == 1 && (app = apps.first).host_port.match(/^\d+$/)
|
51
|
+
"WEBPACKER_DEV_SERVER_PORT=#{devserver_port(app)} WEBPACKER_DEV_SERVER_PUBLIC=localhost:#{devserver_port(app)} bundle exec rails server -p #{app.host_port}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def webpack_dev_server_command
|
56
|
+
name = File.basename(git_dir_or_current_dir)
|
57
|
+
apps = @proxy_apps.select{|app| app.name == name}
|
58
|
+
if apps.size == 1 && File.exists?(File.join(Dir.pwd, 'bin/webpack-dev-server'))
|
59
|
+
app = apps.first
|
60
|
+
"WEBPACKER_DEV_SERVER_PORT=#{devserver_port(app)} WEBPACKER_DEV_SERVER_PUBLIC=localhost:#{devserver_port(app)} ./bin/webpack-dev-server"
|
55
61
|
end
|
56
62
|
end
|
57
63
|
|
@@ -61,6 +67,10 @@ module Puman
|
|
61
67
|
|
62
68
|
private
|
63
69
|
|
70
|
+
def devserver_port(app)
|
71
|
+
(app.host_port.to_i + 10000).to_s
|
72
|
+
end
|
73
|
+
|
64
74
|
def root_directory?(path)
|
65
75
|
File.directory?(path) && File.expand_path(path) == File.expand_path(File.join(path, '..'))
|
66
76
|
end
|
data/lib/puman/cli.rb
CHANGED
@@ -23,21 +23,51 @@ module Puman
|
|
23
23
|
|
24
24
|
desc "server", "run rails server"
|
25
25
|
def server
|
26
|
-
|
26
|
+
server_command = @app_list.server_command
|
27
|
+
webpack_dev_server_command = @app_list.webpack_dev_server_command
|
28
|
+
|
29
|
+
if server_command.nil?
|
30
|
+
puts 'no or multiple apps are defind.'
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
|
34
|
+
if webpack_dev_server_command
|
35
|
+
spawn webpack_dev_server_command
|
36
|
+
end
|
37
|
+
exec server_command
|
38
|
+
rescue
|
27
39
|
end
|
28
40
|
|
29
|
-
desc "symlink DIR_PATH", "create symlink
|
41
|
+
desc "symlink DIR_PATH", "create symlink in puma-dev directory."
|
30
42
|
def symlink(dir)
|
31
|
-
|
32
|
-
|
43
|
+
target_dir, basename = target_directory(dir)
|
44
|
+
if @app_list.include?(basename)
|
45
|
+
puts 'already exists.'
|
46
|
+
elnse
|
47
|
+
FileUtils::ln_s(target_dir, File.join(PUMA_DEV_DIR, basename))
|
48
|
+
puts 'symlink created.'
|
49
|
+
end
|
50
|
+
end
|
33
51
|
|
34
|
-
|
35
|
-
|
52
|
+
desc "proxy DIR_PATH", "create proxy file in puma-dev directory."
|
53
|
+
def proxy(dir)
|
54
|
+
target_dir = target_directory(dir)
|
55
|
+
if @app_list.include?(target_dir)
|
36
56
|
puts 'already exists.'
|
37
57
|
else
|
38
|
-
|
39
|
-
|
58
|
+
puts 'proxy option has not been implemented yet.'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def target_directory(arg_dir)
|
65
|
+
file = File.expand_path(arg_dir)
|
66
|
+
unless File.exists?(file)
|
67
|
+
puts 'invalid argument.'
|
68
|
+
exit 1
|
40
69
|
end
|
70
|
+
[file, File.basename(file)]
|
41
71
|
end
|
42
72
|
end
|
43
73
|
end
|
data/lib/puman/version.rb
CHANGED
data/puman.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_development_dependency "bundler", "~> 1
|
23
|
+
spec.add_development_dependency "bundler", "~> 2.0.1"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
25
|
spec.add_development_dependency "rspec", "~> 3.0"
|
26
26
|
spec.add_development_dependency "fakefs"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pi-chan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.1
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.0.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
139
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.
|
140
|
+
rubygems_version: 2.7.6.2
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: CLI utility for puma-dev.
|