fernandes-ui 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +61 -61
- data/app/assets/stylesheets/ui/application.css +621 -3
- data/lib/generators/ui/css_generator.rb +58 -0
- data/lib/generators/ui/install_generator.rb +140 -0
- data/lib/ui/version.rb +1 -1
- metadata +3 -3
- data/app/assets/stylesheets/ui/sonner.css +0 -610
- data/lib/generators/ui/install/install_generator.rb +0 -141
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ui
|
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
|
5
|
+
source_root File.expand_path("install/templates", __dir__)
|
|
6
|
+
|
|
7
|
+
def detect_asset_pipeline
|
|
8
|
+
@asset_pipeline = if defined?(Propshaft)
|
|
9
|
+
:propshaft
|
|
10
|
+
elsif defined?(Sprockets)
|
|
11
|
+
:sprockets
|
|
12
|
+
else
|
|
13
|
+
:unknown
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
@js_bundler = if File.exist?(Rails.root.join("config/importmap.rb"))
|
|
17
|
+
:importmap
|
|
18
|
+
elsif File.exist?(Rails.root.join("package.json"))
|
|
19
|
+
:node
|
|
20
|
+
else
|
|
21
|
+
:none
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def show_asset_pipeline_info
|
|
26
|
+
say "\nDetecting your setup...\n", :yellow
|
|
27
|
+
say " Asset pipeline: #{@asset_pipeline}", :green
|
|
28
|
+
say " JavaScript bundler: #{@js_bundler}", :green
|
|
29
|
+
say "\n"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def install_tailwind_css
|
|
33
|
+
say "Installing Tailwind CSS 4...\n", :yellow
|
|
34
|
+
|
|
35
|
+
# Create Tailwind CSS config file
|
|
36
|
+
template "application.tailwind.css", Rails.root.join("app/assets/stylesheets/application.tailwind.css")
|
|
37
|
+
|
|
38
|
+
# Create builds directory
|
|
39
|
+
create_file Rails.root.join("app/assets/builds/.keep")
|
|
40
|
+
|
|
41
|
+
# Add to gitignore
|
|
42
|
+
append_to_file Rails.root.join(".gitignore"), "\n# Compiled CSS\n/app/assets/builds/**/*.css\n"
|
|
43
|
+
|
|
44
|
+
say " Created app/assets/stylesheets/application.tailwind.css", :green
|
|
45
|
+
say " Created app/assets/builds directory", :green
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def install_package_json
|
|
49
|
+
if @js_bundler == :node || !File.exist?(Rails.root.join("package.json"))
|
|
50
|
+
say "\nSetting up package.json...\n", :yellow
|
|
51
|
+
template "package.json", Rails.root.join("package.json")
|
|
52
|
+
say " Created package.json with Tailwind CLI", :green
|
|
53
|
+
else
|
|
54
|
+
say "\nUpdating existing package.json...\n", :yellow
|
|
55
|
+
say " Please add Tailwind scripts to your package.json manually", :yellow
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def install_procfile
|
|
60
|
+
if !File.exist?(Rails.root.join("Procfile.dev"))
|
|
61
|
+
say "\nSetting up Procfile.dev...\n", :yellow
|
|
62
|
+
template "Procfile.dev", Rails.root.join("Procfile.dev")
|
|
63
|
+
say " Created Procfile.dev", :green
|
|
64
|
+
else
|
|
65
|
+
say "\n Procfile.dev already exists, skipping", :yellow
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def install_javascript
|
|
70
|
+
case @js_bundler
|
|
71
|
+
when :importmap
|
|
72
|
+
install_importmap_javascript
|
|
73
|
+
when :node
|
|
74
|
+
install_node_javascript
|
|
75
|
+
else
|
|
76
|
+
say "\nNo JavaScript bundler detected", :yellow
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def show_next_steps
|
|
81
|
+
say "\n"
|
|
82
|
+
say "=" * 60, :green
|
|
83
|
+
say "UI Engine installed successfully!", :green
|
|
84
|
+
say "=" * 60, :green
|
|
85
|
+
say "\n"
|
|
86
|
+
say "Next steps:\n", :yellow
|
|
87
|
+
say "\n"
|
|
88
|
+
|
|
89
|
+
say " 1. Install dependencies:", :cyan
|
|
90
|
+
say " $ bun install\n", :white
|
|
91
|
+
say "\n"
|
|
92
|
+
|
|
93
|
+
say " 2. Build Tailwind CSS:", :cyan
|
|
94
|
+
say " $ bun run build:css\n", :white
|
|
95
|
+
say "\n"
|
|
96
|
+
|
|
97
|
+
say " 3. Update your layout file to include:", :cyan
|
|
98
|
+
say " <%= stylesheet_link_tag 'application' %>\n", :white
|
|
99
|
+
say "\n"
|
|
100
|
+
|
|
101
|
+
if @js_bundler == :importmap
|
|
102
|
+
say " 4. Import UI Engine in your JavaScript:", :cyan
|
|
103
|
+
say " import UI from 'ui'\n", :white
|
|
104
|
+
say " UI.init()\n", :white
|
|
105
|
+
say "\n"
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
say " 5. Start development with:", :cyan
|
|
109
|
+
say " $ bin/dev\n", :white
|
|
110
|
+
say "\n"
|
|
111
|
+
|
|
112
|
+
say "=" * 60, :green
|
|
113
|
+
say "Documentation: https://github.com/your-repo/ui", :cyan
|
|
114
|
+
say "=" * 60, :green
|
|
115
|
+
say "\n"
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
private
|
|
119
|
+
|
|
120
|
+
def install_importmap_javascript
|
|
121
|
+
say "\nConfiguring importmap...\n", :yellow
|
|
122
|
+
|
|
123
|
+
# Add UI engine pin to the host app's importmap
|
|
124
|
+
if File.exist?(Rails.root.join("config/importmap.rb"))
|
|
125
|
+
append_to_file Rails.root.join("config/importmap.rb"), <<~RUBY
|
|
126
|
+
|
|
127
|
+
# UI Engine
|
|
128
|
+
pin "ui", to: "ui/index.js"
|
|
129
|
+
RUBY
|
|
130
|
+
say " Added 'ui' pin to config/importmap.rb", :green
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def install_node_javascript
|
|
135
|
+
say "\nNode.js setup detected\n", :yellow
|
|
136
|
+
say " UI Engine JavaScript is available in the gem", :cyan
|
|
137
|
+
say " Import it in your JavaScript bundle as needed", :cyan
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
data/lib/ui/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fernandes-ui
|
|
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
|
- Celso Fernandes
|
|
@@ -100,7 +100,6 @@ files:
|
|
|
100
100
|
- app/assets/javascripts/ui.esm.js
|
|
101
101
|
- app/assets/javascripts/ui.js
|
|
102
102
|
- app/assets/stylesheets/ui/application.css
|
|
103
|
-
- app/assets/stylesheets/ui/sonner.css
|
|
104
103
|
- app/behaviors/ui/accordion_behavior.rb
|
|
105
104
|
- app/behaviors/ui/accordion_content_behavior.rb
|
|
106
105
|
- app/behaviors/ui/accordion_item_behavior.rb
|
|
@@ -1176,10 +1175,11 @@ files:
|
|
|
1176
1175
|
- config/importmap.rb
|
|
1177
1176
|
- config/routes.rb
|
|
1178
1177
|
- lib/fernandes-ui.rb
|
|
1179
|
-
- lib/generators/ui/
|
|
1178
|
+
- lib/generators/ui/css_generator.rb
|
|
1180
1179
|
- lib/generators/ui/install/templates/Procfile.dev
|
|
1181
1180
|
- lib/generators/ui/install/templates/application.tailwind.css
|
|
1182
1181
|
- lib/generators/ui/install/templates/package.json
|
|
1182
|
+
- lib/generators/ui/install_generator.rb
|
|
1183
1183
|
- lib/tasks/ui_tasks.rake
|
|
1184
1184
|
- lib/ui.rb
|
|
1185
1185
|
- lib/ui/configuration.rb
|