banhaten 0.1.2 → 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/CHANGELOG.md +45 -0
- package/CONTRIBUTING.md +44 -0
- package/README.md +145 -328
- package/SECURITY.md +15 -0
- package/banhaten.config.example.json +1 -3
- package/docs/design-system/README.md +20 -0
- package/docs/design-system/adoption-quality-remediation.md +87 -0
- package/docs/design-system/agent-usage.md +13 -0
- package/docs/design-system/appearance-presets.md +189 -0
- package/docs/design-system/appearances/default.md +94 -0
- package/docs/design-system/appearances/rounded.md +95 -0
- package/docs/design-system/appearances/sharp.md +95 -0
- package/docs/design-system/component-docs-pattern.md +81 -0
- package/docs/design-system/component-showcase-consistency-report.md +217 -0
- package/docs/design-system/component-token-consistency-audit.md +173 -0
- package/docs/design-system/components/README.md +75 -0
- package/docs/design-system/components/accordion.md +67 -0
- package/docs/design-system/components/activity-feed.md +106 -0
- package/docs/design-system/components/alert-dialog.md +87 -0
- package/docs/design-system/components/alert.md +111 -0
- package/docs/design-system/components/aspect-ratio.md +59 -0
- package/docs/design-system/components/attribute.md +103 -0
- package/docs/design-system/components/autocomplete.md +93 -0
- package/docs/design-system/components/avatar.md +70 -0
- package/docs/design-system/components/badge.md +72 -0
- package/docs/design-system/components/banner.md +99 -0
- package/docs/design-system/components/breadcrumbs.md +188 -0
- package/docs/design-system/components/button-group.md +117 -0
- package/docs/design-system/components/button.md +95 -0
- package/docs/design-system/components/card.md +95 -0
- package/docs/design-system/components/carousel.md +61 -0
- package/docs/design-system/components/catalog-components.md +59 -0
- package/docs/design-system/components/chart.md +58 -0
- package/docs/design-system/components/checkbox.md +68 -0
- package/docs/design-system/components/collapsible.md +63 -0
- package/docs/design-system/components/command.md +75 -0
- package/docs/design-system/components/context-menu.md +59 -0
- package/docs/design-system/components/date-picker.md +97 -0
- package/docs/design-system/components/divider.md +117 -0
- package/docs/design-system/components/empty-state.md +72 -0
- package/docs/design-system/components/field.md +86 -0
- package/docs/design-system/components/file-upload.md +199 -0
- package/docs/design-system/components/hover-card.md +61 -0
- package/docs/design-system/components/icons.md +48 -0
- package/docs/design-system/components/input-group.md +73 -0
- package/docs/design-system/components/input-otp.md +73 -0
- package/docs/design-system/components/input.md +84 -0
- package/docs/design-system/components/item.md +72 -0
- package/docs/design-system/components/kbd.md +62 -0
- package/docs/design-system/components/label.md +64 -0
- package/docs/design-system/components/menu.md +76 -0
- package/docs/design-system/components/menubar.md +60 -0
- package/docs/design-system/components/modal.md +119 -0
- package/docs/design-system/components/native-select.md +70 -0
- package/docs/design-system/components/navigation-menu.md +63 -0
- package/docs/design-system/components/onboarding-step-list-item.md +94 -0
- package/docs/design-system/components/page-header.md +98 -0
- package/docs/design-system/components/pagination.md +71 -0
- package/docs/design-system/components/popover.md +77 -0
- package/docs/design-system/components/progress-slider.md +66 -0
- package/docs/design-system/components/progress.md +92 -0
- package/docs/design-system/components/radio-card.md +65 -0
- package/docs/design-system/components/radio-group.md +72 -0
- package/docs/design-system/components/resizable.md +57 -0
- package/docs/design-system/components/scroll-area.md +60 -0
- package/docs/design-system/components/segmented-control.md +71 -0
- package/docs/design-system/components/select.md +87 -0
- package/docs/design-system/components/sheet.md +82 -0
- package/docs/design-system/components/sidebar.md +83 -0
- package/docs/design-system/components/skeleton.md +91 -0
- package/docs/design-system/components/slideout.md +77 -0
- package/docs/design-system/components/slider.md +81 -0
- package/docs/design-system/components/social-button.md +65 -0
- package/docs/design-system/components/spinner.md +77 -0
- package/docs/design-system/components/steps.md +77 -0
- package/docs/design-system/components/table.md +411 -0
- package/docs/design-system/components/tabs.md +69 -0
- package/docs/design-system/components/tag.md +95 -0
- package/docs/design-system/components/textarea.md +64 -0
- package/docs/design-system/components/timeline.md +95 -0
- package/docs/design-system/components/toast.md +73 -0
- package/docs/design-system/components/toggle.md +96 -0
- package/docs/design-system/components/toolbar.md +105 -0
- package/docs/design-system/components/tooltip.md +107 -0
- package/docs/design-system/components/typography.md +18 -0
- package/docs/design-system/density-and-elevation.md +44 -0
- package/docs/design-system/design-system-test-missing-items.md +368 -0
- package/docs/design-system/direction-and-localization.md +23 -0
- package/docs/design-system/form-recipes.md +73 -0
- package/docs/design-system/gap-promotion-policy.md +21 -0
- package/docs/design-system/gap-promotion-report.md +166 -0
- package/docs/design-system/icons.md +69 -0
- package/docs/design-system/installation.md +68 -0
- package/docs/design-system/launch-comparison-shadcn.md +98 -0
- package/docs/design-system/registry-and-cli.md +64 -0
- package/docs/design-system/release-policy.md +30 -0
- package/docs/design-system/roadmap.md +14 -0
- package/docs/design-system/support-matrix.md +23 -0
- package/docs/design-system/tabs.md +53 -0
- package/docs/design-system/token-governance.md +60 -0
- package/package.json +97 -65
- package/registry/component-contract.json +40 -0
- package/registry/components/alert-dialog.tsx +297 -0
- package/registry/components/alert.tsx +86 -65
- package/registry/components/aspect-ratio.tsx +30 -0
- package/registry/components/autocomplete.tsx +23 -9
- package/registry/components/avatar.tsx +7 -7
- package/registry/components/badge.tsx +1 -1
- package/registry/components/button-group.tsx +321 -4
- package/registry/components/button.tsx +38 -17
- package/registry/components/card.tsx +68 -59
- package/registry/components/carousel.tsx +282 -0
- package/registry/components/chart.tsx +203 -0
- package/registry/components/checkbox.tsx +3 -3
- package/registry/components/collapsible.tsx +69 -0
- package/registry/components/command.tsx +174 -0
- package/registry/components/context-menu.tsx +236 -0
- package/registry/components/date-picker.tsx +246 -105
- package/registry/components/expanded/ActivityFeed.tsx +6 -15
- package/registry/components/expanded/Banner.tsx +3 -3
- package/registry/components/expanded/Breadcrumbs.tsx +5 -5
- package/registry/components/expanded/CatalogComponentsShowcase.tsx +13 -13
- package/registry/components/expanded/CatalogDivider.tsx +1 -1
- package/registry/components/expanded/EmptyState.tsx +1 -1
- package/registry/components/expanded/FileUpload.tsx +9 -2
- package/registry/components/expanded/OnboardingStepListItem.tsx +2 -4
- package/registry/components/expanded/PageHeader.tsx +14 -14
- package/registry/components/expanded/Slideout.tsx +15 -415
- package/registry/components/expanded/Steps.tsx +4 -4
- package/registry/components/expanded/Table.tsx +116 -69
- package/registry/components/expanded/Timeline.tsx +3 -3
- package/registry/components/expanded/activityFeed.css +1 -1
- package/registry/components/expanded/breadcrumbs.css +139 -139
- package/registry/components/expanded/catalogComponentsShowcase.css +83 -83
- package/registry/components/expanded/divider.css +1 -1
- package/registry/components/expanded/emptyState.css +1 -1
- package/registry/components/expanded/fileUpload.css +6 -6
- package/registry/components/expanded/slideout.css +9 -685
- package/registry/components/expanded/steps.css +274 -274
- package/registry/components/expanded/table.css +2 -2
- package/registry/components/expanded/timeline.css +264 -264
- package/registry/components/field.tsx +230 -0
- package/registry/components/hover-card.tsx +48 -0
- package/registry/components/input-content.ts +1 -0
- package/registry/components/input-group.tsx +130 -0
- package/registry/components/input-otp.tsx +13 -3
- package/registry/components/input.tsx +70 -45
- package/registry/components/item.tsx +189 -0
- package/registry/components/kbd.tsx +151 -0
- package/registry/components/label.tsx +78 -0
- package/registry/components/menu.tsx +34 -246
- package/registry/components/menubar.tsx +226 -0
- package/registry/components/modal.tsx +216 -143
- package/registry/components/native-select.tsx +205 -0
- package/registry/components/navigation-menu.tsx +171 -0
- package/registry/components/pagination.tsx +80 -58
- package/registry/components/popover.tsx +162 -664
- package/registry/components/radio-card.tsx +116 -87
- package/registry/components/radio-group.tsx +1 -1
- package/registry/components/resizable.tsx +74 -0
- package/registry/components/scroll-area.tsx +67 -0
- package/registry/components/segmented-control.tsx +87 -0
- package/registry/components/select-content.tsx +2 -2
- package/registry/components/select.tsx +54 -20
- package/registry/components/sheet.tsx +305 -0
- package/registry/components/sidebar.tsx +352 -0
- package/registry/components/skeleton.css +0 -3
- package/registry/components/social-button.tsx +116 -30
- package/registry/components/spinner.tsx +18 -55
- package/registry/components/{expanded/tabs.css → tabs.css} +127 -106
- package/registry/components/tabs.tsx +246 -0
- package/registry/components/tag.tsx +2 -2
- package/registry/components/textarea.tsx +4 -4
- package/registry/components/toast.tsx +136 -0
- package/registry/components/toggle.tsx +2 -2
- package/registry/components/toolbar.tsx +89 -17
- package/registry/components/tooltip.tsx +1 -1
- package/registry/examples/alert-demo.tsx +25 -5
- package/registry/examples/alert-dialog-demo.tsx +42 -0
- package/registry/examples/aspect-ratio-demo.tsx +11 -0
- package/registry/examples/attribute-demo.tsx +1 -1
- package/registry/examples/autocomplete-demo.tsx +3 -3
- package/registry/examples/avatar-demo.tsx +7 -7
- package/registry/examples/badge-demo.tsx +1 -1
- package/registry/examples/button-demo.tsx +6 -6
- package/registry/examples/button-group-demo.tsx +23 -2
- package/registry/examples/card-demo.tsx +46 -8
- package/registry/examples/carousel-demo.tsx +43 -0
- package/registry/examples/chart-demo.tsx +33 -0
- package/registry/examples/checkbox-demo.tsx +5 -5
- package/registry/examples/collapsible-demo.tsx +16 -0
- package/registry/examples/collection-filter-bar-demo.tsx +135 -0
- package/registry/examples/command-demo.tsx +42 -0
- package/registry/examples/{expanded/command-bar-demo.tsx → command-palette-demo.tsx} +5 -15
- package/registry/examples/context-menu-demo.tsx +29 -0
- package/registry/examples/control-density-contract-demo.tsx +61 -0
- package/registry/examples/date-picker-demo.tsx +12 -12
- package/registry/examples/divider-demo.tsx +3 -3
- package/registry/examples/expanded/banner-demo.tsx +1 -1
- package/registry/examples/expanded/breadcrumbs-demo.tsx +1 -1
- package/registry/examples/expanded/empty-state-demo.tsx +1 -1
- package/registry/examples/expanded/file-upload-demo.tsx +1 -1
- package/registry/examples/expanded/onboarding-step-demo.tsx +1 -1
- package/registry/examples/expanded/slideout-demo.tsx +2 -2
- package/registry/examples/expanded/steps-demo.tsx +1 -1
- package/registry/examples/expanded/tabs-demo.tsx +2 -2
- package/registry/examples/expanded/timeline-demo.tsx +1 -1
- package/registry/examples/field-demo.tsx +51 -0
- package/registry/examples/hover-card-demo.tsx +23 -0
- package/registry/examples/input-demo.tsx +6 -6
- package/registry/examples/input-group-demo.tsx +16 -0
- package/registry/examples/input-otp-demo.tsx +4 -4
- package/registry/examples/item-demo.tsx +46 -0
- package/registry/examples/kbd-demo.tsx +11 -0
- package/registry/examples/label-demo.tsx +20 -0
- package/registry/examples/menu-demo.tsx +1 -1
- package/registry/examples/menubar-demo.tsx +34 -0
- package/registry/examples/modal-demo.tsx +67 -9
- package/registry/examples/native-select-demo.tsx +16 -0
- package/registry/examples/navigation-menu-demo.tsx +29 -0
- package/registry/examples/pagination-demo.tsx +6 -3
- package/registry/examples/popover-demo.tsx +19 -19
- package/registry/examples/progress-demo.tsx +1 -1
- package/registry/examples/progress-slider-demo.tsx +1 -1
- package/registry/examples/radio-card-demo.tsx +4 -4
- package/registry/examples/radio-group-demo.tsx +2 -2
- package/registry/examples/resizable-demo.tsx +22 -0
- package/registry/examples/results-toolbar-demo.tsx +44 -0
- package/registry/examples/scroll-area-demo.tsx +15 -0
- package/registry/examples/segmented-control-demo.tsx +39 -0
- package/registry/examples/select-demo.tsx +1 -1
- package/registry/examples/sheet-demo.tsx +47 -0
- package/registry/examples/sidebar-demo.tsx +55 -0
- package/registry/examples/slider-demo.tsx +3 -3
- package/registry/examples/social-button-demo.tsx +18 -8
- package/registry/examples/spinner-demo.tsx +13 -13
- package/registry/examples/tabs-demo.tsx +13 -0
- package/registry/examples/tag-demo.tsx +1 -1
- package/registry/examples/textarea-demo.tsx +4 -4
- package/registry/examples/toast-demo.tsx +35 -0
- package/registry/examples/toggle-demo.tsx +6 -6
- package/registry/examples/tooltip-demo.tsx +4 -4
- package/registry/guidance/USAGE.md +27 -0
- package/registry/hooks/use-direction.ts +193 -13
- package/registry/index.json +6010 -432
- package/registry/styles/globals.css +3112 -4690
- package/registry.json +1582 -0
- package/schema/config.schema.json +51 -0
- package/schema/registry.schema.json +190 -0
- package/schema/tokens.schema.json +163 -0
- package/src/cli/command-line.js +194 -0
- package/src/cli/config-editors.js +9 -0
- package/src/cli/doctor.js +399 -0
- package/src/cli/file-transaction.js +295 -0
- package/src/cli/global-css.js +153 -0
- package/src/cli/index.js +639 -1391
- package/src/cli/install-plan.js +592 -0
- package/src/cli/install-receipt.js +171 -0
- package/src/cli/jsonc.js +203 -0
- package/src/cli/package-install-state.js +254 -0
- package/src/cli/package-manager.js +238 -0
- package/src/cli/package-plan.js +185 -0
- package/src/cli/package-version.js +97 -0
- package/src/cli/registry-query.js +207 -0
- package/src/cli/reporting.js +55 -0
- package/src/cli/schema-validation.js +19 -0
- package/src/cli/source-scanner.js +686 -0
- package/src/cli/vite-config.js +478 -0
- package/tokens/banhaten.tokens.json +4313 -310
- package/registry/assets/avatars/avatar-02.jpg +0 -0
- package/registry/assets/avatars/avatar-03.jpg +0 -0
- package/registry/assets/avatars/avatar-04.jpg +0 -0
- package/registry/assets/avatars/avatar-05.jpg +0 -0
- package/registry/assets/avatars/avatar-06.jpg +0 -0
- package/registry/assets/avatars/avatar-07.jpg +0 -0
- package/registry/assets/avatars/avatar-08.jpg +0 -0
- package/registry/assets/avatars/avatar-09.jpg +0 -0
- package/registry/assets/avatars/avatar-10.jpg +0 -0
- package/registry/assets/avatars/avatar-11.jpg +0 -0
- package/registry/assets/avatars/avatar-12.jpg +0 -0
- package/registry/assets/avatars/avatar-13.jpg +0 -0
- package/registry/assets/avatars/avatar-14.jpg +0 -0
- package/registry/assets/avatars/avatar-15.jpg +0 -0
- package/registry/assets/avatars/avatar-16.jpg +0 -0
- package/registry/assets/avatars/avatar-17.jpg +0 -0
- package/registry/assets/avatars/avatar-18.jpg +0 -0
- package/registry/assets/avatars/avatar-19.jpg +0 -0
- package/registry/assets/avatars/avatar-20.jpg +0 -0
- package/registry/assets/avatars/avatar-21.jpg +0 -0
- package/registry/assets/avatars/avatar-22.jpg +0 -0
- package/registry/assets/avatars/avatar-23.jpg +0 -0
- package/registry/assets/avatars/avatar-24.jpg +0 -0
- package/registry/assets/avatars/avatar-25.jpg +0 -0
- package/registry/assets/avatars/avatar-26.jpg +0 -0
- package/registry/assets/avatars/avatar-27.jpg +0 -0
- package/registry/assets/avatars/avatar-28.jpg +0 -0
- package/registry/assets/avatars/avatar-29.jpg +0 -0
- package/registry/assets/avatars/avatar-30.jpg +0 -0
- package/registry/assets/avatars/avatar-31.jpg +0 -0
- package/registry/assets/avatars/avatar-32.jpg +0 -0
- package/registry/assets/avatars/avatar-33.jpg +0 -0
- package/registry/assets/avatars/avatar-34.jpg +0 -0
- package/registry/assets/avatars/avatar-35.jpg +0 -0
- package/registry/assets/image-assets.json +0 -744
- package/registry/assets/images/art-02.jpg +0 -0
- package/registry/assets/images/art-03.jpg +0 -0
- package/registry/assets/images/art-04.jpg +0 -0
- package/registry/assets/images/art-05.jpg +0 -0
- package/registry/assets/images/art-06.jpg +0 -0
- package/registry/assets/images/art-07.jpg +0 -0
- package/registry/assets/images/art-08.jpg +0 -0
- package/registry/assets/images/art-09.jpg +0 -0
- package/registry/assets/images/art-10.jpg +0 -0
- package/registry/assets/images/art-11.jpg +0 -0
- package/registry/assets/images/art-12.jpg +0 -0
- package/registry/assets/images/art-13.jpg +0 -0
- package/registry/assets/images/art-14.jpg +0 -0
- package/registry/assets/images/art-15.jpg +0 -0
- package/registry/assets/images/art-16.jpg +0 -0
- package/registry/assets/images/art-17.jpg +0 -0
- package/registry/assets/images/art-18.jpg +0 -0
- package/registry/assets/images/art-19.jpg +0 -0
- package/registry/assets/images/art-20.jpg +0 -0
- package/registry/assets/images/art-21.jpg +0 -0
- package/registry/assets/images/art-22.jpg +0 -0
- package/registry/assets/images/art-23.jpg +0 -0
- package/registry/assets/images/art-24.jpg +0 -0
- package/registry/assets/images/art-25.jpg +0 -0
- package/registry/assets/images/art-26.jpg +0 -0
- package/registry/assets/images/art-27.jpg +0 -0
- package/registry/assets/images/nature-01.jpg +0 -0
- package/registry/assets/images/nature-02.jpg +0 -0
- package/registry/assets/images/nature-03.jpg +0 -0
- package/registry/assets/images/nature-04.jpg +0 -0
- package/registry/assets/images/nature-05.jpg +0 -0
- package/registry/assets/images/nature-06.jpg +0 -0
- package/registry/assets/images/nature-07.jpg +0 -0
- package/registry/assets/images/nature-08.jpg +0 -0
- package/registry/assets/images/nature-09.jpg +0 -0
- package/registry/assets/images/nature-10.jpg +0 -0
- package/registry/assets/images/nature-11.jpg +0 -0
- package/registry/assets/images/nature-12.jpg +0 -0
- package/registry/assets/images/nature-13.jpg +0 -0
- package/registry/assets/images/nature-14.jpg +0 -0
- package/registry/assets/images/nature-15.jpg +0 -0
- package/registry/assets/images/nature-16.jpg +0 -0
- package/registry/assets/images/nature-17.jpg +0 -0
- package/registry/assets/images/nature-18.jpg +0 -0
- package/registry/assets/images/nature-19.jpg +0 -0
- package/registry/assets/images/nature-20.jpg +0 -0
- package/registry/components/expanded/BannerBoard.tsx +0 -225
- package/registry/components/expanded/CatalogTag.tsx +0 -85
- package/registry/components/expanded/CommandBar.tsx +0 -386
- package/registry/components/expanded/IconExplorer.tsx +0 -612
- package/registry/components/expanded/Tabs.tsx +0 -86
- package/registry/components/expanded/TimelineShowcase.tsx +0 -158
- package/registry/components/expanded/commandBar.css +0 -470
- package/registry/components/expanded/iconExplorer.css +0 -764
- package/registry/components/expanded/iconPacks.ts +0 -866
- package/registry/components/expanded/tag.css +0 -148
- package/registry/examples/expanded/icons-demo.tsx +0 -5
- package/tokens/Color mode.zip +0 -0
- package/tokens/Numbers.zip +0 -0
- package/tokens/Radius.zip +0 -0
- package/tokens/Theme.zip +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "urn:banhaten:schema:config",
|
|
4
|
+
"title": "Banhaten CLI config",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["tailwind", "aliases"],
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"$schema": {
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"tailwind": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"required": ["css"],
|
|
15
|
+
"additionalProperties": false,
|
|
16
|
+
"properties": {
|
|
17
|
+
"css": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"minLength": 1,
|
|
20
|
+
"pattern": "^\\S(?:.*\\S)?$",
|
|
21
|
+
"description": "Path to the global CSS file that imports Tailwind and receives Banhaten tokens."
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"aliases": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"required": ["ui", "utils", "hooks"],
|
|
28
|
+
"additionalProperties": false,
|
|
29
|
+
"properties": {
|
|
30
|
+
"ui": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"minLength": 1,
|
|
33
|
+
"pattern": "^\\S(?:.*\\S)?$",
|
|
34
|
+
"description": "Import alias where Banhaten UI components are installed."
|
|
35
|
+
},
|
|
36
|
+
"utils": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"minLength": 1,
|
|
39
|
+
"pattern": "^\\S(?:.*\\S)?$",
|
|
40
|
+
"description": "Import alias for the cn utility file."
|
|
41
|
+
},
|
|
42
|
+
"hooks": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"minLength": 1,
|
|
45
|
+
"pattern": "^\\S(?:.*\\S)?$",
|
|
46
|
+
"description": "Import alias for generated hooks."
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "urn:banhaten:schema:registry",
|
|
4
|
+
"title": "Banhaten registry index",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["name", "base", "components"],
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"$schema": { "type": "string" },
|
|
10
|
+
"name": { "type": "string", "minLength": 1 },
|
|
11
|
+
"base": { "$ref": "#/$defs/baseEntry" },
|
|
12
|
+
"components": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"minProperties": 1,
|
|
15
|
+
"additionalProperties": { "$ref": "#/$defs/componentEntry" }
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"$defs": {
|
|
19
|
+
"baseEntry": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"required": ["dependencies", "files"],
|
|
22
|
+
"additionalProperties": false,
|
|
23
|
+
"properties": {
|
|
24
|
+
"dependencies": { "$ref": "#/$defs/dependencies" },
|
|
25
|
+
"files": {
|
|
26
|
+
"type": "array",
|
|
27
|
+
"minItems": 1,
|
|
28
|
+
"items": { "$ref": "#/$defs/registryFile" }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"componentEntry": {
|
|
33
|
+
"type": "object",
|
|
34
|
+
"required": [
|
|
35
|
+
"description",
|
|
36
|
+
"dependencies",
|
|
37
|
+
"parts",
|
|
38
|
+
"supportedExports",
|
|
39
|
+
"files",
|
|
40
|
+
"examples"
|
|
41
|
+
],
|
|
42
|
+
"additionalProperties": false,
|
|
43
|
+
"properties": {
|
|
44
|
+
"description": { "type": "string", "minLength": 1 },
|
|
45
|
+
"status": { "enum": ["expanded"] },
|
|
46
|
+
"dependencies": { "$ref": "#/$defs/dependencies" },
|
|
47
|
+
"registryDependencies": { "$ref": "#/$defs/stringArray" },
|
|
48
|
+
"parts": {
|
|
49
|
+
"description": "Ordered, non-exhaustive component anatomy. The first value is the primary renderable part; every value must also appear in supportedExports.",
|
|
50
|
+
"type": "array",
|
|
51
|
+
"minItems": 1,
|
|
52
|
+
"uniqueItems": true,
|
|
53
|
+
"items": { "$ref": "#/$defs/componentPartName" }
|
|
54
|
+
},
|
|
55
|
+
"supportedExports": {
|
|
56
|
+
"description": "Exhaustive runtime value exports, grouped by the installed source module that owns each import path. Type-only exports are intentionally excluded.",
|
|
57
|
+
"type": "array",
|
|
58
|
+
"minItems": 1,
|
|
59
|
+
"uniqueItems": true,
|
|
60
|
+
"items": { "$ref": "#/$defs/supportedExportModule" }
|
|
61
|
+
},
|
|
62
|
+
"files": {
|
|
63
|
+
"type": "array",
|
|
64
|
+
"minItems": 1,
|
|
65
|
+
"items": { "$ref": "#/$defs/registryFile" }
|
|
66
|
+
},
|
|
67
|
+
"examples": {
|
|
68
|
+
"type": "array",
|
|
69
|
+
"minItems": 1,
|
|
70
|
+
"items": { "type": "string", "minLength": 1 }
|
|
71
|
+
},
|
|
72
|
+
"props": {
|
|
73
|
+
"description": "Machine-readable public prop behavior, including rendered defaults for optional visual slots.",
|
|
74
|
+
"type": "object",
|
|
75
|
+
"minProperties": 1,
|
|
76
|
+
"additionalProperties": { "$ref": "#/$defs/componentProp" }
|
|
77
|
+
},
|
|
78
|
+
"defaults": {
|
|
79
|
+
"description": "Explicit defaults for array-valued capabilities. Keys must name a capability on the same component and values must belong to that capability list.",
|
|
80
|
+
"type": "object",
|
|
81
|
+
"minProperties": 1,
|
|
82
|
+
"additionalProperties": {
|
|
83
|
+
"type": ["string", "number", "boolean", "null"]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"recommendedFor": { "$ref": "#/$defs/stringArray" },
|
|
87
|
+
"avoidWhen": { "$ref": "#/$defs/stringArray" },
|
|
88
|
+
"recipes": { "$ref": "#/$defs/stringArray" },
|
|
89
|
+
"rtl": {
|
|
90
|
+
"type": "object",
|
|
91
|
+
"minProperties": 1,
|
|
92
|
+
"additionalProperties": { "type": ["string", "boolean"] }
|
|
93
|
+
},
|
|
94
|
+
"actions": { "$ref": "#/$defs/stringArray" },
|
|
95
|
+
"alignments": { "$ref": "#/$defs/stringArray" },
|
|
96
|
+
"breakpoints": { "$ref": "#/$defs/stringArray" },
|
|
97
|
+
"cardPositions": { "$ref": "#/$defs/stringArray" },
|
|
98
|
+
"colors": { "$ref": "#/$defs/stringArray" },
|
|
99
|
+
"controlPositions": { "$ref": "#/$defs/stringArray" },
|
|
100
|
+
"densities": { "$ref": "#/$defs/stringArray" },
|
|
101
|
+
"directions": { "$ref": "#/$defs/stringArray" },
|
|
102
|
+
"features": { "$ref": "#/$defs/stringArray" },
|
|
103
|
+
"forms": { "$ref": "#/$defs/stringArray" },
|
|
104
|
+
"indicators": { "$ref": "#/$defs/stringArray" },
|
|
105
|
+
"intents": { "$ref": "#/$defs/stringArray" },
|
|
106
|
+
"itemKinds": { "$ref": "#/$defs/stringArray" },
|
|
107
|
+
"itemTypes": { "$ref": "#/$defs/stringArray" },
|
|
108
|
+
"kinds": { "$ref": "#/$defs/stringArray" },
|
|
109
|
+
"labelPositions": { "$ref": "#/$defs/stringArray" },
|
|
110
|
+
"layouts": { "$ref": "#/$defs/stringArray" },
|
|
111
|
+
"modes": { "$ref": "#/$defs/stringArray" },
|
|
112
|
+
"offsets": { "$ref": "#/$defs/stringArray" },
|
|
113
|
+
"options": { "$ref": "#/$defs/stringArray" },
|
|
114
|
+
"orientations": { "$ref": "#/$defs/stringArray" },
|
|
115
|
+
"platforms": { "$ref": "#/$defs/stringArray" },
|
|
116
|
+
"pointerPositions": { "$ref": "#/$defs/stringArray" },
|
|
117
|
+
"selectionTypes": { "$ref": "#/$defs/stringArray" },
|
|
118
|
+
"shapes": { "$ref": "#/$defs/stringArray" },
|
|
119
|
+
"sides": { "$ref": "#/$defs/stringArray" },
|
|
120
|
+
"sizes": { "$ref": "#/$defs/stringArray" },
|
|
121
|
+
"states": { "$ref": "#/$defs/stringArray" },
|
|
122
|
+
"statusColors": { "$ref": "#/$defs/stringArray" },
|
|
123
|
+
"styles": { "$ref": "#/$defs/stringArray" },
|
|
124
|
+
"tokens": { "$ref": "#/$defs/stringArray" },
|
|
125
|
+
"tones": { "$ref": "#/$defs/stringArray" },
|
|
126
|
+
"types": { "$ref": "#/$defs/stringArray" },
|
|
127
|
+
"valueModes": { "$ref": "#/$defs/stringArray" },
|
|
128
|
+
"variants": { "$ref": "#/$defs/stringArray" },
|
|
129
|
+
"widths": { "$ref": "#/$defs/stringArray" }
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"dependencies": {
|
|
133
|
+
"type": "object",
|
|
134
|
+
"additionalProperties": { "type": "string", "minLength": 1 }
|
|
135
|
+
},
|
|
136
|
+
"stringArray": {
|
|
137
|
+
"type": "array",
|
|
138
|
+
"uniqueItems": true,
|
|
139
|
+
"items": { "type": "string", "minLength": 1 }
|
|
140
|
+
},
|
|
141
|
+
"exportName": {
|
|
142
|
+
"type": "string",
|
|
143
|
+
"pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
|
|
144
|
+
},
|
|
145
|
+
"componentPartName": {
|
|
146
|
+
"type": "string",
|
|
147
|
+
"pattern": "^[A-Z][A-Za-z0-9_$]*$"
|
|
148
|
+
},
|
|
149
|
+
"componentProp": {
|
|
150
|
+
"type": "object",
|
|
151
|
+
"required": ["type", "default", "description"],
|
|
152
|
+
"additionalProperties": false,
|
|
153
|
+
"properties": {
|
|
154
|
+
"type": { "type": "string", "minLength": 1 },
|
|
155
|
+
"default": {
|
|
156
|
+
"type": ["string", "number", "boolean", "null"]
|
|
157
|
+
},
|
|
158
|
+
"description": { "type": "string", "minLength": 1 },
|
|
159
|
+
"deprecated": { "type": "boolean" }
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"supportedExportModule": {
|
|
163
|
+
"type": "object",
|
|
164
|
+
"required": ["source", "values"],
|
|
165
|
+
"additionalProperties": false,
|
|
166
|
+
"properties": {
|
|
167
|
+
"source": {
|
|
168
|
+
"description": "Exact TypeScript source path from this component's files array.",
|
|
169
|
+
"type": "string",
|
|
170
|
+
"pattern": "^(?!.*\\.d\\.[cm]?[jt]sx?$).+\\.[cm]?[jt]sx?$"
|
|
171
|
+
},
|
|
172
|
+
"values": {
|
|
173
|
+
"type": "array",
|
|
174
|
+
"minItems": 1,
|
|
175
|
+
"uniqueItems": true,
|
|
176
|
+
"items": { "$ref": "#/$defs/exportName" }
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"registryFile": {
|
|
181
|
+
"type": "object",
|
|
182
|
+
"required": ["source", "target"],
|
|
183
|
+
"additionalProperties": false,
|
|
184
|
+
"properties": {
|
|
185
|
+
"source": { "type": "string", "minLength": 1 },
|
|
186
|
+
"target": { "type": "string", "minLength": 1 }
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "urn:banhaten:schema:tokens",
|
|
4
|
+
"title": "Banhaten design tokens",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["name", "sourceStatus", "sourceFiles", "provenance", "modes", "cssContract", "tokens", "cssVariables"],
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"$schema": { "type": "string" },
|
|
10
|
+
"name": { "type": "string", "minLength": 1 },
|
|
11
|
+
"sourceStatus": { "const": "manually-curated-from-reference-archives" },
|
|
12
|
+
"sourceFiles": {
|
|
13
|
+
"type": "array",
|
|
14
|
+
"minItems": 1,
|
|
15
|
+
"uniqueItems": true,
|
|
16
|
+
"items": { "type": "string", "minLength": 1 }
|
|
17
|
+
},
|
|
18
|
+
"provenance": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"required": ["method", "lastReviewed", "themeSources", "notes"],
|
|
21
|
+
"additionalProperties": false,
|
|
22
|
+
"properties": {
|
|
23
|
+
"method": { "type": "string", "minLength": 1 },
|
|
24
|
+
"lastReviewed": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
|
|
25
|
+
"themeSources": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"minProperties": 1,
|
|
28
|
+
"additionalProperties": { "type": "string", "minLength": 1 }
|
|
29
|
+
},
|
|
30
|
+
"notes": {
|
|
31
|
+
"type": "array",
|
|
32
|
+
"minItems": 1,
|
|
33
|
+
"items": { "type": "string", "minLength": 1 }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"modes": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"required": ["color", "theme", "radius", "numbers"],
|
|
40
|
+
"additionalProperties": false,
|
|
41
|
+
"properties": {
|
|
42
|
+
"color": { "$ref": "#/$defs/stringArray" },
|
|
43
|
+
"theme": { "$ref": "#/$defs/stringArray" },
|
|
44
|
+
"radius": { "$ref": "#/$defs/stringArray" },
|
|
45
|
+
"numbers": { "$ref": "#/$defs/stringArray" }
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"cssContract": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"required": ["semanticPrefix", "fontFamily", "fontFamilies", "defaultTheme", "defaultNeutralTheme", "defaultRadius", "shadcnAliases", "shadowTokens"],
|
|
51
|
+
"additionalProperties": false,
|
|
52
|
+
"properties": {
|
|
53
|
+
"semanticPrefix": { "type": "string", "minLength": 1 },
|
|
54
|
+
"fontFamily": { "type": "string", "minLength": 1 },
|
|
55
|
+
"fontFamilies": {
|
|
56
|
+
"type": "object",
|
|
57
|
+
"required": ["english", "arabic", "fallback"],
|
|
58
|
+
"additionalProperties": false,
|
|
59
|
+
"properties": {
|
|
60
|
+
"english": { "type": "string", "minLength": 1 },
|
|
61
|
+
"arabic": { "type": "string", "minLength": 1 },
|
|
62
|
+
"fallback": { "type": "string", "minLength": 1 }
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"defaultTheme": { "type": "string", "minLength": 1 },
|
|
66
|
+
"defaultNeutralTheme": { "type": "string", "minLength": 1 },
|
|
67
|
+
"defaultRadius": { "type": "string", "minLength": 1 },
|
|
68
|
+
"shadowTokens": { "type": "string" },
|
|
69
|
+
"shadcnAliases": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"minProperties": 1,
|
|
72
|
+
"additionalProperties": { "type": "string", "pattern": "^--" }
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"tokens": {
|
|
77
|
+
"type": "object",
|
|
78
|
+
"required": ["colorMode", "theme", "numbers", "radius"],
|
|
79
|
+
"additionalProperties": false,
|
|
80
|
+
"properties": {
|
|
81
|
+
"colorMode": { "$ref": "#/$defs/modeTokenMaps" },
|
|
82
|
+
"theme": { "$ref": "#/$defs/modeTokenMaps" },
|
|
83
|
+
"numbers": { "$ref": "#/$defs/tokenMap" },
|
|
84
|
+
"radius": { "$ref": "#/$defs/modeTokenMaps" }
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"cssVariables": {
|
|
88
|
+
"type": "object",
|
|
89
|
+
"required": ["system", "typography", "effects", "components", "darkEffects", "scopedAliases"],
|
|
90
|
+
"additionalProperties": false,
|
|
91
|
+
"properties": {
|
|
92
|
+
"system": { "$ref": "#/$defs/cssVariableMap" },
|
|
93
|
+
"typography": { "$ref": "#/$defs/cssVariableMap" },
|
|
94
|
+
"effects": { "$ref": "#/$defs/cssVariableMap" },
|
|
95
|
+
"components": { "$ref": "#/$defs/cssVariableMap" },
|
|
96
|
+
"darkEffects": { "$ref": "#/$defs/cssVariableMap" },
|
|
97
|
+
"scopedAliases": { "$ref": "#/$defs/cssVariableMap" }
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"$defs": {
|
|
102
|
+
"stringArray": {
|
|
103
|
+
"type": "array",
|
|
104
|
+
"minItems": 1,
|
|
105
|
+
"uniqueItems": true,
|
|
106
|
+
"items": { "type": "string", "minLength": 1 }
|
|
107
|
+
},
|
|
108
|
+
"modeTokenMaps": {
|
|
109
|
+
"type": "object",
|
|
110
|
+
"minProperties": 1,
|
|
111
|
+
"additionalProperties": { "$ref": "#/$defs/tokenMap" }
|
|
112
|
+
},
|
|
113
|
+
"tokenMap": {
|
|
114
|
+
"type": "object",
|
|
115
|
+
"minProperties": 1,
|
|
116
|
+
"additionalProperties": { "$ref": "#/$defs/token" }
|
|
117
|
+
},
|
|
118
|
+
"token": {
|
|
119
|
+
"oneOf": [
|
|
120
|
+
{
|
|
121
|
+
"type": "object",
|
|
122
|
+
"required": ["type", "value"],
|
|
123
|
+
"additionalProperties": false,
|
|
124
|
+
"properties": {
|
|
125
|
+
"type": { "const": "color" },
|
|
126
|
+
"value": {
|
|
127
|
+
"type": "string",
|
|
128
|
+
"pattern": "^(?:#[0-9A-Fa-f]{6,8}|rgb\\([^\\n]+\\))$"
|
|
129
|
+
},
|
|
130
|
+
"alias": { "type": ["string", "null"], "minLength": 1 }
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"type": "object",
|
|
135
|
+
"required": ["type", "value"],
|
|
136
|
+
"additionalProperties": false,
|
|
137
|
+
"properties": {
|
|
138
|
+
"type": { "const": "number" },
|
|
139
|
+
"value": { "type": "number" },
|
|
140
|
+
"alias": { "type": ["string", "null"], "minLength": 1 }
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
"cssVariableMap": {
|
|
146
|
+
"type": "object",
|
|
147
|
+
"minProperties": 1,
|
|
148
|
+
"propertyNames": { "pattern": "^--(?:bh|shadow)-[a-z0-9-]+$" },
|
|
149
|
+
"additionalProperties": { "$ref": "#/$defs/cssVariableToken" }
|
|
150
|
+
},
|
|
151
|
+
"cssVariableToken": {
|
|
152
|
+
"type": "object",
|
|
153
|
+
"required": ["type", "value"],
|
|
154
|
+
"additionalProperties": false,
|
|
155
|
+
"properties": {
|
|
156
|
+
"type": {
|
|
157
|
+
"enum": ["alias", "cubicBezier", "dimension", "duration", "number", "shadow", "string"]
|
|
158
|
+
},
|
|
159
|
+
"value": { "type": "string", "minLength": 1 }
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { parseArgs as parseNodeArgs } from "node:util"
|
|
2
|
+
|
|
3
|
+
const OPTION_DEFINITIONS = {
|
|
4
|
+
cwd: { type: "string" },
|
|
5
|
+
file: { type: "string" },
|
|
6
|
+
"dry-run": { type: "boolean" },
|
|
7
|
+
force: { type: "boolean" },
|
|
8
|
+
help: { type: "boolean", short: "h" },
|
|
9
|
+
json: { type: "boolean" },
|
|
10
|
+
silent: { type: "boolean", short: "s" },
|
|
11
|
+
version: { type: "boolean", short: "v" },
|
|
12
|
+
yes: { type: "boolean", short: "y" },
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const GLOBAL_OPTIONS = ["help", "silent", "version", "yes"]
|
|
16
|
+
|
|
17
|
+
const COMMAND_SCHEMAS = {
|
|
18
|
+
add: commandSchema({
|
|
19
|
+
minPositionals: 1,
|
|
20
|
+
maxPositionals: Number.POSITIVE_INFINITY,
|
|
21
|
+
options: ["cwd", "dry-run", "force", "json"],
|
|
22
|
+
}),
|
|
23
|
+
diff: commandSchema({
|
|
24
|
+
maxPositionals: Number.POSITIVE_INFINITY,
|
|
25
|
+
options: ["cwd", "json"],
|
|
26
|
+
}),
|
|
27
|
+
docs: commandSchema({
|
|
28
|
+
minPositionals: 1,
|
|
29
|
+
maxPositionals: 1,
|
|
30
|
+
options: ["json"],
|
|
31
|
+
}),
|
|
32
|
+
doctor: commandSchema({
|
|
33
|
+
maxPositionals: 0,
|
|
34
|
+
options: ["cwd", "json"],
|
|
35
|
+
}),
|
|
36
|
+
help: commandSchema(),
|
|
37
|
+
init: commandSchema({
|
|
38
|
+
maxPositionals: 0,
|
|
39
|
+
options: ["cwd", "dry-run", "force", "json"],
|
|
40
|
+
}),
|
|
41
|
+
list: commandSchema({ maxPositionals: 0, options: ["json"] }),
|
|
42
|
+
search: commandSchema({
|
|
43
|
+
minPositionals: 1,
|
|
44
|
+
maxPositionals: Number.POSITIVE_INFINITY,
|
|
45
|
+
options: ["json"],
|
|
46
|
+
}),
|
|
47
|
+
update: commandSchema({
|
|
48
|
+
maxPositionals: Number.POSITIVE_INFINITY,
|
|
49
|
+
options: ["cwd", "dry-run", "force", "json"],
|
|
50
|
+
}),
|
|
51
|
+
version: commandSchema({ maxPositionals: 0 }),
|
|
52
|
+
view: commandSchema({
|
|
53
|
+
minPositionals: 1,
|
|
54
|
+
maxPositionals: 1,
|
|
55
|
+
options: ["file", "json"],
|
|
56
|
+
}),
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function parseCommandLine(argv) {
|
|
60
|
+
let parsed
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
parsed = parseNodeArgs({
|
|
64
|
+
allowPositionals: true,
|
|
65
|
+
args: argv,
|
|
66
|
+
options: OPTION_DEFINITIONS,
|
|
67
|
+
strict: true,
|
|
68
|
+
tokens: true,
|
|
69
|
+
})
|
|
70
|
+
} catch (error) {
|
|
71
|
+
throw new Error(normalizeParseError(error))
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
assertNoDuplicateOptions(parsed.tokens)
|
|
75
|
+
assertNonEmptyValueOptions(parsed.values)
|
|
76
|
+
|
|
77
|
+
const [command, ...positionals] = parsed.positionals
|
|
78
|
+
const flags = { ...parsed.values }
|
|
79
|
+
|
|
80
|
+
if (command === undefined) {
|
|
81
|
+
assertRootOptions(flags)
|
|
82
|
+
return { command: undefined, flags, positionals }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const schema = COMMAND_SCHEMAS[command]
|
|
86
|
+
if (!schema) {
|
|
87
|
+
throw new Error(`unknown command "${command}"`)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
assertAllowedOptions(command, flags, schema)
|
|
91
|
+
|
|
92
|
+
if (!flags.help && !flags.version) {
|
|
93
|
+
assertPositionalCount(command, positionals, schema)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return { command, flags, positionals }
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function commandSchema({
|
|
100
|
+
minPositionals = 0,
|
|
101
|
+
maxPositionals = 0,
|
|
102
|
+
options = [],
|
|
103
|
+
} = {}) {
|
|
104
|
+
return {
|
|
105
|
+
minPositionals,
|
|
106
|
+
maxPositionals,
|
|
107
|
+
options: new Set([...GLOBAL_OPTIONS, ...options]),
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function assertRootOptions(flags) {
|
|
112
|
+
const allowed = new Set(GLOBAL_OPTIONS)
|
|
113
|
+
for (const name of Object.keys(flags)) {
|
|
114
|
+
if (!allowed.has(name)) {
|
|
115
|
+
throw new Error(`option "--${name}" requires a command`)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function assertAllowedOptions(command, flags, schema) {
|
|
121
|
+
for (const name of Object.keys(flags)) {
|
|
122
|
+
if (!schema.options.has(name)) {
|
|
123
|
+
throw new Error(`option "--${name}" is not valid for command "${command}"`)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function assertPositionalCount(command, positionals, schema) {
|
|
129
|
+
if (positionals.length < schema.minPositionals) {
|
|
130
|
+
if (command === "add") {
|
|
131
|
+
throw new Error("missing component name. Try `banhaten add button`.")
|
|
132
|
+
}
|
|
133
|
+
if (command === "search") {
|
|
134
|
+
throw new Error("missing search query. Try `banhaten search input`.")
|
|
135
|
+
}
|
|
136
|
+
throw new Error(
|
|
137
|
+
`missing argument for command "${command}"`
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (positionals.length > schema.maxPositionals) {
|
|
142
|
+
const unexpected = positionals[schema.maxPositionals]
|
|
143
|
+
throw new Error(
|
|
144
|
+
`unexpected argument "${unexpected}" for command "${command}"`
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function assertNoDuplicateOptions(tokens) {
|
|
150
|
+
const seen = new Set()
|
|
151
|
+
|
|
152
|
+
for (const token of tokens) {
|
|
153
|
+
if (token.kind !== "option") continue
|
|
154
|
+
if (seen.has(token.name)) {
|
|
155
|
+
throw new Error(`option "--${token.name}" was provided more than once`)
|
|
156
|
+
}
|
|
157
|
+
seen.add(token.name)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function assertNonEmptyValueOptions(values) {
|
|
162
|
+
for (const name of ["cwd", "file"]) {
|
|
163
|
+
if (name in values && values[name].trim() === "") {
|
|
164
|
+
throw new Error(`option "--${name}" requires a non-empty value`)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function normalizeParseError(error) {
|
|
170
|
+
if (error?.code === "ERR_PARSE_ARGS_UNKNOWN_OPTION") {
|
|
171
|
+
const match = error.message.match(/Unknown option '([^']+)'/)
|
|
172
|
+
return match ? `unknown option "${match[1]}"` : error.message
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (error?.code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE") {
|
|
176
|
+
const missing = error.message.match(/Option '([^']+)' argument missing/)
|
|
177
|
+
if (missing) {
|
|
178
|
+
const optionName = missing[1]
|
|
179
|
+
.split(", ")
|
|
180
|
+
.at(-1)
|
|
181
|
+
.replace(/\s*<value>\s*$/, "")
|
|
182
|
+
.trim()
|
|
183
|
+
return `option "${optionName}" requires a value`
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const ambiguous = error.message.match(/Option '([^']+)' argument is ambiguous/)
|
|
187
|
+
if (ambiguous) return `option "${ambiguous[1]}" requires a value`
|
|
188
|
+
|
|
189
|
+
const booleanValue = error.message.match(/Option '([^']+)' does not take an argument/)
|
|
190
|
+
if (booleanValue) return `option "${booleanValue[1]}" does not take a value`
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return error?.message || String(error)
|
|
194
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Facade over the config editors. Kept so callers have one import site while
|
|
2
|
+
// the JSONC, Vite, and scanner concerns stay in separate modules.
|
|
3
|
+
|
|
4
|
+
export { parseJsonc, updateJsoncAliasSource } from "./jsonc.js"
|
|
5
|
+
export {
|
|
6
|
+
readViteAliasKeys,
|
|
7
|
+
readViteAliasSourceRoot,
|
|
8
|
+
updateViteConfigSource,
|
|
9
|
+
} from "./vite-config.js"
|