@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.
- package/README.md +68 -21
- package/bin/mova.mjs +22 -7
- package/dist/styles.css +131 -1
- package/package.json +62 -14
- package/registry/1.json +14 -0
- package/registry/10.json +14 -0
- package/registry/11.json +14 -0
- package/registry/12.json +14 -0
- package/registry/13.json +14 -0
- package/registry/14.json +14 -0
- package/registry/15.json +14 -0
- package/registry/16.json +14 -0
- package/registry/17.json +14 -0
- package/registry/18.json +14 -0
- package/registry/19.json +14 -0
- package/registry/2.json +14 -0
- package/registry/20.json +14 -0
- package/registry/21.json +14 -0
- package/registry/22.json +14 -0
- package/registry/23.json +14 -0
- package/registry/24.json +14 -0
- package/registry/25.json +14 -0
- package/registry/26.json +14 -0
- package/registry/27.json +14 -0
- package/registry/28.json +14 -0
- package/registry/29.json +14 -0
- package/registry/3.json +14 -0
- package/registry/30.json +14 -0
- package/registry/31.json +14 -0
- package/registry/32.json +14 -0
- package/registry/33.json +14 -0
- package/registry/34.json +14 -0
- package/registry/35.json +14 -0
- package/registry/36.json +11 -0
- package/registry/37.json +11 -0
- package/registry/4.json +14 -0
- package/registry/5.json +14 -0
- package/registry/6.json +14 -0
- package/registry/7.json +14 -0
- package/registry/8.json +14 -0
- package/registry/9.json +14 -0
- package/registry/LICENSE.third-party +283 -0
- package/registry/ab-segmented-tabs.json +14 -0
- package/registry/accordion-blind.json +14 -0
- package/registry/analyzing-image.json +13 -0
- package/registry/animated-sidebar.json +14 -0
- package/registry/animated-tags.json +14 -0
- package/registry/blur-up-char.json +14 -0
- package/registry/blur-up-word.json +14 -0
- package/registry/bookmark-corner-peel.json +14 -0
- package/registry/bookmark-save-pill.json +14 -0
- package/registry/bookmark-toggle.json +14 -0
- package/registry/border-trail-loading.json +13 -0
- package/registry/bounce-in-char.json +14 -0
- package/registry/btn-1.json +14 -0
- package/registry/btn-10.json +14 -0
- package/registry/btn-11.json +14 -0
- package/registry/btn-12.json +14 -0
- package/registry/btn-13.json +14 -0
- package/registry/btn-14.json +14 -0
- package/registry/btn-15.json +14 -0
- package/registry/btn-16.json +14 -0
- package/registry/btn-17.json +14 -0
- package/registry/btn-18.json +14 -0
- package/registry/btn-19.json +14 -0
- package/registry/btn-2.json +14 -0
- package/registry/btn-20.json +14 -0
- package/registry/btn-21.json +14 -0
- package/registry/btn-22.json +14 -0
- package/registry/btn-23.json +14 -0
- package/registry/btn-24.json +14 -0
- package/registry/btn-25.json +14 -0
- package/registry/btn-26.json +14 -0
- package/registry/btn-27.json +14 -0
- package/registry/btn-28.json +14 -0
- package/registry/btn-29.json +14 -0
- package/registry/btn-3.json +14 -0
- package/registry/btn-30.json +14 -0
- package/registry/btn-31.json +14 -0
- package/registry/btn-32.json +14 -0
- package/registry/btn-33.json +14 -0
- package/registry/btn-34.json +14 -0
- package/registry/btn-35.json +14 -0
- package/registry/btn-36.json +11 -0
- package/registry/btn-37.json +11 -0
- package/registry/btn-4.json +14 -0
- package/registry/btn-5.json +14 -0
- package/registry/btn-6.json +14 -0
- package/registry/btn-7.json +14 -0
- package/registry/btn-8.json +14 -0
- package/registry/btn-9.json +14 -0
- package/registry/button-slide-arrow.json +14 -0
- package/registry/cacheable-bandwidth-cost.json +14 -0
- package/registry/card-arc-5.json +13 -0
- package/registry/card-arc-7.json +13 -0
- package/registry/card-carousel-mono.json +14 -0
- package/registry/card-carousel.json +14 -0
- package/registry/card-cascade-stagger.json +13 -0
- package/registry/card-corner-fan.json +13 -0
- package/registry/card-cover-flow-mono.json +14 -0
- package/registry/card-cover-flow.json +14 -0
- package/registry/card-deck-cascade.json +14 -0
- package/registry/card-glance-preview.json +14 -0
- package/registry/card-linear-spread.json +13 -0
- package/registry/card-long-arc-5.json +13 -0
- package/registry/card-scatter-spread.json +13 -0
- package/registry/card-stack-peel.json +14 -0
- package/registry/card-stamp-arc.json +13 -0
- package/registry/card-time-machine-mono.json +13 -0
- package/registry/card-time-machine.json +13 -0
- package/registry/card-wheel-fan.json +13 -0
- package/registry/category-select.json +14 -0
- package/registry/checkbox-draw.json +14 -0
- package/registry/checkmark-draw.json +14 -0
- package/registry/circle-toggle.json +14 -0
- package/registry/circuit-trace-draw.json +14 -0
- package/registry/circular-create-button.json +11 -0
- package/registry/compass-needle-deflect.json +14 -0
- package/registry/context-menu.json +14 -0
- package/registry/credit-score-barcode-meter.json +14 -0
- package/registry/date-position-selector.json +14 -0
- package/registry/dia-text-reveal.json +14 -0
- package/registry/dislike-toggle.json +14 -0
- package/registry/dither-book.json +14 -0
- package/registry/domino-cascade.json +14 -0
- package/registry/double-bounce-toggle.json +14 -0
- package/registry/download-icons.json +14 -0
- package/registry/drop-in-char.json +14 -0
- package/registry/droplet-squish.json +14 -0
- package/registry/dual-magnet-dipole.json +14 -0
- package/registry/elastic-tag-snap.json +14 -0
- package/registry/error-shake.json +14 -0
- package/registry/expanding-icon-tabs.json +13 -0
- package/registry/fade-in-char.json +14 -0
- package/registry/fade-in-text.json +14 -0
- package/registry/fade-in-word.json +14 -0
- package/registry/file-upload-dropzone.json +14 -0
- package/registry/filter-tag-pill.json +14 -0
- package/registry/flip-x-char.json +14 -0
- package/registry/flip-y-char.json +14 -0
- package/registry/float-char.json +14 -0
- package/registry/float-word.json +14 -0
- package/registry/floating-label-input.json +14 -0
- package/registry/focus-blur.json +13 -0
- package/registry/form-submit-button.json +14 -0
- package/registry/french-doors-3d.json +13 -0
- package/registry/gear-tooth-step.json +14 -0
- package/registry/gelatin-wobble.json +14 -0
- package/registry/geometric-iris-shutter.json +14 -0
- package/registry/glow-text.json +14 -0
- package/registry/gooey-popover.json +13 -0
- package/registry/gradient-shimmer.json +13 -0
- package/registry/hex-lattice-draw.json +14 -0
- package/registry/hover-lift-char.json +14 -0
- package/registry/hover-lift-word.json +14 -0
- package/registry/hover-link-card.json +14 -0
- package/registry/hover-scale-char.json +14 -0
- package/registry/hover-scale-word.json +14 -0
- package/registry/inertia-skid-stop.json +14 -0
- package/registry/input-focus-glow.json +14 -0
- package/registry/inset-action-button.json +11 -0
- package/registry/inset-button.json +12 -0
- package/registry/kinetic-metronome-tick.json +14 -0
- package/registry/kinetic-tension-capsule.json +14 -0
- package/registry/light-dark-morph.json +14 -0
- package/registry/like-toggle.json +14 -0
- package/registry/magnetic-disks.json +14 -0
- package/registry/magnetic-slide-btn.json +14 -0
- package/registry/matrix-grid-loader.json +14 -0
- package/registry/modular-tile-snap.json +14 -0
- package/registry/mono-activity-blue.json +13 -0
- package/registry/mono-activity-green.json +13 -0
- package/registry/mono-activity-purple.json +13 -0
- package/registry/mono-heatmap.json +14 -0
- package/registry/mono-rounded-area.json +13 -0
- package/registry/mono-rounded-bar.json +13 -0
- package/registry/mono-rounded-bubble.json +13 -0
- package/registry/mono-rounded-bullet.json +11 -0
- package/registry/mono-rounded-candlestick.json +11 -0
- package/registry/mono-rounded-composed.json +13 -0
- package/registry/mono-rounded-donut.json +13 -0
- package/registry/mono-rounded-funnel.json +13 -0
- package/registry/mono-rounded-gauge-arc.json +13 -0
- package/registry/mono-rounded-heatmap.json +11 -0
- package/registry/mono-rounded-kpi.json +13 -0
- package/registry/mono-rounded-line.json +13 -0
- package/registry/mono-rounded-meter.json +13 -0
- package/registry/mono-rounded-polar.json +13 -0
- package/registry/mono-rounded-pyramid.json +11 -0
- package/registry/mono-rounded-radar.json +13 -0
- package/registry/mono-rounded-radial-gauge.json +13 -0
- package/registry/mono-rounded-radial-group.json +13 -0
- package/registry/mono-rounded-range.json +13 -0
- package/registry/mono-rounded-sankey.json +11 -0
- package/registry/mono-rounded-scatter.json +13 -0
- package/registry/mono-rounded-sparkline.json +13 -0
- package/registry/mono-rounded-stacked-bar.json +13 -0
- package/registry/mono-rounded-step.json +13 -0
- package/registry/mono-rounded-stream.json +13 -0
- package/registry/mono-rounded-treemap.json +11 -0
- package/registry/mono-rounded-waterfall.json +13 -0
- package/registry/mono-stock.json +14 -0
- package/registry/morph-action-pill.json +14 -0
- package/registry/morph-toggle.json +14 -0
- package/registry/multi-select-chips.json +14 -0
- package/registry/multi-tab-bar.json +14 -0
- package/registry/neon-sign-draw.json +14 -0
- package/registry/nested-orbital-gimbal.json +14 -0
- package/registry/network-telemetry-matrix.json +14 -0
- package/registry/noise-decibel-level.json +14 -0
- package/registry/obsidian-liquid-wave.json +11 -0
- package/registry/origami-envelope-unfold.json +14 -0
- package/registry/otp-input.json +14 -0
- package/registry/overview-bar-scrubber-card.json +14 -0
- package/registry/page-turn-curl.json +14 -0
- package/registry/password-toggle.json +14 -0
- package/registry/pendulum-bubble-level.json +14 -0
- package/registry/perspective-flip-stage.json +13 -0
- package/registry/perspective-flip.json +13 -0
- package/registry/perspective-layout-switcher.json +14 -0
- package/registry/physics-dock.json +14 -0
- package/registry/pill-tabs.json +14 -0
- package/registry/plus-minus-toggle.json +14 -0
- package/registry/prism-block-stack.json +14 -0
- package/registry/progress-indicator-piano.json +14 -0
- package/registry/progress-stepper.json +14 -0
- package/registry/pulse-char.json +14 -0
- package/registry/pulse-word.json +14 -0
- package/registry/pyramid-block-build.json +14 -0
- package/registry/radial-iris-mask.json +13 -0
- package/registry/radial-spinner.json +14 -0
- package/registry/radio-scale.json +14 -0
- package/registry/range-slider.json +14 -0
- package/registry/receipt-tape-print.json +14 -0
- package/registry/rectangle-toggle.json +14 -0
- package/registry/repost-toggle.json +14 -0
- package/registry/reveal-text.json +14 -0
- package/registry/ribbon-banner-slide.json +14 -0
- package/registry/rise-up-word.json +14 -0
- package/registry/roller-blind-drop.json +14 -0
- package/registry/rolling-tumble.json +14 -0
- package/registry/rotate-in-char.json +14 -0
- package/registry/rotating-louvers.json +14 -0
- package/registry/sales-analytics-dual-bars.json +14 -0
- package/registry/sales-overview-radial-dashboard.json +14 -0
- package/registry/sales-target-segmented-arc.json +14 -0
- package/registry/scale-in-char.json +14 -0
- package/registry/scale-in-text.json +14 -0
- package/registry/scale-in-word.json +14 -0
- package/registry/scramble-text.json +13 -0
- package/registry/scroll-canvas-unroll.json +14 -0
- package/registry/search-expand.json +14 -0
- package/registry/segmented-arc-meter.json +14 -0
- package/registry/segmented-link-stretch.json +14 -0
- package/registry/segmented-step-bar.json +14 -0
- package/registry/segmented-stepper-dots.json +14 -0
- package/registry/select-dropdown.json +14 -0
- package/registry/server-performance-step-bars.json +14 -0
- package/registry/shimmer-text.json +14 -0
- package/registry/shutter-slide.json +14 -0
- package/registry/shutter-step-slices.json +14 -0
- package/registry/skew-x-char.json +14 -0
- package/registry/slide-down-char.json +14 -0
- package/registry/slide-down-word.json +14 -0
- package/registry/slide-left-char.json +14 -0
- package/registry/slide-right-char.json +14 -0
- package/registry/slide-up-char.json +14 -0
- package/registry/slide-up-text.json +14 -0
- package/registry/slide-up-word.json +14 -0
- package/registry/slinky-coil.json +14 -0
- package/registry/smart-card-dispenser.json +14 -0
- package/registry/solid-switch.json +14 -0
- package/registry/spatial-door-portal.json +13 -0
- package/registry/split-gate-reveal.json +14 -0
- package/registry/spring-text.json +14 -0
- package/registry/squash-sphere.json +14 -0
- package/registry/stagger-text.json +14 -0
- package/registry/staggered-glass-curtain.json +13 -0
- package/registry/sticky-note-peel.json +14 -0
- package/registry/stretch-x-char.json +14 -0
- package/registry/stretch-y-char.json +14 -0
- package/registry/stroke-waveform.json +14 -0
- package/registry/submenu-flyout.json +14 -0
- package/registry/success-check.json +14 -0
- package/registry/sudden-brake.json +14 -0
- package/registry/swing-word.json +14 -0
- package/registry/textarea-auto-grow.json +14 -0
- package/registry/theme-toggle.json +14 -0
- package/registry/timer-preparation-segmented.json +14 -0
- package/registry/tracking-in-text.json +14 -0
- package/registry/tracking-out-text.json +14 -0
- package/registry/typewriter-text.json +13 -0
- package/registry/users-growth-pill-progress.json +14 -0
- package/registry/vertical-wheel-counter.json +14 -0
- package/registry/views-hourly-wave-chart.json +14 -0
- package/registry/wandering-eyes.json +11 -0
- package/registry/wave-reveal.json +13 -0
- package/registry/zoom-in-text.json +14 -0
- package/registry/zoom-out-text.json +14 -0
package/README.md
CHANGED
|
@@ -1,46 +1,93 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Mova
|
|
2
2
|
|
|
3
3
|
**Make interfaces feel alive.**
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
##
|
|
7
|
+
## Install
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
|
19
|
-
return
|
|
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
|
-
|
|
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
|
|
34
|
+
## Copy components
|
|
28
35
|
|
|
29
|
-
Run from a project
|
|
36
|
+
Run the CLI from a project directory containing `package.json`:
|
|
30
37
|
|
|
31
|
-
```
|
|
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
|
-
|
|
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
|
-
|
|
87
|
+
## Attribution
|
|
41
88
|
|
|
42
|
-
|
|
89
|
+
Forked from an early version of [Amicro](https://github.com/Subhan-code/Amicro--Micro-transitions-).
|
|
43
90
|
|
|
44
|
-
## License
|
|
91
|
+
## License
|
|
45
92
|
|
|
46
|
-
MIT.
|
|
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
|
-
|
|
17
|
-
Import the copied styles.css once in your app.
|
|
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 (
|
|
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; }
|