zard-cli 1.0.0-beta.12 → 1.0.0-beta.121
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 +39 -167
- package/commands/add/component-installer.d.ts +4 -1
- package/commands/add/component-installer.d.ts.map +1 -1
- package/commands/add/component-installer.js +33 -5
- package/commands/add/component-installer.js.map +1 -1
- package/commands/add/component-selector.d.ts +6 -0
- package/commands/add/component-selector.d.ts.map +1 -1
- package/commands/add/component-selector.js +9 -27
- package/commands/add/component-selector.js.map +1 -1
- package/commands/add/dark-mode-setup.d.ts +2 -0
- package/commands/add/dark-mode-setup.d.ts.map +1 -1
- package/commands/add/dark-mode-setup.js +5 -11
- package/commands/add/dark-mode-setup.js.map +1 -1
- package/commands/add/dependency-resolver.d.ts +5 -2
- package/commands/add/dependency-resolver.d.ts.map +1 -1
- package/commands/add/dependency-resolver.js +54 -20
- package/commands/add/dependency-resolver.js.map +1 -1
- package/commands/add/index.d.ts.map +1 -1
- package/commands/add/index.js +135 -86
- package/commands/add/index.js.map +1 -1
- package/commands/add/typeset-setup.d.ts +12 -0
- package/commands/add/typeset-setup.d.ts.map +1 -0
- package/commands/add/typeset-setup.js +68 -0
- package/commands/add/typeset-setup.js.map +1 -0
- package/commands/add/wizard.d.ts +34 -0
- package/commands/add/wizard.d.ts.map +1 -0
- package/commands/add/wizard.js +295 -0
- package/commands/add/wizard.js.map +1 -0
- package/commands/init/config-prompter.d.ts +66 -56
- package/commands/init/config-prompter.d.ts.map +1 -1
- package/commands/init/config-prompter.js +90 -74
- package/commands/init/config-prompter.js.map +1 -1
- package/commands/init/dependencies.d.ts +1 -8
- package/commands/init/dependencies.d.ts.map +1 -1
- package/commands/init/dependencies.js +51 -23
- package/commands/init/dependencies.js.map +1 -1
- package/commands/init/index.d.ts.map +1 -1
- package/commands/init/index.js +150 -86
- package/commands/init/index.js.map +1 -1
- package/commands/init/project-kind.d.ts +82 -0
- package/commands/init/project-kind.d.ts.map +1 -0
- package/commands/init/project-kind.js +166 -0
- package/commands/init/project-kind.js.map +1 -0
- package/commands/init/steps.d.ts +15 -0
- package/commands/init/steps.d.ts.map +1 -0
- package/commands/init/steps.js +154 -0
- package/commands/init/steps.js.map +1 -0
- package/commands/init/tailwind-setup.d.ts +9 -2
- package/commands/init/tailwind-setup.d.ts.map +1 -1
- package/commands/init/tailwind-setup.js +33 -9
- package/commands/init/tailwind-setup.js.map +1 -1
- package/commands/init/theme-loader.d.ts.map +1 -1
- package/commands/init/theme-loader.js +1 -3
- package/commands/init/theme-loader.js.map +1 -1
- package/commands/init/tsconfig-updater.d.ts +8 -1
- package/commands/init/tsconfig-updater.d.ts.map +1 -1
- package/commands/init/tsconfig-updater.js +30 -11
- package/commands/init/tsconfig-updater.js.map +1 -1
- package/commands/init/update-angular-config.d.ts.map +1 -1
- package/commands/init/update-angular-config.js +28 -47
- package/commands/init/update-angular-config.js.map +1 -1
- package/commands/init/vite-setup.d.ts +11 -0
- package/commands/init/vite-setup.d.ts.map +1 -0
- package/commands/init/vite-setup.js +61 -0
- package/commands/init/vite-setup.js.map +1 -0
- package/commands/init/wizard.d.ts +30 -0
- package/commands/init/wizard.d.ts.map +1 -0
- package/commands/init/wizard.js +560 -0
- package/commands/init/wizard.js.map +1 -0
- package/core/icons/families.d.ts +38 -0
- package/core/icons/families.d.ts.map +1 -0
- package/core/icons/families.js +26 -0
- package/core/icons/families.js.map +1 -0
- package/core/icons/icon-map.d.ts +24 -0
- package/core/icons/icon-map.d.ts.map +1 -0
- package/core/icons/icon-map.js +135 -0
- package/core/icons/icon-map.js.map +1 -0
- package/core/icons/index.d.ts +107 -0
- package/core/icons/index.d.ts.map +1 -0
- package/core/icons/index.js +183 -0
- package/core/icons/index.js.map +1 -0
- package/core/registry/registry-data.d.ts.map +1 -1
- package/core/registry/registry-data.js +752 -126
- package/core/registry/registry-data.js.map +1 -1
- package/core/themes/theme-definitions.d.ts +5 -5
- package/core/themes/theme-definitions.d.ts.map +1 -1
- package/core/themes/theme-definitions.js +75 -61
- package/core/themes/theme-definitions.js.map +1 -1
- package/index.js +41 -4
- package/index.js.map +1 -1
- package/package.json +9 -14
- package/ui/blocks.d.ts +71 -0
- package/ui/blocks.d.ts.map +1 -0
- package/ui/blocks.js +116 -0
- package/ui/blocks.js.map +1 -0
- package/ui/brand.d.ts +14 -0
- package/ui/brand.d.ts.map +1 -0
- package/ui/brand.js +35 -0
- package/ui/brand.js.map +1 -0
- package/ui/engine/animation/index.d.ts +38 -0
- package/ui/engine/animation/index.d.ts.map +1 -0
- package/ui/engine/animation/index.js +102 -0
- package/ui/engine/animation/index.js.map +1 -0
- package/ui/engine/ansi/index.d.ts +51 -0
- package/ui/engine/ansi/index.d.ts.map +1 -0
- package/ui/engine/ansi/index.js +116 -0
- package/ui/engine/ansi/index.js.map +1 -0
- package/ui/engine/components/index.d.ts +211 -0
- package/ui/engine/components/index.d.ts.map +1 -0
- package/ui/engine/components/index.js +109 -0
- package/ui/engine/components/index.js.map +1 -0
- package/ui/engine/cursor/index.d.ts +16 -0
- package/ui/engine/cursor/index.d.ts.map +1 -0
- package/ui/engine/cursor/index.js +40 -0
- package/ui/engine/cursor/index.js.map +1 -0
- package/ui/engine/diff/index.d.ts +26 -0
- package/ui/engine/diff/index.d.ts.map +1 -0
- package/ui/engine/diff/index.js +56 -0
- package/ui/engine/diff/index.js.map +1 -0
- package/ui/engine/events/index.d.ts +24 -0
- package/ui/engine/events/index.d.ts.map +1 -0
- package/ui/engine/events/index.js +60 -0
- package/ui/engine/events/index.js.map +1 -0
- package/ui/engine/focus/index.d.ts +25 -0
- package/ui/engine/focus/index.d.ts.map +1 -0
- package/ui/engine/focus/index.js +77 -0
- package/ui/engine/focus/index.js.map +1 -0
- package/ui/engine/frame/index.d.ts +48 -0
- package/ui/engine/frame/index.d.ts.map +1 -0
- package/ui/engine/frame/index.js +0 -0
- package/ui/engine/frame/index.js.map +1 -0
- package/ui/engine/index.d.ts +28 -0
- package/ui/engine/index.d.ts.map +1 -0
- package/ui/engine/index.js +28 -0
- package/ui/engine/index.js.map +1 -0
- package/ui/engine/input/index.d.ts +36 -0
- package/ui/engine/input/index.d.ts.map +1 -0
- package/ui/engine/input/index.js +224 -0
- package/ui/engine/input/index.js.map +1 -0
- package/ui/engine/layout/index.d.ts +42 -0
- package/ui/engine/layout/index.d.ts.map +1 -0
- package/ui/engine/layout/index.js +241 -0
- package/ui/engine/layout/index.js.map +1 -0
- package/ui/engine/renderer/index.d.ts +43 -0
- package/ui/engine/renderer/index.d.ts.map +1 -0
- package/ui/engine/renderer/index.js +619 -0
- package/ui/engine/renderer/index.js.map +1 -0
- package/ui/engine/scheduler/index.d.ts +22 -0
- package/ui/engine/scheduler/index.d.ts.map +1 -0
- package/ui/engine/scheduler/index.js +77 -0
- package/ui/engine/scheduler/index.js.map +1 -0
- package/ui/engine/screen/index.d.ts +39 -0
- package/ui/engine/screen/index.d.ts.map +1 -0
- package/ui/engine/screen/index.js +255 -0
- package/ui/engine/screen/index.js.map +1 -0
- package/ui/engine/terminal/index.d.ts +84 -0
- package/ui/engine/terminal/index.d.ts.map +1 -0
- package/ui/engine/terminal/index.js +235 -0
- package/ui/engine/terminal/index.js.map +1 -0
- package/ui/engine/testing/index.d.ts +27 -0
- package/ui/engine/testing/index.d.ts.map +1 -0
- package/ui/engine/testing/index.js +63 -0
- package/ui/engine/testing/index.js.map +1 -0
- package/ui/engine/theme/index.d.ts +26 -0
- package/ui/engine/theme/index.d.ts.map +1 -0
- package/ui/engine/theme/index.js +128 -0
- package/ui/engine/theme/index.js.map +1 -0
- package/ui/engine/utils/index.d.ts +12 -0
- package/ui/engine/utils/index.d.ts.map +1 -0
- package/ui/engine/utils/index.js +143 -0
- package/ui/engine/utils/index.js.map +1 -0
- package/ui/gate.d.ts +19 -0
- package/ui/gate.d.ts.map +1 -0
- package/ui/gate.js +36 -0
- package/ui/gate.js.map +1 -0
- package/ui/index.d.ts +18 -0
- package/ui/index.d.ts.map +1 -0
- package/ui/index.js +18 -0
- package/ui/index.js.map +1 -0
- package/ui/log-sink.d.ts +24 -0
- package/ui/log-sink.d.ts.map +1 -0
- package/ui/log-sink.js +35 -0
- package/ui/log-sink.js.map +1 -0
- package/ui/output.d.ts +14 -0
- package/ui/output.d.ts.map +1 -0
- package/ui/output.js +28 -0
- package/ui/output.js.map +1 -0
- package/ui/report.d.ts +30 -0
- package/ui/report.d.ts.map +1 -0
- package/ui/report.js +45 -0
- package/ui/report.js.map +1 -0
- package/ui/runner.d.ts +66 -0
- package/ui/runner.d.ts.map +1 -0
- package/ui/runner.js +135 -0
- package/ui/runner.js.map +1 -0
- package/ui/style.d.ts +24 -0
- package/ui/style.d.ts.map +1 -0
- package/ui/style.js +44 -0
- package/ui/style.js.map +1 -0
- package/ui/testing/fake-tty.d.ts +26 -0
- package/ui/testing/fake-tty.d.ts.map +1 -0
- package/ui/testing/fake-tty.js +61 -0
- package/ui/testing/fake-tty.js.map +1 -0
- package/ui/text-input.d.ts +31 -0
- package/ui/text-input.d.ts.map +1 -0
- package/ui/text-input.js +89 -0
- package/ui/text-input.js.map +1 -0
- package/ui/theme.d.ts +10 -0
- package/ui/theme.d.ts.map +1 -0
- package/ui/theme.js +20 -0
- package/ui/theme.js.map +1 -0
- package/utils/angular-compat.d.ts +21 -0
- package/utils/angular-compat.d.ts.map +1 -0
- package/utils/angular-compat.js +52 -0
- package/utils/angular-compat.js.map +1 -0
- package/utils/config.d.ts +52 -69
- package/utils/config.d.ts.map +1 -1
- package/utils/config.js +60 -9
- package/utils/config.js.map +1 -1
- package/utils/errors.d.ts +27 -0
- package/utils/errors.d.ts.map +1 -0
- package/utils/errors.js +45 -0
- package/utils/errors.js.map +1 -0
- package/utils/get-package-info.js +4 -4
- package/utils/get-package-info.js.map +1 -1
- package/utils/get-project-info.d.ts +30 -0
- package/utils/get-project-info.d.ts.map +1 -1
- package/utils/get-project-info.js +195 -6
- package/utils/get-project-info.js.map +1 -1
- package/utils/http-client.d.ts +8 -0
- package/utils/http-client.d.ts.map +1 -0
- package/utils/http-client.js +83 -0
- package/utils/http-client.js.map +1 -0
- package/utils/icon-catalog.d.ts +34 -0
- package/utils/icon-catalog.d.ts.map +1 -0
- package/utils/icon-catalog.js +63 -0
- package/utils/icon-catalog.js.map +1 -0
- package/utils/logger.d.ts +16 -1
- package/utils/logger.d.ts.map +1 -1
- package/utils/logger.js +104 -12
- package/utils/logger.js.map +1 -1
- package/utils/package-manager.d.ts +44 -1
- package/utils/package-manager.d.ts.map +1 -1
- package/utils/package-manager.js +210 -14
- package/utils/package-manager.js.map +1 -1
- package/utils/registry.d.ts +44 -2
- package/utils/registry.d.ts.map +1 -1
- package/utils/registry.js +89 -30
- package/utils/registry.js.map +1 -1
- package/utils/schema-version.d.ts +21 -0
- package/utils/schema-version.d.ts.map +1 -0
- package/utils/schema-version.js +28 -0
- package/utils/schema-version.js.map +1 -0
- package/utils/source-file.d.ts +40 -0
- package/utils/source-file.d.ts.map +1 -0
- package/utils/source-file.js +104 -0
- package/utils/source-file.js.map +1 -0
- package/utils/theme-selector.d.ts +1 -1
- package/utils/theme-selector.d.ts.map +1 -1
- package/utils/theme-selector.js +6 -6
- package/utils/theme-selector.js.map +1 -1
- package/utils/fetch-component.d.ts +0 -3
- package/utils/fetch-component.d.ts.map +0 -1
- package/utils/fetch-component.js +0 -75
- package/utils/fetch-component.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,188 +1,60 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Zard
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Modern Angular component library inspired by shadcn/ui, built with TailwindCSS and designed for developers who value <b>beautiful</b>, <b>accessible</b>, and <b>completely free</b> open source components.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<a alt="Zard Ui logo" href="https://www.zardui.com/" target="_blank" rel="noreferrer">
|
|
6
|
+
<img align="center" width=100% src="https://www.zardui.com/images/github_banner.png"/>
|
|
7
|
+
</a>
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## ✨ Features
|
|
13
|
-
|
|
14
|
-
- 🎨 **Beautiful Components** - Modern, accessible UI components
|
|
15
|
-
- ⚡ **TailwindCSS v4** - Latest CSS framework with native cascade layers
|
|
16
|
-
- 🔧 **TypeScript First** - Built for modern Angular with full type safety
|
|
17
|
-
- 🎯 **Angular Focused** - Designed specifically for the Angular ecosystem
|
|
18
|
-
- 📱 **Responsive** - Mobile-first components that work everywhere
|
|
19
|
-
- 🌙 **Dark Mode** - Built-in dark mode support
|
|
20
|
-
- 🧩 **Modular** - Add only the components you need
|
|
21
|
-
|
|
22
|
-
## Installation
|
|
9
|
+
<p align="center">Made with ❤️ from 🇧🇷</p>
|
|
10
|
+
<p align="center">
|
|
11
|
+
<img src="https://img.shields.io/github/stars/zard-ui/zardui" alt="zard ui repository stars"/>
|
|
12
|
+
</p>
|
|
23
13
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
# Initialize your project
|
|
28
|
-
npx @ngzard/ui@latest init
|
|
29
|
-
|
|
30
|
-
# Add components to your project
|
|
31
|
-
npx @ngzard/ui@latest add button
|
|
32
|
-
npx @ngzard/ui@latest add button card dialog
|
|
33
|
-
|
|
34
|
-
# Add all components
|
|
35
|
-
npx @ngzard/ui@latest add --all
|
|
36
|
-
```
|
|
14
|
+
## Stack
|
|
37
15
|
|
|
38
|
-
|
|
16
|
+

|
|
17
|
+

|
|
18
|
+

|
|
39
19
|
|
|
40
|
-
|
|
20
|
+
## Documentation
|
|
41
21
|
|
|
42
|
-
|
|
22
|
+
Visit https://www.zardui.com/docs to view the documentation
|
|
43
23
|
|
|
44
|
-
|
|
45
|
-
npx @ngzard/ui@latest init
|
|
46
|
-
```
|
|
24
|
+
## Contributing
|
|
47
25
|
|
|
48
|
-
|
|
49
|
-
- Install required dependencies (Tailwind CSS v4, class-variance-authority, etc.)
|
|
50
|
-
- Create `.postcssrc.json` for Tailwind CSS PostCSS plugin
|
|
51
|
-
- Set up `src/styles.css` with Tailwind configuration and design tokens
|
|
52
|
-
- Configure TypeScript path mappings in `tsconfig.json`
|
|
53
|
-
- Create utility functions in `src/app/shared/utils/`
|
|
26
|
+
We follow a **simple GitHub Flow** with automated releases. Please read our [contributing guide](/CONTRIBUTING.md) to get started.
|
|
54
27
|
|
|
55
|
-
|
|
56
|
-
- `-y, --yes` - Skip confirmation prompts
|
|
57
|
-
- `-c, --cwd <path>` - Specify working directory
|
|
28
|
+
### Quick Start for Contributors
|
|
58
29
|
|
|
59
|
-
|
|
30
|
+
1. Fork the repository
|
|
31
|
+
2. Create your feature branch: `git checkout -b feat/#123-your-feature`
|
|
32
|
+
3. Develop with as many commits as you want
|
|
33
|
+
4. Open a PR to `master`
|
|
34
|
+
5. After review + merge = automatic release!
|
|
60
35
|
|
|
61
|
-
|
|
36
|
+
### Development Commands
|
|
62
37
|
|
|
63
38
|
```bash
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
# Add a single component
|
|
70
|
-
npx @ngzard/ui@latest add button
|
|
71
|
-
|
|
72
|
-
# Add multiple components
|
|
73
|
-
npx @ngzard/ui@latest add button card badge
|
|
74
|
-
|
|
75
|
-
# Add all components
|
|
76
|
-
npx @ngzard/ui@latest add --all
|
|
77
|
-
|
|
78
|
-
# Interactive selection
|
|
79
|
-
npx @ngzard/ui@latest add
|
|
39
|
+
npm start # Start dev server (port 4222)
|
|
40
|
+
npm test # Run all tests
|
|
41
|
+
npm run build # Build production
|
|
42
|
+
npm run release # Automated release
|
|
80
43
|
```
|
|
81
44
|
|
|
82
|
-
|
|
83
|
-
- `-y, --yes` - Skip confirmation prompts
|
|
84
|
-
- `-o, --overwrite` - Overwrite existing files
|
|
85
|
-
- `-c, --cwd <path>` - Specify working directory
|
|
86
|
-
- `-a, --all` - Add all available components
|
|
87
|
-
- `-p, --path <path>` - Custom path for components
|
|
88
|
-
|
|
89
|
-
## Available Components
|
|
90
|
-
|
|
91
|
-
- `accordion` - Collapsible content panels
|
|
92
|
-
- `alert` - Alert messages with variants
|
|
93
|
-
- `avatar` - User profile pictures with fallbacks
|
|
94
|
-
- `badge` - Small status indicators
|
|
95
|
-
- `breadcrumb` - Navigation breadcrumbs
|
|
96
|
-
- `button` - Interactive buttons with variants
|
|
97
|
-
- `card` - Content containers
|
|
98
|
-
- `checkbox` - Form checkboxes
|
|
99
|
-
- `dialog` - Modal dialogs
|
|
100
|
-
- `divider` - Visual separators
|
|
101
|
-
- `dropdown` - Dropdown menus
|
|
102
|
-
- `input` - Form inputs
|
|
103
|
-
- `loader` - Loading indicators
|
|
104
|
-
- `progress-bar` - Progress indicators
|
|
105
|
-
- `radio` - Radio button inputs
|
|
106
|
-
- `select` - Select dropdowns
|
|
107
|
-
- `slider` - Range sliders
|
|
108
|
-
- `switch` - Toggle switches
|
|
109
|
-
- `tabs` - Tabbed interfaces
|
|
110
|
-
- `toggle` - Toggle buttons
|
|
111
|
-
- `tooltip` - Hover tooltips
|
|
112
|
-
|
|
113
|
-
## Configuration
|
|
114
|
-
|
|
115
|
-
The CLI stores configuration in `components.json`:
|
|
116
|
-
|
|
117
|
-
```json
|
|
118
|
-
{
|
|
119
|
-
"style": "css",
|
|
120
|
-
"tailwind": {
|
|
121
|
-
"css": "src/styles.css",
|
|
122
|
-
"baseColor": "slate"
|
|
123
|
-
},
|
|
124
|
-
"baseUrl": "src/app",
|
|
125
|
-
"aliases": {
|
|
126
|
-
"components": "@/shared/components",
|
|
127
|
-
"utils": "@/shared/utils",
|
|
128
|
-
"core": "@/shared/core",
|
|
129
|
-
"services": "@/shared/services"
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## Requirements
|
|
135
|
-
|
|
136
|
-
- Angular 19+
|
|
137
|
-
- Node.js 20 or 22
|
|
138
|
-
- TypeScript project
|
|
139
|
-
|
|
140
|
-
## Path Mappings
|
|
141
|
-
|
|
142
|
-
The CLI automatically configures TypeScript path mappings in your `tsconfig.json`:
|
|
143
|
-
|
|
144
|
-
```json
|
|
145
|
-
{
|
|
146
|
-
"compilerOptions": {
|
|
147
|
-
"baseUrl": "./",
|
|
148
|
-
"paths": {
|
|
149
|
-
"@/*": ["src/app/*"]
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
This allows you to import components and utilities using clean paths:
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
import { ZardButtonComponent } from '@/shared/components/button';
|
|
159
|
-
import { mergeClasses } from '@/shared/utils/merge-classes';
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
## Tailwind CSS v4 Support
|
|
163
|
-
|
|
164
|
-
ZardUI CLI is built specifically for Tailwind CSS v4, using the new inline configuration approach:
|
|
165
|
-
|
|
166
|
-
- No `tailwind.config.js` needed
|
|
167
|
-
- Configuration via `.postcssrc.json`
|
|
168
|
-
- Design tokens defined in CSS with `@theme`
|
|
169
|
-
- Plugin configuration with `@plugin`
|
|
170
|
-
|
|
171
|
-
## Troubleshooting
|
|
172
|
-
|
|
173
|
-
### "Configuration not found"
|
|
174
|
-
Run `npx @ngzard/ui@latest init` first to initialize your project.
|
|
175
|
-
|
|
176
|
-
### "Not an Angular project"
|
|
177
|
-
Make sure you're in the root directory of an Angular project with a `package.json` that includes `@angular/core`.
|
|
45
|
+
## License
|
|
178
46
|
|
|
179
|
-
|
|
180
|
-
The CLI fetches components from GitHub. If you encounter rate limiting, wait a few minutes before retrying.
|
|
47
|
+
Licensed under the [MIT license](/LICENSE.md).
|
|
181
48
|
|
|
182
|
-
##
|
|
49
|
+
## Get In Touch
|
|
183
50
|
|
|
184
|
-
|
|
51
|
+
<p>Click on one of the icons and Help us on this journey and be part of our community.</p>
|
|
185
52
|
|
|
186
|
-
|
|
53
|
+
<a href="https://chat.whatsapp.com/Dctdh6Huhvm24OX6js5XKT" target="_blank">
|
|
54
|
+
<img src="https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge&logo=whatsapp&logoColor=white" alt="whatsapp" />
|
|
55
|
+
</a>
|
|
56
|
+
<img src="https://dcbadge.limes.pink/api/server/https://discord.com/invite/yP8Uj9rAX9" alt="discord" />
|
|
187
57
|
|
|
188
|
-
|
|
58
|
+
<span>Follow us in</span> <a href="https://x.com/zard_ui" target="_blank">
|
|
59
|
+
<img src="https://img.shields.io/badge/X-%23000000.svg?logo=X&logoColor=white" alt="X" />
|
|
60
|
+
</a>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Config } from '../../utils/config';
|
|
2
|
+
export declare function validateTargetPath(targetDir: string, projectRoot: string): void;
|
|
2
3
|
export declare function installComponent(componentName: string, targetDir: string, config: Config & {
|
|
3
4
|
resolvedPaths: any;
|
|
5
|
+
}, options?: {
|
|
6
|
+
customPath?: boolean;
|
|
4
7
|
}): Promise<void>;
|
|
5
8
|
//# sourceMappingURL=component-installer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-installer.d.ts","sourceRoot":"","sources":["../../../src/commands/add/component-installer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"component-installer.d.ts","sourceRoot":"","sources":["../../../src/commands/add/component-installer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAO3C,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAS/E;AAED,wBAAsB,gBAAgB,CACpC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GAAG;IAAE,aAAa,EAAE,GAAG,CAAA;CAAE,EACvC,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACrC,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
|
|
@@ -1,11 +1,38 @@
|
|
|
1
|
+
import { CliError, InstallError } from '../../utils/errors.js';
|
|
2
|
+
import { logger } from '../../utils/logger.js';
|
|
3
|
+
import { fetchComponent } from '../../utils/registry.js';
|
|
1
4
|
import { promises as fs } from 'node:fs';
|
|
2
5
|
import * as path from 'node:path';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
export function validateTargetPath(targetDir, projectRoot) {
|
|
7
|
+
// Comparing string prefixes let a sibling directory through: `/proj-evil`
|
|
8
|
+
// starts with `/proj` without being inside it. The relative path answers the
|
|
9
|
+
// right question — is it contained? — and normalizes any `..` along the way.
|
|
10
|
+
const relative = path.relative(path.resolve(projectRoot), path.resolve(targetDir));
|
|
11
|
+
if (relative.startsWith('..') || path.isAbsolute(relative)) {
|
|
12
|
+
throw new CliError('Target path must be within the project directory', 'INVALID_PATH');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export async function installComponent(componentName, targetDir, config, options = {}) {
|
|
16
|
+
const component = await fetchComponent(componentName, config, undefined, {
|
|
17
|
+
siblingComponents: options.customPath,
|
|
18
|
+
});
|
|
6
19
|
await fs.mkdir(targetDir, { recursive: true });
|
|
7
|
-
|
|
8
|
-
|
|
20
|
+
const writtenFiles = [];
|
|
21
|
+
try {
|
|
22
|
+
for (const file of component.files) {
|
|
23
|
+
const filePath = await installComponentFile(file, targetDir);
|
|
24
|
+
writtenFiles.push(filePath);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
// Rollback: remove all written files
|
|
29
|
+
for (const filePath of writtenFiles) {
|
|
30
|
+
await fs.unlink(filePath).catch(() => {
|
|
31
|
+
/* ignore cleanup errors */
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
logger.debug(`Rolled back ${writtenFiles.length} file(s) for component "${componentName}"`);
|
|
35
|
+
throw new InstallError(`Failed to install component "${componentName}": ${error instanceof Error ? error.message : error}`, componentName);
|
|
9
36
|
}
|
|
10
37
|
}
|
|
11
38
|
async function installComponentFile(file, targetDir) {
|
|
@@ -13,5 +40,6 @@ async function installComponentFile(file, targetDir) {
|
|
|
13
40
|
const fileDir = path.dirname(filePath);
|
|
14
41
|
await fs.mkdir(fileDir, { recursive: true });
|
|
15
42
|
await fs.writeFile(filePath, file.content, 'utf8');
|
|
43
|
+
return filePath;
|
|
16
44
|
}
|
|
17
45
|
//# sourceMappingURL=component-installer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-installer.js","sourceRoot":"","sources":["../../../src/commands/add/component-installer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"component-installer.js","sourceRoot":"","sources":["../../../src/commands/add/component-installer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAgB,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,MAAM,UAAU,kBAAkB,CAAC,SAAiB,EAAE,WAAmB;IACvE,0EAA0E;IAC1E,6EAA6E;IAC7E,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IAEnF,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,QAAQ,CAAC,kDAAkD,EAAE,cAAc,CAAC,CAAC;IACzF,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,aAAqB,EACrB,SAAiB,EAC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AM,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAEnD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Works out which components the command should install, from its arguments.
|
|
3
|
+
*
|
|
4
|
+
* Returns an empty list when nothing was given: the wizard picks in that case
|
|
5
|
+
* (or, with no interactive terminal, the command fails asking for the names).
|
|
6
|
+
*/
|
|
1
7
|
export declare function selectComponents(components: string[], allFlag: boolean): Promise<string[]>;
|
|
2
8
|
//# sourceMappingURL=component-selector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-selector.d.ts","sourceRoot":"","sources":["../../../src/commands/add/component-selector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"component-selector.d.ts","sourceRoot":"","sources":["../../../src/commands/add/component-selector.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAGhG"}
|
|
@@ -1,31 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { getAllComponentNames } from '../../commands/add/dependency-resolver.js';
|
|
2
|
+
/**
|
|
3
|
+
* Works out which components the command should install, from its arguments.
|
|
4
|
+
*
|
|
5
|
+
* Returns an empty list when nothing was given: the wizard picks in that case
|
|
6
|
+
* (or, with no interactive terminal, the command fails asking for the names).
|
|
7
|
+
*/
|
|
4
8
|
export async function selectComponents(components, allFlag) {
|
|
5
|
-
if (allFlag)
|
|
9
|
+
if (allFlag)
|
|
6
10
|
return getAllComponentNames();
|
|
7
|
-
|
|
8
|
-
if (!components?.length) {
|
|
9
|
-
return await promptForComponents();
|
|
10
|
-
}
|
|
11
|
-
return components;
|
|
12
|
-
}
|
|
13
|
-
async function promptForComponents() {
|
|
14
|
-
const allNames = await getAllComponentNames();
|
|
15
|
-
const { components: selected } = await prompts({
|
|
16
|
-
type: 'multiselect',
|
|
17
|
-
name: 'components',
|
|
18
|
-
message: 'Which components would you like to add?',
|
|
19
|
-
hint: 'Space to select. A to toggle all. Enter to submit.',
|
|
20
|
-
choices: allNames.map(name => ({
|
|
21
|
-
title: name,
|
|
22
|
-
value: name,
|
|
23
|
-
})),
|
|
24
|
-
});
|
|
25
|
-
if (!selected?.length) {
|
|
26
|
-
logger.warn('No components selected. Exiting.');
|
|
27
|
-
process.exit(0);
|
|
28
|
-
}
|
|
29
|
-
return selected;
|
|
11
|
+
return components ?? [];
|
|
30
12
|
}
|
|
31
13
|
//# sourceMappingURL=component-selector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-selector.js","sourceRoot":"","sources":["../../../src/commands/add/component-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"component-selector.js","sourceRoot":"","sources":["../../../src/commands/add/component-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,UAAoB,EAAE,OAAgB;IAC3E,IAAI,OAAO;QAAE,OAAO,oBAAoB,EAAE,CAAC;IAC3C,OAAO,UAAU,IAAI,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { type Config } from '../../utils/config.js';
|
|
1
2
|
export declare function updateProvideZardWithDarkMode(cwd: string, resolvedConfig: {
|
|
2
3
|
resolvedPaths: {
|
|
3
4
|
core: string;
|
|
4
5
|
services: string;
|
|
5
6
|
};
|
|
7
|
+
aliases?: Config['aliases'];
|
|
6
8
|
}): Promise<void>;
|
|
7
9
|
//# sourceMappingURL=dark-mode-setup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dark-mode-setup.d.ts","sourceRoot":"","sources":["../../../src/commands/add/dark-mode-setup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dark-mode-setup.d.ts","sourceRoot":"","sources":["../../../src/commands/add/dark-mode-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAanD,wBAAsB,6BAA6B,CACjD,GAAG,EAAE,MAAM,EACX,cAAc,EAAE;IAAE,aAAa,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAA;CAAE,GACjG,OAAO,CAAC,IAAI,CAAC,CAwCf"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { logger } from '../../utils/logger.js';
|
|
2
|
+
import { withImport } from '../../utils/source-file.js';
|
|
2
3
|
import { existsSync } from 'fs';
|
|
3
4
|
import * as fsPromises from 'fs/promises';
|
|
4
5
|
import * as path from 'path';
|
|
5
|
-
|
|
6
|
+
function getDarkModeImport(servicesAlias) {
|
|
7
|
+
return `import { ZardDarkMode } from '${servicesAlias ?? '@/shared/services'}/dark-mode';`;
|
|
8
|
+
}
|
|
6
9
|
const DARK_MODE_INITIALIZER = 'provideAppInitializer(() => inject(ZardDarkMode).init())';
|
|
7
10
|
export async function updateProvideZardWithDarkMode(cwd, resolvedConfig) {
|
|
8
11
|
const provideZardPath = path.join(resolvedConfig.resolvedPaths.core, 'provider/providezard.ts');
|
|
@@ -21,16 +24,7 @@ export async function updateProvideZardWithDarkMode(cwd, resolvedConfig) {
|
|
|
21
24
|
if (!content.includes('provideAppInitializer')) {
|
|
22
25
|
content = content.replace(/import \{ (.*) \} from '@angular\/core';/, "import { $1, provideAppInitializer } from '@angular/core';");
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
let lastImportMatch = null;
|
|
26
|
-
let match;
|
|
27
|
-
while ((match = importRegex.exec(content)) !== null) {
|
|
28
|
-
lastImportMatch = match;
|
|
29
|
-
}
|
|
30
|
-
if (lastImportMatch) {
|
|
31
|
-
const insertionIndex = lastImportMatch.index + lastImportMatch[0].length;
|
|
32
|
-
content = content.slice(0, insertionIndex) + DARK_MODE_IMPORT + '\n' + content.slice(insertionIndex);
|
|
33
|
-
}
|
|
27
|
+
content = withImport(content, getDarkModeImport(resolvedConfig.aliases?.services));
|
|
34
28
|
content = content.replace(/return makeEnvironmentProviders\(\[(.*?)\]\);/s, (match, providers) => {
|
|
35
29
|
const trimmedProviders = providers.trim();
|
|
36
30
|
if (trimmedProviders) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dark-mode-setup.js","sourceRoot":"","sources":["../../../src/commands/add/dark-mode-setup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dark-mode-setup.js","sourceRoot":"","sources":["../../../src/commands/add/dark-mode-setup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,UAAU,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,SAAS,iBAAiB,CAAC,aAAsB;IAC/C,OAAO,iCAAiC,aAAa,IAAI,mBAAmB,cAAc,CAAC;AAC7F,CAAC;AAED,MAAM,qBAAqB,GAAG,0DAA0D,CAAC;AAEzF,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,GAAW,EACX,cAAkG;IAElG,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,C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"}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { Config } from '../../utils/config.js';
|
|
2
|
-
import { type RegistryIndex } from '../../utils/registry.js';
|
|
2
|
+
import { type RegistryIcons, type RegistryIndex } from '../../utils/registry.js';
|
|
3
|
+
export declare function isItemInstalled(dir: string, files: readonly string[]): boolean;
|
|
3
4
|
export declare function getTargetDir(component: ComponentMeta, resolvedConfig: Config & {
|
|
4
5
|
resolvedPaths: any;
|
|
5
6
|
}, cwd: string, customPath?: string): string;
|
|
6
7
|
export interface ComponentMeta {
|
|
7
8
|
name: string;
|
|
8
9
|
basePath?: string;
|
|
10
|
+
files?: string[];
|
|
9
11
|
dependencies?: string[];
|
|
10
12
|
devDependencies?: string[];
|
|
11
13
|
registryDependencies?: string[];
|
|
14
|
+
icons?: RegistryIcons;
|
|
12
15
|
}
|
|
13
16
|
export interface ResolvedDependencies {
|
|
14
17
|
componentsToInstall: ComponentMeta[];
|
|
15
18
|
dependenciesToInstall: Set<string>;
|
|
16
19
|
}
|
|
17
|
-
export declare function getRegistryIndex(): Promise<RegistryIndex>;
|
|
20
|
+
export declare function getRegistryIndex(forceRefresh?: boolean): Promise<RegistryIndex>;
|
|
18
21
|
export declare function getComponentMeta(name: string): Promise<ComponentMeta | undefined>;
|
|
19
22
|
export declare function getAllComponentNames(): Promise<string[]>;
|
|
20
23
|
export declare function resolveDependencies(selectedComponents: string[], resolvedConfig: Config & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency-resolver.d.ts","sourceRoot":"","sources":["../../../src/commands/add/dependency-resolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dependency-resolver.d.ts","sourceRoot":"","sources":["../../../src/commands/add/dependency-resolver.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAG/C,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,yBAAyB,CAAC;AAUjC,wB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AC,oBAAoB,CAAC,CA4C/B"}
|
|
@@ -1,20 +1,38 @@
|
|
|
1
|
-
import { existsSync
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
+
import { iconPackagesFor } from '../../core/icons/index.js';
|
|
4
|
+
import { iconCatalog } from '../../utils/icon-catalog.js';
|
|
3
5
|
import { logger } from '../../utils/logger.js';
|
|
4
|
-
import { fetchRegistryIndex } from '../../utils/registry.js';
|
|
5
|
-
|
|
6
|
+
import { fetchRegistryIndex, invalidateRegistryCache, } from '../../utils/registry.js';
|
|
7
|
+
/*
|
|
8
|
+
* An item is installed when every file it declares already exists.
|
|
9
|
+
*
|
|
10
|
+
* The old question was "does the directory hold any file?", which only works
|
|
11
|
+
* for an item that lives alone. Typeset is written next to the project's
|
|
12
|
+
* global stylesheet, a directory that is never empty — it would be skipped
|
|
13
|
+
* every time. On the way, a half-installed item is now completed, not skipped.
|
|
14
|
+
*/
|
|
15
|
+
export function isItemInstalled(dir, files) {
|
|
6
16
|
if (!existsSync(dir))
|
|
7
17
|
return false;
|
|
8
|
-
|
|
9
|
-
const files = readdirSync(dir);
|
|
10
|
-
return files.length > 0;
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
18
|
+
if (!files.length)
|
|
13
19
|
return false;
|
|
14
|
-
|
|
20
|
+
return files.every(file => existsSync(path.join(dir, file)));
|
|
15
21
|
}
|
|
16
22
|
export function getTargetDir(component, resolvedConfig, cwd, customPath) {
|
|
17
23
|
const basePath = component.basePath ?? component.name;
|
|
24
|
+
/*
|
|
25
|
+
* A stylesheet goes next to the global CSS declared in components.json, not
|
|
26
|
+
* inside components/. That is what lets the `@import './typeset.css'` the
|
|
27
|
+
* setup injects resolve without a brittle relative path.
|
|
28
|
+
*
|
|
29
|
+
* It comes before `customPath` on purpose: --path moves components, and a
|
|
30
|
+
* stylesheet that moved with them would be imported from a directory it does
|
|
31
|
+
* not sit in — the install would report success and style nothing.
|
|
32
|
+
*/
|
|
33
|
+
if (basePath === 'styles') {
|
|
34
|
+
return path.dirname(resolvedConfig.resolvedPaths.tailwindCss);
|
|
35
|
+
}
|
|
18
36
|
if (customPath) {
|
|
19
37
|
return path.resolve(cwd, customPath, basePath);
|
|
20
38
|
}
|
|
@@ -29,12 +47,11 @@ export function getTargetDir(component, resolvedConfig, cwd, customPath) {
|
|
|
29
47
|
}
|
|
30
48
|
return path.resolve(resolvedConfig.resolvedPaths.components, basePath);
|
|
31
49
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
registryIndexCache = await fetchRegistryIndex();
|
|
50
|
+
export async function getRegistryIndex(forceRefresh = false) {
|
|
51
|
+
if (forceRefresh) {
|
|
52
|
+
invalidateRegistryCache();
|
|
36
53
|
}
|
|
37
|
-
return
|
|
54
|
+
return fetchRegistryIndex();
|
|
38
55
|
}
|
|
39
56
|
export async function getComponentMeta(name) {
|
|
40
57
|
const index = await getRegistryIndex();
|
|
@@ -44,9 +61,11 @@ export async function getComponentMeta(name) {
|
|
|
44
61
|
return {
|
|
45
62
|
name: item.name,
|
|
46
63
|
basePath: item.basePath,
|
|
64
|
+
files: item.files,
|
|
47
65
|
dependencies: item.dependencies,
|
|
48
66
|
devDependencies: item.devDependencies,
|
|
49
67
|
registryDependencies: item.registryDependencies,
|
|
68
|
+
icons: item.icons,
|
|
50
69
|
};
|
|
51
70
|
}
|
|
52
71
|
export async function getAllComponentNames() {
|
|
@@ -69,11 +88,11 @@ export async function resolveDependencies(selectedComponents, resolvedConfig, cw
|
|
|
69
88
|
const componentsToInstall = [];
|
|
70
89
|
for (const component of componentMetas) {
|
|
71
90
|
const targetDir = getTargetDir(component, resolvedConfig, cwd, options.path);
|
|
72
|
-
if (
|
|
91
|
+
if (isItemInstalled(targetDir, component.files ?? []) && !options.overwrite) {
|
|
73
92
|
continue;
|
|
74
93
|
}
|
|
75
94
|
componentsToInstall.push(component);
|
|
76
|
-
addComponentDependencies(component, dependenciesToInstall);
|
|
95
|
+
addComponentDependencies(component, dependenciesToInstall, resolvedConfig.icons);
|
|
77
96
|
if (component.registryDependencies && !options.all) {
|
|
78
97
|
await resolveRegistryDependencies(component, componentsToInstall, dependenciesToInstall, resolvedConfig, cwd, options);
|
|
79
98
|
}
|
|
@@ -83,22 +102,37 @@ export async function resolveDependencies(selectedComponents, resolvedConfig, cw
|
|
|
83
102
|
dependenciesToInstall,
|
|
84
103
|
};
|
|
85
104
|
}
|
|
86
|
-
|
|
105
|
+
/**
|
|
106
|
+
* The npm dependencies the component requires.
|
|
107
|
+
*
|
|
108
|
+
* Beyond the declared ones, anything that draws icons needs ng-icons and the
|
|
109
|
+
* package of the configured family. That does not come from the registry: the
|
|
110
|
+
* registry publishes WHICH icons a component uses, and which family they come
|
|
111
|
+
* from is the installing project's decision. Installing inside `add` also
|
|
112
|
+
* covers anyone who switched family after init.
|
|
113
|
+
*/
|
|
114
|
+
function addComponentDependencies(component, dependenciesToInstall, iconFamily) {
|
|
87
115
|
component.dependencies?.forEach(dep => dependenciesToInstall.add(dep));
|
|
116
|
+
if (component.icons?.symbols?.length) {
|
|
117
|
+
iconPackagesFor(iconFamily, iconCatalog()).forEach(pkg => dependenciesToInstall.add(pkg));
|
|
118
|
+
}
|
|
88
119
|
}
|
|
89
120
|
async function resolveRegistryDependencies(component, componentsToInstall, dependenciesToInstall, resolvedConfig, cwd, options) {
|
|
90
121
|
if (!component.registryDependencies)
|
|
91
122
|
return;
|
|
92
123
|
for (const dep of component.registryDependencies) {
|
|
93
124
|
const depComponent = await getComponentMeta(dep);
|
|
94
|
-
if (!depComponent)
|
|
125
|
+
if (!depComponent) {
|
|
126
|
+
logger.warn(`"${component.name}" depends on "${dep}", which the registry does not publish. ` +
|
|
127
|
+
'The component may not compile — please report it.');
|
|
95
128
|
continue;
|
|
129
|
+
}
|
|
96
130
|
if (componentsToInstall.find(c => c.name === dep))
|
|
97
131
|
continue;
|
|
98
132
|
const depTargetDir = getTargetDir(depComponent, resolvedConfig, cwd, options.path);
|
|
99
|
-
if (!
|
|
133
|
+
if (!isItemInstalled(depTargetDir, depComponent.files ?? []) || options.overwrite) {
|
|
100
134
|
componentsToInstall.push(depComponent);
|
|
101
|
-
addComponentDependencies(depComponent, dependenciesToInstall);
|
|
135
|
+
addComponentDependencies(depComponent, dependenciesToInstall, resolvedConfig.icons);
|
|
102
136
|
if (depComponent.registryDependencies) {
|
|
103
137
|
await resolveRegistryDependencies(depComponent, componentsToInstall, dependenciesToInstall, resolvedConfig, cwd, options);
|
|
104
138
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency-resolver.js","sourceRoot":"","sources":["../../../src/commands/add/dependency-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"dependency-resolver.js","sourceRoot":"","sources":["../../../src/commands/add/dependency-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,uBAAuB,GAGxB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,KAAwB;IACnE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACnC,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAEhC,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,MAA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C,KAAK,MAAM,GAAG,IAAI,SAAS,CAAC,oBAAoB,EAAE,CAAC;QACjD,MAAM,YAAY,GAAG,MAAM,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAEjD,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,CAAC,IAAI,CACT,IAAI,SAAS,CAAC,IAAI,iBAAiB,GAAG,0CAA0C;gBAC9E,mDAAmD,CACtD,CAAC;YACF,SAAS;QACX,CAAC;QACD,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC;YAAE,SAAS;QAE5D,MAAM,YAAY,GAAG,YAAY,CAAC,YAAY,EAAE,cAAc,EAAE,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAEnF,IAAI,CAAC,eAAe,CAAC,YAAY,EAAE,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;YAClF,mBAAmB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACvC,wBAAwB,CAAC,YAAY,EAAE,qBAAqB,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;YAEpF,IAAI,YAAY,CAAC,oBAAoB,EAAE,CAAC;gBACtC,MAAM,2BAA2B,CAC/B,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,GAAG,EACH,OAAO,CACR,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/add/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/add/index.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC,eAAO,MAAM,GAAG,SAoFZ,CAAC"}
|