rails_app 0.7.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/README.md +29 -14
- data/assets/screenshot_cli_readconfig.png +0 -0
- data/lib/rails_app/cli.rb +35 -14
- data/lib/rails_app/command.rb +7 -7
- data/lib/rails_app/config_file.rb +35 -0
- data/lib/rails_app/options_data.rb +11 -9
- data/lib/rails_app/template/template.rb +1 -1
- data/lib/rails_app/version.rb +1 -1
- data/lib/rails_app.rb +1 -0
- data/rails_app.gemspec +1 -0
- metadata +20 -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: fa0c7e932155134e3302a6ac298bf0042427dcbf1c43ee9ae91f44b4156718cb
|
4
|
+
data.tar.gz: 2870a89982c68aa08b3a8ee772d88a781174630967097a2dec87dd91cde662b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2febb710ca10bbadc35bf436bf3aab125068ee2ae3c9b5415d3820217e12163a6ede6648afdfd660a89ca44ffa0a283426244c45b2be0984e12d56e2d595ccb1
|
7
|
+
data.tar.gz: 4abdce09c8d37c63f164c1bf70678852491dd816dd9f90e2acd2666b40271e8c210ec5d48e045ca0e11b06e817c310af474249155f5adfc0ab2ec4738fc0a72e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.8.1](https://github.com/eclectic-coding/rails_app/tree/0.8.1) (2024-04-08)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/eclectic-coding/rails_app/compare/0.8.0...0.8.1)
|
6
|
+
|
7
|
+
**Implemented enhancements:**
|
8
|
+
|
9
|
+
- Read users existing .railsrc for preferences [\#1](https://github.com/eclectic-coding/rails_app/issues/1)
|
10
|
+
|
11
|
+
**Fixed bugs:**
|
12
|
+
|
13
|
+
- CLI Menu should be bypassed when using saved configuration [\#28](https://github.com/eclectic-coding/rails_app/issues/28)
|
14
|
+
- CLI menu should be bypassed when using saved configuration [\#29](https://github.com/eclectic-coding/rails_app/pull/29) ([eclectic-coding](https://github.com/eclectic-coding))
|
15
|
+
|
16
|
+
## [0.8.0](https://github.com/eclectic-coding/rails_app/tree/0.8.0) (2024-04-05)
|
17
|
+
|
18
|
+
[Full Changelog](https://github.com/eclectic-coding/rails_app/compare/0.7.0...0.8.0)
|
19
|
+
|
20
|
+
**Implemented enhancements:**
|
21
|
+
|
22
|
+
- setup `tty-config` to save a new config [\#24](https://github.com/eclectic-coding/rails_app/issues/24)
|
23
|
+
- Add more tests [\#4](https://github.com/eclectic-coding/rails_app/issues/4)
|
24
|
+
- 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))
|
25
|
+
- 4 add more tests [\#23](https://github.com/eclectic-coding/rails_app/pull/23) ([eclectic-coding](https://github.com/eclectic-coding))
|
26
|
+
|
3
27
|
## [0.7.0](https://github.com/eclectic-coding/rails_app/tree/0.7.0) (2024-04-04)
|
4
28
|
|
5
29
|
[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,8 +36,9 @@ 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
|
-
rails_app
|
41
|
+
rails_app my_app -a propshaft --css bootstrap -d postgresql
|
40
42
|
```
|
41
43
|
I few things to note:
|
42
44
|
- the `app_name` must be first, just like with `rails new`
|
@@ -52,15 +54,20 @@ Right not this syntax only supports the following options:
|
|
52
54
|
|
53
55
|
More options will be added in future releases.
|
54
56
|
|
55
|
-
##
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
+
The CLI menu will then be bypassed and the application with be created with your presets.
|
62
64
|
|
63
|
-
|
65
|
+
# Features
|
66
|
+
|
67
|
+
## Authentication
|
68
|
+
documentation coming soon
|
69
|
+
|
70
|
+
## Code Quality Tools
|
64
71
|
The template includes the following code quality tools:
|
65
72
|
- Rubocop using the `rubocop-rails-omakase` gem with a few custom settings in a provided `.rubocop.yml`
|
66
73
|
- Brakeman for security scanning
|
@@ -69,10 +76,18 @@ The template includes the following code quality tools:
|
|
69
76
|
All of this tools can be run using the following command, which also will run the test suite: `bin/ci`
|
70
77
|
|
71
78
|
In addition, the template includes:
|
72
|
-
- the `annotate` gem to annotate models and
|
73
|
-
- the `bullet` gem to help identify and
|
79
|
+
- the `annotate` gem to annotate models and factories with schema information
|
80
|
+
- the `bullet` gem to help identify and diagnose N+1 queries
|
81
|
+
|
82
|
+
## Testing
|
83
|
+
The template includes RSpec for testing, which includes pre configured:
|
84
|
+
- FactoryBot
|
85
|
+
- Faker
|
86
|
+
- Webmock
|
87
|
+
- VCR
|
88
|
+
- Simplecov
|
74
89
|
|
75
|
-
|
90
|
+
# Development
|
76
91
|
|
77
92
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
78
93
|
|
Binary file
|
data/lib/rails_app/cli.rb
CHANGED
@@ -5,29 +5,50 @@ require "tty-prompt"
|
|
5
5
|
module RailsApp
|
6
6
|
class CLI
|
7
7
|
def self.start(args)
|
8
|
+
puts "args: #{args}"
|
8
9
|
prompt = TTY::Prompt.new
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
# Read from existing configuration and ask the user if they want to use it
|
16
|
+
config_options = config_file.read
|
17
|
+
|
18
|
+
if config_options && prompt.yes?("Do you want to use this configuration? #{config_options}")
|
19
|
+
|
20
|
+
create_app(app_name, config_options) # standard:disable Style/IdenticalConditionalBranches
|
21
|
+
else
|
22
|
+
# not using config display menu to user
|
23
|
+
config_options = menu(app_name, prompt)
|
24
|
+
|
25
|
+
# Ask the user if they wish to save their configuration
|
26
|
+
if prompt.yes?("Do you wish to save your configuration?")
|
27
|
+
# Iterate over the hash and set the configuration
|
28
|
+
config_options.each do |key, value|
|
29
|
+
next if key == :app_name
|
30
|
+
config_file.set(key, value)
|
31
|
+
end
|
32
|
+
config_file.write(force: true)
|
33
|
+
puts "Configuration saved successfully @ #{config_file.full_path}"
|
34
|
+
end
|
35
|
+
|
36
|
+
puts "config_options: #{config_options}"
|
37
|
+
create_app(app_name, config_options) # standard:disable Style/IdenticalConditionalBranches
|
38
|
+
end
|
39
|
+
end
|
23
40
|
|
41
|
+
def self.menu(app_name, prompt)
|
42
|
+
assets = prompt.select("How would you like to manage assets?", %w[propshaft sprockets])
|
43
|
+
styling = prompt.select("How would you like to manage styling?", %w[bootstrap tailwind bulma postcss sass])
|
24
44
|
database = prompt.select("Which database would you like to use?",
|
25
|
-
%w[postgresql sqlite3 mysql trilogy oracle sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc]
|
26
|
-
default: options_data.default_database)
|
45
|
+
%w[postgresql sqlite3 mysql trilogy oracle sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc])
|
27
46
|
|
28
|
-
|
47
|
+
{app_name: app_name, assets: assets, styling: styling, database: database}
|
48
|
+
end
|
29
49
|
|
30
|
-
|
50
|
+
def self.create_app(app_name, args)
|
51
|
+
Command.new(app_name, args).run
|
31
52
|
end
|
32
53
|
end
|
33
54
|
end
|
data/lib/rails_app/command.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
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(app_name
|
5
|
+
def initialize(app_name, args)
|
8
6
|
@app_name = app_name
|
9
|
-
@assets = assets
|
10
|
-
@styling = styling
|
11
|
-
@database = database
|
7
|
+
@assets = args[:assets]
|
8
|
+
@styling = args[:styling]
|
9
|
+
@database = args[:database]
|
10
|
+
puts "Command: #{@app_name} #{args[:app_name]}"
|
12
11
|
end
|
13
12
|
|
14
13
|
def template
|
@@ -17,7 +16,8 @@ module RailsApp
|
|
17
16
|
|
18
17
|
def run
|
19
18
|
command = "rails new #{@app_name} --no-rc #{skip_spring} #{database_adapter} #{asset_management} #{javascript_bundling} #{styling_framework} #{testing_framework} -m #{template}"
|
20
|
-
|
19
|
+
command.squeeze!(" ")
|
20
|
+
# puts command
|
21
21
|
system(command)
|
22
22
|
end
|
23
23
|
|
@@ -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,7 @@ module RailsApp
|
|
5
5
|
attr_reader :options
|
6
6
|
|
7
7
|
def initialize(args)
|
8
|
-
@options = args
|
8
|
+
@options = args
|
9
9
|
end
|
10
10
|
|
11
11
|
def app_name
|
@@ -17,15 +17,17 @@ module RailsApp
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def default_styling
|
20
|
-
if @options.
|
21
|
-
"tailwind"
|
22
|
-
elsif @options.
|
23
|
-
"bulma"
|
24
|
-
elsif @options.
|
25
|
-
"postcss"
|
26
|
-
elsif @options.
|
20
|
+
if @options.any? { |option| option.end_with?("tailwind") }
|
21
|
+
"tailwind".strip
|
22
|
+
elsif @options.any? { |option| option.end_with?("bulma") }
|
23
|
+
"bulma".strip
|
24
|
+
elsif @options.any? { |option| option.end_with?("postcss") }
|
25
|
+
"postcss".strip
|
26
|
+
elsif @options.any? { |option| option.end_with?("sass") }
|
27
27
|
"sass"
|
28
|
-
elsif @options.
|
28
|
+
elsif @options.any? { |option| option.end_with?("bootstrap") }
|
29
|
+
"bootstrap"
|
30
|
+
else
|
29
31
|
"bootstrap"
|
30
32
|
end
|
31
33
|
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.1
|
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-08 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,14 @@ 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
|
83
100
|
- bin/rails_app
|
84
101
|
- lib/rails_app.rb
|
85
102
|
- lib/rails_app/cli.rb
|
86
103
|
- lib/rails_app/command.rb
|
104
|
+
- lib/rails_app/config_file.rb
|
87
105
|
- lib/rails_app/error.rb
|
88
106
|
- lib/rails_app/options_data.rb
|
89
107
|
- lib/rails_app/rails_app.rb
|
@@ -227,8 +245,6 @@ files:
|
|
227
245
|
- lib/rails_app/template/template.rb
|
228
246
|
- lib/rails_app/version.rb
|
229
247
|
- rails_app.gemspec
|
230
|
-
- screenshot_cli.png
|
231
|
-
- screenshot_cli_db.png
|
232
248
|
homepage: https://github.com/eclectic-coding/rails_app
|
233
249
|
licenses:
|
234
250
|
- MIT
|
File without changes
|
File without changes
|