m9sh 0.1.0 → 0.2.0

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +2 -1
  3. data/GEM_README.md +284 -0
  4. data/LICENSE.txt +21 -0
  5. data/M9SH_CLI.md +453 -0
  6. data/PUBLISHING.md +331 -0
  7. data/README.md +120 -52
  8. data/app/components/m9sh/accordion_component.rb +3 -3
  9. data/app/components/m9sh/alert_component.rb +7 -9
  10. data/app/components/m9sh/base_component.rb +1 -0
  11. data/app/components/m9sh/button_component.rb +3 -2
  12. data/app/components/m9sh/color_customizer_component.rb +624 -0
  13. data/app/components/m9sh/dialog_close_component.rb +30 -0
  14. data/app/components/m9sh/dialog_component.rb +11 -99
  15. data/app/components/m9sh/dialog_content_component.rb +102 -0
  16. data/app/components/m9sh/dialog_description_component.rb +14 -0
  17. data/app/components/m9sh/dialog_footer_component.rb +14 -0
  18. data/app/components/m9sh/dialog_header_component.rb +27 -0
  19. data/app/components/m9sh/dialog_title_component.rb +14 -0
  20. data/app/components/m9sh/dialog_trigger_component.rb +23 -0
  21. data/app/components/m9sh/dropdown_menu_content_component.rb +1 -1
  22. data/app/components/m9sh/dropdown_menu_item_component.rb +1 -1
  23. data/app/components/m9sh/dropdown_menu_trigger_component.rb +1 -1
  24. data/app/components/m9sh/icon_component.rb +78 -0
  25. data/app/components/m9sh/main_component.rb +1 -1
  26. data/app/components/m9sh/menu_component.rb +85 -0
  27. data/app/components/m9sh/navbar_component.rb +186 -0
  28. data/app/components/m9sh/navigation_menu_component.rb +2 -2
  29. data/app/components/m9sh/popover_component.rb +12 -7
  30. data/app/components/m9sh/radio_group_component.rb +45 -13
  31. data/app/components/m9sh/sheet_component.rb +6 -6
  32. data/app/components/m9sh/sidebar_component.rb +6 -1
  33. data/app/components/m9sh/skeleton_component.rb +7 -1
  34. data/app/components/m9sh/tabs_component.rb +76 -48
  35. data/app/components/m9sh/textarea_component.rb +1 -1
  36. data/app/components/m9sh/theme_toggle_component.rb +1 -0
  37. data/app/javascript/controllers/m9sh/popover_controller.js +24 -18
  38. data/app/javascript/controllers/m9sh/sidebar_controller.js +29 -7
  39. data/lib/m9sh/config.rb +5 -5
  40. data/lib/m9sh/registry.rb +2 -2
  41. data/lib/m9sh/registry.yml +37 -0
  42. data/lib/m9sh/version.rb +1 -1
  43. data/lib/tasks/tailwindcss.rake +15 -0
  44. data/m9sh.gemspec +48 -0
  45. data/publish.sh +48 -0
  46. metadata +20 -3
  47. data/fix_namespaces.py +0 -32
