@mova-ui/react 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 (299) hide show
  1. package/README.md +68 -21
  2. package/bin/mova.mjs +22 -7
  3. package/dist/styles.css +131 -1
  4. package/package.json +62 -14
  5. package/registry/1.json +14 -0
  6. package/registry/10.json +14 -0
  7. package/registry/11.json +14 -0
  8. package/registry/12.json +14 -0
  9. package/registry/13.json +14 -0
  10. package/registry/14.json +14 -0
  11. package/registry/15.json +14 -0
  12. package/registry/16.json +14 -0
  13. package/registry/17.json +14 -0
  14. package/registry/18.json +14 -0
  15. package/registry/19.json +14 -0
  16. package/registry/2.json +14 -0
  17. package/registry/20.json +14 -0
  18. package/registry/21.json +14 -0
  19. package/registry/22.json +14 -0
  20. package/registry/23.json +14 -0
  21. package/registry/24.json +14 -0
  22. package/registry/25.json +14 -0
  23. package/registry/26.json +14 -0
  24. package/registry/27.json +14 -0
  25. package/registry/28.json +14 -0
  26. package/registry/29.json +14 -0
  27. package/registry/3.json +14 -0
  28. package/registry/30.json +14 -0
  29. package/registry/31.json +14 -0
  30. package/registry/32.json +14 -0
  31. package/registry/33.json +14 -0
  32. package/registry/34.json +14 -0
  33. package/registry/35.json +14 -0
  34. package/registry/36.json +11 -0
  35. package/registry/37.json +11 -0
  36. package/registry/4.json +14 -0
  37. package/registry/5.json +14 -0
  38. package/registry/6.json +14 -0
  39. package/registry/7.json +14 -0
  40. package/registry/8.json +14 -0
  41. package/registry/9.json +14 -0
  42. package/registry/LICENSE.third-party +283 -0
  43. package/registry/ab-segmented-tabs.json +14 -0
  44. package/registry/accordion-blind.json +14 -0
  45. package/registry/analyzing-image.json +13 -0
  46. package/registry/animated-sidebar.json +14 -0
  47. package/registry/animated-tags.json +14 -0
  48. package/registry/blur-up-char.json +14 -0
  49. package/registry/blur-up-word.json +14 -0
  50. package/registry/bookmark-corner-peel.json +14 -0
  51. package/registry/bookmark-save-pill.json +14 -0
  52. package/registry/bookmark-toggle.json +14 -0
  53. package/registry/border-trail-loading.json +13 -0
  54. package/registry/bounce-in-char.json +14 -0
  55. package/registry/btn-1.json +14 -0
  56. package/registry/btn-10.json +14 -0
  57. package/registry/btn-11.json +14 -0
  58. package/registry/btn-12.json +14 -0
  59. package/registry/btn-13.json +14 -0
  60. package/registry/btn-14.json +14 -0
  61. package/registry/btn-15.json +14 -0
  62. package/registry/btn-16.json +14 -0
  63. package/registry/btn-17.json +14 -0
  64. package/registry/btn-18.json +14 -0
  65. package/registry/btn-19.json +14 -0
  66. package/registry/btn-2.json +14 -0
  67. package/registry/btn-20.json +14 -0
  68. package/registry/btn-21.json +14 -0
  69. package/registry/btn-22.json +14 -0
  70. package/registry/btn-23.json +14 -0
  71. package/registry/btn-24.json +14 -0
  72. package/registry/btn-25.json +14 -0
  73. package/registry/btn-26.json +14 -0
  74. package/registry/btn-27.json +14 -0
  75. package/registry/btn-28.json +14 -0
  76. package/registry/btn-29.json +14 -0
  77. package/registry/btn-3.json +14 -0
  78. package/registry/btn-30.json +14 -0
  79. package/registry/btn-31.json +14 -0
  80. package/registry/btn-32.json +14 -0
  81. package/registry/btn-33.json +14 -0
  82. package/registry/btn-34.json +14 -0
  83. package/registry/btn-35.json +14 -0
  84. package/registry/btn-36.json +11 -0
  85. package/registry/btn-37.json +11 -0
  86. package/registry/btn-4.json +14 -0
  87. package/registry/btn-5.json +14 -0
  88. package/registry/btn-6.json +14 -0
  89. package/registry/btn-7.json +14 -0
  90. package/registry/btn-8.json +14 -0
  91. package/registry/btn-9.json +14 -0
  92. package/registry/button-slide-arrow.json +14 -0
  93. package/registry/cacheable-bandwidth-cost.json +14 -0
  94. package/registry/card-arc-5.json +13 -0
  95. package/registry/card-arc-7.json +13 -0
  96. package/registry/card-carousel-mono.json +14 -0
  97. package/registry/card-carousel.json +14 -0
  98. package/registry/card-cascade-stagger.json +13 -0
  99. package/registry/card-corner-fan.json +13 -0
  100. package/registry/card-cover-flow-mono.json +14 -0
  101. package/registry/card-cover-flow.json +14 -0
  102. package/registry/card-deck-cascade.json +14 -0
  103. package/registry/card-glance-preview.json +14 -0
  104. package/registry/card-linear-spread.json +13 -0
  105. package/registry/card-long-arc-5.json +13 -0
  106. package/registry/card-scatter-spread.json +13 -0
  107. package/registry/card-stack-peel.json +14 -0
  108. package/registry/card-stamp-arc.json +13 -0
  109. package/registry/card-time-machine-mono.json +13 -0
  110. package/registry/card-time-machine.json +13 -0
  111. package/registry/card-wheel-fan.json +13 -0
  112. package/registry/category-select.json +14 -0
  113. package/registry/checkbox-draw.json +14 -0
  114. package/registry/checkmark-draw.json +14 -0
  115. package/registry/circle-toggle.json +14 -0
  116. package/registry/circuit-trace-draw.json +14 -0
  117. package/registry/circular-create-button.json +11 -0
  118. package/registry/compass-needle-deflect.json +14 -0
  119. package/registry/context-menu.json +14 -0
  120. package/registry/credit-score-barcode-meter.json +14 -0
  121. package/registry/date-position-selector.json +14 -0
  122. package/registry/dia-text-reveal.json +14 -0
  123. package/registry/dislike-toggle.json +14 -0
  124. package/registry/dither-book.json +14 -0
  125. package/registry/domino-cascade.json +14 -0
  126. package/registry/double-bounce-toggle.json +14 -0
  127. package/registry/download-icons.json +14 -0
  128. package/registry/drop-in-char.json +14 -0
  129. package/registry/droplet-squish.json +14 -0
  130. package/registry/dual-magnet-dipole.json +14 -0
  131. package/registry/elastic-tag-snap.json +14 -0
  132. package/registry/error-shake.json +14 -0
  133. package/registry/expanding-icon-tabs.json +13 -0
  134. package/registry/fade-in-char.json +14 -0
  135. package/registry/fade-in-text.json +14 -0
  136. package/registry/fade-in-word.json +14 -0
  137. package/registry/file-upload-dropzone.json +14 -0
  138. package/registry/filter-tag-pill.json +14 -0
  139. package/registry/flip-x-char.json +14 -0
  140. package/registry/flip-y-char.json +14 -0
  141. package/registry/float-char.json +14 -0
  142. package/registry/float-word.json +14 -0
  143. package/registry/floating-label-input.json +14 -0
  144. package/registry/focus-blur.json +13 -0
  145. package/registry/form-submit-button.json +14 -0
  146. package/registry/french-doors-3d.json +13 -0
  147. package/registry/gear-tooth-step.json +14 -0
  148. package/registry/gelatin-wobble.json +14 -0
  149. package/registry/geometric-iris-shutter.json +14 -0
  150. package/registry/glow-text.json +14 -0
  151. package/registry/gooey-popover.json +13 -0
  152. package/registry/gradient-shimmer.json +13 -0
  153. package/registry/hex-lattice-draw.json +14 -0
  154. package/registry/hover-lift-char.json +14 -0
  155. package/registry/hover-lift-word.json +14 -0
  156. package/registry/hover-link-card.json +14 -0
  157. package/registry/hover-scale-char.json +14 -0
  158. package/registry/hover-scale-word.json +14 -0
  159. package/registry/inertia-skid-stop.json +14 -0
  160. package/registry/input-focus-glow.json +14 -0
  161. package/registry/inset-action-button.json +11 -0
  162. package/registry/inset-button.json +12 -0
  163. package/registry/kinetic-metronome-tick.json +14 -0
  164. package/registry/kinetic-tension-capsule.json +14 -0
  165. package/registry/light-dark-morph.json +14 -0
  166. package/registry/like-toggle.json +14 -0
  167. package/registry/magnetic-disks.json +14 -0
  168. package/registry/magnetic-slide-btn.json +14 -0
  169. package/registry/matrix-grid-loader.json +14 -0
  170. package/registry/modular-tile-snap.json +14 -0
  171. package/registry/mono-activity-blue.json +13 -0
  172. package/registry/mono-activity-green.json +13 -0
  173. package/registry/mono-activity-purple.json +13 -0
  174. package/registry/mono-heatmap.json +14 -0
  175. package/registry/mono-rounded-area.json +13 -0
  176. package/registry/mono-rounded-bar.json +13 -0
  177. package/registry/mono-rounded-bubble.json +13 -0
  178. package/registry/mono-rounded-bullet.json +11 -0
  179. package/registry/mono-rounded-candlestick.json +11 -0
  180. package/registry/mono-rounded-composed.json +13 -0
  181. package/registry/mono-rounded-donut.json +13 -0
  182. package/registry/mono-rounded-funnel.json +13 -0
  183. package/registry/mono-rounded-gauge-arc.json +13 -0
  184. package/registry/mono-rounded-heatmap.json +11 -0
  185. package/registry/mono-rounded-kpi.json +13 -0
  186. package/registry/mono-rounded-line.json +13 -0
  187. package/registry/mono-rounded-meter.json +13 -0
  188. package/registry/mono-rounded-polar.json +13 -0
  189. package/registry/mono-rounded-pyramid.json +11 -0
  190. package/registry/mono-rounded-radar.json +13 -0
  191. package/registry/mono-rounded-radial-gauge.json +13 -0
  192. package/registry/mono-rounded-radial-group.json +13 -0
  193. package/registry/mono-rounded-range.json +13 -0
  194. package/registry/mono-rounded-sankey.json +11 -0
  195. package/registry/mono-rounded-scatter.json +13 -0
  196. package/registry/mono-rounded-sparkline.json +13 -0
  197. package/registry/mono-rounded-stacked-bar.json +13 -0
  198. package/registry/mono-rounded-step.json +13 -0
  199. package/registry/mono-rounded-stream.json +13 -0
  200. package/registry/mono-rounded-treemap.json +11 -0
  201. package/registry/mono-rounded-waterfall.json +13 -0
  202. package/registry/mono-stock.json +14 -0
  203. package/registry/morph-action-pill.json +14 -0
  204. package/registry/morph-toggle.json +14 -0
  205. package/registry/multi-select-chips.json +14 -0
  206. package/registry/multi-tab-bar.json +14 -0
  207. package/registry/neon-sign-draw.json +14 -0
  208. package/registry/nested-orbital-gimbal.json +14 -0
  209. package/registry/network-telemetry-matrix.json +14 -0
  210. package/registry/noise-decibel-level.json +14 -0
  211. package/registry/obsidian-liquid-wave.json +11 -0
  212. package/registry/origami-envelope-unfold.json +14 -0
  213. package/registry/otp-input.json +14 -0
  214. package/registry/overview-bar-scrubber-card.json +14 -0
  215. package/registry/page-turn-curl.json +14 -0
  216. package/registry/password-toggle.json +14 -0
  217. package/registry/pendulum-bubble-level.json +14 -0
  218. package/registry/perspective-flip-stage.json +13 -0
  219. package/registry/perspective-flip.json +13 -0
  220. package/registry/perspective-layout-switcher.json +14 -0
  221. package/registry/physics-dock.json +14 -0
  222. package/registry/pill-tabs.json +14 -0
  223. package/registry/plus-minus-toggle.json +14 -0
  224. package/registry/prism-block-stack.json +14 -0
  225. package/registry/progress-indicator-piano.json +14 -0
  226. package/registry/progress-stepper.json +14 -0
  227. package/registry/pulse-char.json +14 -0
  228. package/registry/pulse-word.json +14 -0
  229. package/registry/pyramid-block-build.json +14 -0
  230. package/registry/radial-iris-mask.json +13 -0
  231. package/registry/radial-spinner.json +14 -0
  232. package/registry/radio-scale.json +14 -0
  233. package/registry/range-slider.json +14 -0
  234. package/registry/receipt-tape-print.json +14 -0
  235. package/registry/rectangle-toggle.json +14 -0
  236. package/registry/repost-toggle.json +14 -0
  237. package/registry/reveal-text.json +14 -0
  238. package/registry/ribbon-banner-slide.json +14 -0
  239. package/registry/rise-up-word.json +14 -0
  240. package/registry/roller-blind-drop.json +14 -0
  241. package/registry/rolling-tumble.json +14 -0
  242. package/registry/rotate-in-char.json +14 -0
  243. package/registry/rotating-louvers.json +14 -0
  244. package/registry/sales-analytics-dual-bars.json +14 -0
  245. package/registry/sales-overview-radial-dashboard.json +14 -0
  246. package/registry/sales-target-segmented-arc.json +14 -0
  247. package/registry/scale-in-char.json +14 -0
  248. package/registry/scale-in-text.json +14 -0
  249. package/registry/scale-in-word.json +14 -0
  250. package/registry/scramble-text.json +13 -0
  251. package/registry/scroll-canvas-unroll.json +14 -0
  252. package/registry/search-expand.json +14 -0
  253. package/registry/segmented-arc-meter.json +14 -0
  254. package/registry/segmented-link-stretch.json +14 -0
  255. package/registry/segmented-step-bar.json +14 -0
  256. package/registry/segmented-stepper-dots.json +14 -0
  257. package/registry/select-dropdown.json +14 -0
  258. package/registry/server-performance-step-bars.json +14 -0
  259. package/registry/shimmer-text.json +14 -0
  260. package/registry/shutter-slide.json +14 -0
  261. package/registry/shutter-step-slices.json +14 -0
  262. package/registry/skew-x-char.json +14 -0
  263. package/registry/slide-down-char.json +14 -0
  264. package/registry/slide-down-word.json +14 -0
  265. package/registry/slide-left-char.json +14 -0
  266. package/registry/slide-right-char.json +14 -0
  267. package/registry/slide-up-char.json +14 -0
  268. package/registry/slide-up-text.json +14 -0
  269. package/registry/slide-up-word.json +14 -0
  270. package/registry/slinky-coil.json +14 -0
  271. package/registry/smart-card-dispenser.json +14 -0
  272. package/registry/solid-switch.json +14 -0
  273. package/registry/spatial-door-portal.json +13 -0
  274. package/registry/split-gate-reveal.json +14 -0
  275. package/registry/spring-text.json +14 -0
  276. package/registry/squash-sphere.json +14 -0
  277. package/registry/stagger-text.json +14 -0
  278. package/registry/staggered-glass-curtain.json +13 -0
  279. package/registry/sticky-note-peel.json +14 -0
  280. package/registry/stretch-x-char.json +14 -0
  281. package/registry/stretch-y-char.json +14 -0
  282. package/registry/stroke-waveform.json +14 -0
  283. package/registry/submenu-flyout.json +14 -0
  284. package/registry/success-check.json +14 -0
  285. package/registry/sudden-brake.json +14 -0
  286. package/registry/swing-word.json +14 -0
  287. package/registry/textarea-auto-grow.json +14 -0
  288. package/registry/theme-toggle.json +14 -0
  289. package/registry/timer-preparation-segmented.json +14 -0
  290. package/registry/tracking-in-text.json +14 -0
  291. package/registry/tracking-out-text.json +14 -0
  292. package/registry/typewriter-text.json +13 -0
  293. package/registry/users-growth-pill-progress.json +14 -0
  294. package/registry/vertical-wheel-counter.json +14 -0
  295. package/registry/views-hourly-wave-chart.json +14 -0
  296. package/registry/wandering-eyes.json +11 -0
  297. package/registry/wave-reveal.json +13 -0
  298. package/registry/zoom-in-text.json +14 -0
  299. package/registry/zoom-out-text.json +14 -0
