rails_app 0.7.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 +11 -0
- data/README.md +13 -2
- data/assets/screenshot_cli_readconfig.png +0 -0
- data/assets/screenshot_cli_useconfig.png +0 -0
- data/lib/rails_app/cli.rb +28 -12
- data/lib/rails_app/command.rb +6 -7
- data/lib/rails_app/config_file.rb +35 -0
- data/lib/rails_app/options_data.rb +16 -9
- data/lib/rails_app/version.rb +1 -1
- data/lib/rails_app.rb +1 -0
- data/rails_app.gemspec +1 -0
- metadata +21 -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,16 @@
|
|
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
|
+
|
3
14
|
## [0.7.0](https://github.com/eclectic-coding/rails_app/tree/0.7.0) (2024-04-04)
|
4
15
|
|
5
16
|
[Full Changelog](https://github.com/eclectic-coding/rails_app/compare/0.6.0...0.7.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,11 +24,11 @@ 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
|
|
@@ -35,6 +36,7 @@ The template will then create a new Rails application with the selected options.
|
|
35
36
|
|
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:
|
37
38
|
|
39
|
+
|
38
40
|
```bash
|
39
41
|
rails_app new my_app -a propshaft --css bootstrap -d postgresql
|
40
42
|
```
|
@@ -52,6 +54,15 @@ Right not this syntax only supports the following options:
|
|
52
54
|
|
53
55
|
More options will be added in future releases.
|
54
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
|
+
|
55
66
|
## Testing
|
56
67
|
The template includes RSpec for testing, which includes pre configured:
|
57
68
|
- FactoryBot
|
Binary file
|
Binary file
|
data/lib/rails_app/cli.rb
CHANGED
@@ -8,26 +8,42 @@ module RailsApp
|
|
8
8
|
prompt = TTY::Prompt.new
|
9
9
|
|
10
10
|
options_data = OptionsData.new(args)
|
11
|
+
config_file = ConfigFile.new
|
11
12
|
|
12
13
|
app_name = options_data.app_name || prompt.ask("What is the name of your application?", required: true)
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
{name: "PostCSS", value: "postcss"},
|
20
|
-
{name: "SASS", value: "sass"}
|
21
|
-
]
|
22
|
-
styling = prompt.select("How would you like to manage styling?", styling_choices, default: options_data.default_styling)
|
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
|
23
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)
|
24
23
|
database = prompt.select("Which database would you like to use?",
|
25
24
|
%w[postgresql sqlite3 mysql trilogy oracle sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc],
|
26
25
|
default: options_data.default_database)
|
27
26
|
|
28
|
-
#
|
29
|
-
|
30
|
-
|
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
|
31
47
|
end
|
32
48
|
end
|
33
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
|
@@ -5,7 +5,12 @@ module RailsApp
|
|
5
5
|
attr_reader :options
|
6
6
|
|
7
7
|
def initialize(args)
|
8
|
-
@options = 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)
|
9
14
|
end
|
10
15
|
|
11
16
|
def app_name
|
@@ -17,15 +22,17 @@ module RailsApp
|
|
17
22
|
end
|
18
23
|
|
19
24
|
def default_styling
|
20
|
-
if @options.
|
21
|
-
"tailwind"
|
22
|
-
elsif @options.
|
23
|
-
"bulma"
|
24
|
-
elsif @options.
|
25
|
-
"postcss"
|
26
|
-
elsif @options.
|
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") }
|
27
32
|
"sass"
|
28
|
-
elsif @options.
|
33
|
+
elsif @options.any? { |option| option.end_with?("bootstrap") }
|
34
|
+
"bootstrap"
|
35
|
+
else
|
29
36
|
"bootstrap"
|
30
37
|
end
|
31
38
|
end
|
data/lib/rails_app/version.rb
CHANGED
data/lib/rails_app.rb
CHANGED
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,10 +94,15 @@ 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
|
88
107
|
- lib/rails_app/options_data.rb
|
89
108
|
- lib/rails_app/rails_app.rb
|
@@ -227,8 +246,6 @@ files:
|
|
227
246
|
- lib/rails_app/template/template.rb
|
228
247
|
- lib/rails_app/version.rb
|
229
248
|
- rails_app.gemspec
|
230
|
-
- screenshot_cli.png
|
231
|
-
- screenshot_cli_db.png
|
232
249
|
homepage: https://github.com/eclectic-coding/rails_app
|
233
250
|
licenses:
|
234
251
|
- MIT
|
File without changes
|
File without changes
|