next_rails_scaffold 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +12 -0
- data/.vscode/settings.json +3 -0
- data/README.md +45 -8
- data/lib/generators/next_rails/USAGE +27 -0
- data/lib/generators/next_rails/install_generator.rb +14 -0
- data/lib/generators/next_rails/templates/config/initializers/next_rails.rb +9 -0
- data/lib/generators/rails/next_rails/next_rails_generator.rb +56 -0
- data/lib/next_rails/version.rb +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18755bfa18f40bbdb7ee12fc01dbe7ab74795d5474a3549422e70a773e219545
|
4
|
+
data.tar.gz: a8fa5f99891d25e12c291541c0873e03dee707bdf44e39f93d6f1faaede8b500
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 160dfded6868506ab551eb3b02fa6ffc56d6b7d061095aee9ae432bdc42bff0fe1d0225988e12721d253ffd80b87f549874b7c751128d0831a51c6752c7f06aa
|
7
|
+
data.tar.gz: 0e1bf40f9b3d107cecef54719756999cc4ca3916004aec2470eccae24a6e26be13db88c999f9a7ff7f2e1a6604bdc76075531218e72409d510fc51f4912a15ca
|
data/.editorconfig
ADDED
data/README.md
CHANGED
@@ -1,24 +1,61 @@
|
|
1
1
|
# NextRails
|
2
2
|
|
3
|
-
|
3
|
+
The `next_rails_scaffold` gem is a powerful extension to the standard Ruby on Rails scaffold generator. It streamlines the development workflow by not only creating the backend structure with Rails but also automating the setup of a frontend directory using Next.js. Upon running the scaffold generator, this gem intelligently generates a Next.js application within the specified frontend directory.
|
4
4
|
|
5
|
-
|
5
|
+
The generated Next.js app follows best practices, including a structured page routing system, ensuring that each resource created by the scaffold has its corresponding page and components. This integration enables developers to seamlessly transition between Rails backend and Next.js frontend development, fostering a cohesive and efficient development environment.
|
6
6
|
|
7
|
-
|
7
|
+
Key Features:
|
8
|
+
|
9
|
+
- **Automatic Frontend Setup:** The gem automates the creation of a frontend directory within the Rails project, ready for Next.js development.
|
10
|
+
- **Page Routing Integration:** All scaffolded resources come with their own pages and components, organized using Next.js' page routing system.
|
11
|
+
- **Effortless Transition:** Developers can seamlessly switch between Rails backend and Next.js frontend development within the same project.
|
12
|
+
- **Boosted Productivity:** Accelerate development by eliminating the manual setup of frontend components and pages, allowing developers to focus on building features.
|
8
13
|
|
9
|
-
|
14
|
+
Integrate `next_rails_scaffold` into your Ruby on Rails projects to enjoy a streamlined, organized, and efficient full-stack development experience.
|
15
|
+
|
16
|
+
## Installation
|
10
17
|
|
11
18
|
Install the gem and add to the application's Gemfile by executing:
|
12
19
|
|
13
|
-
$ bundle add
|
20
|
+
$ bundle add next_rails_scaffold
|
14
21
|
|
15
22
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
23
|
|
17
|
-
$ gem install
|
24
|
+
$ gem install next_rails_scaffold
|
18
25
|
|
19
26
|
## Usage
|
20
27
|
|
21
|
-
|
28
|
+
The `next_rails_scaffold` gem enhances the default Ruby on Rails scaffold generator by seamlessly integrating with Next.js, a React framework. This gem automates the process of scaffolding a Rails application along with a corresponding frontend directory containing a Next.js application. The generated Next.js app includes all necessary pages and components, leveraging the power of page routing for a smooth and organized development experience.
|
29
|
+
|
30
|
+
Example:
|
31
|
+
|
32
|
+
```
|
33
|
+
bin/rails generate scaffold Post tile:string body:text
|
34
|
+
```
|
35
|
+
|
36
|
+
This will create:
|
37
|
+
|
38
|
+
```
|
39
|
+
app/
|
40
|
+
controllers/
|
41
|
+
posts_controller.rb
|
42
|
+
models/
|
43
|
+
post.rb
|
44
|
+
...
|
45
|
+
frontend/
|
46
|
+
src
|
47
|
+
pages
|
48
|
+
posts
|
49
|
+
[id]
|
50
|
+
edit.js
|
51
|
+
index.js
|
52
|
+
_components
|
53
|
+
Post.js
|
54
|
+
PostForm.js
|
55
|
+
index.js
|
56
|
+
new.js
|
57
|
+
services.js
|
58
|
+
```
|
22
59
|
|
23
60
|
## Development
|
24
61
|
|
@@ -28,7 +65,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
28
65
|
|
29
66
|
## Contributing
|
30
67
|
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
68
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/raphox/next_rails.
|
32
69
|
|
33
70
|
## License
|
34
71
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Description:
|
2
|
+
The `next_rails_scaffold` gem enhances the default Ruby on Rails scaffold generator by seamlessly integrating with Next.js, a React framework. This gem automates the process of scaffolding a Rails application along with a corresponding frontend directory containing a Next.js application. The generated Next.js app includes all necessary pages and components, leveraging the power of page routing for a smooth and organized development experience.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
bin/rails generate scaffold Post tile:string body:text
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
|
9
|
+
app/
|
10
|
+
controllers/
|
11
|
+
posts_controller.rb
|
12
|
+
models/
|
13
|
+
post.rb
|
14
|
+
...
|
15
|
+
frontend/
|
16
|
+
src
|
17
|
+
pages
|
18
|
+
posts
|
19
|
+
[id]
|
20
|
+
edit.js
|
21
|
+
index.js
|
22
|
+
_components
|
23
|
+
Post.js
|
24
|
+
PostForm.js
|
25
|
+
index.js
|
26
|
+
new.js
|
27
|
+
services.js
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NextRails
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
desc "Copy NextRails default files"
|
7
|
+
source_root File.expand_path("templates", __dir__)
|
8
|
+
|
9
|
+
def copy_config
|
10
|
+
template "config/initializers/next_rails.rb"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Rails::NextRailsGenerator < Rails::Generators::NamedBase
|
4
|
+
source_root File.expand_path("templates", __dir__)
|
5
|
+
|
6
|
+
NODE_REQUIRED_VERSION = ">= 18.17.0"
|
7
|
+
YARN_VERSION = "1.22.19"
|
8
|
+
NEXT_VERSION = "14.0.2"
|
9
|
+
|
10
|
+
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
11
|
+
|
12
|
+
def initialize(args, *options) # :nodoc:
|
13
|
+
super
|
14
|
+
self.attributes = shell.base.attributes
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_frontend_project
|
18
|
+
node_version = run("node --version", capture: true).gsub(/[^0-9.]/, "")
|
19
|
+
|
20
|
+
if Gem::Dependency.new("", NODE_REQUIRED_VERSION).match?("", node_version)
|
21
|
+
say "Your Node version is '#{node_version}'", :green
|
22
|
+
else
|
23
|
+
say_error "You need to have a Node version '#{NODE_REQUIRED_VERSION}'", :red
|
24
|
+
abort
|
25
|
+
end
|
26
|
+
|
27
|
+
append_to_file ".gitignore", "\n# Ingoring node modules for Rails and Next.js projects\nnode_modules/\n"
|
28
|
+
empty_directory "frontend"
|
29
|
+
|
30
|
+
inside("frontend") do
|
31
|
+
unless File.exist?("package.json")
|
32
|
+
system("npm install --global yarn@#{YARN_VERSION}")
|
33
|
+
system("yarn global add create-next-app@#{NEXT_VERSION}")
|
34
|
+
run("yarn create next-app . --no-app --src-dir --import-alias \"@/*\"")
|
35
|
+
end
|
36
|
+
|
37
|
+
unless Dir.exist?("_templates")
|
38
|
+
run("yarn add -D hygen hygen-add")
|
39
|
+
run("npx hygen-add next-rails-scaffold")
|
40
|
+
end
|
41
|
+
|
42
|
+
run("yarn add axios @tanstack/react-query zod react-hook-form @hookform/resolvers")
|
43
|
+
run("npx hygen generate scaffold #{name} #{mapped_attributes.join(" ")}")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def mapped_attributes
|
50
|
+
attributes.map { |attr| "#{attr.name}:#{attr.type}" }
|
51
|
+
end
|
52
|
+
|
53
|
+
def exit_on_failure?
|
54
|
+
true
|
55
|
+
end
|
56
|
+
end
|
data/lib/next_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: next_rails_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raphael Araújo
|
@@ -43,11 +43,17 @@ executables: []
|
|
43
43
|
extensions: []
|
44
44
|
extra_rdoc_files: []
|
45
45
|
files:
|
46
|
+
- ".editorconfig"
|
46
47
|
- ".rubocop.yml"
|
48
|
+
- ".vscode/settings.json"
|
47
49
|
- CHANGELOG.md
|
48
50
|
- LICENSE.txt
|
49
51
|
- README.md
|
50
52
|
- Rakefile
|
53
|
+
- lib/generators/next_rails/USAGE
|
54
|
+
- lib/generators/next_rails/install_generator.rb
|
55
|
+
- lib/generators/next_rails/templates/config/initializers/next_rails.rb
|
56
|
+
- lib/generators/rails/next_rails/next_rails_generator.rb
|
51
57
|
- lib/next_rails.rb
|
52
58
|
- lib/next_rails/version.rb
|
53
59
|
- sig/next_rails.rbs
|
@@ -58,7 +64,7 @@ metadata:
|
|
58
64
|
allowed_push_host: https://rubygems.org
|
59
65
|
homepage_uri: https://github.com/raphox/next-rails#readme
|
60
66
|
source_code_uri: https://github.com/raphox/next-rails
|
61
|
-
changelog_uri: https://github.com/raphox/next-rails/CHANGELOG.md
|
67
|
+
changelog_uri: https://github.com/raphox/next-rails/blob/main/CHANGELOG.md
|
62
68
|
post_install_message:
|
63
69
|
rdoc_options: []
|
64
70
|
require_paths:
|
@@ -74,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
80
|
- !ruby/object:Gem::Version
|
75
81
|
version: '0'
|
76
82
|
requirements: []
|
77
|
-
rubygems_version: 3.
|
83
|
+
rubygems_version: 3.3.7
|
78
84
|
signing_key:
|
79
85
|
specification_version: 4
|
80
86
|
summary: The `next_rails_scaffold` gem enhances the default Ruby on Rails scaffold
|