data/M9SH_CLI.md ADDED
@@ -0,0 +1,453 @@
1
+ # M9sh CLI - Component Generator
2
+
3
+ A powerful CLI tool for generating and managing M9sh components, inspired by shadcn/ui CLI.
4
+
5
+ ## Features
6
+
7
+ - 🎨 **Component Generation** - Generate individual components or all at once
8
+ - 📦 **Dependency Management** - Automatically resolves and installs dependencies
9
+ - 🔧 **Customizable** - Override namespace, paths, and other settings
10
+ - 🔄 **Sync Components** - Update existing components to latest versions
11
+ - 📋 **Component Registry** - Browse all available components
12
+ - ⚙️ **YAML Configuration** - Project-specific configuration via `m9sh.yml`
13
+
14
+ ## Installation
15
+
16
+ The CLI is already included in this project. Simply run:
17
+
18
+ ```bash
19
+ bundle install
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ### 1. Initialize Configuration
25
+
26
+ ```bash
27
+ bin/m9sh init
28
+ ```
29
+
30
+ This will create an interactive setup to configure:
31
+ - Component namespace (e.g., `M9sh`, `MyApp::UI`)
32
+ - Components directory path
33
+ - JavaScript controllers path
34
+ - Tailwind and CSS file paths
35
+
36
+ Non-interactive initialization:
37
+
38
+ ```bash
39
+ bin/m9sh init --interactive=false \
40
+ --namespace=MyComponents \
41
+ --components_path=app/components/ui \
42
+ --javascript_path=app/javascript/controllers/ui
43
+ ```
44
+
45
+ ### 2. List Available Components
46
+
47
+ ```bash
48
+ bin/m9sh list
49
+ ```
50
+
51
+ Show only installed components:
52
+
53
+ ```bash
54
+ bin/m9sh list -i
55
+ ```
56
+
57
+ Show only available (not installed) components:
58
+
59
+ ```bash
60
+ bin/m9sh list -a
61
+ ```
62
+
63
+ ### 3. Add a Component
64
+
65
+ ```bash
66
+ bin/m9sh add button
67
+ ```
68
+
69
+ This will:
70
+ - Install the `button` component
71
+ - Automatically install dependencies (`base`, `utilities`)
72
+ - Copy files to configured directories
73
+ - Transform namespaces if custom namespace is set
74
+
75
+ Add multiple components:
76
+
77
+ ```bash
78
+ bin/m9sh add button
79
+ bin/m9sh add card
80
+ bin/m9sh add dialog
81
+ ```
82
+
83
+ Add all components:
84
+
85
+ ```bash
86
+ bin/m9sh add --all
87
+ ```
88
+
89
+ ### 4. Get Component Information
90
+
91
+ ```bash
92
+ bin/m9sh info button
93
+ ```
94
+
95
+ Shows:
96
+ - Component description
97
+ - Installation status
98
+ - Dependencies
99
+ - Files that will be generated
100
+
101
+ ### 5. Sync Components
102
+
103
+ Update a component to the latest version:
104
+
105
+ ```bash
106
+ bin/m9sh sync button
107
+ ```
108
+
109
+ Sync all components:
110
+
111
+ ```bash
112
+ bin/m9sh sync --all
113
+ ```
114
+
115
+ ## Commands Reference
116
+
117
+ ### `init`
118
+
119
+ Initialize M9sh configuration.
120
+
121
+ **Options:**
122
+ - `--interactive` / `-i` - Interactive setup (default: true)
123
+ - `--namespace` - Component namespace
124
+ - `--components_path` - Path to components directory
125
+ - `--javascript_path` - Path to JavaScript controllers
126
+
127
+ **Examples:**
128
+
129
+ ```bash
130
+ # Interactive setup
131
+ bin/m9sh init
132
+
133
+ # Non-interactive with defaults
134
+ bin/m9sh init --interactive=false
135
+
136
+ # Custom configuration
137
+ bin/m9sh init --interactive=false \
138
+ --namespace=MyApp::Components \
139
+ --components_path=app/components/myapp \
140
+ --javascript_path=app/javascript/controllers/myapp
141
+ ```
142
+
143
+ ### `add COMPONENT`
144
+
145
+ Add a component with its dependencies.
146
+
147
+ **Options:**
148
+ - `--namespace` - Override namespace from config
149
+ - `--components_path` - Override components path
150
+ - `--javascript_path` - Override JavaScript path
151
+ - `--force` / `-f` - Overwrite existing files
152
+ - `--all` - Install all components
153
+
154
+ **Examples:**
155
+
156
+ ```bash
157
+ # Add single component
158
+ bin/m9sh add button
159
+
160
+ # Add with force (overwrite)
161
+ bin/m9sh add button --force
162
+
163
+ # Add with custom namespace
164
+ bin/m9sh add button --namespace=CustomNamespace
165
+
166
+ # Add all components
167
+ bin/m9sh add --all
168
+ ```
169
+
170
+ ### `list`
171
+
172
+ List all available components.
173
+
174
+ **Options:**
175
+ - `--installed` / `-i` - Show only installed components
176
+ - `--available` / `-a` - Show only available components
177
+
178
+ **Examples:**
179
+
180
+ ```bash
181
+ # List all
182
+ bin/m9sh list
183
+
184
+ # Only installed
185
+ bin/m9sh list -i
186
+
187
+ # Only available
188
+ bin/m9sh list -a
189
+ ```
190
+
191
+ ### `sync COMPONENT`
192
+
193
+ Update a component to the latest version.
194
+
195
+ **Options:**
196
+ - `--all` - Sync all components
197
+ - `--namespace` - Override namespace from config
198
+ - `--components_path` - Override components path
199
+ - `--javascript_path` - Override JavaScript path
200
+
201
+ **Examples:**
202
+
203
+ ```bash
204
+ # Sync single component
205
+ bin/m9sh sync button
206
+
207
+ # Sync all
208
+ bin/m9sh sync --all
209
+ ```
210
+
211
+ ### `info COMPONENT`
212
+
213
+ Show information about a component.
214
+
215
+ **Examples:**
216
+
217
+ ```bash
218
+ bin/m9sh info button
219
+ bin/m9sh info accordion
220
+ ```
221
+
222
+ ### `version`
223
+
224
+ Show M9sh CLI version.
225
+
226
+ ```bash
227
+ bin/m9sh version
228
+ ```
229
+
230
+ ## Configuration File
231
+
232
+ The `m9sh.yml` file stores your project configuration:
233
+
234
+ ```yaml
235
+ ---
236
+ namespace: M9sh
237
+ components_path: app/components/m9sh
238
+ javascript_path: app/javascript/controllers/m9sh
239
+ tailwind_config: tailwind.config.js
240
+ css_file: app/assets/stylesheets/application.tailwind.css
241
+ style: default
242
+ ```
243
+
244
+ ### Configuration Options
245
+
246
+ - **namespace**: The Ruby module namespace for components (e.g., `M9sh`, `MyApp::UI`)
247
+ - **components_path**: Directory where component Ruby files are generated
248
+ - **javascript_path**: Directory where Stimulus controller files are generated
249
+ - **tailwind_config**: Path to Tailwind configuration file
250
+ - **css_file**: Path to main CSS file
251
+ - **style**: Component style variant (currently only `default`)
252
+
253
+ ## Available Components
254
+
255
+ ### Base Components
256
+ - **base** - Base component class
257
+ - **utilities** - Helper module for class names
258
+
259
+ ### Form Components
260
+ - **button** - Button with variants (default, outline, ghost, destructive, etc.)
261
+ - **input** - Text input
262
+ - **label** - Form label
263
+ - **checkbox** - Checkbox input
264
+ - **textarea** - Multi-line text input
265
+ - **select** - Dropdown select
266
+ - **switch** - Toggle switch (with Stimulus)
267
+ - **slider** - Slider input (with Stimulus)
268
+ - **radio_group** - Radio button group (with Stimulus)
269
+
270
+ ### Layout Components
271
+ - **card** - Container with header, body, footer
272
+ - **table** - Styled table
273
+ - **separator** - Horizontal/vertical separator
274
+ - **main** - Main content wrapper
275
+
276
+ ### Feedback Components
277
+ - **alert** - Alert notifications
278
+ - **toast** - Toast notifications (with Stimulus)
279
+ - **toaster** - Toast container (with Stimulus)
280
+ - **progress** - Progress bar
281
+ - **spinner** - Loading spinner
282
+ - **skeleton** - Loading skeleton
283
+
284
+ ### Navigation Components
285
+ - **breadcrumb** - Breadcrumb navigation
286
+ - **navigation_menu** - Navigation menu (with Stimulus)
287
+ - **sidebar** - Sidebar navigation (with Stimulus)
288
+ - **tabs** - Tab navigation (with Stimulus)
289
+
290
+ ### Display Components
291
+ - **avatar** - User avatar
292
+ - **badge** - Status badge
293
+ - **typography** - Typography styles
294
+
295
+ ### Interactive Components
296
+ - **accordion** - Collapsible accordion (with Stimulus)
297
+ - **dialog** - Modal dialog (with Stimulus)
298
+ - **alert_dialog** - Confirmation dialog (with Stimulus)
299
+ - **sheet** - Side sheet (with Stimulus)
300
+ - **tooltip** - Tooltip (with Stimulus)
301
+ - **popover** - Popover (with Stimulus)
302
+ - **hover_card** - Hover card (with Stimulus)
303
+ - **collapsible** - Collapsible section (with Stimulus)
304
+ - **dropdown_menu** - Dropdown menu (with Stimulus)
305
+ - **toggle** - Toggle button (with Stimulus)
306
+
307
+ ### Theme Components
308
+ - **theme_toggle** - Dark/light theme toggle
309
+
310
+ ## How It Works
311
+
312
+ ### Component Registry
313
+
314
+ The CLI uses `lib/m9sh/registry.yml` to define all available components, their dependencies, and file locations.
315
+
316
+ ### Dependency Resolution
317
+
318
+ When you add a component, the CLI automatically:
319
+ 1. Resolves all dependencies recursively
320
+ 2. Installs dependencies in correct order
321
+ 3. Copies component files
322
+ 4. Transforms namespaces if needed
323
+
324
+ For example, adding `button` will also install:
325
+ - `base` (base component class)
326
+ - `utilities` (helper module)
327
+
328
+ ### Namespace Transformation
329
+
330
+ If you use a custom namespace (e.g., `MyApp::Components`), the CLI automatically:
331
+ - Transforms module declarations: `module M9sh` → `module MyApp::Components`
332
+ - Updates class names: `M9sh::ButtonComponent` → `MyApp::Components::ButtonComponent`
333
+ - Updates Stimulus controller identifiers: `m9sh--button` → `myapp-components--button`
334
+ - Updates data attributes accordingly
335
+
336
+ ## Examples
337
+
338
+ ### Example 1: Start a New Project
339
+
340
+ ```bash
341
+ # Initialize with defaults
342
+ bin/m9sh init
343
+
344
+ # Add core components
345
+ bin/m9sh add button
346
+ bin/m9sh add card
347
+ bin/m9sh add input
348
+
349
+ # Check what's installed
350
+ bin/m9sh list -i
351
+ ```
352
+
353
+ ### Example 2: Custom Namespace
354
+
355
+ ```bash
356
+ # Initialize with custom namespace
357
+ bin/m9sh init --interactive=false \
358
+ --namespace=MyApp::UI \
359
+ --components_path=app/components/myapp/ui \
360
+ --javascript_path=app/javascript/controllers/myapp/ui
361
+
362
+ # Add components
363
+ bin/m9sh add button
364
+ bin/m9sh add dialog
365
+ ```
366
+
367
+ Result in `app/components/myapp/ui/button_component.rb`:
368
+ ```ruby
369
+ module MyApp
370
+ module UI
371
+ class ButtonComponent < BaseComponent
372
+ # ...
373
+ end
374
+ end
375
+ end
376
+ ```
377
+
378
+ ### Example 3: Sync All Components
379
+
380
+ ```bash
381
+ # Update all components to latest version
382
+ bin/m9sh sync --all
383
+ ```
384
+
385
+ ## Troubleshooting
386
+
387
+ ### "Configuration not found"
388
+
389
+ Run `bin/m9sh init` first to create the configuration file.
390
+
391
+ ### "Component not found in registry"
392
+
393
+ Check available components with `bin/m9sh list` or verify the component name.
394
+
395
+ ### "Source file not found"
396
+
397
+ This happens when:
398
+ - You're not in the project root directory
399
+ - The source components don't exist in `app/components/m9sh/`
400
+
401
+ ### Overwrite Existing Files
402
+
403
+ Use the `--force` flag:
404
+
405
+ ```bash
406
+ bin/m9sh add button --force
407
+ # or
408
+ bin/m9sh sync button
409
+ ```
410
+
411
+ ## Development
412
+
413
+ ### Adding New Components to Registry
414
+
415
+ Edit `lib/m9sh/registry.yml`:
416
+
417
+ ```yaml
418
+ components:
419
+ my_component:
420
+ name: "My Component"
421
+ description: "Description here"
422
+ files:
423
+ - app/components/m9sh/my_component.rb
424
+ - app/javascript/controllers/m9sh/my_component_controller.js
425
+ dependencies:
426
+ - base
427
+ - utilities
428
+ ```
429
+
430
+ ### Registry File Structure
431
+
432
+ ```yaml
433
+ components:
434
+ component_key:
435
+ name: "Display Name"
436
+ description: "Component description"
437
+ files: # List of files to copy
438
+ - path/to/component.rb
439
+ - path/to/controller.js
440
+ dependencies: # Components that must be installed first
441
+ - base
442
+ - another_component
443
+ ```
444
+
445
+ ## License
446
+
447
+ MIT License - See LICENSE file for details.
448
+
449
+ ## Credits
450
+
451
+ - Inspired by [shadcn/ui](https://ui.shadcn.com)
452
+ - Built with [Thor](https://github.com/rails/thor)
453
+ - Part of the M9sh component library