package/README.md CHANGED
@@ -1,46 +1,93 @@
1
- # @mova-ui/react
1
+ # Mova
2
2
 
3
3
  **Make interfaces feel alive.**
4
4
 
5
- Reusable React animation components and an offline, copy-source CLI. Documentation: https://mova.zeeland.studio
5
+ React components for motion: entrance transitions, hover effects, text reveals, loading indicators, and scroll interactions. Import them as a library, or copy the source into your project with the bundled CLI.
6
6
 
7
- ## Use as a React library
7
+ ## Install
8
8
 
9
- ```sh
10
- npm install @mova-ui/react react react-dom
9
+ Requires Node.js 20+ and React / React DOM 18.2+ or 19.
10
+
11
+ ```bash
12
+ npm install @mova-ui/react
11
13
  ```
12
14
 
15
+ Import the CSS once in your app entry point. Mova ships compiled styles, so you do not need to configure Tailwind. The stylesheet includes component utilities without a global reset.
16
+
13
17
  ```tsx
14
- 'use client';
15
- import { FadeIn, GlowButton, ClassicSpinner } from '@mova-ui/react';
18
+ import { FadeIn, GlowButton } from '@mova-ui/react';
16
19
  import '@mova-ui/react/styles.css';
17
20
 
18
- export function Example() {
19
- return <FadeIn><GlowButton>Continue</GlowButton><ClassicSpinner /></FadeIn>;
21
+ export function Welcome() {
22
+ return (
23
+ <FadeIn>
24
+ <GlowButton onClick={() => console.log('Hello!')}>
25
+ Try Mova
26
+ </GlowButton>
27
+ </FadeIn>
28
+ );
20
29
  }
21
30
  ```
22
31
 
23
- ESM with TypeScript declarations. React 18.2+ or 19; Node 20+ for the CLI. Animation and class utility dependencies are installed automatically. Bundlers can tree-shake unused exports. The library entry is marked `use client` for React Server Component frameworks.
24
-
25
- The exported CSS contains the bundled components' Tailwind utility classes and theme tokens, **not** the website stylesheet or Tailwind preflight. Import it once; Tailwind is not required for the supplied styles. Its utility class names are global: applications that already use Tailwind may instead scan their installed package's JS or copied source using their own Tailwind configuration. Custom `className` values require your own CSS. Components include upstream demo defaults; check individual props before use. Motion accessibility behavior varies by component; applications should configure reduced-motion preferences and test accessibility for their use case.
32
+ The package includes TypeScript declarations and an ESM entry point. In frameworks with React Server Components, use interactive components inside a client boundary.
26
33
 
27
- ## Copy editable source
34
+ ## Copy components
28
35
 
29
- Run from a project root containing `package.json`:
36
+ Run the CLI from a project directory containing `package.json`:
30
37
 
31
- ```sh
32
- npx @mova-ui/react --help
38
+ ```bash
33
39
  npx @mova-ui/react list
34
40
  npx @mova-ui/react add glow-button
35
41
  npx @mova-ui/react add fade-in --dir src/components/mova
42
+ npx @mova-ui/react --help
43
+ ```
44
+
45
+ The CLI copies component source, `styles.css`, and attribution licenses into `src/components/mova` by default. Missing dependencies are installed automatically using your project's npm, pnpm, yarn, or bun. Import the copied CSS once and keep both license files with the source.
46
+
47
+ Component sources are bundled with the package. Use `--skip-install` for offline source copying; otherwise dependency installation updates your package manifest and lockfile. It refuses symlink targets and paths outside your project. Existing component files stay untouched unless you pass `--overwrite`.
48
+
49
+ The extended site catalog is generated into standalone JavaScript bundles stored in `.tsx` files with an explicit typecheck exemption. Original library components retain their TypeScript source; generated catalog bundles do not preserve their original prop types.
50
+
51
+ ## Development
52
+
53
+ This repository contains the component library and CLI only.
54
+
55
+ ```bash
56
+ npm ci --include=dev
57
+ npm run build
58
+ npm test
59
+ npm run test:consumer
60
+ # Run all checks:
61
+ npm run verify
62
+ ```
63
+
64
+ - `source-registry/` contains the editable components, hooks, and utilities. The classic toggle is stored as registry JSON.
65
+ - `scripts/build.mjs` compiles the ESM bundle, strict TypeScript declarations, CSS, and offline registry.
66
+ - `bin/mova.mjs` implements the source-copy CLI.
67
+ - `install-catalog/` freezes the site's expanded catalog and third-party attribution. Refresh it with `npm run export:cli` in the sibling `mova-site` repository before building.
68
+ - `tests/` covers package exports, CLI safety, and installation into a separate React consumer.
69
+
70
+ The build recreates `dist/`, `registry/`, and `.generated/`. Do not edit those directories. Consumer verification packs the library, checks its file allowlist, installs it in a temporary project, then runs CLI commands, server rendering, strict typechecking, and a Vite production build.
71
+
72
+ ## Source catalog
73
+
74
+ `catalog/` preserves 153 additional reusable UI modules: cards, charts, metrics, forms, toggles, text effects, and CSS animation experiments. Starting with `0.2.0`, the expanded website catalog is also available through the bundled CLI; these additions are not root package exports. See [the catalog guide](catalog/README.md) for source development.
75
+
76
+ ```bash
77
+ npm ci --prefix catalog --include=dev
78
+ npm --prefix catalog run verify
36
79
  ```
37
80
 
38
- The CLI copies TypeScript source, compiled `styles.css`, and `LICENSE.mova` to `src/components/mova` by default. It prints required dependencies (for example `npm install framer-motion`) but never installs packages, downloads component code, or edits project configuration. Import the copied CSS once, e.g. `import './components/mova/styles.css'` from `src/App.tsx`. Source uses React and, where needed, `framer-motion`, `clsx`, and `tailwind-merge`.
81
+ ## Contributing
82
+
83
+ Keep changes focused on reusable components or CLI behavior. Edit `source-registry/`, add regression coverage where applicable, and run `npm run verify` before opening a pull request. Include usage notes when you change a component API. Check keyboard interaction and reduced-motion behavior for interactive or animated changes.
84
+
85
+ Maintainers can use the manual npm release workflow for a reviewed, unpublished version. The workflow requires an exact version match and the `NPM_TOKEN` secret. Version `0.2.0` adds automatic dependency installation and the expanded CLI catalog.
39
86
 
40
- Existing files are protected. Use `--overwrite` only when you intend to replace them. Identical shared CSS/license files can be reused when adding another component. Absolute paths, parent traversal, symlink targets, Git metadata, and `node_modules` destinations are refused. This is a local developer tool, not a sandbox against another process concurrently mutating your project's directories.
87
+ ## Attribution
41
88
 
42
- `list` enumerates all packaged IDs, including loaders, text/entrance/hover/scroll/cursor effects, the page transition, a toggle, hooks, and utilities. The package is generated from the original reusable registry, not the documentation application; website-only chart/demo pages are not exported.
89
+ Forked from an early version of [Amicro](https://github.com/Subhan-code/Amicro--Micro-transitions-).
43
90
 
44
- ## License and attribution
91
+ ## License
45
92
 
46
- MIT. Derived from Amicro by SYED SUBHAN UDDIN. The original copyright and complete license are retained in `LICENSE` and in source installations. Mova packaging, CLI, and compatibility adjustments preserve that attribution.
93
+ MIT. See [LICENSE](LICENSE).
package/bin/mova.mjs CHANGED
@@ -3,18 +3,19 @@ import { readdirSync, readFileSync, writeFileSync, lstatSync, realpathSync, mkdi
3
3
  import { resolve, dirname, join, isAbsolute, relative, sep } from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import { randomUUID } from 'node:crypto';
6
+ import { execFileSync } from 'node:child_process';
6
7
  const pkg = resolve(dirname(fileURLToPath(import.meta.url)), '..');
7
8
  const help = `Mova — Make interfaces feel alive.
8
9
 
9
10
  Usage:
10
11
  npx @mova-ui/react list
11
- npx @mova-ui/react add <id> [--dir src/components/mova] [--overwrite]
12
+ npx @mova-ui/react add <id> [--dir src/components/mova] [--overwrite] [--skip-install]
12
13
  npx @mova-ui/react --help
13
14
 
14
15
  Run add from your project root (must contain package.json).
15
16
  Copies bundled TypeScript source, compiled styles.css and the MIT license.
16
- No downloads, package installation or project configuration changes are made.
17
- Import the copied styles.css once in your app. Required dependencies are printed.
17
+ Installs missing dependencies using your project's npm, pnpm, yarn, or bun.
18
+ Import the copied styles.css once in your app. --skip-install copies source only.
18
19
  --dir must be a relative directory inside this project; symlinks are refused.
19
20
  --overwrite explicitly replaces existing regular files (never symlinks).
20
21
  `;
@@ -37,16 +38,17 @@ function main(args) {
37
38
  console.log(readdirSync(join(pkg, 'registry')).filter(f => f.endsWith('.json')).map(f => f.slice(0,-5)).sort().join('\n')); return;
38
39
  }
39
40
  if (args[0] !== 'add' || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(args[1] ?? '')) throw new Error('Use add <id>, list, or --help');
40
- const id = args[1]; let dir = 'src/components/mova'; let overwrite = false;
41
+ const id = args[1]; let dir = 'src/components/mova'; let overwrite = false; let skipInstall = false;
41
42
  for (let i=2;i<args.length;i++) {
42
43
  if (args[i] === '--overwrite' && !overwrite) overwrite = true;
44
+ else if (args[i] === '--skip-install' && !skipInstall) skipInstall = true;
43
45
  else if (args[i] === '--dir' && args[i+1] && !args[i+1].startsWith('--')) dir = args[++i];
44
46
  else throw new Error(`Unknown or incomplete option: ${args[i]}`);
45
47
  }
46
48
  if (!dir || isAbsolute(dir) || dir.includes('\\') || dir.includes(':') || dir.split('/').some(p => p === '..' || p.startsWith('.git') || p === 'node_modules')) throw new Error('Directory must be a relative path inside this project');
47
49
  const root = realpathSync(process.cwd());
48
50
  if (!stat(join(root, 'package.json'))?.isFile()) throw new Error('Run add from a project root containing package.json');
49
- JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
51
+ const project = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
50
52
  const registryFile = join(pkg, 'registry', `${id}.json`);
51
53
  if (!stat(registryFile)?.isFile()) throw new Error(`Unknown component: ${id}. Run npx @mova-ui/react list`);
52
54
  const item = JSON.parse(readFileSync(registryFile, 'utf8'));
@@ -55,7 +57,8 @@ function main(args) {
55
57
  const files = [
56
58
  { name: item.file, content: item.content },
57
59
  { name: 'styles.css', content: readFileSync(join(pkg, 'dist/styles.css'), 'utf8') },
58
- { name: 'LICENSE.mova', content: readFileSync(join(pkg, 'LICENSE'), 'utf8') }
60
+ { name: 'LICENSE.mova', content: readFileSync(join(pkg, 'LICENSE'), 'utf8') },
61
+ { name: 'LICENSE.third-party', content: readFileSync(join(pkg, 'registry/LICENSE.third-party'), 'utf8') }
59
62
  ].map(f => ({...f, path: join(out, f.name)}));
60
63
  // Preflight the entire operation before creating directories or replacing files.
61
64
  for (const f of files) {
@@ -64,6 +67,18 @@ function main(args) {
64
67
  f.skip = exists && f.name !== item.file && readFileSync(f.path, 'utf8') === f.content;
65
68
  if (exists && !f.skip && !overwrite) throw new Error(`${relative(root, f.path)} already exists; use --overwrite to replace it`);
66
69
  }
70
+ const dependencies = item.dependencies.filter(name => !project.dependencies?.[name] && !project.devDependencies?.[name]);
71
+ if (dependencies.some(name => !/^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/.test(name))) throw new Error('Invalid registry dependency');
72
+ if (!skipInstall && dependencies.length) {
73
+ const declared = project.packageManager?.split('@')[0];
74
+ const manager = ['npm', 'pnpm', 'yarn', 'bun'].includes(declared) ? declared
75
+ : stat(join(root, 'pnpm-lock.yaml')) ? 'pnpm'
76
+ : stat(join(root, 'yarn.lock')) ? 'yarn'
77
+ : stat(join(root, 'bun.lock')) || stat(join(root, 'bun.lockb')) ? 'bun' : 'npm';
78
+ console.log(`Installing ${dependencies.join(', ')} with ${manager}…`);
79
+ try { execFileSync(manager, [manager === 'npm' ? 'install' : 'add', ...dependencies], { cwd: root, stdio: 'inherit' }); }
80
+ catch { throw new Error(`Dependency installation failed (${manager}). Component files were not written. Resolve the package-manager error and retry.`); }
81
+ }
67
82
  for (const f of files.filter(f => !f.skip)) {
68
83
  mkdirSync(dirname(f.path), { recursive: true });
69
84
  safePath(root, f.path);
@@ -78,7 +93,7 @@ function main(args) {
78
93
  }
79
94
  }
80
95
  console.log(`Added ${id} to ${dir}\nImport '${dir}/styles.css' once in your app (adjust the relative import).`);
81
- if (item.dependencies.length) console.log(`Dependencies: npm install ${item.dependencies.join(' ')}`);
96
+ if (skipInstall && dependencies.length) console.log(`Skipped dependencies: ${dependencies.join(' ')}`);
82
97
  console.log('Requires React 18.2+ or 19 and React DOM. MIT attribution is in LICENSE.mova.');
83
98
  }
84
99
  try { main(process.argv.slice(2)); } catch (error) { console.error(`Mova: ${error.message}`); process.exitCode = 1; }