@pushpak_jangela/pushpak-ui-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/bin/index.js +130 -0
- package/index.ts +0 -0
- package/package.json +20 -0
- package/templates/components/js/button.jsx +16 -0
- package/templates/components/ts/button.tsx +31 -0
- package/templates/dashboard/js/index.jsx +10 -0
- package/templates/dashboard/ts/index.tsx +11 -0
- package/tsconfig.json +8 -0
package/bin/index.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { Command } = require("commander");
|
|
4
|
+
const chalk = require("chalk");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const fs = require("fs-extra");
|
|
7
|
+
|
|
8
|
+
const program = new Command();
|
|
9
|
+
|
|
10
|
+
/* -------------------------------------------------------
|
|
11
|
+
Helpers
|
|
12
|
+
-------------------------------------------------------- */
|
|
13
|
+
|
|
14
|
+
function isTypeScriptProject(projectRoot) {
|
|
15
|
+
return fs.existsSync(path.join(projectRoot, "tsconfig.json"));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function ensureReactProject(srcDir) {
|
|
19
|
+
if (!fs.existsSync(srcDir)) {
|
|
20
|
+
console.log(
|
|
21
|
+
chalk.red("❌ src folder not found. Run this inside a React project.")
|
|
22
|
+
);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* -------------------------------------------------------
|
|
28
|
+
CLI Meta
|
|
29
|
+
-------------------------------------------------------- */
|
|
30
|
+
|
|
31
|
+
program
|
|
32
|
+
.name("pushpak-ui")
|
|
33
|
+
.description("Pushpak UI CLI – React component & dashboard generator")
|
|
34
|
+
.version("1.0.0");
|
|
35
|
+
|
|
36
|
+
/* -------------------------------------------------------
|
|
37
|
+
INIT → Install EVERYTHING
|
|
38
|
+
-------------------------------------------------------- */
|
|
39
|
+
|
|
40
|
+
program
|
|
41
|
+
.command("init")
|
|
42
|
+
.description("Install all UI components & dashboard")
|
|
43
|
+
.action(() => {
|
|
44
|
+
const projectRoot = process.cwd();
|
|
45
|
+
const srcDir = path.join(projectRoot, "src");
|
|
46
|
+
|
|
47
|
+
ensureReactProject(srcDir);
|
|
48
|
+
|
|
49
|
+
const isTS = isTypeScriptProject(projectRoot);
|
|
50
|
+
const lang = isTS ? "ts" : "js";
|
|
51
|
+
|
|
52
|
+
console.log(
|
|
53
|
+
chalk.cyan(`ℹ Detected ${isTS ? "TypeScript" : "JavaScript"} project`)
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const componentsSrc = path.join(
|
|
57
|
+
__dirname,
|
|
58
|
+
`../templates/components/${lang}`
|
|
59
|
+
);
|
|
60
|
+
const dashboardSrc = path.join(
|
|
61
|
+
__dirname,
|
|
62
|
+
`../templates/dashboard/${lang}`
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const componentsDest = path.join(srcDir, "components/ui");
|
|
66
|
+
const dashboardDest = path.join(srcDir, "dashboard");
|
|
67
|
+
|
|
68
|
+
fs.ensureDirSync(componentsDest);
|
|
69
|
+
fs.ensureDirSync(dashboardDest);
|
|
70
|
+
|
|
71
|
+
fs.copySync(componentsSrc, componentsDest);
|
|
72
|
+
fs.copySync(dashboardSrc, dashboardDest);
|
|
73
|
+
|
|
74
|
+
console.log(chalk.green("✔ All UI components added"));
|
|
75
|
+
console.log(chalk.green("✔ Dashboard added"));
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/* -------------------------------------------------------
|
|
79
|
+
ADD → Install SINGLE component
|
|
80
|
+
-------------------------------------------------------- */
|
|
81
|
+
|
|
82
|
+
program
|
|
83
|
+
.command("add <component>")
|
|
84
|
+
.description("Install a single UI component")
|
|
85
|
+
.action((component) => {
|
|
86
|
+
const projectRoot = process.cwd();
|
|
87
|
+
const srcDir = path.join(projectRoot, "src");
|
|
88
|
+
|
|
89
|
+
ensureReactProject(srcDir);
|
|
90
|
+
|
|
91
|
+
const isTS = isTypeScriptProject(projectRoot);
|
|
92
|
+
const lang = isTS ? "ts" : "js";
|
|
93
|
+
const ext = isTS ? "tsx" : "jsx";
|
|
94
|
+
|
|
95
|
+
const componentSrc = path.join(
|
|
96
|
+
__dirname,
|
|
97
|
+
`../templates/components/${lang}/${component}.${ext}`
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
if (!fs.existsSync(componentSrc)) {
|
|
101
|
+
console.log(
|
|
102
|
+
chalk.red(`❌ Component "${component}" does not exist.`)
|
|
103
|
+
);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const destDir = path.join(srcDir, "components/ui");
|
|
108
|
+
const destFile = path.join(destDir, `${component}.${ext}`);
|
|
109
|
+
|
|
110
|
+
fs.ensureDirSync(destDir);
|
|
111
|
+
|
|
112
|
+
if (fs.existsSync(destFile)) {
|
|
113
|
+
console.log(
|
|
114
|
+
chalk.yellow(`⚠ "${component}" already exists. Skipping.`)
|
|
115
|
+
);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
fs.copySync(componentSrc, destFile);
|
|
120
|
+
|
|
121
|
+
console.log(
|
|
122
|
+
chalk.green(`✔ "${component}" component added`)
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
/* -------------------------------------------------------
|
|
127
|
+
Parse CLI
|
|
128
|
+
-------------------------------------------------------- */
|
|
129
|
+
|
|
130
|
+
program.parse(process.argv);
|
package/index.ts
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pushpak_jangela/pushpak-ui-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"bin": {
|
|
5
|
+
"pushpak-ui": "bin/index.js"
|
|
6
|
+
},
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"description": "",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"chalk": "^4.1.2",
|
|
17
|
+
"commander": "^14.0.2",
|
|
18
|
+
"fs-extra": "^11.3.3"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function Button({ children }) {
|
|
2
|
+
return (
|
|
3
|
+
<button
|
|
4
|
+
style={{
|
|
5
|
+
padding: "8px 16px",
|
|
6
|
+
borderRadius: "6px",
|
|
7
|
+
backgroundColor: "#2563eb",
|
|
8
|
+
color: "#fff",
|
|
9
|
+
border: "none",
|
|
10
|
+
cursor: "pointer",
|
|
11
|
+
}}
|
|
12
|
+
>
|
|
13
|
+
{children}
|
|
14
|
+
</button>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
type ButtonProps = {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export function Button({ children }: ButtonProps) {
|
|
8
|
+
return <button>{children}</button>;
|
|
9
|
+
}
|
|
10
|
+
import React from "react";
|
|
11
|
+
|
|
12
|
+
type ButtonProps = {
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function Button({ children }: ButtonProps) {
|
|
17
|
+
return (
|
|
18
|
+
<button
|
|
19
|
+
style={{
|
|
20
|
+
padding: "8px 16px",
|
|
21
|
+
borderRadius: "6px",
|
|
22
|
+
backgroundColor: "#2563eb",
|
|
23
|
+
color: "#fff",
|
|
24
|
+
border: "none",
|
|
25
|
+
cursor: "pointer"
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
{children}
|
|
29
|
+
</button>
|
|
30
|
+
);
|
|
31
|
+
}
|