@rajdeep0510/scaffold-cli 1.0.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/.idea/cil-mvp.iml +12 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/bin/index.js +46 -0
- package/commands/addComponent.js +76 -0
- package/commands/list.js +62 -0
- package/package.json +42 -0
- package/templates/button/component.jsx +92 -0
- package/templates/button/index.js +2 -0
- package/templates/button/meta.json +28 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Rajdeep Vala
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# lib_ui
|
|
2
|
+
|
|
3
|
+
A CLI tool for creating versatile and modern UI components.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g lib_ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
lib_ui add <component-name>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Examples
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
lib_ui add Header
|
|
21
|
+
lib_ui add Button
|
|
22
|
+
lib_ui add Card
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Troubleshooting
|
|
26
|
+
|
|
27
|
+
If you get a "command not found" error after installation, you may need to add npm's global bin directory to your PATH:
|
|
28
|
+
|
|
29
|
+
### For macOS/Linux:
|
|
30
|
+
```bash
|
|
31
|
+
# Add this to your ~/.zshrc or ~/.bashrc
|
|
32
|
+
export PATH="$(npm config get prefix)/bin:$PATH"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### For Windows:
|
|
36
|
+
The npm global bin directory is usually already in your PATH. If not, you can find it by running:
|
|
37
|
+
```bash
|
|
38
|
+
npm config get prefix
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Development
|
|
42
|
+
|
|
43
|
+
To install locally for development:
|
|
44
|
+
```bash
|
|
45
|
+
git clone <repository-url>
|
|
46
|
+
cd lib_ui
|
|
47
|
+
npm install
|
|
48
|
+
npm link
|
|
49
|
+
```
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander'
|
|
3
|
+
import { addComponent } from '../commands/addComponent.js'
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import figlet from "figlet";
|
|
6
|
+
import list from "../commands/list.js";
|
|
7
|
+
|
|
8
|
+
const program = new Command()
|
|
9
|
+
|
|
10
|
+
program
|
|
11
|
+
.name('scaffold')
|
|
12
|
+
.version('1.0.0', '-v, --version', 'output the current version')
|
|
13
|
+
.description('Custom UI component generator')
|
|
14
|
+
|
|
15
|
+
// Add custom help text before the built-in help
|
|
16
|
+
program.addHelpText('before', () => {
|
|
17
|
+
const banner = chalk.cyan(
|
|
18
|
+
figlet.textSync("Scaffold", {
|
|
19
|
+
font: "Standard",
|
|
20
|
+
horizontalLayout: "default",
|
|
21
|
+
verticalLayout: "default"
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const description = chalk.bold(
|
|
26
|
+
"This is a UI library of components which are very easy to import and use"
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const importInfo = chalk.blue("How to import components:") + "\n" +
|
|
30
|
+
chalk.green(" import { Button } from '@/components/ui/button'");
|
|
31
|
+
|
|
32
|
+
return banner + "\n\n" + description + "\n\n" + importInfo + "\n\n";
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
program
|
|
36
|
+
.command('add <component-name>')
|
|
37
|
+
.description('Add a new component')
|
|
38
|
+
.action(addComponent)
|
|
39
|
+
|
|
40
|
+
program
|
|
41
|
+
.command('list')
|
|
42
|
+
.description('List all the components')
|
|
43
|
+
.action(list)
|
|
44
|
+
|
|
45
|
+
program.parse()
|
|
46
|
+
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { fileURLToPath } from 'url'
|
|
4
|
+
import chalk from 'chalk'
|
|
5
|
+
import figlet from 'figlet'
|
|
6
|
+
import ora from 'ora'
|
|
7
|
+
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url)) // ESM-safe __dirname
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
// banner TODO: remove
|
|
12
|
+
console.log(
|
|
13
|
+
chalk.cyan(
|
|
14
|
+
figlet.text('scaffold', { font: 'doom' }, function(err, data) {
|
|
15
|
+
if (err) {
|
|
16
|
+
console.log('Something went wrong...');
|
|
17
|
+
console.dir(err);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
console.log(data);
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
export async function addComponent(name) {
|
|
27
|
+
const useSrc = await fs.pathExists('src')
|
|
28
|
+
const hasApp = await fs.pathExists(path.join(useSrc ? 'src' : '', 'app'))
|
|
29
|
+
const hasPages = await fs.pathExists(path.join(useSrc ? 'src' : '', 'pages'))
|
|
30
|
+
|
|
31
|
+
if (!hasApp && !hasPages) {
|
|
32
|
+
console.log(chalk.red('Could not detect Next.js routing structure (no app/ or pages/ directory)'))
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const baseDir = useSrc ? 'src/components/ui' : 'components/ui'
|
|
37
|
+
const targetDir = path.join(baseDir, name)
|
|
38
|
+
const templateDir = path.resolve(__dirname, '../templates', name)
|
|
39
|
+
|
|
40
|
+
// š check if template folder exists
|
|
41
|
+
if (!(await fs.pathExists(templateDir))) {
|
|
42
|
+
console.log(chalk.red(`Template folder '${templateDir}' not found.`))
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// š validate meta.json before copying
|
|
47
|
+
const metaPath = path.join(templateDir, 'meta.json')
|
|
48
|
+
if (!(await fs.pathExists(metaPath))) {
|
|
49
|
+
console.log(chalk.red(`No meta.json found in template '${name}'`))
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const meta = await fs.readJson(metaPath)
|
|
54
|
+
if (!meta.name || !meta.description || !meta.version) {
|
|
55
|
+
console.log(chalk.red(`Invalid meta.json for '${name}'. Missing required fields.`))
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// š Spinner while copying
|
|
60
|
+
const spinner = ora(`Adding component '${name}'...`).start()
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
await fs.ensureDir(targetDir)
|
|
64
|
+
await fs.copy(templateDir, targetDir)
|
|
65
|
+
|
|
66
|
+
spinner.succeed(chalk.green(`Component '${meta.name}' created at ${targetDir}`))
|
|
67
|
+
|
|
68
|
+
console.log(chalk.yellow(`ā¹ļø Description:`), chalk.white(meta.description))
|
|
69
|
+
console.log(chalk.magenta(`š¦ Version:`), chalk.white(meta.version))
|
|
70
|
+
console.log(chalk.cyan(`\nš Import in Next.js:`))
|
|
71
|
+
console.log(chalk.blueBright(` import { ${meta.name} } from "@/components/ui/${name}"\n`))
|
|
72
|
+
} catch (err) {
|
|
73
|
+
spinner.fail(chalk.red(`Failed to add component '${name}'`))
|
|
74
|
+
console.error(err)
|
|
75
|
+
}
|
|
76
|
+
}
|
package/commands/list.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import figlet from "figlet";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
|
|
9
|
+
// š¹ Helper to render figlet banner
|
|
10
|
+
function renderFiglet(text, font = "Standard") {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
figlet.text(text, { font }, (err, data) => {
|
|
13
|
+
if (err) reject(err);
|
|
14
|
+
else resolve(data);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default async function list() {
|
|
20
|
+
try {
|
|
21
|
+
const banner = await renderFiglet("Available Components", "doom");
|
|
22
|
+
console.log(chalk.cyan(banner));
|
|
23
|
+
|
|
24
|
+
const templatesDir = path.resolve(__dirname, "../templates");
|
|
25
|
+
|
|
26
|
+
if (!(await fs.pathExists(templatesDir))) {
|
|
27
|
+
console.log(chalk.red("ā No templates directory found."));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const components = await fs.readdir(templatesDir);
|
|
32
|
+
|
|
33
|
+
if (!components.length) {
|
|
34
|
+
console.log(chalk.yellow("ā ļø No components found in templates/"));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
console.log(chalk.green("š¦ Components available:\n"));
|
|
39
|
+
|
|
40
|
+
for (const comp of components) {
|
|
41
|
+
const metaPath = path.join(templatesDir, comp, "meta.json");
|
|
42
|
+
|
|
43
|
+
if (await fs.pathExists(metaPath)) {
|
|
44
|
+
const meta = await fs.readJson(metaPath);
|
|
45
|
+
console.log(
|
|
46
|
+
chalk.blueBright(`š¹ ${meta.name} `) +
|
|
47
|
+
chalk.gray(`(v${meta.version}) - ${meta.description}`)
|
|
48
|
+
);
|
|
49
|
+
} else {
|
|
50
|
+
console.log(chalk.magenta(`š¹ ${comp}`) + chalk.red(" (no meta.json)"));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
console.log(
|
|
55
|
+
chalk.cyan(
|
|
56
|
+
"\nš Use `scaffold add <component>` to add one of these to your project."
|
|
57
|
+
)
|
|
58
|
+
);
|
|
59
|
+
} catch (err) {
|
|
60
|
+
console.error(chalk.red("ā Failed to list components:"), err);
|
|
61
|
+
}
|
|
62
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rajdeep0510/scaffold-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "This is a CLI app for a UI library which is used for creating versatile and modern UI components.",
|
|
5
|
+
"main": "bin/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"scaffold": "bin/index.js"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"cli",
|
|
12
|
+
"ui",
|
|
13
|
+
"components",
|
|
14
|
+
"scaffold",
|
|
15
|
+
"generator"
|
|
16
|
+
],
|
|
17
|
+
"author": "Rajdeep Vala",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/rajdeep0510/scaffold-cli.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/rajdeep0510/scaffold-cli/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/rajdeep0510/scaffold-cli#readme",
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18.0.0"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"test": "echo 'OK'",
|
|
32
|
+
"postinstall": "node -e \"console.log('ā
Scaffold CLI installed successfully!\\nš” Run: scaffold help to get started')\""
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"chalk": "^5.6.0",
|
|
36
|
+
"commander": "^14.0.0",
|
|
37
|
+
"figlet": "^1.8.2",
|
|
38
|
+
"fs-extra": "^11.3.1",
|
|
39
|
+
"ora": "^8.2.0",
|
|
40
|
+
"prop-types": "^15.8.1"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A customizable button component with multiple variants and sizes + click animation
|
|
6
|
+
*/
|
|
7
|
+
const Button = ({
|
|
8
|
+
children,
|
|
9
|
+
variant = 'primary',
|
|
10
|
+
size = 'md',
|
|
11
|
+
disabled = false,
|
|
12
|
+
loading = false,
|
|
13
|
+
className = '',
|
|
14
|
+
onClick,
|
|
15
|
+
type = 'button',
|
|
16
|
+
...rest
|
|
17
|
+
}) => {
|
|
18
|
+
const [isActive, setIsActive] = useState(false);
|
|
19
|
+
|
|
20
|
+
const baseStyles = {
|
|
21
|
+
display: 'inline-flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
justifyContent: 'center',
|
|
24
|
+
border: 'none',
|
|
25
|
+
borderRadius: '6px',
|
|
26
|
+
fontFamily: 'inherit',
|
|
27
|
+
fontWeight: '500',
|
|
28
|
+
cursor: disabled || loading ? 'not-allowed' : 'pointer',
|
|
29
|
+
transition: 'all 0.15s ease-in-out',
|
|
30
|
+
opacity: disabled || loading ? 0.6 : 1,
|
|
31
|
+
transform: isActive ? 'scale(0.95)' : 'scale(1)', // š shrink effect
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const variantStyles = {
|
|
35
|
+
primary: { backgroundColor: '#3b82f6', color: 'white' },
|
|
36
|
+
secondary: { backgroundColor: '#f8fafc', color: '#374151', border: '1px solid #d1d5db' },
|
|
37
|
+
destructive: { backgroundColor: '#dc2626', color: 'white' },
|
|
38
|
+
outline: { backgroundColor: 'transparent', border: '1px solid #d1d5db', color: '#374151' },
|
|
39
|
+
ghost: { backgroundColor: 'transparent', color: '#374151' },
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const sizeStyles = {
|
|
43
|
+
sm: { height: '32px', padding: '0 12px', fontSize: '14px' },
|
|
44
|
+
md: { height: '40px', padding: '0 16px', fontSize: '14px' },
|
|
45
|
+
lg: { height: '44px', padding: '0 24px', fontSize: '16px' },
|
|
46
|
+
xl: { height: '52px', padding: '0 32px', fontSize: '16px' },
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const buttonStyles = {
|
|
50
|
+
...baseStyles,
|
|
51
|
+
...variantStyles[variant],
|
|
52
|
+
...sizeStyles[size],
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const handleClick = (e) => {
|
|
56
|
+
if (disabled || loading) {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
setIsActive(true);
|
|
61
|
+
setTimeout(() => setIsActive(false), 150); // reset after animation
|
|
62
|
+
if (onClick) onClick(e);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<button
|
|
67
|
+
type={type}
|
|
68
|
+
disabled={disabled || loading}
|
|
69
|
+
onClick={handleClick}
|
|
70
|
+
className={className}
|
|
71
|
+
style={buttonStyles}
|
|
72
|
+
aria-disabled={disabled || loading}
|
|
73
|
+
aria-busy={loading}
|
|
74
|
+
{...rest}
|
|
75
|
+
>
|
|
76
|
+
{loading ? 'Loading...' : children}
|
|
77
|
+
</button>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
Button.propTypes = {
|
|
82
|
+
children: PropTypes.node,
|
|
83
|
+
variant: PropTypes.oneOf(['primary', 'secondary', 'destructive', 'outline', 'ghost']),
|
|
84
|
+
size: PropTypes.oneOf(['sm', 'md', 'lg', 'xl']),
|
|
85
|
+
disabled: PropTypes.bool,
|
|
86
|
+
loading: PropTypes.bool,
|
|
87
|
+
className: PropTypes.string,
|
|
88
|
+
onClick: PropTypes.func,
|
|
89
|
+
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export default Button;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Button",
|
|
3
|
+
"description": "A customizable button component with multiple variants, sizes, and states.",
|
|
4
|
+
"category": "form",
|
|
5
|
+
"tags": ["button", "interactive", "form", "cta"],
|
|
6
|
+
"version": "1.0.0",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"npm": [],
|
|
9
|
+
"peer": ["react", "prop-types"]
|
|
10
|
+
},
|
|
11
|
+
"props": [
|
|
12
|
+
{ "name": "children", "type": "React.ReactNode", "description": "Content inside the button" },
|
|
13
|
+
{ "name": "variant", "type": "string", "default": "primary", "options": ["primary","secondary","destructive","outline","ghost"] },
|
|
14
|
+
{ "name": "size", "type": "string", "default": "md", "options": ["sm","md","lg","xl"] },
|
|
15
|
+
{ "name": "disabled", "type": "boolean", "default": false, "description": "Disable button" },
|
|
16
|
+
{ "name": "loading", "type": "boolean", "default": false, "description": "Loading state" },
|
|
17
|
+
{ "name": "className", "type": "string", "description": "Extra CSS classes" },
|
|
18
|
+
{ "name": "onClick", "type": "function", "description": "Click handler" },
|
|
19
|
+
{ "name": "type", "type": "string", "default": "button", "options": ["button","submit","reset"] }
|
|
20
|
+
],
|
|
21
|
+
"examples": [
|
|
22
|
+
{ "name": "Basic", "code": "<Button>Click Me</Button>" },
|
|
23
|
+
{ "name": "Variants", "code": "<><Button variant='primary'>Primary</Button><Button variant='secondary'>Secondary</Button></>" },
|
|
24
|
+
{ "name": "Sizes", "code": "<><Button size='sm'>Small</Button><Button size='lg'>Large</Button></>" },
|
|
25
|
+
{ "name": "Loading", "code": "<Button loading>Loading...</Button>" }
|
|
26
|
+
],
|
|
27
|
+
"files": ["component.jsx", "index.js"]
|
|
28
|
+
}
|