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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 534816163e2b9fc2c353d1a2afb4568c8bd9b3355b46fcbe1b132b83cb89acad
4
- data.tar.gz: e2e50fd1ebe97b1981da6713e49cc7595c8f11c58bb600b67e7b99088a745252
3
+ metadata.gz: fa0c7e932155134e3302a6ac298bf0042427dcbf1c43ee9ae91f44b4156718cb
4
+ data.tar.gz: 2870a89982c68aa08b3a8ee772d88a781174630967097a2dec87dd91cde662b4
5
5
  SHA512:
6
- metadata.gz: d5242d9c1382772a58599ab08658745d6eac76a12c78ef2b83395af317a777abd022885028c5f664087882a4b6fed1331b831a0cc5dec9bd760746b5268ceb05
7
- data.tar.gz: b3dcfc4ecbe21b2c96435606cb44bd7867f1de8d8da66075d50b9852db7d294580639434fdbef7f2fe4e81f72dcad879a5c336eeb5cf5a7ba1ea3b513a8fde16
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
- ![](./screenshot_cli.png)
27
+ ![](assets/screenshot_cli.png)
27
28
 
28
29
  Also, you can select your database of choice:
29
30
 
30
- ![](./screenshot_cli_db.png)
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 new my_app -a propshaft --css bootstrap -d postgresql
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
- ## Testing
56
- The template includes RSpec for testing, which includes pre configured:
57
- - FactoryBot
58
- - Faker
59
- - Webmock
60
- - VCR
61
- - Simplecov
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
- ### Code Quality Tools
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 and factories with schema information
73
- - the `bullet` gem to help identify and remove N+1 queries
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
- ## Development
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
 
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
- assets = prompt.select("How would you like to manage assets?", %w[propshaft sprockets], default: options_data.default_assets)
15
- styling_choices = [
16
- {name: "Bootstrap", value: "bootstrap"},
17
- {name: "Tailwind CSS", value: "tailwind"},
18
- {name: "Bulma", value: "bulma"},
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 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
- # save configuration
47
+ {app_name: app_name, assets: assets, styling: styling, database: database}
48
+ end
29
49
 
30
- Command.new(app_name: app_name, assets: assets, styling: styling, database: database).run
50
+ def self.create_app(app_name, args)
51
+ Command.new(app_name, args).run
31
52
  end
32
53
  end
33
54
  end
@@ -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:, assets:, styling:, database:)
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
- puts command
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.flat_map { |arg| arg.split(" ") }
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.include?("tailwind")
21
- "tailwind"
22
- elsif @options.include?("bulma")
23
- "bulma"
24
- elsif @options.include?("postcss")
25
- "postcss"
26
- elsif @options.include?("sass")
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.include?("bootstrap")
28
+ elsif @options.any? { |option| option.end_with?("bootstrap") }
29
+ "bootstrap"
30
+ else
29
31
  "bootstrap"
30
32
  end
31
33
  end
@@ -3,7 +3,7 @@
3
3
  require "fileutils"
4
4
  require "shellwords"
5
5
 
6
- puts "options: #{options}"
6
+ # puts "options: #{options}"
7
7
 
8
8
  def add_template_to_source_path
9
9
  source_paths.unshift(File.expand_path(File.join(__dir__)))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsApp
4
- VERSION = "0.7.0"
4
+ VERSION = "0.8.1"
5
5
  end
data/lib/rails_app.rb CHANGED
@@ -7,5 +7,6 @@ module RailsApp
7
7
  autoload :CLI, "rails_app/cli"
8
8
  autoload :Command, "rails_app/command"
9
9
  autoload :OptionsData, "rails_app/options_data"
10
+ autoload :ConfigFile, "rails_app/config_file"
10
11
  autoload :Error, "rails_app/error"
11
12
  end
data/rails_app.gemspec CHANGED
@@ -33,4 +33,5 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency "bootsnap", "~> 1.18", ">= 1.18.3" # used by rails new
34
34
  spec.add_dependency "thor", "~> 1.3", ">= 1.3.1"
35
35
  spec.add_dependency "tty-prompt", "~> 0.23.1"
36
+ spec.add_dependency "tty-config", "~> 0.6.0"
36
37
  end
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.7.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-04 00:00:00.000000000 Z
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