ui-thing 0.2.5 → 0.2.7
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/.github/CONTRIBUTING.md +93 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +41 -0
- package/.github/ISSUE_TEMPLATE/config.yml +8 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +27 -0
- package/.github/SECURITY.md +54 -0
- package/.github/workflows/test.yml +4 -4
- package/CHANGELOG.md +59 -0
- package/README.md +1 -1
- package/dist/index.js +24 -28
- package/dist/index.js.map +1 -1
- package/package.json +27 -26
- package/src/commands/block.ts +165 -0
- package/src/commands/init.ts +8 -4
- package/src/commands/prettier.ts +2 -6
- package/src/commands/prose.ts +200 -0
- package/src/index.ts +4 -0
- package/src/templates/prettier.ts +1 -1
- package/src/templates/shortcuts.ts +1 -7
- package/src/templates/vs-code.ts +10 -2
- package/src/types.ts +52 -7
- package/src/utils/addPrettierConfig.ts +13 -0
- package/src/utils/constants.ts +5 -3
- package/src/utils/fetchBlockCategories.ts +19 -0
- package/src/utils/fetchBlocks.ts +21 -0
- package/src/utils/fetchProseComponents.ts +21 -0
- package/src/utils/promptForComponents.ts +7 -4
- package/tests/utils/addPrettierConfig.test.ts +10 -17
- package/tests/utils/compareUIConfig.test.ts +3 -3
- package/tests/utils/constants.test.ts +136 -0
- package/tests/utils/detectNuxtVersion.test.ts +97 -0
- package/tests/utils/fetchBlockCategories.test.ts +59 -0
- package/tests/utils/fetchBlocks.test.ts +59 -0
- package/tests/utils/fetchComponents.test.ts +92 -0
- package/tests/utils/fetchProseComponents.test.ts +62 -0
- package/tests/utils/installPackages.test.ts +114 -0
- package/tests/utils/printFancyBoxMessage.test.ts +66 -0
- package/tests/utils/promptForComponents.test.ts +94 -0
- package/tests/utils/writeFile.test.ts +56 -0
- package/vite.config.ts +14 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Contributing to UI Thing CLI
|
|
2
|
+
|
|
3
|
+
First off, thank you for considering contributing to UI Thing CLI! It's people like you that make UI Thing CLI such a great tool.
|
|
4
|
+
|
|
5
|
+
## Code of Conduct
|
|
6
|
+
|
|
7
|
+
By participating in this project, you are expected to uphold our code of conduct: be respectful, inclusive, and considerate in all interactions.
|
|
8
|
+
|
|
9
|
+
## How Can I Contribute?
|
|
10
|
+
|
|
11
|
+
### Reporting Bugs
|
|
12
|
+
|
|
13
|
+
Before creating bug reports, please check the existing issues to avoid duplicates. When you create a bug report, include as many details as possible:
|
|
14
|
+
|
|
15
|
+
- Use a clear and descriptive title
|
|
16
|
+
- Describe the exact steps to reproduce the problem
|
|
17
|
+
- Provide specific examples to demonstrate the steps
|
|
18
|
+
- Describe the behavior you observed and what you expected
|
|
19
|
+
- Include your environment details (OS, Node version, package version)
|
|
20
|
+
|
|
21
|
+
### Suggesting Enhancements
|
|
22
|
+
|
|
23
|
+
Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion, include:
|
|
24
|
+
|
|
25
|
+
- A clear and descriptive title
|
|
26
|
+
- A detailed description of the proposed feature
|
|
27
|
+
- Explain why this enhancement would be useful
|
|
28
|
+
- List any alternatives you've considered
|
|
29
|
+
|
|
30
|
+
### Pull Requests
|
|
31
|
+
|
|
32
|
+
1. Fork the repo and create your branch from `main`
|
|
33
|
+
2. If you've added code, add tests
|
|
34
|
+
3. Ensure the test suite passes
|
|
35
|
+
4. Make sure your code follows the existing code style
|
|
36
|
+
5. Write a clear commit message
|
|
37
|
+
|
|
38
|
+
## Development Setup
|
|
39
|
+
|
|
40
|
+
1. Clone your fork of the repository
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
git clone https://github.com/YOUR_USERNAME/ui-thing-cli.git
|
|
44
|
+
cd ui-thing-cli
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
2. Install dependencies
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
3. Build the project
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm run build
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
4. Run tests
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm run test
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Project Structure
|
|
66
|
+
|
|
67
|
+
- `src/commands/` - CLI command implementations
|
|
68
|
+
- `src/templates/` - File and code templates
|
|
69
|
+
- `src/utils/` - Shared utility functions
|
|
70
|
+
- `tests/` - Unit tests (mirrors src/ structure)
|
|
71
|
+
|
|
72
|
+
## Coding Guidelines
|
|
73
|
+
|
|
74
|
+
- Write TypeScript with proper type annotations
|
|
75
|
+
- Follow the existing code style (check `eslint.config.ts`)
|
|
76
|
+
- Write meaningful commit messages
|
|
77
|
+
- Add tests for new features
|
|
78
|
+
- Update documentation as needed
|
|
79
|
+
|
|
80
|
+
## Testing
|
|
81
|
+
|
|
82
|
+
- Add tests to the `tests/` directory
|
|
83
|
+
- Run `npm run test` to execute all tests
|
|
84
|
+
- Ensure all tests pass before submitting a PR
|
|
85
|
+
|
|
86
|
+
## Need Help?
|
|
87
|
+
|
|
88
|
+
If you need help or have questions, feel free to:
|
|
89
|
+
|
|
90
|
+
- Open an issue
|
|
91
|
+
- Reach out via email: behon.baker@yahoo.com
|
|
92
|
+
|
|
93
|
+
Thank you for your contributions! 🎉
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: "🐛 [BUG] "
|
|
5
|
+
labels: bug
|
|
6
|
+
assignees: ""
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Describe the bug
|
|
10
|
+
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
## To Reproduce
|
|
14
|
+
|
|
15
|
+
Steps to reproduce the behavior:
|
|
16
|
+
|
|
17
|
+
1. Run command '...'
|
|
18
|
+
2. See error
|
|
19
|
+
|
|
20
|
+
## Expected behavior
|
|
21
|
+
|
|
22
|
+
A clear and concise description of what you expected to happen.
|
|
23
|
+
|
|
24
|
+
## Screenshots
|
|
25
|
+
|
|
26
|
+
If applicable, add screenshots to help explain your problem.
|
|
27
|
+
|
|
28
|
+
## Environment
|
|
29
|
+
|
|
30
|
+
- **OS:** [e.g. macOS, Windows, Linux]
|
|
31
|
+
- **Node version:** [e.g. 18.0.0]
|
|
32
|
+
- **Package version:** [e.g. 0.2.5]
|
|
33
|
+
- **Nuxt version:** [e.g. 3.12.0]
|
|
34
|
+
|
|
35
|
+
## Additional context
|
|
36
|
+
|
|
37
|
+
Add any other context about the problem here.
|
|
38
|
+
|
|
39
|
+
## Contact
|
|
40
|
+
|
|
41
|
+
If you need immediate assistance, feel free to reach out at behon.baker@yahoo.com
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
blank_issues_enabled: false
|
|
2
|
+
contact_links:
|
|
3
|
+
- name: 📧 Email Support
|
|
4
|
+
url: mailto:behon.baker@yahoo.com
|
|
5
|
+
about: For urgent issues or private concerns, contact the maintainer directly
|
|
6
|
+
- name: 💬 Discussions
|
|
7
|
+
url: https://github.com/BayBreezy/ui-thing-cli/discussions
|
|
8
|
+
about: Ask questions and discuss ideas with the community
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: "✨ [FEATURE] "
|
|
5
|
+
labels: enhancement
|
|
6
|
+
assignees: ""
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Is your feature request related to a problem? Please describe.
|
|
10
|
+
|
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
+
|
|
13
|
+
## Describe the solution you'd like
|
|
14
|
+
|
|
15
|
+
A clear and concise description of what you want to happen.
|
|
16
|
+
|
|
17
|
+
## Describe alternatives you've considered
|
|
18
|
+
|
|
19
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
|
20
|
+
|
|
21
|
+
## Additional context
|
|
22
|
+
|
|
23
|
+
Add any other context or screenshots about the feature request here.
|
|
24
|
+
|
|
25
|
+
## Contact
|
|
26
|
+
|
|
27
|
+
If you'd like to discuss this feature in more detail, feel free to reach out at behon.baker@yahoo.com
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
We release patches for security vulnerabilities. Currently supported versions:
|
|
6
|
+
|
|
7
|
+
| Version | Supported |
|
|
8
|
+
| ------- | ------------------ |
|
|
9
|
+
| 0.2.x | :white_check_mark: |
|
|
10
|
+
| < 0.2.0 | :x: |
|
|
11
|
+
|
|
12
|
+
## Reporting a Vulnerability
|
|
13
|
+
|
|
14
|
+
We take the security of UI Thing CLI seriously. If you believe you have found a security vulnerability, please report it to us as described below.
|
|
15
|
+
|
|
16
|
+
### Please do NOT:
|
|
17
|
+
|
|
18
|
+
- Open a public GitHub issue
|
|
19
|
+
- Disclose the vulnerability publicly before it has been addressed
|
|
20
|
+
|
|
21
|
+
### Please DO:
|
|
22
|
+
|
|
23
|
+
- Email your findings to **behon.baker@yahoo.com**
|
|
24
|
+
- Provide as much information as possible about the vulnerability:
|
|
25
|
+
- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
|
26
|
+
- Full paths of source file(s) related to the manifestation of the issue
|
|
27
|
+
- The location of the affected source code (tag/branch/commit or direct URL)
|
|
28
|
+
- Any special configuration required to reproduce the issue
|
|
29
|
+
- Step-by-step instructions to reproduce the issue
|
|
30
|
+
- Proof-of-concept or exploit code (if possible)
|
|
31
|
+
- Impact of the issue, including how an attacker might exploit it
|
|
32
|
+
|
|
33
|
+
### What to Expect:
|
|
34
|
+
|
|
35
|
+
- You will receive a response within 48 hours acknowledging your report
|
|
36
|
+
- We will investigate and keep you updated on the progress
|
|
37
|
+
- Once the vulnerability is confirmed, we will work on a fix and release a security patch
|
|
38
|
+
- We will credit you for the discovery (unless you prefer to remain anonymous)
|
|
39
|
+
|
|
40
|
+
## Security Best Practices for Users
|
|
41
|
+
|
|
42
|
+
When using UI Thing CLI:
|
|
43
|
+
|
|
44
|
+
- Always use the latest version of the package
|
|
45
|
+
- Review generated code before committing to your repository
|
|
46
|
+
- Be cautious when running CLI commands with elevated privileges
|
|
47
|
+
- Keep your Node.js and npm/pnpm/yarn up to date
|
|
48
|
+
|
|
49
|
+
## Contact
|
|
50
|
+
|
|
51
|
+
For any security-related questions or concerns, please contact:
|
|
52
|
+
**Behon Baker** - behon.baker@yahoo.com
|
|
53
|
+
|
|
54
|
+
Thank you for helping keep UI Thing CLI and its users safe!
|
|
@@ -10,10 +10,10 @@ jobs:
|
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
11
|
steps:
|
|
12
12
|
- uses: actions/checkout@v4
|
|
13
|
-
- name: Install dependencies
|
|
14
|
-
run: npm install
|
|
15
13
|
- uses: actions/setup-node@v4
|
|
16
14
|
with:
|
|
17
|
-
node-version: "
|
|
15
|
+
node-version: "22.x"
|
|
16
|
+
- name: Install dependencies
|
|
17
|
+
run: npm install
|
|
18
18
|
- name: Test
|
|
19
|
-
run: npm run test
|
|
19
|
+
run: npm run test -- --run
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,64 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.2.7
|
|
4
|
+
|
|
5
|
+
[compare changes](https://github.com/BayBreezy/ui-thing-cli/compare/v0.2.6...v0.2.7)
|
|
6
|
+
|
|
7
|
+
### 🚀 Enhancements
|
|
8
|
+
|
|
9
|
+
- Update tailwindFunctions in Prettier configuration to include 'tw' ([273f00a](https://github.com/BayBreezy/ui-thing-cli/commit/273f00a))
|
|
10
|
+
- Update VS Code recommendations ([898dc3d](https://github.com/BayBreezy/ui-thing-cli/commit/898dc3d))
|
|
11
|
+
- Add docsPath property to Component type ([7eb5fb4](https://github.com/BayBreezy/ui-thing-cli/commit/7eb5fb4))
|
|
12
|
+
- Simplify DEFINE_SHORTCUT import statement in shortcuts.ts ([2cb48c7](https://github.com/BayBreezy/ui-thing-cli/commit/2cb48c7))
|
|
13
|
+
- Add unit tests for various utility functions and components ([9b9067a](https://github.com/BayBreezy/ui-thing-cli/commit/9b9067a))
|
|
14
|
+
- Enhance test configuration in vite.config.ts for improved coverage reporting ([051541f](https://github.com/BayBreezy/ui-thing-cli/commit/051541f))
|
|
15
|
+
- Update dependencies in package.json and package-lock.json for improved functionality ([4b5a43c](https://github.com/BayBreezy/ui-thing-cli/commit/4b5a43c))
|
|
16
|
+
- Enhance promptUserForComponents to support ProseComponent type ([aa77801](https://github.com/BayBreezy/ui-thing-cli/commit/aa77801))
|
|
17
|
+
- Add fetchProseComponents utility to retrieve prose components from UI Thing API ([78acc6a](https://github.com/BayBreezy/ui-thing-cli/commit/78acc6a))
|
|
18
|
+
- Add fetchBlocks utility to retrieve block components from UI Thing API ([8bffb9e](https://github.com/BayBreezy/ui-thing-cli/commit/8bffb9e))
|
|
19
|
+
- Add fetchBlockCategories utility to retrieve block categories from UI Thing API ([cb5bde0](https://github.com/BayBreezy/ui-thing-cli/commit/cb5bde0))
|
|
20
|
+
- Implement prose command to add prose components to the project ([1f5c532](https://github.com/BayBreezy/ui-thing-cli/commit/1f5c532))
|
|
21
|
+
- Implement block command to add UI Thing blocks with category filtering ([23aa9e4](https://github.com/BayBreezy/ui-thing-cli/commit/23aa9e4))
|
|
22
|
+
- Update types to include TemplateFile and enhance ProseComponent and BlockComponent definitions ([1563080](https://github.com/BayBreezy/ui-thing-cli/commit/1563080))
|
|
23
|
+
- Add block and prose commands to the CLI ([d35e3b7](https://github.com/BayBreezy/ui-thing-cli/commit/d35e3b7))
|
|
24
|
+
|
|
25
|
+
### 🩹 Fixes
|
|
26
|
+
|
|
27
|
+
- Update test mocking for CI compatibility ([9bc7a32](https://github.com/BayBreezy/ui-thing-cli/commit/9bc7a32))
|
|
28
|
+
|
|
29
|
+
### 🏡 Chore
|
|
30
|
+
|
|
31
|
+
- Update dependencies to latest versions ([f70d2d5](https://github.com/BayBreezy/ui-thing-cli/commit/f70d2d5))
|
|
32
|
+
- Remove unused devDependencies from package.json and package-lock.json ([ba2d7cf](https://github.com/BayBreezy/ui-thing-cli/commit/ba2d7cf))
|
|
33
|
+
|
|
34
|
+
### ❤️ Contributors
|
|
35
|
+
|
|
36
|
+
- Behon Baker ([@BayBreezy](https://github.com/BayBreezy))
|
|
37
|
+
|
|
38
|
+
## v0.2.6
|
|
39
|
+
|
|
40
|
+
[compare changes](https://github.com/BayBreezy/ui-thing-cli/compare/v0.2.5...v0.2.6)
|
|
41
|
+
|
|
42
|
+
### 🚀 Enhancements
|
|
43
|
+
|
|
44
|
+
- Add issue templates for bug reports and feature requests ([906dabc](https://github.com/BayBreezy/ui-thing-cli/commit/906dabc))
|
|
45
|
+
- Enhance Prettier integration by prompting user for configuration and updating dependencies ([5d9f7b0](https://github.com/BayBreezy/ui-thing-cli/commit/5d9f7b0))
|
|
46
|
+
|
|
47
|
+
### 📖 Documentation
|
|
48
|
+
|
|
49
|
+
- Update README to clarify `init` command functionality ([2353699](https://github.com/BayBreezy/ui-thing-cli/commit/2353699))
|
|
50
|
+
- Add CONTRIBUTING.md to guide new contributors ([3cfd3cd](https://github.com/BayBreezy/ui-thing-cli/commit/3cfd3cd))
|
|
51
|
+
- Add SECURITY.md to outline security policy and reporting procedures ([1213eef](https://github.com/BayBreezy/ui-thing-cli/commit/1213eef))
|
|
52
|
+
|
|
53
|
+
### 🏡 Chore
|
|
54
|
+
|
|
55
|
+
- Update dependencies to latest versions ([fbb17d0](https://github.com/BayBreezy/ui-thing-cli/commit/fbb17d0))
|
|
56
|
+
- Update dependencies and devDependencies ([a6793dd](https://github.com/BayBreezy/ui-thing-cli/commit/a6793dd))
|
|
57
|
+
|
|
58
|
+
### ❤️ Contributors
|
|
59
|
+
|
|
60
|
+
- Behon Baker ([@BayBreezy](https://github.com/BayBreezy))
|
|
61
|
+
|
|
3
62
|
## v0.2.5
|
|
4
63
|
|
|
5
64
|
[compare changes](https://github.com/BayBreezy/ui-thing-cli/compare/v0.2.4...v0.2.5)
|
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ npx ui-thing@latest add
|
|
|
49
49
|
npx ui-thing@latest init
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
This command will install the dependencies and add the required configuration to your project.
|
|
52
|
+
This command will install the dependencies and add the required configuration to your project. It will also add a `.prettierrc` file to your project.
|
|
53
53
|
|
|
54
54
|
### `add`
|
|
55
55
|
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Command as
|
|
2
|
+
import{Command as Er}from"commander";var lo="0.2.6";import U from"path";import{updateConfig as xo}from"c12/update";import{Command as we}from"commander";import{consola as K}from"consola";import k from"kleur";import N from"lodash";import X from"prompts";import{join as bo}from"path";import{loadConfig as ne}from"c12";import x from"fs-extra";import ce from"lodash";import{loadFile as ae,writeFile as ie}from"magicast";import{addNuxtModule as se}from"magicast/helpers";import le from"prompts";var F="ui-thing.config.ts",ho={theme:"zinc",tailwindCSSLocation:"assets/css/tailwind.css",componentsLocation:"components/Ui",composablesLocation:"composables",pluginsLocation:"plugins",utilsLocation:"utils",force:!0,useDefaultFilename:!0,packageManager:"npm"},po={theme:"zinc",tailwindCSSLocation:"app/assets/css/tailwind.css",componentsLocation:"app/components/Ui",composablesLocation:"app/composables",pluginsLocation:"app/plugins",utilsLocation:"app/utils",force:!0,useDefaultFilename:!0,packageManager:"npm"},uo=["tailwindcss","motion-v","@tailwindcss/vite","reka-ui","tailwind-variants","tailwind-merge","@nuxt/fonts","@nuxtjs/color-mode","@nuxt/icon","@vueuse/nuxt","@tailwindcss/forms"],mo=["typescript","tw-animate-css"],O=["prettier-plugin-tailwindcss","prettier","@ianvs/prettier-plugin-sort-imports"],fo=["@nuxtjs/color-mode","motion-v/nuxt","@vueuse/nuxt","@nuxt/icon","@nuxt/fonts"],C=[{title:"Npm",value:"npm"},{title:"Yarn",value:"yarn"},{title:"Pnpm",value:"pnpm"},{title:"Bun",value:"bun"}],T=[{title:"Zinc",value:"zinc"},{title:"Slate",value:"slate"},{title:"Stone",value:"stone"},{title:"Gray",value:"gray"},{title:"Neutral",value:"neutral"},{title:"Red",value:"red"},{title:"Rose",value:"rose"},{title:"Orange",value:"orange"},{title:"Green",value:"green"},{title:"Blue",value:"blue"},{title:"Yellow",value:"yellow"},{title:"Violet",value:"violet"}];import re from"fs";function ko(){try{let o=JSON.parse(re.readFileSync("package.json","utf-8")),r=o.dependencies?.nuxt||o.devDependencies?.nuxt;if(r)return/^[~^>=<\s]*4/.test(r)?4:3}catch{return 4}return 4}import go from"kleur";import te from"prompts";var yo=async o=>{let r=await te([{name:"theme",type:"autocomplete",message:"Which theme do you want to start with?",choices:T},{name:"tailwindCSSLocation",type:"text",message:"Where is your tailwind.css file located?",initial:(e,t)=>o==3?"assets/css/tailwind.css":"app/assets/css/tailwind.css"},{name:"componentsLocation",type:"text",message:"Where should your components be stored?",initial:(e,t)=>o==3?"components/Ui":"app/components/Ui"},{name:"composablesLocation",type:"text",message:"Where should your composables be stored?",initial:(e,t)=>o==3?"composables":"app/composables"},{name:"pluginsLocation",type:"text",message:"Where should your plugins be stored?",initial:(e,t)=>o==3?"plugins":"app/plugins"},{name:"utilsLocation",type:"text",message:"Where should your utils be stored?",initial:(e,t)=>o==3?"utils":"app/utils"},{name:"force",type:"confirm",message:"Should we just replace component files if they already exist?",initial:!0},{name:"useDefaultFilename",type:"confirm",message:"Would you like to use the default filename when adding components?",initial:!0},{name:"packageManager",type:"select",message:"Which package manager do you use?",choices:C}]);return!r||Object.keys(r).length<9?(console.log(go.red(go.bold("Incomplete configuration submitted. Exiting..."))),process.exit(0)):r};var vo=process.cwd(),u=async o=>{let r=x.existsSync(F),e={},t=Number(o?.nuxtVersion)||ko();if(!r||o?.force){if(e=o?.yes?t===4?po:ho:await yo(t),await x.writeFile(F,`export default ${JSON.stringify(e,null,2)}`),e.packageManager==="pnpm"){let c=x.existsSync(".npmrc"),a=!0;if(c){let{confirmCreateNpmrc:i}=await le({type:"confirm",name:"confirmCreateNpmrc",message:"A .npmrc file already exists. Overwrite it?",initial:!1});a=i}a&&await x.writeFile(".npmrc",`shamefully-hoist=true
|
|
3
3
|
strict-peer-dependencies=false
|
|
4
|
-
`)}}else e=(await
|
|
5
|
-
${r}`:
|
|
6
|
-
`+
|
|
7
|
-
`,{box:{title:"Components Added"}});let
|
|
4
|
+
`)}}else e=(await ne({configFile:F.replace(".ts","")})).config;return ce.isEmpty(e)?u({force:!0}):(de(e),e)},de=o=>{let r=(e,t=!1)=>{e&&(t?x.ensureDirSync(e):x.ensureFileSync(e))};r(o.tailwindCSSLocation),r(o.pluginsLocation,!0),r(o.componentsLocation,!0),r(o.composablesLocation,!0),r(o.utilsLocation,!0)},A=async o=>{if(!o)return;let r=typeof o=="string"?[o]:o,e=await ae(bo(vo,"nuxt.config.ts"));r.forEach(t=>se(e,t)),await ie(e,bo(vo,"nuxt.config.ts"))};var g=async()=>{let o=await u(),r={nuxtVersion:3,theme:"string",tailwindCSSLocation:"string",componentsLocation:"string",composablesLocation:"string",utilsLocation:"string",force:!0,useDefaultFilename:!0,packageManager:"string"},e=[];for(let t of Object.keys(r))o[t]===void 0&&e.push(t);return!(e.length>1)};import he from"axios";import pe from"dotenv";import ue from"ora";pe.config();var wo=async()=>{let o=ue("Fetching components...").start(),{data:r}=await he.get(process.env.COMPONENTS_API||"https://uithing.com/api/components");return o.succeed("Components fetched."),r};import V from"fs";var y=async o=>{try{return await V.promises.access(o,V.constants.F_OK||V.constants.W_OK),!0}catch{return!1}};import{execa as z}from"execa";import P from"lodash";import me from"ora";var f=async(o,r,e)=>{typeof r=="string"&&(r=[r]),typeof e=="string"&&(e=[e]);let t=me("Installing dependencies...").start();!P.isUndefined(r)&&!P.isEmpty(r)&&await z(o,[o==="yarn"?"add":"install",...r]),t.text="Installing dev dependencies...",!P.isUndefined(e)&&!P.isEmpty(e)&&await z(o,[o==="yarn"?"add":"install","-D",...e]),t.text="Running nuxt prepare...",await z`npx -y nuxt prepare`,t.succeed("Installed dependencies!")};import fe from"prompts";var Co=async o=>{let r={yup:["yup","@vee-validate/yup"],zod:["zod","@vee-validate/zod"],joi:["joi","@vee-validate/joi"],valibot:["valibot","@vee-validate/valibot"]},{validator:e}=await fe({type:"select",name:"validator",message:"Choose the validator package to use with Vee Validate: ",choices:[{title:"Yup",value:"yup"},{title:"Zod",value:"zod"},{title:"Joi",value:"joi"},{title:"Valibot",value:"valibot"}]});if(!e){console.log("No validator package selected");return}return console.log(`Selected ${e} as the validator package`),r[e]&&await f(o,r[e]),e};import ke from"boxen";import ge from"figlet";var ye=(o,r,e={})=>{let{box:t,figletFont:c}=e,a=ge.textSync(o,{font:c||"Standard"}),l=ke(a,{...{borderColor:"greenBright",padding:1,borderStyle:"round",titleAlignment:"center"},...t});return r?`${l}
|
|
5
|
+
${r}`:l},m=(o,r,e)=>{console.log(`
|
|
6
|
+
`+ye(o,r,e))};import be from"prompts";var L=async(o,r=[])=>{if(o)return r.map(t=>t.value);let{components:e}=await be({type:"autocompleteMultiselect",name:"components",message:"Select the components you want to add",choices:r.map(t=>({title:t.name,value:t.value}))});return e};import q from"fs";import ve from"path";var S=async(o,r)=>{if(!await y(o)){let t=ve.dirname(o);q.existsSync(t)||q.mkdirSync(t,{recursive:!0})}q.writeFileSync(o,r)};var Z=[],_=process.cwd(),Y=o=>Z.find(r=>r.value.toLowerCase()===o.toLowerCase());async function So(o,r,e,t){if(await y(o)&&!e){let{value:a}=await X({type:"confirm",name:"value",message:t,initial:!1});if(!a)return K.info(`Skipped: ${k.cyan(U.basename(o))}`),!1}return await S(o,r),!0}async function J(o,r,e,t){for(let c of r){let a=U.join(_,e,c.fileName);await So(a,c.fileContent,t,`The ${o} file ${k.bold(c.fileName)} already exists. Overwrite?`)}}var Ce=async(o,r)=>{let e=await u();await g()||(e=await u({force:!0})),N.isEmpty(e)&&(K.info("Config file not set. Exiting..."),process.exit(0)),Z=await wo();let t=o;if(t.length===0){let n=await L(r.all,Z);(!n||n.length===0)&&(K.info("No components selected. Exiting..."),process.exit(0)),t=n}let c=t.filter(n=>!Y(n));c.length>0&&K.error(`Not found: ${k.bgRed(c.join(", "))}`);let a=t.map(n=>Y(n)).filter(Boolean);for(let n of[...a])n.components&&n.components.forEach(p=>{a.find(h=>h.value===p)||a.push(Y(p))});for(let n of a)for(let p of n.files){let h=e.componentsLocation,s=U.join(_,h,p.fileName);if(!e.useDefaultFilename){let{value:b}=await X({type:"text",name:"value",message:`Where should we add the file ${k.cyan(p.fileName)}?`,initial:h});b&&(h=b,s=U.join(_,h,p.fileName))}await So(s,p.fileContent,e.force,`The file ${k.bold(p.fileName)} already exists. Overwrite?`)&&((n.value==="vue-sonner"||n.value==="sonner")&&await xe(),n.value==="datatable"&&await Se(),await J("utils",n.utils,e.utilsLocation,e.force),await J("composables",n.composables,e.composablesLocation,e.force),await J("plugins",n.plugins,e.pluginsLocation??"",e.force))}await A(N.uniq(a.flatMap(n=>n.nuxtModules||[])));let i=N.uniq(a.flatMap(n=>n.deps||[])),l=N.uniq(a.flatMap(n=>n.devDeps||[]));if(i.length>0||l.length>0)if(r.all)await f(e.packageManager,i,l);else{let{confirmInstall:n}=await X({type:"confirm",name:"confirmInstall",message:`Install packages: ${k.cyan([...i,...l].join(", "))}?`,initial:!0});n&&await f(e.packageManager,i,l)}a.some(n=>n.askValidator)&&await Co(e.packageManager),m("All Done!",`Run the ${k.cyan("ui-thing@latest --help")} command to learn more.
|
|
7
|
+
`,{box:{title:"Components Added"}});let d=N.compact(a.flatMap(n=>n.instructions));d.length>0&&(console.log(""),console.log(k.bgCyan(" Instructions ")),d.forEach(n=>console.log(`${k.cyan("-")} ${n}`)))},Eo=new we().name("add").command("add").description("Add a list of components to your project.").option("-a --all","Add all components to your project.",!1).argument("[componentNames...]","Components that you want to add.").action(Ce);async function xe(){await xo({configFile:"nuxt.config",cwd:_,onUpdate(o){o.imports||={imports:[]},o.imports.imports.find(r=>r.from==="vue-sonner"&&r.name==="toast")||o.imports.imports.push({from:"vue-sonner",name:"toast",as:"useSonner"})}})}async function Se(){await xo({configFile:"nuxt.config",cwd:_,onUpdate(o){o.app||={head:{script:[]}},["https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.12/pdfmake.min.js","https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.12/vfs_fonts.min.js"].forEach(e=>{o.app.head.script.find(t=>t.src===e)||o.app.head.script.push({src:e,defer:!0})})}})}import{spawnSync as Fe}from"child_process";import Q from"path";import{Command as Oe}from"commander";import{consola as E}from"consola";import j from"kleur";import No from"lodash";import R from"prompts";import Ee from"axios";import Ie from"dotenv";import Te from"ora";Ie.config();var Io=async()=>{let o=Te("Fetching block categories...").start(),{data:r}=await Ee.get(process.env.BLOCK_CATEGORIES_API||"https://uithing.com/api/blocks/categories");return o.succeed("Block categories fetched."),r};import Ne from"axios";import _e from"dotenv";import Me from"ora";_e.config();var To=async()=>{let o=Me("Fetching blocks...").start(),{data:r}=await Ne.get(process.env.BLOCKS_API||"https://uithing.com/api/blocks");return o.succeed("Blocks fetched."),r};var D=[],_o=process.cwd();function Ae(o){return o.componentsLocation?.startsWith("app/")?"app/components/Blocks":"components/Blocks"}async function Pe(o,r,e,t){if(await y(o)&&!e){let{value:a}=await R({type:"confirm",name:"value",message:t,initial:!1});if(!a)return E.info(`Skipped: ${j.cyan(Q.basename(o))}`),!1}return await S(o,r),!0}var Le=async(o,r)=>{let e=await u();await g()||(e=await u({force:!0})),No.isEmpty(e)&&(E.info("Config file not set. Exiting..."),process.exit(0));let t=await Io(),c=r.category;if(!c&&t?.length){let{category:s}=await R({type:"select",name:"category",message:"Choose a block category",choices:[{title:"All",value:"all"},...t.map(w=>({title:w,value:w}))],initial:0});c=s}D=await To();let a=D;c&&c!=="all"&&(a=D.filter(s=>s.category===c),a.length===0&&(E.warn(`No blocks found for category ${j.cyan(c)}. Falling back to all.`),a=D));let{selectedBlocks:i}=await R({type:"autocompleteMultiselect",name:"selectedBlocks",message:"Select the blocks you want to add",choices:a.map(s=>({title:s.name,value:s}))});(!i||i.length===0)&&(E.info("No blocks selected. Exiting..."),process.exit(0));let l=i,d=Ae(e),{blocksDir:n}=await R({type:"text",name:"blocksDir",message:"Where should we add the blocks?",initial:d}),p=n||d;for(let s of l){let w=Q.join(p,s.path),b=Q.join(_o,w);await Pe(b,s.file,e.force,`The block file ${j.bold(s.fileName)} already exists. Overwrite?`)}let h=No.uniq(l.flatMap(s=>s.components||[]));if(h.length>0){E.info(`Adding ${h.length} component(s) required by blocks...`);let s=Fe("npx",["ui-thing@latest","add",...h],{cwd:_o,stdio:"inherit"});s.error&&E.error("Failed to add components:",s.error.message)}m("Blocks added!",`Run the ${j.cyan("ui-thing@latest --help")} command to learn more.
|
|
8
|
+
`,{box:{title:"Blocks Added"}})},Mo=new Oe().name("block").command("block").description("Add UI Thing blocks to your project.").option("-c --category <category>","Filter blocks by category before selection").action(Le);import ar from"path";import{updateConfig as ir}from"c12/update";import{Command as sr}from"commander";import jo from"fs-extra";import to from"kleur";import lr from"ora";var Ke=`@import "tailwindcss";
|
|
8
9
|
@import "tw-animate-css";
|
|
9
10
|
|
|
10
11
|
@plugin "@tailwindcss/forms" {
|
|
@@ -129,7 +130,7 @@ ${r}`:i},l=(o,r,e)=>{console.log(`
|
|
|
129
130
|
--gradient-rust: oklch(55.695% 0.19944 34.155);
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
`,
|
|
133
|
+
`,Ue=`@layer base {
|
|
133
134
|
* {
|
|
134
135
|
@apply border-border outline-ring/50;
|
|
135
136
|
}
|
|
@@ -158,7 +159,7 @@ ${r}`:i},l=(o,r,e)=>{console.log(`
|
|
|
158
159
|
cursor: pointer;
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
|
-
`,
|
|
162
|
+
`,B=o=>(Fo[o]||(o="ZINC"),`${Ke}${Fo[o]}${Ue}`),De=`
|
|
162
163
|
:root {
|
|
163
164
|
--radius: 0.65rem;
|
|
164
165
|
--background: oklch(1 0 0);
|
|
@@ -228,7 +229,7 @@ ${r}`:i},l=(o,r,e)=>{console.log(`
|
|
|
228
229
|
--sidebar-ring: oklch(0.556 0 0);
|
|
229
230
|
}
|
|
230
231
|
|
|
231
|
-
`,
|
|
232
|
+
`,je=`
|
|
232
233
|
:root {
|
|
233
234
|
--radius: 0.625rem;
|
|
234
235
|
--background: oklch(1 0 0);
|
|
@@ -298,7 +299,7 @@ ${r}`:i},l=(o,r,e)=>{console.log(`
|
|
|
298
299
|
--sidebar-ring: oklch(0.551 0.027 264.364);
|
|
299
300
|
}
|
|
300
301
|
|
|
301
|
-
`,
|
|
302
|
+
`,Re=`
|
|
302
303
|
:root {
|
|
303
304
|
--radius: 0.625rem;
|
|
304
305
|
--background: oklch(1 0 0);
|
|
@@ -367,7 +368,7 @@ ${r}`:i},l=(o,r,e)=>{console.log(`
|
|
|
367
368
|
--sidebar-ring: oklch(0.553 0.013 58.071);
|
|
368
369
|
}
|
|
369
370
|
|
|
370
|
-
`,
|
|
371
|
+
`,Be=`
|
|
371
372
|
:root {
|
|
372
373
|
--radius: 0.625rem;
|
|
373
374
|
--background: oklch(1 0 0);
|
|
@@ -437,7 +438,7 @@ ${r}`:i},l=(o,r,e)=>{console.log(`
|
|
|
437
438
|
--sidebar-ring: oklch(0.551 0.027 264.364);
|
|
438
439
|
}
|
|
439
440
|
|
|
440
|
-
|
|
441
|
+
`,$e=`
|
|
441
442
|
:root {
|
|
442
443
|
--radius: 0.625rem;
|
|
443
444
|
--background: oklch(1 0 0);
|
|
@@ -507,7 +508,7 @@ ${r}`:i},l=(o,r,e)=>{console.log(`
|
|
|
507
508
|
--sidebar-ring: oklch(0.556 0 0);
|
|
508
509
|
}
|
|
509
510
|
|
|
510
|
-
`,
|
|
511
|
+
`,We=`
|
|
511
512
|
:root {
|
|
512
513
|
--radius: 0.65rem;
|
|
513
514
|
--background: oklch(1 0 0);
|
|
@@ -577,7 +578,7 @@ ${r}`:i},l=(o,r,e)=>{console.log(`
|
|
|
577
578
|
--sidebar-ring: oklch(0.637 0.237 25.331);
|
|
578
579
|
}
|
|
579
580
|
|
|
580
|
-
`,
|
|
581
|
+
`,Ge=`
|
|
581
582
|
:root {
|
|
582
583
|
--radius: 0.65rem;
|
|
583
584
|
--background: oklch(1 0 0);
|
|
@@ -647,7 +648,7 @@ ${r}`:i},l=(o,r,e)=>{console.log(`
|
|
|
647
648
|
--sidebar-ring: oklch(0.645 0.246 16.439);
|
|
648
649
|
}
|
|
649
650
|
|
|
650
|
-
`,
|
|
651
|
+
`,He=`
|
|
651
652
|
:root {
|
|
652
653
|
--radius: 0.65rem;
|
|
653
654
|
--background: oklch(1 0 0);
|
|
@@ -717,7 +718,7 @@ ${r}`:i},l=(o,r,e)=>{console.log(`
|
|
|
717
718
|
--sidebar-ring: oklch(0.646 0.222 41.116);
|
|
718
719
|
}
|
|
719
720
|
|
|
720
|
-
`,
|
|
721
|
+
`,Ve=`
|
|
721
722
|
:root {
|
|
722
723
|
--radius: 0.65rem;
|
|
723
724
|
--background: oklch(1 0 0);
|
|
@@ -787,7 +788,7 @@ ${r}`:i},l=(o,r,e)=>{console.log(`
|
|
|
787
788
|
--sidebar-ring: oklch(0.527 0.154 150.069);
|
|
788
789
|
}
|
|
789
790
|
|
|
790
|
-
`,
|
|
791
|
+
`,ze=`
|
|
791
792
|
:root {
|
|
792
793
|
--radius: 0.65rem;
|
|
793
794
|
--background: oklch(1 0 0);
|
|
@@ -857,7 +858,7 @@ ${r}`:i},l=(o,r,e)=>{console.log(`
|
|
|
857
858
|
--sidebar-ring: oklch(0.488 0.243 264.376);
|
|
858
859
|
}
|
|
859
860
|
|
|
860
|
-
`,
|
|
861
|
+
`,qe=`
|
|
861
862
|
:root {
|
|
862
863
|
--radius: 0.65rem;
|
|
863
864
|
--background: oklch(1 0 0);
|
|
@@ -927,7 +928,7 @@ ${r}`:i},l=(o,r,e)=>{console.log(`
|
|
|
927
928
|
--sidebar-ring: oklch(0.554 0.135 66.442);
|
|
928
929
|
}
|
|
929
930
|
|
|
930
|
-
`,
|
|
931
|
+
`,Ye=`
|
|
931
932
|
:root {
|
|
932
933
|
--radius: 0.65rem;
|
|
933
934
|
--background: oklch(1 0 0);
|
|
@@ -997,22 +998,17 @@ ${r}`:i},l=(o,r,e)=>{console.log(`
|
|
|
997
998
|
--sidebar-ring: oklch(0.541 0.281 293.009);
|
|
998
999
|
}
|
|
999
1000
|
|
|
1000
|
-
`,
|
|
1001
|
+
`,Fo={ZINC:De,SLATE:je,STONE:Re,GRAY:Be,NEUTRAL:$e,RED:We,ROSE:Ge,ORANGE:He,GREEN:Ve,BLUE:ze,YELLOW:qe,VIOLET:Ye};var Oo=`/**
|
|
1001
1002
|
* Utility function to return Tailwind CSS classes.
|
|
1002
1003
|
*/
|
|
1003
1004
|
export const tw = <T extends TemplateStringsArray | string>(tailwindClasses: T) => tailwindClasses;
|
|
1004
|
-
`;import{join as
|
|
1005
|
+
`;import{join as Je}from"path";import{$ as Xe}from"execa";import oo from"fs-extra";import Ze from"ora";import Ao from"prompts";var $={arrowParens:"always",endOfLine:"lf",plugins:["@ianvs/prettier-plugin-sort-imports","prettier-plugin-tailwindcss"],printWidth:100,semi:!0,singleQuote:!1,tabWidth:2,trailingComma:"es5",useTabs:!1,vueIndentScriptAndStyle:!0,tailwindFunctions:["tv","tw"],importOrder:["<BUILTIN_MODULES>","<THIRD_PARTY_MODULES>","<TYPES>","","^[.]"]};var W=async(o=process.cwd(),r=!0)=>{let e=Je(o,".prettierrc"),t=$;if(oo.existsSync(e)){let a=await oo.readFile(e,"utf-8"),i={};try{i=JSON.parse(a)}catch{console.warn("\u26A0\uFE0F Existing .prettierrc is not valid JSON \u2014 will prompt for overwrite.")}let l=await Ao({name:"merge",type:"select",message:"A prettier config file already exists. What would you like to do?",choices:[{title:"Merge configs",value:"merge"},{title:"Overwrite with new config",value:"overwrite"},{title:"Cancel",value:"cancel"}],initial:0});if(l.merge==="merge")t={...i,...$};else if(l.merge==="overwrite")t=$;else return!1}if(await oo.writeFile(e,JSON.stringify(t,null,2),"utf-8"),!r)return!0;let c=Ze("Formatting files with prettier...").start();return await Xe`npx prettier --write .`,c.succeed("Files formatted with prettier"),!0},Po=async()=>{let{addPrettier:o}=await Ao({name:"addPrettier",type:"confirm",message:"Would you like to add a Prettier configuration to your project?",initial:!0});return o};import{join as Qe}from"path";import{builders as or,loadFile as er,writeFile as rr}from"magicast";import{getDefaultExportOptions as tr}from"magicast/helpers";var Lo=async()=>{let o=Qe(process.cwd(),"nuxt.config.ts"),r=await er(o);if(!r.$code.includes("tailwindcss()")){let e=tr(r);e.vite||={},e.vite.plugins||=[],e.vite.plugins.push(or.functionCall("tailwindcss"))}r.imports.$items.find(e=>e.local==="tailwindcss")||r.imports.$prepend({from:"@tailwindcss/vite",local:"tailwindcss",imported:"default"}),await rr(r,o)};import cr from"fs-extra";var Ko={recommendations:["vue.volar","bradlc.vscode-tailwindcss","antfu.iconify","formulahendry.auto-close-tag","formulahendry.auto-rename-tag","prettier.prettier-vscode"]},Uo={"editor.formatOnSave":!0,"editor.quickSuggestions":{strings:"on"},"files.associations":{"*.css":"tailwindcss"},"tailwindCSS.classFunctions":["tw","clsx","tw\\.[a-z-]+"],"tailwindCSS.experimental.classRegex":[["tv\\(([^)(]*(?:\\([^)(]*(?:\\([^)(]*(?:\\([^)(]*\\)[^)(]*)*\\)[^)(]*)*\\)[^)(]*)*)\\)",'"(.*?)"'],"tw`(.*?)`","tw\\('(.*?)'\\)",`tw\\(\\s*('(.*?)'|"(.*?)")\\s*\\)`]};import{merge as nr}from"es-toolkit";import eo from"fs-extra";function ro(o,r){let e={};if(eo.existsSync(o))try{e=eo.readJsonSync(o)}catch{console.warn(`\u26A0\uFE0F Could not parse ${o}, starting fresh.`)}let t=nr(e,r);eo.writeJsonSync(o,t,{spaces:2})}var Do=(o=".vscode")=>{cr.ensureDirSync(o),ro(`${o}/extensions.json`,Ko),ro(`${o}/settings.json`,Uo)};var dr=async o=>{let r=await u(o),e=lr("Updating nuxt.config...").start();await ir({cwd:process.cwd(),configFile:"nuxt.config",async onUpdate(c){c.modules||(c.modules=[]),c.imports||(c.imports={imports:[]});for(let d of fo)c.modules.includes(d)||c.modules.push(d);if(!c.colorMode){let d=ar.basename(process.cwd());c.colorMode={storageKey:`${d}-color-mode`,classSuffix:""}}c.icon||(c.icon={clientBundle:{scan:!0,sizeLimitKb:0},mode:"svg",class:"shrink-0",fetchTimeout:2e3,serverBundle:"local"}),c.imports.imports.find(d=>d.from==="tailwind-variants"&&d.name==="tv")||c.imports.imports.push({from:"tailwind-variants",name:"tv"}),c.imports.imports.find(d=>d.from==="tailwind-variants"&&d.name==="VariantProps")||c.imports.imports.push({from:"tailwind-variants",name:"VariantProps",type:!0}),c.css||=[];let a=r.tailwindCSSLocation?.split("app/")[1],i=`~/${a}`,l=`@/${a}`;!c.css.includes(i)&&!c.css.includes(l)&&c.css.push(i)}}),await Lo(),e.succeed("Updated nuxt.config!"),e.start("Adding initial Tailwind CSS file..."),jo.writeFileSync(r.tailwindCSSLocation,B(r.theme.toUpperCase()),"utf-8"),e.succeed("Added initial Tailwind CSS file!"),e.start("Adding Autocomplete helper..."),jo.writeFileSync(r.utilsLocation+"/tw-helper.ts",Oo,"utf-8"),e.succeed("Added Autocomplete helper!"),e.start("Merging VS Code settings..."),Do(),e.succeed("Merged VS Code settings!"),await f(r.packageManager,uo,mo),await Po()&&(await f(r.packageManager,[],O),await W()),m("Initialized",`Feel free to start adding components with the ${to.bgWhite(" add ")} command.`,{box:{title:"Complete"}})},Ro=new sr().command("init").name("init").summary("Initialize UI Thing in your Nuxt project.").description(`${to.bold("Initialize UI Thing in your Nuxt project.")}
|
|
1005
1006
|
|
|
1006
1007
|
\u2705 Add tailwindcss to your project
|
|
1007
1008
|
\u2705 Update your nuxt.config file
|
|
1008
1009
|
\u2705 Add the necessary dependencies
|
|
1009
|
-
\u2705 Create a ${
|
|
1010
|
-
|
|
1011
|
-
useActiveElement,
|
|
1012
|
-
useDebounceFn,
|
|
1013
|
-
useEventListener,
|
|
1014
|
-
} from "@vueuse/core";
|
|
1015
|
-
import type { MaybeRef } from "vue";
|
|
1010
|
+
\u2705 Create a ${to.bold("ui-thing.config")} file with the default configuration`).option("-f --force","Overwrite config file if it exists.",!1).option("-y --yes","Skip prompts and use default values.",!1).option("-n --nuxtVersion <number>","Specify the Nuxt version you are using.").action(dr);import{Command as hr}from"commander";import pr from"prompts";var Bo=new hr().command("prettier").name("prettier").description("Adds prettier config to your project.").action(async()=>{if(!await W(void 0,!1)){m("Not Added","Prettier config was not added.",{box:{title:"Prettier Not Added",borderColor:"red"}});return}let{pkgManager:r}=await pr({name:"pkgManager",type:"select",message:"Which package manager are you using?",choices:C});if(!r)return process.exit(0);await f(r,void 0,O),m("All Done!","A .prettierrc file has been added to your project and the code formatted. Enjoy!",{box:{title:"Prettier Added"}})});import{spawnSync as kr}from"child_process";import H from"path";import{Command as gr}from"commander";import{consola as I}from"consola";import v from"kleur";import M from"lodash";import ao from"prompts";import ur from"axios";import mr from"dotenv";import fr from"ora";mr.config();var $o=async()=>{let o=fr("Fetching prose components...").start(),{data:r}=await ur.get(process.env.PROSE_COMPONENTS_API||"https://uithing.com/api/prose");return o.succeed("Prose components fetched."),r};var io=[],G=process.cwd(),no=o=>io.find(r=>r.value.toLowerCase()===o.toLowerCase());async function Wo(o,r,e,t){if(await y(o)&&!e){let{value:a}=await ao({type:"confirm",name:"value",message:t,initial:!1});if(!a)return I.info(`Skipped: ${v.cyan(H.basename(o))}`),!1}return await S(o,r),!0}async function co(o,r,e,t){if(!(!r||r.length===0))for(let c of r){let a=H.join(G,e,c.fileName);await Wo(a,c.fileContent,t,`The ${o} file ${v.bold(c.fileName)} already exists. Overwrite?`)}}var yr=async(o,r)=>{let e=await u();await g()||(e=await u({force:!0})),M.isEmpty(e)&&(I.info("Config file not set. Exiting..."),process.exit(0)),io=await $o();let t=o;if(t.length===0){let n=await L(r.all,io);(!n||n.length===0)&&(I.info("No components selected. Exiting..."),process.exit(0)),t=n}let c=t.filter(n=>!no(n));c.length>0&&I.error(`Not found: ${v.bgRed(c.join(", "))}`);let a=t.map(n=>no(n)).filter(Boolean);for(let n of[...a])n.prose&&n.prose.length>0&&n.prose.forEach(p=>{if(!a.find(h=>h.value===p)){let h=no(p);h&&a.push(h)}});for(let n of a){let p=n.file,h=e.componentsLocation,s=H.join(G,h,p.fileName);if(!e.useDefaultFilename){let{value:b}=await ao({type:"text",name:"value",message:`Where should we add the file ${v.cyan(p.fileName)}?`,initial:h});b&&(h=b,s=H.join(G,h,p.fileName))}await Wo(s,p.fileContent,e.force,`The file ${v.bold(p.fileName)} already exists. Overwrite?`)&&(await co("utils",n.utils,e.utilsLocation,e.force),await co("composables",n.composables,e.composablesLocation,e.force),await co("plugins",n.plugins,e.pluginsLocation??"",e.force))}await A(M.uniq(a.flatMap(n=>n.modules||[])));let i=M.uniq(a.flatMap(n=>n.deps||[])),l=M.uniq(a.flatMap(n=>n.devDeps||[]));if(i.length>0||l.length>0)if(r.all)await f(e.packageManager,i,l);else{let{confirmInstall:n}=await ao({type:"confirm",name:"confirmInstall",message:`Install packages: ${v.cyan([...i,...l].join(", "))}?`,initial:!0});n&&await f(e.packageManager,i,l)}let d=M.uniq(a.flatMap(n=>n.components||[]));if(d.length>0){I.info(`Adding ${d.length} component(s) required by prose...`);let n=kr("npx",["ui-thing@latest","add",...d],{cwd:G,stdio:"inherit"});n.error&&I.error("Failed to add components:",n.error.message)}m("Prose added!",`Run the ${v.cyan("ui-thing@latest --help")} command to learn more.
|
|
1011
|
+
`,{box:{title:"Prose Components Added"}})},Go=new gr().name("prose").command("prose").description("Add prose components to your project.").option("-a --all","Add all prose components to your project.",!1).argument("[componentNames...]").action(yr);import{Command as br}from"commander";import{execa as vr}from"execa";import wr from"ora";import Cr from"prompts";import{join as Vo}from"path";import zo from"fs-extra";var Ho=`import type { MaybeRef } from "vue";
|
|
1016
1012
|
|
|
1017
1013
|
type KbdKeysSpecificMap = {
|
|
1018
1014
|
meta: string;
|
|
@@ -1326,5 +1322,5 @@ export function defineShortcuts(config: MaybeRef<ShortcutsConfig>, options: Shor
|
|
|
1326
1322
|
return useEventListener("keydown", onKeyDown);
|
|
1327
1323
|
}
|
|
1328
1324
|
|
|
1329
|
-
`;var
|
|
1325
|
+
`;var qo=async(o=process.cwd())=>{let r=await u(),e=Vo(o,r.composablesLocation);await zo.ensureDir(e),await zo.writeFile(Vo(e,"shortcuts.ts"),Ho,"utf-8")};var Yo=new br().command("shortcuts").name("shortcuts").description("Add the shortcuts composables to your project.").action(async()=>{await qo();let{pkgManager:o}=await Cr({name:"pkgManager",type:"select",message:"Which package manager are you using?",choices:C});if(!o)return process.exit(0);let r=wr("Installing vueuse module...").start();await vr`npx -y nuxi@latest module add vueuse`,r.succeed("VueUse module installed successfully!"),m("All Done!","Check the composables folder for the shortcuts composables.",{box:{title:"Composable Added"}})});import{Command as xr}from"commander";import Jo from"fs-extra";import Xo from"kleur";import so from"lodash";import Zo from"prompts";var Sr=o=>T.some(r=>r.value===o?.toLowerCase()),Qo=new xr().command("theme").name("theme").description("Add a new theme to your project.").argument("[themeName]","The name of the theme you would like to add").action(async o=>{let r=await u();await g()||(r=await u({force:!0})),so.isEmpty(r)&&(console.log(Xo.red("Config file not set. Exiting...")),process.exit(0));let t=o&&Sr(o)?o.toLowerCase():void 0;if(!t){let{theme:c}=await Zo([{name:"theme",type:"autocomplete",message:"Which theme do you want to add?",choices:T}]);c||(console.log(Xo.red("No theme selected. Exiting...")),process.exit(0)),t=c}if(Jo.existsSync(r.tailwindCSSLocation)){let{force:c}=await Zo([{name:"force",type:"confirm",message:"The Tailwind CSS file already exists. Overwrite?",initial:!1}]);if(!c)return console.log("Exiting..."),process.exit(0)}Jo.writeFileSync(r.tailwindCSSLocation,B(t.toUpperCase()),"utf-8"),m(`${so.capitalize(t)}`,`${so.capitalize(t)} theme has been added to ${r.tailwindCSSLocation}`,{box:{title:"New Theme Added"}})});process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));process.on("SIGTSTP",()=>process.exit(0));var oe=new Er;console.clear();m("UI Thing",void 0,{box:{title:"Welcome"}});console.log();oe.name("ui-thing").description("CLI for adding ui-thing components to your Nuxt application").version(lo).addCommand(Ro).addCommand(Eo).addCommand(Go).addCommand(Mo).addCommand(Qo).addCommand(Yo).addCommand(Bo);oe.parse(process.argv);
|
|
1330
1326
|
//# sourceMappingURL=index.js.map
|