rails_app 0.8.0 → 0.9.0

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: 58716cd225034bd8c2deecc05e99d82b58d05ffbbdeadc3b721a526d249a4b1e
4
- data.tar.gz: 531c6ecd9e5a5910d0170a53a2cf50e31f294037ae2deeb21908eb2de626f45b
3
+ metadata.gz: 52a552ad38f9b0cd6267841541720a9f89db6000e68131eb8a34247f1a329fdc
4
+ data.tar.gz: 87e54f8b3f3a27327d426f14871e3ede7b5d7f5377a5ef54d586b77ec6953f99
5
5
  SHA512:
6
- metadata.gz: 0be667225b33a863c11cd13a0a9f1fa5cf52b70983d6cd3c549c89f3e1012942a0bb44dd1de6f695db48dca5275e23512a5e053541439bfa73480ba73b6ccc68
7
- data.tar.gz: 420dc812fc3fb540a55b072c4a4ec18635862efbdb2bdf751de64890dc279b33b76cbbb4840a81cc296bf06d1ba72d068439311e1a5e57d13d361b126e09461f
6
+ metadata.gz: 0ce7c421dd28e008f52caf74b520e8bb2aa57ca13e8d21f7b4dc5c0cc6ab8357d3ffad3a18dd8f65b7ae80339475664fcf23ff28d5fb8a4d838f165bbb9e0e71
7
+ data.tar.gz: 54409b3d01c1bd0a11f4ca01bcd8ba0f0d153192127ab262b2e2f9a4bfafb7046fd2f8df04b84d37ed4451d6858fdb1ee9451296a1a214628bd031499de3e42e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.0](https://github.com/eclectic-coding/rails_app/tree/0.9.0) (2024-04-09)
4
+
5
+ [Full Changelog](https://github.com/eclectic-coding/rails_app/compare/0.8.1...0.9.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Add additional flags to CLI [\#26](https://github.com/eclectic-coding/rails_app/issues/26)
10
+ - Add additional flags to cli [\#30](https://github.com/eclectic-coding/rails_app/pull/30) ([eclectic-coding](https://github.com/eclectic-coding))
11
+
12
+ ## [0.8.1](https://github.com/eclectic-coding/rails_app/tree/0.8.1) (2024-04-08)
13
+
14
+ [Full Changelog](https://github.com/eclectic-coding/rails_app/compare/0.8.0...0.8.1)
15
+
16
+ **Implemented enhancements:**
17
+
18
+ - Read users existing .railsrc for preferences [\#1](https://github.com/eclectic-coding/rails_app/issues/1)
19
+
20
+ **Fixed bugs:**
21
+
22
+ - CLI Menu should be bypassed when using saved configuration [\#28](https://github.com/eclectic-coding/rails_app/issues/28)
23
+ - 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))
24
+
3
25
  ## [0.8.0](https://github.com/eclectic-coding/rails_app/tree/0.8.0) (2024-04-05)
4
26
 
5
27
  [Full Changelog](https://github.com/eclectic-coding/rails_app/compare/0.7.0...0.8.0)
data/README.md CHANGED
@@ -38,7 +38,7 @@ There is an additional syntax, available starting with release `v. 0.7.0`, which
38
38
 
39
39
 
40
40
  ```bash
41
- rails_app new my_app -a propshaft --css bootstrap -d postgresql
41
+ rails_app my_app -a propshaft --css bootstrap -d postgresql
42
42
  ```
43
43
  I few things to note:
44
44
  - the `app_name` must be first, just like with `rails new`
@@ -60,18 +60,14 @@ If a file has been previously saved, you will be prompted if you want to use:
60
60
  ![](assets/screenshot_cli_readconfig.png)
61
61
 
62
62
 
63
- Then your options will be pre-selected:
64
- ![](assets/screenshot_cli_useconfig.png)
63
+ The CLI menu will then be bypassed and the application with be created with your presets.
65
64
 
66
- ## Testing
67
- The template includes RSpec for testing, which includes pre configured:
68
- - FactoryBot
69
- - Faker
70
- - Webmock
71
- - VCR
72
- - Simplecov
65
+ # Features
66
+
67
+ ## Authentication
68
+ documentation coming soon
73
69
 
74
- ### Code Quality Tools
70
+ ## Code Quality Tools
75
71
  The template includes the following code quality tools:
76
72
  - Rubocop using the `rubocop-rails-omakase` gem with a few custom settings in a provided `.rubocop.yml`
77
73
  - Brakeman for security scanning
@@ -80,10 +76,18 @@ The template includes the following code quality tools:
80
76
  All of this tools can be run using the following command, which also will run the test suite: `bin/ci`
81
77
 
82
78
  In addition, the template includes:
83
- - the `annotate` gem to annotate models and and factories with schema information
84
- - 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
85
89
 
86
- ## Development
90
+ # Development
87
91
 
88
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.
89
93
 
data/lib/rails_app/cli.rb CHANGED
@@ -5,45 +5,53 @@ 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
11
  config_file = ConfigFile.new
12
12
 
13
13
  app_name = options_data.app_name || prompt.ask("What is the name of your application?", required: true)
14
14
 
15
- # Read the configuration and ask the user if they want to use it
15
+ # Read from existing configuration and ask the user if they want to use it
16
16
  config_options = config_file.read
17
+
17
18
  if config_options && prompt.yes?("Do you want to use this configuration? #{config_options}")
18
- options_data = OptionsData.from_config(config_options)
19
+ create_app(app_name, config_options) # standard:disable Style/IdenticalConditionalBranches
20
+ else
21
+ config_options = menu(prompt, options_data) # open cli menus to get user input
22
+ # puts "config_options: #{config_options}"
23
+ save_config(prompt, config_file, config_options) # save their configuration
24
+ create_app(app_name, config_options) # standard:disable Style/IdenticalConditionalBranches
19
25
  end
26
+ end
27
+
28
+ def self.menu(prompt, option_data = nil)
29
+ assets = prompt.select("How would you like to manage assets?", %w[propshaft sprockets], default: option_data&.default_assets)
30
+ styling = prompt.select("How would you like to manage styling?", %w[bootstrap tailwind bulma postcss sass], default: option_data&.default_styling)
31
+ database = prompt.select("Which database would you like to use?", %w[postgresql sqlite3 mysql trilogy oracle sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc], default: option_data&.default_database)
32
+ skip_spring = prompt.yes?("Would you like to SKIP spring?", default: option_data&.default_action_mailer)
33
+ action_mailer = prompt.yes?("Would you like to SKIP Action Mailer?", default: option_data&.default_action_mailer)
34
+ action_mailbox = prompt.yes?("Would you like to SKIP Action Mailbox?", default: option_data&.default_action_mailbox)
35
+ action_text = prompt.yes?("Would you like to SKIP Action Text?", default: option_data&.default_action_text)
36
+ action_storage = prompt.yes?("Would you like to SKIP Active Storage?", default: option_data&.default_action_storage)
37
+ action_cable = prompt.yes?("Would you like to SKIP Active Cable?", default: option_data&.default_action_cable)
38
+
39
+ {assets: assets, styling: styling, database: database, skip_spring: skip_spring, action_mailer: action_mailer,
40
+ action_mailbox: action_mailbox, action_text: action_text, action_storage: action_storage, action_cable: action_cable}
41
+ end
42
+
43
+ def self.create_app(app_name, args)
44
+ Command.new(app_name, args).run
45
+ end
20
46
 
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
47
+ def self.save_config(prompt, config_file, config_options)
36
48
  if prompt.yes?("Do you wish to save your configuration?")
37
- # Iterate over the hash and set the configuration
38
49
  config_options.each do |key, value|
39
- next if key == :app_name
40
50
  config_file.set(key, value)
41
51
  end
42
52
  config_file.write(force: true)
43
53
  puts "Configuration saved successfully @ #{config_file.full_path}"
44
54
  end
45
-
46
- Command.new(config_options).run
47
55
  end
48
56
  end
49
57
  end
@@ -2,11 +2,18 @@ module RailsApp
2
2
  class Command
3
3
  attr_reader :app_name, :assets, :styling, :database
4
4
 
5
- def initialize(args)
6
- @app_name = args[:app_name]
5
+ def initialize(app_name, args)
6
+ # puts "args: #{args}"
7
+ @app_name = app_name
7
8
  @assets = args[:assets]
8
9
  @styling = args[:styling]
9
10
  @database = args[:database]
11
+ @skip_spring = args[:skip_spring]
12
+ @skip_action_mailer = args[:action_mailer]
13
+ @skip_action_mailbox = args[:action_mailbox]
14
+ @skip_action_text = args[:action_text]
15
+ @skip_action_storage = args[:action_storage]
16
+ @skip_action_cable = args[:action_cable]
10
17
  end
11
18
 
12
19
  def template
@@ -14,14 +21,34 @@ module RailsApp
14
21
  end
15
22
 
16
23
  def run
17
- command = "rails new #{@app_name} --no-rc #{skip_spring} #{database_adapter} #{asset_management} #{javascript_bundling} #{styling_framework} #{testing_framework} -m #{template}"
24
+ command = "rails new #{@app_name} --no-rc #{skip_spring} #{skip_action_mailer} #{skip_action_mailbox} #{skip_action_text} #{skip_action_text} #{skip_action_cable} #{database_adapter} #{asset_management} #{javascript_bundling} #{styling_framework} #{testing_framework} -m #{template}"
18
25
  command.squeeze!(" ")
19
- puts command
26
+ # puts command
20
27
  system(command)
21
28
  end
22
29
 
23
30
  def skip_spring
24
- "--skip-spring"
31
+ "--skip-spring" if @skip_spring == true
32
+ end
33
+
34
+ def skip_action_mailer
35
+ "--skip-action-mailer" if @skip_action_mailer == true
36
+ end
37
+
38
+ def skip_action_mailbox
39
+ "--skip-action-mailbox" if @skip_action_mailbox == true
40
+ end
41
+
42
+ def skip_action_text
43
+ "--skip-action-text" if @skip_action_text == true
44
+ end
45
+
46
+ def skip_action_storage
47
+ "--skip-active-storage" if @skip_action_storage == true
48
+ end
49
+
50
+ def skip_action_cable
51
+ "--skip-action-cable" if @skip_action_cable == true
25
52
  end
26
53
 
27
54
  def database_adapter
@@ -8,16 +8,13 @@ module RailsApp
8
8
  @options = args
9
9
  end
10
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
11
  def app_name
17
12
  @options[0]
18
13
  end
19
14
 
20
15
  def default_assets
16
+ # puts "@options: #{@options.include?("sprockets")}"
17
+
21
18
  @options.include?("sprockets") ? "sprockets" : "propshaft"
22
19
  end
23
20
 
@@ -60,5 +57,25 @@ module RailsApp
60
57
  "sqlite3"
61
58
  end
62
59
  end
60
+
61
+ def default_action_mailer
62
+ @options.include?("skip_action_mailer")
63
+ end
64
+
65
+ def default_action_mailbox
66
+ @options.include?("skip_action_mailbox")
67
+ end
68
+
69
+ def default_action_text
70
+ @options.include?("skip_action_text")
71
+ end
72
+
73
+ def default_action_storage
74
+ @options.include?("skip_action_storage")
75
+ end
76
+
77
+ def default_action_cable
78
+ @options.include?("skip_action_cable")
79
+ end
63
80
  end
64
81
  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.8.0"
4
+ VERSION = "0.9.0"
5
5
  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.8.0
4
+ version: 0.9.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-05 00:00:00.000000000 Z
11
+ date: 2024-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootsnap
@@ -97,7 +97,6 @@ files:
97
97
  - assets/screenshot_cli.png
98
98
  - assets/screenshot_cli_db.png
99
99
  - assets/screenshot_cli_readconfig.png
100
- - assets/screenshot_cli_useconfig.png
101
100
  - bin/rails_app
102
101
  - lib/rails_app.rb
103
102
  - lib/rails_app/cli.rb
Binary file