uniqueui-cli 0.1.4 → 0.1.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/dist/commands/add.js +40 -6
- package/dist/commands/init.js +19 -3
- package/dist/debug.js +37 -0
- package/package.json +9 -8
package/dist/commands/add.js
CHANGED
|
@@ -32,7 +32,8 @@ async function add(componentName, options) {
|
|
|
32
32
|
return null;
|
|
33
33
|
return await res.json();
|
|
34
34
|
}
|
|
35
|
-
catch {
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error(chalk_1.default.yellow(`\nWarning: Failed to fetch from ${baseUrl}:`), error);
|
|
36
37
|
return null;
|
|
37
38
|
}
|
|
38
39
|
}
|
|
@@ -90,27 +91,60 @@ async function add(componentName, options) {
|
|
|
90
91
|
await updateTailwindConfig(config.tailwind.config, item.tailwindConfig);
|
|
91
92
|
}
|
|
92
93
|
// 5. Write Files
|
|
93
|
-
const targetDir = path_1.default.resolve(config.paths.components || "components/ui");
|
|
94
|
-
await fs_extra_1.default.ensureDir(targetDir);
|
|
95
94
|
for (const file of item.files) {
|
|
96
|
-
// We only handle ui components for now
|
|
97
95
|
if (file.type === "registry:ui") {
|
|
96
|
+
const targetDir = path_1.default.resolve(config.paths.components || "components/ui");
|
|
97
|
+
await fs_extra_1.default.ensureDir(targetDir);
|
|
98
98
|
const fileName = path_1.default.basename(file.path);
|
|
99
99
|
const targetPath = path_1.default.join(targetDir, fileName);
|
|
100
100
|
await fs_extra_1.default.writeFile(targetPath, file.content);
|
|
101
101
|
console.log(chalk_1.default.green(`Created ${fileName}`));
|
|
102
102
|
}
|
|
103
|
-
|
|
103
|
+
else if (file.type === "registry:util") {
|
|
104
|
+
const targetDir = path_1.default.resolve(config.paths.lib || "utils");
|
|
105
|
+
await fs_extra_1.default.ensureDir(targetDir);
|
|
106
|
+
const fileName = path_1.default.basename(file.path);
|
|
107
|
+
const targetPath = path_1.default.join(targetDir, fileName);
|
|
108
|
+
// Only create util if it doesn't exist
|
|
109
|
+
if (!fs_extra_1.default.existsSync(targetPath)) {
|
|
110
|
+
await fs_extra_1.default.writeFile(targetPath, file.content);
|
|
111
|
+
console.log(chalk_1.default.green(`Created ${fileName}`));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
104
114
|
}
|
|
105
115
|
}
|
|
106
116
|
async function updateTailwindConfig(configPath, newConfig) {
|
|
117
|
+
// Check for config file existence and handle fallback
|
|
118
|
+
let finalConfigPath = configPath;
|
|
119
|
+
if (!fs_extra_1.default.existsSync(finalConfigPath)) {
|
|
120
|
+
// Try alternatives
|
|
121
|
+
const ext = path_1.default.extname(configPath);
|
|
122
|
+
const base = configPath.slice(0, -ext.length);
|
|
123
|
+
const altExts = [".ts", ".js", ".mjs", ".cjs"];
|
|
124
|
+
const found = altExts.find(e => fs_extra_1.default.existsSync(base + e));
|
|
125
|
+
if (found) {
|
|
126
|
+
console.log(chalk_1.default.yellow(`Config ${configPath} not found, using ${base + found} instead.`));
|
|
127
|
+
finalConfigPath = base + found;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
console.warn(chalk_1.default.yellow(`Tailwind config not found at ${configPath}. Skipping update.`));
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
107
134
|
const project = new ts_morph_1.Project({
|
|
108
135
|
manipulationSettings: {
|
|
109
136
|
quoteKind: ts_morph_1.QuoteKind.Double,
|
|
110
137
|
}
|
|
111
138
|
});
|
|
112
139
|
// Attempt to add the file
|
|
113
|
-
|
|
140
|
+
let sourceFile;
|
|
141
|
+
try {
|
|
142
|
+
sourceFile = project.addSourceFileAtPath(finalConfigPath);
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
console.error(chalk_1.default.yellow(`Failed to parse tailwind config at ${finalConfigPath}. Skipping update.`), e);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
114
148
|
// Simplistic handling: look for export default or module.exports
|
|
115
149
|
// We expect the config to be an object literal.
|
|
116
150
|
// We need to merge `newConfig.theme.extend` into the existing config.
|
package/dist/commands/init.js
CHANGED
|
@@ -40,19 +40,35 @@ async function init() {
|
|
|
40
40
|
tsx: response.typescript,
|
|
41
41
|
tailwind: {
|
|
42
42
|
config: response.tailwindConfig,
|
|
43
|
-
css: "app/globals.css",
|
|
43
|
+
css: "app/globals.css",
|
|
44
44
|
baseColor: "slate",
|
|
45
45
|
cssVariables: true,
|
|
46
46
|
},
|
|
47
47
|
aliases: {
|
|
48
48
|
components: "@/components",
|
|
49
|
-
utils: "@/
|
|
49
|
+
utils: "@/utils",
|
|
50
50
|
},
|
|
51
51
|
paths: {
|
|
52
52
|
components: response.componentsDir,
|
|
53
|
-
lib: "
|
|
53
|
+
lib: "utils"
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
await fs_1.promises.writeFile(path_1.default.join(cwd, "components.json"), JSON.stringify(config, null, 2));
|
|
57
|
+
// Create utils/cn.ts if it doesn't exist
|
|
58
|
+
const utilsDir = path_1.default.join(cwd, "utils");
|
|
59
|
+
const cnPath = path_1.default.join(utilsDir, "cn.ts");
|
|
60
|
+
const cnContent = `import { type ClassValue, clsx } from "clsx";
|
|
61
|
+
import { twMerge } from "tailwind-merge";
|
|
62
|
+
|
|
63
|
+
export function cn(...inputs: ClassValue[]) {
|
|
64
|
+
return twMerge(clsx(inputs));
|
|
65
|
+
}`;
|
|
66
|
+
if (!(await fs_1.promises.stat(utilsDir).catch(() => null))) {
|
|
67
|
+
await fs_1.promises.mkdir(utilsDir, { recursive: true });
|
|
68
|
+
}
|
|
69
|
+
if (!(await fs_1.promises.stat(cnPath).catch(() => null))) {
|
|
70
|
+
await fs_1.promises.writeFile(cnPath, cnContent);
|
|
71
|
+
console.log(chalk_1.default.green("Created utils/cn.ts"));
|
|
72
|
+
}
|
|
57
73
|
console.log(chalk_1.default.green("Configuration saved to components.json"));
|
|
58
74
|
}
|
package/dist/debug.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
7
|
+
async function run() {
|
|
8
|
+
console.log('Node:', process.version);
|
|
9
|
+
const urls = [
|
|
10
|
+
'https://uniqueui-platform.vercel.app/registry.json',
|
|
11
|
+
'https://uniqueui-platform.vercel.app/api/registry',
|
|
12
|
+
'https://raw.githubusercontent.com/pras75299/uniqueui/main/registry.json'
|
|
13
|
+
];
|
|
14
|
+
for (const url of urls) {
|
|
15
|
+
try {
|
|
16
|
+
console.log(`\nTesting ${url}...`);
|
|
17
|
+
const res = await (0, node_fetch_1.default)(url);
|
|
18
|
+
console.log('Status:', res.status);
|
|
19
|
+
if (!res.ok) {
|
|
20
|
+
try {
|
|
21
|
+
const body = await res.text();
|
|
22
|
+
console.log('Error Body:', body.slice(0, 200));
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
console.log('No body');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
console.log('Success. Body length:', (await res.text()).length);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
console.error('Fetch Error:', e);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
run();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uniqueui-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "CLI to add beautiful animated UI components from UniqueUI to your React project",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -43,19 +43,20 @@
|
|
|
43
43
|
"node": ">=18"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"
|
|
46
|
+
"@types/node-fetch": "^2.6.13",
|
|
47
47
|
"chalk": "^4.1.2",
|
|
48
|
+
"commander": "^11.1.0",
|
|
48
49
|
"fs-extra": "^11.2.0",
|
|
49
|
-
"
|
|
50
|
-
"zod": "^3.22.4",
|
|
51
|
-
"node-fetch": "^3.3.2",
|
|
50
|
+
"node-fetch": "^2.7.0",
|
|
52
51
|
"ora": "^5.4.1",
|
|
53
|
-
"prompts": "^2.4.2"
|
|
52
|
+
"prompts": "^2.4.2",
|
|
53
|
+
"ts-morph": "^21.0.1",
|
|
54
|
+
"zod": "^3.22.4"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
57
|
+
"@types/fs-extra": "^11.0.4",
|
|
56
58
|
"@types/node": "^20.10.0",
|
|
57
|
-
"typescript": "^5.3.3",
|
|
58
59
|
"@types/prompts": "^2.4.9",
|
|
59
|
-
"
|
|
60
|
+
"typescript": "^5.3.3"
|
|
60
61
|
}
|
|
61
62
|
}
|