flamerb 0.2.0 → 0.3.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: 21cf2de29fdc8d873003895b2c56cf75f7812471ba481f297ca86fcd28a344a2
4
- data.tar.gz: 909ef801c9df9d4668165824959595af2d3eebae808d90858756ea4655efa16c
3
+ metadata.gz: 9454312b3e487a027ad473bbb28a5f2cc426e0c80c89fb465543b7973688d967
4
+ data.tar.gz: 916844f29bc26883c1cdd6996dab823013c2c5583ad84af2c9af0bfe71db59a5
5
5
  SHA512:
6
- metadata.gz: 5b9839c63e4f8ab236d46c777fe183fc738b607dd20fc9fc648eae4e592b7ba6405164b9e59d97c18545dce030a7e18cbc5423f850343a8a301a771e6c22e53c
7
- data.tar.gz: db0ef98dc5a90c962d2dac400f89d2c3ad49289debb5d81384e4821871b64de4c87631696f526505a1c6f11e1e4a2c1d8f2595da20fc2ac7e296a8dcb239c677
6
+ metadata.gz: 7ebf2d41b963182dc3163bffc71527269765775131e88958d8398257781ea283495e9f154eca5121598242ce273af9d6ee1385ff4386237becfcb04772a4f27b
7
+ data.tar.gz: a7d218f734570eb3aff0180e1d77f354d0b88c61053d76cb934f39b37bfc650c4b1c7398c32d76d14e99cbc4809760c8def8f2957e427ec8e47a019ba5a7bdb5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## v0.3.0 (2023-07-18)
2
+
3
+ ### Feat
4
+
5
+ - problems with some templates
6
+
7
+ ### Fix
8
+
9
+ - problems with solargraph
10
+
11
+ ## v0.2.2 (2023-07-14)
12
+
13
+ ### Fix
14
+
15
+ - problems with rubocop
16
+
17
+ ## v0.2.1 (2023-07-13)
18
+
19
+ ### Fix
20
+
21
+ - conflict with template location
22
+
1
23
  ## v0.2.0 (2023-07-13)
2
24
 
3
25
  ### Feat
data/bin/flamerb CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
- require 'pathname'
2
+ require "pathname"
3
3
 
4
- source_path = (Pathname.new(__FILE__).dirname + '../lib').expand_path
4
+ source_path = (Pathname.new(__FILE__).dirname + "../lib").expand_path
5
5
  $LOAD_PATH << source_path
6
6
 
7
- require 'flame'
7
+ require "flame"
8
8
 
9
9
  if ARGV.empty?
10
10
  puts "Please provide a path for the new application"
@@ -21,6 +21,6 @@ ARGV << "--skip-jbuilder"
21
21
  ARGV << "--database=postgresql"
22
22
  ARGV << "-T"
23
23
 
24
- templates_path = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
24
+ templates_path = File.expand_path("../../templates", __FILE__)
25
25
  Flame::Generators::App.source_paths << Rails::Generators::AppGenerator.source_root << templates_path
26
26
  Flame::Generators::App.start
@@ -1,3 +1,4 @@
1
+ require 'bundler'
1
2
  require "rails/generators"
2
3
  require "rails/generators/rails/app/app_generator"
3
4
 
@@ -16,8 +17,9 @@ module Flame
16
17
  end
17
18
 
18
19
  def generators
19
- run("spring stop > /dev/null 2>&1 || true")
20
- run("bundle install")
20
+ run "spring stop > /dev/null 2>&1 || true"
21
+ template "Gemfile.erb", "Gemfile", force: true
22
+ Bundler.with_unbundled_env { run "bundle install" }
21
23
  invoke "flame:haml"
22
24
  rails_command "db:create"
23
25
 
@@ -26,12 +28,14 @@ module Flame
26
28
  invoke "flame:devise"
27
29
  invoke "flame:vite"
28
30
 
29
- generate("annotate:install")
30
- template ".rubocop.yml", ".rubocop.yml"
31
- template ".solargraph.yml", ".solargraph.yml"
32
- run("bundle exec standardrb --fix-unsafely")
33
- rails_command("db:migrate") if yes?("\nDo you want to run migrations? [y/n]")
31
+ if yes?("\nDo you want to run migrations? [y/n]")
32
+ rails_command("db:migrate")
33
+ generate("annotate:install")
34
+ end
34
35
  rails_command("db:seed") if yes?("\nDo you want to run seed? [y/n]")
