gorails 0.1.0 → 0.1.3
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/CHANGELOG.md +14 -1
- data/Gemfile +3 -1
- data/Gemfile.lock +65 -0
- data/README.md +41 -12
- data/bin/update-deps +95 -0
- data/exe/gorails +18 -0
- data/gorails.gemspec +4 -3
- data/lib/gorails/commands/episodes.rb +25 -0
- data/lib/gorails/commands/example.rb +19 -0
- data/lib/gorails/commands/help.rb +21 -0
- data/lib/gorails/commands/jobs.rb +25 -0
- data/lib/gorails/commands/jumpstart.rb +29 -0
- data/lib/gorails/commands/railsbytes.rb +67 -0
- data/lib/gorails/commands.rb +19 -0
- data/lib/gorails/entry_point.rb +10 -0
- data/lib/gorails/version.rb +1 -1
- data/lib/gorails.rb +22 -1
- data/vendor/deps/cli-kit/REVISION +1 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args/definition.rb +301 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args/evaluation.rb +237 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args/parser/node.rb +131 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args/parser.rb +128 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args/tokenizer.rb +132 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args.rb +15 -0
- data/vendor/deps/cli-kit/lib/cli/kit/base_command.rb +29 -0
- data/vendor/deps/cli-kit/lib/cli/kit/command_help.rb +256 -0
- data/vendor/deps/cli-kit/lib/cli/kit/command_registry.rb +141 -0
- data/vendor/deps/cli-kit/lib/cli/kit/config.rb +137 -0
- data/vendor/deps/cli-kit/lib/cli/kit/core_ext.rb +30 -0
- data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +165 -0
- data/vendor/deps/cli-kit/lib/cli/kit/executor.rb +99 -0
- data/vendor/deps/cli-kit/lib/cli/kit/ini.rb +94 -0
- data/vendor/deps/cli-kit/lib/cli/kit/levenshtein.rb +89 -0
- data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +95 -0
- data/vendor/deps/cli-kit/lib/cli/kit/opts.rb +284 -0
- data/vendor/deps/cli-kit/lib/cli/kit/resolver.rb +67 -0
- data/vendor/deps/cli-kit/lib/cli/kit/sorbet_runtime_stub.rb +142 -0
- data/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +253 -0
- data/vendor/deps/cli-kit/lib/cli/kit/support.rb +10 -0
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +350 -0
- data/vendor/deps/cli-kit/lib/cli/kit/util.rb +133 -0
- data/vendor/deps/cli-kit/lib/cli/kit/version.rb +7 -0
- data/vendor/deps/cli-kit/lib/cli/kit.rb +151 -0
- data/vendor/deps/cli-ui/REVISION +1 -0
- data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +180 -0
- data/vendor/deps/cli-ui/lib/cli/ui/color.rb +98 -0
- data/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +216 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +116 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +176 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +149 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +112 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +300 -0
- data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +92 -0
- data/vendor/deps/cli-ui/lib/cli/ui/os.rb +58 -0
- data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +72 -0
- data/vendor/deps/cli-ui/lib/cli/ui/progress.rb +102 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +534 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +36 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +354 -0
- data/vendor/deps/cli-ui/lib/cli/ui/sorbet_runtime_stub.rb +143 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/async.rb +46 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +292 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +82 -0
- data/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +264 -0
- data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +53 -0
- data/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +107 -0
- data/vendor/deps/cli-ui/lib/cli/ui/version.rb +6 -0
- data/vendor/deps/cli-ui/lib/cli/ui/widgets/base.rb +37 -0
- data/vendor/deps/cli-ui/lib/cli/ui/widgets/status.rb +75 -0
- data/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +91 -0
- data/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +63 -0
- data/vendor/deps/cli-ui/lib/cli/ui.rb +356 -0
- metadata +114 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e70b979a5284596091b39be5e2372914fc9712839b6e1d5a666bc7ac142e61a2
|
4
|
+
data.tar.gz: 838162e13a911e26c5654778513229b1411441d968f593bf467168b57d24b985
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b108dc53a37aa0bed0faae758d157c742de83e9f6b30258c42dc36e0a1b1440f9112bde7d5db71bc1ddeb23b7995151b82309eb5e921e05004e8c0cde1e180f
|
7
|
+
data.tar.gz: 585422f5c6221e3d3fb23c0aa7a460dc2725e702cfe58ded81566b21b94432087312cd4a29f20b8d58a02f7c5c94984eb79e0ee247c1a70b490c2776499b6bbd
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
-
## [0.1.
|
3
|
+
## [0.1.3] - 2022-03-13
|
4
|
+
|
5
|
+
- Vendor cli-kit and cli-ui for speed
|
6
|
+
This also skips loading bundler/setup which looks for a Gemfile
|
7
|
+
|
8
|
+
## [0.1.2] - 2022-03-13
|
9
|
+
|
10
|
+
- Add ability to view and apply individual Railsbytes
|
11
|
+
|
12
|
+
## [0.1.1] - 2022-03-13
|
4
13
|
|
5
14
|
- Initial release
|
15
|
+
|
16
|
+
## [0.1.0] - 2021-12-16
|
17
|
+
|
18
|
+
- Empty release
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gorails (0.1.3)
|
5
|
+
cli-kit (~> 4.0.0)
|
6
|
+
cli-ui (~> 1.5.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ansi (1.5.0)
|
12
|
+
ast (2.4.2)
|
13
|
+
builder (3.2.4)
|
14
|
+
cli-kit (4.0.0)
|
15
|
+
cli-ui (>= 1.1.4)
|
16
|
+
cli-ui (1.5.1)
|
17
|
+
metaclass (0.0.4)
|
18
|
+
minitest (5.15.0)
|
19
|
+
minitest-reporters (1.5.0)
|
20
|
+
ansi
|
21
|
+
builder
|
22
|
+
minitest (>= 5.0)
|
23
|
+
ruby-progressbar
|
24
|
+
mocha (1.5.0)
|
25
|
+
metaclass (~> 0.0.1)
|
26
|
+
parallel (1.21.0)
|
27
|
+
parser (3.1.1.0)
|
28
|
+
ast (~> 2.4.1)
|
29
|
+
rainbow (3.1.1)
|
30
|
+
rake (13.0.6)
|
31
|
+
regexp_parser (2.2.1)
|
32
|
+
rexml (3.2.5)
|
33
|
+
rubocop (1.25.1)
|
34
|
+
parallel (~> 1.10)
|
35
|
+
parser (>= 3.1.0.0)
|
36
|
+
rainbow (>= 2.2.2, < 4.0)
|
37
|
+
regexp_parser (>= 1.8, < 3.0)
|
38
|
+
rexml
|
39
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
40
|
+
ruby-progressbar (~> 1.7)
|
41
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
42
|
+
rubocop-ast (1.16.0)
|
43
|
+
parser (>= 3.1.1.0)
|
44
|
+
rubocop-performance (1.13.3)
|
45
|
+
rubocop (>= 1.7.0, < 2.0)
|
46
|
+
rubocop-ast (>= 0.4.0)
|
47
|
+
ruby-progressbar (1.11.0)
|
48
|
+
standard (1.7.3)
|
49
|
+
rubocop (= 1.25.1)
|
50
|
+
rubocop-performance (= 1.13.3)
|
51
|
+
unicode-display_width (2.1.0)
|
52
|
+
|
53
|
+
PLATFORMS
|
54
|
+
arm64-darwin-21
|
55
|
+
|
56
|
+
DEPENDENCIES
|
57
|
+
gorails!
|
58
|
+
minitest (>= 5.0.0)
|
59
|
+
minitest-reporters
|
60
|
+
mocha (~> 1.5.0)
|
61
|
+
rake (~> 13.0)
|
62
|
+
standard
|
63
|
+
|
64
|
+
BUNDLED WITH
|
65
|
+
2.3.8
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# GoRails CLI
|
2
2
|
|
3
|
-
|
3
|
+
[](https://badge.fury.io/rb/gorails)
|
4
4
|
|
5
|
-
|
5
|
+
An interactive CLI for [GoRails](https://gorails.com), [Railsbytes](https://railsbytes.com), [Jumpstart](https://github.com/excid3/jumpstart), [Ruby on Rails jobs](https://jobs.gorails.com), and more.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -12,27 +12,56 @@ Add this line to your application's Gemfile:
|
|
12
12
|
gem 'gorails'
|
13
13
|
```
|
14
14
|
|
15
|
-
And then
|
15
|
+
And then run
|
16
16
|
|
17
|
-
|
17
|
+
```bash
|
18
|
+
gorails
|
19
|
+
```
|
20
|
+
|
21
|
+
## Usage
|
18
22
|
|
19
|
-
|
23
|
+
#### GoRails episodes
|
20
24
|
|
21
|
-
|
25
|
+
To see a list of the recent GoRails screencasts, you can run:
|
22
26
|
|
23
|
-
|
27
|
+
```sh
|
28
|
+
gorails episodes
|
29
|
+
```
|
30
|
+
|
31
|
+
#### Ruby on Rails Jobs
|
32
|
+
|
33
|
+
To see a list of Ruby on Rails job posts, you can run:
|
34
|
+
|
35
|
+
```sh
|
36
|
+
gorails jobs
|
37
|
+
```
|
38
|
+
|
39
|
+
#### Railsbytes
|
40
|
+
|
41
|
+
To see a list of Railsbytes.com templates, you can run:
|
42
|
+
|
43
|
+
```sh
|
44
|
+
gorails railsbytes
|
45
|
+
gorails railsbytes x7msKX
|
46
|
+
```
|
47
|
+
|
48
|
+
#### Jumpstart
|
24
49
|
|
25
|
-
|
50
|
+
To create a Ruby on Rails app using the [Jumpstart template](https://github.com/excid3/jumpstart), you can run:
|
51
|
+
|
52
|
+
```sh
|
53
|
+
gorails jumpstart myapp
|
54
|
+
```
|
26
55
|
|
27
56
|
## Development
|
28
57
|
|
29
|
-
After checking out the repo, run `
|
58
|
+
After checking out the repo, run `bundle` to install dependencies. Then, run `rake test` to run the tests. You can also run `exe/gorails` to test the gem.
|
30
59
|
|
31
60
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
61
|
|
33
62
|
## Contributing
|
34
63
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
64
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/excid3/gorails-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/excid3/gorails-ruby/blob/master/CODE_OF_CONDUCT.md).
|
36
65
|
|
37
66
|
## License
|
38
67
|
|
@@ -40,4 +69,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
40
69
|
|
41
70
|
## Code of Conduct
|
42
71
|
|
43
|
-
Everyone interacting in the
|
72
|
+
Everyone interacting in the GoRails project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/excid3/gorails-ruby/blob/master/CODE_OF_CONDUCT.md).
|
data/bin/update-deps
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.expand_path("../../vendor/deps/cli-ui/lib", __FILE__))
|
4
|
+
require 'open3'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
def fmt(tag, msg)
|
8
|
+
# Not really CLI::UI.fmt compatible: no nesting support, for example.
|
9
|
+
# While we could pull in CLI::UI here, it makes it more difficult to
|
10
|
+
# bootstrap a new project and to fix a broken vendor.
|
11
|
+
fmt_msg = msg
|
12
|
+
.gsub(/{{yellow:(.*?)}}/, "\x1b[33m\\1\x1b[31m")
|
13
|
+
.gsub(/{{green:(.*?)}}/, "\x1b[32m\\1\x1b[31m")
|
14
|
+
.gsub(/{{blue:(.*?)}}/, "\x1b[34m\\1\x1b[31m")
|
15
|
+
.gsub(/{{bold_blue:(.*?)}}/, "\x1b[1;34m\\1\x1b[0;31m")
|
16
|
+
.gsub(/{{bold_green:(.*?)}}/, "\x1b[1;32m\\1\x1b[0;31m")
|
17
|
+
"\x1b[1;31m[#{tag}] \x1b[0;31m#{fmt_msg}\x1b[0m"
|
18
|
+
end
|
19
|
+
|
20
|
+
def bail(msg)
|
21
|
+
STDERR.puts(fmt("ERROR", msg))
|
22
|
+
exit 1
|
23
|
+
end
|
24
|
+
|
25
|
+
def warn(msg)
|
26
|
+
STDERR.puts(fmt("WARNING", msg))
|
27
|
+
end
|
28
|
+
|
29
|
+
def source_path
|
30
|
+
File.expand_path(ENV.fetch('SOURCE_ROOT', File.expand_path('../../..', __FILE__)))
|
31
|
+
end
|
32
|
+
|
33
|
+
deps = %w(cli-ui cli-kit)
|
34
|
+
|
35
|
+
deps.each do |dep|
|
36
|
+
path = File.expand_path(dep, source_path)
|
37
|
+
|
38
|
+
unless Dir.exist?(path)
|
39
|
+
bail(
|
40
|
+
"dependency is not checked out: {{yellow:#{dep}}}.\n" \
|
41
|
+
" This repo {{bold_blue:(github.com/shopify/#{dep})}} must be cloned at {{bold_blue:#{path}}} for this script to succeed.\n" \
|
42
|
+
" Currently, SOURCE_ROOT is set to {{bold_blue:#{source_path}}}.\n" \
|
43
|
+
" Alternatively, you can set {{bold_blue:SOURCE_ROOT}} to a directory containing {{yellow:#{dep}}}.\n" \
|
44
|
+
" {{bold_blue:SOURCE_ROOT}} defaults to {{bold_blue:../}}."
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
head_sha = nil
|
49
|
+
dirty = false
|
50
|
+
|
51
|
+
Dir.chdir(path) do
|
52
|
+
_, _, stat = Open3.capture3('git fetch origin main')
|
53
|
+
bail("couldn't git fetch in dependency: {{yellow:#{dep}}}") unless stat.success?
|
54
|
+
|
55
|
+
head_sha, stat = Open3.capture2('git rev-parse HEAD')
|
56
|
+
bail("couldn't determine HEAD: {{yellow:#{dep}}}") unless stat.success?
|
57
|
+
head_sha.chomp!
|
58
|
+
|
59
|
+
fetch_head_sha, stat = Open3.capture2('git rev-parse FETCH_HEAD')
|
60
|
+
bail("couldn't determine FETCH_HEAD: {{yellow:#{dep}}}") unless stat.success?
|
61
|
+
fetch_head_sha.chomp!
|
62
|
+
|
63
|
+
git_status, stat = Open3.capture2('git status --porcelain')
|
64
|
+
bail("couldn't determine git status: {{yellow:#{dep}}}") unless stat.success?
|
65
|
+
|
66
|
+
if head_sha != fetch_head_sha
|
67
|
+
warn(
|
68
|
+
"Copying files from {{yellow:#{path}}} to satisfy dependency {{yellow:#{dep}}}.\n" \
|
69
|
+
" However, the repo at {{yellow:#{path}}} isn't up to date.\n" \
|
70
|
+
" The checked-out revision is {{yellow:#{head_sha[0..8]}}}, and "\
|
71
|
+
"{{yellow:origin/master}} is {{yellow:#{fetch_head_sha[0..8]}}}.\n" \
|
72
|
+
" Unless you know what you're doing, you should {{green:cd}} to that repo and {{green:git pull}}, then run this again."
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
unless git_status.chomp.empty?
|
77
|
+
dirty = true
|
78
|
+
warn("importing uncommitted changes from dependency: {{yellow:#{dep}}}")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
depdir = File.expand_path("../../vendor/deps/#{dep}", __FILE__)
|
83
|
+
FileUtils.rm_rf(depdir)
|
84
|
+
FileUtils.mkdir_p(depdir)
|
85
|
+
dstlib = File.expand_path('lib', depdir)
|
86
|
+
srclib = File.expand_path('lib', path)
|
87
|
+
|
88
|
+
FileUtils.cp_r(srclib, dstlib)
|
89
|
+
|
90
|
+
rev = head_sha
|
91
|
+
rev << " (dirty)" if dirty
|
92
|
+
rev << "\n"
|
93
|
+
|
94
|
+
File.write("#{depdir}/REVISION", rev)
|
95
|
+
end
|
data/exe/gorails
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
Encoding.default_external = Encoding::UTF_8
|
4
|
+
Encoding.default_internal = Encoding::UTF_8
|
5
|
+
|
6
|
+
unshift_path = ->(path) {
|
7
|
+
p = File.expand_path("../../#{path}", __FILE__)
|
8
|
+
$LOAD_PATH.unshift(p) unless $LOAD_PATH.include?(p)
|
9
|
+
}
|
10
|
+
unshift_path.call('vendor/deps/cli-ui/lib')
|
11
|
+
unshift_path.call('vendor/deps/cli-kit/lib')
|
12
|
+
unshift_path.call('lib')
|
13
|
+
|
14
|
+
require "gorails"
|
15
|
+
|
16
|
+
exit(Gorails::ErrorHandler.call do
|
17
|
+
Gorails::EntryPoint.call(ARGV.dup)
|
18
|
+
end)
|
data/gorails.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
-
#spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
19
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
20
20
|
|
21
21
|
# Specify which files should be added to the gem when it is released.
|
22
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -29,8 +29,9 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
30
|
spec.require_paths = ["lib"]
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
spec.add_dependency "cli-kit", "~> 4.0.0"
|
33
|
+
spec.add_dependency "cli-ui", "~> 1.5.1"
|
34
|
+
spec.add_development_dependency "standard"
|
34
35
|
|
35
36
|
# For more information and examples about making a new gem, checkout our
|
36
37
|
# guide at: https://bundler.io/guides/creating_gem.html
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "gorails"
|
2
|
+
require "net/http"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Gorails
|
6
|
+
module Commands
|
7
|
+
class Episodes < Gorails::Command
|
8
|
+
def call(_args, _name)
|
9
|
+
episodes = JSON.parse Net::HTTP.get(URI("https://gorails.com/episodes.json"))
|
10
|
+
|
11
|
+
CLI::UI::Frame.open("Latest GoRails episodes") do
|
12
|
+
episodes.each do |episode|
|
13
|
+
puts CLI::UI.fmt "##{episode["number"]} {{green:#{episode["name"]}}}"
|
14
|
+
puts episode["url"]
|
15
|
+
puts
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.help
|
21
|
+
"View the latest GoRails episodes.\nUsage: {{command:#{Gorails::TOOL_NAME} episodes}}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "gorails"
|
2
|
+
|
3
|
+
module Gorails
|
4
|
+
module Commands
|
5
|
+
class Example < Gorails::Command
|
6
|
+
def call(_args, _name)
|
7
|
+
puts "neato"
|
8
|
+
|
9
|
+
if rand < 0.05
|
10
|
+
raise(CLI::Kit::Abort, "you got unlucky!")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.help
|
15
|
+
"A dummy command.\nUsage: {{command:#{Gorails::TOOL_NAME} example}}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "gorails"
|
2
|
+
|
3
|
+
module Gorails
|
4
|
+
module Commands
|
5
|
+
class Help < Gorails::Command
|
6
|
+
def call(args, _name)
|
7
|
+
puts CLI::UI.fmt("{{bold:Available commands}}")
|
8
|
+
puts ""
|
9
|
+
|
10
|
+
Gorails::Commands::Registry.resolved_commands.each do |name, klass|
|
11
|
+
next if name == "help"
|
12
|
+
puts CLI::UI.fmt("{{command:#{Gorails::TOOL_NAME} #{name}}}")
|
13
|
+
if (help = klass.help)
|
14
|
+
puts CLI::UI.fmt(help)
|
15
|
+
end
|
16
|
+
puts ""
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "gorails"
|
2
|
+
require "net/http"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Gorails
|
6
|
+
module Commands
|
7
|
+
class Jobs < Gorails::Command
|
8
|
+
def call(_args, _name)
|
9
|
+
jobs = JSON.parse Net::HTTP.get(URI("https://jobs.gorails.com/jobs.json"))
|
10
|
+
|
11
|
+
CLI::UI::Frame.open("Ruby on Rails jobs") do
|
12
|
+
jobs.each do |job|
|
13
|
+
puts CLI::UI.fmt "{{green:#{job["title"]}}} at {{blue:#{job.dig("company", "name")}}}"
|
14
|
+
puts job["url"]
|
15
|
+
puts
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.help
|
21
|
+
"View the latest Ruby on Rails jobs.\nUsage: {{command:#{Gorails::TOOL_NAME} jobs}}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "gorails"
|
2
|
+
require "net/http"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Gorails
|
6
|
+
module Commands
|
7
|
+
class Jumpstart < Gorails::Command
|
8
|
+
def call(args, _name)
|
9
|
+
name = args.first
|
10
|
+
|
11
|
+
if name.nil?
|
12
|
+
puts CLI::UI.fmt "{{red:Application name is required.}}"
|
13
|
+
puts "Try again with \"gorails jumpstart myapp\""
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
|
17
|
+
CLI::UI::Frame.open("Generating Jumpstart application \"#{name}\"") do
|
18
|
+
Bundler.with_original_env do
|
19
|
+
system "rails new #{name} -d postgresql -m https://raw.githubusercontent.com/excid3/jumpstart/master/template.rb"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.help
|
25
|
+
"Create a new Ruby on Rails application with the Jumpstart template. https://github.com/excid3/jumpstart\nUsage: {{command:#{Gorails::TOOL_NAME} jumpstart myapp}}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require "gorails"
|
2
|
+
require "bundler"
|
3
|
+
require "json"
|
4
|
+
require "net/http"
|
5
|
+
|
6
|
+
module Gorails
|
7
|
+
module Commands
|
8
|
+
class Railsbytes < Gorails::Command
|
9
|
+
def call(args, _name)
|
10
|
+
if args.none?
|
11
|
+
list
|
12
|
+
else
|
13
|
+
apply(args.first)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.help
|
18
|
+
<<~EOF
|
19
|
+
View the latest Railsbytes templates or load a template by ID.
|
20
|
+
Usage:
|
21
|
+
{{command:#{Gorails::TOOL_NAME} railsbytes}}
|
22
|
+
{{command:#{Gorails::TOOL_NAME} railsbytes x7msKX}}
|
23
|
+
EOF
|
24
|
+
end
|
25
|
+
|
26
|
+
def list
|
27
|
+
bytes = JSON.parse Net::HTTP.get(URI("https://railsbytes.com/public/templates.json"))
|
28
|
+
|
29
|
+
CLI::UI::Frame.open("Railsbytes") do
|
30
|
+
bytes.each do |byte|
|
31
|
+
puts CLI::UI.fmt "{{green:#{byte["name"]}}} by #{byte["created_by"]}"
|
32
|
+
puts byte["short_description"]
|
33
|
+
puts "#{byte["id"]} - #{byte["url"]}"
|
34
|
+
puts
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def apply(id)
|
40
|
+
byte = JSON.parse Net::HTTP.get(URI("https://railsbytes.com/public/templates/#{id}.json"))
|
41
|
+
|
42
|
+
CLI::UI::Frame.open("Railsbyte") do
|
43
|
+
puts CLI::UI.fmt "{{green:#{byte["name"]}}} by #{byte["created_by"]}"
|
44
|
+
puts byte["short_description"]
|
45
|
+
puts
|
46
|
+
|
47
|
+
CLI::UI::Prompt.ask("What would you like to do?") do |handler|
|
48
|
+
handler.option("Apply Railsbyte") do |selection|
|
49
|
+
puts
|
50
|
+
puts "Running Railsbyte..."
|
51
|
+
puts
|
52
|
+
|
53
|
+
system "rails app:template LOCATION=\"https://railsbytes.com/script/#{id}\""
|
54
|
+
end
|
55
|
+
|
56
|
+
handler.option("View source") do |selection|
|
57
|
+
puts
|
58
|
+
puts byte["script"]
|
59
|
+
end
|
60
|
+
|
61
|
+
handler.option("Exit") { |selection| exit 0 }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "gorails"
|
2
|
+
|
3
|
+
module Gorails
|
4
|
+
module Commands
|
5
|
+
Registry = CLI::Kit::CommandRegistry.new(default: "help")
|
6
|
+
|
7
|
+
def self.register(const, cmd, path)
|
8
|
+
autoload(const, path)
|
9
|
+
Registry.add(-> { const_get(const) }, cmd)
|
10
|
+
end
|
11
|
+
|
12
|
+
register :Episodes, "episodes", "gorails/commands/episodes"
|
13
|
+
register :Jobs, "jobs", "gorails/commands/jobs"
|
14
|
+
register :Jumpstart, "jumpstart", "gorails/commands/jumpstart"
|
15
|
+
register :Railsbytes, "railsbytes", "gorails/commands/railsbytes"
|
16
|
+
# register :Example, 'example', 'gorails/commands/example'
|
17
|
+
register :Help, "help", "gorails/commands/help"
|
18
|
+
end
|
19
|
+
end
|
data/lib/gorails/version.rb
CHANGED
data/lib/gorails.rb
CHANGED
@@ -1,8 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "gorails/version"
|
4
|
+
require "cli/ui"
|
5
|
+
require "cli/kit"
|
6
|
+
|
7
|
+
CLI::UI::StdoutRouter.enable
|
4
8
|
|
5
9
|
module Gorails
|
6
10
|
class Error < StandardError; end
|
7
|
-
|
11
|
+
|
12
|
+
TOOL_NAME = "gorails"
|
13
|
+
ROOT = File.expand_path("../..", __FILE__)
|
14
|
+
LOG_FILE = "/tmp/gorails.log"
|
15
|
+
|
16
|
+
autoload(:EntryPoint, "gorails/entry_point")
|
17
|
+
autoload(:Commands, "gorails/commands")
|
18
|
+
|
19
|
+
Config = CLI::Kit::Config.new(tool_name: TOOL_NAME)
|
20
|
+
Command = CLI::Kit::BaseCommand
|
21
|
+
|
22
|
+
Executor = CLI::Kit::Executor.new(log_file: LOG_FILE)
|
23
|
+
Resolver = CLI::Kit::Resolver.new(
|
24
|
+
tool_name: TOOL_NAME,
|
25
|
+
command_registry: Gorails::Commands::Registry
|
26
|
+
)
|
27
|
+
|
28
|
+
ErrorHandler = CLI::Kit::ErrorHandler.new(log_file: LOG_FILE)
|
8
29
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
635eab627526f34c7ce15d2c894633246493b1a4
|