rails_app 0.6.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +35 -3
- data/assets/screenshot_cli_readconfig.png +0 -0
- data/assets/screenshot_cli_useconfig.png +0 -0
- data/bin/rails_app +1 -1
- data/lib/rails_app/cli.rb +38 -14
- data/lib/rails_app/command.rb +6 -7
- data/lib/rails_app/config_file.rb +35 -0
- data/lib/rails_app/options_data.rb +64 -0
- data/lib/rails_app/rails_app.rb +2 -2
- data/lib/rails_app/version.rb +1 -1
- data/lib/rails_app.rb +2 -0
- data/rails_app.gemspec +1 -0
- metadata +22 -4
- /data/{screenshot_cli.png → assets/screenshot_cli.png} +0 -0
- /data/{screenshot_cli_db.png → assets/screenshot_cli_db.png} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58716cd225034bd8c2deecc05e99d82b58d05ffbbdeadc3b721a526d249a4b1e
|
4
|
+
data.tar.gz: 531c6ecd9e5a5910d0170a53a2cf50e31f294037ae2deeb21908eb2de626f45b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0be667225b33a863c11cd13a0a9f1fa5cf52b70983d6cd3c549c89f3e1012942a0bb44dd1de6f695db48dca5275e23512a5e053541439bfa73480ba73b6ccc68
|
7
|
+
data.tar.gz: 420dc812fc3fb540a55b072c4a4ec18635862efbdb2bdf751de64890dc279b33b76cbbb4840a81cc296bf06d1ba72d068439311e1a5e57d13d361b126e09461f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,26 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.8.0](https://github.com/eclectic-coding/rails_app/tree/0.8.0) (2024-04-05)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/eclectic-coding/rails_app/compare/0.7.0...0.8.0)
|
6
|
+
|
7
|
+
**Implemented enhancements:**
|
8
|
+
|
9
|
+
- setup `tty-config` to save a new config [\#24](https://github.com/eclectic-coding/rails_app/issues/24)
|
10
|
+
- Add more tests [\#4](https://github.com/eclectic-coding/rails_app/issues/4)
|
11
|
+
- Setup tty config to save a new config [\#25](https://github.com/eclectic-coding/rails_app/pull/25) ([eclectic-coding](https://github.com/eclectic-coding))
|
12
|
+
- 4 add more tests [\#23](https://github.com/eclectic-coding/rails_app/pull/23) ([eclectic-coding](https://github.com/eclectic-coding))
|
13
|
+
|
14
|
+
## [0.7.0](https://github.com/eclectic-coding/rails_app/tree/0.7.0) (2024-04-04)
|
15
|
+
|
16
|
+
[Full Changelog](https://github.com/eclectic-coding/rails_app/compare/0.6.0...0.7.0)
|
17
|
+
|
18
|
+
**Implemented enhancements:**
|
19
|
+
|
20
|
+
- handle optional CLI ARGV [\#21](https://github.com/eclectic-coding/rails_app/issues/21)
|
21
|
+
- Add user option to select other styling systems [\#2](https://github.com/eclectic-coding/rails_app/issues/2)
|
22
|
+
- Handle optional cli argv [\#22](https://github.com/eclectic-coding/rails_app/pull/22) ([eclectic-coding](https://github.com/eclectic-coding))
|
23
|
+
|
3
24
|
## [0.6.0](https://github.com/eclectic-coding/rails_app/tree/0.6.0) (2024-04-04)
|
4
25
|
|
5
26
|
[Full Changelog](https://github.com/eclectic-coding/rails_app/compare/0.5.0...0.6.0)
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
![GitHub License](https://img.shields.io/github/license/eclectic-coding/rails_app)
|
2
2
|
[![Tests](https://github.com/eclectic-coding/rails_app/actions/workflows/ci.yml/badge.svg)](https://github.com/eclectic-coding/rails_app/actions/workflows/ci.yml)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/rails_app.svg)](https://badge.fury.io/rb/rails_app)
|
3
4
|
# RailsApp
|
4
5
|
|
5
6
|
RailsApp is a gem that provides a simple way to create a new Rails application with a pre-configured set of gems and settings, utilizing the Rails application templates feature.
|
@@ -23,15 +24,46 @@ To bootstrap a new Rails application: `rails_app`
|
|
23
24
|
|
24
25
|
The user will be prompted to enter the name of the new Rails application, and the select the assets pipeline to use (propshaft or sprockets), and a styling option:
|
25
26
|
|
26
|
-
![](
|
27
|
+
![](assets/screenshot_cli.png)
|
27
28
|
|
28
29
|
Also, you can select your database of choice:
|
29
30
|
|
30
|
-
![](
|
31
|
+
![](assets/screenshot_cli_db.png)
|
31
32
|
|
32
33
|
The template will then create a new Rails application with the selected options.
|
33
34
|
|
34
|
-
###
|
35
|
+
### Optional CLI Syntax
|
36
|
+
|
37
|
+
There is an additional syntax, available starting with release `v. 0.7.0`, which allows you to use `rails_app` very similarly to the `rails new` command:
|
38
|
+
|
39
|
+
|
40
|
+
```bash
|
41
|
+
rails_app new my_app -a propshaft --css bootstrap -d postgresql
|
42
|
+
```
|
43
|
+
I few things to note:
|
44
|
+
- the `app_name` must be first, just like with `rails new`
|
45
|
+
- the following arguments and flags must be separated by a space `-a propshaft`. Since, the parser ignores the flag and checks for the specific keywords only, you technically can use the follow: `rails_app my_app propshaft bootstrap postgresql`.
|
46
|
+
|
47
|
+
If you use this syntax, the template will not prompt you the application name, and subsequent options will be preselected for you.
|
48
|
+
|
49
|
+
Right not this syntax only supports the following options:
|
50
|
+
- app name
|
51
|
+
- assets pipeline
|
52
|
+
- styling
|
53
|
+
- database
|
54
|
+
|
55
|
+
More options will be added in future releases.
|
56
|
+
|
57
|
+
## Configuration
|
58
|
+
**NEW** Starting with release `v. 0.8.0`, you can save your preferred defaults to you users home directory (`rails_aap-config.yml`).
|
59
|
+
If a file has been previously saved, you will be prompted if you want to use:
|
60
|
+
![](assets/screenshot_cli_readconfig.png)
|
61
|
+
|
62
|
+
|
63
|
+
Then your options will be pre-selected:
|
64
|
+
![](assets/screenshot_cli_useconfig.png)
|
65
|
+
|
66
|
+
## Testing
|
35
67
|
The template includes RSpec for testing, which includes pre configured:
|
36
68
|
- FactoryBot
|
37
69
|
- Faker
|
Binary file
|
Binary file
|
data/bin/rails_app
CHANGED
data/lib/rails_app/cli.rb
CHANGED
@@ -4,22 +4,46 @@ require "tty-prompt"
|
|
4
4
|
|
5
5
|
module RailsApp
|
6
6
|
class CLI
|
7
|
-
def self.start
|
7
|
+
def self.start(args)
|
8
8
|
prompt = TTY::Prompt.new
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
10
|
+
options_data = OptionsData.new(args)
|
11
|
+
config_file = ConfigFile.new
|
12
|
+
|
13
|
+
app_name = options_data.app_name || prompt.ask("What is the name of your application?", required: true)
|
14
|
+
|
15
|
+
# Read the configuration and ask the user if they want to use it
|
16
|
+
config_options = config_file.read
|
17
|
+
if config_options && prompt.yes?("Do you want to use this configuration? #{config_options}")
|
18
|
+
options_data = OptionsData.from_config(config_options)
|
19
|
+
end
|
20
|
+
|
21
|
+
assets = prompt.select("How would you like to manage assets?", %w[propshaft sprockets], default: options_data.default_assets)
|
22
|
+
styling = prompt.select("How would you like to manage styling?", %w[bootstrap tailwind bulma postcss sass], default: options_data.default_styling)
|
23
|
+
database = prompt.select("Which database would you like to use?",
|
24
|
+
%w[postgresql sqlite3 mysql trilogy oracle sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc],
|
25
|
+
default: options_data.default_database)
|
26
|
+
|
27
|
+
# Collect all configuration options into a hash
|
28
|
+
config_options = {
|
29
|
+
app_name: app_name,
|
30
|
+
assets: assets,
|
31
|
+
styling: styling,
|
32
|
+
database: database
|
33
|
+
}
|
34
|
+
|
35
|
+
# Ask the user if they wish to save their configuration
|
36
|
+
if prompt.yes?("Do you wish to save your configuration?")
|
37
|
+
# Iterate over the hash and set the configuration
|
38
|
+
config_options.each do |key, value|
|
39
|
+
next if key == :app_name
|
40
|
+
config_file.set(key, value)
|
41
|
+
end
|
42
|
+
config_file.write(force: true)
|
43
|
+
puts "Configuration saved successfully @ #{config_file.full_path}"
|
44
|
+
end
|
45
|
+
|
46
|
+
Command.new(config_options).run
|
23
47
|
end
|
24
48
|
end
|
25
49
|
end
|
data/lib/rails_app/command.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
module RailsApp
|
4
2
|
class Command
|
5
3
|
attr_reader :app_name, :assets, :styling, :database
|
6
4
|
|
7
|
-
def initialize(
|
8
|
-
@app_name = app_name
|
9
|
-
@assets = assets
|
10
|
-
@styling = styling
|
11
|
-
@database = database
|
5
|
+
def initialize(args)
|
6
|
+
@app_name = args[:app_name]
|
7
|
+
@assets = args[:assets]
|
8
|
+
@styling = args[:styling]
|
9
|
+
@database = args[:database]
|
12
10
|
end
|
13
11
|
|
14
12
|
def template
|
@@ -17,6 +15,7 @@ module RailsApp
|
|
17
15
|
|
18
16
|
def run
|
19
17
|
command = "rails new #{@app_name} --no-rc #{skip_spring} #{database_adapter} #{asset_management} #{javascript_bundling} #{styling_framework} #{testing_framework} -m #{template}"
|
18
|
+
command.squeeze!(" ")
|
20
19
|
puts command
|
21
20
|
system(command)
|
22
21
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "tty-config"
|
4
|
+
|
5
|
+
module RailsApp
|
6
|
+
class ConfigFile
|
7
|
+
def initialize
|
8
|
+
@config = TTY::Config.new
|
9
|
+
@config.append_path(Dir.home)
|
10
|
+
@config.filename = "rails_app-config"
|
11
|
+
@config.extname = ".yml"
|
12
|
+
end
|
13
|
+
|
14
|
+
def exist?
|
15
|
+
@config.exist?
|
16
|
+
end
|
17
|
+
|
18
|
+
def set(key, value)
|
19
|
+
@config.set(key, value: value)
|
20
|
+
end
|
21
|
+
|
22
|
+
def write(force: false)
|
23
|
+
@config.write(force: force)
|
24
|
+
end
|
25
|
+
|
26
|
+
def full_path
|
27
|
+
File.join(@config.location_paths[0] + "/" + @config.filename + @config.extname)
|
28
|
+
end
|
29
|
+
|
30
|
+
def read
|
31
|
+
@config.read if exist?
|
32
|
+
@config.to_h
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsApp
|
4
|
+
class OptionsData
|
5
|
+
attr_reader :options
|
6
|
+
|
7
|
+
def initialize(args)
|
8
|
+
@options = args
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.from_config(config_hash)
|
12
|
+
new_args = config_hash.map { |key, value| value.to_s }
|
13
|
+
new(new_args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def app_name
|
17
|
+
@options[0]
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_assets
|
21
|
+
@options.include?("sprockets") ? "sprockets" : "propshaft"
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_styling
|
25
|
+
if @options.any? { |option| option.end_with?("tailwind") }
|
26
|
+
"tailwind".strip
|
27
|
+
elsif @options.any? { |option| option.end_with?("bulma") }
|
28
|
+
"bulma".strip
|
29
|
+
elsif @options.any? { |option| option.end_with?("postcss") }
|
30
|
+
"postcss".strip
|
31
|
+
elsif @options.any? { |option| option.end_with?("sass") }
|
32
|
+
"sass"
|
33
|
+
elsif @options.any? { |option| option.end_with?("bootstrap") }
|
34
|
+
"bootstrap"
|
35
|
+
else
|
36
|
+
"bootstrap"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def default_database
|
41
|
+
if @options.include?("postgresql")
|
42
|
+
"postgresql"
|
43
|
+
elsif @options.include?("mysql")
|
44
|
+
"mysql"
|
45
|
+
elsif @options.include?("trilogy")
|
46
|
+
"trilogy"
|
47
|
+
elsif @options.include?("oracle")
|
48
|
+
"oracle"
|
49
|
+
elsif @options.include?("sqlserver")
|
50
|
+
"sqlserver"
|
51
|
+
elsif @options.include?("jdbcmysql")
|
52
|
+
"jdbcmysql"
|
53
|
+
elsif @options.include?("jdbcsqlite3")
|
54
|
+
"jdbcsqlite3"
|
55
|
+
elsif @options.include?("jdbcpostgresql")
|
56
|
+
"jdbcpostgresql"
|
57
|
+
elsif @options.include?("jdbc")
|
58
|
+
"jdbc"
|
59
|
+
else
|
60
|
+
"sqlite3"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/rails_app/rails_app.rb
CHANGED
data/lib/rails_app/version.rb
CHANGED
data/lib/rails_app.rb
CHANGED
@@ -6,5 +6,7 @@ module RailsApp
|
|
6
6
|
autoload :App, "rails_app/rails_app"
|
7
7
|
autoload :CLI, "rails_app/cli"
|
8
8
|
autoload :Command, "rails_app/command"
|
9
|
+
autoload :OptionsData, "rails_app/options_data"
|
10
|
+
autoload :ConfigFile, "rails_app/config_file"
|
9
11
|
autoload :Error, "rails_app/error"
|
10
12
|
end
|
data/rails_app.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chuck Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bootsnap
|
@@ -64,6 +64,20 @@ dependencies:
|
|
64
64
|
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: 0.23.1
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: tty-config
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 0.6.0
|
74
|
+
type: :runtime
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 0.6.0
|
67
81
|
description: Bootstrap a new customized Rails application with a better development
|
68
82
|
experience.
|
69
83
|
email:
|
@@ -80,11 +94,17 @@ files:
|
|
80
94
|
- LICENSE.txt
|
81
95
|
- README.md
|
82
96
|
- Rakefile
|
97
|
+
- assets/screenshot_cli.png
|
98
|
+
- assets/screenshot_cli_db.png
|
99
|
+
- assets/screenshot_cli_readconfig.png
|
100
|
+
- assets/screenshot_cli_useconfig.png
|
83
101
|
- bin/rails_app
|
84
102
|
- lib/rails_app.rb
|
85
103
|
- lib/rails_app/cli.rb
|
86
104
|
- lib/rails_app/command.rb
|
105
|
+
- lib/rails_app/config_file.rb
|
87
106
|
- lib/rails_app/error.rb
|
107
|
+
- lib/rails_app/options_data.rb
|
88
108
|
- lib/rails_app/rails_app.rb
|
89
109
|
- lib/rails_app/template/.rspec
|
90
110
|
- lib/rails_app/template/.rubocop.yml
|
@@ -226,8 +246,6 @@ files:
|
|
226
246
|
- lib/rails_app/template/template.rb
|
227
247
|
- lib/rails_app/version.rb
|
228
248
|
- rails_app.gemspec
|
229
|
-
- screenshot_cli.png
|
230
|
-
- screenshot_cli_db.png
|
231
249
|
homepage: https://github.com/eclectic-coding/rails_app
|
232
250
|
licenses:
|
233
251
|
- MIT
|
File without changes
|
File without changes
|