36
+ template("rubocop.yml", ".rubocop.yml")
37
+ template("solargraph.yml", ".solargraph.yml")
38
+ run("bundle exec standardrb --fix-unsafely")
35
39
  welcome_message
36
40
 
37
41
  exit 0
@@ -2,79 +2,25 @@ require_relative "base"
2
2
 
3
3
  module Flame
4
4
  class DeviseGenerator < Generators::Base
5
- APP_CONTROLLER = <<~RUBY
6
- before_action :authenticate_user!, only: [:current]
7
- protect_from_forgery with: :exception, unless: :json_request?
8
-
9
- def current
10
- render json: current_user
11
- end
12
-
13
-
14
- private
15
-
16
- def json_request?
17
- request.format.json?
18
- end
19
- RUBY
20
-
21
- SESSION_CONTROLLER = <<~RUBY
22
- class SessionsController < Devise::SessionsController
23
- respond_to :json
24
-
25
- private
26
-
27
- def respond_with(resource, _opts = {})
28
- render json: resource
29
- end
30
-
31
- def respond_to_on_destroy
32
- head :no_content
33
- end
34
- end
35
- RUBY
36
-
37
5
  def install
38
6
  generate("devise:install")
39
7
  generate("devise", "User")
40
8
  end
41
9
 
42
- def add_timeoutable
43
- gsub_file(
44
- "app/models/user.rb",
45
- /^\s*devise\s*:[a-z_]+(?:,\s*:[a-z_]+)*\s*$/,
46
- " devise :database_authenticatable, :registerable, :timeoutable, timeout_in: 1.day"
47
- )
10
+ def custom_user_model
11
+ template("app/models/user.rb", force: true)
48
12
  end
49
13
 
50
14
  def generate_session_controller
51
- create_file(
52
- "app/controllers/sessions_controller.rb",
53
- SESSION_CONTROLLER
54
- )
15
+ template("app/controllers/sessions_controller.rb", force: true)
55
16
  end
56
17
 
57
18
  def modify_session_route
58
- gsub_file(
59
- "config/routes.rb",
60
- /devise_for\s*:\s*users/,
61
- <<~RUBY
62
- devise_for :users, defaults: {format: :json}, controllers: {sessions: "sessions"}
63
- get "/users/current", to: "application#current", defaults: {format: :json}
64
-
65
- get "*path", to: "pages#index", constraints: ->(request) do
66
- !request.xhr? && request.format.html?
67
- end
68
- RUBY
69
- )
19
+ template("config/routes.rb", force: true)
70
20
  end
71
21
 
72
22
  def modify_app_controller
73
- inject_into_class(
74
- "app/controllers/application_controller.rb",
75
- "ApplicationController",
76
- APP_CONTROLLER
77
- )
23
+ template("app/controllers/application_controller.rb", force: true)
78
24
  end
79
25
 
80
26
  def insert_secret_key
@@ -3,7 +3,7 @@ require_relative "base"
3
3
  module Flame
4
4
  class HamlGenerator < Generators::Base
5
5
  def convert_erb_to_haml
6
- run("HAML_RAILS_DELETE_ERB=true rails haml:erb2haml")
6
+ run("HAML_RAILS_DELETE_ERB=true bundle exec rails haml:erb2haml")
7
7
  end
8
8
  end
9
9
  end
data/lib/flame/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Flame
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  RUBY_VERSION = "3.2.2"
4
4
  RAILS_VERSION = "6.1.7"
5
5
  end
@@ -0,0 +1,14 @@
1
+ class ApplicationController < ActionController::Base
2
+ before_action :authenticate_user!, only: [:current]
3
+ protect_from_forgery with: :exception, unless: :json_request?
4
+
5
+ def current
6
+ render json: current_user
7
+ end
8
+
9
+ private
10
+
11
+ def json_request?
12
+ request.format.json?
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ class SessionsController < Devise::SessionsController
2
+ respond_to :json
3
+
4
+ private
5
+
6
+ def respond_with(resource, _opts = {})
7
+ render json: resource
8
+ end
9
+
10
+ def respond_to_on_destroy
11
+ head :no_content
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ class User < ApplicationRecord
2
+ devise :database_authenticatable, :registerable, :timeoutable, timeout_in: 1.day
3
+ end
@@ -0,0 +1,8 @@
1
+ Rails.application.routes.draw do
2
+ devise_for :users, defaults: {format: :json}, controllers: {sessions: "sessions"}
3
+ get "/users/current", to: "application#current", defaults: {format: :json}
4
+
5
+ get "*path", to: "pages#index", constraints: ->(request) do
6
+ !request.xhr? && request.format.html?
7
+ end
8
+ end
@@ -0,0 +1,25 @@
1
+ inherit_mode:
2
+ merge:
3
+ - Exclude
4
+ require:
5
+ - standard
6
+ # problem with block_single_line_braces solved by: https://github.com/castwide/vscode-solargraph/issues/118#issuecomment-505348192
7
+ - standard/cop/block_single_line_braces
8
+ - rubocop-performance
9
+ - rubocop-rspec
10
+ - rubocop-factory_bot
11
+ - rubocop-rails
12
+ inherit_gem:
13
+ standard: config/base.yml
14
+ standard-performance: config/base.yml
15
+ standard-custom: config/base.yml
16
+ AllCops:
17
+ SuggestExtensions: false
18
+ TargetRubyVersion: 3.2
19
+ NewCops: enable
20
+ Exclude:
21
+ - node_modules/**/*
22
+ - public/**/*
23
+ - vendor/**/*
24
+ RSpec:
25
+ Enabled: true # enable rubocop-rspec cops
@@ -0,0 +1,26 @@
1
+ ---
2
+ include:
3
+ - "**/*.rb"
4
+ - "app/**/*.rb"
5
+ - "config/**/*.rb"
6
+ - "lib/**/*.rb"
7
+ exclude:
8
+ - vendor/**/*
9
+ - ".bundle/**/*"
10
+ require:
11
+ - actioncable
12
+ - actionmailer
13
+ - actionpack
14
+ - actionview
15
+ - activejob
16
+ - activemodel
17
+ - activerecord
18
+ - activestorage
19
+ - activesupport
20
+ domains: []
21
+ reporters:
22
+ - rubocop # diagnostics
23
+ require_paths: []
24
+ plugins:
25
+ - solargraph-rails
26
+ max_files: 20000
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flamerb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - n0tbot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-13 00:00:00.000000000 Z
11
+ date: 2023-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 6.1.7
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.4'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rspec
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +66,34 @@ dependencies:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: '1.29'
69
+ - !ruby/object:Gem::Dependency
70
+ name: generator_spec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.9.4
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.9.4
83
+ - !ruby/object:Gem::Dependency
84
+ name: overcommit
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.60.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.60.0
55
97
  description: Flame is a powerful Ruby gem designed to simplify and streamline application
56
98
  development by providing a comprehensive set of tools and functionalities.
57
99
  email:
@@ -76,7 +118,11 @@ files:
76
118
  - lib/flame/generators/vite_generator.rb
77
119
  - lib/flame/version.rb
78
120
  - templates/Gemfile.erb
121
+ - templates/app/controllers/application_controller.rb
122
+ - templates/app/controllers/sessions_controller.rb
123
+ - templates/app/models/user.rb
79
124
  - templates/app/views/layouts/application.html.haml
125
+ - templates/config/routes.rb
80
126
  - templates/db/seeds.rb
81
127
  - templates/eslintrc.js
82
128
  - templates/frontend/assets/react.svg
@@ -102,6 +148,8 @@ files:
102
148
  - templates/frontend/store/slices/userSlice.js
103
149
  - templates/frontend/theme/index.js
104
150
  - templates/jsconfig.json
151
+ - templates/rubocop.yml
152
+ - templates/solargraph.yml
105
153
  - templates/spec/support/database_cleaner.rb
106
154
  - templates/spec/support/factory_bot.rb
107
155
  - templates/spec/support/shoulda_matchers.rb